Skip to contentSkip to conversation

Intel FPGA Device Drivers

PATCH In review Wu Hao 5 participants 98 messages Nov 27, 2017 – Feb 13, 2018 Page 2 of 2

Subsystems (4)
lore
Share & tools
lore
Acked-by on v3 16/21
#83 lore raw

Re: [PATCH v3 16/21] fpga: dfl: add fpga region platform driver for FME

In reply to Wu Hao

On Mon, Nov 27, 2017 at 12:42 AM, Wu Hao <[email protected]> wrote:

Hi Hao,

Just fix the SPDX, otherwise it looks good.

Quoted 8 lines

This patch adds fpga region platform driver for FPGA Management Engine. It register an fpga region with given fpga manager / bridge device.

Quoted 14 lines
drivers/fpga/fpga-dfl-fme-region.c new file +8 -0
new file mode 100644
index 0000000..0b988ab
@@ -0,0 +1,92 @@
+/*
+ * FPGA Region Driver for FPGA Management Engine (FME)
+ *
+ * Copyright (C) 2017 Intel Corporation, Inc.
+ *
+ * Authors:
+ *   Wu Hao <[email protected]>
+ *   Joseph Grecco <[email protected]>

drivers/fpga/fpga-dfl-fme-region.c line 18

Quoted 10 lines
drivers/fpga/fpga-dfl-fme-region.c new file +10 -0
+ *   Enno Luebbers <[email protected]>
+ *   Tim Whisonant <[email protected]>
+ *   Ananda Ravuri <[email protected]>
+ *   Henry Mitchel <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL version 2.
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#include <linux/module.h>

Thanks,
Alan

author
#84 lore raw

Re: [PATCH v3 16/21] fpga: dfl: add fpga region platform driver for FME

Quoted 5 lines · Alan Tull

On Mon, Nov 27, 2017 at 12:42 AM, Wu Hao <[email protected]> wrote:

Hi Hao,

Just fix the SPDX, otherwise it looks good.

Sure, will fix it. Thanks for the review. :)

Thanks
Hao

Quoted 39 lines
Quoted 9 lines

This patch adds fpga region platform driver for FPGA Management Engine. It register an fpga region with given fpga manager / bridge device.

Quoted 14 lines
drivers/fpga/fpga-dfl-fme-region.c new file +8 -0
new file mode 100644
index 0000000..0b988ab
@@ -0,0 +1,92 @@
+/*
+ * FPGA Region Driver for FPGA Management Engine (FME)
+ *
+ * Copyright (C) 2017 Intel Corporation, Inc.
+ *
+ * Authors:
+ *   Wu Hao <[email protected]>
+ *   Joseph Grecco <[email protected]>

drivers/fpga/fpga-dfl-fme-region.c line 18

Quoted 10 lines
drivers/fpga/fpga-dfl-fme-region.c new file +10 -0
+ *   Enno Luebbers <[email protected]>
+ *   Tim Whisonant <[email protected]>
+ *   Ananda Ravuri <[email protected]>
+ *   Henry Mitchel <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL version 2.
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#include <linux/module.h>

Thanks,
Alan

maintainer Acked-by
#85 lore raw

Re: [PATCH v3 16/21] fpga: dfl: add fpga region platform driver for FME

Quoted 22 lines · Wu Hao
Quoted 5 lines · Alan Tull

On Mon, Nov 27, 2017 at 12:42 AM, Wu Hao <[email protected]> wrote:

Hi Hao,

Just fix the SPDX, otherwise it looks good.

Sure, will fix it. Thanks for the review. :)

Thanks
Hao

Quoted 10 lines
Quoted 9 lines

This patch adds fpga region platform driver for FPGA Management Engine. It register an fpga region with given fpga manager / bridge device.

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
drivers/fpga/fpga-dfl-fme-region.c new file +13 -0
new file mode 100644
index 0000000..0b988ab
@@ -0,0 +1,92 @@
+/*
+ * FPGA Region Driver for FPGA Management Engine (FME)
+ *
+ * Copyright (C) 2017 Intel Corporation, Inc.
+ *
+ * Authors:
+ *   Wu Hao <[email protected]>
+ *   Joseph Grecco <[email protected]>
+ *   Enno Luebbers <[email protected]>
+ *   Tim Whisonant <[email protected]>
+ *   Ananda Ravuri <[email protected]>
+ *   Henry Mitchel <[email protected]>
+ *
Quoted 8 lines
Quoted 8 lines

drivers/fpga/fpga-dfl-fme-region.c line 18

Quoted 5 lines
drivers/fpga/fpga-dfl-fme-region.c new file +5 -0
+ * This work is licensed under the terms of the GNU GPL version 2.
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#include <linux/module.h>

Thanks,
Alan

Thanks,
Moritz

author
#86 lore raw

PATCH v3 17/21 fpga: dfl: add FPGA Accelerated Function Unit driver basic framework

In reply to Wu Hao

On DFL FPGA devices, the Accelerated Function Unit (AFU), can be reprogrammed for different functions. It connects to the FPGA infrastructure("blue bistream") via a Port. Port CSRs are implemented separately from the AFU CSRs to provide control and status of the Port. Once valid green bitstream is programmed into the AFU, it allows access to the AFU CSRs in the AFU MMIO space.

This patch only implements basic driver framework for AFU, including device file operation framework.

----
v3: rename driver to dfl-afu-main

---
 drivers/fpga/Kconfig        |   9 +++
 drivers/fpga/Makefile       |   2 +
 drivers/fpga/dfl-afu-main.c | 161 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/fpga/dfl-afu-main.c
drivers/fpga/Kconfig +9 -0
index 2df9dfd..fa1905b 100644
@@ -168,6 +168,15 @@ config FPGA_DFL_FME_REGION
 	help
 	  Say Y to enable FPGA Region driver for FPGA Management Engine.
 
+config FPGA_DFL_AFU
+	tristate "FPGA DFL AFU Driver"
+	depends on FPGA_DFL
+	help
+	  This is the driver for FPGA Accelerated Function Unit (AFU) which
+	  implements AFU and Port management features. A User AFU connects
+	  to the FPGA infrastructure via a Port. There may be more than 1
+	  Port/AFU per DFL based FPGA device.
+
 config INTEL_FPGA_DFL_PCI
 	tristate "Intel FPGA DFL PCIe Device Driver"
 	depends on PCI && FPGA_DFL
drivers/fpga/Makefile +2 -0
index 11777d3..e234fa8 100644
@@ -34,8 +34,10 @@ obj-$(CONFIG_FPGA_DFL_FME)		+= fpga-dfl-fme.o
 obj-$(CONFIG_FPGA_DFL_FME_MGR)		+= fpga-dfl-fme-mgr.o
 obj-$(CONFIG_FPGA_DFL_FME_BRIDGE)	+= fpga-dfl-fme-br.o
 obj-$(CONFIG_FPGA_DFL_FME_REGION)	+= fpga-dfl-fme-region.o
+obj-$(CONFIG_FPGA_DFL_AFU)		+= fpga-dfl-afu.o
 
 fpga-dfl-fme-objs := dfl-fme-main.o dfl-fme-pr.o
+fpga-dfl-afu-objs := dfl-afu-main.o
 
 # Drivers for FPGAs which implement DFL
 obj-$(CONFIG_INTEL_FPGA_DFL_PCI)	+= intel-dfl-pci.o
drivers/fpga/dfl-afu-main.c new file +161 -0

161 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#87 lore raw

PATCH v3 18/21 fpga: dfl: afu: add header sub feature support

In reply to Wu Hao

The port header register set is always present for port, it is mainly for capability, control and status of the ports that AFU connected to.

This patch implements header sub feature support. Below user interfaces are created by this patch.

Sysfs interface:
* /sys/class/fpga_region/<regionX>/<fpga-dfl-port.x>/id Read-only. Port ID.

Ioctl interface:
* FPGA_PORT_RESET
Reset the FPGA Port and its AFU.

----
v3: rename driver name to fpga-dfl-afu
add more description for reset ioctl.
fix some checkpatch issues.

---
 .../ABI/testing/sysfs-platform-fpga-dfl-afu        |  7 ++++
 drivers/fpga/dfl-afu-main.c                        | 44 +++++++++++++++++++++-
 include/uapi/linux/fpga-dfl.h                      | 17 +++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu
Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu new file +7 -0
new file mode 100644
index 0000000..f4bcd94
@@ -0,0 +1,7 @@
+What:		/sys/bus/platform/devices/fpga-dfl-port.0/id
+Date:		November 2017
+KernelVersion:  4.15
+Contact:	Wu Hao <[email protected]>
+Description:	Read-only. It returns id of this port. One DFL FPGA device
+		may have more than one port. Userspace could use this id to
+		distinguish different ports under same FPGA device.
drivers/fpga/dfl-afu-main.c +43 -1

74 lines not on this page · raw message

include/uapi/linux/fpga-dfl.h +17 -0
index 75bdf88..9bf273d 100644
@@ -30,8 +30,11 @@
 #define FPGA_MAGIC 0xB6
 
 #define FPGA_BASE 0
+#define PORT_BASE 0x40
 #define FME_BASE 0x80
 
+/* Common IOCTLs for both FME and AFU file descriptor */
+
 /**
  * FPGA_GET_API_VERSION - _IO(FPGA_MAGIC, FPGA_BASE + 0)
  *
@@ -50,6 +53,20 @@
 
 #define FPGA_CHECK_EXTENSION	_IO(FPGA_MAGIC, FPGA_BASE + 1)
 
+/* IOCTLs for AFU file descriptor */
+
+/**
+ * FPGA_PORT_RESET - _IO(FPGA_MAGIC, PORT_BASE + 0)
+ *
+ * Reset the FPGA Port and its AFU. No parameters are supported.
+ * Userspace can do Port reset at any time, e.g during DMA or PR. But
+ * it should never cause any system level issue, only functional failure
+ * (e.g DMA or PR operation failure) and be recoverable from the failure.
+ * Return: 0 on success, -errno of failure
+ */
+
+#define FPGA_PORT_RESET		_IO(FPGA_MAGIC, PORT_BASE + 0)
+
 /* IOCTLs for FME file descriptor */
 
 /**
Signature · 1 line
1.8.3.1
Acked-by on v3 18/21
#88 lore raw

Re: [PATCH v3 18/21] fpga: dfl: afu: add header sub feature support

On Mon, Nov 27, 2017 at 12:42 AM, Wu Hao <[email protected]> wrote:

Hi Hao,

Thanks for documenting the reset. Please add this documentation to the function header that is in fpga-dfl.h.

One question for clarification below.

This patch looks good.

Quoted 14 lines

The port header register set is always present for port, it is mainly for capability, control and status of the ports that AFU connected to.

This patch implements header sub feature support. Below user interfaces are created by this patch.

Sysfs interface:
* /sys/class/fpga_region/<regionX>/<fpga-dfl-port.x>/id Read-only. Port ID.

Ioctl interface:
* FPGA_PORT_RESET
Reset the FPGA Port and its AFU.

Quoted 6 lines
Quoted 17 lines

----
v3: rename driver name to fpga-dfl-afu
add more description for reset ioctl.
fix some checkpatch issues.

---
 .../ABI/testing/sysfs-platform-fpga-dfl-afu        |  7 ++++
 drivers/fpga/dfl-afu-main.c                        | 44 +++++++++++++++++++++-
 include/uapi/linux/fpga-dfl.h                      | 17 +++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu
Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu new file +0 -0
new file mode 100644
index 0000000..f4bcd94

Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu line 7

Quoted 7 lines
Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu new file +7 -0
@@ -0,0 +1,7 @@
+What:          /sys/bus/platform/devices/fpga-dfl-port.0/id
+Date:          November 2017
+KernelVersion:  4.15
+Contact:       Wu Hao <[email protected]>
+Description:   Read-only. It returns id of this port. One DFL FPGA device
+               may have more than one port. Userspace could use this id to
+               distinguish different ports under same FPGA device.

Potentially >1 port per FPGA, but only one port per fpga-region, right?

Quoted 120 lines
drivers/fpga/dfl-afu-main.c +43 -1
index d9f4b81..b01376c 100644
@@ -18,25 +18,66 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/fpga-dfl.h>
 
 #include "fpga-dfl.h"
 
+static ssize_t
+id_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       int id = fpga_port_id(to_platform_device(dev));
+
+       return scnprintf(buf, PAGE_SIZE, "%d\n", id);
+}
+static DEVICE_ATTR_RO(id);
+
+static const struct attribute *port_hdr_attrs[] = {
+       &dev_attr_id.attr,
+       NULL,
+};
+
 static int port_hdr_init(struct platform_device *pdev, struct feature *feature)
 {
        dev_dbg(&pdev->dev, "PORT HDR Init.\n");
 
-       return 0;
+       fpga_port_reset(pdev);
+
+       return sysfs_create_files(&pdev->dev.kobj, port_hdr_attrs);
 }
 
 static void port_hdr_uinit(struct platform_device *pdev,
                           struct feature *feature)
 {
        dev_dbg(&pdev->dev, "PORT HDR UInit.\n");
+
+       sysfs_remove_files(&pdev->dev.kobj, port_hdr_attrs);
+}
+
+static long
+port_hdr_ioctl(struct platform_device *pdev, struct feature *feature,
+              unsigned int cmd, unsigned long arg)
+{
+       long ret;
+
+       switch (cmd) {
+       case FPGA_PORT_RESET:
+               if (!arg)
+                       ret = fpga_port_reset(pdev);
+               else
+                       ret = -EINVAL;
+               break;
+       default:
+               dev_dbg(&pdev->dev, "%x cmd not handled", cmd);
+               ret = -ENODEV;
+       }
+
+       return ret;
 }
 
 static const struct feature_ops port_hdr_ops = {
        .init = port_hdr_init,
        .uinit = port_hdr_uinit,
+       .ioctl = port_hdr_ioctl,
 };
 
 static struct feature_driver port_feature_drvs[] = {
@@ -76,6 +117,7 @@ static int afu_release(struct inode *inode, struct file *filp)
 
        dev_dbg(&pdev->dev, "Device File Release\n");
 
+       fpga_port_reset(pdev);
        feature_dev_use_end(pdata);
 
        return 0;
include/uapi/linux/fpga-dfl.h +17 -1
index 75bdf88..9bf273d 100644
@@ -30,8 +30,11 @@
 #define FPGA_MAGIC 0xB6
 
 #define FPGA_BASE 0
+#define PORT_BASE 0x40
 #define FME_BASE 0x80
 
+/* Common IOCTLs for both FME and AFU file descriptor */
+
 /**
  * FPGA_GET_API_VERSION - _IO(FPGA_MAGIC, FPGA_BASE + 0)
  *
@@ -50,6 +53,20 @@
 
 #define FPGA_CHECK_EXTENSION   _IO(FPGA_MAGIC, FPGA_BASE + 1)
 
+/* IOCTLs for AFU file descriptor */
+
+/**
+ * FPGA_PORT_RESET - _IO(FPGA_MAGIC, PORT_BASE + 0)
+ *
+ * Reset the FPGA Port and its AFU. No parameters are supported.
+ * Userspace can do Port reset at any time, e.g during DMA or PR. But
+ * it should never cause any system level issue, only functional failure
+ * (e.g DMA or PR operation failure) and be recoverable from the failure.
+ * Return: 0 on success, -errno of failure
+ */
+
+#define FPGA_PORT_RESET                _IO(FPGA_MAGIC, PORT_BASE + 0)
+
 /* IOCTLs for FME file descriptor */
 
 /**
--

1.8.3.1

author
#89 lore raw

Re: [PATCH v3 18/21] fpga: dfl: afu: add header sub feature support

Quoted 6 lines · Alan Tull

On Mon, Nov 27, 2017 at 12:42 AM, Wu Hao <[email protected]> wrote:

Hi Hao,

Thanks for documenting the reset. Please add this documentation to the function header that is in fpga-dfl.h.

Sure, thanks for the review.

I will add the description to the function header.

Quoted 39 lines

One question for clarification below.

This patch looks good.

Quoted 14 lines

The port header register set is always present for port, it is mainly for capability, control and status of the ports that AFU connected to.

This patch implements header sub feature support. Below user interfaces are created by this patch.

Sysfs interface:
* /sys/class/fpga_region/<regionX>/<fpga-dfl-port.x>/id Read-only. Port ID.

Ioctl interface:
* FPGA_PORT_RESET
Reset the FPGA Port and its AFU.

Quoted 6 lines
Quoted 11 lines

----
v3: rename driver name to fpga-dfl-afu
add more description for reset ioctl.
fix some checkpatch issues.

---
 .../ABI/testing/sysfs-platform-fpga-dfl-afu        |  7 ++++
 drivers/fpga/dfl-afu-main.c                        | 44 +++++++++++++++++++++-
 include/uapi/linux/fpga-dfl.h                      | 17 +++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu
Quoted 15 lines

Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu line 7

Quoted 13 lines
Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu new file +7 -0
new file mode 100644
index 0000000..f4bcd94
@@ -0,0 +1,7 @@
+What:          /sys/bus/platform/devices/fpga-dfl-port.0/id
+Date:          November 2017
+KernelVersion:  4.15
+Contact:       Wu Hao <[email protected]>
+Description:   Read-only. It returns id of this port. One DFL FPGA device
+               may have more than one port. Userspace could use this id to
+               distinguish different ports under same FPGA device.

Potentially >1 port per FPGA, but only one port per fpga-region, right?

Yes.

Thanks
Hao

Quoted 121 lines
Quoted 121 lines
drivers/fpga/dfl-afu-main.c +43 -1
index d9f4b81..b01376c 100644
@@ -18,25 +18,66 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/fpga-dfl.h>
 
 #include "fpga-dfl.h"
 
+static ssize_t
+id_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       int id = fpga_port_id(to_platform_device(dev));
+
+       return scnprintf(buf, PAGE_SIZE, "%d\n", id);
+}
+static DEVICE_ATTR_RO(id);
+
+static const struct attribute *port_hdr_attrs[] = {
+       &dev_attr_id.attr,
+       NULL,
+};
+
 static int port_hdr_init(struct platform_device *pdev, struct feature *feature)
 {
        dev_dbg(&pdev->dev, "PORT HDR Init.\n");
 
-       return 0;
+       fpga_port_reset(pdev);
+
+       return sysfs_create_files(&pdev->dev.kobj, port_hdr_attrs);
 }
 
 static void port_hdr_uinit(struct platform_device *pdev,
                           struct feature *feature)
 {
        dev_dbg(&pdev->dev, "PORT HDR UInit.\n");
+
+       sysfs_remove_files(&pdev->dev.kobj, port_hdr_attrs);
+}
+
+static long
+port_hdr_ioctl(struct platform_device *pdev, struct feature *feature,
+              unsigned int cmd, unsigned long arg)
+{
+       long ret;
+
+       switch (cmd) {
+       case FPGA_PORT_RESET:
+               if (!arg)
+                       ret = fpga_port_reset(pdev);
+               else
+                       ret = -EINVAL;
+               break;
+       default:
+               dev_dbg(&pdev->dev, "%x cmd not handled", cmd);
+               ret = -ENODEV;
+       }
+
+       return ret;
 }
 
 static const struct feature_ops port_hdr_ops = {
        .init = port_hdr_init,
        .uinit = port_hdr_uinit,
+       .ioctl = port_hdr_ioctl,
 };
 
 static struct feature_driver port_feature_drvs[] = {
@@ -76,6 +117,7 @@ static int afu_release(struct inode *inode, struct file *filp)
 
        dev_dbg(&pdev->dev, "Device File Release\n");
 
+       fpga_port_reset(pdev);
        feature_dev_use_end(pdata);
 
        return 0;
include/uapi/linux/fpga-dfl.h +17 -1
index 75bdf88..9bf273d 100644
@@ -30,8 +30,11 @@
 #define FPGA_MAGIC 0xB6
 
 #define FPGA_BASE 0
+#define PORT_BASE 0x40
 #define FME_BASE 0x80
 
+/* Common IOCTLs for both FME and AFU file descriptor */
+
 /**
  * FPGA_GET_API_VERSION - _IO(FPGA_MAGIC, FPGA_BASE + 0)
  *
@@ -50,6 +53,20 @@
 
 #define FPGA_CHECK_EXTENSION   _IO(FPGA_MAGIC, FPGA_BASE + 1)
 
+/* IOCTLs for AFU file descriptor */
+
+/**
+ * FPGA_PORT_RESET - _IO(FPGA_MAGIC, PORT_BASE + 0)
+ *
+ * Reset the FPGA Port and its AFU. No parameters are supported.
+ * Userspace can do Port reset at any time, e.g during DMA or PR. But
+ * it should never cause any system level issue, only functional failure
+ * (e.g DMA or PR operation failure) and be recoverable from the failure.
+ * Return: 0 on success, -errno of failure
+ */
+
+#define FPGA_PORT_RESET                _IO(FPGA_MAGIC, PORT_BASE + 0)
+
 /* IOCTLs for FME file descriptor */
 
 /**
--

1.8.3.1

author
#90 lore raw

PATCH v3 19/21 fpga: dfl: afu: add FPGA_GET_API_VERSION/CHECK_EXTENSION ioctls support

In reply to Wu Hao

FPGA_GET_API_VERSION and FPGA_CHECK_EXTENSION ioctls are common ones which need to be supported by all feature devices drivers including FME and AFU. This patch implements above 2 ioctls in FPGA Accelerated Function Unit (AFU) driver.

----
v2: rebased
v3: rebased as driver renamed to fpga-dfl-afu
fix one checkpatch issue

---
 drivers/fpga/dfl-afu-main.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/fpga/dfl-afu-main.c +11 -0
index b01376c..d3d534c 100644
@@ -123,6 +123,13 @@ static int afu_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
+static long afu_ioctl_check_extension(struct feature_platform_data *pdata,
+				      unsigned long arg)
+{
+	/* No extension support for now */
+	return 0;
+}
+
 static long afu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
 	struct platform_device *pdev = filp->private_data;
