Skip to contentSkip to conversation

drm/i915: don't call swsci_setup on resume

PATCH In review Paulo Zanoni 3 participants 5 messages Feb 6, 2014

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

PATCH 1/1 drm/i915: don't call swsci_setup on resume

From: Paulo Zanoni <[email protected]>

This function is used to discover which swsci callbacks the machine supports. It calls swsci() 3 times, and usually takes a considerable number of milliseconds to finish.

I don't see a reason for a change on the supported callbacks between boot and resume, so use the values retrieved at boot time forever, making resume a little bit faster.

---
 drivers/gpu/drm/i915/i915_dma.c       | 1 +
 drivers/gpu/drm/i915/i915_drv.h       | 2 ++
 drivers/gpu/drm/i915/intel_opregion.c | 8 ++++----
 3 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -0
index 258b1be..f57e220 100644
@@ -1616,6 +1616,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	intel_setup_mchbar(dev);
 	intel_setup_gmbus(dev);
 	intel_opregion_setup(dev);
+	intel_swsci_setup(dev);
 
 	intel_setup_bios(dev);
 
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 728b9c3..4f65e12 100644
@@ -2507,6 +2507,7 @@ extern int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 					 bool enable);
 extern int intel_opregion_notify_adapter(struct drm_device *dev,
 					 pci_power_t state);
+extern void intel_swsci_setup(struct drm_device *dev);
 #else
 static inline void intel_opregion_init(struct drm_device *dev) { return; }
 static inline void intel_opregion_fini(struct drm_device *dev) { return; }
@@ -2521,6 +2522,7 @@ intel_opregion_notify_adapter(struct drm_device *dev, pci_power_t state)
 {
 	return 0;
 }
+static inline void intel_swsci_setup(struct drm_device *dev) { return; }
 #endif
 
 /* intel_acpi.c */
drivers/gpu/drm/i915/intel_opregion.c +4 -4
index 6845960..579bf24 100644
@@ -780,13 +780,16 @@ void intel_opregion_fini(struct drm_device *dev)
 	opregion->lid_state = NULL;
 }
 
-static void swsci_setup(struct drm_device *dev)
+void intel_swsci_setup(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_opregion *opregion = &dev_priv->opregion;
 	bool requested_callbacks = false;
 	u32 tmp;
 
+	if (!opregion->swsci)
+		return;
+
 	/* Sub-function code 0 is okay, let's allow them. */
 	opregion->swsci_gbda_sub_functions = 1;
 	opregion->swsci_sbcb_sub_functions = 1;
@@ -836,8 +839,6 @@ static void swsci_setup(struct drm_device *dev)
 			 opregion->swsci_gbda_sub_functions,
 			 opregion->swsci_sbcb_sub_functions);
 }
-#else /* CONFIG_ACPI */
-static inline void swsci_setup(struct drm_device *dev) {}
 #endif  /* CONFIG_ACPI */
 
 int intel_opregion_setup(struct drm_device *dev)
@@ -885,7 +886,6 @@ int intel_opregion_setup(struct drm_device *dev)
 	if (mboxes & MBOX_SWSCI) {
 		DRM_DEBUG_DRIVER("SWSCI supported\n");
 		opregion->swsci = base + OPREGION_SWSCI_OFFSET;
-		swsci_setup(dev);
 	}
 	if (mboxes & MBOX_ASLE) {
 		DRM_DEBUG_DRIVER("ASLE supported\n");
Signature · 1 line
1.8.5.3
#1 lore raw
Quoted 9 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

This function is used to discover which swsci callbacks the machine supports. It calls swsci() 3 times, and usually takes a considerable number of milliseconds to finish.

I don't see a reason for a change on the supported callbacks between boot and resume, so use the values retrieved at boot time forever, making resume a little bit faster.

This looks unsafe following a hibernate resume where the system could change around us. Across a suspend resume, you can argue that we do not need to shootdown OpRegion (and not just swsci) at all. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 7 lines · Chris Wilson
Quoted 6 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

This function is used to discover which swsci callbacks the machine supports. It calls swsci() 3 times, and usually takes a considerable number of milliseconds to finish.

Quoted 7 lines
Quoted 3 lines

I don't see a reason for a change on the supported callbacks between boot and resume, so use the values retrieved at boot time forever, making resume a little bit faster.

This looks unsafe following a hibernate resume where the system could change around us. Across a suspend resume, you can argue that we do not need to shootdown OpRegion (and not just swsci) at all.

See my other mail, but I think _init/_fini take care of all this. The only exception would be if the bios moves the opregion around, but that's only really possible if you update it or change your machine otherwise. Then you get both pieces anyway.
-Daniel

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

From: Paulo Zanoni <[email protected]>

This function is used to discover which swsci callbacks the machine supports. It calls swsci() 3 times, and usually takes a considerable number of milliseconds to finish.

I don't see a reason for a change on the supported callbacks between boot and resume, so use the values retrieved at boot time forever, making resume a little bit faster.

Quoted 8 lines
Quoted 3 lines

This looks unsafe following a hibernate resume where the system could change around us. Across a suspend resume, you can argue that we do not need to shootdown OpRegion (and not just swsci) at all.

See my other mail, but I think _init/_fini take care of all this. The only exception would be if the bios moves the opregion around, but that's only really possible if you update it or change your machine otherwise. Then you get both pieces anyway.

Exactly, that's why I think trusting the layout post hibernate is danagerous.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#4 lore raw
In reply to Paulo Zanoni
Quoted 11 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

This function is used to discover which swsci callbacks the machine supports. It calls swsci() 3 times, and usually takes a considerable number of milliseconds to finish.

I don't see a reason for a change on the supported callbacks between boot and resume, so use the values retrieved at boot time forever, making resume a little bit faster.

I think we could simply not call opregion_setup in our thaw function. The actual runtime setup is already split out into _init/fini functions, so if anything in opregion_setup needs to be done at resume we could simply move that. But afaict the split looks sane already.

That way the init sequence is much less tricky than the conditional swsci_setup in your patch. The only write we have in _setup is ASLE_ARDY_NOT_READY, but that's the default state - the driver only needs to signal readiness once everything is up (in _init) and tell the bios again that it's gone in _fini.
-Daniel

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