On Fri, 2016-11-18 at 06:57 +0000, Chris Wilson wrote:
> On Thu, Nov 17, 2016 at 06:03:48PM -0800, Dhinakaran Pandiyan wrote:
> > static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr,
> > struct drm_dp_vcpi *vcpi, int pbn)
> > {
> > - int num_slots;
> > + int req_slots;
> > int ret;
> >
> > - num_slots = DIV_ROUND_UP(pbn, mgr->pbn_div);
> > + req_slots = DIV_ROUND_UP(pbn, mgr->pbn_div);
> >
> > - if (num_slots > mgr->avail_slots)
> > - return -ENOSPC;
> > + mutex_lock(&mgr->lock);
> > + if (req_slots > mgr->avail_slots) {
> > + ret = -ENOSPC;
> > + goto out;
> > + }
>
> You are not atomically reducing the mgr->avail_slots, leading to
> possible overallocation of multiple streams?
> -Chris
>
Yeah, I got it wrong. I should have reduced mgr->avail_slots here before
releasing the mutex. Thanks for pointing it out.