All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 08/10] drm/i915: Merge sbi read/write into a single accessor
Date: Tue, 23 Apr 2019 20:21:26 +0300	[thread overview]
Message-ID: <20190423172126.GD1747@intel.com> (raw)
In-Reply-To: <20190419171402.30596-9-chris@chris-wilson.co.uk>

On Fri, Apr 19, 2019 at 06:14:00PM +0100, Chris Wilson wrote:
> Since intel_sideband_read and intel_sideband_write differ by only a
> couple of lines (depending on whether we feed the value in or out),
> merge the two into a single common accessor.
> 
> v2: Restore vlv_flisdsi_read() lost during rebasing.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Looks equivalent

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/intel_sideband.c | 94 +++++++++++----------------
>  1 file changed, 38 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_sideband.c b/drivers/gpu/drm/i915/intel_sideband.c
> index 5c3ae5185a01..7113fb8850d6 100644
> --- a/drivers/gpu/drm/i915/intel_sideband.c
> +++ b/drivers/gpu/drm/i915/intel_sideband.c
> @@ -273,81 +273,63 @@ void vlv_flisdsi_write(struct drm_i915_private *i915, u32 reg, u32 val)
>  }
>  
>  /* SBI access */
> -u32 intel_sbi_read(struct drm_i915_private *dev_priv, u16 reg,
> -		   enum intel_sbi_destination destination)
> +static int intel_sbi_rw(struct drm_i915_private *i915, u16 reg,
> +			enum intel_sbi_destination destination,
> +			u32 *val, bool is_read)
>  {
> -	u32 value = 0;
> +	struct intel_uncore *uncore = &i915->uncore;
> +	u32 cmd;
>  
> -	lockdep_assert_held(&dev_priv->sb_lock);
> +	lockdep_assert_held(&i915->sb_lock);
>  
> -	if (intel_wait_for_register(&dev_priv->uncore,
> -				    SBI_CTL_STAT, SBI_BUSY, 0,
> -				    100)) {
> +	if (intel_wait_for_register_fw(uncore,
> +				       SBI_CTL_STAT, SBI_BUSY, 0,
> +				       100)) {
>  		DRM_ERROR("timeout waiting for SBI to become ready\n");
> -		return 0;
> +		return -EBUSY;
>  	}
>  
> -	I915_WRITE(SBI_ADDR, (reg << 16));
> -	I915_WRITE(SBI_DATA, 0);
> +	intel_uncore_write_fw(uncore, SBI_ADDR, (u32)reg << 16);
> +	intel_uncore_write_fw(uncore, SBI_DATA, is_read ? 0 : *val);
>  
>  	if (destination == SBI_ICLK)
> -		value = SBI_CTL_DEST_ICLK | SBI_CTL_OP_CRRD;
> +		cmd = SBI_CTL_DEST_ICLK | SBI_CTL_OP_CRRD;
>  	else
> -		value = SBI_CTL_DEST_MPHY | SBI_CTL_OP_IORD;
> -	I915_WRITE(SBI_CTL_STAT, value | SBI_BUSY);
> -
> -	if (intel_wait_for_register(&dev_priv->uncore,
> -				    SBI_CTL_STAT,
> -				    SBI_BUSY,
> -				    0,
> -				    100)) {
> +		cmd = SBI_CTL_DEST_MPHY | SBI_CTL_OP_IORD;
> +	if (!is_read)
> +		cmd |= BIT(8);
> +	intel_uncore_write_fw(uncore, SBI_CTL_STAT, cmd | SBI_BUSY);
> +
> +	if (__intel_wait_for_register_fw(uncore,
> +					 SBI_CTL_STAT, SBI_BUSY, 0,
> +					 100, 100, &cmd)) {
>  		DRM_ERROR("timeout waiting for SBI to complete read\n");
> -		return 0;
> +		return -ETIMEDOUT;
>  	}
>  
> -	if (I915_READ(SBI_CTL_STAT) & SBI_RESPONSE_FAIL) {
> +	if (cmd & SBI_RESPONSE_FAIL) {
>  		DRM_ERROR("error during SBI read of reg %x\n", reg);
> -		return 0;
> +		return -ENXIO;
>  	}
>  
> -	return I915_READ(SBI_DATA);
> +	if (is_read)
> +		*val = intel_uncore_read_fw(uncore, SBI_DATA);
> +
> +	return 0;
>  }
>  
> -void intel_sbi_write(struct drm_i915_private *dev_priv, u16 reg, u32 value,
> -		     enum intel_sbi_destination destination)
> +u32 intel_sbi_read(struct drm_i915_private *i915, u16 reg,
> +		   enum intel_sbi_destination destination)
>  {
> -	u32 tmp;
> +	u32 result = 0;
>  
> -	lockdep_assert_held(&dev_priv->sb_lock);
> +	intel_sbi_rw(i915, reg, destination, &result, true);
>  
> -	if (intel_wait_for_register(&dev_priv->uncore,
> -				    SBI_CTL_STAT, SBI_BUSY, 0,
> -				    100)) {
> -		DRM_ERROR("timeout waiting for SBI to become ready\n");
> -		return;
> -	}
> -
> -	I915_WRITE(SBI_ADDR, (reg << 16));
> -	I915_WRITE(SBI_DATA, value);
> -
> -	if (destination == SBI_ICLK)
> -		tmp = SBI_CTL_DEST_ICLK | SBI_CTL_OP_CRWR;
> -	else
> -		tmp = SBI_CTL_DEST_MPHY | SBI_CTL_OP_IOWR;
> -	I915_WRITE(SBI_CTL_STAT, SBI_BUSY | tmp);
> -
> -	if (intel_wait_for_register(&dev_priv->uncore,
> -				    SBI_CTL_STAT,
> -				    SBI_BUSY,
> -				    0,
> -				    100)) {
> -		DRM_ERROR("timeout waiting for SBI to complete write\n");
> -		return;
> -	}
> +	return result;
> +}
>  
> -	if (I915_READ(SBI_CTL_STAT) & SBI_RESPONSE_FAIL) {
> -		DRM_ERROR("error during SBI write of %x to reg %x\n",
> -			  value, reg);
> -		return;
> -	}
> +void intel_sbi_write(struct drm_i915_private *i915, u16 reg, u32 value,
> +		     enum intel_sbi_destination destination)
> +{
> +	intel_sbi_rw(i915, reg, destination, &value, false);
>  }
> -- 
> 2.20.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-04-23 17:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-19 17:13 Nefarious Baytrail Chris Wilson
2019-04-19 17:13 ` [PATCH 01/10] drm/i915: Disable preemption and sleeping while using the punit sideband Chris Wilson
2019-04-23 16:49   ` Ville Syrjälä
2019-04-19 17:13 ` [PATCH 02/10] drm/i915: Lift acquiring the vlv punit magic to a common sb-get Chris Wilson
2019-04-23 16:55   ` Ville Syrjälä
2019-04-19 17:13 ` [PATCH 03/10] drm/i915: Lift sideband locking for vlv_punit_(read|write) Chris Wilson
2019-04-23 17:14   ` Ville Syrjälä
2019-04-19 17:13 ` [PATCH 04/10] drm/i915: Reduce RPS update frequency on Valleyview/Cherryview Chris Wilson
2019-04-23 17:15   ` Ville Syrjälä
2019-04-19 17:13 ` [PATCH 05/10] Revert "drm/i915: Avoid tweaking evaluation thresholds on Baytrail v3" Chris Wilson
2019-04-19 17:13 ` [PATCH 06/10] drm/i915: Replace pcu_lock with sb_lock Chris Wilson
2019-04-19 17:13 ` [PATCH 07/10] drm/i915: Separate sideband declarations to intel_sideband.h Chris Wilson
2019-04-23 17:17   ` Ville Syrjälä
2019-04-19 17:14 ` [PATCH 08/10] drm/i915: Merge sbi read/write into a single accessor Chris Wilson
2019-04-23 17:21   ` Ville Syrjälä [this message]
2019-04-19 17:14 ` [PATCH 09/10] drm/i915: Merge sandybridge_pcode_(read|write) Chris Wilson
2019-04-19 17:14 ` [PATCH 10/10] drm/i915: Move sandybride pcode access to intel_sideband.c Chris Wilson
2019-04-23 17:22   ` Ville Syrjälä
2019-04-19 17:39 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/10] drm/i915: Disable preemption and sleeping while using the punit sideband Patchwork
2019-04-19 17:43 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-04-19 17:59 ` ✓ Fi.CI.BAT: success " Patchwork
2019-04-19 19:44 ` ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2018-03-07 19:41 vlv punit and sideband tidy Chris Wilson
2018-03-07 19:42 ` [PATCH 08/10] drm/i915: Merge sbi read/write into a single accessor Chris Wilson

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=20190423172126.GD1747@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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.