Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1695045 > unrolled thread

[RFC 0/5] Open source FPGA image header

Started byAlan Tull <atull@kernel.org>
First post2017-07-24 21:50 +0200
Last post2017-07-24 22:00 +0200
Articles 4 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [RFC 0/5] Open source FPGA image header Alan Tull <atull@kernel.org> - 2017-07-24 21:50 +0200
    [RFC 3/5] fpga: add dev to fpga_image_info Alan Tull <atull@kernel.org> - 2017-07-24 22:00 +0200
    [RFC 2/5] doc: fpga: add sysfs document for fpga region Alan Tull <atull@kernel.org> - 2017-07-24 22:00 +0200
    [RFC 4/5] fpga-region: new function fpga_region_free Alan Tull <atull@kernel.org> - 2017-07-24 22:00 +0200

#1695045 — [RFC 0/5] Open source FPGA image header

FromAlan Tull <atull@kernel.org>
Date2017-07-24 21:50 +0200
Subject[RFC 0/5] Open source FPGA image header
Message-ID<u6RwD-Yz-15@gated-at.bofh.it>
This patch set adds open source FPGA image headers.  This allows FPGA
FPGA image specific information to be added to the images themselves.
The header format is a simplified form of u-boot FIT images and can be
expanded as real use cases are raised.  As all the FPGA kernel
frameworks are intended to be vendor agnostic, so also is the header.
As libfdt's licensing is permissive, this header is also intended to
be useful for OS's other than Linux.

In February, there was a conversation on the linux-fpga mailing list
where Moritz and Jason suggested headers, so with their permission
I'll be happy to add 'Suggested-by'.

An API function and a sysfs interface are added for applying FPGA
images to regions.

Patches 1-2 are documentation

Patches 3-4 are small API changes and could be rolled into my "non-DT
  support for FPGA regions" patchset.

Patch 5 is the bulk of it.

todo: I've been working on scatter gather table support for this.
It's not done yet, so I pulled it out for now.

This patch applies on top of my "non-DT support for FPGA regions" v3
patchset.

Alan Tull

Alan Tull (5):
  doc: fpga: add document for the fdt FPGA header
  doc: fpga: add sysfs document for fpga region
  fpga: add dev to fpga_image_info
  fpga-region: new function fpga_region_free
  fpga-region support for fdt headers on fpga images

 Documentation/ABI/testing/sysfs-class-fpga-region |   7 +
 Documentation/fpga/fpga-header.txt                | 103 +++++
 drivers/fpga/Kconfig                              |   7 +
 drivers/fpga/fpga-mgr.c                           |  14 +-
 drivers/fpga/fpga-region.c                        | 460 ++++++++++++++++++++++
 drivers/fpga/of-fpga-region.c                     |  16 +-
 include/linux/fpga/fpga-mgr.h                     |  13 +-
 include/linux/fpga/fpga-region.h                  |   3 +
 8 files changed, 612 insertions(+), 11 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-region
 create mode 100644 Documentation/fpga/fpga-header.txt

-- 
2.7.4

[toc] | [next] | [standalone]


#1695049 — [RFC 3/5] fpga: add dev to fpga_image_info

FromAlan Tull <atull@kernel.org>
Date2017-07-24 22:00 +0200
Subject[RFC 3/5] fpga: add dev to fpga_image_info
Message-ID<u6RGh-12s-7@gated-at.bofh.it>
In reply to#1695045
This patch should be rolled into the next version of my
"non-dt support for FPGA regions" patchset.

Add a pointer to the device that owns the fpga_image_info to
fpga_image_info.  That way the fpga_image_info_free can
drop the 'dev' parameter and we are left with:

struct fpga_image_info *fpga_image_info_alloc(struct device *dev);

void fpga_image_info_free(struct fpga_image_info *info);

Signed-off-by: Alan Tull <atull@kernel.org>
---
 drivers/fpga/fpga-mgr.c       | 14 ++++++++++----
 drivers/fpga/of-fpga-region.c |  6 +++---
 include/linux/fpga/fpga-mgr.h |  4 +++-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index be13cce..af33310 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -40,20 +40,26 @@ struct fpga_image_info *fpga_image_info_alloc(struct device *dev)
 	if (!info)
 		return ERR_PTR(-ENOMEM);
 
+	get_device(dev);
+	info->dev = dev;
+
 	return info;
 }
 EXPORT_SYMBOL_GPL(fpga_image_info_alloc);
 
-void fpga_image_info_free(struct device *dev,
-			  struct fpga_image_info *info)
+void fpga_image_info_free(struct fpga_image_info *info)
 {
+	struct device *dev;
+
 	if (!info)
 		return;
 
 	if (info->firmware_name)
-		devm_kfree(dev, info->firmware_name);
+		devm_kfree(info->dev, info->firmware_name);
 
-	devm_kfree(dev, info);
+	dev = info->dev;
+	devm_kfree(info->dev, info);
+	put_device(dev);
 }
 EXPORT_SYMBOL_GPL(fpga_image_info_free);
 
diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c
index c2ea9b6..6bb5799 100644
--- a/drivers/fpga/of-fpga-region.c
+++ b/drivers/fpga/of-fpga-region.c
@@ -273,7 +273,7 @@ static struct fpga_image_info *of_fpga_region_parse_ov(
 
 	return info;
 ret_no_info:
-	fpga_image_info_free(dev, info);
+	fpga_image_info_free(info);
 	return ERR_PTR(ret);
 }
 
@@ -314,7 +314,7 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
 	ret = fpga_region_program_fpga(region);
 	if (ret) {
 		/* error; reject overlay */
-		fpga_image_info_free(dev, info);
+		fpga_image_info_free(info);
 		region->info = NULL;
 	}
 
@@ -335,7 +335,7 @@ static void of_fpga_region_notify_post_remove(struct fpga_region *region,
 {
 	fpga_bridges_disable(&region->bridge_list);
 	fpga_bridges_put(&region->bridge_list);
-	fpga_image_info_free(&region->dev, region->info);
+	fpga_image_info_free(region->info);
 	region->info = NULL;
 }
 
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index 50954cb..ddc56c0 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -79,6 +79,7 @@ enum fpga_mgr_states {
 
 /**
  * struct fpga_image_info - information specific to a FPGA image
+ * @dev: device that owns this info
  * @flags: boolean flags as defined above
  * @enable_timeout_us: maximum time to enable traffic through bridge (uSec)
  * @disable_timeout_us: maximum time to disable traffic through bridge (uSec)
@@ -91,6 +92,7 @@ enum fpga_mgr_states {
  * @overlay: Device Tree overlay
  */
 struct fpga_image_info {
+	struct device *dev;
 	u32 flags;
 	u32 enable_timeout_us;
 	u32 disable_timeout_us;
@@ -153,7 +155,7 @@ struct fpga_manager {
 
 struct fpga_image_info *fpga_image_info_alloc(struct device *dev);
 
-void fpga_image_info_free(struct device *dev, struct fpga_image_info *info);
+void fpga_image_info_free(struct fpga_image_info *info);
 
 int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info);
 
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1695055 — [RFC 2/5] doc: fpga: add sysfs document for fpga region

FromAlan Tull <atull@kernel.org>
Date2017-07-24 22:00 +0200
Subject[RFC 2/5] doc: fpga: add sysfs document for fpga region
Message-ID<u6RGi-12s-17@gated-at.bofh.it>
In reply to#1695045
Document the firmware_name attribute added for each
region.

Signed-off-by: Alan Tull <atull@kernel.org>
---
 Documentation/ABI/testing/sysfs-class-fpga-region | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-region

diff --git a/Documentation/ABI/testing/sysfs-class-fpga-region b/Documentation/ABI/testing/sysfs-class-fpga-region
new file mode 100644
index 0000000..de47645
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-fpga-region
@@ -0,0 +1,7 @@
+What:		/sys/class/fpga_region/<fpga>/firmware_name
+Date:		July 2017
+KernelVersion:	4.15
+Contact:	Alan Tull <atull@kernel.org>
+Description:	Write the name of FPGA image file on the firmware path to
+		program the FPGA region.  Write nothing to free up the
+		FPGA region for reprogramming.
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1695056 — [RFC 4/5] fpga-region: new function fpga_region_free

FromAlan Tull <atull@kernel.org>
Date2017-07-24 22:00 +0200
Subject[RFC 4/5] fpga-region: new function fpga_region_free
Message-ID<u6RGi-12s-21@gated-at.bofh.it>
In reply to#1695045
Add FPGA region API function fpga_region_free() that
undoes some of what fpga_region_program_fpga() does
to free up a region to be reprogrammed.

Signed-off-by: Alan Tull <atull@kernel.org>
---
 drivers/fpga/fpga-region.c       | 20 ++++++++++++++++++++
 drivers/fpga/of-fpga-region.c    |  5 +----
 include/linux/fpga/fpga-region.h |  2 ++
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
index afc6188..944d24a 100644
--- a/drivers/fpga/fpga-region.c
+++ b/drivers/fpga/fpga-region.c
@@ -162,6 +162,26 @@ int fpga_region_program_fpga(struct fpga_region *region)
 }
 EXPORT_SYMBOL_GPL(fpga_region_program_fpga);
 
+/**
+ * fpga_region_free
+ * Undo some of what fpga_region_program_fpga() did to free up
+ * region to be reprogrammed.
+ * @region: FPGA region
+ */
+void fpga_region_free(struct fpga_region *region)
+{
+	if (!region->info)
+		return;
+
+	fpga_bridges_disable(&region->bridge_list);
+	if (region->get_bridges)
+		fpga_bridges_put(&region->bridge_list);
+
+	fpga_image_info_free(region->info);
+	region->info = NULL;
+}
+EXPORT_SYMBOL_GPL(fpga_region_free);
+
 int fpga_region_register(struct device *dev, struct fpga_region *region)
 {
 	int id, ret = 0;
diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c
index 6bb5799..019ca37 100644
--- a/drivers/fpga/of-fpga-region.c
+++ b/drivers/fpga/of-fpga-region.c
@@ -333,10 +333,7 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
 static void of_fpga_region_notify_post_remove(struct fpga_region *region,
 					      struct of_overlay_notify_data *nd)
 {
-	fpga_bridges_disable(&region->bridge_list);
-	fpga_bridges_put(&region->bridge_list);
-	fpga_image_info_free(region->info);
-	region->info = NULL;
+	fpga_region_free(region);
 }
 
 /**
diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h
index f2eecdd..3b6f0b0 100644
--- a/include/linux/fpga/fpga-region.h
+++ b/include/linux/fpga/fpga-region.h
@@ -32,6 +32,8 @@ struct fpga_region *fpga_region_class_find(
 	int (*match)(struct device *, const void *));
 
 int fpga_region_program_fpga(struct fpga_region *region);
+void fpga_region_free(struct fpga_region *region);
+
 int fpga_region_register(struct device *dev, struct fpga_region *region);
 int fpga_region_unregister(struct fpga_region *region);
 
-- 
2.7.4

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web