All of lore.kernel.org
 help / color / mirror / Atom feed
From: Archit Taneja <architt@codeaurora.org>
To: robdclark@gmail.com
Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	robh@kernel.org, Archit Taneja <architt@codeaurora.org>
Subject: [PATCH v2 11/25] drm/msm: Call pm_runtime_enable/disable for newly created devices
Date: Thu, 23 Jun 2016 19:43:16 +0530	[thread overview]
Message-ID: <1466691210-22779-12-git-send-email-architt@codeaurora.org> (raw)
In-Reply-To: <1466691210-22779-1-git-send-email-architt@codeaurora.org>

With the new device hierarchy for MDP5, we need to enable runtime PM
for both the toplevel MDSS device and the MDP5 device itself. Enable
runtime PM for the new devices.

Since MDP4 and MDP5 now have different places where runtime PM is
enabled, remove the previous pm_runtime_enable/disable calls, and
squash them in the respective kms drivers.

The new device hierarchy (as expressed in the DT bindings) has the GDSC
tied only to the MDSS wrapper device. This GDSC needs to be enabled for
accessing any register in the MDSS sub-blocks. Once every driver is
runtime adapted, the GDSC will be enabled when any sub-block device
calls runtime_get because of the parent-child relationship with MDSS.

Until then, we call pm_runtime_get_sync() once for the MDSS device to
ensure the GDSC is never disabled. This will be removed once all the
drivers are runtime PM adapted.

The error handling paths become a bit tricky when we call these runtime
PM funcs. There doesn't seem to be any helper that checks if runtime PM
is enabled already. Add bool variables in mdp4_kms/mdp5_kms structs to
check if the driver had managed to call pm_runtime_enable before bailing
out.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c  |  8 ++++++++
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h  |  2 ++
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c  |  6 ++++++
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h  |  2 ++
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c | 12 ++++++++++++
 drivers/gpu/drm/msm/msm_drv.c            |  5 +----
 6 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
index 0e751c0..70b96bb 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
@@ -158,6 +158,7 @@ static const char * const iommu_ports[] = {
 static void mdp4_destroy(struct msm_kms *kms)
 {
 	struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
+	struct device *dev = mdp4_kms->dev->dev;
 	struct msm_mmu *mmu = mdp4_kms->mmu;
 
 	if (mmu) {
@@ -169,6 +170,10 @@ static void mdp4_destroy(struct msm_kms *kms)
 		msm_gem_put_iova(mdp4_kms->blank_cursor_bo, mdp4_kms->id);
 	if (mdp4_kms->blank_cursor_bo)
 		drm_gem_object_unreference_unlocked(mdp4_kms->blank_cursor_bo);
+
+	if (mdp4_kms->rpm_enabled)
+		pm_runtime_disable(dev);
+
 	kfree(mdp4_kms);
 }
 
@@ -515,6 +520,9 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)
 	clk_set_rate(mdp4_kms->clk, config->max_clk);
 	clk_set_rate(mdp4_kms->lut_clk, config->max_clk);
 
+	pm_runtime_enable(dev->dev);
+	mdp4_kms->rpm_enabled = true;
+
 	/* make sure things are off before attaching iommu (bootloader could
 	 * have left things on, in which case we'll start getting faults if
 	 * we don't disable):
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
index c5d045d..25fb839 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
@@ -47,6 +47,8 @@ struct mdp4_kms {
 
 	struct mdp_irq error_handler;
 
+	bool rpm_enabled;
+
 	/* empty/blank cursor bo to use when cursor is "disabled" */
 	struct drm_gem_object *blank_cursor_bo;
 	uint32_t blank_cursor_iova;
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
index a0b9747..5d6d9e1 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
@@ -668,6 +668,9 @@ static void mdp5_destroy(struct platform_device *pdev)
 		mdp5_smp_destroy(mdp5_kms->smp);
 	if (mdp5_kms->cfg)
 		mdp5_cfg_destroy(mdp5_kms->cfg);
+
+	if (mdp5_kms->rpm_enabled)
+		pm_runtime_disable(&pdev->dev);
 }
 
 static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)
@@ -720,6 +723,9 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)
 	 */
 	clk_set_rate(mdp5_kms->core_clk, 200000000);
 
+	pm_runtime_enable(&pdev->dev);
+	mdp5_kms->rpm_enabled = true;
+
 	read_mdp_hw_revision(mdp5_kms, &major, &minor);
 
 	mdp5_kms->cfg = mdp5_cfg_init(mdp5_kms, major, minor);
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
index d214d50..0373892 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
@@ -59,6 +59,8 @@ struct mdp5_kms {
 	 */
 	spinlock_t resource_lock;
 
+	bool rpm_enabled;
+
 	struct mdp_irq error_handler;
 };
 #define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base)
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c
index 871c442..d444a69 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c
@@ -152,6 +152,10 @@ void msm_mdss_destroy(struct drm_device *dev)
 	mdss->irqcontroller.domain = NULL;
 
 	regulator_disable(mdss->vdd);
