linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] add DFL bus support to MODULE_DEVICE_TABLE()
@ 2020-09-15  3:27 Xu Yilun
  2020-09-15  3:27 ` [PATCH v2 1/4] fpga: dfl: move dfl_device_id to mod_devicetable.h Xu Yilun
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Xu Yilun @ 2020-09-15  3:27 UTC (permalink / raw)
  To: mdf, linux-fpga, linux-kernel, masahiroy; +Cc: trix, lgoncalv, Xu Yilun

Patch #1 and #2 add dfl bus support to MODULE_DEVICE_TABLE(), so that
dfl driver modules could be auto-loaded when dfl devices are added.

Patch #3 is a fix of the description of fields in struct dfl_device.

Patch #4 moves the dfl bus APIs to a new header file in the public
folder so that scattered dfl device drivers could include the common
dfl bus APIs.

Main changes from v1:
- A new patch (Patch #3) to fix the description.
- Rename the dfl-bus.h to dfl.h
- Updated the MAINTAINERS under FPGA DFL DRIVERS.
- Improve comments and minor fixes.

Xu Yilun (4):
  fpga: dfl: move dfl_device_id to mod_devicetable.h
  dfl: add dfl bus support to MODULE_DEVICE_TABLE()
  fpga: dfl: fix the comments of type & feature_id fields
  fpga: dfl: move dfl bus related APIs to include/linux/fpga/dfl.h

 MAINTAINERS                       |  1 +
 drivers/fpga/dfl-n3000-nios.c     |  3 +-
 drivers/fpga/dfl.c                |  1 +
 drivers/fpga/dfl.h                | 85 +-------------------------------------
 include/linux/fpga/dfl.h          | 86 +++++++++++++++++++++++++++++++++++++++
 include/linux/mod_devicetable.h   | 12 ++++++
 scripts/mod/devicetable-offsets.c |  4 ++
 scripts/mod/file2alias.c          | 17 ++++++++
 8 files changed, 123 insertions(+), 86 deletions(-)
 create mode 100644 include/linux/fpga/dfl.h

-- 
2.7.4


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/4] fpga: dfl: move dfl_device_id to mod_devicetable.h
  2020-09-15  3:27 [PATCH v2 0/4] add DFL bus support to MODULE_DEVICE_TABLE() Xu Yilun
@ 2020-09-15  3:27 ` Xu Yilun
  2020-09-15  3:59   ` Moritz Fischer
  2020-09-15  3:27 ` [PATCH v2 2/4] dfl: add dfl bus support to MODULE_DEVICE_TABLE() Xu Yilun
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Xu Yilun @ 2020-09-15  3:27 UTC (permalink / raw)
  To: mdf, linux-fpga, linux-kernel, masahiroy
  Cc: trix, lgoncalv, Xu Yilun, Wu Hao, Matthew Gerlach, Russ Weight

In order to support MODULE_DEVICE_TABLE() for dfl device driver, this
patch moves struct dfl_device_id to mod_devicetable.h

Signed-off-by: Xu Yilun <yilun.xu@intel.com>
Signed-off-by: Wu Hao <hao.wu@intel.com>
Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
Reviewed-by: Tom Rix <trix@redhat.com>
Acked-by: Wu Hao <hao.wu@intel.com>
---
v2: fix the order for the header file
---
 drivers/fpga/dfl.h              | 13 +------------
 include/linux/mod_devicetable.h | 12 ++++++++++++
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h
index 5dc758f..3c69596 100644
--- a/drivers/fpga/dfl.h
+++ b/drivers/fpga/dfl.h
@@ -22,6 +22,7 @@
 #include <linux/interrupt.h>
 #include <linux/iopoll.h>
 #include <linux/io-64-nonatomic-lo-hi.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/uuid.h>
@@ -526,18 +527,6 @@ enum dfl_id_type {
 };
 
 /**
- * struct dfl_device_id -  dfl device identifier
- * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
- * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
- * @driver_data: driver specific data.
- */
-struct dfl_device_id {
-	u8 type;
-	u16 feature_id;
-	unsigned long driver_data;
-};
-
-/**
  * struct dfl_device - represent an dfl device on dfl bus
  *
  * @dev: generic device interface.
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 5b08a47..407d8dc 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -838,4 +838,16 @@ struct mhi_device_id {
 	kernel_ulong_t driver_data;
 };
 
+/**
+ * struct dfl_device_id -  dfl device identifier
+ * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
+ * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
+ * @driver_data: driver specific data.
+ */
+struct dfl_device_id {
+	__u8 type;
+	__u16 feature_id;
+	kernel_ulong_t driver_data;
+};
+
 #endif /* LINUX_MOD_DEVICETABLE_H */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/4] dfl: add dfl bus support to MODULE_DEVICE_TABLE()
  2020-09-15  3:27 [PATCH v2 0/4] add DFL bus support to MODULE_DEVICE_TABLE() Xu Yilun
  2020-09-15  3:27 ` [PATCH v2 1/4] fpga: dfl: move dfl_device_id to mod_devicetable.h Xu Yilun
@ 2020-09-15  3:27 ` Xu Yilun
  2020-09-15  3:59   ` Moritz Fischer
  2020-09-15  3:27 ` [PATCH v2 3/4] fpga: dfl: fix the comments of type & feature_id fields Xu Yilun
  2020-09-15  3:27 ` [PATCH v2 4/4] fpga: dfl: move dfl bus related APIs to include/linux/fpga/dfl.h Xu Yilun
  3 siblings, 1 reply; 13+ messages in thread
From: Xu Yilun @ 2020-09-15  3:27 UTC (permalink / raw)
  To: mdf, linux-fpga, linux-kernel, masahiroy
  Cc: trix, lgoncalv, Xu Yilun, Wu Hao, Matthew Gerlach, Russ Weight

Device Feature List (DFL) is a linked list of feature headers within the
device MMIO space. It is used by FPGA to enumerate multiple sub features
within it. Each feature can be uniquely identified by DFL type and
feature id, which can be read out from feature headers.

A dfl bus helps DFL framework modularize DFL device drivers for different
sub features. The dfl bus matches its devices and drivers by DFL type and
feature id.

This patch add dfl bus support to MODULE_DEVICE_TABLE() by adding info
about struct dfl_device_id in devicetable-offsets.c and add a dfl entry
point in file2alias.c.

Signed-off-by: Xu Yilun <yilun.xu@intel.com>
Signed-off-by: Wu Hao <hao.wu@intel.com>
Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
Acked-by: Wu Hao <hao.wu@intel.com>
---
v2: add comments for the format of modalias
---
 scripts/mod/devicetable-offsets.c |  4 ++++
 scripts/mod/file2alias.c          | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index 27007c1..d8350ee 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -243,5 +243,9 @@ int main(void)
 	DEVID(mhi_device_id);
 	DEVID_FIELD(mhi_device_id, chan);
 
+	DEVID(dfl_device_id);
+	DEVID_FIELD(dfl_device_id, type);
+	DEVID_FIELD(dfl_device_id, feature_id);
+
 	return 0;
 }
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 2417dd1..9fd2e60 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1368,6 +1368,22 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias)
 	return 1;
 }
 
+/* Looks like: dfl:tNfN */
+static int do_dfl_entry(const char *filename, void *symval, char *alias)
+{
+	DEF_FIELD(symval, dfl_device_id, type);
+	DEF_FIELD(symval, dfl_device_id, feature_id);
+
+	/*
+	 * type contains 4 valid bits and feature_id contains 12 valid bits
+	 * according to DFL specification.
+	 */
+	sprintf(alias, "dfl:t%01Xf%03X", type, feature_id);
+
+	add_wildcard(alias);
+	return 1;
+}
+
 /* Does namelen bytes of name exactly match the symbol? */
 static bool sym_is(const char *name, unsigned namelen, const char *symbol)
 {
@@ -1442,6 +1458,7 @@ static const struct devtable devtable[] = {
 	{"tee", SIZE_tee_client_device_id, do_tee_entry},
 	{"wmi", SIZE_wmi_device_id, do_wmi_entry},
 	{"mhi", SIZE_mhi_device_id, do_mhi_entry},
+	{"dfl", SIZE_dfl_device_id, do_dfl_entry},
 };
 
 /* Create MODULE_ALIAS() statements.
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/4] fpga: dfl: fix the comments of type & feature_id fields
  2020-09-15  3:27 [PATCH v2 0/4] add DFL bus support to MODULE_DEVICE_TABLE() Xu Yilun
  2020-09-15  3:27 ` [PATCH v2 1/4] fpga: dfl: move dfl_device_id to mod_devicetable.h Xu Yilun
  2020-09-15  3:27 ` [PATCH v2 2/4] dfl: add dfl bus support to MODULE_DEVICE_TABLE() Xu Yilun
@ 2020-09-15  3:27 ` Xu Yilun
  2020-09-15  3:59   ` Moritz Fischer
  2020-09-15  3:27 ` [PATCH v2 4/4] fpga: dfl: move dfl bus related APIs to include/linux/fpga/dfl.h Xu Yilun
  3 siblings, 1 reply; 13+ messages in thread
