fpga: dfl: support multiple opens on feature device node.
Each DFL functional block, e.g. AFU (Accelerated Function Unit) and FME (FPGA Management Engine), could implement more than one function within its region, but current driver only allows one user application to access it by exclusive open on device node. So this is not convenient and flexible for userspace applications, as they have to combine lots of different functions into one single application. This patch removes the limitation here to allow multiple opens to each feature device node for AFU and FME from userspace applications. If user still needs exclusive access to these device node, O_EXCL flag must be issued together with open. Signed-off-by: Wu Hao <hao.wu@intel.com> Signed-off-by: Xu Yilun <yilun.xu@intel.com> Signed-off-by: Moritz Fischer <mdf@kernel.org>
This commit is contained in:
@@ -561,14 +561,16 @@ static int afu_open(struct inode *inode, struct file *filp)
|
||||
if (WARN_ON(!pdata))
|
||||
return -ENODEV;
|
||||
|
||||
ret = dfl_feature_dev_use_begin(pdata);
|
||||
if (ret)
|
||||
return ret;
|
||||
mutex_lock(&pdata->lock);
|
||||
ret = dfl_feature_dev_use_begin(pdata, filp->f_flags & O_EXCL);
|
||||
if (!ret) {
|
||||
dev_dbg(&fdev->dev, "Device File Opened %d Times\n",
|
||||
dfl_feature_dev_use_count(pdata));
|
||||
filp->private_data = fdev;
|
||||
}
|
||||
mutex_unlock(&pdata->lock);
|
||||
|
||||
dev_dbg(&fdev->dev, "Device File Open\n");
|
||||
filp->private_data = fdev;
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int afu_release(struct inode *inode, struct file *filp)
|
||||
@@ -581,12 +583,14 @@ static int afu_release(struct inode *inode, struct file *filp)
|
||||
pdata = dev_get_platdata(&pdev->dev);
|
||||
|
||||
mutex_lock(&pdata->lock);
|
||||
__port_reset(pdev);
|
||||
afu_dma_region_destroy(pdata);
|
||||
mutex_unlock(&pdata->lock);
|
||||
|
||||
dfl_feature_dev_use_end(pdata);
|
||||
|
||||
if (!dfl_feature_dev_use_count(pdata)) {
|
||||
__port_reset(pdev);
|
||||
afu_dma_region_destroy(pdata);
|
||||
}
|
||||
mutex_unlock(&pdata->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user