2020-04-15 22:56:27

by Xu Yilun

[permalink] [raw]
Subject: [PATCH v4 0/7] Add interrupt support to FPGA DFL drivers

This patchset add interrupt support to FPGA DFL drivers.

With these patches, DFL driver will parse and assign interrupt resources
for enumerated feature devices and their sub features.

This patchset also introduces a set of APIs for user to monitor DFL
interrupts. Three sub features (DFL FME error, DFL AFU error and user
interrupt) drivers now support these APIs.

Patch #1: DFL framework change. Accept interrupt info input from DFL bus
driver, and add interrupt parsing and assignment for feature
sub devices.
Patch #2: DFL pci driver change, add interrupt info on DFL enumeration.
Patch #3: DFL framework change. Add helper functions for feature sub
device drivers to handle interrupt and notify users.
Patch #4: Add interrupt support for AFU error reporting sub feature.
Patch #5: Add interrupt support for FME global error reporting sub
feature.
Patch #6: Add interrupt support for a new sub feature, to handle user
interrupts implemented in AFU.
Patch #7: Documentation for DFL interrupt handling.

Main changes from v1:
- Early validating irq table for each feature in parse_feature_irq()
in Patch #1.
- Changes IOCTL interfaces. use DFL_FPGA_FME/PORT_XXX_GET_IRQ_NUM
instead of DFL_FPGA_FME/PORT_XXX_GET_INFO, delete flag field for
DFL_FPGA_FME/PORT_XXX_SET_IRQ param

Main changes from v2:
- put parse_feature_irqs() inside create_feature_instance().
- refines code for dfl_fpga_set_irq_triggers, delete local variable j.
- put_user() instead of copy_to_user() for DFL_FPGA_XXX_GET_IRQ_NUM IOCTL

Main changes from v3:
- rebased to 5.7-rc1.
- fail the dfl enumeration when irq parsing error happens.
- Add 2 helper functions in dfl.c to handle generic irq ioctls in feature
drivers.

Xu Yilun (7):
fpga: dfl: parse interrupt info for feature devices on enumeration
fpga: dfl: pci: add irq info for feature devices enumeration
fpga: dfl: introduce interrupt trigger setting API
fpga: dfl: afu: add interrupt support for port error reporting
fpga: dfl: fme: add interrupt support for global error reporting
fpga: dfl: afu: add AFU interrupt support
Documentation: fpga: dfl: add descriptions for interrupt related
interfaces.

Documentation/fpga/dfl.rst | 19 +++
drivers/fpga/dfl-afu-error.c | 22 +++
drivers/fpga/dfl-afu-main.c | 36 +++++
drivers/fpga/dfl-fme-error.c | 23 ++++
drivers/fpga/dfl-fme-main.c | 6 +
drivers/fpga/dfl-pci.c | 80 +++++++++--
drivers/fpga/dfl.c | 311 ++++++++++++++++++++++++++++++++++++++++++
drivers/fpga/dfl.h | 57 ++++++++
include/uapi/linux/fpga-dfl.h | 82 +++++++++++
9 files changed, 627 insertions(+), 9 deletions(-)

--
2.7.4


2020-04-15 22:56:32

by Xu Yilun

[permalink] [raw]
Subject: [PATCH v4 4/7] fpga: dfl: afu: add interrupt support for port error reporting

Error reporting interrupt is very useful to notify users that some
errors are detected by the hardware. Once users are notified, they
could query hardware logged error states, no need to continuously
poll on these states.

This patch adds interrupt support for port error reporting sub feature.
It follows the common DFL interrupt notification and handling mechanism,
implements two ioctl commands below for user to query number of irqs
supported, and set/unset interrupt triggers.

Ioctls:
* DFL_FPGA_PORT_ERR_GET_IRQ_NUM
get the number of irqs, which is used to determine whether/how many
interrupts error reporting feature supports.

* DFL_FPGA_PORT_ERR_SET_IRQ
set/unset given eventfds as error interrupt triggers.

Signed-off-by: Luwei Kang <[email protected]>
Signed-off-by: Wu Hao <[email protected]>
Signed-off-by: Xu Yilun <[email protected]>
----
v2: use DFL_FPGA_PORT_ERR_GET_IRQ_NUM instead of
DFL_FPGA_PORT_ERR_GET_INFO
Delete flag field for DFL_FPGA_PORT_ERR_SET_IRQ param
v3: put_user() instead of copy_to_user()
improves comments
v4: use common functions to handle irq ioctls
---
drivers/fpga/dfl-afu-error.c | 22 ++++++++++++++++++++++
drivers/fpga/dfl-afu-main.c | 4 ++++
include/uapi/linux/fpga-dfl.h | 23 +++++++++++++++++++++++
3 files changed, 49 insertions(+)

diff --git a/drivers/fpga/dfl-afu-error.c b/drivers/fpga/dfl-afu-error.c
index c1467ae..facbd7b 100644
--- a/drivers/fpga/dfl-afu-error.c
+++ b/drivers/fpga/dfl-afu-error.c
@@ -15,6 +15,7 @@
*/

#include <linux/uaccess.h>
+#include <linux/fpga-dfl.h>

#include "dfl-afu.h"

@@ -219,6 +220,26 @@ static void port_err_uinit(struct platform_device *pdev,
afu_port_err_mask(&pdev->dev, true);
}