From: Xu Yilun @ 2020-09-15  3:27 UTC (permalink / raw)
  To: mdf, linux-fpga, linux-kernel, masahiroy; +Cc: trix, lgoncalv, Xu Yilun

The description of feature_id in struct dfl_device is not accurate. In
DFL specification the feature_id is the 12 bits field. The description
in struct dfl_device_id is more clear so we make them aligned. We also
made the similar fix for the type field.

Signed-off-by: Xu Yilun <yilun.xu@intel.com>
---
 drivers/fpga/dfl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h
index 3c69596..d5e050a 100644
--- a/drivers/fpga/dfl.h
+++ b/drivers/fpga/dfl.h
@@ -531,8 +531,8 @@ enum dfl_id_type {
  *
  * @dev: generic device interface.
  * @id: id of the dfl device.
- * @type: type of DFL FIU of the device. See enum dfl_id_type.
- * @feature_id: 16 bits feature identifier local to its DFL FIU type.
+ * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
+ * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
  * @mmio_res: mmio resource of this dfl device.
  * @irqs: list of Linux IRQ numbers of this dfl device.
  * @num_irqs: number of IRQs supported by this dfl device.
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 4/4] fpga: dfl: move dfl bus related APIs to include/linux/fpga/dfl.h
  2020-09-15  3:27 [PATCH v2 0/4] add DFL bus support to MODULE_DEVICE_TABLE() Xu Yilun
                   ` (2 preceding siblings ...)
  2020-09-15  3:27 ` [PATCH v2 3/4] fpga: dfl: fix the comments of type & feature_id fields Xu Yilun
@ 2020-09-15  3:27 ` Xu Yilun
  2020-09-15 22:55   ` Moritz Fischer
  3 siblings, 1 reply; 13+ messages in thread
From: Xu Yilun @ 2020-09-15  3:27 UTC (permalink / raw)
  To: mdf, linux-fpga, linux-kernel, masahiroy; +Cc: trix, lgoncalv, Xu Yilun

The patch moves dfl-bus related APIs to include/linux/fpga/dfl.h

Now the DFL device drivers could be made as independent modules and put
in different folders according to their functionality. In order for
scattered DFL device drivers to include dfl bus APIs, move the dfl bus
APIs to a new header file in the public folder.

Signed-off-by: Xu Yilun <yilun.xu@intel.com>
Reviewed-by: Tom Rix <trix@redhat.com>
Acked-by: Wu Hao <hao.wu@intel.com>
---
v2: updated the MAINTAINERS under FPGA DFL DRIVERS
    improve the comments
    rename the dfl-bus.h to dfl.h
---
 MAINTAINERS                   |  1 +
 drivers/fpga/dfl-n3000-nios.c |  3 +-
 drivers/fpga/dfl.c            |  1 +
 drivers/fpga/dfl.h            | 72 ------------------------------------
 include/linux/fpga/dfl.h      | 86 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 74 deletions(-)
 create mode 100644 include/linux/fpga/dfl.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 31c5165..fa46592 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6883,6 +6883,7 @@ S:	Maintained
 F:	Documentation/ABI/testing/sysfs-bus-dfl
 F:	Documentation/fpga/dfl.rst
 F:	drivers/fpga/dfl*
+F:	include/linux/fpga/dfl.h
 F:	include/uapi/linux/fpga-dfl.h
 
 FPGA MANAGER FRAMEWORK
diff --git a/drivers/fpga/dfl-n3000-nios.c b/drivers/fpga/dfl-n3000-nios.c
index 70b44c3..5088f8f 100644
--- a/drivers/fpga/dfl-n3000-nios.c
+++ b/drivers/fpga/dfl-n3000-nios.c
@@ -11,6 +11,7 @@
  */
 #include <linux/bitfield.h>
 #include <linux/errno.h>
+#include <linux/fpga/dfl.h>
 #include <linux/io.h>
 #include <linux/io-64-nonatomic-lo-hi.h>
 #include <linux/kernel.h>
@@ -22,8 +23,6 @@
 #include <linux/spi/spi.h>
 #include <linux/types.h>
 
-#include "dfl.h"
-
 static char *fec_mode = "rs";
 module_param(fec_mode, charp, 0444);
 MODULE_PARM_DESC(fec_mode, "FEC mode of the ethernet retimer on Intel PAC N3000");
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index b450870..8bf6e99 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -11,6 +11,7 @@
  *   Xiao Guangrong <guangrong.xiao@linux.intel.com>
  */
 #include <linux/fpga-dfl.h>
+#include <linux/fpga/dfl.h>
 #include <linux/module.h>
 #include <linux/uaccess.h>
 
diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h
index d5e050a..2b82c96 100644
--- a/drivers/fpga/dfl.h
+++ b/drivers/fpga/dfl.h
@@ -517,76 +517,4 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev,
 			       struct dfl_feature *feature,
 			       unsigned long arg);
 
