Received: by 10.223.176.5 with SMTP id f5csp603796wra; Fri, 9 Feb 2018 04:20:31 -0800 (PST) X-Google-Smtp-Source: AH8x224N7nCO4CPefoXbj71sEjhmxUhUZwmbsi/12Ot1OKabziLvgfalnH5wDiX9Kat6WLK8aeEf X-Received: by 10.98.110.202 with SMTP id j193mr2700620pfc.19.1518178831152; Fri, 09 Feb 2018 04:20:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518178831; cv=none; d=google.com; s=arc-20160816; b=gvCs6ilZ4KLKPBDJkiAQ4G7zsV4+qCHi6kGdQu/4NRtW16mT6WRlnPvawWahf3uqCh 4ACmIPKRzTydrxG60xxG2y3BdjjZIwpOW4JlMPnCBnZlscz9GGvnniVmVlMg6Uo/TG/i ynI8s54bammlCPg+mgopC1Xn+osYSo22cc4xAAz3qAjuxCEeN/LapkSFN2i4tGZY8tVj OLr0DTmPhpqwUJshJjISbhIWqhCmBFn1WVWon7yKv1Nw7n/vOKuqmFPcC3ulTN+bSpHp HPX812IdP6EG2W2j2qS6+TD36ohyxMtYzDFXdt5bwvDWpYOurpMT3UNVlJUYNdXm7jWi L5HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:arc-authentication-results; bh=gmJQNdgfYz4c6Vlu0thyXFSZ08xlxPrp78WxHgn8cEE=; b=V0JhPSWEL/8+cFJ3PefNGsNUMa5+SRTN/eEXTFyr3vrmr4SWVIeWh4s04cJ5w7dOYR jeFZXj7gqDQ32B84mlRbpDl5pEGqcEmT8goGo5aNGlWHP6KAKkq589yhFOcIIilBbdwU UN7PZieqAaJSu3wAcaNsHcALWESKY325mqDEvyay/GqbdJqmRSeJ4uIP6ACCO8jwToxT a+5FMHWcNFfingy4vAytFdy2GKjiUuc77p+OVEc4pQveR2FoFWkj2rmNunBoVShs84Kw +0JJ3yqMcOX4lUzzcGl9cu7l4Gk/ckO8EfHEBJKsadARZD6NhIKLyPwMoRMMmBumBAL6 KcUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si13925pfg.267.2018.02.09.04.20.17; Fri, 09 Feb 2018 04:20:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751253AbeBIMTG convert rfc822-to-8bit (ORCPT + 99 others); Fri, 9 Feb 2018 07:19:06 -0500 Received: from mail.fireflyinternet.com ([109.228.58.192]:62288 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751005AbeBIMTE (ORCPT ); Fri, 9 Feb 2018 07:19:04 -0500 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 10630324-1500050 for multiple; Fri, 09 Feb 2018 12:18:59 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Shreeya Patel , daniel@ffwll.ch, airlied@redhat.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, seanpaul@chromium.org From: Chris Wilson In-Reply-To: <1518178256-17157-1-git-send-email-shreeya.patel23498@gmail.com> Cc: "Shreeya Patel" References: <1518178256-17157-1-git-send-email-shreeya.patel23498@gmail.com> Message-ID: <151817873639.28809.8475696517820926336@mail.alporthouse.com> User-Agent: alot/0.3.6 Subject: Re: [PATCH] gpu/drm/udl: Replace struct_mutex with driver private lock Date: Fri, 09 Feb 2018 12:18:56 +0000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Shreeya Patel (2018-02-09 12:10:56) > dev->struct_mutex is the Big DRM Lock and the only bit where > it’s mandatory is serializing GEM buffer object destruction. > Which unfortunately means drivers have to keep track of that > lock and either call unreference or unreference_locked > depending upon context. Core GEM doesn’t have a need for > struct_mutex any more since kernel 4.8. > > For drivers that need struct_mutex it should be replaced by a driver > private lock. In that regard, dev->struct_mutex is already a driver private lock. The impetus is to reduce a big lock into lots of little locks where contention deems prudent. > Signed-off-by: Shreeya Patel > --- > drivers/gpu/drm/udl/udl_dmabuf.c | 5 +++-- > drivers/gpu/drm/udl/udl_drv.h | 1 + > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/udl/udl_dmabuf.c b/drivers/gpu/drm/udl/udl_dmabuf.c > index 2867ed1..120d2d9 100644 > --- a/drivers/gpu/drm/udl/udl_dmabuf.c > +++ b/drivers/gpu/drm/udl/udl_dmabuf.c > @@ -76,6 +76,7 @@ static struct sg_table *udl_map_dma_buf(struct dma_buf_attachment *attach, > struct udl_drm_dmabuf_attachment *udl_attach = attach->priv; > struct udl_gem_object *obj = to_udl_bo(attach->dmabuf->priv); > struct drm_device *dev = obj->base.dev; > + struct udl_device *udl = dev->dev_private; > struct scatterlist *rd, *wr; > struct sg_table *sgt = NULL; > unsigned int i; > @@ -112,7 +113,7 @@ static struct sg_table *udl_map_dma_buf(struct dma_buf_attachment *attach, > return ERR_PTR(-ENOMEM); > } > > - mutex_lock(&dev->struct_mutex); > + mutex_lock(&udl->urbs.plock); > > rd = obj->sg->sgl; > wr = sgt->sgl; > @@ -137,7 +138,7 @@ static struct sg_table *udl_map_dma_buf(struct dma_buf_attachment *attach, > attach->priv = udl_attach; > > err_unlock: > - mutex_unlock(&dev->struct_mutex); > + mutex_unlock(&udl->urbs.plock); > return sgt; > } > > diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h > index 2a75ab8..24cca17 100644 > --- a/drivers/gpu/drm/udl/udl_drv.h > +++ b/drivers/gpu/drm/udl/udl_drv.h > @@ -39,6 +39,7 @@ struct urb_node { > > struct urb_list { > struct list_head list; > + struct mutex plock; > spinlock_t lock; > struct semaphore limit_sem; > int available; This hasn't seen much testing as it lacks a mutex_init, and one would wish for a description of what it is guarding. -Chris