Skip to contentSkip to conversation

fpga: patches for v4.19

PATCH In review Alan Tull 2 participants 12 messages Sep 12, 2018 – Nov 12, 2018

Subsystems (3)
lore
Share & tools
lore

Alan Tull

author
#0 lore raw

cover fpga: patches for v4.19

Hi Greg,

Please take these five small patches for FPGA. They have been reviewed on the mailing lists and apply cleanly on linux-next/master and char-misc-testing.

Thanks,
Alan

Alan Tull (3):
fpga: do not access region struct after fpga_region_unregister
fpga: bridge: fix obvious function documentation error
docs: fpga: document fpga manager flags

Moritz Fischer (2):
fpga: of-fpga-region: Use platform_set_drvdata
fpga: dfl-fme-region: Use platform_get_drvdata()

 Documentation/driver-api/fpga/fpga-mgr.rst |  5 +++++
 drivers/fpga/dfl-fme-region.c              |  6 ++++--
 drivers/fpga/fpga-bridge.c                 |  2 +-
 drivers/fpga/of-fpga-region.c              |  5 +++--
 include/linux/fpga/fpga-mgr.h              | 20 ++++++++++++++------
 5 files changed, 27 insertions(+), 11 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/5 fpga: do not access region struct after fpga_region_unregister

A couple drivers were accessing the region struct after it had been freed. Save off the pointer to the mgr before the region struct gets freed.

---
 drivers/fpga/dfl-fme-region.c | 4 +++-
 drivers/fpga/of-fpga-region.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/fpga/dfl-fme-region.c +3 -1
index 0b7e19c..51a5ac2 100644
@@ -14,6 +14,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/fpga/fpga-mgr.h>
 #include <linux/fpga/fpga-region.h>
 
 #include "dfl-fme-pr.h"
@@ -66,9 +67,10 @@ static int fme_region_probe(struct platform_device *pdev)
 static int fme_region_remove(struct platform_device *pdev)
 {
 	struct fpga_region *region = dev_get_drvdata(&pdev->dev);
+	struct fpga_manager *mgr = region->mgr;
 
 	fpga_region_unregister(region);
-	fpga_mgr_put(region->mgr);
+	fpga_mgr_put(mgr);
 
 	return 0;
 }
drivers/fpga/of-fpga-region.c +2 -1
index 35fabb8..052a134 100644
@@ -437,9 +437,10 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 static int of_fpga_region_remove(struct platform_device *pdev)
 {
 	struct fpga_region *region = platform_get_drvdata(pdev);
+	struct fpga_manager *mgr = region->mgr;
 
 	fpga_region_unregister(region);
-	fpga_mgr_put(region->mgr);
+	fpga_mgr_put(mgr);
 
 	return 0;
 }
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/5 fpga: bridge: fix obvious function documentation error

In reply to Alan Tull

fpga_bridge_dev_match() returns a FPGA bridge struct, not a FPGA manager struct so s/manager/bridge/.

---
 drivers/fpga/fpga-bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/fpga-bridge.c +1 -1
index 24b8f98..c983dac 100644
@@ -125,7 +125,7 @@ static int fpga_bridge_dev_match(struct device *dev, const void *data)
  *
  * Given a device, get an exclusive reference to a fpga bridge.
  *
- * Return: fpga manager struct or IS_ERR() condition containing error code.
+ * Return: fpga bridge struct or IS_ERR() condition containing error code.
  */
 struct fpga_bridge *fpga_bridge_get(struct device *dev,
 				    struct fpga_image_info *info)
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 3/5 docs: fpga: document fpga manager flags

In reply to Alan Tull

Add flags #defines to kerneldoc documentation in a useful place.

---
 Documentation/driver-api/fpga/fpga-mgr.rst |  5 +++++
 include/linux/fpga/fpga-mgr.h              | 20 ++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)
Documentation/driver-api/fpga/fpga-mgr.rst +5 -0
index 4b3825d..82b6dbb 100644
@@ -184,6 +184,11 @@ API for implementing a new FPGA Manager driver
 API for programming an FPGA
 ---------------------------
 
+FPGA Manager flags
+
+.. kernel-doc:: include/linux/fpga/fpga-mgr.h
+   :doc: FPGA Manager flags
+
 .. kernel-doc:: include/linux/fpga/fpga-mgr.h
    :functions: fpga_image_info
 
include/linux/fpga/fpga-mgr.h +14 -6
index 8942e61..8ab5df7 100644
@@ -53,12 +53,20 @@ enum fpga_mgr_states {
 	FPGA_MGR_STATE_OPERATING,
 };
 