-/**
- * enum dfl_id_type - define the DFL FIU types
- */
-enum dfl_id_type {
-	FME_ID,
-	PORT_ID,
-	DFL_ID_MAX,
-};
-
-/**
- * struct dfl_device - represent an dfl device on dfl bus
- *
- * @dev: generic device interface.
- * @id: id of the dfl device.
- * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
- * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
- * @mmio_res: mmio resource of this dfl device.
- * @irqs: list of Linux IRQ numbers of this dfl device.
- * @num_irqs: number of IRQs supported by this dfl device.
- * @cdev: pointer to DFL FPGA container device this dfl device belongs to.
- * @id_entry: matched id entry in dfl driver's id table.
- */
-struct dfl_device {
-	struct device dev;
-	int id;
-	u8 type;
-	u16 feature_id;
-	struct resource mmio_res;
-	int *irqs;
-	unsigned int num_irqs;
-	struct dfl_fpga_cdev *cdev;
-	const struct dfl_device_id *id_entry;
-};
-
-/**
- * struct dfl_driver - represent an dfl device driver
- *
- * @drv: driver model structure.
- * @id_table: pointer to table of device IDs the driver is interested in.
- *	      { } member terminated.
- * @probe: mandatory callback for device binding.
- * @remove: callback for device unbinding.
- */
-struct dfl_driver {
-	struct device_driver drv;
-	const struct dfl_device_id *id_table;
-
-	int (*probe)(struct dfl_device *dfl_dev);
-	void (*remove)(struct dfl_device *dfl_dev);
-};
-
-#define to_dfl_dev(d) container_of(d, struct dfl_device, dev)
-#define to_dfl_drv(d) container_of(d, struct dfl_driver, drv)
-
-/*
- * use a macro to avoid include chaining to get THIS_MODULE.
- */
-#define dfl_driver_register(drv) \
-	__dfl_driver_register(drv, THIS_MODULE)
-int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner);
-void dfl_driver_unregister(struct dfl_driver *dfl_drv);
-
-/*
- * module_dfl_driver() - Helper macro for drivers that don't do
- * anything special in module init/exit.  This eliminates a lot of
- * boilerplate.  Each module may only use this macro once, and
- * calling it replaces module_init() and module_exit().
- */
-#define module_dfl_driver(__dfl_driver) \
-	module_driver(__dfl_driver, dfl_driver_register, \
-		      dfl_driver_unregister)
-
 #endif /* __FPGA_DFL_H */
diff --git a/include/linux/fpga/dfl.h b/include/linux/fpga/dfl.h
new file mode 100644
index 0000000..0d7806f
--- /dev/null
+++ b/include/linux/fpga/dfl.h
@@ -0,0 +1,86 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Header file for DFL driver and device API
+ *
+ * Copyright (C) 2020 Intel Corporation, Inc.
+ */
+
+#ifndef __LINUX_FPGA_DFL_H
+#define __LINUX_FPGA_DFL_H
+
+#include <linux/device.h>
+#include <linux/mod_devicetable.h>
+
+/**
+ * enum dfl_id_type - define the DFL FIU types
+ */
+enum dfl_id_type {
+	FME_ID,
+	PORT_ID,
+	DFL_ID_MAX,
+};
+
+/**
+ * struct dfl_device - represent an dfl device on dfl bus
+ *
+ * @dev: generic device interface.
+ * @id: id of the dfl device.
+ * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
+ * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
+ * @mmio_res: mmio resource of this dfl device.
+ * @irqs: list of Linux IRQ numbers of this dfl device.
+ * @num_irqs: number of IRQs supported by this dfl device.
+ * @cdev: pointer to DFL FPGA container device this dfl device belongs to.
+ * @id_entry: matched id entry in dfl driver's id table.
+ */
+struct dfl_device {
+	struct device dev;
+	int id;
+	u8 type;
+	u16 feature_id;
+	struct resource mmio_res;
+	int *irqs;
+	unsigned int num_irqs;
+	struct dfl_fpga_cdev *cdev;
+	const struct dfl_device_id *id_entry;
+};
+
+/**
+ * struct dfl_driver - represent an dfl device driver
+ *
+ * @drv: driver model structure.
+ * @id_table: pointer to table of device IDs the driver is interested in.
+ *	      { } member terminated.
+ * @probe: mandatory callback for device binding.
+ * @remove: callback for device unbinding.
+ */
+struct dfl_driver {
+	struct device_driver drv;
+	const struct dfl_device_id *id_table;
+
+	int (*probe)(struct dfl_device *dfl_dev);
+	void (*remove)(struct dfl_device *dfl_dev);
+};
+
+#define to_dfl_dev(d) container_of(d, struct dfl_device, dev)
+#define to_dfl_drv(d) container_of(d, struct dfl_driver, drv)
+
+/*
+ * use a macro to avoid include chaining to get THIS_MODULE.
+ */
+#define dfl_driver_register(drv) \
+	__dfl_driver_register(drv, THIS_MODULE)
+int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner);
+void dfl_driver_unregister(struct dfl_driver *dfl_drv);
+
+/*
+ * module_dfl_driver() - Helper macro for drivers that don't do
+ * anything special in module init/exit.  This eliminates a lot of
+ * boilerplate.  Each module may only use this macro once, and
+ * calling it replaces module_init() and module_exit().
+ */
+#define module_dfl_driver(__dfl_driver) \
+	module_driver(__dfl_driver, dfl_driver_register, \
+		      dfl_driver_unregister)
+
+#endif /* __LINUX_FPGA_DFL_H */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 1/4] fpga: dfl: move dfl_device_id to mod_devicetable.h
  2020-09-15  3:27 ` [PATCH v2 1/4] fpga: dfl: move dfl_device_id to mod_devicetable.h Xu Yilun
@ 2020-09-15  3:59   ` Moritz Fischer
  0 siblings, 0 replies; 13+ messages in thread
From: Moritz Fischer @ 2020-09-15  3:59 UTC (permalink / raw)
  To: Xu Yilun
  Cc: mdf, linux-fpga, linux-kernel, masahiroy, trix, lgoncalv, Wu Hao,
	Matthew Gerlach, Russ Weight

On Tue, Sep 15, 2020 at 11:27:50AM +0800, Xu Yilun wrote:
> In order to support MODULE_DEVICE_TABLE() for dfl device driver, this
> patch moves struct dfl_device_id to mod_devicetable.h
> 
> Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> Signed-off-by: Wu Hao <hao.wu@intel.com>
> Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> Reviewed-by: Tom Rix <trix@redhat.com>
> Acked-by: Wu Hao <hao.wu@intel.com>
> ---
> v2: fix the order for the header file
> ---
>  drivers/fpga/dfl.h              | 13 +------------
>  include/linux/mod_devicetable.h | 12 ++++++++++++
>  2 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h
> index 5dc758f..3c69596 100644
> --- a/drivers/fpga/dfl.h
> +++ b/drivers/fpga/dfl.h
> @@ -22,6 +22,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/iopoll.h>
>  #include <linux/io-64-nonatomic-lo-hi.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/uuid.h>
> @@ -526,18 +527,6 @@ enum dfl_id_type {
>  };
>  
>  /**
> - * struct dfl_device_id -  dfl device identifier
> - * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
> - * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
> - * @driver_data: driver specific data.
> - */
> -struct dfl_device_id {
> -	u8 type;
> -	u16 feature_id;
> -	unsigned long driver_data;
> -};
> -
> -/**
>   * struct dfl_device - represent an dfl device on dfl bus
>   *
>   * @dev: generic device interface.
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 5b08a47..407d8dc 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -838,4 +838,16 @@ struct mhi_device_id {
>  	kernel_ulong_t driver_data;
>  };
>  
> +/**
> + * struct dfl_device_id -  dfl device identifier
> + * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
> + * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
> + * @driver_data: driver specific data.
> + */
> +struct dfl_device_id {
> +	__u8 type;
> +	__u16 feature_id;
> +	kernel_ulong_t driver_data;
> +};
> +
>  #endif /* LINUX_MOD_DEVICETABLE_H */
> -- 
> 2.7.4
> 

Applied to for-next,

Thanks

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/4] dfl: add dfl bus support to MODULE_DEVICE_TABLE()
  2020-09-15  3:27 ` [PATCH v2 2/4] dfl: add dfl bus support to MODULE_DEVICE_TABLE() Xu Yilun
@ 2020-09-15  3:59   ` Moritz Fischer
       [not found]     ` <DM6PR11MB381970CD3C77534AA3E4C76385200@DM6PR11MB3819.namprd11.prod.outlook.com>
  0 siblings, 1 reply; 13+ messages in thread
From: Moritz Fischer @ 2020-09-15  3:59 UTC (permalink / raw)
  To: Xu Yilun
  Cc: mdf, linux-fpga, linux-kernel, masahiroy, trix, lgoncalv, Wu Hao,
	Matthew Gerlach, Russ Weight

On Tue, Sep 15, 2020 at 11:27:51AM +0800, Xu Yilun wrote:
> Device Feature List (DFL) is a linked list of feature headers within the
> device MMIO space. It is used by FPGA to enumerate multiple sub features
> within it. Each feature can be uniquely identified by DFL type and
> feature id, which can be read out from feature headers.
> 
> A dfl bus helps DFL framework modularize DFL device drivers for different
> sub features. The dfl bus matches its devices and drivers by DFL type and
> feature id.
> 
> This patch add dfl bus support to MODULE_DEVICE_TABLE() by adding info
> about struct dfl_device_id in devicetable-offsets.c and add a dfl entry
> point in file2alias.c.
> 
> Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> Signed-off-by: Wu Hao <hao.wu@intel.com>
> Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> Acked-by: Wu Hao <hao.wu@intel.com>
> ---
> v2: add comments for the format of modalias
> ---
>  scripts/mod/devicetable-offsets.c |  4 ++++
>  scripts/mod/file2alias.c          | 17 +++++++++++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
> index 27007c1..d8350ee 100644
> --- a/scripts/mod/devicetable-offsets.c
> +++ b/scripts/mod/devicetable-offsets.c
> @@ -243,5 +243,9 @@ int main(void)
>  	DEVID(mhi_device_id);
>  	DEVID_FIELD(mhi_device_id, chan);
>  
> +	DEVID(dfl_device_id);
> +	DEVID_FIELD(dfl_device_id, type);
> +	DEVID_FIELD(dfl_device_id, feature_id);
> +
>  	return 0;
>  }
> diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> index 2417dd1..9fd2e60 100644
> --- a/scripts/mod/file2alias.c
> +++ b/scripts/mod/file2alias.c
> @@ -1368,6 +1368,22 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias)
>  	return 1;
>  }
>  
> +/* Looks like: dfl:tNfN */
> +static int do_dfl_entry(const char *filename, void *symval, char *alias)
> +{
> +	DEF_FIELD(symval, dfl_device_id, type);
> +	DEF_FIELD(symval, dfl_device_id, feature_id);
> +
> +	/*
> +	 * type contains 4 valid bits and feature_id contains 12 valid bits
> +	 * according to DFL specification.
> +	 */
> +	sprintf(alias, "dfl:t%01Xf%03X", type, feature_id);
> +
> +	add_wildcard(alias);
> +	return 1;
> +}
> +
>  /* Does namelen bytes of name exactly match the symbol? */
>  static bool sym_is(const char *name, unsigned namelen, const char *symbol)
>  {
> @@ -1442,6 +1458,7 @@ static const struct devtable devtable[] = {
>  	{"tee", SIZE_tee_client_device_id, do_tee_entry},
>  	{"wmi", SIZE_wmi_device_id, do_wmi_entry},
>  	{"mhi", SIZE_mhi_device_id, do_mhi_entry},
> +	{"dfl", SIZE_dfl_device_id, do_dfl_entry},
>  };
>  
>  /* Create MODULE_ALIAS() statements.
> -- 
> 2.7.4
> 
Applied to for-next,

Thanks

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/4] fpga: dfl: fix the comments of type & feature_id fields
  2020-09-15  3:27 ` [PATCH v2 3/4] fpga: dfl: fix the comments of type & feature_id fields Xu Yilun
@ 2020-09-15  3:59   ` Moritz Fischer
  2020-09-15  4:42     ` Wu, Hao
  0 siblings, 1 reply; 13+ messages in thread
From: Moritz Fischer @ 2020-09-15  3:59 UTC (permalink / raw)
  To: Xu Yilun; +Cc: mdf, linux-fpga, linux-kernel, masahiroy, trix, lgoncalv

On Tue, Sep 15, 2020 at 11:27:52AM +0800, Xu Yilun wrote:
> The description of feature_id in struct dfl_device is not accurate. In
> DFL specification the feature_id is the 12 bits field. The description
> in struct dfl_device_id is more clear so we make them aligned. We also
> made the similar fix for the type field.
> 
> Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> ---
>  drivers/fpga/dfl.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h
> index 3c69596..d5e050a 100644
> --- a/drivers/fpga/dfl.h
> +++ b/drivers/fpga/dfl.h
> @@ -531,8 +531,8 @@ enum dfl_id_type {
>   *
>   * @dev: generic device interface.
>   * @id: id of the dfl device.
> - * @type: type of DFL FIU of the device. See enum dfl_id_type.
> - * @feature_id: 16 bits feature identifier local to its DFL FIU type.
> + * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
> + * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
>   * @mmio_res: mmio resource of this dfl device.
>   * @irqs: list of Linux IRQ numbers of this dfl device.
>   * @num_irqs: number of IRQs supported by this dfl device.
> -- 
> 2.7.4
> 

Applied to for-next,

Thanks

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH v2 3/4] fpga: dfl: fix the comments of type & feature_id fields
  2020-09-15  3:59   ` Moritz Fischer
@ 2020-09-15  4:42     ` Wu, Hao
  0 siblings, 0 replies; 13+ messages in thread
From: Wu, Hao @ 2020-09-15  4:42 UTC (permalink / raw)
  To: Moritz Fischer, Xu, Yilun
  Cc: linux-fpga, linux-kernel, masahiroy, trix, lgoncalv

> On Tue, Sep 15, 2020 at 11:27:52AM +0800, Xu Yilun wrote:
> > The description of feature_id in struct dfl_device is not accurate. In
> > DFL specification the feature_id is the 12 bits field. The description
> > in struct dfl_device_id is more clear so we make them aligned. We also
> > made the similar fix for the type field.
> >
> > Signed-off-by: Xu Yilun <yilun.xu@intel.com>

Acked-by: Wu Hao <hao.wu@intel.com>

Thanks
Hao

