Received: by 10.223.185.116 with SMTP id b49csp3559471wrg; Mon, 19 Feb 2018 02:01:16 -0800 (PST) X-Google-Smtp-Source: AH8x225C3V0AaR2jKGcbS4y+SpOCg0Y48T7pmBETVclnpAaf3GtVf5Y+sZ1p38/uQ1f0SEDuYvlG X-Received: by 10.99.114.77 with SMTP id c13mr1613485pgn.286.1519034476768; Mon, 19 Feb 2018 02:01:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519034476; cv=none; d=google.com; s=arc-20160816; b=xFGwQoDc1rHAuapprss0/U/bAVXuoDju49cPxPhG2XRskz/WpuypI2icbbanyT+B8O g//KFhKdfehFEGXeQS8Dweb/FLy060OVa36JOrln6TX52uTP1nN8+f1P5luTz/D3tFMa vfYrmg+Rt4OTTLOHtZfa6ars+290u4J2rk6iXzfrddJwGkomgYseXTtG75LFTML5gR73 9qt9eVwzUYcHDcvrf8rX4GwmgnnwD8IdCEvvgu3dUSZ+zoAm5rIOsytuXQ3NA3LCkIEG IRMEQX6xFyMO1haXgTIbFRjl0FhsR3yiVbHTCvXccIdvj7qxJ4E7bNvy5WwH0SNILugz FlIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=pNXgJJv4T/HF2O7nYdJ0DzCFbX3Reakzl1YoGrQgZ6Q=; b=T8uWQpdpRtMSgnzjwYs14gCseY11Nqx58vSyrE1PdyWqobkn52pY+9XZXLVVbwGgOc 5KHRfb+iI5lPq1tC5Nnp+D2Yd/y0nWHAIZNJrrKQu9UO73CdsquDXo5hh1BI/H6lrWZC 73bMGf7k4qIAld6XbTT5T2ufPK7e/5AwOsjjQ/afcYegx9ciMcpLGff5J7SpJ5Zb3+H5 /Sa0vMtAG4SPkhW3UWjPfQbDZ/Yk7EqyzLeotqW7izXAL3wREqRkUjVXorEKNNpD7/02 MgqJMt9OUsRpaDBTQ7NbfUbZNkDlJscJstjQQQTDyqltxqQybeJRI5WmcGq4Mdh9CGpy G+Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=Dif+J3OS; 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 o5-v6si3980551plh.135.2018.02.19.02.01.01; Mon, 19 Feb 2018 02:01:16 -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; dkim=fail header.i=@ffwll.ch header.s=google header.b=Dif+J3OS; 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 S1752480AbeBSJ7u (ORCPT + 99 others); Mon, 19 Feb 2018 04:59:50 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35196 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752142AbeBSJ7t (ORCPT ); Mon, 19 Feb 2018 04:59:49 -0500 Received: by mail-wm0-f68.google.com with SMTP id x21so13871253wmh.0 for ; Mon, 19 Feb 2018 01:59:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=pNXgJJv4T/HF2O7nYdJ0DzCFbX3Reakzl1YoGrQgZ6Q=; b=Dif+J3OSzXDpWxlTipvoqu+CoDW4v0vuNsImjOtKXAW8w0qf9U3m3SDQqllDD1MwiH Q61hQRpMULzpqVuV0K/60gxGxOvTlMZzWXuiZQc+79qetSr+4GZt9aV7clGJI5LnQo8G jjq8y/C/GfWX/nY+U8wdiZ/W5ak20R9O7mpps= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=pNXgJJv4T/HF2O7nYdJ0DzCFbX3Reakzl1YoGrQgZ6Q=; b=OeVeJvp6K/7c/d/rYMiaPVsl05hW/7Q+5MYgualkQ7PSTSOH0NCXBEq/K13vIwLiTh 7xC7HobhRftdc0I1pPAixd516fbEOUgfj49Yh8Idbq1JT2weJWlNw6+1bAYBafH5DL+/ lz/CR0/EwZGQeTm/zh32HJOSgfZm8N0k5J8Ru/pvciFo7ZFE/xE+HPmEsevtdJEETkox zfD4H+wRv3rrOZTP6Q66ofdOMsA1T12Bw9Yv5BYcRKo5v9fWFE72BibrPiO+ozbm9JMa u3085jg2CaO/CwxbmZApAsILAg43X+4bB15lEGf6LuGRJ9v60vLOfF69fJbYYGoPzEdj UfHQ== X-Gm-Message-State: APf1xPAWHz0hC9lD3uEjV0fdkB2VMOqr0EpqHFlLqdOUuUKYk40A0RKk gQ23TrKHoOfA/wvM9sWQp9bV4Q== X-Received: by 10.80.183.4 with SMTP id g4mr269017ede.191.1519034387713; Mon, 19 Feb 2018 01:59:47 -0800 (PST) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id m37sm16510819edc.50.2018.02.19.01.59.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Feb 2018 01:59:46 -0800 (PST) Date: Mon, 19 Feb 2018 10:59:45 +0100 From: Daniel Vetter To: Shreeya Patel Cc: Chris Wilson , daniel@ffwll.ch, airlied@redhat.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, seanpaul@chromium.org Subject: Re: [PATCH] gpu/drm/udl: Replace struct_mutex with driver private lock Message-ID: <20180219095945.GQ22199@phenom.ffwll.local> Mail-Followup-To: Shreeya Patel , Chris Wilson , airlied@redhat.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, seanpaul@chromium.org References: <1518178256-17157-1-git-send-email-shreeya.patel23498@gmail.com> <151817873639.28809.8475696517820926336@mail.alporthouse.com> <1518268651.3820.4.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1518268651.3820.4.camel@gmail.com> X-Operating-System: Linux phenom 4.14.0-3-amd64 User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 10, 2018 at 06:47:31PM +0530, Shreeya Patel wrote: > On Fri, 2018-02-09 at 12:18 +0000, Chris Wilson wrote: > > 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. > > Ok. I'll make the changes in the commit message. udl_driver_load would be a good place. Also, running with CONFIG_PROVE_LOCKING enabled will catch this stuff. On that note, do you have the hardware to test your changes? If not we need to find someone who can do that. Also please switch udl from the gem_free_object to the gem_free_object_unlocked hook. -Daniel > > > > > > > > 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. > > Yes, I'll add mutex_init but I am not sure that in which function I > should add it as there is no probe or init function. > > Also I will add the description for the lock. > > Thanks  > > -Chris -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch