LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3 0/5] Enhance support for system and runtime power management on malidp.
@ 2018-04-24 18:12 Ayan Kumar Halder
  2018-04-24 18:12 ` [PATCH v3 1/5] drm/arm/malidp: Modified the prototype of malidp irq de-initializers Ayan Kumar Halder
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Ayan Kumar Halder @ 2018-04-24 18:12 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, malidp, airlied,
	dri-devel, linux-kernel
  Cc: nd

This patch series enhances and fixes certain issues relevant to system and
runtime power management on malidp.

---
Changes in v3:
- Squashed some commits. 
- Fixed an issue related to writeback.
  Reported-by: Alexandru-Cosmin Gheorghe <Alexandru-Cosmin.Gheorghe@arm.com>

Changes in v2:
- Removed the change ids and modified some commit messages

---
Ayan Kumar Halder (5):
  drm/arm/malidp: Modified the prototype of malidp irq de-initializers
  drm/arm/malidp: Split malidp interrupt initialization functions.
  drm/arm/malidp: Enable/disable interrupts in runtime pm
  drm/arm/malidp: Set the output_depth register in modeset
  drm/arm/malidp: Added the late system pm functions

 drivers/gpu/drm/arm/malidp_drv.c | 35 +++++++++++++++++++++++----
 drivers/gpu/drm/arm/malidp_hw.c  | 52 +++++++++++++++++++++++++++-------------
 drivers/gpu/drm/arm/malidp_hw.h  |  7 ++++--
 3 files changed, 70 insertions(+), 24 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 1/5] drm/arm/malidp: Modified the prototype of malidp irq de-initializers
  2018-04-24 18:12 [PATCH v3 0/5] Enhance support for system and runtime power management on malidp Ayan Kumar Halder
@ 2018-04-24 18:12 ` Ayan Kumar Halder
  2018-04-24 18:12 ` [PATCH v3 2/5] drm/arm/malidp: Split malidp interrupt initialization functions Ayan Kumar Halder
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Ayan Kumar Halder @ 2018-04-24 18:12 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, malidp, airlied,
	dri-devel, linux-kernel
  Cc: nd

Malidp uses two interrupts ie 1. se_irq - used for memory writeback. 
 and 2. de_irq - used for display output.
'struct drm_device' is being replaced with 'struct malidp_hw_device'
as the function argument. The reason being the dependency of
malidp_de_irq_fini on 'struct drm_device' needs to be removed so as to
enable it to call from functions which receives 'struct malidp_hw_device'
as argument. Furthermore, there is no way to retrieve 'struct drm_device'
from 'struct malidp_hw_device'.

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>

---
Changes in v3:-
- Squashed https://patchwork.kernel.org/patch/10357201/ and 
https://patchwork.kernel.org/patch/10308283/ into a single commit.
The reason being that although the two functions belong to different units
of malidp (ie scaling engine and display engine), the intent for modifying 
the prototype of these functions remain the same.

Changes in v2:-
- Removed the change id and modified the commit messages
---
 drivers/gpu/drm/arm/malidp_drv.c | 13 ++++++++-----
 drivers/gpu/drm/arm/malidp_hw.c  | 10 ++--------
 drivers/gpu/drm/arm/malidp_hw.h  |  4 ++--
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 4b0c4b4..f7a8beb 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -295,6 +295,8 @@ static int malidp_irq_init(struct platform_device *pdev)
 {
 	int irq_de, irq_se, ret = 0;
 	struct drm_device *drm = dev_get_drvdata(&pdev->dev);
+	struct malidp_drm *malidp = drm->dev_private;
+	struct malidp_hw_device *hwdev = malidp->dev;
 
 	/* fetch the interrupts from DT */
 	irq_de = platform_get_irq_byname(pdev, "DE");
@@ -314,7 +316,7 @@ static int malidp_irq_init(struct platform_device *pdev)
 
 	ret = malidp_se_irq_init(drm, irq_se);
 	if (ret) {
-		malidp_de_irq_fini(drm);
+		malidp_de_irq_fini(hwdev);
 		return ret;
 	}
 
@@ -651,8 +653,8 @@ static int malidp_bind(struct device *dev)
 fbdev_fail:
 	pm_runtime_get_sync(dev);
 vblank_fail:
-	malidp_se_irq_fini(drm);
-	malidp_de_irq_fini(drm);
+	malidp_se_irq_fini(hwdev);
+	malidp_de_irq_fini(hwdev);
 	drm->irq_enabled = false;
 irq_init_fail:
 	component_unbind_all(dev, drm);
@@ -681,14 +683,15 @@ static void malidp_unbind(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
 	struct malidp_drm *malidp = drm->dev_private;
+	struct malidp_hw_device *hwdev = malidp->dev;
 
 	drm_dev_unregister(drm);
 	drm_fb_cma_fbdev_fini(drm);
 	drm_kms_helper_poll_fini(drm);
 	pm_runtime_get_sync(dev);
 	drm_crtc_vblank_off(&malidp->crtc);
-	malidp_se_irq_fini(drm);
-	malidp_de_irq_fini(drm);
+	malidp_se_irq_fini(hwdev);
+	malidp_de_irq_fini(hwdev);
 	drm->irq_enabled = false;
 	component_unbind_all(dev, drm);
 	of_node_put(malidp->crtc.port);
diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
index e4d9ebc..8fb02f3 100644
--- a/drivers/gpu/drm/arm/malidp_hw.c
+++ b/drivers/gpu/drm/arm/malidp_hw.c
@@ -900,11 +900,8 @@ int malidp_de_irq_init(struct drm_device *drm, int irq)
 	return 0;
 }
 
-void malidp_de_irq_fini(struct drm_device *drm)
+void malidp_de_irq_fini(struct malidp_hw_device *hwdev)
 {
-	struct malidp_drm *malidp = drm->dev_private;
-	struct malidp_hw_device *hwdev = malidp->dev;
-
 	malidp_hw_disable_irq(hwdev, MALIDP_DE_BLOCK,
 			      hwdev->hw->map.de_irq_map.irq_mask);
 	malidp_hw_disable_irq(hwdev, MALIDP_DC_BLOCK,
@@ -973,11 +970,8 @@ int malidp_se_irq_init(struct drm_device *drm, int irq)
 	return 0;
 }
 
-void malidp_se_irq_fini(struct drm_device *drm)
+void malidp_se_irq_fini(struct malidp_hw_device *hwdev)
 {
-	struct malidp_drm *malidp = drm->dev_private;
-	struct malidp_hw_device *hwdev = malidp->dev;
-
 	malidp_hw_disable_irq(hwdev, MALIDP_SE_BLOCK,
 			      hwdev->hw->map.se_irq_map.irq_mask);
 }
diff --git a/drivers/gpu/drm/arm/malidp_hw.h b/drivers/gpu/drm/arm/malidp_hw.h
index a242e97..6607aba 100644
--- a/drivers/gpu/drm/arm/malidp_hw.h
+++ b/drivers/gpu/drm/arm/malidp_hw.h
@@ -297,9 +297,9 @@ static inline void malidp_hw_enable_irq(struct malidp_hw_device *hwdev,
 }
 
 int malidp_de_irq_init(struct drm_device *drm, int irq);
-void malidp_de_irq_fini(struct drm_device *drm);
+void malidp_de_irq_fini(struct malidp_hw_device *hwdev);
 int malidp_se_irq_init(struct drm_device *drm, int irq);
-void malidp_se_irq_fini(struct drm_device *drm);
+void malidp_se_irq_fini(struct malidp_hw_device *hwdev);
 
 u8 malidp_hw_get_format_id(const struct malidp_hw_regmap *map,
 			   u8 layer_id, u32 format);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 2/5] drm/arm/malidp: Split malidp interrupt initialization functions.
  2018-04-24 18:12 [PATCH v3 0/5] Enhance support for system and runtime power management on malidp Ayan Kumar Halder
  2018-04-24 18:12 ` [PATCH v3 1/5] drm/arm/malidp: Modified the prototype of malidp irq de-initializers Ayan Kumar Halder
