All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 6/7] drm/atomic: Fix the early return in drm_atomic_set_mode_for_crtc()
Date: Tue, 19 Nov 2019 11:20:47 +0100	[thread overview]
Message-ID: <20191119102047.GB30416@phenom.ffwll.local> (raw)
In-Reply-To: <20191115194204.22244-7-ville.syrjala@linux.intel.com>

On Fri, Nov 15, 2019 at 09:42:03PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> The early return in drm_atomic_set_mode_for_crtc() isn't quite
> right. It would mistakenly return and fail to update
> crtc_state->enable if someone actually tried to set a zeroed
> mode on a currently disabled crtc. That should never actually
> happen in response to any userspace request as the zeroed mode
> would get rejected earlier. However there is some chance of this
> happening internally (eg. during hw state readout) so it seems
> best to not let the state become totally inconsistent.
> 
> Additionally the early return will not be taken if we're trying to
> disable an already disabled crtc. While that is not actually
> harmful it is inconsistent, so let's handle that case as well.
> 
> Testcase: igt/kms_selftest/check_atomic_set_mode_for_crtc
> Testcase: igt/kms_selftest/check_atomic_set_zeroed_mode_fort_crtc
> Reviewed-by: Daniel Vetter <daniel@ffwll.ch>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_uapi.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 0d466d3b0809..a3a6a8137af4 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -68,8 +68,13 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
>  	struct drm_mode_modeinfo umode;
>  
>  	/* Early return for no change. */
> -	if (mode && memcmp(&state->mode, mode, sizeof(*mode)) == 0)
> -		return 0;
> +	if (state->enable) {

Hm I think this would be clearer if you go with

	if (state->enable == !!mode &&
	    (!mode || memcmp(&state->mode, mode, sizeof(*mode)) == 0))
	    	return 0;

But also somewhat a bikeshed. I'm also wondering whether we shouldn't just
declare this a driver bug (it means enable and mode are already out of
sync), but I guess hw state readout is special sometimes.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +		if (mode && memcmp(&state->mode, mode, sizeof(*mode)) == 0)
> +			return 0;
> +	} else {
> +		if (!mode)
> +			return 0;
> +	}
>  
>  	drm_property_blob_put(state->mode_blob);
>  	state->mode_blob = NULL;
> -- 
> 2.23.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 6/7] drm/atomic: Fix the early return in drm_atomic_set_mode_for_crtc()
Date: Tue, 19 Nov 2019 11:20:47 +0100	[thread overview]
Message-ID: <20191119102047.GB30416@phenom.ffwll.local> (raw)
Message-ID: <20191119102047.7qI8MXm6NCevbP0Yc6jlxcTEyAjXUjStlx1PHhIVBFs@z> (raw)
In-Reply-To: <20191115194204.22244-7-ville.syrjala@linux.intel.com>

On Fri, Nov 15, 2019 at 09:42:03PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> The early return in drm_atomic_set_mode_for_crtc() isn't quite
> right. It would mistakenly return and fail to update
> crtc_state->enable if someone actually tried to set a zeroed
> mode on a currently disabled crtc. That should never actually
> happen in response to any userspace request as the zeroed mode
> would get rejected earlier. However there is some chance of this
> happening internally (eg. during hw state readout) so it seems
> best to not let the state become totally inconsistent.
> 
> Additionally the early return will not be taken if we're trying to
> disable an already disabled crtc. While that is not actually
> harmful it is inconsistent, so let's handle that case as well.
> 
> Testcase: igt/kms_selftest/check_atomic_set_mode_for_crtc
> Testcase: igt/kms_selftest/check_atomic_set_zeroed_mode_fort_crtc
> Reviewed-by: Daniel Vetter <daniel@ffwll.ch>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_uapi.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 0d466d3b0809..a3a6a8137af4 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -68,8 +68,13 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
>  	struct drm_mode_modeinfo umode;
>  
>  	/* Early return for no change. */
> -	if (mode && memcmp(&state->mode, mode, sizeof(*mode)) == 0)
> -		return 0;
> +	if (state->enable) {

Hm I think this would be clearer if you go with

	if (state->enable == !!mode &&
	    (!mode || memcmp(&state->mode, mode, sizeof(*mode)) == 0))
	    	return 0;

But also somewhat a bikeshed. I'm also wondering whether we shouldn't just
declare this a driver bug (it means enable and mode are already out of
sync), but I guess hw state readout is special sometimes.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +		if (mode && memcmp(&state->mode, mode, sizeof(*mode)) == 0)
> +			return 0;
> +	} else {
> +		if (!mode)
> +			return 0;
> +	}
>  
>  	drm_property_blob_put(state->mode_blob);
>  	state->mode_blob = NULL;
> -- 
> 2.23.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 6/7] drm/atomic: Fix the early return in drm_atomic_set_mode_for_crtc()
Date: Tue, 19 Nov 2019 11:20:47 +0100	[thread overview]
Message-ID: <20191119102047.GB30416@phenom.ffwll.local> (raw)
Message-ID: <20191119102047.WD92_35cJpfwnyUicHt_5Fqetb6HAVtXpZsg-Gs_9MA@z> (raw)
In-Reply-To: <20191115194204.22244-7-ville.syrjala@linux.intel.com>

