public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel-/w4YWyX8dFk@public.gmane.org>
To: Lyude Paul <lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 5/6] drm/dp_mst: Check payload count in ->atomic_check()
Date: Wed, 24 Oct 2018 10:54:43 +0200	[thread overview]
Message-ID: <20181024085443.GI324@phenom.ffwll.local> (raw)
In-Reply-To: <20181023231251.16883-6-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Tue, Oct 23, 2018 at 07:12:50PM -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>
> ---
>  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 adb4298570cc..cafb769a4ec3 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -3225,7 +3225,7 @@ static int drm_dp_mst_atomic_check(struct drm_private_obj *obj,
>  		to_dp_mst_topology_state(state);
>  	struct drm_dp_mst_topology_mgr *mgr = mst_state->mgr;
>  	struct drm_dp_vcpi_allocation *pos;
> -	int avail_slots = 63;
> +	int avail_slots = 63, payload_count = 0;
>  
>  	list_for_each_entry(pos, &mst_state->vcpis, next) {
>  		DRM_DEBUG_ATOMIC("[MST PORT:%p] requires %d vcpi slots\n",
> @@ -3238,6 +3238,12 @@ static int drm_dp_mst_atomic_check(struct drm_private_obj *obj,
>  					 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_dp_init_vcpi() shouldn't ever fail on atomic drivers, so maybe worth
adding a check to that effect? Probably only after amdgpu is converted
over too.

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

>  	}
>  	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
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

  parent reply	other threads:[~2018-10-24  8:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-23 23:12 [PATCH 0/6] drm/dp_mst: Improve VCPI helpers, use in nouveau Lyude Paul
2018-10-23 23:12 ` [PATCH 1/6] drm/dp_mst: Deprecate drm_dp_find_vcpi_slots() Lyude Paul
2018-10-24  8:27   ` Daniel Vetter
     [not found] ` <20181023231251.16883-1-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-10-23 23:12   ` [PATCH 2/6] drm/dp_mst: Remove all evil duplicate state pointers Lyude Paul
2018-10-24  8:27     ` Daniel Vetter
2018-10-23 23:12   ` [PATCH 3/6] drm/atomic: Add ->atomic_check() hook for private objects Lyude Paul
2018-10-24  8:45     ` Daniel Vetter
2018-10-23 23:12   ` [PATCH 5/6] drm/dp_mst: Check payload count in ->atomic_check() Lyude Paul
     [not found]     ` <20181023231251.16883-6-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-10-24  8:54       ` Daniel Vetter [this message]
2018-10-23 23:12   ` [PATCH 6/6] drm/nouveau: Use atomic VCPI helpers for MST Lyude Paul
2018-10-24  8:50   ` [PATCH 0/6] drm/dp_mst: Improve VCPI helpers, use in nouveau Daniel Vetter
2018-10-23 23:12 ` [PATCH 4/6] drm/dp_mst: Start tracking per-port VCPI allocations Lyude Paul
     [not found]   ` <20181023231251.16883-5-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-10-24  8:55     ` Daniel Vetter
2018-10-23 23:46 ` ✓ Fi.CI.BAT: success for drm/dp_mst: Improve VCPI helpers, use in nouveau Patchwork
2018-10-24  3:57 ` ✓ Fi.CI.IGT: " 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=20181024085443.GI324@phenom.ffwll.local \
    --to=daniel-/w4ywyx8dfk@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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