@ 2018-04-24 18:12 ` Ayan Kumar Halder
  2018-04-24 18:12 ` [PATCH v3 3/5] drm/arm/malidp: Enable/disable interrupts in runtime pm Ayan Kumar Halder
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Ayan Kumar Halder @ 2018-04-24 18:12 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, malidp, airlied,
	dri-devel, linux-kernel
  Cc: nd

Malidp uses two interrupts ie 1. se_irq - used for memory writeback. 
 and 2. de_irq - used for display output.
Extract the hardware initialization part from malidp interrupt registration
ie (malidp_de_irq_init()/ malidp_se_irq_init()) into a separate function 
(ie malidp_de_irq_hw_init()/malidp_se_irq_hw_init())
which will be later invoked from runtime_pm_resume function when it needs
to re-enable the interrupts.

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>

---
Changes in v3:-
- Squashed https://patchwork.kernel.org/patch/10357203/ and 
https://patchwork.kernel.org/patch/10357209/ into a single commit.
The reason being that although the two functions belong to different units
of malidp (ie scaling engine and display engine), the intent for splitting 
these functions remain the same.

Changes in v2:-
- Removed the change id
---
 drivers/gpu/drm/arm/malidp_hw.c | 38 +++++++++++++++++++++++++++++---------
 drivers/gpu/drm/arm/malidp_hw.h |  2 ++
 2 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
index 8fb02f3..3f53f7e8 100644
--- a/drivers/gpu/drm/arm/malidp_hw.c
+++ b/drivers/gpu/drm/arm/malidp_hw.c
@@ -869,6 +869,23 @@ static irqreturn_t malidp_de_irq_thread_handler(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+void malidp_de_irq_hw_init(struct malidp_hw_device *hwdev)
+{
+	/* ensure interrupts are disabled */
+	malidp_hw_disable_irq(hwdev, MALIDP_DE_BLOCK, 0xffffffff);
+	malidp_hw_clear_irq(hwdev, MALIDP_DE_BLOCK, 0xffffffff);
+	malidp_hw_disable_irq(hwdev, MALIDP_DC_BLOCK, 0xffffffff);
+	malidp_hw_clear_irq(hwdev, MALIDP_DC_BLOCK, 0xffffffff);
+
+	/* first enable the DC block IRQs */
+	malidp_hw_enable_irq(hwdev, MALIDP_DC_BLOCK,
+			     hwdev->hw->map.dc_irq_map.irq_mask);
+
+	/* now enable the DE block IRQs */
+	malidp_hw_enable_irq(hwdev, MALIDP_DE_BLOCK,
+			     hwdev->hw->map.de_irq_map.irq_mask);
+}
+
 int malidp_de_irq_init(struct drm_device *drm, int irq)
 {
 	struct malidp_drm *malidp = drm->dev_private;
@@ -889,13 +906,7 @@ int malidp_de_irq_init(struct drm_device *drm, int irq)
 		return ret;
 	}
 
-	/* first enable the DC block IRQs */
-	malidp_hw_enable_irq(hwdev, MALIDP_DC_BLOCK,
-			     hwdev->hw->map.dc_irq_map.irq_mask);
-
-	/* now enable the DE block IRQs */
-	malidp_hw_enable_irq(hwdev, MALIDP_DE_BLOCK,
-			     hwdev->hw->map.de_irq_map.irq_mask);
+	malidp_de_irq_hw_init(hwdev);
 
 	return 0;
 }
