Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions XVSEC/linux-kernel/drv/xvsec_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static int xvsec_gen_open(struct inode *inode, struct file *filep)
dev_ctx = container_of(inode->i_cdev,
struct context, generic_cdev.cdev);

spin_lock(&dev_ctx->lock);
mutex_lock(&dev_ctx->lock);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps mutex_lock_interruptible() is more appropriate.


if (dev_ctx->fopen_cnt != 0) {
ret = -(EBUSY);
Expand All @@ -242,7 +242,7 @@ static int xvsec_gen_open(struct inode *inode, struct file *filep)
pr_info("%s success\n", __func__);

CLEANUP:
spin_unlock(&dev_ctx->lock);
mutex_unlock(&dev_ctx->lock);
return ret;
}

Expand All @@ -251,15 +251,15 @@ static int xvsec_gen_close(struct inode *inode, struct file *filep)
struct file_priv *priv = filep->private_data;
struct context *dev_ctx = (struct context *)priv->dev_ctx;

spin_lock(&dev_ctx->lock);
mutex_lock(&dev_ctx->lock);
if (dev_ctx->fopen_cnt == 0) {
pr_warn("File Open/close mismatch\n");
} else {
dev_ctx->fopen_cnt--;
pr_info("%s success\n", __func__);
}
kfree(priv);
spin_unlock(&dev_ctx->lock);
mutex_unlock(&dev_ctx->lock);

return 0;
}
Expand All @@ -273,11 +273,11 @@ static long xvsec_ioc_get_cap_list(struct file *filep,

pr_debug("ioctl : IOC_XVSEC_GET_CAP_LIST\n");

spin_lock(&dev_ctx->lock);
mutex_lock(&dev_ctx->lock);
ret = copy_to_user((void __user *)arg,
(void *)&dev_ctx->capabilities,
sizeof(struct xvsec_capabilities));
spin_unlock(&dev_ctx->lock);
mutex_unlock(&dev_ctx->lock);

return ret;
}
Expand Down Expand Up @@ -312,9 +312,9 @@ static long xvsec_ioc_get_device_info(struct file *filep,

pr_debug("ioctl : IOC_GET_DEVICE_INFO\n");

spin_lock(&dev_ctx->lock);
mutex_lock(&dev_ctx->lock);
ret = xvsec_get_dev_info(dev_ctx, &dev_info);
spin_unlock(&dev_ctx->lock);
mutex_unlock(&dev_ctx->lock);

if (ret < 0)
goto CLEANUP;
Expand Down Expand Up @@ -382,7 +382,7 @@ static int xvsec_initialize(struct pci_dev *pdev, struct context *dev_ctx)
return ret;
}