On Fri, Nov 15, 2019 at 09:42:03PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> The early return in drm_atomic_set_mode_for_crtc() isn't quite
> right. It would mistakenly return and fail to update
> crtc_state->enable if someone actually tried to set a zeroed
> mode on a currently disabled crtc. That should never actually
> happen in response to any userspace request as the zeroed mode
> would get rejected earlier. However there is some chance of this
> happening internally (eg. during hw state readout) so it seems
> best to not let the state become totally inconsistent.
> 
> Additionally the early return will not be taken if we're trying to
> disable an already disabled crtc. While that is not actually
> harmful it is inconsistent, so let's handle that case as well.
> 
> Testcase: igt/kms_selftest/check_atomic_set_mode_for_crtc
> Testcase: igt/kms_selftest/check_atomic_set_zeroed_mode_fort_crtc
> Reviewed-by: Daniel Vetter <daniel@ffwll.ch>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_uapi.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 0d466d3b0809..a3a6a8137af4 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -68,8 +68,13 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
>  	struct drm_mode_modeinfo umode;
>  
>  	/* Early return for no change. */
> -	if (mode && memcmp(&state->mode, mode, sizeof(*mode)) == 0)
> -		return 0;
> +	if (state->enable) {

Hm I think this would be clearer if you go with

	if (state->enable == !!mode &&
	    (!mode || memcmp(&state->mode, mode, sizeof(*mode)) == 0))
	    	return 0;

But also somewhat a bikeshed. I'm also wondering whether we shouldn't just
declare this a driver bug (it means enable and mode are already out of
sync), but I guess hw state readout is special sometimes.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +		if (mode && memcmp(&state->mode, mode, sizeof(*mode)) == 0)
> +			return 0;
> +	} else {
> +		if (!mode)
> +			return 0;
> +	}
>  
>  	drm_property_blob_put(state->mode_blob);
>  	state->mode_blob = NULL;
> -- 
> 2.23.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-11-19 10:20 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 19:41 [PATCH 0/7] drm: Random pile of core stuff Ville Syrjala
2019-11-15 19:41 ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:41 ` Ville Syrjala
2019-11-15 19:41 ` [PATCH 1/7] drm: Move page_flip fb lookup earlier Ville Syrjala
2019-11-15 19:41   ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:41   ` Ville Syrjala
2019-11-15 19:41 ` [PATCH 2/7] drm: Allocate the page flip event earlier Ville Syrjala
2019-11-15 19:41   ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:41   ` Ville Syrjala
2019-11-15 19:42 ` [PATCH 3/7] drm: Extract page_flip_{internal, atomic}() Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:42   ` [PATCH 3/7] drm: Extract page_flip_{internal,atomic}() Ville Syrjala
2019-11-19 10:14   ` [PATCH 3/7] drm: Extract page_flip_{internal, atomic}() Daniel Vetter
2019-11-19 10:14     ` [Intel-gfx] " Daniel Vetter
2019-11-19 10:14     ` Daniel Vetter
2019-11-22 18:35     ` Ville Syrjälä
2019-11-22 18:35       ` [Intel-gfx] " Ville Syrjälä
2019-11-22 18:35       ` Ville Syrjälä
2019-11-25  9:02       ` Daniel Vetter
2019-11-25  9:02         ` [Intel-gfx] " Daniel Vetter
2019-11-25  9:02         ` Daniel Vetter
2019-11-25 15:05         ` Ville Syrjälä
2019-11-25 15:05           ` [Intel-gfx] " Ville Syrjälä
2019-11-25 15:05           ` Ville Syrjälä
2019-11-25 17:24           ` Daniel Vetter
2019-11-25 17:24             ` [Intel-gfx] " Daniel Vetter
2019-11-25 17:24             ` Daniel Vetter
2019-11-15 19:42 ` [PATCH 4/7] drm: Simplify the setplane old_fb handling further Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:42   ` Ville Syrjala
2019-11-15 19:42 ` [PATCH 5/7] drm/selftests: Add some selftests for drm_atomic_set_mode_for_crtc() Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:42   ` Ville Syrjala
2019-11-19 10:39   ` Daniel Vetter
2019-11-19 10:39     ` [Intel-gfx] " Daniel Vetter
2019-11-15 19:42 ` [PATCH 6/7] drm/atomic: Fix the early return in drm_atomic_set_mode_for_crtc() Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-19 10:20   ` Daniel Vetter [this message]
2019-11-19 10:20     ` Daniel Vetter
2019-11-19 10:20     ` Daniel Vetter
2019-11-15 19:42 ` [PATCH 7/7] drm/atomic: Reduce setplane locking Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-19 10:47   ` Daniel Vetter
2019-11-19 10:47     ` [Intel-gfx] " Daniel Vetter
2019-11-19 10:47     ` Daniel Vetter
2019-11-15 22:59 ` ✗ Fi.CI.CHECKPATCH: warning for drm: Random pile of core stuff Patchwork
2019-11-15 22:59   ` [Intel-gfx] " Patchwork
2019-11-15 23:20 ` ✓ Fi.CI.BAT: success " Patchwork
2019-11-15 23:20   ` [Intel-gfx] " Patchwork
2019-11-17 12:20 ` ✗ Fi.CI.IGT: failure " Patchwork
2019-11-17 12:20   ` [Intel-gfx] " Patchwork

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=20191119102047.GB30416@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.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.