@@ -941,6 +952,16 @@ static irqreturn_t malidp_se_irq(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+void malidp_se_irq_hw_init(struct malidp_hw_device *hwdev)
+{
+	/* ensure interrupts are disabled */
+	malidp_hw_disable_irq(hwdev, MALIDP_SE_BLOCK, 0xffffffff);
+	malidp_hw_clear_irq(hwdev, MALIDP_SE_BLOCK, 0xffffffff);
+
+	malidp_hw_enable_irq(hwdev, MALIDP_SE_BLOCK,
+			     hwdev->hw->map.se_irq_map.irq_mask);
+}
+
 static irqreturn_t malidp_se_irq_thread_handler(int irq, void *arg)
 {
 	return IRQ_HANDLED;
@@ -964,8 +985,7 @@ int malidp_se_irq_init(struct drm_device *drm, int irq)
 		return ret;
 	}
 
-	malidp_hw_enable_irq(hwdev, MALIDP_SE_BLOCK,
-			     hwdev->hw->map.se_irq_map.irq_mask);
+	malidp_se_irq_hw_init(hwdev);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/arm/malidp_hw.h b/drivers/gpu/drm/arm/malidp_hw.h
index 6607aba..864fe92 100644
--- a/drivers/gpu/drm/arm/malidp_hw.h
+++ b/drivers/gpu/drm/arm/malidp_hw.h
@@ -297,6 +297,8 @@ static inline void malidp_hw_enable_irq(struct malidp_hw_device *hwdev,
 }
 
 int malidp_de_irq_init(struct drm_device *drm, int irq);
+void malidp_se_irq_hw_init(struct malidp_hw_device *hwdev);
+void malidp_de_irq_hw_init(struct malidp_hw_device *hwdev);
 void malidp_de_irq_fini(struct malidp_hw_device *hwdev);
 int malidp_se_irq_init(struct drm_device *drm, int irq);
 void malidp_se_irq_fini(struct malidp_hw_device *hwdev);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 3/5] drm/arm/malidp: Enable/disable interrupts in runtime pm
  2018-04-24 18:12 [PATCH v3 0/5] Enhance support for system and runtime power management on malidp Ayan Kumar Halder
  2018-04-24 18:12 ` [PATCH v3 1/5] drm/arm/malidp: Modified the prototype of malidp irq de-initializers Ayan Kumar Halder
  2018-04-24 18:12 ` [PATCH v3 2/5] drm/arm/malidp: Split malidp interrupt initialization functions Ayan Kumar Halder