> > ---
> >  drivers/fpga/dfl.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h
> > index 3c69596..d5e050a 100644
> > --- a/drivers/fpga/dfl.h
> > +++ b/drivers/fpga/dfl.h
> > @@ -531,8 +531,8 @@ enum dfl_id_type {
> >   *
> >   * @dev: generic device interface.
> >   * @id: id of the dfl device.
> > - * @type: type of DFL FIU of the device. See enum dfl_id_type.
> > - * @feature_id: 16 bits feature identifier local to its DFL FIU type.
> > + * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
> > + * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
> >   * @mmio_res: mmio resource of this dfl device.
> >   * @irqs: list of Linux IRQ numbers of this dfl device.
> >   * @num_irqs: number of IRQs supported by this dfl device.
> > --
> > 2.7.4
> >
> 
> Applied to for-next,
> 
> Thanks

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/4] dfl: add dfl bus support to MODULE_DEVICE_TABLE()
       [not found]     ` <DM6PR11MB381970CD3C77534AA3E4C76385200@DM6PR11MB3819.namprd11.prod.outlook.com>
@ 2020-09-15  5:19       ` Xu Yilun
       [not found]         ` <DM6PR11MB3819106F9D50E39F7CC7837D85200@DM6PR11MB3819.namprd11.prod.outlook.com>
  0 siblings, 1 reply; 13+ messages in thread
From: Xu Yilun @ 2020-09-15  5:19 UTC (permalink / raw)
  To: Wu, Hao
  Cc: Moritz Fischer, linux-fpga, linux-kernel, masahiroy, trix,
	lgoncalv, Matthew Gerlach, Weight, Russell H

On Tue, Sep 15, 2020 at 12:08:38PM +0800, Wu, Hao wrote:
> > On Tue, Sep 15, 2020 at 11:27:51AM +0800, Xu Yilun wrote:
> > > Device Feature List (DFL) is a linked list of feature headers within the
> > > device MMIO space. It is used by FPGA to enumerate multiple sub features
> > > within it. Each feature can be uniquely identified by DFL type and
> > > feature id, which can be read out from feature headers.
> > >
> > > A dfl bus helps DFL framework modularize DFL device drivers for different
> > > sub features. The dfl bus matches its devices and drivers by DFL type and
> > > feature id.
> > >
> > > This patch add dfl bus support to MODULE_DEVICE_TABLE() by adding info
> > > about struct dfl_device_id in devicetable-offsets.c and add a dfl entry
> > > point in file2alias.c.
> > >
> > > Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> > > Signed-off-by: Wu Hao <hao.wu@intel.com>
> > > Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> > > Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> > > Acked-by: Wu Hao <hao.wu@intel.com>
> 
> Yilun,
> 
> I haven't acked-by this patch as it doesn't modify any dfl files, ideally you

Sorry, I misunderstood your comments "Acked-by: xxx for DFL related changes after
this fix".

> need acked-by from real maintainer of scripts/mod code, right?

Ideally yes. From the MAINTAINERS it is Masahiro Yamada, I added him on the "to"
list. But I see some other patches (also for devtable entries) in kernel
don't have his acked-by.

Hi Moritz:

Do you have any ideas on that?

Thanks,
Yilun.

> 
> Thanks
> Hao
> 
> > > ---
> > > v2: add comments for the format of modalias
> > > ---
> > >  scripts/mod/devicetable-offsets.c |  4 ++++
> > >  scripts/mod/file2alias.c          | 17 +++++++++++++++++
> > >  2 files changed, 21 insertions(+)
> > >
> > > diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-
> > offsets.c
> > > index 27007c1..d8350ee 100644
> > > --- a/scripts/mod/devicetable-offsets.c
> > > +++ b/scripts/mod/devicetable-offsets.c
> > > @@ -243,5 +243,9 @@ int main(void)
> > >  DEVID(mhi_device_id);
> > >  DEVID_FIELD(mhi_device_id, chan);
> > >
> > > +DEVID(dfl_device_id);
> > > +DEVID_FIELD(dfl_device_id, type);
> > > +DEVID_FIELD(dfl_device_id, feature_id);
> > > +
> > >  return 0;
> > >  }
> > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> > > index 2417dd1..9fd2e60 100644
> > > --- a/scripts/mod/file2alias.c
> > > +++ b/scripts/mod/file2alias.c
> > > @@ -1368,6 +1368,22 @@ static int do_mhi_entry(const char *filename,
> > void *symval, char *alias)
> > >  return 1;
> > >  }
> > >
> > > +/* Looks like: dfl:tNfN */
> > > +static int do_dfl_entry(const char *filename, void *symval, char *alias)
> > > +{
> > > +DEF_FIELD(symval, dfl_device_id, type);
> > > +DEF_FIELD(symval, dfl_device_id, feature_id);
> > > +
> > > +/*
> > > + * type contains 4 valid bits and feature_id contains 12 valid bits
> > > + * according to DFL specification.
> > > + */
> > > +sprintf(alias, "dfl:t%01Xf%03X", type, feature_id);
> > > +
> > > +add_wildcard(alias);
> > > +return 1;
> > > +}
> > > +
> > >  /* Does namelen bytes of name exactly match the symbol? */
> > >  static bool sym_is(const char *name, unsigned namelen, const char
> > *symbol)
> > >  {
> > > @@ -1442,6 +1458,7 @@ static const struct devtable devtable[] = {
> > >  {"tee", SIZE_tee_client_device_id, do_tee_entry},
> > >  {"wmi", SIZE_wmi_device_id, do_wmi_entry},
> > >  {"mhi", SIZE_mhi_device_id, do_mhi_entry},
> > > +{"dfl", SIZE_dfl_device_id, do_dfl_entry},
> > >  };
> > >
> > >  /* Create MODULE_ALIAS() statements.
> > > --
> > > 2.7.4
> > >
> > Applied to for-next,
> >
> > Thanks

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/4] dfl: add dfl bus support to MODULE_DEVICE_TABLE()
       [not found]         ` <DM6PR11MB3819106F9D50E39F7CC7837D85200@DM6PR11MB3819.namprd11.prod.outlook.com>
@ 2020-09-15 18:07           ` Moritz Fischer
  2020-09-16  0:24             ` Xu Yilun
  0 siblings, 1 reply; 13+ messages in thread
From: Moritz Fischer @ 2020-09-15 18:07 UTC (permalink / raw)
  To: Wu, Hao
  Cc: Xu, Yilun, Moritz Fischer, linux-fpga, linux-kernel, masahiroy,
	trix, lgoncalv, Matthew Gerlach, Weight, Russell H

Hi Hao, Xu,

On Tue, Sep 15, 2020 at 05:58:46AM +0000, Wu, Hao wrote:
> > On Tue, Sep 15, 2020 at 12:08:38PM +0800, Wu, Hao wrote:
> > > > On Tue, Sep 15, 2020 at 11:27:51AM +0800, Xu Yilun wrote:
> > > > > Device Feature List (DFL) is a linked list of feature headers within the
> > > > > device MMIO space. It is used by FPGA to enumerate multiple sub
> > features
> > > > > within it. Each feature can be uniquely identified by DFL type and
> > > > > feature id, which can be read out from feature headers.
> > > > >
> > > > > A dfl bus helps DFL framework modularize DFL device drivers for
> > different
> > > > > sub features. The dfl bus matches its devices and drivers by DFL type
> > and
> > > > > feature id.
> > > > >
> > > > > This patch add dfl bus support to MODULE_DEVICE_TABLE() by adding
> > info
> > > > > about struct dfl_device_id in devicetable-offsets.c and add a dfl entry
> > > > > point in file2alias.c.
> > > > >
> > > > > Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> > > > > Signed-off-by: Wu Hao <hao.wu@intel.com>
> > > > > Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> > > > > Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> > > > > Acked-by: Wu Hao <hao.wu@intel.com>
> > >
> > > Yilun,
> > >
> > > I haven't acked-by this patch as it doesn't modify any dfl files, ideally you
> > 
> > Sorry, I misunderstood your comments "Acked-by: xxx for DFL related
> > changes after this fix".

