Skip to content

Commit 29de762

Browse files
Kang Luweigregkh
authored andcommitted
fpga: dfl: fme: add partial reconfiguration sub feature support
Partial Reconfiguration (PR) is the most important function for FME. It allows reconfiguration for given Port/Accelerated Function Unit (AFU). It creates platform devices for fpga-mgr, fpga-regions and fpga-bridges, and invokes fpga-region's interface (fpga_region_program_fpga) for PR operation once PR request received via ioctl. Below user space interface is exposed by this sub feature. Ioctl interface: * DFL_FPGA_FME_PORT_PR Do partial reconfiguration per information from userspace, including target port(AFU), buffer size and address info. It returns error code to userspace if failed. For detailed PR error information, user needs to read fpga-mgr's status sysfs interface. Signed-off-by: Tim Whisonant <[email protected]> Signed-off-by: Enno Luebbers <[email protected]> Signed-off-by: Shiva Rao <[email protected]> Signed-off-by: Christopher Rauer <[email protected]> Signed-off-by: Kang Luwei <[email protected]> Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Wu Hao <[email protected]> Acked-by: Alan Tull <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 620e190 commit 29de762

File tree

6 files changed

+671
-2
lines changed

6 files changed

+671
-2
lines changed

drivers/fpga/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ obj-$(CONFIG_OF_FPGA_REGION) += of-fpga-region.o
3333
obj-$(CONFIG_FPGA_DFL) += dfl.o
3434
obj-$(CONFIG_FPGA_DFL_FME) += dfl-fme.o
3535

36-
dfl-fme-objs := dfl-fme-main.o
36+
dfl-fme-objs := dfl-fme-main.o dfl-fme-pr.o
3737

3838
# Drivers for FPGAs which implement DFL
3939
obj-$(CONFIG_FPGA_DFL_PCI) += dfl-pci.o

drivers/fpga/dfl-fme-main.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/fpga-dfl.h>
2020

2121
#include "dfl.h"
22+
#include "dfl-fme.h"
2223

2324
static ssize_t ports_num_show(struct device *dev,
2425
struct device_attribute *attr, char *buf)
@@ -112,6 +113,10 @@ static struct dfl_feature_driver fme_feature_drvs[] = {
112113
.id = FME_FEATURE_ID_HEADER,
113114
.ops = &fme_hdr_ops,
114115
},
116+
{
117+
.id = FME_FEATURE_ID_PR_MGMT,
118+
.ops = &pr_mgmt_ops,
119+
},
115120
{
116121
.ops = NULL,
117122
},
@@ -187,6 +192,35 @@ static long fme_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
187192
return -EINVAL;
188193
}
189194

195+
static int fme_dev_init(struct platform_device *pdev)
196+
{
197+
struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
198+
struct dfl_fme *fme;
199+
200+
fme = devm_kzalloc(&pdev->dev, sizeof(*fme), GFP_KERNEL);
201+
if (!fme)
202+
return -ENOMEM;
203+
204+
fme->pdata = pdata;
205+
206+
mutex_lock(&pdata->lock);
207+
dfl_fpga_pdata_set_private(pdata, fme);
208+
mutex_unlock(&pdata->lock);
209+
210+
return 0;
211+
}
212+
213+
static void fme_dev_destroy(struct platform_device *pdev)
214+
{
215+
struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
216+
struct dfl_fme *fme;
217+
218+
mutex_lock(&pdata->lock);
219+
fme = dfl_fpga_pdata_get_private(pdata);
220+
dfl_fpga_pdata_set_private(pdata, NULL);
221+
mutex_unlock(&pdata->lock);
222+
}
223+
190224
static const struct file_operations fme_fops = {
191225
.owner = THIS_MODULE,
192226
.open = fme_open,
@@ -198,10 +232,14 @@ static int fme_probe(struct platform_device *pdev)
198232
{
199233
int ret;
200234

201-
ret = dfl_fpga_dev_feature_init(pdev, fme_feature_drvs);
235+
ret = fme_dev_init(pdev);
202236
if (ret)
203237
goto exit;
204238

239+
ret = dfl_fpga_dev_feature_init(pdev, fme_feature_drvs);
240+
if (ret)
241+
goto dev_destroy;
242+
205243
ret = dfl_fpga_dev_ops_register(pdev, &fme_fops, THIS_MODULE);
206244
if (ret)
207245
goto feature_uinit;
@@ -210,6 +248,8 @@ static int fme_probe(struct platform_device *pdev)
210248

211249
feature_uinit:
212250
dfl_fpga_dev_feature_uinit(pdev);
251+
dev_destroy:
252+
fme_dev_destroy(pdev);
213253
exit:
214254
return ret;
215255
}
@@ -218,6 +258,7 @@ static int fme_remove(struct platform_device *pdev)
218258
{
219259
dfl_fpga_dev_ops_unregister(pdev);
220260
dfl_fpga_dev_feature_uinit(pdev);
261+
fme_dev_destroy(pdev);
221262

222263
return 0;
223264
}

0 commit comments

Comments
 (0)