dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Lyude Paul <lyude@redhat.com>
Cc: nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: Re: [PATCH v2 3/4] drm/dp_mst: Check payload count in drm_dp_mst_atomic_check()
Date: Mon, 29 Oct 2018 15:25:37 +0100	[thread overview]
Message-ID: <20181029142537.GC21967@phenom.ffwll.local> (raw)
In-Reply-To: <20181026203549.1796-4-lyude@redhat.com>

On Fri, Oct 26, 2018 at 04:35:48PM -0400, Lyude Paul wrote:
> It occurred to me that we never actually check this! So let's start
> doing that.
> 
> Signed-off-by: Lyude Paul <lyude@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

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

One thought on testing all this: I think long term some unti tests, where
we have a fake driver doing fake mst branch/ports and a bunch of
allocations and then checking that it all works and validates would be
nice. Longer term project ofc, and maybe after Kunit has been merged ...
-Daniel

> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index dcfab7536914..8bb03700e199 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -3238,7 +3238,7 @@ int drm_dp_mst_atomic_check(struct drm_dp_mst_topology_state *state)
>  {
>  	struct drm_dp_mst_topology_mgr *mgr = state->mgr;
>  	struct drm_dp_vcpi_allocation *pos;
> -	int avail_slots = 63;
> +	int avail_slots = 63, payload_count = 0;
>  
>  	list_for_each_entry(pos, &state->vcpis, next) {
>  		DRM_DEBUG_ATOMIC("[MST PORT:%p] requires %d vcpi slots\n",
> @@ -3251,6 +3251,12 @@ int drm_dp_mst_atomic_check(struct drm_dp_mst_topology_state *state)
>  					 avail_slots + pos->vcpi);
>  			return -ENOSPC;
>  		}
> +
> +		if (++payload_count > mgr->max_payloads) {
> +			DRM_DEBUG_ATOMIC("[MST MGR:%p] state %p has too many payloads (max=%d)\n",
> +					 mgr, state, mgr->max_payloads);
> +			return -EINVAL;
> +		}
>  	}
>  	DRM_DEBUG_ATOMIC("[MST MGR:%p] state %p vcpi avail=%d used=%d\n",
>  			 mgr, state, avail_slots, 63 - avail_slots);
> -- 
> 2.17.2
> 

-- 
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

  reply	other threads:[~2018-10-29 14:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 20:35 [PATCH v2 0/4] drm/dp_mst: Improve VCPI helpers, use in nouveau Lyude Paul
     [not found] ` <20181026203549.1796-1-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-10-26 20:35   ` [PATCH v2 1/4] drm/dp_mst: Add some atomic state iterator macros Lyude Paul
2018-10-29 14:08     ` Daniel Vetter
2018-10-26 20:35   ` [PATCH v2 2/4] drm/dp_mst: Start tracking per-port VCPI allocations Lyude Paul
2018-10-29 14:24     ` Daniel Vetter
2018-10-29 16:43       ` Lyude Paul
     [not found]       ` <20181029142429.GB21967-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-10-30  9:04         ` Daniel Vetter
2018-10-26 20:35 ` [PATCH v2 3/4] drm/dp_mst: Check payload count in drm_dp_mst_atomic_check() Lyude Paul
2018-10-29 14:25   ` Daniel Vetter [this message]
2018-10-29 15:34     ` Lyude Paul
2018-10-26 20:35 ` [PATCH v2 4/4] drm/nouveau: Use atomic VCPI helpers for MST Lyude Paul
2018-10-29 14:11   ` Daniel Vetter

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=20181029142537.GC21967@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lyude@redhat.com \
    --cc=nouveau@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).