On Mon, 05 Oct 2020, Ville Syrjala <ville.syrjala@xxxxxxxxxxxxxxx> wrote: > From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > > i915_{save,restore}_state() are actually all about the display. > Currently they are split into display part + SWF part. But since > the SWF part is also related to the display let's just move that > part into its own thing and flip the roles around so that the > current display part is the main function. > > Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> Reviewed-by: Jani Nikula <jani.nikula@xxxxxxxxx> > --- > drivers/gpu/drm/i915/i915_drv.c | 4 +- > drivers/gpu/drm/i915/i915_suspend.c | 116 ++++++++++++++-------------- > drivers/gpu/drm/i915/i915_suspend.h | 4 +- > 3 files changed, 60 insertions(+), 64 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c > index 45e719c79183..1c1f5dbb467c 100644 > --- a/drivers/gpu/drm/i915/i915_drv.c > +++ b/drivers/gpu/drm/i915/i915_drv.c > @@ -1089,7 +1089,7 @@ static int i915_drm_suspend(struct drm_device *dev) > > i915_ggtt_suspend(&dev_priv->ggtt); > > - i915_save_state(dev_priv); > + i915_save_display(dev_priv); > > opregion_target_state = suspend_to_idle(dev_priv) ? PCI_D1 : PCI_D3cold; > intel_opregion_suspend(dev_priv, opregion_target_state); > @@ -1202,7 +1202,7 @@ static int i915_drm_resume(struct drm_device *dev) > > intel_csr_ucode_resume(dev_priv); > > - i915_restore_state(dev_priv); > + i915_restore_display(dev_priv); > intel_pps_unlock_regs_wa(dev_priv); > > intel_init_pch_refclk(dev_priv); > diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c > index 7b64e7137270..db2111fc809e 100644 > --- a/drivers/gpu/drm/i915/i915_suspend.c > +++ b/drivers/gpu/drm/i915/i915_suspend.c > @@ -32,7 +32,57 @@ > #include "i915_reg.h" > #include "i915_suspend.h" > > -static void i915_save_display(struct drm_i915_private *dev_priv) > +static void intel_save_swf(struct drm_i915_private *dev_priv) > +{ > + int i; > + > + /* Scratch space */ > + if (IS_GEN(dev_priv, 2) && IS_MOBILE(dev_priv)) { > + for (i = 0; i < 7; i++) { > + dev_priv->regfile.saveSWF0[i] = I915_READ(SWF0(i)); > + dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i)); > + } > + for (i = 0; i < 3; i++) > + dev_priv->regfile.saveSWF3[i] = I915_READ(SWF3(i)); > + } else if (IS_GEN(dev_priv, 2)) { > + for (i = 0; i < 7; i++) > + dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i)); > + } else if (HAS_GMCH(dev_priv)) { > + for (i = 0; i < 16; i++) { > + dev_priv->regfile.saveSWF0[i] = I915_READ(SWF0(i)); > + dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i)); > + } > + for (i = 0; i < 3; i++) > + dev_priv->regfile.saveSWF3[i] = I915_READ(SWF3(i)); > + } > +} > + > +static void intel_restore_swf(struct drm_i915_private *dev_priv) > +{ > + int i; > + > + /* Scratch space */ > + if (IS_GEN(dev_priv, 2) && IS_MOBILE(dev_priv)) { > + for (i = 0; i < 7; i++) { > + I915_WRITE(SWF0(i), dev_priv->regfile.saveSWF0[i]); > + I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]); > + } > + for (i = 0; i < 3; i++) > + I915_WRITE(SWF3(i), dev_priv->regfile.saveSWF3[i]); > + } else if (IS_GEN(dev_priv, 2)) { > + for (i = 0; i < 7; i++) > + I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]); > + } else if (HAS_GMCH(dev_priv)) { > + for (i = 0; i < 16; i++) { > + I915_WRITE(SWF0(i), dev_priv->regfile.saveSWF0[i]); > + I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]); > + } > + for (i = 0; i < 3; i++) > + I915_WRITE(SWF3(i), dev_priv->regfile.saveSWF3[i]); > + } > +} > + > +void i915_save_display(struct drm_i915_private *dev_priv) > { > struct pci_dev *pdev = dev_priv->drm.pdev; > > @@ -43,12 +93,16 @@ static void i915_save_display(struct drm_i915_private *dev_priv) > if (IS_GEN(dev_priv, 4)) > pci_read_config_word(pdev, GCDGMBUS, > &dev_priv->regfile.saveGCDGMBUS); > + > + intel_save_swf(dev_priv); > } > > -static void i915_restore_display(struct drm_i915_private *dev_priv) > +void i915_restore_display(struct drm_i915_private *dev_priv) > { > struct pci_dev *pdev = dev_priv->drm.pdev; > > + intel_restore_swf(dev_priv); > + > if (IS_GEN(dev_priv, 4)) > pci_write_config_word(pdev, GCDGMBUS, > dev_priv->regfile.saveGCDGMBUS); > @@ -64,61 +118,3 @@ static void i915_restore_display(struct drm_i915_private *dev_priv) > > intel_gmbus_reset(dev_priv); > } > - > -int i915_save_state(struct drm_i915_private *dev_priv) > -{ > - int i; > - > - i915_save_display(dev_priv); > - > - /* Scratch space */ > - if (IS_GEN(dev_priv, 2) && IS_MOBILE(dev_priv)) { > - for (i = 0; i < 7; i++) { > - dev_priv->regfile.saveSWF0[i] = I915_READ(SWF0(i)); > - dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i)); > - } > - for (i = 0; i < 3; i++) > - dev_priv->regfile.saveSWF3[i] = I915_READ(SWF3(i)); > - } else if (IS_GEN(dev_priv, 2)) { > - for (i = 0; i < 7; i++) > - dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i)); > - } else if (HAS_GMCH(dev_priv)) { > - for (i = 0; i < 16; i++) { > - dev_priv->regfile.saveSWF0[i] = I915_READ(SWF0(i)); > - dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i)); > - } > - for (i = 0; i < 3; i++) > - dev_priv->regfile.saveSWF3[i] = I915_READ(SWF3(i)); > - } > - > - return 0; > -} > - > -int i915_restore_state(struct drm_i915_private *dev_priv) > -{ > - int i; > - > - i915_restore_display(dev_priv); > - > - /* Scratch space */ > - if (IS_GEN(dev_priv, 2) && IS_MOBILE(dev_priv)) { > - for (i = 0; i < 7; i++) { > - I915_WRITE(SWF0(i), dev_priv->regfile.saveSWF0[i]); > - I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]); > - } > - for (i = 0; i < 3; i++) > - I915_WRITE(SWF3(i), dev_priv->regfile.saveSWF3[i]); > - } else if (IS_GEN(dev_priv, 2)) { > - for (i = 0; i < 7; i++) > - I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]); > - } else if (HAS_GMCH(dev_priv)) { > - for (i = 0; i < 16; i++) { > - I915_WRITE(SWF0(i), dev_priv->regfile.saveSWF0[i]); > - I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]); > - } > - for (i = 0; i < 3; i++) > - I915_WRITE(SWF3(i), dev_priv->regfile.saveSWF3[i]); > - } > - > - return 0; > -} > diff --git a/drivers/gpu/drm/i915/i915_suspend.h b/drivers/gpu/drm/i915/i915_suspend.h > index 3a36fb4ecc05..e5a611ee3d15 100644 > --- a/drivers/gpu/drm/i915/i915_suspend.h > +++ b/drivers/gpu/drm/i915/i915_suspend.h > @@ -8,7 +8,7 @@ > > struct drm_i915_private; > > -int i915_save_state(struct drm_i915_private *i915); > -int i915_restore_state(struct drm_i915_private *i915); > +void i915_save_display(struct drm_i915_private *i915); > +void i915_restore_display(struct drm_i915_private *i915); > > #endif /* __I915_SUSPEND_H__ */ -- Jani Nikula, Intel Open Source Graphics Center _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx