Skip to contentSkip to conversation

Enable PM generic domain support

PATCH In review Nava kishore Manne 6 participants 13 messages Apr 2, 2021 – Jun 2, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Enable PM generic domain support

Adds support to handle FPGA/PL power Domain to optimize the PL power consumption.

Nava kishore Manne (3):
dt-bindings: zynqmp: Add new PD_PL macro
fpga: region: Add fpga-region property 'power-domains'
fpga: region: Adds runtime PM support

 .../devicetree/bindings/fpga/fpga-region.txt   | 14 ++++++++++++++
 drivers/fpga/of-fpga-region.c                  | 18 +++++++++++++++++-
 include/dt-bindings/power/xlnx-zynqmp-power.h  |  1 +
 3 files changed, 32 insertions(+), 1 deletion(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/3 dt-bindings: zynqmp: Add new PD_PL macro

Add new power domain for PL region.

---
 include/dt-bindings/power/xlnx-zynqmp-power.h | 1 +
 1 file changed, 1 insertion(+)
include/dt-bindings/power/xlnx-zynqmp-power.h +1 -0
index 0d9a412fd5e0..5f718759c38f 100644
@@ -35,5 +35,6 @@
 #define		PD_CAN_1	48
 #define		PD_GPU		58
 #define		PD_PCIE		59
+#define		PD_PL		69
 
 #endif
Signature · 1 line
2.18.0
#3 lore raw

PATCH 2/3 fpga: region: Add fpga-region property 'power-domains'

In reply to Nava kishore Manne

Add fpga-region property 'power-domains' to allow to handle the FPGA/PL power domins.

dt-bindings: fpga: Enable PM generic domain support

---
 .../devicetree/bindings/fpga/fpga-region.txt       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +14 -0
index e811cf825019..969ca53bb65e 100644
@@ -196,6 +196,20 @@ Optional properties:
 - config-complete-timeout-us : The maximum time in microseconds time for the
 	FPGA to go to operating mode after the region has been programmed.
 - child nodes : devices in the FPGA after programming.
+- power-domains : A phandle and PM domain specifier as defined by bindings of
+	the power controller specified by phandle.
+Example:
+	fpga_full: fpga-full {
+                compatible = "fpga-region";
+                fpga-mgr = <&zynqmp_pcap>;
+                #address-cells = <2>;
+                #size-cells = <2>;
+                ranges;
+                power-domains = <&zynqmp_firmware PL_PD>;
+        };
+
+	The PL_PD power domain will be turned on before loading the bitstream
+and turned off while removing/unloading the bitstream using overlays.
 
 In the example below, when an overlay is applied targeting fpga-region0,
 fpga_mgr is used to program the FPGA.  Two bridges are controlled during
Signature · 1 line
2.18.0
maintainer
#4 lore raw

Re: [PATCH 2/3] fpga: region: Add fpga-region property 'power-domains'

Quoted 22 lines · Nava kishore Manne

Add fpga-region property 'power-domains' to allow to handle the FPGA/PL power domins.

dt-bindings: fpga: Enable PM generic domain support

---
 .../devicetree/bindings/fpga/fpga-region.txt       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +4 -0
index e811cf825019..969ca53bb65e 100644
@@ -196,6 +196,20 @@ Optional properties:
 - config-complete-timeout-us : The maximum time in microseconds time for the
 	FPGA to go to operating mode after the region has been programmed.
 - child nodes : devices in the FPGA after programming.
+- power-domains : A phandle and PM domain specifier as defined by bindings of
+	the power controller specified by phandle.
+Example:
+	fpga_full: fpga-full {

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 212

Quoted 10 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +10 -0
+                compatible = "fpga-region";
+                fpga-mgr = <&zynqmp_pcap>;
+                #address-cells = <2>;
+                #size-cells = <2>;
+                ranges;
+                power-domains = <&zynqmp_firmware PL_PD>;
+        };
+
+	The PL_PD power domain will be turned on before loading the bitstream
+and turned off while removing/unloading the bitstream using overlays.

Can multiple regions share a power-domain or is this specific to full fpga reconfiguration?

- Moritz

#5 lore raw

RE: [PATCH 2/3] fpga: region: Add fpga-region property 'power-domains'

Hi Moritz,

Thanks for the response.
Please find my response inline.

Quoted 50 lines

-----Original Message-----
From: Moritz Fischer <[email protected]>
Sent: Friday, April 2, 2021 10:46 PM
To: Nava kishore Manne <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; git <[email protected]>
Subject: Re: [PATCH 2/3] fpga: region: Add fpga-region property 'power- domains'

Quoted 16 lines · Nava kishore Manne

Add fpga-region property 'power-domains' to allow to handle the FPGA/PL power domins.

dt-bindings: fpga: Enable PM generic domain support

---
 .../devicetree/bindings/fpga/fpga-region.txt       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf825019..969ca53bb65e 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 196

Quoted 1 line
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
@@ -196,6 +196,20 @@ Optional properties:
 - config-complete-timeout-us : The maximum time in microseconds time

for the

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 197

Quoted 1 line
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
 	FPGA to go to operating mode after the region has been

programmed.

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 199

Quoted 2 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
 - child nodes : devices in the FPGA after programming.
+- power-domains : A phandle and PM domain specifier as defined by

bindings of

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties:

Quoted 13 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +13 -0
+	the power controller specified by phandle.
+Example:
+	fpga_full: fpga-full {
+                compatible = "fpga-region";
+                fpga-mgr = <&zynqmp_pcap>;
+                #address-cells = <2>;
+                #size-cells = <2>;
+                ranges;
+                power-domains = <&zynqmp_firmware PL_PD>;
+        };
+
+	The PL_PD power domain will be turned on before loading the
+bitstream and turned off while removing/unloading the bitstream using

overlays.

Quoted 3 lines

Can multiple regions share a power-domain or is this specific to full fpga reconfiguration?

These are generic changes and not limited to full region. If H/W supports individual power domains to control the Partial reconfiguration regions we can control the individual Partial reconfiguration region power domains as well.

Regards,
Navakishore.

maintainer Acked-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] fpga: region: Add fpga-region property 'power-domains'

In reply to Nava kishore Manne
Quoted 10 lines · Nava kishore Manne

Add fpga-region property 'power-domains' to allow to handle the FPGA/PL power domins.

dt-bindings: fpga: Enable PM generic domain support

---
 .../devicetree/bindings/fpga/fpga-region.txt       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
#7 lore raw

PATCH 3/3 fpga: region: Adds runtime PM support

In reply to Nava kishore Manne

Adds support to handle FPGA/PL power domain. With this patch, the PL power domain will be turned on before loading the bitstream and turned off while removing/unloading the bitstream using overlays. This can be achieved by adding the runtime PM support.

---
 drivers/fpga/of-fpga-region.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/fpga/of-fpga-region.c +17 -1
index e405309baadc..35fc2f3d4bd8 100644
@@ -15,6 +15,7 @@
 #include <linux/of_platform.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/pm_runtime.h>
 
 static const struct of_device_id fpga_region_of_match[] = {
 	{ .compatible = "fpga-region", },
@@ -302,6 +303,7 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
 	}
 
 	region->info = info;
+	pm_runtime_get_sync(dev->parent);
 	ret = fpga_region_program_fpga(region);
 	if (ret) {
 		/* error; reject overlay */
@@ -324,10 +326,13 @@ 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)
 {
+	struct device *dev = &region->dev;
+
 	fpga_bridges_disable(&region->bridge_list);
 	fpga_bridges_put(&region->bridge_list);
 	fpga_image_info_free(region->info);
 	region->info = NULL;
+	pm_runtime_put(dev->parent);
 }
 
 /**
@@ -411,9 +416,16 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 		goto eprobe_mgr_put;
 	}
 
+	pm_runtime_enable(&pdev->dev);
+	ret = pm_runtime_get_sync(&pdev->dev);
+	if (ret < 0)
+		goto err_pm;
+
+	pm_runtime_put(&pdev->dev);
+
 	ret = fpga_region_register(region);
 	if (ret)
-		goto eprobe_mgr_put;
+		goto err_pm;
 
 	of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
 	platform_set_drvdata(pdev, region);
@@ -422,6 +434,9 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_pm:
+	pm_runtime_put(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 eprobe_mgr_put:
 	fpga_mgr_put(mgr);
 	return ret;
@@ -434,6 +449,7 @@ static int of_fpga_region_remove(struct platform_device *pdev)
 
 	fpga_region_unregister(region);
 	fpga_mgr_put(mgr);
+	pm_runtime_disable(region->dev.parent);
 
 	return 0;
 }
Signature · 1 line
2.18.0
maintainer
#8 lore raw

Re: [PATCH 3/3] fpga: region: Adds runtime PM support

Quoted 83 lines · Nava kishore Manne

Adds support to handle FPGA/PL power domain. With this patch, the PL power domain will be turned on before loading the bitstream and turned off while removing/unloading the bitstream using overlays. This can be achieved by adding the runtime PM support.

---
 drivers/fpga/of-fpga-region.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/fpga/of-fpga-region.c +17 -1
index e405309baadc..35fc2f3d4bd8 100644
@@ -15,6 +15,7 @@
 #include <linux/of_platform.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/pm_runtime.h>
 
 static const struct of_device_id fpga_region_of_match[] = {
 	{ .compatible = "fpga-region", },
@@ -302,6 +303,7 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
 	}
 
 	region->info = info;
+	pm_runtime_get_sync(dev->parent);
 	ret = fpga_region_program_fpga(region);
 	if (ret) {
 		/* error; reject overlay */