@ 2018-04-24 18:12 ` Ayan Kumar Halder
  2018-04-24 18:12 ` [PATCH v3 4/5] drm/arm/malidp: Set the output_depth register in modeset Ayan Kumar Halder
  2018-04-24 18:12 ` [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions Ayan Kumar Halder
  4 siblings, 0 replies; 12+ messages in thread
From: Ayan Kumar Halder @ 2018-04-24 18:12 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, malidp, airlied,
	dri-devel, linux-kernel
  Cc: nd, Alexandru-Cosmin Gheorghe

Display and scaling engine interrupts need to be disabled when the
runtime pm invokes malidp_runtime_pm_suspend(). Conversely, they
need to be enabled in malidp_runtime_pm_resume().

This patch depends on:
https://lkml.org/lkml/2017/5/15/695

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
Signed-off-by: Alexandru-Cosmin Gheorghe <Alexandru-Cosmin.Gheorghe@arm.com>
Reported-by: Alexandru-Cosmin Gheorghe <Alexandru-Cosmin.Gheorghe@arm.com>

---
Changes in v3:-
- Abandoned https://patchwork.kernel.org/patch/10357213/ bacause scaling (aka 
writeback) interrupts are enabled or disabled when a commit posts a scene 
with or without writeback framebuffer respectively. This causes an issue in the
following sequence:-
(It is to be noted that scaling engine interrupts are used for writeback)
1. Commit with writeback attached.
2. Before writeback finishes, commit without writeback, which calls 
disable_writeback -> disable scaling interrupts (ie clears the scaling
interrupt mask).
3. Scaling (ie for writeback completion) interrupt is called for commit
 in step 1. However, as the scaling interrupt mask has been cleared by
step 2, so writeback completion is not signalled to userspace app. 
This is a BUG.

Changes in v2:-
- Removed the change id
---
 drivers/gpu/drm/arm/malidp_drv.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index f7a8beb..983b854 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -470,6 +470,8 @@ static int malidp_runtime_pm_suspend(struct device *dev)
 	/* we can only suspend if the hardware is in config mode */
 	WARN_ON(!hwdev->hw->in_config_mode(hwdev));
 
+	malidp_se_irq_fini(hwdev);
+	malidp_de_irq_fini(hwdev);
 	hwdev->pm_suspended = true;
 	clk_disable_unprepare(hwdev->mclk);
 	clk_disable_unprepare(hwdev->aclk);
@@ -488,6 +490,8 @@ static int malidp_runtime_pm_resume(struct device *dev)
 	clk_prepare_enable(hwdev->aclk);
 	clk_prepare_enable(hwdev->mclk);
 	hwdev->pm_suspended = false;
+	malidp_de_irq_hw_init(hwdev);
+	malidp_se_irq_hw_init(hwdev);
 
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 4/5] drm/arm/malidp: Set the output_depth register in modeset
  2018-04-24 18:12 [PATCH v3 0/5] Enhance support for system and runtime power management on malidp Ayan Kumar Halder
                   ` (2 preceding siblings ...)
  2018-04-24 18:12 ` [PATCH v3 3/5] drm/arm/malidp: Enable/disable interrupts in runtime pm Ayan Kumar Halder
@ 2018-04-24 18:12 ` Ayan Kumar Halder
  2018-04-24 18:12 ` [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions Ayan Kumar Halder
  4 siblings, 0 replies; 12+ messages in thread
From: Ayan Kumar Halder @ 2018-04-24 18:12 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, malidp, airlied,
	dri-devel, linux-kernel
  Cc: nd

One needs to store the value of the OUTPUT_DEPTH that one has parsed from
device tree, so that it can be restored on system resume. This value is
set in the modeset function as this gets reset when the system suspends.

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>

---
Changes in v3:-
- Rebased the patch on top of the earlier v3 patches.

Changes in v2:-
- Removed the change id
---
 drivers/gpu/drm/arm/malidp_drv.c | 1 +
 drivers/gpu/drm/arm/malidp_hw.c  | 4 ++++
 drivers/gpu/drm/arm/malidp_hw.h  | 1 +
 3 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 983b854..82221ea 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -603,6 +603,7 @@ static int malidp_bind(struct device *dev)
 	for (i = 0; i < MAX_OUTPUT_CHANNELS; i++)
 		out_depth = (out_depth << 8) | (output_width[i] & 0xf);
 	malidp_hw_write(hwdev, out_depth, hwdev->hw->map.out_depth_base);
+	hwdev->output_color_depth = out_depth;
 
 	atomic_set(&malidp->config_valid, 0);
 	init_waitqueue_head(&malidp->wq);
diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
index 3f53f7e8..52c7031 100644
--- a/drivers/gpu/drm/arm/malidp_hw.c
+++ b/drivers/gpu/drm/arm/malidp_hw.c
@@ -233,6 +233,8 @@ static void malidp500_modeset(struct malidp_hw_device *hwdev, struct videomode *
 {
 	u32 val = 0;
 
+	malidp_hw_write(hwdev, hwdev->output_color_depth,
+		hwdev->hw->map.out_depth_base);
 	malidp_hw_clearbits(hwdev, MALIDP500_DC_CLEAR_MASK, MALIDP500_DC_CONTROL);
 	if (mode->flags & DISPLAY_FLAGS_HSYNC_HIGH)
 		val |= MALIDP500_HSYNCPOL;
@@ -457,6 +459,8 @@ static void malidp550_modeset(struct malidp_hw_device *hwdev, struct videomode *
 {
 	u32 val = MALIDP_DE_DEFAULT_PREFETCH_START;
 
+	malidp_hw_write(hwdev, hwdev->output_color_depth,
+		hwdev->hw->map.out_depth_base);
 	malidp_hw_write(hwdev, val, MALIDP550_DE_CONTROL);
 	/*
 	 * Mali-DP550 and Mali-DP650 encode the background color like this:
diff --git a/drivers/gpu/drm/arm/malidp_hw.h b/drivers/gpu/drm/arm/malidp_hw.h
index 864fe92..6e3db57 100644
--- a/drivers/gpu/drm/arm/malidp_hw.h
+++ b/drivers/gpu/drm/arm/malidp_hw.h
@@ -228,6 +228,7 @@ struct malidp_hw_device {
 
 	u8 min_line_size;
 	u16 max_line_size;
+	u32 output_color_depth;
 
 	/* track the device PM state */
 	bool pm_suspended;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions
  2018-04-24 18:12 [PATCH v3 0/5] Enhance support for system and runtime power management on malidp Ayan Kumar Halder
                   ` (3 preceding siblings ...)
  2018-04-24 18:12 ` [PATCH v3 4/5] drm/arm/malidp: Set the output_depth register in modeset Ayan Kumar Halder
@ 2018-04-24 18:12 ` Ayan Kumar Halder
  2018-04-25  7:17   ` Daniel Vetter
  4 siblings, 1 reply; 12+ messages in thread
From: Ayan Kumar Halder @ 2018-04-24 18:12 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, malidp, airlied,
	dri-devel, linux-kernel
  Cc: nd

malidp_pm_suspend_late checks if the runtime status is not suspended
and if so, invokes malidp_runtime_pm_suspend which disables the
display engine/core interrupts and the clocks. It sets the runtime status
as suspended.

The difference between suspend() and suspend_late() is as follows:-
1. suspend() makes the device quiescent. In our case, we invoke the DRM
helper which disables the CRTC. This would have invoked runtime pm
suspend but the system suspend process disables runtime pm.
2. suspend_late() It continues the suspend operations of the drm device 
which was started by suspend(). In our case, it performs the same functionality
as runtime_suspend().

The complimentary functions are resume() and resume_early(). In the case of
resume_early(), we invoke malidp_runtime_pm_resume() which enables the clocks
and the interrupts. It sets the runtime status as active. If the device was
in runtime suspend mode before system suspend was called, pm_runtime_work()
will put the device back in runtime suspended mode( after the complete system
has been resumed).

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>

---
Changes in v3:-
- Rebased on top of earlier v3 patches, 

Changes in v2:-
- Removed the change id and modified the commit message
---
 drivers/gpu/drm/arm/malidp_drv.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 82221ea..c53b46a 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -768,8 +768,25 @@ static int __maybe_unused malidp_pm_resume(struct device *dev)
 	return 0;
 }
 
+static int __maybe_unused malidp_pm_suspend_late(struct device *dev)
+{
+	if (!pm_runtime_status_suspended(dev)) {
+		malidp_runtime_pm_suspend(dev);
+		pm_runtime_set_suspended(dev);
+	}
+	return 0;
+}
+
+static int __maybe_unused malidp_pm_resume_early(struct device *dev)
+{
+	malidp_runtime_pm_resume(dev);
+	pm_runtime_set_active(dev);
+	return 0;
+}
+
 static const struct dev_pm_ops malidp_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend, malidp_pm_resume) \
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend_late, malidp_pm_resume_early) \
 	SET_RUNTIME_PM_OPS(malidp_runtime_pm_suspend, malidp_runtime_pm_resume, NULL)
 };
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions
  2018-04-24 18:12 ` [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions Ayan Kumar Halder
@ 2018-04-25  7:17   ` Daniel Vetter
  2018-04-25 11:26     ` Liviu Dudau
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Vetter @ 2018-04-25  7:17 UTC (permalink / raw)
  To: Ayan Kumar Halder
  Cc: liviu.dudau, brian.starkey, malidp, airlied, dri-devel, linux-kernel, nd

On Tue, Apr 24, 2018 at 07:12:47PM +0100, Ayan Kumar Halder wrote:
> malidp_pm_suspend_late checks if the runtime status is not suspended
> and if so, invokes malidp_runtime_pm_suspend which disables the
> display engine/core interrupts and the clocks. It sets the runtime status
> as suspended.
> 
> The difference between suspend() and suspend_late() is as follows:-
> 1. suspend() makes the device quiescent. In our case, we invoke the DRM
> helper which disables the CRTC. This would have invoked runtime pm
> suspend but the system suspend process disables runtime pm.
> 2. suspend_late() It continues the suspend operations of the drm device 
> which was started by suspend(). In our case, it performs the same functionality
> as runtime_suspend().
> 
> The complimentary functions are resume() and resume_early(). In the case of
> resume_early(), we invoke malidp_runtime_pm_resume() which enables the clocks
> and the interrupts. It sets the runtime status as active. If the device was
> in runtime suspend mode before system suspend was called, pm_runtime_work()
> will put the device back in runtime suspended mode( after the complete system
> has been resumed).
> 
> Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> 

Afaiui we still haven't bottomed out on the discussion on v1. Did you get
hold of Rafael?
-Daniel

> ---
> Changes in v3:-
> - Rebased on top of earlier v3 patches, 
> 
> Changes in v2:-
> - Removed the change id and modified the commit message
> ---
>  drivers/gpu/drm/arm/malidp_drv.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 82221ea..c53b46a 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -768,8 +768,25 @@ static int __maybe_unused malidp_pm_resume(struct device *dev)
>  	return 0;
>  }
>  
> +static int __maybe_unused malidp_pm_suspend_late(struct device *dev)
> +{
> +	if (!pm_runtime_status_suspended(dev)) {
> +		malidp_runtime_pm_suspend(dev);
> +		pm_runtime_set_suspended(dev);
> +	}
> +	return 0;
> +}
> +
> +static int __maybe_unused malidp_pm_resume_early(struct device *dev)
> +{
> +	malidp_runtime_pm_resume(dev);
> +	pm_runtime_set_active(dev);
> +	return 0;
> +}
> +
>  static const struct dev_pm_ops malidp_pm_ops = {
>  	SET_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend, malidp_pm_resume) \
> +	SET_LATE_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend_late, malidp_pm_resume_early) \
>  	SET_RUNTIME_PM_OPS(malidp_runtime_pm_suspend, malidp_runtime_pm_resume, NULL)
>  };
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions
  2018-04-25  7:17   ` Daniel Vetter
@ 2018-04-25 11:26     ` Liviu Dudau
  2018-04-25 11:49       ` Daniel Vetter
  0 siblings, 1 reply; 12+ messages in thread
From: Liviu Dudau @ 2018-04-25 11:26 UTC (permalink / raw)
  To: Ayan Kumar Halder, brian.starkey, airlied, dri-devel,
	linux-kernel, Rafael J. Wysocki

On Wed, Apr 25, 2018 at 09:17:22AM +0200, Daniel Vetter wrote:
> On Tue, Apr 24, 2018 at 07:12:47PM +0100, Ayan Kumar Halder wrote:
> > malidp_pm_suspend_late checks if the runtime status is not suspended
> > and if so, invokes malidp_runtime_pm_suspend which disables the
> > display engine/core interrupts and the clocks. It sets the runtime status
> > as suspended.
> > 
> > The difference between suspend() and suspend_late() is as follows:-
> > 1. suspend() makes the device quiescent. In our case, we invoke the DRM
> > helper which disables the CRTC. This would have invoked runtime pm
> > suspend but the system suspend process disables runtime pm.
> > 2. suspend_late() It continues the suspend operations of the drm device 
> > which was started by suspend(). In our case, it performs the same functionality
> > as runtime_suspend().
> > 
> > The complimentary functions are resume() and resume_early(). In the case of
> > resume_early(), we invoke malidp_runtime_pm_resume() which enables the clocks
> > and the interrupts. It sets the runtime status as active. If the device was
> > in runtime suspend mode before system suspend was called, pm_runtime_work()
> > will put the device back in runtime suspended mode( after the complete system
> > has been resumed).
> > 
> > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> > 
> 
> Afaiui we still haven't bottomed out on the discussion on v1. Did you get
> hold of Rafael?

No, there was no reply from him. Lets try again:

Rafael, we are debating on what the proper approach is for handling the
suspend/resume callbacks for a DRM driver that is likely to not be
runtime suspended when the power-down happens (because we are driving
the display output). We are using in this patch the LATE_SYSTEM_SLEEP_PM_OPS
in order to do the work that we also do during runtime suspend, which is
turning off the output and the clocks driving it. The reason for doing
that is because the PM core takes a runtime reference during system
suspend for all devices that are not already runtime suspended, so our
runtime_pm_suspend() hook is never called.

Daniel's argument is that we should not be doing this from LATE hooks,
but from the normal suspend hooks, however kernel doc seems to suggest
otherwise.

Best regards,
Liviu



> -Daniel
> 
> > ---
> > Changes in v3:-
> > - Rebased on top of earlier v3 patches, 
> > 
> > Changes in v2:-
> > - Removed the change id and modified the commit message
> > ---
> >  drivers/gpu/drm/arm/malidp_drv.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> > index 82221ea..c53b46a 100644
> > --- a/drivers/gpu/drm/arm/malidp_drv.c
> > +++ b/drivers/gpu/drm/arm/malidp_drv.c
> > @@ -768,8 +768,25 @@ static int __maybe_unused malidp_pm_resume(struct device *dev)
> >  	return 0;
> >  }
> >  
> > +static int __maybe_unused malidp_pm_suspend_late(struct device *dev)
> > +{
> > +	if (!pm_runtime_status_suspended(dev)) {
> > +		malidp_runtime_pm_suspend(dev);
> > +		pm_runtime_set_suspended(dev);
> > +	}
> > +	return 0;
> > +}
> > +
> > +static int __maybe_unused malidp_pm_resume_early(struct device *dev)
> > +{
> > +	malidp_runtime_pm_resume(dev);
> > +	pm_runtime_set_active(dev);
> > +	return 0;
> > +}
> > +
> >  static const struct dev_pm_ops malidp_pm_ops = {
> >  	SET_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend, malidp_pm_resume) \
> > +	SET_LATE_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend_late, malidp_pm_resume_early) \
> >  	SET_RUNTIME_PM_OPS(malidp_runtime_pm_suspend, malidp_runtime_pm_resume, NULL)
> >  };
> >  
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions
  2018-04-25 11:26     ` Liviu Dudau