-/*
- * FPGA Manager flags
- * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported
- * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting
- * FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first
- * FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed
+/**
+ * DOC: FPGA Manager flags
+ *
+ * Flags used in the &fpga_image_info->flags field
+ *
+ * %FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported
+ *
+ * %FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting
+ *
+ * %FPGA_MGR_ENCRYPTED_BITSTREAM: indicates bitstream is encrypted
+ *
+ * %FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first
+ *
+ * %FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed
  */
 #define FPGA_MGR_PARTIAL_RECONFIG	BIT(0)
 #define FPGA_MGR_EXTERNAL_CONFIG	BIT(1)
Signature · 1 line
2.7.4
author
#4 lore raw

PATCH 4/5 fpga: of-fpga-region: Use platform_set_drvdata

In reply to Alan Tull

From: Moritz Fischer <[email protected]>

Use platform_set_drvdata rather than dev_set_drvdata to match the platform_get_drvdata in the _remove() function of the platform driver.

---
 drivers/fpga/of-fpga-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/of-fpga-region.c +1 -1
index 052a134..d6a70e4 100644
@@ -421,7 +421,7 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 		goto eprobe_free;
 
 	of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
-	dev_set_drvdata(dev, region);
+	platform_set_drvdata(pdev, region);
 
 	dev_info(dev, "FPGA Region probed\n");
 
Signature · 1 line
2.7.4
author
#7 lore raw

PATCH 5/5 fpga: dfl-fme-region: Use platform_get_drvdata()

In reply to Alan Tull

From: Moritz Fischer <[email protected]>

Use platform_get_drvdata() in remove() function of the platform driver rather than dev_get_drvdata() to match the platform_set_drvdata in the probe().

---
 drivers/fpga/dfl-fme-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl-fme-region.c +1 -1