@@ -133,6 +140,10 @@ static long afu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	dev_dbg(&pdev->dev, "%s cmd 0x%x\n", __func__, cmd);
 
 	switch (cmd) {
+	case FPGA_GET_API_VERSION:
+		return FPGA_API_VERSION;
+	case FPGA_CHECK_EXTENSION:
+		return afu_ioctl_check_extension(pdata, arg);
 	default:
 		/*
 		 * Let sub-feature's ioctl function to handle the cmd
Signature · 1 line
1.8.3.1
Acked-by on v3 19/21
#91 lore raw

Re: [PATCH v3 19/21] fpga: dfl: afu: add FPGA_GET_API_VERSION/CHECK_EXTENSION ioctls support

On Mon, Nov 27, 2017 at 12:42 AM, Wu Hao <[email protected]> wrote:

Hi Hao,

I'm adding my "Acked-by' below. When you post v4, please add it so that we can keep track of what got acked.

Thanks,
Alan

Quoted 11 lines

FPGA_GET_API_VERSION and FPGA_CHECK_EXTENSION ioctls are common ones which need to be supported by all feature devices drivers including FME and AFU. This patch implements above 2 ioctls in FPGA Accelerated Function Unit (AFU) driver.

author
#92 lore raw

Re: [PATCH v3 19/21] fpga: dfl: afu: add FPGA_GET_API_VERSION/CHECK_EXTENSION ioctls support

Quoted 6 lines · Alan Tull

On Mon, Nov 27, 2017 at 12:42 AM, Wu Hao <[email protected]> wrote:

Hi Hao,

I'm adding my "Acked-by' below. When you post v4, please add it so that we can keep track of what got acked.

Sure, thanks a lot for the code review. :)

Hao

Quoted 20 lines

Thanks,
Alan

Quoted 11 lines

FPGA_GET_API_VERSION and FPGA_CHECK_EXTENSION ioctls are common ones which need to be supported by all feature devices drivers including FME and AFU. This patch implements above 2 ioctls in FPGA Accelerated Function Unit (AFU) driver.

--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Acked-by
#93 lore raw

Re: [PATCH v3 19/21] fpga: dfl: afu: add FPGA_GET_API_VERSION/CHECK_EXTENSION ioctls support

Quoted 28 lines · Wu Hao
Quoted 6 lines · Alan Tull

On Mon, Nov 27, 2017 at 12:42 AM, Wu Hao <[email protected]> wrote:

Hi Hao,

I'm adding my "Acked-by' below. When you post v4, please add it so that we can keep track of what got acked.

Sure, thanks a lot for the code review. :)

Hao

Quoted 16 lines

Thanks,
Alan

Quoted 11 lines

FPGA_GET_API_VERSION and FPGA_CHECK_EXTENSION ioctls are common ones which need to be supported by all feature devices drivers including FME and AFU. This patch implements above 2 ioctls in FPGA Accelerated Function Unit (AFU) driver.

Quoted 4 lines
Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Looks good,

Moritz

author
#94 lore raw

Re: [PATCH v3 19/21] fpga: dfl: afu: add FPGA_GET_API_VERSION/CHECK_EXTENSION ioctls support

Quoted 28 lines · Moritz Fischer
Quoted 27 lines · Wu Hao
Quoted 6 lines · Alan Tull

On Mon, Nov 27, 2017 at 12:42 AM, Wu Hao <[email protected]> wrote:

Hi Hao,

I'm adding my "Acked-by' below. When you post v4, please add it so that we can keep track of what got acked.

Sure, thanks a lot for the code review. :)

Hao

Quoted 15 lines

Thanks,
Alan

Quoted 11 lines

FPGA_GET_API_VERSION and FPGA_CHECK_EXTENSION ioctls are common ones which need to be supported by all feature devices drivers including FME and AFU. This patch implements above 2 ioctls in FPGA Accelerated Function Unit (AFU) driver.

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 4 lines
Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Looks good,

Thanks a lot for the code review. :)

Hao

Quoted 2 lines

Moritz

author
#95 lore raw

PATCH v3 20/21 fpga: dfl: afu: add user afu sub feature support

In reply to Wu Hao

From: Xiao Guangrong <[email protected]>

User Accelerated Function Unit sub feature exposes the MMIO region of the AFU. After valid green bitstream (GBS) is programmed and port is enabled, then this MMIO region could be accessed.

This patch adds support to enumerate the AFU MMIO region and expose it to userspace via mmap file operation. Below interfaces are exposed to user:

Sysfs interface:
* /sys/class/fpga_region/<regionX>/<fpga-dfl-port.x>/afu_id Read-only. Indicate which green bitstream is programmed to this AFU.

Ioctl interfaces:
* FPGA_PORT_GET_INFO
Provide info to userspace on the number of supported region. Only UAFU region is supported now.

* FPGA_PORT_GET_REGION_INFO
Provide region information, including access permission, region size, offset from the start of device fd.

------
v2: moved the code to drivers/fpga folder as suggested by Alan Tull.
add sysfs documentation.
switched to GPLv2 license.
v3: rename driver to fpga-dfl-afu
fix coding style and checkpatch issue.
only allow afu_id to be read when port isn't in reset.

---
 .../ABI/testing/sysfs-platform-fpga-dfl-afu        |   9 +
 drivers/fpga/Makefile                              |   2 +-
 drivers/fpga/dfl-afu-main.c                        | 211 ++++++++++++++++++++-
 drivers/fpga/dfl-afu-region.c                      | 127 +++++++++++++
 drivers/fpga/dfl-afu.h                             |  54 ++++++
 include/uapi/linux/fpga-dfl.h                      |  47 +++++
 6 files changed, 446 insertions(+), 4 deletions(-)
 create mode 100644 drivers/fpga/dfl-afu-region.c
 create mode 100644 drivers/fpga/dfl-afu.h
Documentation/ABI/testing/sysfs-platform-fpga-dfl-afu +9 -0
index f4bcd94..54bcfad 100644
@@ -5,3 +5,12 @@ Contact:	Wu Hao <[email protected]>
 Description:	Read-only. It returns id of this port. One DFL FPGA device
 		may have more than one port. Userspace could use this id to
 		distinguish different ports under same FPGA device.
+
+What:		/sys/bus/platform/devices/fpga-dfl-port.0/afu_id
+Date:		November 2017
+KernelVersion:  4.15
+Contact:	Wu Hao <[email protected]>
+Description:	Read-only. User can program different green bitstreams (GBS) to
+		FPGA Accelerator Function Unit (AFU) for different functions.
+		It returns uuid which could be used to identify which GBS is
+		programmed in this AFU.
drivers/fpga/Makefile +1 -1
index e234fa8..f0dd09f 100644
@@ -37,7 +37,7 @@ obj-$(CONFIG_FPGA_DFL_FME_REGION)	+= fpga-dfl-fme-region.o
 obj-$(CONFIG_FPGA_DFL_AFU)		+= fpga-dfl-afu.o
 
 fpga-dfl-fme-objs := dfl-fme-main.o dfl-fme-pr.o
-fpga-dfl-afu-objs := dfl-afu-main.o
+fpga-dfl-afu-objs := dfl-afu-main.o dfl-afu-region.o
 
 # Drivers for FPGAs which implement DFL
 obj-$(CONFIG_INTEL_FPGA_DFL_PCI)	+= intel-dfl-pci.o
drivers/fpga/dfl-afu-main.c +208 -3

274 lines not on this page · raw message

drivers/fpga/dfl-afu-region.c new file +127 -0

127 lines not on this page · raw message

drivers/fpga/dfl-afu.h new file +54 -0

54 lines not on this page · raw message

include/uapi/linux/fpga-dfl.h +47 -0

53 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#96 lore raw

PATCH v3 21/21 fpga: dfl: afu: add FPGA_PORT_DMA_MAP/UNMAP ioctls support

In reply to Wu Hao

DMA memory regions are required for Accelerated Function Unit (AFU) usage. These two ioctls allow user space applications to map user memory regions for dma, and unmap them after use. Iova is returned from driver to user space application via FPGA_PORT_DMA_MAP ioctl. Application needs to unmap it after use, otherwise, driver will unmap them in device file release operation.

Each AFU has its own rb tree to keep track of its mapped DMA regions.

Ioctl interfaces:
* FPGA_PORT_DMA_MAP
Do the dma mapping per user_addr and length which provided by user. Return iova in provided struct afu_port_dma_map.

* FPGA_PORT_DMA_UNMAP
Unmap the dma region per iova provided by user.

-----
v2: moved the code to drivers/fpga folder as suggested by Alan Tull.
switched to GPLv2 license.
fixed kbuild warnings.
v3: improved commit description and fixed coding style issues.
replaced fpga_pdata_to_pcidev with fpga_pdata_to_fpga_cdev

---
 drivers/fpga/Makefile             |   2 +-
 drivers/fpga/dfl-afu-dma-region.c | 465 ++++++++++++++++++++++++++++++++++++++
 drivers/fpga/dfl-afu-main.c       |  61 ++++-
 drivers/fpga/dfl-afu.h            |  18 ++
 include/uapi/linux/fpga-dfl.h     |  37 +++
 5 files changed, 581 insertions(+), 2 deletions(-)
 create mode 100644 drivers/fpga/dfl-afu-dma-region.c
drivers/fpga/Makefile +1 -1
index f0dd09f..5715a78 100644
@@ -37,7 +37,7 @@ obj-$(CONFIG_FPGA_DFL_FME_REGION)	+= fpga-dfl-fme-region.o
 obj-$(CONFIG_FPGA_DFL_AFU)		+= fpga-dfl-afu.o
 
 fpga-dfl-fme-objs := dfl-fme-main.o dfl-fme-pr.o
-fpga-dfl-afu-objs := dfl-afu-main.o dfl-afu-region.o
+fpga-dfl-afu-objs := dfl-afu-main.o dfl-afu-region.o dfl-afu-dma-region.o
 
 # Drivers for FPGAs which implement DFL
 obj-$(CONFIG_INTEL_FPGA_DFL_PCI)	+= intel-dfl-pci.o
drivers/fpga/dfl-afu-dma-region.c new file +465 -0

465 lines not on this page · raw message

drivers/fpga/dfl-afu-main.c +60 -1

91 lines not on this page · raw message

drivers/fpga/dfl-afu.h +18 -0
index 78f9696..46c4e71f 100644
@@ -32,11 +32,21 @@ struct fpga_afu_region {
 	struct list_head node;
 };
 
+struct fpga_afu_dma_region {
+	u64 user_addr;
+	u64 length;
+	u64 iova;
+	struct page **pages;
+	struct rb_node node;
+	bool in_use;
+};
+
 struct fpga_afu {
 	u64 region_cur_offset;
 	int num_regions;
 	u8 num_umsgs;
 	struct list_head regions;
+	struct rb_root dma_regions;
 
 	struct feature_platform_data *pdata;
 };
@@ -51,4 +61,12 @@ int afu_get_region_by_offset(struct feature_platform_data *pdata,
 			     u64 offset, u64 size,
 			     struct fpga_afu_region *pregion);
 
+void afu_dma_region_init(struct feature_platform_data *pdata);
+void afu_dma_region_destroy(struct feature_platform_data *pdata);
+int afu_dma_map_region(struct feature_platform_data *pdata,
+		       u64 user_addr, u64 length, u64 *iova);
+int afu_dma_unmap_region(struct feature_platform_data *pdata, u64 iova);
+struct fpga_afu_dma_region *afu_dma_region_find(
+		struct feature_platform_data *pdata, u64 iova, u64 size);
+
 #endif
include/uapi/linux/fpga-dfl.h +37 -0
index 78937b0..a052e76 100644
@@ -114,6 +114,43 @@ struct fpga_port_region_info {
 
 #define FPGA_PORT_GET_REGION_INFO	_IO(FPGA_MAGIC, PORT_BASE + 2)
 
+/**
+ * FPGA_PORT_DMA_MAP - _IOWR(FPGA_MAGIC, PORT_BASE + 3,
+ *						struct fpga_port_dma_map)
+ *
+ * Map the dma memory per user_addr and length which are provided by caller.
+ * Driver fills the iova in provided struct afu_port_dma_map.
+ * This interface only accepts page-size aligned user memory for dma mapping.
+ * Return: 0 on success, -errno on failure.
+ */
+struct fpga_port_dma_map {
+	/* Input */
+	__u32 argsz;		/* Structure length */
+	__u32 flags;		/* Zero for now */
+	__u64 user_addr;        /* Process virtual address */
+	__u64 length;           /* Length of mapping (bytes)*/
+	/* Output */
+	__u64 iova;             /* IO virtual address */
+};
+
+#define FPGA_PORT_DMA_MAP	_IO(FPGA_MAGIC, PORT_BASE + 3)
+
+/**
+ * FPGA_PORT_DMA_UNMAP - _IOW(FPGA_MAGIC, PORT_BASE + 4,
+ *						struct fpga_port_dma_unmap)
+ *
+ * Unmap the dma memory per iova provided by caller.
+ * Return: 0 on success, -errno on failure.
+ */
+struct fpga_port_dma_unmap {
+	/* Input */
+	__u32 argsz;		/* Structure length */
+	__u32 flags;		/* Zero for now */
+	__u64 iova;		/* IO virtual address */
+};
+
+#define FPGA_PORT_DMA_UNMAP	_IO(FPGA_MAGIC, PORT_BASE + 4)
+
 /* IOCTLs for FME file descriptor */
 
 /**
Signature · 1 line
1.8.3.1