All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nava kishore Manne <nava.manne@xilinx.com>
To: <mdf@kernel.org>, <hao.wu@intel.com>, <yilun.xu@intel.com>,
	<trix@redhat.com>, <robh+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <michal.simek@xilinx.com>,
	<nava.manne@xilinx.com>, <linux-fpga@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <git@xilinx.com>
Subject: [PATCH v2 3/3] fpga: region: Add runtime PM support
Date: Mon, 23 May 2022 19:15:17 +0530	[thread overview]
Message-ID: <20220523134517.4056873-4-nava.manne@xilinx.com> (raw)
In-Reply-To: <20220523134517.4056873-1-nava.manne@xilinx.com>

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

Signed-off-by: Nava kishore Manne <nava.manne@xilinx.com>
---
Changes for v2:
              - Updated commit message.
              - Updated runtime PM handling logic to fix the PM ref count
                imbalance issues.

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

diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c
index ae82532fc127..f14bb5916d97 100644
--- a/drivers/fpga/of-fpga-region.c
+++ b/drivers/fpga/of-fpga-region.c
@@ -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", },
@@ -301,10 +302,17 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
 		return -EINVAL;
 	}
 
+	ret = pm_runtime_resume_and_get(dev->parent);
+	if (ret < 0) {
+		fpga_image_info_free(info);
+		return ret;
+	}
+
 	region->info = info;
 	ret = fpga_region_program_fpga(region);
 	if (ret) {
 		/* error; reject overlay */
+		pm_runtime_put_sync(dev->parent);
 		fpga_image_info_free(info);
 		region->info = NULL;
 	}
@@ -324,10 +332,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_sync(dev->parent);
 }
 
 /**
@@ -411,6 +422,8 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 		goto eprobe_mgr_put;
 	}
 
+	pm_runtime_enable(&pdev->dev);
+
 	of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
 	platform_set_drvdata(pdev, region);
 
@@ -430,6 +443,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;
 }
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Nava kishore Manne <nava.manne@xilinx.com>
To: <mdf@kernel.org>, <hao.wu@intel.com>, <yilun.xu@intel.com>,
	<trix@redhat.com>, <robh+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>,  <michal.simek@xilinx.com>,
	<nava.manne@xilinx.com>, <linux-fpga@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <git@xilinx.com>
Subject: [PATCH v2 3/3] fpga: region: Add runtime PM support
Date: Mon, 23 May 2022 19:15:17 +0530	[thread overview]
Message-ID: <20220523134517.4056873-4-nava.manne@xilinx.com> (raw)
In-Reply-To: <20220523134517.4056873-1-nava.manne@xilinx.com>

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

Signed-off-by: Nava kishore Manne <nava.manne@xilinx.com>
---
Changes for v2:
              - Updated commit message.
              - Updated runtime PM handling logic to fix the PM ref count
                imbalance issues.

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

diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c
index ae82532fc127..f14bb5916d97 100644
--- a/drivers/fpga/of-fpga-region.c
+++ b/drivers/fpga/of-fpga-region.c
@@ -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", },
@@ -301,10 +302,17 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
 		return -EINVAL;
 	}
 
+	ret = pm_runtime_resume_and_get(dev->parent);
+	if (ret < 0) {
+		fpga_image_info_free(info);
+		return ret;
+	}
+
 	region->info = info;
 	ret = fpga_region_program_fpga(region);
 	if (ret) {
 		/* error; reject overlay */
+		pm_runtime_put_sync(dev->parent);
 		fpga_image_info_free(info);
 		region->info = NULL;
 	}
@@ -324,10 +332,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_sync(dev->parent);
 }
 
 /**
@@ -411,6 +422,8 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 		goto eprobe_mgr_put;
 	}
 
+	pm_runtime_enable(&pdev->dev);
+
 	of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
 	platform_set_drvdata(pdev, region);
 
@@ -430,6 +443,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;
 }
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-05-23 13:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-23 13:45 [PATCH v2 0/3]Enable PM generic domain support Nava kishore Manne
2022-05-23 13:45 ` Nava kishore Manne
2022-05-23 13:45 ` [PATCH v2 1/3] dt-bindings: zynqmp: Add new PD_PL macro Nava kishore Manne
2022-05-23 13:45   ` Nava kishore Manne
2022-05-23 13:45 ` [PATCH v2 2/3] fpga: region: Add fpga-region 'power-domains' property Nava kishore Manne
2022-05-23 13:45   ` Nava kishore Manne
2022-06-24 16:28   ` Xu Yilun
2022-06-24 16:28     ` Xu Yilun
2022-07-18  6:46     ` Manne, Nava kishore
2022-07-18  6:46       ` Manne, Nava kishore
2022-07-21  6:54       ` Xu Yilun
2022-07-21  6:54         ` Xu Yilun
2022-08-16 10:22         ` Manne, Nava kishore
2022-08-16 10:22           ` Manne, Nava kishore
2022-08-18  2:58           ` Xu Yilun
2022-08-18  2:58             ` Xu Yilun
2022-07-21  7:38   ` Krzysztof Kozlowski
2022-07-21  7:38     ` Krzysztof Kozlowski
2022-05-23 13:45 ` Nava kishore Manne [this message]
2022-05-23 13:45   ` [PATCH v2 3/3] fpga: region: Add runtime PM support Nava kishore Manne
2022-06-20  5:38   ` Manne, Nava kishore
2022-06-20  5:38     ` Manne, Nava kishore
2022-06-20  7:34     ` Xu Yilun
2022-06-20  7:34       ` Xu Yilun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220523134517.4056873-4-nava.manne@xilinx.com \
    --to=nava.manne@xilinx.com \
    --cc=devicetree@vger.kernel.org \
    --cc=git@xilinx.com \
    --cc=hao.wu@intel.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=robh+dt@kernel.org \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.