spin_lock_init(&dev_ctx->lock);
mutex_init(&dev_ctx->lock);
ret = xvsec_cdev_create(pdev,
&dev_ctx->generic_cdev, &xvsec_gen_fops, NULL);
if (ret < 0) {
Expand Down
4 changes: 2 additions & 2 deletions XVSEC/linux-kernel/drv/xvsec_drv_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct xvsec_ioctl_ops {

struct vsec_context {
struct pci_dev *pdev;
spinlock_t lock;
struct mutex lock;
struct cdev_info char_dev;
int fopen_cnt;
uint16_t vsec_offset;
Expand All @@ -97,7 +97,7 @@ struct vsec_ops {
struct context {
struct pci_dev *pdev;
int fopen_cnt;
spinlock_t lock;
struct mutex lock;
struct cdev_info generic_cdev;
uint16_t vsec_supported_cnt;
struct vsec_context *vsec_ctx;
Expand Down
78 changes: 39 additions & 39 deletions XVSEC/linux-kernel/drv/xvsec_mcap/xvsec_mcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static int xvsec_mcap_open(struct inode *inode, struct file *filep)

pr_info("%s: mcap_ctx address : %p\n", __func__, mcap_ctx);

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);

if (mcap_ctx->fopen_cnt != 0) {
ret = -(EBUSY);
Expand All @@ -180,7 +180,7 @@ static int xvsec_mcap_open(struct inode *inode, struct file *filep)
pr_debug("%s success\n", __func__);

CLEANUP:
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);
return ret;
}

Expand All @@ -189,7 +189,7 @@ static int xvsec_mcap_close(struct inode *inode, struct file *filep)
struct file_priv_mcap *priv = filep->private_data;
struct vsec_context *mcap_ctx = (struct vsec_context *)priv->ctx;

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);

if (mcap_ctx->fopen_cnt == 0) {
pr_warn("File Open/close mismatch\n");
Expand All @@ -199,7 +199,7 @@ static int xvsec_mcap_close(struct inode *inode, struct file *filep)
}
kfree(priv);

spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

return 0;
}
Expand Down Expand Up @@ -236,9 +236,9 @@ static long xvsec_ioc_mcap_reset(struct file *filep,

pr_debug("ioctl : IOC_MCAP_RESET\n");

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->reset(mcap_ctx);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

return ret;

Expand All @@ -256,9 +256,9 @@ static long xvsec_ioc_mcap_module_reset(struct file *filep,

pr_debug("ioctl : IOC_MCAP_MODULE_RESET\n");

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->module_reset(mcap_ctx);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

return ret;
}
Expand All @@ -275,9 +275,9 @@ static long xvsec_ioc_mcap_full_reset(struct file *filep,

pr_debug("ioctl : IOC_MCAP_FULL_RESET\n");

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->full_reset(mcap_ctx);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

return ret;
}
Expand All @@ -296,9 +296,9 @@ static long xvsec_ioc_get_mcap_revision(struct file *filep,

pr_debug("ioctl : IOC_MCAP_GET_REVISION\n");

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->get_revision(mcap_ctx, &vsec_id, &rev_id);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

if (ret == 0) {
pr_debug("vsec_id: %d, rev_id: %d\n", vsec_id, rev_id);
Expand All @@ -322,9 +322,9 @@ static long xvsec_ioc_get_data_regs(struct file *filep,

pr_debug("ioctl : IOC_MCAP_GET_DATA_REGISTERS\n");

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->get_data_regs(mcap_ctx, read_data_reg);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

memset(read_data_reg, 0, sizeof(read_data_reg));
if (ret == 0) {
Expand All @@ -351,9 +351,9 @@ static long xvsec_ioc_get_regs(struct file *filep,

memset(&mcap_regs, 0, sizeof(union mcap_regs));

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->get_regs(mcap_ctx, &mcap_regs);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

if (ret == 0) {
ret = copy_to_user((void __user *)arg,
Expand All @@ -378,9 +378,9 @@ static long xvsec_ioc_get_fpga_regs(struct file *filep,

memset(&fpga_cfg_regs, 0, sizeof(union fpga_cfg_regs));

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->get_fpga_regs(mcap_ctx, &fpga_cfg_regs);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

if (ret == 0) {
ret = copy_to_user((void __user *)arg,
Expand Down Expand Up @@ -409,9 +409,9 @@ static long xvsec_ioc_prog_bitstream(struct file *filep,
if (ret != 0)
goto CLEANUP;

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->program_bitstream(mcap_ctx, &bit_files);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

if (ret < 0)
goto CLEANUP;
Expand Down Expand Up @@ -442,9 +442,9 @@ static long xvsec_ioc_rd_dev_cfg_reg(struct file *filep,
if (ret != 0)
goto CLEANUP;

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->rd_cfg_addr(mcap_ctx, &rw_cfg_data);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

if (ret < 0)
goto CLEANUP;
Expand Down Expand Up @@ -475,9 +475,9 @@ static long xvsec_ioc_wr_dev_cfg_reg(struct file *filep,
if (ret != 0)
goto CLEANUP;

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->wr_cfg_addr(mcap_ctx, &rw_cfg_data);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

CLEANUP:
return ret;
Expand All @@ -502,9 +502,9 @@ static long xvsec_ioc_rd_fpga_cfg_reg(struct file *filep,
if (ret != 0)
goto CLEANUP;

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->fpga_rd_cfg_addr(mcap_ctx, &fpga_cfg_data);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

if (ret != 0)
goto CLEANUP;
Expand Down Expand Up @@ -534,9 +534,9 @@ static long xvsec_ioc_wr_fpga_cfg_reg(struct file *filep,
if (ret != 0)
goto CLEANUP;

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->fpga_wr_cfg_addr(mcap_ctx, &fpga_cfg_data);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);
CLEANUP:
return ret;
}
Expand All @@ -560,9 +560,9 @@ static long xvsec_ioc_read_axi_reg(struct file *filep,
goto CLEANUP;


spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->axi_rd_addr(mcap_ctx, &axi_rd_info);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

if (ret == 0) {
ret = copy_to_user((void __user *)arg,
Expand Down Expand Up @@ -592,9 +592,9 @@ static long xvsec_ioc_write_axi_reg(struct file *filep,
goto CLEANUP;


spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->axi_wr_addr(mcap_ctx, &axi_wr_info);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

CLEANUP:
return ret;
Expand All @@ -619,9 +619,9 @@ static long xvsec_ioc_file_download(struct file *filep,
if (ret != 0)
goto CLEANUP;

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->file_download(mcap_ctx, &file_args);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

rv = copy_to_user((void __user *)arg, (void *)&file_args,
sizeof(union file_download_upload));
Expand Down Expand Up @@ -652,9 +652,9 @@ static long xvsec_ioc_file_upload(struct file *filep,
if (ret != 0)
goto CLEANUP;

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->file_upload(mcap_ctx, &file_args);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

rv = copy_to_user((void __user *)arg, (void *)&file_args,
sizeof(union file_download_upload));
Expand Down Expand Up @@ -684,9 +684,9 @@ static long xvsec_ioc_set_axi_attr(struct file *filep,
if (ret != 0)
goto CLEANUP;

spin_lock(&mcap_ctx->lock);
mutex_lock(&mcap_ctx->lock);
ret = mcap_fops->set_axi_cache_attr(mcap_ctx, &axi_attr_info);
spin_unlock(&mcap_ctx->lock);
mutex_unlock(&mcap_ctx->lock);

if (ret != 0)
goto CLEANUP;
Expand Down Expand Up @@ -769,7 +769,7 @@ int xvsec_mcap_module_init(struct vsec_context *mcap_ctx)

pr_info("%s: mcap_ctx address : %p\n", __func__, mcap_ctx);

spin_lock_init(&mcap_ctx->lock);
mutex_init(&mcap_ctx->lock);
mcap_priv_ctx = kzalloc(sizeof(struct mcap_priv_ctx), GFP_KERNEL);
if (mcap_priv_ctx == NULL)
return -(ENOMEM);
Expand Down