Yeah it wasn't entirely clear to me either :)
> 
> Because the first patch contains changes to non-dfl files as well. : )
> 
> Hao
> 
> > 
> > > need acked-by from real maintainer of scripts/mod code, right?
> > 
> > Ideally yes. From the MAINTAINERS it is Masahiro Yamada, I added him on
> > the "to"
> > list. But I see some other patches (also for devtable entries) in kernel
> > don't have his acked-by.

Yeah, I've looked at that and most patches for those files seem to be
from subsystem maintainers. So I *think* it should be fine?

> > 
> > Hi Moritz:
> > 
> > Do you have any ideas on that?
> > 
> > Thanks,
> > Yilun.
> > 
> > >
> > > Thanks
> > > Hao
> > >
> > > > > ---
> > > > > v2: add comments for the format of modalias
> > > > > ---
> > > > >  scripts/mod/devicetable-offsets.c |  4 ++++
> > > > >  scripts/mod/file2alias.c          | 17 +++++++++++++++++
> > > > >  2 files changed, 21 insertions(+)
> > > > >
> > > > > diff --git a/scripts/mod/devicetable-offsets.c
> > b/scripts/mod/devicetable-
> > > > offsets.c
> > > > > index 27007c1..d8350ee 100644
> > > > > --- a/scripts/mod/devicetable-offsets.c
> > > > > +++ b/scripts/mod/devicetable-offsets.c
> > > > > @@ -243,5 +243,9 @@ int main(void)
> > > > >  DEVID(mhi_device_id);
> > > > >  DEVID_FIELD(mhi_device_id, chan);
> > > > >
> > > > > +DEVID(dfl_device_id);
> > > > > +DEVID_FIELD(dfl_device_id, type);
> > > > > +DEVID_FIELD(dfl_device_id, feature_id);
> > > > > +
> > > > >  return 0;
> > > > >  }
> > > > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> > > > > index 2417dd1..9fd2e60 100644
> > > > > --- a/scripts/mod/file2alias.c
> > > > > +++ b/scripts/mod/file2alias.c
> > > > > @@ -1368,6 +1368,22 @@ static int do_mhi_entry(const char
> > *filename,
> > > > void *symval, char *alias)
> > > > >  return 1;
> > > > >  }
> > > > >
> > > > > +/* Looks like: dfl:tNfN */
> > > > > +static int do_dfl_entry(const char *filename, void *symval, char *alias)
> > > > > +{
> > > > > +DEF_FIELD(symval, dfl_device_id, type);
> > > > > +DEF_FIELD(symval, dfl_device_id, feature_id);
> > > > > +
> > > > > +/*
> > > > > + * type contains 4 valid bits and feature_id contains 12 valid bits
> > > > > + * according to DFL specification.
> > > > > + */
> > > > > +sprintf(alias, "dfl:t%01Xf%03X", type, feature_id);
> > > > > +
> > > > > +add_wildcard(alias);
> > > > > +return 1;
> > > > > +}
> > > > > +
> > > > >  /* Does namelen bytes of name exactly match the symbol? */
> > > > >  static bool sym_is(const char *name, unsigned namelen, const char
> > > > *symbol)
> > > > >  {
> > > > > @@ -1442,6 +1458,7 @@ static const struct devtable devtable[] = {
> > > > >  {"tee", SIZE_tee_client_device_id, do_tee_entry},
> > > > >  {"wmi", SIZE_wmi_device_id, do_wmi_entry},
> > > > >  {"mhi", SIZE_mhi_device_id, do_mhi_entry},
> > > > > +{"dfl", SIZE_dfl_device_id, do_dfl_entry},
> > > > >  };
> > > > >
> > > > >  /* Create MODULE_ALIAS() statements.
> > > > > --
> > > > > 2.7.4
> > > > >
> > > > Applied to for-next,
> > > >
> > > > Thanks

Cheers,
Moritz

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/4] fpga: dfl: move dfl bus related APIs to include/linux/fpga/dfl.h
  2020-09-15  3:27 ` [PATCH v2 4/4] fpga: dfl: move dfl bus related APIs to include/linux/fpga/dfl.h Xu Yilun
@ 2020-09-15 22:55   ` Moritz Fischer
  0 siblings, 0 replies; 13+ messages in thread
From: Moritz Fischer @ 2020-09-15 22:55 UTC (permalink / raw)
  To: Xu Yilun; +Cc: mdf, linux-fpga, linux-kernel, masahiroy, trix, lgoncalv

On Tue, Sep 15, 2020 at 11:27:53AM +0800, Xu Yilun wrote:
> The patch moves dfl-bus related APIs to include/linux/fpga/dfl.h
> 
> Now the DFL device drivers could be made as independent modules and put
> in different folders according to their functionality. In order for
> scattered DFL device drivers to include dfl bus APIs, move the dfl bus
> APIs to a new header file in the public folder.
> 
> Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> Reviewed-by: Tom Rix <trix@redhat.com>
> Acked-by: Wu Hao <hao.wu@intel.com>
> ---
> v2: updated the MAINTAINERS under FPGA DFL DRIVERS
>     improve the comments
>     rename the dfl-bus.h to dfl.h
> ---
>  MAINTAINERS                   |  1 +
>  drivers/fpga/dfl-n3000-nios.c |  3 +-
>  drivers/fpga/dfl.c            |  1 +
>  drivers/fpga/dfl.h            | 72 ------------------------------------
>  include/linux/fpga/dfl.h      | 86 +++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 89 insertions(+), 74 deletions(-)
>  create mode 100644 include/linux/fpga/dfl.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 31c5165..fa46592 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6883,6 +6883,7 @@ S:	Maintained
>  F:	Documentation/ABI/testing/sysfs-bus-dfl
>  F:	Documentation/fpga/dfl.rst
>  F:	drivers/fpga/dfl*
> +F:	include/linux/fpga/dfl.h
>  F:	include/uapi/linux/fpga-dfl.h
>  
>  FPGA MANAGER FRAMEWORK
> diff --git a/drivers/fpga/dfl-n3000-nios.c b/drivers/fpga/dfl-n3000-nios.c
> index 70b44c3..5088f8f 100644
> --- a/drivers/fpga/dfl-n3000-nios.c
> +++ b/drivers/fpga/dfl-n3000-nios.c
> @@ -11,6 +11,7 @@
>   */
>  #include <linux/bitfield.h>
>  #include <linux/errno.h>
> +#include <linux/fpga/dfl.h>
>  #include <linux/io.h>
>  #include <linux/io-64-nonatomic-lo-hi.h>
>  #include <linux/kernel.h>
> @@ -22,8 +23,6 @@
>  #include <linux/spi/spi.h>
>  #include <linux/types.h>
>  
> -#include "dfl.h"
> -
>  static char *fec_mode = "rs";
>  module_param(fec_mode, charp, 0444);
>  MODULE_PARM_DESC(fec_mode, "FEC mode of the ethernet retimer on Intel PAC N3000");
> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
> index b450870..8bf6e99 100644
> --- a/drivers/fpga/dfl.c
> +++ b/drivers/fpga/dfl.c
> @@ -11,6 +11,7 @@
>   *   Xiao Guangrong <guangrong.xiao@linux.intel.com>
>   */
>  #include <linux/fpga-dfl.h>
> +#include <linux/fpga/dfl.h>
>  #include <linux/module.h>
>  #include <linux/uaccess.h>
>  
> diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h
> index d5e050a..2b82c96 100644
> --- a/drivers/fpga/dfl.h
> +++ b/drivers/fpga/dfl.h
> @@ -517,76 +517,4 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev,
>  			       struct dfl_feature *feature,
>  			       unsigned long arg);
>  
> -/**
> - * enum dfl_id_type - define the DFL FIU types
> - */
> -enum dfl_id_type {
> -	FME_ID,
> -	PORT_ID,
> -	DFL_ID_MAX,
> -};
> -
> -/**
> - * struct dfl_device - represent an dfl device on dfl bus
> - *
> - * @dev: generic device interface.
> - * @id: id of the dfl device.
> - * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
> - * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
> - * @mmio_res: mmio resource of this dfl device.
> - * @irqs: list of Linux IRQ numbers of this dfl device.
> - * @num_irqs: number of IRQs supported by this dfl device.
> - * @cdev: pointer to DFL FPGA container device this dfl device belongs to.
> - * @id_entry: matched id entry in dfl driver's id table.
> - */
> -struct dfl_device {
> -	struct device dev;
> -	int id;
> -	u8 type;
> -	u16 feature_id;
> -	struct resource mmio_res;
> -	int *irqs;
> -	unsigned int num_irqs;
> -	struct dfl_fpga_cdev *cdev;
> -	const struct dfl_device_id *id_entry;
> -};
> -
> -/**
> - * struct dfl_driver - represent an dfl device driver
> - *
> - * @drv: driver model structure.
> - * @id_table: pointer to table of device IDs the driver is interested in.
> - *	      { } member terminated.
> - * @probe: mandatory callback for device binding.
> - * @remove: callback for device unbinding.
> - */
> -struct dfl_driver {
> -	struct device_driver drv;
> -	const struct dfl_device_id *id_table;
> -
> -	int (*probe)(struct dfl_device *dfl_dev);
> -	void (*remove)(struct dfl_device *dfl_dev);
> -};
> -
> -#define to_dfl_dev(d) container_of(d, struct dfl_device, dev)
> -#define to_dfl_drv(d) container_of(d, struct dfl_driver, drv)
> -
> -/*
> - * use a macro to avoid include chaining to get THIS_MODULE.
> - */
> -#define dfl_driver_register(drv) \
> -	__dfl_driver_register(drv, THIS_MODULE)
> -int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner);
> -void dfl_driver_unregister(struct dfl_driver *dfl_drv);
> -
> -/*
> - * module_dfl_driver() - Helper macro for drivers that don't do
> - * anything special in module init/exit.  This eliminates a lot of
> - * boilerplate.  Each module may only use this macro once, and
> - * calling it replaces module_init() and module_exit().
> - */
> -#define module_dfl_driver(__dfl_driver) \
> -	module_driver(__dfl_driver, dfl_driver_register, \
> -		      dfl_driver_unregister)
> -
>  #endif /* __FPGA_DFL_H */
> diff --git a/include/linux/fpga/dfl.h b/include/linux/fpga/dfl.h
> new file mode 100644
> index 0000000..0d7806f
> --- /dev/null
> +++ b/include/linux/fpga/dfl.h
> @@ -0,0 +1,86 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Header file for DFL driver and device API
> + *
> + * Copyright (C) 2020 Intel Corporation, Inc.
> + */
> +
> +#ifndef __LINUX_FPGA_DFL_H
> +#define __LINUX_FPGA_DFL_H
> +
> +#include <linux/device.h>
> +#include <linux/mod_devicetable.h>
> +
> +/**
> + * enum dfl_id_type - define the DFL FIU types
> + */
> +enum dfl_id_type {
> +	FME_ID,
> +	PORT_ID,
> +	DFL_ID_MAX,
> +};
> +
> +/**
> + * struct dfl_device - represent an dfl device on dfl bus
> + *
> + * @dev: generic device interface.
> + * @id: id of the dfl device.
> + * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
> + * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
> + * @mmio_res: mmio resource of this dfl device.
> + * @irqs: list of Linux IRQ numbers of this dfl device.
> + * @num_irqs: number of IRQs supported by this dfl device.
> + * @cdev: pointer to DFL FPGA container device this dfl device belongs to.
> + * @id_entry: matched id entry in dfl driver's id table.
> + */
> +struct dfl_device {
> +	struct device dev;
> +	int id;
> +	u8 type;
> +	u16 feature_id;
> +	struct resource mmio_res;
> +	int *irqs;
> +	unsigned int num_irqs;
> +	struct dfl_fpga_cdev *cdev;
> +	const struct dfl_device_id *id_entry;
> +};
> +
> +/**
> + * struct dfl_driver - represent an dfl device driver
> + *
> + * @drv: driver model structure.
> + * @id_table: pointer to table of device IDs the driver is interested in.
> + *	      { } member terminated.
> + * @probe: mandatory callback for device binding.
> + * @remove: callback for device unbinding.
> + */
> +struct dfl_driver {
> +	struct device_driver drv;
> +	const struct dfl_device_id *id_table;
> +
> +	int (*probe)(struct dfl_device *dfl_dev);
> +	void (*remove)(struct dfl_device *dfl_dev);
> +};
> +
> +#define to_dfl_dev(d) container_of(d, struct dfl_device, dev)
> +#define to_dfl_drv(d) container_of(d, struct dfl_driver, drv)
> +
> +/*
> + * use a macro to avoid include chaining to get THIS_MODULE.
> + */
> +#define dfl_driver_register(drv) \
> +	__dfl_driver_register(drv, THIS_MODULE)
> +int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner);
> +void dfl_driver_unregister(struct dfl_driver *dfl_drv);
> +
> +/*
> + * module_dfl_driver() - Helper macro for drivers that don't do
> + * anything special in module init/exit.  This eliminates a lot of
> + * boilerplate.  Each module may only use this macro once, and
> + * calling it replaces module_init() and module_exit().
> + */
> +#define module_dfl_driver(__dfl_driver) \
> +	module_driver(__dfl_driver, dfl_driver_register, \
> +		      dfl_driver_unregister)
> +
> +#endif /* __LINUX_FPGA_DFL_H */
> -- 
> 2.7.4
> 