@ 2018-04-25 11:49       ` Daniel Vetter
  2018-05-14 10:01         ` Ayan Halder
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Vetter @ 2018-04-25 11:49 UTC (permalink / raw)
  To: Liviu Dudau
  Cc: Ayan Kumar Halder, Brian Starkey, Dave Airlie, dri-devel,
	Linux Kernel Mailing List, Rafael J. Wysocki

On Wed, Apr 25, 2018 at 1:26 PM, Liviu Dudau <liviu.dudau@arm.com> wrote:
> On Wed, Apr 25, 2018 at 09:17:22AM +0200, Daniel Vetter wrote:
>> On Tue, Apr 24, 2018 at 07:12:47PM +0100, Ayan Kumar Halder wrote:
>> > malidp_pm_suspend_late checks if the runtime status is not suspended
>> > and if so, invokes malidp_runtime_pm_suspend which disables the
>> > display engine/core interrupts and the clocks. It sets the runtime status
>> > as suspended.
>> >
>> > The difference between suspend() and suspend_late() is as follows:-
>> > 1. suspend() makes the device quiescent. In our case, we invoke the DRM
>> > helper which disables the CRTC. This would have invoked runtime pm
>> > suspend but the system suspend process disables runtime pm.
>> > 2. suspend_late() It continues the suspend operations of the drm device
>> > which was started by suspend(). In our case, it performs the same functionality
>> > as runtime_suspend().
>> >
>> > The complimentary functions are resume() and resume_early(). In the case of
>> > resume_early(), we invoke malidp_runtime_pm_resume() which enables the clocks
>> > and the interrupts. It sets the runtime status as active. If the device was
>> > in runtime suspend mode before system suspend was called, pm_runtime_work()
>> > will put the device back in runtime suspended mode( after the complete system
>> > has been resumed).
>> >
>> > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
>> >
>>
>> Afaiui we still haven't bottomed out on the discussion on v1. Did you get
>> hold of Rafael?
>
> No, there was no reply from him. Lets try again:
>
> Rafael, we are debating on what the proper approach is for handling the
> suspend/resume callbacks for a DRM driver that is likely to not be
> runtime suspended when the power-down happens (because we are driving
> the display output). We are using in this patch the LATE_SYSTEM_SLEEP_PM_OPS
> in order to do the work that we also do during runtime suspend, which is
> turning off the output and the clocks driving it. The reason for doing
> that is because the PM core takes a runtime reference during system
> suspend for all devices that are not already runtime suspended, so our
> runtime_pm_suspend() hook is never called.
>
> Daniel's argument is that we should not be doing this from LATE hooks,
> but from the normal suspend hooks, however kernel doc seems to suggest
> otherwise.