+
+	pm_runtime_put_sync(dev->dev);
+
+	pm_runtime_disable(dev->dev);
 }
 
 int msm_mdss_init(struct drm_device *dev)
@@ -215,6 +219,14 @@ int msm_mdss_init(struct drm_device *dev)
 
 	priv->mdss = mdss;
 
+	pm_runtime_enable(dev->dev);
+
+	/*
+	 * TODO: This is needed as the MDSS GDSC is only tied to MDSS's power
+	 * domain. Remove this once runtime PM is adapted for all the devices.
+	 */
+	pm_runtime_get_sync(dev->dev);
+
 	return 0;
 fail_irq:
 	regulator_disable(mdss->vdd);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index d650aac..1c18690 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -215,10 +215,8 @@ static int msm_drm_uninit(struct device *dev)
 	flush_workqueue(priv->atomic_wq);
 	destroy_workqueue(priv->atomic_wq);
 
-	if (kms) {
-		pm_runtime_disable(dev);
+	if (kms)
 		kms->funcs->destroy(kms);
-	}
 
 	if (gpu) {
 		mutex_lock(&ddev->struct_mutex);
@@ -410,7 +408,6 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
 	}
 
 	if (kms) {
-		pm_runtime_enable(dev);
 		ret = kms->funcs->hw_init(kms);
 		if (ret) {
 			dev_err(dev, "kms hw init failed: %d\n", ret);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

  parent reply	other threads:[~2016-06-23 14:14 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 11:36 [PATCH 00/22] drm/msm: Enable DT support Archit Taneja
2016-06-16 11:36 ` [PATCH 01/22] drm/msm: Drop the id_table in platform_driver Archit Taneja
2016-06-16 11:36 ` [PATCH 02/22] drm/msm: Remove unused fields Archit Taneja
2016-06-16 11:36 ` [PATCH 03/22] drm/msm: Get irq number within kms driver itself Archit Taneja
2016-06-16 11:36 ` [PATCH 04/22] drm/msm/mdp5: Add MDSS top level driver Archit Taneja
2016-06-16 11:36 ` [PATCH 05/22] drm/msm/mdp5: Create a separate MDP5 device Archit Taneja
2016-06-16 11:36 ` [PATCH 06/22] drm/msm/mdp5: Prepare new kms_init funcs Archit Taneja
2016-06-16 11:36 ` [PATCH 07/22] drm/msm/mdp5: Use the new hierarchy and drop old irq management Archit Taneja
2016-06-16 11:36 ` [PATCH 08/22] drm/msm/mdp5: Remove old kms init/destroy funcs Archit Taneja
2016-06-16 11:36 ` [PATCH 09/22] drm/msm/mdp5: Use updated MDP5 register names Archit Taneja
2016-06-16 11:36 ` [PATCH 10/22] drm/msm/mdp5: Update the register offsets of MDP5 sub-blocks Archit Taneja
2016-06-16 11:36 ` [PATCH 11/22] drm/msm: Call pm_runtime_enable/disable for newly created devices Archit Taneja
2016-06-16 11:36 ` [PATCH 12/22] drm/msm/mdp5: Add missing mdp5_enable/disable calls Archit Taneja
2016-06-16 11:36 ` [PATCH 13/22] drm/msm: Create separate funcs for adding display/gpu components Archit Taneja
2016-06-16 11:36 ` [PATCH 14/22] drm/msm: Add display components by parsing MDP ports Archit Taneja
2016-06-16 11:36 ` [PATCH 15/22] drm/msm: Add components for MDP5 Archit Taneja
2016-06-16 11:36 ` [PATCH 16/22] drm/msm: Drop the gpu binding Archit Taneja
2016-06-16 11:36 ` [PATCH 17/22] drm/msm/mdp5: Update compatible strings for MDSS/MDP5 Archit Taneja
2016-06-16 11:36 ` [PATCH 18/22] dt-bindings: msm/mdp4: Create a separate binding doc for MDP4 Archit Taneja
2016-06-20 12:53   ` Rob Herring
2016-06-16 11:36 ` [PATCH 19/22] dt-bindings: msm/mdp5: Add MDP5 display bindings Archit Taneja
2016-06-20 12:57   ` Rob Herring
2016-06-16 11:36 ` [PATCH 20/22] dt-bindings: msm/mdp: Provide details on MDP interface ports Archit Taneja
2016-06-20 13:01   ` Rob Herring
2016-06-16 11:36 ` [PATCH 21/22] arm64: dts: msm8916: Add display support Archit Taneja
2016-06-20 13:04   ` Rob Herring
2016-06-20 13:47     ` Archit Taneja
2016-06-16 11:36 ` [PATCH 22/22] arm64: dts: apq8016-sbc: Add HDMI " Archit Taneja
2016-06-23 14:13 ` [PATCH v2 00/25] drm/msm: Enable DT support Archit Taneja
2016-06-23 14:13   ` [PATCH v2 01/25] drm/msm: Drop the id_table in platform_driver Archit Taneja
2016-06-23 14:13   ` [PATCH v2 02/25] drm/msm: Remove unused fields Archit Taneja
2016-06-23 14:13   ` [PATCH v2 03/25] drm/msm: Get irq number within kms driver itself Archit Taneja
2016-06-23 14:13   ` [PATCH v2 04/25] drm/msm/mdp5: Add MDSS top level driver Archit Taneja
2016-06-23 14:13   ` [PATCH v2 05/25] drm/msm/mdp5: Create a separate MDP5 device Archit Taneja
2016-06-23 14:13   ` [PATCH v2 06/25] drm/msm/mdp5: Prepare new kms_init funcs Archit Taneja
2016-06-23 14:13   ` [PATCH v2 07/25] drm/msm/mdp5: Use the new hierarchy and drop old irq management Archit Taneja
2016-06-23 14:13   ` [PATCH v2 08/25] drm/msm/mdp5: Remove old kms init/destroy funcs Archit Taneja
2016-06-23 14:13   ` [PATCH v2 09/25] drm/msm/mdp5: Use updated MDP5 register names Archit Taneja
2016-06-23 14:13   ` [PATCH v2 10/25] drm/msm/mdp5: Update the register offsets of MDP5 sub-blocks Archit Taneja
2016-06-23 14:13   ` Archit Taneja [this message]
2016-06-23 14:13   ` [PATCH v2 12/25] drm/msm/mdp5: Add missing mdp5_enable/disable calls Archit Taneja
2016-06-23 14:13   ` [PATCH v2 13/25] drm/msm: Create separate funcs for adding display/gpu components Archit Taneja
2016-06-23 14:13   ` [PATCH v2 14/25] drm/msm: Add display components by parsing MDP ports Archit Taneja
2016-06-23 14:13   ` [PATCH v2 15/25] drm/msm: Add components for MDP5 Archit Taneja
2016-06-23 14:13   ` [PATCH v2 16/25] drm/msm: Drop the gpu binding Archit Taneja
2016-06-23 14:13   ` [PATCH v2 17/25] drm/msm/mdp5: Update compatible strings for MDSS/MDP5 Archit Taneja
2016-07-11  8:39     ` Matthias Brugger
2016-07-11 11:33       ` Rob Clark
2016-06-23 14:13   ` [PATCH v2 18/25] drm/msm/dsi: Don't get DSI index from DT Archit Taneja
2016-06-23 14:45     ` Rob Herring
2016-06-24  5:00       ` Archit Taneja
2016-06-23 14:13   ` [PATCH v2 19/25] dt-bindings: msm/mdp4: Create a separate binding doc for MDP4 Archit Taneja
2016-06-23 14:13   ` [PATCH v2 20/25] dt-bindings: msm/mdp5: Add MDP5 display bindings Archit Taneja
2016-06-23 14:13   ` [PATCH v2 21/25] dt-bindings: msm/mdp: Provide details on MDP interface ports Archit Taneja
2016-06-23 14:13   ` [PATCH v2 22/25] dt-bindings: msm/dsi: Remove unused properties Archit Taneja
2016-08-26  4:55     ` Archit Taneja
2016-06-23 14:13   ` [PATCH v2 23/25] dt-bindings: display/msm: Remove power domain property from encoder nodes Archit Taneja
2016-08-26  4:55     ` Archit Taneja
2016-06-23 14:13   ` [PATCH v2 24/25] arm64: dts: msm8916: Add display support Archit Taneja
2016-08-26  4:57     ` Archit Taneja
2016-08-26 12:12       ` Rob Herring
     [not found]     ` <1466691210-22779-25-git-send-email-architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-08-26  5:33       ` Andy Gross
     [not found]   ` <1466691210-22779-1-git-send-email-architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-06-23 14:13     ` [PATCH v2 25/25] arm64: dts: apq8016-sbc: Add HDMI " Archit Taneja
2016-08-26  4:58       ` Archit Taneja
2016-08-26  5:34       ` Andy Gross

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=1466691210-22779-12-git-send-email-architt@codeaurora.org \
    --to=architt@codeaurora.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=robdclark@gmail.com \
    --cc=robh@kernel.org \
    /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.