Applied to for-next,

Thanks

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/4] dfl: add dfl bus support to MODULE_DEVICE_TABLE()
  2020-09-15 18:07           ` Moritz Fischer
@ 2020-09-16  0:24             ` Xu Yilun
  0 siblings, 0 replies; 13+ messages in thread
From: Xu Yilun @ 2020-09-16  0:24 UTC (permalink / raw)
  To: Moritz Fischer
  Cc: Wu, Hao, linux-fpga, linux-kernel, masahiroy, trix, lgoncalv,
	Matthew Gerlach, Weight, Russell H

On Tue, Sep 15, 2020 at 11:07:55AM -0700, Moritz Fischer wrote:
> Hi Hao, Xu,
> 
> On Tue, Sep 15, 2020 at 05:58:46AM +0000, Wu, Hao wrote:
> > > On Tue, Sep 15, 2020 at 12:08:38PM +0800, Wu, Hao wrote:
> > > > > On Tue, Sep 15, 2020 at 11:27:51AM +0800, Xu Yilun wrote:
> > > > > > Device Feature List (DFL) is a linked list of feature headers within the
> > > > > > device MMIO space. It is used by FPGA to enumerate multiple sub
> > > features
> > > > > > within it. Each feature can be uniquely identified by DFL type and
> > > > > > feature id, which can be read out from feature headers.
> > > > > >
> > > > > > A dfl bus helps DFL framework modularize DFL device drivers for
> > > different
> > > > > > sub features. The dfl bus matches its devices and drivers by DFL type
> > > and
> > > > > > feature id.
> > > > > >
> > > > > > This patch add dfl bus support to MODULE_DEVICE_TABLE() by adding
> > > info
> > > > > > about struct dfl_device_id in devicetable-offsets.c and add a dfl entry
> > > > > > point in file2alias.c.
> > > > > >
> > > > > > Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> > > > > > Signed-off-by: Wu Hao <hao.wu@intel.com>
> > > > > > Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> > > > > > Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> > > > > > Acked-by: Wu Hao <hao.wu@intel.com>
> > > >
> > > > Yilun,
> > > >
> > > > I haven't acked-by this patch as it doesn't modify any dfl files, ideally you
> > > 
> > > Sorry, I misunderstood your comments "Acked-by: xxx for DFL related
> > > changes after this fix".
> 
> Yeah it wasn't entirely clear to me either :)
> > 
> > Because the first patch contains changes to non-dfl files as well. : )
> > 
> > Hao
> > 
> > > 
> > > > need acked-by from real maintainer of scripts/mod code, right?
> > > 
> > > Ideally yes. From the MAINTAINERS it is Masahiro Yamada, I added him on
> > > the "to"
> > > list. But I see some other patches (also for devtable entries) in kernel
> > > don't have his acked-by.
> 
> Yeah, I've looked at that and most patches for those files seem to be
> from subsystem maintainers. So I *think* it should be fine?

I see you have applied the patch. I'm very fine. :)

> 
> > > 
> > > Hi Moritz:
> > > 
> > > Do you have any ideas on that?
> > > 
> > > Thanks,
> > > Yilun.
> > > 
> > > >
> > > > Thanks
> > > > Hao
> > > >
> > > > > > ---
> > > > > > v2: add comments for the format of modalias
> > > > > > ---
> > > > > >  scripts/mod/devicetable-offsets.c |  4 ++++
> > > > > >  scripts/mod/file2alias.c          | 17 +++++++++++++++++
> > > > > >  2 files changed, 21 insertions(+)
> > > > > >
> > > > > > diff --git a/scripts/mod/devicetable-offsets.c
> > > b/scripts/mod/devicetable-
> > > > > offsets.c
> > > > > > index 27007c1..d8350ee 100644
> > > > > > --- a/scripts/mod/devicetable-offsets.c
> > > > > > +++ b/scripts/mod/devicetable-offsets.c
> > > > > > @@ -243,5 +243,9 @@ int main(void)
> > > > > >  DEVID(mhi_device_id);
> > > > > >  DEVID_FIELD(mhi_device_id, chan);
> > > > > >
> > > > > > +DEVID(dfl_device_id);
> > > > > > +DEVID_FIELD(dfl_device_id, type);
> > > > > > +DEVID_FIELD(dfl_device_id, feature_id);
> > > > > > +
> > > > > >  return 0;
> > > > > >  }
> > > > > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> > > > > > index 2417dd1..9fd2e60 100644
> > > > > > --- a/scripts/mod/file2alias.c
> > > > > > +++ b/scripts/mod/file2alias.c
> > > > > > @@ -1368,6 +1368,22 @@ static int do_mhi_entry(const char
> > > *filename,
> > > > > void *symval, char *alias)
> > > > > >  return 1;
> > > > > >  }
> > > > > >
> > > > > > +/* Looks like: dfl:tNfN */
> > > > > > +static int do_dfl_entry(const char *filename, void *symval, char *alias)
> > > > > > +{
> > > > > > +DEF_FIELD(symval, dfl_device_id, type);
> > > > > > +DEF_FIELD(symval, dfl_device_id, feature_id);
> > > > > > +
> > > > > > +/*
> > > > > > + * type contains 4 valid bits and feature_id contains 12 valid bits
> > > > > > + * according to DFL specification.
> > > > > > + */
> > > > > > +sprintf(alias, "dfl:t%01Xf%03X", type, feature_id);
> > > > > > +
> > > > > > +add_wildcard(alias);
> > > > > > +return 1;
> > > > > > +}
> > > > > > +
> > > > > >  /* Does namelen bytes of name exactly match the symbol? */
> > > > > >  static bool sym_is(const char *name, unsigned namelen, const char
> > > > > *symbol)
> > > > > >  {
> > > > > > @@ -1442,6 +1458,7 @@ static const struct devtable devtable[] = {
> > > > > >  {"tee", SIZE_tee_client_device_id, do_tee_entry},
> > > > > >  {"wmi", SIZE_wmi_device_id, do_wmi_entry},
> > > > > >  {"mhi", SIZE_mhi_device_id, do_mhi_entry},
> > > > > > +{"dfl", SIZE_dfl_device_id, do_dfl_entry},
> > > > > >  };
> > > > > >
> > > > > >  /* Create MODULE_ALIAS() statements.
> > > > > > --
> > > > > > 2.7.4
> > > > > >
> > > > > Applied to for-next,
> > > > >
> > > > > Thanks
> 
> Cheers,
> Moritz

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-09-16  0:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15  3:27 [PATCH v2 0/4] add DFL bus support to MODULE_DEVICE_TABLE() Xu Yilun
2020-09-15  3:27 ` [PATCH v2 1/4] fpga: dfl: move dfl_device_id to mod_devicetable.h Xu Yilun
2020-09-15  3:59   ` Moritz Fischer
2020-09-15  3:27 ` [PATCH v2 2/4] dfl: add dfl bus support to MODULE_DEVICE_TABLE() Xu Yilun
2020-09-15  3:59   ` Moritz Fischer
     [not found]     ` <DM6PR11MB381970CD3C77534AA3E4C76385200@DM6PR11MB3819.namprd11.prod.outlook.com>
2020-09-15  5:19       ` Xu Yilun
     [not found]         ` <DM6PR11MB3819106F9D50E39F7CC7837D85200@DM6PR11MB3819.namprd11.prod.outlook.com>
2020-09-15 18:07           ` Moritz Fischer
2020-09-16  0:24             ` Xu Yilun
2020-09-15  3:27 ` [PATCH v2 3/4] fpga: dfl: fix the comments of type & feature_id fields Xu Yilun
2020-09-15  3:59   ` Moritz Fischer
2020-09-15  4:42     ` Wu, Hao
2020-09-15  3:27 ` [PATCH v2 4/4] fpga: dfl: move dfl bus related APIs to include/linux/fpga/dfl.h Xu Yilun
2020-09-15 22:55   ` Moritz Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).