For more context: I thought the reason behind the recommendation to
stuff the rpm callbacks into the late/early hooks was to solve
cross-device ordering issues. That way everyone shuts down the device
functionality in the normal hooks, but only powers them off in the
late hook (to allow other drivers to keep using the clock/i2c
master/whatever). But we now have device_link to solve that since a
while, so I'm not sure the recommendation to stuff the rpm hooks into
late/early callbacks is still correct.
-Daniel

>
> Best regards,
> Liviu
>
>
>
>> -Daniel
>>
>> > ---
>> > Changes in v3:-
>> > - Rebased on top of earlier v3 patches,
>> >
>> > Changes in v2:-
>> > - Removed the change id and modified the commit message
>> > ---
>> >  drivers/gpu/drm/arm/malidp_drv.c | 17 +++++++++++++++++
>> >  1 file changed, 17 insertions(+)
>> >
>> > diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
>> > index 82221ea..c53b46a 100644
>> > --- a/drivers/gpu/drm/arm/malidp_drv.c
>> > +++ b/drivers/gpu/drm/arm/malidp_drv.c
>> > @@ -768,8 +768,25 @@ static int __maybe_unused malidp_pm_resume(struct device *dev)
>> >     return 0;
>> >  }
>> >
>> > +static int __maybe_unused malidp_pm_suspend_late(struct device *dev)
>> > +{
>> > +   if (!pm_runtime_status_suspended(dev)) {
>> > +           malidp_runtime_pm_suspend(dev);
>> > +           pm_runtime_set_suspended(dev);
>> > +   }
>> > +   return 0;
>> > +}
>> > +
>> > +static int __maybe_unused malidp_pm_resume_early(struct device *dev)
>> > +{
>> > +   malidp_runtime_pm_resume(dev);
>> > +   pm_runtime_set_active(dev);
>> > +   return 0;
>> > +}
>> > +
>> >  static const struct dev_pm_ops malidp_pm_ops = {
>> >     SET_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend, malidp_pm_resume) \
>> > +   SET_LATE_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend_late, malidp_pm_resume_early) \
>> >     SET_RUNTIME_PM_OPS(malidp_runtime_pm_suspend, malidp_runtime_pm_resume, NULL)
>> >  };
>> >
>> > --
>> > 2.7.4
>> >
>> > _______________________________________________
>> > dri-devel mailing list
>> > dri-devel@lists.freedesktop.org
>> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>> --
>> Daniel Vetter
>> Software Engineer, Intel Corporation
>> http://blog.ffwll.ch
>
> --
> ====================
> | I would like to |
> | fix the world,  |
> | but they're not |
> | giving me the   |
>  \ source code!  /
>   ---------------
>     ¯\_(ツ)_/¯
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions
  2018-04-25 11:49       ` Daniel Vetter
@ 2018-05-14 10:01         ` Ayan Halder
  2018-05-15  9:50           ` Rafael J. Wysocki
  0 siblings, 1 reply; 12+ messages in thread
From: Ayan Halder @ 2018-05-14 10:01 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Liviu Dudau, Brian Starkey, Dave Airlie, dri-devel,
	Linux Kernel Mailing List, Rafael J. Wysocki, nd

On Wed, Apr 25, 2018 at 01:49:35PM +0200, Daniel Vetter wrote:
Hi Daniel,
> On Wed, Apr 25, 2018 at 1:26 PM, Liviu Dudau <liviu.dudau@arm.com> wrote:
> > On Wed, Apr 25, 2018 at 09:17:22AM +0200, Daniel Vetter wrote:
> >> On Tue, Apr 24, 2018 at 07:12:47PM +0100, Ayan Kumar Halder wrote:
> >> > malidp_pm_suspend_late checks if the runtime status is not suspended
> >> > and if so, invokes malidp_runtime_pm_suspend which disables the
> >> > display engine/core interrupts and the clocks. It sets the runtime status
> >> > as suspended.
> >> >
> >> > The difference between suspend() and suspend_late() is as follows:-
> >> > 1. suspend() makes the device quiescent. In our case, we invoke the DRM
> >> > helper which disables the CRTC. This would have invoked runtime pm
> >> > suspend but the system suspend process disables runtime pm.
> >> > 2. suspend_late() It continues the suspend operations of the drm device
> >> > which was started by suspend(). In our case, it performs the same functionality
> >> > as runtime_suspend().
> >> >
> >> > The complimentary functions are resume() and resume_early(). In the case of
> >> > resume_early(), we invoke malidp_runtime_pm_resume() which enables the clocks
> >> > and the interrupts. It sets the runtime status as active. If the device was
> >> > in runtime suspend mode before system suspend was called, pm_runtime_work()
> >> > will put the device back in runtime suspended mode( after the complete system
> >> > has been resumed).
> >> >
> >> > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> >> >
> >>
> >> Afaiui we still haven't bottomed out on the discussion on v1. Did you get
> >> hold of Rafael?
> >
> > No, there was no reply from him. Lets try again:
> >
> > Rafael, we are debating on what the proper approach is for handling the
> > suspend/resume callbacks for a DRM driver that is likely to not be
> > runtime suspended when the power-down happens (because we are driving
> > the display output). We are using in this patch the LATE_SYSTEM_SLEEP_PM_OPS
> > in order to do the work that we also do during runtime suspend, which is
> > turning off the output and the clocks driving it. The reason for doing
> > that is because the PM core takes a runtime reference during system
> > suspend for all devices that are not already runtime suspended, so our
> > runtime_pm_suspend() hook is never called.
> >
> > Daniel's argument is that we should not be doing this from LATE hooks,
> > but from the normal suspend hooks, however kernel doc seems to suggest
> > otherwise.
> 
> For more context: I thought the reason behind the recommendation to
> stuff the rpm callbacks into the late/early hooks was to solve
> cross-device ordering issues. That way everyone shuts down the device
> functionality in the normal hooks, but only powers them off in the
> late hook (to allow other drivers to keep using the clock/i2c
> master/whatever). But we now have device_link to solve that since a
> while, so I'm not sure the recommendation to stuff the rpm hooks into
> late/early callbacks is still correct.
> -Daniel
> 
It has been more than two weeks and we have not got any response from
Rafael. Can you ping him personally or suggest any way by which ask
him to respond?
> >
> > Best regards,
> > Liviu
> >
> >
> >
> >> -Daniel
> >>
> >> > ---
> >> > Changes in v3:-
> >> > - Rebased on top of earlier v3 patches,
> >> >
> >> > Changes in v2:-
> >> > - Removed the change id and modified the commit message
> >> > ---
> >> >  drivers/gpu/drm/arm/malidp_drv.c | 17 +++++++++++++++++
> >> >  1 file changed, 17 insertions(+)
> >> >
> >> > diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> >> > index 82221ea..c53b46a 100644
> >> > --- a/drivers/gpu/drm/arm/malidp_drv.c
> >> > +++ b/drivers/gpu/drm/arm/malidp_drv.c
> >> > @@ -768,8 +768,25 @@ static int __maybe_unused malidp_pm_resume(struct device *dev)
> >> >     return 0;
> >> >  }
> >> >
> >> > +static int __maybe_unused malidp_pm_suspend_late(struct device *dev)
> >> > +{
> >> > +   if (!pm_runtime_status_suspended(dev)) {
> >> > +           malidp_runtime_pm_suspend(dev);
> >> > +           pm_runtime_set_suspended(dev);
> >> > +   }
> >> > +   return 0;
> >> > +}
> >> > +
> >> > +static int __maybe_unused malidp_pm_resume_early(struct device *dev)
> >> > +{
> >> > +   malidp_runtime_pm_resume(dev);
> >> > +   pm_runtime_set_active(dev);
> >> > +   return 0;
> >> > +}
> >> > +
> >> >  static const struct dev_pm_ops malidp_pm_ops = {
> >> >     SET_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend, malidp_pm_resume) \
> >> > +   SET_LATE_SYSTEM_SLEEP_PM_OPS(malidp_pm_suspend_late, malidp_pm_resume_early) \
> >> >     SET_RUNTIME_PM_OPS(malidp_runtime_pm_suspend, malidp_runtime_pm_resume, NULL)
> >> >  };
> >> >
> >> > --
> >> > 2.7.4
> >> >
> >> > _______________________________________________
> >> > dri-devel mailing list
> >> > dri-devel@lists.freedesktop.org
> >> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> >>
> >> --
> >> Daniel Vetter
> >> Software Engineer, Intel Corporation
> >> http://blog.ffwll.ch
> >
> > --
> > ====================
> > | I would like to |
> > | fix the world,  |
> > | but they're not |
> > | giving me the   |
> >  \ source code!  /
> >   ---------------
> >     ??\_(???)_/??
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions
  2018-05-14 10:01         ` Ayan Halder
