All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: <intel-gfx@lists.freedesktop.org>,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	Jani Nikula <jani.nikula@intel.com>
Subject: Re: [PATCH] drm/i915/display: Convert i915_suspend into i9xx_display_sr
Date: Mon, 16 Sep 2024 17:25:38 -0400	[thread overview]
Message-ID: <ZuiiUjsibLttMH1i@intel.com> (raw)
In-Reply-To: <ZuQgetl8IlS4MQ28@intel.com>

On Fri, Sep 13, 2024 at 02:22:34PM +0300, Ville Syrjälä wrote:
> On Thu, Sep 12, 2024 at 01:45:34PM -0400, Rodrigo Vivi wrote:
> > These save & restore functions inside i915_suspend are old display
> > functions to save and restore a bunch of display related registers.
> > 
> > Move it under display and rename accordantly. Just don't move it
> > entirely towards intel_display struct yet because it depends
> > on drm_i915_private for the IS_MOBILE.
> > 
> > While doing this conversion also update the MIT header using
> > the new SPDX ones.
> > 
> > Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> > Cc: Jani Nikula <jani.nikula@intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > ---
> >  drivers/gpu/drm/i915/Makefile                 |   2 +-
> >  .../gpu/drm/i915/display/i9xx_display_sr.c    | 119 +++++++++++++++
> >  .../gpu/drm/i915/display/i9xx_display_sr.h    |  14 ++
> >  drivers/gpu/drm/i915/i915_driver.c            |   6 +-
> >  drivers/gpu/drm/i915/i915_suspend.c           | 141 ------------------
> >  drivers/gpu/drm/i915/i915_suspend.h           |  14 --
> >  6 files changed, 137 insertions(+), 159 deletions(-)
> >  create mode 100644 drivers/gpu/drm/i915/display/i9xx_display_sr.c
> >  create mode 100644 drivers/gpu/drm/i915/display/i9xx_display_sr.h
> >  delete mode 100644 drivers/gpu/drm/i915/i915_suspend.c
> >  delete mode 100644 drivers/gpu/drm/i915/i915_suspend.h
> > 
> > diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> > index c63fa2133ccb..89f04bdbc27f 100644
> > --- a/drivers/gpu/drm/i915/Makefile
> > +++ b/drivers/gpu/drm/i915/Makefile
> > @@ -30,7 +30,6 @@ i915-y += \
> >  	i915_params.o \
> >  	i915_pci.o \
> >  	i915_scatterlist.o \
> > -	i915_suspend.o \
> >  	i915_switcheroo.o \
> >  	i915_sysfs.o \
> >  	i915_utils.o \
> > @@ -219,6 +218,7 @@ i915-$(CONFIG_HWMON) += \
> >  i915-y += \
> >  	display/hsw_ips.o \
> >  	display/i9xx_plane.o \
> > +	display/i9xx_suspend.o \
> >  	display/i9xx_wm.o \
> >  	display/intel_alpm.o \
> >  	display/intel_atomic.o \
> > diff --git a/drivers/gpu/drm/i915/display/i9xx_display_sr.c b/drivers/gpu/drm/i915/display/i9xx_display_sr.c
> > new file mode 100644
> > index 000000000000..211cf41119ad
> > --- /dev/null
> > +++ b/drivers/gpu/drm/i915/display/i9xx_display_sr.c
> > @@ -0,0 +1,119 @@
> > +// SPDX-License-Identifier: MIT
> > +/*
> > + * Copyright © 2024 Intel Corporation
> > + */
> > +
> > +#include "i915_drv.h"
> > +#include "i915_reg.h"
> > +#include "i9xx_suspend.h"
> > +#include "intel_de.h"
> > +#include "intel_gmbus.h"
> > +#include "intel_vga.h"
> > +#include "intel_pci_config.h"
> > +
> > +static void intel_save_swf(struct drm_i915_private *i915)
> > +{
> > +	int i;
> > +
> > +	/* Scratch space */
> > +	if (DISPLAY_VER(i915) == 2 && IS_MOBILE(i915)) {
> > +		for (i = 0; i < 7; i++) {
> > +			i915->regfile.saveSWF0[i] = intel_de_read(i915,
> > +								      SWF0(i915, i));
> > +			i915->regfile.saveSWF1[i] = intel_de_read(i915,
> > +								      SWF1(i915, i));
> > +		}
> > +		for (i = 0; i < 3; i++)
> > +			i915->regfile.saveSWF3[i] = intel_de_read(i915,
> > +								      SWF3(i915, i));
> > +	} else if (DISPLAY_VER(i915) == 2) {
> > +		for (i = 0; i < 7; i++)
> > +			i915->regfile.saveSWF1[i] = intel_de_read(i915,
> > +								      SWF1(i915, i));
> > +	} else if (HAS_GMCH(i915)) {
> > +		for (i = 0; i < 16; i++) {
> > +			i915->regfile.saveSWF0[i] = intel_de_read(i915,
> > +								      SWF0(i915, i));
> > +			i915->regfile.saveSWF1[i] = intel_de_read(i915,
> > +								      SWF1(i915, i));
> > +		}
> > +		for (i = 0; i < 3; i++)
> > +			i915->regfile.saveSWF3[i] = intel_de_read(i915,
> > +								      SWF3(i915, i));
> > +	}
> > +}
> > +
> > +static void intel_restore_swf(struct drm_i915_private *i915)
> > +{
> > +	int i;
> > +
> > +	/* Scratch space */
> > +	if (DISPLAY_VER(i915) == 2 && IS_MOBILE(i915)) {
> > +		for (i = 0; i < 7; i++) {
> > +			intel_de_write(i915, SWF0(i915, i),
> > +				       i915->regfile.saveSWF0[i]);
> > +			intel_de_write(i915, SWF1(i915, i),
> > +				       i915->regfile.saveSWF1[i]);
> > +		}
> > +		for (i = 0; i < 3; i++)
> > +			intel_de_write(i915, SWF3(i915, i),
> > +				       i915->regfile.saveSWF3[i]);
> > +	} else if (DISPLAY_VER(i915) == 2) {
> > +		for (i = 0; i < 7; i++)
> > +			intel_de_write(i915, SWF1(i915, i),
> > +				       i915->regfile.saveSWF1[i]);
> > +	} else if (HAS_GMCH(i915)) {
> > +		for (i = 0; i < 16; i++) {
> > +			intel_de_write(i915, SWF0(i915, i),
> > +				       i915->regfile.saveSWF0[i]);
> > +			intel_de_write(i915, SWF1(i915, i),
> > +				       i915->regfile.saveSWF1[i]);
> > +		}
> > +		for (i = 0; i < 3; i++)
> > +			intel_de_write(i915, SWF3(i915, i),
> > +				       i915->regfile.saveSWF3[i]);
> > +	}
> > +}
> > +
> > +void i9xx_display_sr_save(struct drm_i915_private *i915)
> > +{
> > +	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
> > +
> > +	if (!HAS_DISPLAY(i915))
> > +		return;
> > +
> > +	/* Display arbitration control */
> > +	if (DISPLAY_VER(i915) <= 4)
> > +		i915->regfile.saveDSPARB = intel_de_read(i915,
> > +							     DSPARB(i915));
> > +
> > +	if (DISPLAY_VER(i915) == 4)
> > +		pci_read_config_word(pdev, GCDGMBUS,
> > +				     &i915->regfile.saveGCDGMBUS);
> > +
> > +	intel_save_swf(i915);
> > +}
> > +
> > +void i9xx_display_sr_restore(struct drm_i915_private *i915)
> > +{
> > +	struct intel_display *display = &i915->display;
> > +	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
> > +
> > +	if (!HAS_DISPLAY(i915))
> > +		return;
> > +
> > +	intel_restore_swf(i915);
> > +
> > +	if (DISPLAY_VER(i915) == 4)
> > +		pci_write_config_word(pdev, GCDGMBUS,
> > +				      i915->regfile.saveGCDGMBUS);
> > +
> > +	/* Display arbitration */
> > +	if (DISPLAY_VER(i915) <= 4)
> > +		intel_de_write(i915, DSPARB(i915),
> > +			       i915->regfile.saveDSPARB);
> > +
> > +	intel_vga_redisable(display);
> > +
> > +	intel_gmbus_reset(i915);
> 
> The last two are for all platforms, so the function name is a bit
> misleading now.

Indeed... having another patch to remove this from this function
before the name conversion.

> 
> Also we might want to do the SWF save/restore for all platforms
> as well, because technically we should be reading one of those
> to determine the maximum CDCLK for the system (if the BIOS
> has chosen a limit other than the platform default). We could
> get into trouble there if the driver is reloaded after S3,
> assuming S3 clobbers the SWF registers (which I'm not 100%
> sure it does, would need to confirm it).

Well, if we end up needing that we can always do a s/i9xx/i915
later in the name. But I really don't believe that we should
be the ones taking care of the registers save/restore. Some
one else should be taking care of this save restore, or we should
simply stash the boot value.

> 
> I have an old branch that does the SWF read for BDW only
> 'https://github.com/vsyrjala/linux.git bdw_vbios_cdclk_limit'
> but last I looked Windows was still doing this for all
> platforms, so we should probably we doing the same.
> 
> -- 
> Ville Syrjälä
> Intel

  reply	other threads:[~2024-09-16 21:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-12 17:45 [PATCH] drm/i915/display: Convert i915_suspend into i9xx_display_sr Rodrigo Vivi
2024-09-12 21:50 ` ✗ Fi.CI.BUILD: failure for " Patchwork
2024-09-13 10:14 ` [PATCH] " Jani Nikula
2024-09-13 11:22 ` Ville Syrjälä
2024-09-16 21:25   ` Rodrigo Vivi [this message]
2024-09-13 13:04 ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZuiiUjsibLttMH1i@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.