All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>,
	intel-gfx@lists.freedesktop.org
Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com,
	jonathan.cavitt@intel.com, ville.syrjala@linux.intel.com,
	animesh.manna@intel.com
Subject: Re: [PATCH] drm/i915/display: Simplify modular operations with vtotal
Date: Fri, 12 Sep 2025 11:55:44 +0300	[thread overview]
Message-ID: <e696008aa8675e2ff33f478b3ff47032c8c7ae36@intel.com> (raw)
In-Reply-To: <20250911153921.9038-2-jonathan.cavitt@intel.com>

On Thu, 11 Sep 2025, Jonathan Cavitt <jonathan.cavitt@intel.com> wrote:
> There are a couple of modulus operations in the i915 display code with
> vtotal as the divisor that add vtotal to the dividend.  In modular
> arithmetic, adding the divisor to the dividend is equivalent to adding
> zero to the dividend, so this addition can be dropped.

The result might become negative with this?

BR,
Jani.

>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Animesh Manna <animesh.manna@intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dsb.c    | 4 ++--
>  drivers/gpu/drm/i915/display/intel_vblank.c | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
> index dee44d45b668..67315116839b 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsb.c
> +++ b/drivers/gpu/drm/i915/display/intel_dsb.c
> @@ -173,7 +173,7 @@ static int dsb_scanline_to_hw(struct intel_atomic_state *state,
>  		intel_pre_commit_crtc_state(state, crtc);
>  	int vtotal = dsb_vtotal(state, crtc);
>  
> -	return (scanline + vtotal - intel_crtc_scanline_offset(crtc_state)) % vtotal;
> +	return (scanline - intel_crtc_scanline_offset(crtc_state)) % vtotal;
>  }
>  
>  /*
> @@ -482,7 +482,7 @@ static void assert_dsl_ok(struct intel_atomic_state *state,
>  	 * Waiting for the entire frame doesn't make sense,
>  	 * (IN==don't wait, OUT=wait forever).
>  	 */
> -	drm_WARN(crtc->base.dev, (end - start + vtotal) % vtotal == vtotal - 1,
> +	drm_WARN(crtc->base.dev, (end - start) % vtotal == vtotal - 1,
>  		 "[CRTC:%d:%s] DSB %d bad scanline window wait: %d-%d (vt=%d)\n",
>  		 crtc->base.base.id, crtc->base.name, dsb->id,
>  		 start, end, vtotal);
> diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c
> index c15234c1d96e..bcfca2fcef3c 100644
> --- a/drivers/gpu/drm/i915/display/intel_vblank.c
> +++ b/drivers/gpu/drm/i915/display/intel_vblank.c
> @@ -288,7 +288,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
>  	 * See update_scanline_offset() for the details on the
>  	 * scanline_offset adjustment.
>  	 */
> -	return (position + vtotal + crtc->scanline_offset) % vtotal;
> +	return (position + crtc->scanline_offset) % vtotal;
>  }
>  
>  /*

-- 
Jani Nikula, Intel

  parent reply	other threads:[~2025-09-12  8:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11 15:39 [PATCH] drm/i915/display: Simplify modular operations with vtotal Jonathan Cavitt
2025-09-11 17:09 ` ✓ i915.CI.BAT: success for " Patchwork
2025-09-12  6:38 ` ✗ i915.CI.Full: failure " Patchwork
2025-09-12  8:55 ` Jani Nikula [this message]
2025-09-12 14:29   ` [PATCH] " Cavitt, Jonathan
2025-09-12 15:30     ` Ville Syrjälä
2025-09-15 14:49       ` Cavitt, Jonathan
2025-09-15 15:16         ` Ville Syrjälä
2025-09-15 15:21           ` Cavitt, Jonathan
2025-09-15 15:31             ` Ville Syrjälä
2025-09-15 16:51               ` Cavitt, Jonathan

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=e696008aa8675e2ff33f478b3ff47032c8c7ae36@intel.com \
    --to=jani.nikula@intel.com \
    --cc=alex.zuo@intel.com \
    --cc=animesh.manna@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=saurabhg.gupta@intel.com \
    --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.