@ 2018-05-15  9:50           ` Rafael J. Wysocki
  0 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2018-05-15  9:50 UTC (permalink / raw)
  To: Ayan Halder
  Cc: Daniel Vetter, Liviu Dudau, Brian Starkey, Dave Airlie,
	dri-devel, Linux Kernel Mailing List, nd

On 5/14/2018 12:01 PM, Ayan Halder wrote:
> On Wed, Apr 25, 2018 at 01:49:35PM +0200, Daniel Vetter wrote:
> Hi Daniel,
>> On Wed, Apr 25, 2018 at 1:26 PM, Liviu Dudau <liviu.dudau@arm.com> wrote:
>>> On Wed, Apr 25, 2018 at 09:17:22AM +0200, Daniel Vetter wrote:
>>>> On Tue, Apr 24, 2018 at 07:12:47PM +0100, Ayan Kumar Halder wrote:
>>>>> malidp_pm_suspend_late checks if the runtime status is not suspended
>>>>> and if so, invokes malidp_runtime_pm_suspend which disables the
>>>>> display engine/core interrupts and the clocks. It sets the runtime status
>>>>> as suspended.
>>>>>
>>>>> The difference between suspend() and suspend_late() is as follows:-
>>>>> 1. suspend() makes the device quiescent. In our case, we invoke the DRM
>>>>> helper which disables the CRTC. This would have invoked runtime pm
>>>>> suspend but the system suspend process disables runtime pm.
>>>>> 2. suspend_late() It continues the suspend operations of the drm device
>>>>> which was started by suspend(). In our case, it performs the same functionality
>>>>> as runtime_suspend().
>>>>>
>>>>> The complimentary functions are resume() and resume_early(). In the case of
>>>>> resume_early(), we invoke malidp_runtime_pm_resume() which enables the clocks
>>>>> and the interrupts. It sets the runtime status as active. If the device was
>>>>> in runtime suspend mode before system suspend was called, pm_runtime_work()
>>>>> will put the device back in runtime suspended mode( after the complete system
>>>>> has been resumed).
>>>>>
>>>>> Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
>>>>>
>>>> Afaiui we still haven't bottomed out on the discussion on v1. Did you get
>>>> hold of Rafael?
>>> No, there was no reply from him. Lets try again:
>>>
>>> Rafael, we are debating on what the proper approach is for handling the
>>> suspend/resume callbacks for a DRM driver that is likely to not be
>>> runtime suspended when the power-down happens (because we are driving
>>> the display output). We are using in this patch the LATE_SYSTEM_SLEEP_PM_OPS
>>> in order to do the work that we also do during runtime suspend, which is
>>> turning off the output and the clocks driving it. The reason for doing
>>> that is because the PM core takes a runtime reference during system
>>> suspend for all devices that are not already runtime suspended, so our
>>> runtime_pm_suspend() hook is never called.
>>>
>>> Daniel's argument is that we should not be doing this from LATE hooks,
>>> but from the normal suspend hooks, however kernel doc seems to suggest
>>> otherwise.
>> For more context: I thought the reason behind the recommendation to
>> stuff the rpm callbacks into the late/early hooks was to solve
>> cross-device ordering issues. That way everyone shuts down the device
>> functionality in the normal hooks, but only powers them off in the
>> late hook (to allow other drivers to keep using the clock/i2c
>> master/whatever). But we now have device_link to solve that since a
>> while, so I'm not sure the recommendation to stuff the rpm hooks into
>> late/early callbacks is still correct.
>> -Daniel
>>
> It has been more than two weeks and we have not got any response from
> Rafael. Can you ping him personally or suggest any way by which ask
> him to respond?

It is in my queue though, sorry for the delay.

It would help if you resent the series with a CC to 
linux-pm@vger.kernel.org as it would be easier for me to review it then.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 4/5] drm/arm/malidp: Set the output_depth register in modeset
  2018-05-15 16:04 [PATCH v3 0/5] Enhance support for system and runtime power management on malidp Ayan Kumar Halder
@ 2018-05-15 16:04 ` Ayan Kumar Halder
  0 siblings, 0 replies; 12+ messages in thread