index 51a5ac2..3fa0de2 100644
@@ -66,7 +66,7 @@ static int fme_region_probe(struct platform_device *pdev)
 
 static int fme_region_remove(struct platform_device *pdev)
 {
-	struct fpga_region *region = dev_get_drvdata(&pdev->dev);
+	struct fpga_region *region = platform_get_drvdata(pdev);
 	struct fpga_manager *mgr = region->mgr;
 
 	fpga_region_unregister(region);
Signature · 1 line
2.7.4
#8 lore raw

Re: [PATCH 5/5] fpga: dfl-fme-region: Use platform_get_drvdata()

Quoted 17 lines · Alan Tull

From: Moritz Fischer <[email protected]>

Use platform_get_drvdata() in remove() function of the platform driver rather than dev_get_drvdata() to match the platform_set_drvdata in the probe().

---
 drivers/fpga/dfl-fme-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl-fme-region.c +0 -0
index 51a5ac2..3fa0de2 100644

drivers/fpga/dfl-fme-region.c static int fme_region_probe(struct platform_device *pdev) · line 69

Quoted 5 lines
drivers/fpga/dfl-fme-region.c +1 -1
@@ -66,7 +66,7 @@ static int fme_region_probe(struct platform_device *pdev)
 
 static int fme_region_remove(struct platform_device *pdev)
 {
-	struct fpga_region *region = dev_get_drvdata(&pdev->dev);
+	struct fpga_region *region = platform_get_drvdata(pdev);

This is nice, but not a bugfix. I'll wait for 4.20-rc1 for this patch.

thanks,

greg k-h

#5 lore raw

Re: [PATCH 4/5] fpga: of-fpga-region: Use platform_set_drvdata

In reply to Alan Tull
Quoted 17 lines · Alan Tull

From: Moritz Fischer <[email protected]>

Use platform_set_drvdata rather than dev_set_drvdata to match the platform_get_drvdata in the _remove() function of the platform driver.

---
 drivers/fpga/of-fpga-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/of-fpga-region.c +0 -0
index 052a134..d6a70e4 100644

drivers/fpga/of-fpga-region.c static int of_fpga_region_probe(struct platform_device *pdev) · line 424

Quoted 5 lines
drivers/fpga/of-fpga-region.c +1 -1
@@ -421,7 +421,7 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 		goto eprobe_free;
 
 	of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
-	dev_set_drvdata(dev, region);
+	platform_set_drvdata(pdev, region);

Again, not really a bugfix :)

author
#9 lore raw

Re: [PATCH 5/5] fpga: dfl-fme-region: Use platform_get_drvdata()

In reply to Greg Kroah-Hartman

On Sun, Sep 30, 2018 at 10:48 AM Greg Kroah-Hartman <[email protected]> wrote:

Hi Greg,

Quoted 20 lines · Alan Tull
Quoted 18 lines

From: Moritz Fischer <[email protected]>

Use platform_get_drvdata() in remove() function of the platform driver rather than dev_get_drvdata() to match the platform_set_drvdata in the probe().

---
 drivers/fpga/dfl-fme-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl-fme-region.c +0 -0
index 51a5ac2..3fa0de2 100644
@@ -66,7 +66,7 @@ static int fme_region_probe(struct platform_device *pdev)
 
Quoted 6 lines

drivers/fpga/dfl-fme-region.c static int fme_region_probe(struct platform_device *pdev) · line 69

Quoted 4 lines
drivers/fpga/dfl-fme-region.c +1 -1
 static int fme_region_remove(struct platform_device *pdev)
 {
-     struct fpga_region *region = dev_get_drvdata(&pdev->dev);
+     struct fpga_region *region = platform_get_drvdata(pdev);

This is nice, but not a bugfix. I'll wait for 4.20-rc1 for this patch.

Could you take patch 4/5 and 5/5? They didn't make it into a 4.20 rc yet.

Alan

Quoted 4 lines

thanks,

greg k-h

author
#6 lore raw

Re: [PATCH 4/5] fpga: of-fpga-region: Use platform_set_drvdata

In reply to Greg Kroah-Hartman

On Sun, Sep 30, 2018 at 10:49 AM Greg Kroah-Hartman <[email protected]> wrote:

Hi Greg,

Quoted 21 lines · Alan Tull
Quoted 19 lines

From: Moritz Fischer <[email protected]>

Use platform_set_drvdata rather than dev_set_drvdata to match the platform_get_drvdata in the _remove() function of the platform driver.

---
 drivers/fpga/of-fpga-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/of-fpga-region.c +0 -0
index 052a134..d6a70e4 100644
@@ -421,7 +421,7 @@ static int of_fpga_region_probe(struct platform_device *pdev)
              goto eprobe_free;
 
Quoted 5 lines

drivers/fpga/of-fpga-region.c static int of_fpga_region_probe(struct platform_device *pdev) · line 424

Quoted 3 lines
drivers/fpga/of-fpga-region.c +1 -1
      of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
-     dev_set_drvdata(dev, region);
+     platform_set_drvdata(pdev, region);

Again, not really a bugfix :)

Could you take this patch 4/5 (just sent a reminder for 5/5)?

Thanks
Alan

#10 lore raw

Re: [PATCH 5/5] fpga: dfl-fme-region: Use platform_get_drvdata()

In reply to Alan Tull
Quoted 25 lines · Alan Tull

On Sun, Sep 30, 2018 at 10:48 AM Greg Kroah-Hartman <[email protected]> wrote:

Hi Greg,

Quoted 20 lines · Alan Tull
Quoted 18 lines

From: Moritz Fischer <[email protected]>

Use platform_get_drvdata() in remove() function of the platform driver rather than dev_get_drvdata() to match the platform_set_drvdata in the probe().

---
 drivers/fpga/dfl-fme-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl-fme-region.c +0 -0
index 51a5ac2..3fa0de2 100644
@@ -66,7 +66,7 @@ static int fme_region_probe(struct platform_device *pdev)
 
Quoted 8 lines
Quoted 6 lines

drivers/fpga/dfl-fme-region.c static int fme_region_probe(struct platform_device *pdev) · line 69

Quoted 4 lines
drivers/fpga/dfl-fme-region.c +1 -1
 static int fme_region_remove(struct platform_device *pdev)
 {
-     struct fpga_region *region = dev_get_drvdata(&pdev->dev);
+     struct fpga_region *region = platform_get_drvdata(pdev);

This is nice, but not a bugfix. I'll wait for 4.20-rc1 for this patch.

Could you take patch 4/5 and 5/5? They didn't make it into a 4.20 rc yet.

Can you resend them please? I don't see either of these in my queue anywhere.

thanks,

greg k-h

author
#11 lore raw

Re: [PATCH 5/5] fpga: dfl-fme-region: Use platform_get_drvdata()

Quoted 34 lines · Greg Kroah-Hartman
Quoted 32 lines · Alan Tull

On Sun, Sep 30, 2018 at 10:48 AM Greg Kroah-Hartman <[email protected]> wrote:

Hi Greg,

Quoted 26 lines · Alan Tull
Quoted 17 lines

From: Moritz Fischer <[email protected]>

Use platform_get_drvdata() in remove() function of the platform driver rather than dev_get_drvdata() to match the platform_set_drvdata in the probe().

---
 drivers/fpga/dfl-fme-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl-fme-region.c +0 -0
index 51a5ac2..3fa0de2 100644

drivers/fpga/dfl-fme-region.c static int fme_region_probe(struct platform_device *pdev) · line 69

Quoted 5 lines
drivers/fpga/dfl-fme-region.c +1 -1
@@ -66,7 +66,7 @@ static int fme_region_probe(struct platform_device *pdev)
 
 static int fme_region_remove(struct platform_device *pdev)
 {
-     struct fpga_region *region = dev_get_drvdata(&pdev->dev);
+     struct fpga_region *region = platform_get_drvdata(pdev);

This is nice, but not a bugfix. I'll wait for 4.20-rc1 for this patch.

Quoted 8 lines
Quoted 1 line

Could you take patch 4/5 and 5/5? They didn't make it into a 4.20 rc yet.

Can you resend them please? I don't see either of these in my queue anywhere.

thanks,

greg k-h

Sure! Just sent them.

Thanks,
Alan