@@ -324,10 +326,13 @@ 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)
 {
+	struct device *dev = &region->dev;
+
 	fpga_bridges_disable(&region->bridge_list);
 	fpga_bridges_put(&region->bridge_list);
 	fpga_image_info_free(region->info);
 	region->info = NULL;
+	pm_runtime_put(dev->parent);
 }
 
 /**
@@ -411,9 +416,16 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 		goto eprobe_mgr_put;
 	}
 
+	pm_runtime_enable(&pdev->dev);
+	ret = pm_runtime_get_sync(&pdev->dev);
+	if (ret < 0)
+		goto err_pm;
+
+	pm_runtime_put(&pdev->dev);
+
 	ret = fpga_region_register(region);
 	if (ret)
-		goto eprobe_mgr_put;
+		goto err_pm;
 
 	of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
 	platform_set_drvdata(pdev, region);
@@ -422,6 +434,9 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_pm:
+	pm_runtime_put(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 eprobe_mgr_put:
 	fpga_mgr_put(mgr);
 	return ret;
@@ -434,6 +449,7 @@ static int of_fpga_region_remove(struct platform_device *pdev)
 
 	fpga_region_unregister(region);
 	fpga_mgr_put(mgr);
+	pm_runtime_disable(region->dev.parent);
 
 	return 0;
 }
Signature · 1 line
2.18.0

Does this add a dependency on CONFIG_PM?

Thanks,
Moritz

#9 lore raw

RE: [PATCH 3/3] fpga: region: Adds runtime PM support

Hi Moritz,

Please find my response inline.

Quoted 96 lines

-----Original Message-----
From: Moritz Fischer <[email protected]>
Sent: Saturday, April 10, 2021 3:01 AM
To: Nava kishore Manne <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; git <[email protected]>
Subject: Re: [PATCH 3/3] fpga: region: Adds runtime PM support

drivers/fpga/of-fpga-region.c static int of_fpga_region_notify_pre_apply(struct

Quoted 24 lines · Nava kishore Manne

Adds support to handle FPGA/PL power domain. With this patch, the PL power domain will be turned on before loading the bitstream and turned off while removing/unloading the bitstream using overlays. This can be achieved by adding the runtime PM support.

---
 drivers/fpga/of-fpga-region.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/fpga/of-fpga-region.c index e405309baadc..35fc2f3d4bd8 100644

drivers/fpga/of-fpga-region.c +1 -0
@@ -15,6 +15,7 @@
 #include <linux/of_platform.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/pm_runtime.h>
 
 static const struct of_device_id fpga_region_of_match[] = {
 	{ .compatible = "fpga-region", },
@@ -302,6 +303,7 @@ static int of_fpga_region_notify_pre_apply(struct

fpga_region *region,

Quoted 9 lines
drivers/fpga/of-fpga-region.c +1 -0
 	}
 
 	region->info = info;
+	pm_runtime_get_sync(dev->parent);
 	ret = fpga_region_program_fpga(region);
 	if (ret) {
 		/* error; reject overlay */
@@ -324,10 +326,13 @@ static int