From: Ayan Kumar Halder @ 2018-05-15 16:04 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, malidp, airlied,
	dri-devel, linux-pm, linux-kernel
  Cc: nd

One needs to store the value of the OUTPUT_DEPTH that one has parsed from
device tree, so that it can be restored on system resume. This value is
set in the modeset function as this gets reset when the system suspends.

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>

---
Changes in v3:-
- Rebased the patch on top of the earlier v3 patches.

Changes in v2:-
- Removed the change id
---
 drivers/gpu/drm/arm/malidp_drv.c | 1 +
 drivers/gpu/drm/arm/malidp_hw.c  | 4 ++++
 drivers/gpu/drm/arm/malidp_hw.h  | 1 +
 3 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 983b854..82221ea 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -603,6 +603,7 @@ static int malidp_bind(struct device *dev)
 	for (i = 0; i < MAX_OUTPUT_CHANNELS; i++)
 		out_depth = (out_depth << 8) | (output_width[i] & 0xf);
 	malidp_hw_write(hwdev, out_depth, hwdev->hw->map.out_depth_base);
+	hwdev->output_color_depth = out_depth;
 
 	atomic_set(&malidp->config_valid, 0);
 	init_waitqueue_head(&malidp->wq);
diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
index 3f53f7e8..52c7031 100644
--- a/drivers/gpu/drm/arm/malidp_hw.c
+++ b/drivers/gpu/drm/arm/malidp_hw.c
@@ -233,6 +233,8 @@ static void malidp500_modeset(struct malidp_hw_device *hwdev, struct videomode *
 {
 	u32 val = 0;
 
+	malidp_hw_write(hwdev, hwdev->output_color_depth,
+		hwdev->hw->map.out_depth_base);
 	malidp_hw_clearbits(hwdev, MALIDP500_DC_CLEAR_MASK, MALIDP500_DC_CONTROL);
 	if (mode->flags & DISPLAY_FLAGS_HSYNC_HIGH)
 		val |= MALIDP500_HSYNCPOL;
@@ -457,6 +459,8 @@ static void malidp550_modeset(struct malidp_hw_device *hwdev, struct videomode *
 {
 	u32 val = MALIDP_DE_DEFAULT_PREFETCH_START;
 
+	malidp_hw_write(hwdev, hwdev->output_color_depth,
+		hwdev->hw->map.out_depth_base);
 	malidp_hw_write(hwdev, val, MALIDP550_DE_CONTROL);
 	/*
 	 * Mali-DP550 and Mali-DP650 encode the background color like this:
diff --git a/drivers/gpu/drm/arm/malidp_hw.h b/drivers/gpu/drm/arm/malidp_hw.h
index 864fe92..6e3db57 100644
--- a/drivers/gpu/drm/arm/malidp_hw.h
+++ b/drivers/gpu/drm/arm/malidp_hw.h
@@ -228,6 +228,7 @@ struct malidp_hw_device {
 
 	u8 min_line_size;
 	u16 max_line_size;
+	u32 output_color_depth;
 
 	/* track the device PM state */
 	bool pm_suspended;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-05-15 16:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-24 18:12 [PATCH v3 0/5] Enhance support for system and runtime power management on malidp Ayan Kumar Halder
2018-04-24 18:12 ` [PATCH v3 1/5] drm/arm/malidp: Modified the prototype of malidp irq de-initializers Ayan Kumar Halder
2018-04-24 18:12 ` [PATCH v3 2/5] drm/arm/malidp: Split malidp interrupt initialization functions Ayan Kumar Halder
2018-04-24 18:12 ` [PATCH v3 3/5] drm/arm/malidp: Enable/disable interrupts in runtime pm Ayan Kumar Halder
2018-04-24 18:12 ` [PATCH v3 4/5] drm/arm/malidp: Set the output_depth register in modeset Ayan Kumar Halder
2018-04-24 18:12 ` [PATCH v3 5/5] drm/arm/malidp: Added the late system pm functions Ayan Kumar Halder
2018-04-25  7:17   ` Daniel Vetter
2018-04-25 11:26     ` Liviu Dudau
2018-04-25 11:49       ` Daniel Vetter
2018-05-14 10:01         ` Ayan Halder
2018-05-15  9:50           ` Rafael J. Wysocki
2018-05-15 16:04 [PATCH v3 0/5] Enhance support for system and runtime power management on malidp Ayan Kumar Halder
2018-05-15 16:04 ` [PATCH v3 4/5] drm/arm/malidp: Set the output_depth register in modeset Ayan Kumar Halder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).