Received: by 10.223.185.116 with SMTP id b49csp194495wrg; Sat, 10 Feb 2018 05:19:05 -0800 (PST) X-Google-Smtp-Source: AH8x227Xr+5FrMuOzt24ifaoMBdJOkH69L26OTo5MPsy2yv5JyuJk44oLN4GzncqYBIKagnMgZMk X-Received: by 2002:a17:902:f:: with SMTP id 15-v6mr5553016pla.419.1518268745581; Sat, 10 Feb 2018 05:19:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518268745; cv=none; d=google.com; s=arc-20160816; b=P9CwpmqLNuLmL5N+qCfow0ALe3m5CX7MNH7KHZVxmXmal+RDM5Yjx1GqhAxyUqpH/J gLewqMjgI7wmsCvP6NTpLb1qbxW3rZ7+DWtpzXy4ix1YY/C04t/L03LLiIpiS7rsn7CI oYCQbqoCevOWm5g4EdM5LQ2G41Fhi8dG2L7sD7/KYTDOX8dZxKOlycr4UtBmJ+UJI2EE HVOeyTdZVc0HAy+sZQmea3ydZwhZrb6y8WRGDy9BO9TGufMUHG5Ko+lJ1UVTZiTqv7Mx XQhXT8Qd2gSMt26S3Ztt2x9l0sg95O19zlfeHBteLLrkIWHjCPYhal1nulM3anWG4sgy 7u+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=5ICMfJGcXlqkXd5yujMF2TQU0svcLHKRRTe0xlJwYv0=; b=fc4pSS9EH4l65G0hpgunN0KrHFva8b3hsDrW0QRHytGpKRE1in4ArDjt+KS3ZxdXJZ Ihglh2euxJLGBfBgaNupFfSQWD78XbbG5d7wGzpUBVXRqKy1cEbd9gaIGSBvw49vHXEb SAreW2fdPCU8g5xBt9sF1W2L4kbbCJYENDMLNSTULzvTZb/91YX2yAUQZo61EX6tPfRs 3pzsCoBMtNiGl09MJjB5MmedrgE4g1uL2MBinad+bRYi7dTwJQZW5heqL1MyaN2vBScE NrGC+17TVBeJA7U6qdY0rlyLpnMDLbjTQ1/ZhWbpbtthwiylkPUZqI51fC+ZTQK09Y13 +4dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gkHRcNw2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q82si3309540pfd.240.2018.02.10.05.18.40; Sat, 10 Feb 2018 05:19:05 -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=pass header.i=@gmail.com header.s=20161025 header.b=gkHRcNw2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751314AbeBJNRk (ORCPT + 99 others); Sat, 10 Feb 2018 08:17:40 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:45068 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942AbeBJNRj (ORCPT ); Sat, 10 Feb 2018 08:17:39 -0500 Received: by mail-io0-f193.google.com with SMTP id p188so12709619ioe.12 for ; Sat, 10 Feb 2018 05:17:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:date:in-reply-to:references:mime-version :content-transfer-encoding; bh=5ICMfJGcXlqkXd5yujMF2TQU0svcLHKRRTe0xlJwYv0=; b=gkHRcNw26kSQIR/IlOpnyingFfsM9l2LQtLswFQtI7NF6TusqVZQ/o8XYhz0gmeud3 fL1m5V2k+Y1/i9KTVoa1VvfgnRYhjXCr2/OkyayQXfFgCEO8UoIeeCZg5eZVZIVA+Su6 0Jcfi8imQNGol0jc73/vnegtXngFryaI/bbaywJzfUR2AqUFMnC+CLmCv7yCQ8AYFnz6 Oxq6tRWv6DpUScoF2G1KjANkY6c2mu/0ewzyxxC0r6gtXsQf2AkIQiE7dssdamaFMBRu ZnUvCUM5iUgOZeK54do9s2B1PdZwM4444yDF5f37PLFmOj5aEe9FnIzbapmk/CrocfFZ QTXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=5ICMfJGcXlqkXd5yujMF2TQU0svcLHKRRTe0xlJwYv0=; b=lBHJYNKaRSaE0xPJW0jLmq2j/64eyKjT573YE9wSkPhxl+oYAiCS1/b/gUmMYVNzUf bUjt9QsybT120I3yJ9dHms6uWhpC8OtyntPpNEp5Qfs+5iKFo0/jYguKXlMVRLXOQ2zF 01q5SsJV+5llRWeCWatf7XGOh1w2joCHTxYckBubzA8FjiB4dOjz/24ee5tE65TMVkYY I+e6Cdc9fvWCJK35Zw6NsvH5IO6aEjxjNFian2yzbBRujy9mbF5oZ1b9V5ozXf5GZ2aN nN8adCZtVzV1Hite59rJnEW1o5OVcJAgZPtcPZFAgRgOL3WT47pWXzBZmEiB+1Ow+dJX hO6w== X-Gm-Message-State: APf1xPCw9TqIZl5o+nfAgKYdGFaC/T3NEFHaypRZ1MUVXPHvCTmW5tDg /FeGDD01tsHBVR4JXsBcgQI= X-Received: by 10.107.1.3 with SMTP id 3mr7132655iob.221.1518268658164; Sat, 10 Feb 2018 05:17:38 -0800 (PST) Received: from [10.0.2.15] ([103.212.140.156]) by smtp.googlemail.com with ESMTPSA id 137sm2286715itl.32.2018.02.10.05.17.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Feb 2018 05:17:37 -0800 (PST) Message-ID: <1518268651.3820.4.camel@gmail.com> Subject: Re: [PATCH] gpu/drm/udl: Replace struct_mutex with driver private lock From: Shreeya Patel To: Chris Wilson , daniel@ffwll.ch, airlied@redhat.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, seanpaul@chromium.org Date: Sat, 10 Feb 2018 18:47:31 +0530 In-Reply-To: <151817873639.28809.8475696517820926336@mail.alporthouse.com> References: <1518178256-17157-1-git-send-email-shreeya.patel23498@gmail.com> <151817873639.28809.8475696517820926336@mail.alporthouse.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > > > > 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