of_fpga_region_notify_pre_apply(struct fpga_region *region, static void

of_fpga_region_notify_post_remove(struct fpga_region *region,

Quoted 1 line

struct of_overlay_notify_data

*nd) {

drivers/fpga/of-fpga-region.c static int of_fpga_region_probe(struct

Quoted 11 lines
drivers/fpga/of-fpga-region.c +3 -0
+	struct device *dev = &region->dev;
+
 	fpga_bridges_disable(&region->bridge_list);
 	fpga_bridges_put(&region->bridge_list);
 	fpga_image_info_free(region->info);
 	region->info = NULL;
+	pm_runtime_put(dev->parent);
 }
 
 /**
@@ -411,9 +416,16 @@ static int of_fpga_region_probe(struct

platform_device *pdev)

Quoted 36 lines
drivers/fpga/of-fpga-region.c +8 -1
 		goto eprobe_mgr_put;
 	}
 
+	pm_runtime_enable(&pdev->dev);
+	ret = pm_runtime_get_sync(&pdev->dev);
+	if (ret < 0)
+		goto err_pm;
+
+	pm_runtime_put(&pdev->dev);
+
 	ret = fpga_region_register(region);
 	if (ret)
-		goto eprobe_mgr_put;
+		goto err_pm;
 
 	of_platform_populate(np, fpga_region_of_match, NULL, &region-
 dev);
drivers/fpga/of-fpga-region.c +3 -0
 	platform_set_drvdata(pdev, region);
@@ -422,6 +434,9 @@ static int of_fpga_region_probe(struct
 platform_device *pdev)
 
 	return 0;
 
+err_pm:
+	pm_runtime_put(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 eprobe_mgr_put:
 	fpga_mgr_put(mgr);
drivers/fpga/of-fpga-region.c +1 -0
 	return ret;
@@ -434,6 +449,7 @@ static int of_fpga_region_remove(struct
 platform_device *pdev)
 
 	fpga_region_unregister(region);
 	fpga_mgr_put(mgr);
+	pm_runtime_disable(region->dev.parent);
 
Quoted 8 lines
Quoted 5 lines
drivers/fpga/of-fpga-region.c +0 -0
 	return 0;

}
--
2.18.0

Does this add a dependency on CONFIG_PM?

Yes, the newly added functionality has a dependency on CONFIG_PM if it's disabled the expected power domain (in our cases it's PL) will not powered ON/OFF dynamically at runtime and this is as an expected behavior. Other than this it will not impact the any of the driver existing functionality.

Regards,
Navakishore.

#10 lore raw

RE: [PATCH 3/3] fpga: region: Adds runtime PM support

Ping!

Quoted 126 lines

-----Original Message-----
From: Nava kishore Manne
Sent: Monday, April 19, 2021 10:49 AM
To: Moritz Fischer <[email protected]>
Cc: [email protected]; [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; git <[email protected]>
Subject: RE: [PATCH 3/3] fpga: region: Adds runtime PM support

Hi Moritz,

Please find my response inline.

Quoted 97 lines

-----Original Message-----
From: Moritz Fischer <[email protected]>
Sent: Saturday, April 10, 2021 3:01 AM
To: Nava kishore Manne <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; git <[email protected]>
Subject: Re: [PATCH 3/3] fpga: region: Adds runtime PM support

Quoted 24 lines · Nava kishore Manne

Adds support to handle FPGA/PL power domain. With this patch, the PL power domain will be turned on before loading the bitstream and turned off while removing/unloading the bitstream using overlays. This can be achieved by adding the runtime PM support.

---
 drivers/fpga/of-fpga-region.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/fpga/of-fpga-region.c index e405309baadc..35fc2f3d4bd8 100644

drivers/fpga/of-fpga-region.c +1 -0
@@ -15,6 +15,7 @@
 #include <linux/of_platform.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/pm_runtime.h>
 
 static const struct of_device_id fpga_region_of_match[] = {
 	{ .compatible = "fpga-region", },
@@ -302,6 +303,7 @@ static int
Quoted 1 line

of_fpga_region_notify_pre_apply(struct

fpga_region *region,

Quoted 10 lines
drivers/fpga/of-fpga-region.c +1 -0
 	}
 
 	region->info = info;
+	pm_runtime_get_sync(dev->parent);
 	ret = fpga_region_program_fpga(region);
 	if (ret) {
 		/* error; reject overlay */
@@ -324,10 +326,13 @@ static int

of_fpga_region_notify_pre_apply(struct fpga_region *region, static void

of_fpga_region_notify_post_remove(struct fpga_region *region,

Quoted 1 line

struct of_overlay_notify_data

*nd) {

drivers/fpga/of-fpga-region.c static int of_fpga_region_probe(struct

Quoted 11 lines
drivers/fpga/of-fpga-region.c +3 -0
+	struct device *dev = &region->dev;
+
 	fpga_bridges_disable(&region->bridge_list);
 	fpga_bridges_put(&region->bridge_list);
 	fpga_image_info_free(region->info);
 	region->info = NULL;
+	pm_runtime_put(dev->parent);
 }
 
 /**
@@ -411,9 +416,16 @@ static int of_fpga_region_probe(struct

platform_device *pdev)

Quoted 35 lines
drivers/fpga/of-fpga-region.c +8 -1
 		goto eprobe_mgr_put;
 	}
 
+	pm_runtime_enable(&pdev->dev);
+	ret = pm_runtime_get_sync(&pdev->dev);
+	if (ret < 0)
+		goto err_pm;
+
+	pm_runtime_put(&pdev->dev);
+
 	ret = fpga_region_register(region);
 	if (ret)
-		goto eprobe_mgr_put;
+		goto err_pm;
 
 	of_platform_populate(np, fpga_region_of_match, NULL, &region-
 dev);

platform_set_drvdata(pdev, region); @@ -422,6 +434,9 @@ static
int of_fpga_region_probe(struct platform_device *pdev)

drivers/fpga/of-fpga-region.c +4 -0
 	return 0;
 
+err_pm:
+	pm_runtime_put(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 eprobe_mgr_put:
 	fpga_mgr_put(mgr);
 	return ret;
@@ -434,6 +449,7 @@ static int of_fpga_region_remove(struct
 platform_device *pdev)
 
 	fpga_region_unregister(region);
 	fpga_mgr_put(mgr);
+	pm_runtime_disable(region->dev.parent);
 
Quoted 8 lines
Quoted 5 lines
drivers/fpga/of-fpga-region.c +0 -0
 	return 0;

}
--
2.18.0

Does this add a dependency on CONFIG_PM?

Yes, the newly added functionality has a dependency on CONFIG_PM if it's disabled the expected power domain (in our cases it's PL) will not powered ON/OFF dynamically at runtime and this is as an expected behavior. Other than this it will not impact the any of the driver existing functionality.

Regards,
Navakishore.

reviewer
#11 lore raw

Re: [PATCH 3/3] fpga: region: Adds runtime PM support

Quoted 124 lines · Nava kishore Manne

Ping!

Quoted 122 lines

-----Original Message-----
From: Nava kishore Manne
Sent: Monday, April 19, 2021 10:49 AM
To: Moritz Fischer <[email protected]>
Cc: [email protected]; [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; git <[email protected]>
Subject: RE: [PATCH 3/3] fpga: region: Adds runtime PM support

Hi Moritz,

Please find my response inline.

Quoted 97 lines

-----Original Message-----
From: Moritz Fischer <[email protected]>
Sent: Saturday, April 10, 2021 3:01 AM
To: Nava kishore Manne <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; git <[email protected]>
Subject: Re: [PATCH 3/3] fpga: region: Adds runtime PM support

Quoted 24 lines · Nava kishore Manne

Adds support to handle FPGA/PL power domain. With this patch, the PL power domain will be turned on before loading the bitstream and turned off while removing/unloading the bitstream using overlays. This can be achieved by adding the runtime PM support.

---
  drivers/fpga/of-fpga-region.c | 18 +++++++++++++++++-
  1 file changed, 17 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/fpga/of-fpga-region.c index e405309baadc..35fc2f3d4bd8 100644

drivers/fpga/of-fpga-region.c +1 -0
@@ -15,6 +15,7 @@
  #include <linux/of_platform.h>
  #include <linux/slab.h>
  #include <linux/spinlock.h>
+#include <linux/pm_runtime.h>
 
  static const struct of_device_id fpga_region_of_match[] = {
  	{ .compatible = "fpga-region", },
@@ -302,6 +303,7 @@ static int
Quoted 1 line

of_fpga_region_notify_pre_apply(struct

fpga_region *region,

Quoted 10 lines
  	}

  	region->info = info;
drivers/fpga/of-fpga-region.c +1 -0
+	pm_runtime_get_sync(dev->parent);
  	ret = fpga_region_program_fpga(region);
  	if (ret) {
  		/* error; reject overlay */
@@ -324,10 +326,13 @@ static int

of_fpga_region_notify_pre_apply(struct fpga_region *region, static void

of_fpga_region_notify_post_remove(struct fpga_region *region,

Quoted 1 line

struct of_overlay_notify_data

*nd) {

drivers/fpga/of-fpga-region.c static int of_fpga_region_probe(struct

Quoted 11 lines
drivers/fpga/of-fpga-region.c +3 -0
+	struct device *dev = &region->dev;
+
  	fpga_bridges_disable(&region->bridge_list);
  	fpga_bridges_put(&region->bridge_list);
  	fpga_image_info_free(region->info);
  	region->info = NULL;
+	pm_runtime_put(dev->parent);
  }
 
  /**
@@ -411,9 +416,16 @@ static int of_fpga_region_probe(struct

platform_device *pdev)

Quoted 35 lines
drivers/fpga/of-fpga-region.c +8 -1
  		goto eprobe_mgr_put;
  	}
 
+	pm_runtime_enable(&pdev->dev);
+	ret = pm_runtime_get_sync(&pdev->dev);
+	if (ret < 0)
+		goto err_pm;
+
+	pm_runtime_put(&pdev->dev);
+
  	ret = fpga_region_register(region);
  	if (ret)
-		goto eprobe_mgr_put;
+		goto err_pm;
 
  	of_platform_populate(np, fpga_region_of_match, NULL, &region-
 dev);

platform_set_drvdata(pdev, region); @@ -422,6 +434,9 @@ static
int of_fpga_region_probe(struct platform_device *pdev)

return 0;

drivers/fpga/of-fpga-region.c +4 -0
+err_pm:
+	pm_runtime_put(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
  eprobe_mgr_put:
  	fpga_mgr_put(mgr);
  	return ret;
@@ -434,6 +449,7 @@ static int of_fpga_region_remove(struct
 platform_device *pdev)
 
  	fpga_region_unregister(region);
  	fpga_mgr_put(mgr);
+	pm_runtime_disable(region->dev.parent);
 
Quoted 7 lines
Quoted 5 lines
drivers/fpga/of-fpga-region.c +0 -0
  	return 0;

}
--
2.18.0

Does this add a dependency on CONFIG_PM?

Yes, the newly added functionality has a dependency on CONFIG_PM if it's disabled the expected power domain (in our cases it's PL) will not powered ON/OFF dynamically at runtime and this is as an expected behavior. Other than this it will not impact the any of the driver existing functionality.

This looks like a general change for a specific board.

Why can't this be done at the board level ?

Tom

Quoted 3 lines
Quoted 3 lines

Regards,
Navakishore.

#12 lore raw

Re: [PATCH 3/3] fpga: region: Adds runtime PM support

In reply to Nava kishore Manne
Quoted 16 lines · Nava kishore Manne

Adds support to handle FPGA/PL power domain. With this patch, the PL power domain will be turned on before loading the bitstream and turned off while removing/unloading the bitstream using overlays. This can be achieved by adding the runtime PM support.

---
 drivers/fpga/of-fpga-region.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

/**

drivers/fpga/of-fpga-region.c +1 -0
@@ -411,9 +416,16 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 		goto eprobe_mgr_put;
 	}
 
+	pm_runtime_enable(&pdev->dev);

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

Quoted 10 lines
drivers/fpga/of-fpga-region.c +7 -1
+	ret = pm_runtime_get_sync(&pdev->dev);
+	if (ret < 0)
+		goto err_pm;
+
+	pm_runtime_put(&pdev->dev);
+
 	ret = fpga_region_register(region);
 	if (ret)
-		goto eprobe_mgr_put;
+		goto err_pm;

Just a drive-by comment: you have PM usage counter imbalance here (double put).

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

Quoted 12 lines
drivers/fpga/of-fpga-region.c +3 -0
 	of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
 	platform_set_drvdata(pdev, region);
@@ -422,6 +434,9 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_pm:
+	pm_runtime_put(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 eprobe_mgr_put:
 	fpga_mgr_put(mgr);
 	return ret;

Johan