On Tue, Mar 07, 2023 at 10:50:49AM +0200, Jani Nikula wrote: > On Tue, 21 Feb 2023, Imre Deak <imre.deak@xxxxxxxxx> wrote: > > Call the opregion register/unregister functions during driver > > loading/unloading on !HAS_DISPLAY platforms. These functions will send > > the opregion adapter power state notifications which is required on all > > platforms (similarly how this is sent during runtime and system > > suspend/resume). Skip registering the ACPI video notifier callback on > > !HAS_DISPLAY, where the corresponding video extensions are not > > supported. > > I think the direction should be towards better separation of display > code, and this patch is counter productive. Basically we shouldn't > require calling display functions on !HAS_DISPLAY, and the early return > is what we should do. Ok, missed this point. > This, in turn, means we probably need to handle opregion differently. :( > > Dunno, maybe we need to move opregion under soc/ and have parts called > by high level driver code, and some other parts from display code. Yes, I think we can be sure that some part of the opregion i/f is not display-only (VRAM SR), so makes sense, though it's a bigger change. I think the following instead of patch 4 would be more in line with what you said above: diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c index b7973a05d022d..abfe1615afb06 100644 --- a/drivers/gpu/drm/i915/display/intel_opregion.c +++ b/drivers/gpu/drm/i915/display/intel_opregion.c @@ -1155,8 +1155,6 @@ void intel_opregion_register(struct drm_i915_private *i915) intel_opregion_video_event; register_acpi_notifier(&opregion->acpi_notifier); } - - intel_opregion_resume(i915); } static void intel_opregion_resume_display(struct drm_i915_private *i915) @@ -1228,8 +1226,6 @@ void intel_opregion_unregister(struct drm_i915_private *i915) { struct intel_opregion *opregion = &i915->display.opregion; - intel_opregion_suspend(i915, PCI_D1); - if (!opregion->header) return; diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c index 8f5e3ded52233..c554495d4f8e1 100644 --- a/drivers/gpu/drm/i915/i915_driver.c +++ b/drivers/gpu/drm/i915/i915_driver.c @@ -633,6 +633,8 @@ static void i915_driver_register(struct drm_i915_private *dev_priv) intel_display_driver_register(dev_priv); + intel_opregion_resume(i915); + intel_power_domains_enable(dev_priv); intel_runtime_pm_enable(&dev_priv->runtime_pm); @@ -658,6 +660,8 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv) intel_runtime_pm_disable(&dev_priv->runtime_pm); intel_power_domains_disable(dev_priv); + intel_opregion_suspend(i915, PCI_D1); + intel_display_driver_unregister(dev_priv); intel_pxp_fini(dev_priv); > BR, > Jani. > > > > > > Signed-off-by: Imre Deak <imre.deak@xxxxxxxxx> > > --- > > drivers/gpu/drm/i915/display/intel_display.c | 11 +++++++---- > > drivers/gpu/drm/i915/display/intel_opregion.c | 2 +- > > 2 files changed, 8 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c > > index 7827ef3e2d1e6..467f6e2376057 100644 > > --- a/drivers/gpu/drm/i915/display/intel_display.c > > +++ b/drivers/gpu/drm/i915/display/intel_display.c > > @@ -8882,11 +8882,12 @@ bool intel_modeset_probe_defer(struct pci_dev *pdev) > > > > void intel_display_driver_register(struct drm_i915_private *i915) > > { > > - if (!HAS_DISPLAY(i915)) > > - return; > > - > > /* Must be done after probing outputs */ > > intel_opregion_register(i915); > > + > > + if (!HAS_DISPLAY(i915)) > > + return; > > + > > intel_acpi_video_register(i915); > > > > intel_audio_init(i915); > > @@ -8914,7 +8915,7 @@ void intel_display_driver_register(struct drm_i915_private *i915) > > void intel_display_driver_unregister(struct drm_i915_private *i915) > > { > > if (!HAS_DISPLAY(i915)) > > - return; > > + goto unregister_opregion; > > > > intel_fbdev_unregister(i915); > > intel_audio_deinit(i915); > > @@ -8928,6 +8929,8 @@ void intel_display_driver_unregister(struct drm_i915_private *i915) > > drm_atomic_helper_shutdown(&i915->drm); > > > > acpi_video_unregister(); > > + > > +unregister_opregion: > > intel_opregion_unregister(i915); > > } > > > > diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c > > index b7973a05d022d..37098e7f607e6 100644 > > --- a/drivers/gpu/drm/i915/display/intel_opregion.c > > +++ b/drivers/gpu/drm/i915/display/intel_opregion.c > > @@ -1150,7 +1150,7 @@ void intel_opregion_register(struct drm_i915_private *i915) > > if (!opregion->header) > > return; > > > > - if (opregion->acpi) { > > + if (HAS_DISPLAY(i915) && opregion->acpi) { > > opregion->acpi_notifier.notifier_call = > > intel_opregion_video_event; > > register_acpi_notifier(&opregion->acpi_notifier); > > -- > Jani Nikula, Intel Open Source Graphics Center