+static long
+port_err_ioctl(struct platform_device *pdev, struct dfl_feature *feature,
+ unsigned int cmd, unsigned long arg)
+{
+ long ret = -ENODEV;
+
+ switch (cmd) {
+ case DFL_FPGA_PORT_ERR_GET_IRQ_NUM:
+ ret = dfl_feature_ioctl_get_num_irqs(pdev, feature, arg);
+ break;
+ case DFL_FPGA_PORT_ERR_SET_IRQ:
+ ret = dfl_feature_ioctl_set_irq(pdev, feature, arg);
+ break;
+ default:
+ dev_dbg(&pdev->dev, "%x cmd not handled", cmd);
+ }
+
+ return ret;
+}
+
const struct dfl_feature_id port_err_id_table[] = {
{.id = PORT_FEATURE_ID_ERROR,},
{0,}
@@ -227,4 +248,5 @@ const struct dfl_feature_id port_err_id_table[] = {
const struct dfl_feature_ops port_err_ops = {
.init = port_err_init,
.uinit = port_err_uinit,
+ .ioctl = port_err_ioctl,
};
diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index b0c3178..357cd5d 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -577,6 +577,7 @@ static int afu_release(struct inode *inode, struct file *filp)
{
struct platform_device *pdev = filp->private_data;
struct dfl_feature_platform_data *pdata;
+ struct dfl_feature *feature;

dev_dbg(&pdev->dev, "Device File Release\n");

@@ -586,6 +587,9 @@ static int afu_release(struct inode *inode, struct file *filp)
dfl_feature_dev_use_end(pdata);

if (!dfl_feature_dev_use_count(pdata)) {
+ dfl_fpga_dev_for_each_feature(pdata, feature)
+ dfl_fpga_set_irq_triggers(feature, 0,
+ feature->nr_irqs, NULL);
__port_reset(pdev);
afu_dma_region_destroy(pdata);
}
diff --git a/include/uapi/linux/fpga-dfl.h b/include/uapi/linux/fpga-dfl.h
index 8a5979e..fbe1e99 100644
--- a/include/uapi/linux/fpga-dfl.h
+++ b/include/uapi/linux/fpga-dfl.h
@@ -164,6 +164,29 @@ struct dfl_fpga_irq_set {
__s32 evtfds[];
};

+/**
+ * DFL_FPGA_PORT_ERR_GET_IRQ_NUM - _IOR(DFL_FPGA_MAGIC, DFL_PORT_BASE + 5,
+ * __u32 num_irqs)
+ *
+ * Get the number of irqs supported by the fpga port error reporting private
+ * feature. Currently hardware supports up to 1 irq.
+ * Return: 0 on success, -errno on failure.
+ */
+#define DFL_FPGA_PORT_ERR_GET_IRQ_NUM _IOR(DFL_FPGA_MAGIC, \
+ DFL_PORT_BASE + 5, __u32)
+
+/**
+ * DFL_FPGA_PORT_ERR_SET_IRQ - _IOW(DFL_FPGA_MAGIC, DFL_PORT_BASE + 6,
+ * struct dfl_fpga_irq_set)
+ *
+ * Set fpga port error reporting interrupt trigger if evtfds[n] is valid.
+ * Unset related interrupt trigger if evtfds[n] is a negative value.
+ * Return: 0 on success, -errno on failure.
+ */
+#define DFL_FPGA_PORT_ERR_SET_IRQ _IOW(DFL_FPGA_MAGIC, \
+ DFL_PORT_BASE + 6, \
+ struct dfl_fpga_irq_set)
+
/* IOCTLs for FME file descriptor */

/**
--
2.7.4

2020-04-15 22:56:45

by Xu Yilun

[permalink] [raw]
Subject: [PATCH v4 7/7] Documentation: fpga: dfl: add descriptions for interrupt related interfaces.

This patch adds introductions of interrupt related interfaces for FME
error reporting, port error reporting and AFU user interrupts features.

Signed-off-by: Luwei Kang <[email protected]>
Signed-off-by: Wu Hao <[email protected]>
Signed-off-by: Xu Yilun <[email protected]>
----
v2: Update Documents cause change of irq ioctl interfaces.
v3: No change
v4: Update interrupt support part.
---
Documentation/fpga/dfl.rst | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/Documentation/fpga/dfl.rst b/Documentation/fpga/dfl.rst
index 094fc8a..702bf62 100644
--- a/Documentation/fpga/dfl.rst
+++ b/Documentation/fpga/dfl.rst
@@ -89,6 +89,8 @@ The following functions are exposed through ioctls:
- Program bitstream (DFL_FPGA_FME_PORT_PR)
- Assign port to PF (DFL_FPGA_FME_PORT_ASSIGN)
- Release port from PF (DFL_FPGA_FME_PORT_RELEASE)
+- Get number of irqs of FME global error (DFL_FPGA_FME_ERR_GET_IRQ_NUM)
+- Set interrupt trigger for FME error (DFL_FPGA_FME_ERR_SET_IRQ)

More functions are exposed through sysfs
(/sys/class/fpga_region/regionX/dfl-fme.n/):
@@ -144,6 +146,10 @@ The following functions are exposed through ioctls:
- Map DMA buffer (DFL_FPGA_PORT_DMA_MAP)
- Unmap DMA buffer (DFL_FPGA_PORT_DMA_UNMAP)
- Reset AFU (DFL_FPGA_PORT_RESET)
+- Get number of irqs of port error (DFL_FPGA_PORT_ERR_GET_IRQ_NUM)
+- Set interrupt trigger for port error (DFL_FPGA_PORT_ERR_SET_IRQ)
+- Get number of irqs of UINT (DFL_FPGA_PORT_UINT_GET_IRQ_NUM)
+- Set interrupt trigger for UINT (DFL_FPGA_PORT_UINT_SET_IRQ)

DFL_FPGA_PORT_RESET:
reset the FPGA Port and its AFU. Userspace can do Port
@@ -378,6 +384,19 @@ The device nodes used for ioctl() or mmap() can be referenced through::
/sys/class/fpga_region/<regionX>/<dfl-port.n>/dev


+Interrupt support
+=================
+Some FME and AFU private features are able to generate interrupts. As mentioned
+above, users could call ioctl (DFL_FPGA_*_GET_IRQ_NUM) to know whether or how
+many interrupts are supported for this private feature. Drivers also implement
+an eventfd based interrupt handling mechanism for users to get notified when
+interrupt happens. Users could set eventfds to driver via
+ioctl (DFL_FPGA_*_SET_IRQ), and then poll/select on these eventfds waiting for
+notification.
+In Current DFL, 3 sub features (Port error, FME global error and AFU interrupt)
+support interrupts.
+
+
Add new FIUs support
====================
It's possible that developers made some new function blocks (FIUs) under this
--
2.7.4

2020-04-15 22:56:50

by Xu Yilun

[permalink] [raw]
Subject: [PATCH v4 5/7] fpga: dfl: fme: add interrupt support for global error reporting

Error reporting interrupt is very useful to notify users that some
errors are detected by the hardware. Once users are notified, they
could query hardware logged error states, no need to continuously
poll on these states.

This patch adds interrupt support for fme global error reporting sub
feature. It follows the common DFL interrupt notification and handling
mechanism. And it implements two ioctls below for user to query
number of irqs supported, and set/unset interrupt triggers.

Ioctls:
* DFL_FPGA_FME_ERR_GET_IRQ_NUM
get the number of irqs, which is used to determine whether/how many
interrupts fme error reporting feature supports.

* DFL_FPGA_FME_ERR_SET_IRQ
set/unset given eventfds as fme error reporting interrupt triggers.

Signed-off-by: Luwei Kang <[email protected]>
Signed-off-by: Wu Hao <[email protected]>
Signed-off-by: Xu Yilun <[email protected]>
----
v2: use DFL_FPGA_FME_ERR_GET_IRQ_NUM instead of
DFL_FPGA_FME_ERR_GET_INFO
Delete flags field for DFL_FPGA_FME_ERR_SET_IRQ
v3: put_user() instead of copy_to_user()
improves comments
v4: use common functions to handle irq ioctls
---
drivers/fpga/dfl-fme-error.c | 23 +++++++++++++++++++++++
drivers/fpga/dfl-fme-main.c | 6 ++++++
include/uapi/linux/fpga-dfl.h | 23 +++++++++++++++++++++++
3 files changed, 52 insertions(+)

diff --git a/drivers/fpga/dfl-fme-error.c b/drivers/fpga/dfl-fme-error.c
index f897d41..a4cbf8c 100644
--- a/drivers/fpga/dfl-fme-error.c
+++ b/drivers/fpga/dfl-fme-error.c
@@ -16,6 +16,7 @@
*/

#include <linux/uaccess.h>
+#include <linux/fpga-dfl.h>

#include "dfl.h"
#include "dfl-fme.h"
@@ -348,6 +349,27 @@ static void fme_global_err_uinit(struct platform_device *pdev,
fme_err_mask(&pdev->dev, true);
}

+static long
+fme_global_error_ioctl(struct platform_device *pdev,
+ struct dfl_feature *feature,
+ unsigned int cmd, unsigned long arg)
+{
+ long ret = -ENODEV;
+
+ switch (cmd) {
+ case DFL_FPGA_FME_ERR_GET_IRQ_NUM:
+ ret = dfl_feature_ioctl_get_num_irqs(pdev, feature, arg);
+ break;
+ case DFL_FPGA_FME_ERR_SET_IRQ:
+ ret = dfl_feature_ioctl_set_irq(pdev, feature, arg);
+ break;
+ default:
+ dev_dbg(&pdev->dev, "%x cmd not handled", cmd);
+ }
+
+ return ret;
+}
+
const struct dfl_feature_id fme_global_err_id_table[] = {
{.id = FME_FEATURE_ID_GLOBAL_ERR,},
{0,}
@@ -356,4 +378,5 @@ const struct dfl_feature_id fme_global_err_id_table[] = {
const struct dfl_feature_ops fme_global_err_ops = {
.init = fme_global_err_init,
.uinit = fme_global_err_uinit,
+ .ioctl = fme_global_error_ioctl,
};
diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c
index 56d720c..ab3722d 100644
--- a/drivers/fpga/dfl-fme-main.c
+++ b/drivers/fpga/dfl-fme-main.c
@@ -616,11 +616,17 @@ static int fme_release(struct inode *inode, struct file *filp)
{
struct dfl_feature_platform_data *pdata = filp->private_data;
struct platform_device *pdev = pdata->dev;
+ struct dfl_feature *feature;

dev_dbg(&pdev->dev, "Device File Release\n");

mutex_lock(&pdata->lock);
dfl_feature_dev_use_end(pdata);
+
+ if (!dfl_feature_dev_use_count(pdata))
+ dfl_fpga_dev_for_each_feature(pdata, feature)
+ dfl_fpga_set_irq_triggers(feature, 0,
+ feature->nr_irqs, NULL);
mutex_unlock(&pdata->lock);

return 0;
diff --git a/include/uapi/linux/fpga-dfl.h b/include/uapi/linux/fpga-dfl.h
index fbe1e99..9e12fff 100644
--- a/include/uapi/linux/fpga-dfl.h
+++ b/include/uapi/linux/fpga-dfl.h
@@ -230,4 +230,27 @@ struct dfl_fpga_fme_port_pr {
*/
#define DFL_FPGA_FME_PORT_ASSIGN _IOW(DFL_FPGA_MAGIC, DFL_FME_BASE + 2, int)

+/**
+ * DFL_FPGA_FME_ERR_GET_IRQ_NUM - _IOR(DFL_FPGA_MAGIC, DFL_FME_BASE + 3,
+ * __u32 num_irqs)
+ *
+ * Get the number of irqs supported by the fpga fme error reporting private
+ * feature. Currently hardware supports up to 1 irq.
+ * Return: 0 on success, -errno on failure.
+ */
+#define DFL_FPGA_FME_ERR_GET_IRQ_NUM _IOR(DFL_FPGA_MAGIC, \
+ DFL_FME_BASE + 3, __u32)
+
+/**
+ * DFL_FPGA_FME_ERR_SET_IRQ - _IOW(DFL_FPGA_MAGIC, DFL_FME_BASE + 4,
+ * struct dfl_fpga_irq_set)
+ *
+ * Set fpga fme error reporting interrupt trigger if evtfds[n] is valid.
+ * Unset related interrupt trigger if evtfds[n] is a negative value.
+ * Return: 0 on success, -errno on failure.
+ */
+#define DFL_FPGA_FME_ERR_SET_IRQ _IOW(DFL_FPGA_MAGIC, \
+ DFL_FME_BASE + 4, \
+ struct dfl_fpga_irq_set)
+
#endif /* _UAPI_LINUX_FPGA_DFL_H */
--
2.7.4

2020-04-16 09:47:31

by Wu Hao

[permalink] [raw]
Subject: RE: [PATCH v4 4/7] fpga: dfl: afu: add interrupt support for port error reporting

> -----Original Message-----
> From: Xu, Yilun <[email protected]>
> Sent: Wednesday, April 15, 2020 6:08 PM
> To: [email protected]; [email protected]; linux-
> [email protected]
> Cc: [email protected]; [email protected]; Xu, Yilun <[email protected]>;
> Kang, Luwei <[email protected]>; Wu, Hao <[email protected]>
> Subject: [PATCH v4 4/7] fpga: dfl: afu: add interrupt support for port error
> reporting
>
> Error reporting interrupt is very useful to notify users that some
> errors are detected by the hardware. Once users are notified, they
> could query hardware logged error states, no need to continuously
> poll on these states.
>
> This patch adds interrupt support for port error reporting sub feature.
> It follows the common DFL interrupt notification and handling mechanism,
> implements two ioctl commands below for user to query number of irqs
> supported, and set/unset interrupt triggers.
>
> Ioctls:
> * DFL_FPGA_PORT_ERR_GET_IRQ_NUM
> get the number of irqs, which is used to determine whether/how many
> interrupts error reporting feature supports.
>
> * DFL_FPGA_PORT_ERR_SET_IRQ
> set/unset given eventfds as error interrupt triggers.
>
> Signed-off-by: Luwei Kang <[email protected]>
> Signed-off-by: Wu Hao <[email protected]>
> Signed-off-by: Xu Yilun <[email protected]>
> ----
> v2: use DFL_FPGA_PORT_ERR_GET_IRQ_NUM instead of
> DFL_FPGA_PORT_ERR_GET_INFO
> Delete flag field for DFL_FPGA_PORT_ERR_SET_IRQ param
> v3: put_user() instead of copy_to_user()
> improves comments
> v4: use common functions to handle irq ioctls
> ---
> drivers/fpga/dfl-afu-error.c | 22 ++++++++++++++++++++++
> drivers/fpga/dfl-afu-main.c | 4 ++++
> include/uapi/linux/fpga-dfl.h | 23 +++++++++++++++++++++++
> 3 files changed, 49 insertions(+)
>
> diff --git a/drivers/fpga/dfl-afu-error.c b/drivers/fpga/dfl-afu-error.c
> index c1467ae..facbd7b 100644
> --- a/drivers/fpga/dfl-afu-error.c
> +++ b/drivers/fpga/dfl-afu-error.c
> @@ -15,6 +15,7 @@
> */
>
> #include <linux/uaccess.h>
> +#include <linux/fpga-dfl.h>

Same. : )

>
> #include "dfl-afu.h"
>
> @@ -219,6 +220,26 @@ static void port_err_uinit(struct platform_device
> *pdev,
> afu_port_err_mask(&pdev->dev, true);
> }
>
> +static long
> +port_err_ioctl(struct platform_device *pdev, struct dfl_feature *feature,
> + unsigned int cmd, unsigned long arg)
> +{
> + long ret = -ENODEV;
> +
> + switch (cmd) {
> + case DFL_FPGA_PORT_ERR_GET_IRQ_NUM:
> + ret = dfl_feature_ioctl_get_num_irqs(pdev, feature, arg);
> + break;
> + case DFL_FPGA_PORT_ERR_SET_IRQ:
> + ret = dfl_feature_ioctl_set_irq(pdev, feature, arg);
> + break;
> + default:
> + dev_dbg(&pdev->dev, "%x cmd not handled", cmd);
> + }
> +
> + return ret;
> +}

Looks like we don't have to introduce this local 'ret'.

With above fixings:

Acked-by: Wu Hao <[email protected]>

Thanks
Hao

2020-04-16 09:50:19

by Wu Hao

[permalink] [raw]
Subject: RE: [PATCH v4 5/7] fpga: dfl: fme: add interrupt support for global error reporting

> -----Original Message-----
> From: Xu, Yilun <[email protected]>
> Sent: Wednesday, April 15, 2020 6:08 PM
> To: [email protected]; [email protected]; linux-
> [email protected]
> Cc: [email protected]; [email protected]; Xu, Yilun <[email protected]>;
> Kang, Luwei <[email protected]>; Wu, Hao <[email protected]>
> Subject: [PATCH v4 5/7] fpga: dfl: fme: add interrupt support for global error
> reporting
>
> Error reporting interrupt is very useful to notify users that some
> errors are detected by the hardware. Once users are notified, they
> could query hardware logged error states, no need to continuously
> poll on these states.
>
> This patch adds interrupt support for fme global error reporting sub
> feature. It follows the common DFL interrupt notification and handling
> mechanism. And it implements two ioctls below for user to query
> number of irqs supported, and set/unset interrupt triggers.
>
> Ioctls:
> * DFL_FPGA_FME_ERR_GET_IRQ_NUM
> get the number of irqs, which is used to determine whether/how many
> interrupts fme error reporting feature supports.
>
> * DFL_FPGA_FME_ERR_SET_IRQ
> set/unset given eventfds as fme error reporting interrupt triggers.
>
> Signed-off-by: Luwei Kang <[email protected]>
> Signed-off-by: Wu Hao <[email protected]>
> Signed-off-by: Xu Yilun <[email protected]>
> ----
> v2: use DFL_FPGA_FME_ERR_GET_IRQ_NUM instead of
> DFL_FPGA_FME_ERR_GET_INFO
> Delete flags field for DFL_FPGA_FME_ERR_SET_IRQ
> v3: put_user() instead of copy_to_user()
> improves comments
> v4: use common functions to handle irq ioctls
> ---
> drivers/fpga/dfl-fme-error.c | 23 +++++++++++++++++++++++
> drivers/fpga/dfl-fme-main.c | 6 ++++++
> include/uapi/linux/fpga-dfl.h | 23 +++++++++++++++++++++++
> 3 files changed, 52 insertions(+)
>
> diff --git a/drivers/fpga/dfl-fme-error.c b/drivers/fpga/dfl-fme-error.c
> index f897d41..a4cbf8c 100644
> --- a/drivers/fpga/dfl-fme-error.c
> +++ b/drivers/fpga/dfl-fme-error.c
> @@ -16,6 +16,7 @@
> */
>
> #include <linux/uaccess.h>
> +#include <linux/fpga-dfl.h>
>
> #include "dfl.h"
> #include "dfl-fme.h"
> @@ -348,6 +349,27 @@ static void fme_global_err_uinit(struct
> platform_device *pdev,
> fme_err_mask(&pdev->dev, true);
> }
>
> +static long
> +fme_global_error_ioctl(struct platform_device *pdev,
> + struct dfl_feature *feature,
> + unsigned int cmd, unsigned long arg)
> +{
> + long ret = -ENODEV;

Same case for patch #5 and #6.
Other place looks good to me.

Thanks
Hao

> +
> + switch (cmd) {
> + case DFL_FPGA_FME_ERR_GET_IRQ_NUM:
> + ret = dfl_feature_ioctl_get_num_irqs(pdev, feature, arg);
> + break;
> + case DFL_FPGA_FME_ERR_SET_IRQ:
> + ret = dfl_feature_ioctl_set_irq(pdev, feature, arg);
> + break;
> + default:
> + dev_dbg(&pdev->dev, "%x cmd not handled", cmd);
> + }
> +
> + return ret;
> +}
> +
> const struct dfl_feature_id fme_global_err_id_table[] = {
> {.id = FME_FEATURE_ID_GLOBAL_ERR,},
> {0,}
> @@ -356,4 +378,5 @@ const struct dfl_feature_id fme_global_err_id_table[]
> = {
> const struct dfl_feature_ops fme_global_err_ops = {
> .init = fme_global_err_init,
> .uinit = fme_global_err_uinit,
> + .ioctl = fme_global_error_ioctl,
> };
> diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c
> index 56d720c..ab3722d 100644
> --- a/drivers/fpga/dfl-fme-main.c
> +++ b/drivers/fpga/dfl-fme-main.c
> @@ -616,11 +616,17 @@ static int fme_release(struct inode *inode, struct
> file *filp)
> {
> struct dfl_feature_platform_data *pdata = filp->private_data;
> struct platform_device *pdev = pdata->dev;
> + struct dfl_feature *feature;
>
> dev_dbg(&pdev->dev, "Device File Release\n");
>
> mutex_lock(&pdata->lock);
> dfl_feature_dev_use_end(pdata);
> +
> + if (!dfl_feature_dev_use_count(pdata))
> + dfl_fpga_dev_for_each_feature(pdata, feature)
> + dfl_fpga_set_irq_triggers(feature, 0,
> + feature->nr_irqs, NULL);
> mutex_unlock(&pdata->lock);
>
> return 0;
> diff --git a/include/uapi/linux/fpga-dfl.h b/include/uapi/linux/fpga-dfl.h
> index fbe1e99..9e12fff 100644
> --- a/include/uapi/linux/fpga-dfl.h
> +++ b/include/uapi/linux/fpga-dfl.h
> @@ -230,4 +230,27 @@ struct dfl_fpga_fme_port_pr {
> */
> #define DFL_FPGA_FME_PORT_ASSIGN _IOW(DFL_FPGA_MAGIC,
> DFL_FME_BASE + 2, int)
>
> +/**
> + * DFL_FPGA_FME_ERR_GET_IRQ_NUM - _IOR(DFL_FPGA_MAGIC,
> DFL_FME_BASE + 3,
> + * __u32 num_irqs)
> + *
> + * Get the number of irqs supported by the fpga fme error reporting private
> + * feature. Currently hardware supports up to 1 irq.
> + * Return: 0 on success, -errno on failure.
> + */
> +#define DFL_FPGA_FME_ERR_GET_IRQ_NUM _IOR(DFL_FPGA_MAGIC,
> \
> + DFL_FME_BASE + 3, __u32)
> +
> +/**
> + * DFL_FPGA_FME_ERR_SET_IRQ - _IOW(DFL_FPGA_MAGIC, DFL_FME_BASE
> + 4,
> + * struct dfl_fpga_irq_set)
> + *
> + * Set fpga fme error reporting interrupt trigger if evtfds[n] is valid.
> + * Unset related interrupt trigger if evtfds[n] is a negative value.
> + * Return: 0 on success, -errno on failure.
> + */
> +#define DFL_FPGA_FME_ERR_SET_IRQ _IOW(DFL_FPGA_MAGIC,
> \
> + DFL_FME_BASE + 4, \
> + struct dfl_fpga_irq_set)
> +
> #endif /* _UAPI_LINUX_FPGA_DFL_H */
> --
> 2.7.4