Skip to contentSkip to conversation

Enabling D0i3 transition for Valleyview

PATCH In review [email protected] 3 participants 10 messages Jun 9, 2014 – Jun 11, 2014

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

cover Enabling D0i3 transition for Valleyview

From: Sagar Kamble <[email protected]>

With these patches runtime_suspend is triggered by updating runtime pm usage count when display well is power gated and pci state is set to D3 hot in runtime_suspend and set to D0 in runtime_resume.

Sagar Kamble (2):
drm/i915: do runtime_get/put during display well power gate/ungate drm/i915/vlv: Set D3_hot for vlv during runtime_suspend

 drivers/gpu/drm/i915/i915_drv.c | 11 +++++++++++
 drivers/gpu/drm/i915/intel_pm.c |  6 ++++++
 2 files changed, 17 insertions(+)
Signature · 1 line
1.8.5
#1 lore raw

PATCH 1/2 drm/i915: do runtime_get/put during display well power gate/ungate

From: Sagar Kamble <[email protected]>

Display power island is on during boot, we have one count for it once this power gates, we do a put making sure runtime_suspend is called

Cc Daniel Vetter <[email protected]> (supporter:INTEL DRM DRIVERS...)
Cc Jani Nikula <[email protected]> (supporter:INTEL DRM DRIVERS...)
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +6 -0
index f83d1ff..b333aae 100644
@@ -6017,6 +6017,12 @@ void __vlv_set_power_well(struct drm_i915_private *dev_priv,
 			  state,
 			  vlv_punit_read(dev_priv, PUNIT_REG_PWRGT_CTRL));
 
+	if (PUNIT_POWER_WELL_DISP2D == power_well_id) {
+		if (enable)
+			intel_runtime_pm_get(dev_priv);
+		else
+			intel_runtime_pm_put(dev_priv);
+	}
 #undef COND
 
 out:
Signature · 1 line
1.8.5
#2 lore raw

Re: [PATCH 1/2] drm/i915: do runtime_get/put during display well power gate/ungate

Hi Sagar,

Quoted 18 lines · On Tue, 2014-06-10 at 00:27 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

Display power island is on during boot, we have one count for it once this power gates, we do a put making sure runtime_suspend is called

Cc Daniel Vetter <[email protected]> (supporter:INTEL DRM DRIVERS...)
Cc Jani Nikula <[email protected]> (supporter:INTEL DRM DRIVERS...)
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index f83d1ff..b333aae 100644

drivers/gpu/drm/i915/intel_pm.c void __vlv_set_power_well(struct drm_i915_private *dev_priv, · line 6025

Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
@@ -6017,6 +6017,12 @@ void __vlv_set_power_well(struct drm_i915_private *dev_priv,
 			  state,
 			  vlv_punit_read(dev_priv, PUNIT_REG_PWRGT_CTRL));
 
+	if (PUNIT_POWER_WELL_DISP2D == power_well_id) {
+		if (enable)
+			intel_runtime_pm_get(dev_priv);
+		else
+			intel_runtime_pm_put(dev_priv);
+	}

The RPM refcount should already be get/put properly in intel_display_power_get/put(), so the above doesn't seem correct to me.

With current -nightly after blanking the screen the RPM refcount does drop to 0 for me, so I'm not sure what you're missing. One possibility is:

# echo auto > /sys/bus/pci/devices/0000:00:02.0/power/control

--Imre

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

PATCH 2/2 drm/i915/vlv: Set D3_hot for vlv during runtime_suspend

In reply to [email protected]

From: Sagar Kamble <[email protected]>

To do a platform wide S0i3 transition, Gfx is required to go to D3_hot state. pci_save_state and pci_restore_state needed to avoid ring hangs across D3_hot transitions.

Cc Daniel Vetter <[email protected]> (supporter:INTEL DRM DRIVERS...)
Cc Jani Nikula <[email protected]> (supporter:INTEL DRM DRIVERS...)
---
 drivers/gpu/drm/i915/i915_drv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +11 -0
index 5a08c86..70bb456 100644
@@ -1412,6 +1412,11 @@ static int intel_runtime_suspend(struct device *device)
 	 * via the suspend path.
 	 */
 	intel_opregion_notify_adapter(dev, PCI_D1);
+	if (IS_VALLEYVIEW(dev)) {
+		pci_save_state(pdev);
+		pci_disable_device(pdev);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 
 	DRM_DEBUG_KMS("Device suspended\n");
 	return 0;
@@ -1428,6 +1433,12 @@ static int intel_runtime_resume(struct device *device)
 
 	DRM_DEBUG_KMS("Resuming device\n");
 
+	if (IS_VALLEYVIEW(dev)) {
+		pci_set_power_state(pdev, PCI_D0);
+		pci_restore_state(pdev);
+		pci_enable_device(pdev);
+	}
+
 	intel_opregion_notify_adapter(dev, PCI_D0);
 	dev_priv->pm.suspended = false;
 
Signature · 1 line
1.8.5
#4 lore raw

Re: [PATCH 2/2] drm/i915/vlv: Set D3_hot for vlv during runtime_suspend

Quoted 30 lines · On Tue, 2014-06-10 at 00:27 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

To do a platform wide S0i3 transition, Gfx is required to go to D3_hot state. pci_save_state and pci_restore_state needed to avoid ring hangs across D3_hot transitions.

Cc Daniel Vetter <[email protected]> (supporter:INTEL DRM DRIVERS...)
Cc Jani Nikula <[email protected]> (supporter:INTEL DRM DRIVERS...)
---
 drivers/gpu/drm/i915/i915_drv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
index 5a08c86..70bb456 100644
@@ -1412,6 +1412,11 @@ static int intel_runtime_suspend(struct device *device)
 	 * via the suspend path.
 	 */
 	intel_opregion_notify_adapter(dev, PCI_D1);
+	if (IS_VALLEYVIEW(dev)) {
+		pci_save_state(pdev);
+		pci_disable_device(pdev);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 
 	DRM_DEBUG_KMS("Device suspended\n");
 	return 0;

drivers/gpu/drm/i915/i915_drv.c static int intel_runtime_resume(struct device *device) · line 1440

Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.c +5 -0
@@ -1428,6 +1433,12 @@ static int intel_runtime_resume(struct device *device)
 
 	DRM_DEBUG_KMS("Resuming device\n");
 
+	if (IS_VALLEYVIEW(dev)) {
+		pci_set_power_state(pdev, PCI_D0);
+		pci_restore_state(pdev);
+		pci_enable_device(pdev);
+	}

Setting the proper Dx state and saving/restoring the PCI config space is already done for us by the PCI runtime PM framework, see pci_pm_runtime_suspend/resume(). They don't disable/enable the PCI device, but I'm not sure if that's really needed. Based on the docs I found so far the requirement for S0ix is that we put the device into D3 state and that's already the case w/o disabling the device.

So could you explain/confirm if we need that particular step?

Also if it's really needed it should be done for all platforms.

--Imre

drivers/gpu/drm/i915/i915_drv.c static int intel_runtime_resume(struct device *device) · line 1444

Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
+
 	intel_opregion_notify_adapter(dev, PCI_D0);
 	dev_priv->pm.suspended = false;
 

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

Re: [PATCH 2/2] drm/i915/vlv: Set D3_hot for vlv during runtime_suspend

Quoted 34 lines · Imre Deak
Quoted 33 lines · On Tue, 2014-06-10 at 00:27 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

To do a platform wide S0i3 transition, Gfx is required to go to D3_hot state. pci_save_state and pci_restore_state needed to avoid ring hangs across D3_hot transitions.

Cc Daniel Vetter <[email protected]> (supporter:INTEL DRM DRIVERS...)
Cc Jani Nikula <[email protected]> (supporter:INTEL DRM DRIVERS...)
---
 drivers/gpu/drm/i915/i915_drv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
index 5a08c86..70bb456 100644
@@ -1412,6 +1412,11 @@ static int intel_runtime_suspend(struct device *device)
 	 * via the suspend path.
 	 */
 	intel_opregion_notify_adapter(dev, PCI_D1);
+	if (IS_VALLEYVIEW(dev)) {
+		pci_save_state(pdev);
+		pci_disable_device(pdev);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 
 	DRM_DEBUG_KMS("Device suspended\n");
 	return 0;
@@ -1428,6 +1433,12 @@ static int intel_runtime_resume(struct device *device)
 
 	DRM_DEBUG_KMS("Resuming device\n");
 
Quoted 9 lines

drivers/gpu/drm/i915/i915_drv.c static int intel_runtime_resume(struct device *device) · line 1440

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.c +5 -0
+	if (IS_VALLEYVIEW(dev)) {
+		pci_set_power_state(pdev, PCI_D0);
+		pci_restore_state(pdev);
+		pci_enable_device(pdev);
+	}

Setting the proper Dx state and saving/restoring the PCI config space is already done for us by the PCI runtime PM framework, see pci_pm_runtime_suspend/resume().

Where exactly it calls pci_pm_set_powerstate to set D3_hot ? There seems to be bug in the pci driver in the suspend path. it is not saving the pci configuration space although code for same exists. pci driver checks if client driver has saved if not it will exit from suspend path.
check the code snippet below:

        if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
            && pci_dev->current_state != PCI_UNKNOWN) {
                WARN_ONCE(pci_dev->current_state != prev,
                        "PCI PM: State of device not saved by %pF\n",
                        pm->runtime_suspend);
                return 0;
        }

        if (!pci_dev->state_saved) {
                pci_save_state(pci_dev);
                pci_finish_runtime_suspend(pci_dev);
        }
Quoted 17 lines

They don't disable/enable the PCI
device, but I'm not sure if that's really needed. Based on the docs I found so far the requirement for S0ix is that we put the device into D3 state and that's already the case w/o disabling the device.

So could you explain/confirm if we need that particular step?

Also if it's really needed it should be done for all platforms.

--Imre

Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
+
 	intel_opregion_notify_adapter(dev, PCI_D0);
 	dev_priv->pm.suspended = false;
 
#6 lore raw

Re: [PATCH 2/2] drm/i915/vlv: Set D3_hot for vlv during runtime_suspend

Quoted 45 lines · Sagar Arun Kamble
Quoted 34 lines · Imre Deak
Quoted 33 lines · On Tue, 2014-06-10 at 00:27 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

To do a platform wide S0i3 transition, Gfx is required to go to D3_hot state. pci_save_state and pci_restore_state needed to avoid ring hangs across D3_hot transitions.

Cc Daniel Vetter <[email protected]> (supporter:INTEL DRM DRIVERS...)
Cc Jani Nikula <[email protected]> (supporter:INTEL DRM DRIVERS...)
---
 drivers/gpu/drm/i915/i915_drv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
index 5a08c86..70bb456 100644
@@ -1412,6 +1412,11 @@ static int intel_runtime_suspend(struct device *device)
 	 * via the suspend path.
 	 */
 	intel_opregion_notify_adapter(dev, PCI_D1);
+	if (IS_VALLEYVIEW(dev)) {
+		pci_save_state(pdev);
+		pci_disable_device(pdev);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 
 	DRM_DEBUG_KMS("Device suspended\n");
 	return 0;
@@ -1428,6 +1433,12 @@ static int intel_runtime_resume(struct device *device)
 
 	DRM_DEBUG_KMS("Resuming device\n");
 
Quoted 9 lines

drivers/gpu/drm/i915/i915_drv.c static int intel_runtime_resume(struct device *device) · line 1440

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.c +5 -0
+	if (IS_VALLEYVIEW(dev)) {
+		pci_set_power_state(pdev, PCI_D0);
+		pci_restore_state(pdev);
+		pci_enable_device(pdev);
+	}

Setting the proper Dx state and saving/restoring the PCI config space is already done for us by the PCI runtime PM framework, see pci_pm_runtime_suspend/resume().

Quoted 1 line

Where exactly it calls pci_pm_set_powerstate to set D3_hot ?

It's pci_pm_runtime_suspend()->pci_finish_runtime_suspend()->pci_set_power_state() .

Quoted 6 lines

There seems to be bug in the pci driver in the suspend path. it is not saving the pci configuration space although code for same exists. pci driver checks if client driver has saved if not it will exit from suspend path.
check the code snippet below:

Quoted 12 lines
        if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
            && pci_dev->current_state != PCI_UNKNOWN) {
                WARN_ONCE(pci_dev->current_state != prev,
                        "PCI PM: State of device not saved by %pF\n",
                        pm->runtime_suspend);
                return 0;
        }

        if (!pci_dev->state_saved) {
                pci_save_state(pci_dev);
                pci_finish_runtime_suspend(pci_dev);
        }

I don't think this is a bug, but something the PCI framework requires from drivers. That is if they set the power state to something else than PCI_D0 or PCI_UNKNOWN they also have to save the state themselves.

I can't check this right now, but I haven't ever seen the above WARN and by the look of it we are doing the right thing in the driver. That is leave the power state in D0 and let the PCI framework handle the state saving/power state transitioning.

--Imre

#7 lore raw

Re: [PATCH 2/2] drm/i915/vlv: Set D3_hot for vlv during runtime_suspend

This patch can be marked as "abandoned".
Have verified locally that pci driver is taking care of D0ix transitions and state save/restore.

Thanks Imre for the clarification.

Quoted 82 lines · Imre Deak
Quoted 45 lines · Sagar Arun Kamble
Quoted 34 lines · Imre Deak
Quoted 33 lines · On Tue, 2014-06-10 at 00:27 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

To do a platform wide S0i3 transition, Gfx is required to go to D3_hot state. pci_save_state and pci_restore_state needed to avoid ring hangs across D3_hot transitions.

Cc Daniel Vetter <[email protected]> (supporter:INTEL DRM DRIVERS...)
Cc Jani Nikula <[email protected]> (supporter:INTEL DRM DRIVERS...)
---
 drivers/gpu/drm/i915/i915_drv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
index 5a08c86..70bb456 100644
@@ -1412,6 +1412,11 @@ static int intel_runtime_suspend(struct device *device)
 	 * via the suspend path.
 	 */
 	intel_opregion_notify_adapter(dev, PCI_D1);
+	if (IS_VALLEYVIEW(dev)) {
+		pci_save_state(pdev);
+		pci_disable_device(pdev);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 
 	DRM_DEBUG_KMS("Device suspended\n");
 	return 0;
@@ -1428,6 +1433,12 @@ static int intel_runtime_resume(struct device *device)
 
 	DRM_DEBUG_KMS("Resuming device\n");
 
Quoted 9 lines

drivers/gpu/drm/i915/i915_drv.c static int intel_runtime_resume(struct device *device) · line 1440

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.c +5 -0
+	if (IS_VALLEYVIEW(dev)) {
+		pci_set_power_state(pdev, PCI_D0);
+		pci_restore_state(pdev);
+		pci_enable_device(pdev);
+	}

Setting the proper Dx state and saving/restoring the PCI config space is already done for us by the PCI runtime PM framework, see pci_pm_runtime_suspend/resume().

Quoted 1 line

Where exactly it calls pci_pm_set_powerstate to set D3_hot ?

It's pci_pm_runtime_suspend()->pci_finish_runtime_suspend()->pci_set_power_state() .

Quoted 6 lines

There seems to be bug in the pci driver in the suspend path. it is not saving the pci configuration space although code for same exists. pci driver checks if client driver has saved if not it will exit from suspend path.
check the code snippet below:

Quoted 12 lines
        if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
            && pci_dev->current_state != PCI_UNKNOWN) {
                WARN_ONCE(pci_dev->current_state != prev,
                        "PCI PM: State of device not saved by %pF\n",
                        pm->runtime_suspend);
                return 0;
        }

        if (!pci_dev->state_saved) {
                pci_save_state(pci_dev);
                pci_finish_runtime_suspend(pci_dev);
        }

I don't think this is a bug, but something the PCI framework requires from drivers. That is if they set the power state to something else than PCI_D0 or PCI_UNKNOWN they also have to save the state themselves.

I can't check this right now, but I haven't ever seen the above WARN and by the look of it we are doing the right thing in the driver. That is leave the power state in D0 and let the PCI framework handle the state saving/power state transitioning.

--Imre

#8 lore raw

Re: [PATCH 2/2] drm/i915/vlv: Set D3_hot for vlv during runtime_suspend

Quoted 3 lines · Sagar Arun Kamble

This patch can be marked as "abandoned".
Have verified locally that pci driver is taking care of D0ix transitions and state save/restore.

That still leaves the question why you originally thought this is required. What did blow up here in your testing?

Thanks, Daniel

Quoted 88 lines

Thanks Imre for the clarification.

Quoted 82 lines · Imre Deak
Quoted 45 lines · Sagar Arun Kamble
Quoted 34 lines · Imre Deak
Quoted 33 lines · On Tue, 2014-06-10 at 00:27 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

To do a platform wide S0i3 transition, Gfx is required to go to D3_hot state. pci_save_state and pci_restore_state needed to avoid ring hangs across D3_hot transitions.

Cc Daniel Vetter <[email protected]> (supporter:INTEL DRM DRIVERS...)
Cc Jani Nikula <[email protected]> (supporter:INTEL DRM DRIVERS...)
---
 drivers/gpu/drm/i915/i915_drv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
index 5a08c86..70bb456 100644
@@ -1412,6 +1412,11 @@ static int intel_runtime_suspend(struct device *device)
 	 * via the suspend path.
 	 */
 	intel_opregion_notify_adapter(dev, PCI_D1);
+	if (IS_VALLEYVIEW(dev)) {
+		pci_save_state(pdev);
+		pci_disable_device(pdev);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 
 	DRM_DEBUG_KMS("Device suspended\n");
 	return 0;
@@ -1428,6 +1433,12 @@ static int intel_runtime_resume(struct device *device)
 
 	DRM_DEBUG_KMS("Resuming device\n");
 
Quoted 9 lines

drivers/gpu/drm/i915/i915_drv.c static int intel_runtime_resume(struct device *device) · line 1440

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.c +5 -0
+	if (IS_VALLEYVIEW(dev)) {
+		pci_set_power_state(pdev, PCI_D0);
+		pci_restore_state(pdev);
+		pci_enable_device(pdev);
+	}

Setting the proper Dx state and saving/restoring the PCI config space is already done for us by the PCI runtime PM framework, see pci_pm_runtime_suspend/resume().

Quoted 1 line

Where exactly it calls pci_pm_set_powerstate to set D3_hot ?

It's pci_pm_runtime_suspend()->pci_finish_runtime_suspend()->pci_set_power_state() .

Quoted 6 lines

There seems to be bug in the pci driver in the suspend path. it is not saving the pci configuration space although code for same exists. pci driver checks if client driver has saved if not it will exit from suspend path.
check the code snippet below:

Quoted 12 lines
        if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
            && pci_dev->current_state != PCI_UNKNOWN) {
                WARN_ONCE(pci_dev->current_state != prev,
                        "PCI PM: State of device not saved by %pF\n",
                        pm->runtime_suspend);
                return 0;
        }

        if (!pci_dev->state_saved) {
                pci_save_state(pci_dev);
                pci_finish_runtime_suspend(pci_dev);
        }

I don't think this is a bug, but something the PCI framework requires from drivers. That is if they set the power state to something else than PCI_D0 or PCI_UNKNOWN they also have to save the state themselves.

I can't check this right now, but I haven't ever seen the above WARN and by the look of it we are doing the right thing in the driver. That is leave the power state in D0 and let the PCI framework handle the state saving/power state transitioning.

--Imre

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#9 lore raw

Re: [PATCH 2/2] drm/i915/vlv: Set D3_hot for vlv during runtime_suspend

Quoted 7 lines · Daniel Vetter
Quoted 3 lines · Sagar Arun Kamble

This patch can be marked as "abandoned".
Have verified locally that pci driver is taking care of D0ix transitions and state save/restore.

That still leaves the question why you originally thought this is required. What did blow up here in your testing?

Took reference from suspend path in our previous repo where driver was setting and saving the state. For S0iX, Gfx is supposed to go into D3_hot, so we explicitly set that state assuming its gfx driver responsibility.
We should have done more testing with current driver to ensure it is indeed going to D3_hot.

Quoted 91 lines

Thanks, Daniel

Quoted 88 lines

Thanks Imre for the clarification.

Quoted 82 lines · Imre Deak
Quoted 45 lines · Sagar Arun Kamble
Quoted 34 lines · Imre Deak
Quoted 33 lines · On Tue, 2014-06-10 at 00:27 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

To do a platform wide S0i3 transition, Gfx is required to go to D3_hot state. pci_save_state and pci_restore_state needed to avoid ring hangs across D3_hot transitions.

Cc Daniel Vetter <[email protected]> (supporter:INTEL DRM DRIVERS...)
Cc Jani Nikula <[email protected]> (supporter:INTEL DRM DRIVERS...)
---
 drivers/gpu/drm/i915/i915_drv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
index 5a08c86..70bb456 100644
@@ -1412,6 +1412,11 @@ static int intel_runtime_suspend(struct device *device)
 	 * via the suspend path.
 	 */
 	intel_opregion_notify_adapter(dev, PCI_D1);
+	if (IS_VALLEYVIEW(dev)) {
+		pci_save_state(pdev);
+		pci_disable_device(pdev);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 
 	DRM_DEBUG_KMS("Device suspended\n");
 	return 0;
@@ -1428,6 +1433,12 @@ static int intel_runtime_resume(struct device *device)
 
 	DRM_DEBUG_KMS("Resuming device\n");
 
Quoted 9 lines

drivers/gpu/drm/i915/i915_drv.c static int intel_runtime_resume(struct device *device) · line 1440

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.c +5 -0
+	if (IS_VALLEYVIEW(dev)) {
+		pci_set_power_state(pdev, PCI_D0);
+		pci_restore_state(pdev);
+		pci_enable_device(pdev);
+	}

Setting the proper Dx state and saving/restoring the PCI config space is already done for us by the PCI runtime PM framework, see pci_pm_runtime_suspend/resume().

Quoted 1 line

Where exactly it calls pci_pm_set_powerstate to set D3_hot ?

It's pci_pm_runtime_suspend()->pci_finish_runtime_suspend()->pci_set_power_state() .

Quoted 6 lines

There seems to be bug in the pci driver in the suspend path. it is not saving the pci configuration space although code for same exists. pci driver checks if client driver has saved if not it will exit from suspend path.
check the code snippet below:

Quoted 12 lines
        if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
            && pci_dev->current_state != PCI_UNKNOWN) {
                WARN_ONCE(pci_dev->current_state != prev,
                        "PCI PM: State of device not saved by %pF\n",
                        pm->runtime_suspend);
                return 0;
        }

        if (!pci_dev->state_saved) {
                pci_save_state(pci_dev);
                pci_finish_runtime_suspend(pci_dev);
        }

I don't think this is a bug, but something the PCI framework requires from drivers. That is if they set the power state to something else than PCI_D0 or PCI_UNKNOWN they also have to save the state themselves.

I can't check this right now, but I haven't ever seen the above WARN and by the look of it we are doing the right thing in the driver. That is leave the power state in D0 and let the PCI framework handle the state saving/power state transitioning.

--Imre