Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3762279rdh; Tue, 28 Nov 2023 03:16:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8Iza38JqHR958iF9NY7Tkgf1THTFIQ6aD2yUexRxhnvgqRtObWOSW+uET0LWk0t2bXTEH X-Received: by 2002:a05:6a20:d396:b0:163:5bfd:ae5b with SMTP id iq22-20020a056a20d39600b001635bfdae5bmr16521573pzb.15.1701170184968; Tue, 28 Nov 2023 03:16:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701170184; cv=none; d=google.com; s=arc-20160816; b=Tiavy95JaHR5oRc1TaZg+w6jNYfdEzKo8o+TdDiCdboJJNBC7YYhTDzVP+blIGp0PE v4IsfPSiuRH64naAzg2z4OrJ136fwqZrVrkm/ZmnxuG5kKiuNsypmZ4UuI+4Cb/l6lwf WJpT/hhHPAGpUGcY4dp6RNdvLyxaXKcnYj7UYVd53HCmMrerDP/37+VcKMTw3XcpcrUa L0A0cdEHno0BjeedGn7EpLtF+UkL7HKX9sGUpPE2OoCxH2k2m9OpzABD4619hcaFRPm0 LklOorGMKHzx2PgBO8UWmGjEAdknuRGRxIZftPh8eEFu2qQMMSl4rsckWls3425qsuKT 44aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=k+EEeneDzdPhLpawqtX2cJDo9ADlmIyCI4wxKeQkcUA=; fh=JMATQZ6ibRl3eyuQLADwzYkhYBKdu/2gHu7BVYHakXs=; b=uZjqv0KhI7N9RNWD3qVpSbzcTjMytRKErS0knTMvn+yK2P2RpA5HGZUoqE2Z0zh531 jjaPfwW8smX711a9ixXVO/8rcTHwjWP1rCNtKXHco/oF3TEqzCEhisJpJxmayUul0En/ kb0ReHJPHMwsjz5r0lQ7u8S7swJ4IKDFWKURxDSr0ES4bFXSyl9JumPsR1PUPNwhhxV/ rAzZbnO66UiwDA56uYWhA9DMrjXbhNZCEeTavz9GC5T5nlmZ39Oy3YaitUsMIxhJftPC tUwg6jP+mG7serOSqXdBRCpJcydrCYwbiyOHxyYe9Im7t5iZD6RECAr+mbc+u11Rh9B8 wGxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RMsIKIwU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id d12-20020a056a00198c00b006c386ea46dbsi11988210pfl.35.2023.11.28.03.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 03:16:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RMsIKIwU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 390C78079CB8; Tue, 28 Nov 2023 03:15:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344195AbjK1LOk (ORCPT + 99 others); Tue, 28 Nov 2023 06:14:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234702AbjK1LOi (ORCPT ); Tue, 28 Nov 2023 06:14:38 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 387D7D6 for ; Tue, 28 Nov 2023 03:14:45 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70CABC433C7; Tue, 28 Nov 2023 11:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701170084; bh=ghXHN0aqKTTETA6By+7Mc0o8Xy5WxEMUZIlYt+T2S2k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RMsIKIwU5rCX0ZEd0AknFuQtsCuGZOd+UAdrNrElQLX+FzsvWwmnGzu/13zFTjv8S 1sEGdUq+2Bh4u+xNBIkrOOA8OSDB/8dEVr+Q56+9wc6pXUozr4s9v+fIFf75ETOlF8 XzZ2CFbTXGZyPhcJTLNeLIW2fjYac22oBY/+Br5aBCc6IHjl+TkO83cOKk+1da8jxN kcv0PqsiaEZGa6Py7G5TSKYyFsk91CQK+QFXFSva2vpwwhI8R7/GtaB6DiMrQG0oCq vpfDbnOoEWH7qtaUuEpPX6SypVnAweYMwsC1Zn+ukA5U3TbtvvX/W9MFchbO8JwdGt XHotEI5pg4ayg== Date: Tue, 28 Nov 2023 12:14:42 +0100 From: Maxime Ripard To: Boris Brezillon Cc: Dmitry Osipenko , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Christian =?utf-8?B?S8O2bmln?= , Qiang Yu , Steven Price , Emma Anholt , Melissa Wen , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v18 04/26] drm/shmem-helper: Refactor locked/unlocked functions Message-ID: References: <20231029230205.93277-1-dmitry.osipenko@collabora.com> <20231029230205.93277-5-dmitry.osipenko@collabora.com> <20231124115911.79ab24af@collabora.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4o4oj77z6epqtcan" Content-Disposition: inline In-Reply-To: <20231124115911.79ab24af@collabora.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 28 Nov 2023 03:15:16 -0800 (PST) --4o4oj77z6epqtcan Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Fri, Nov 24, 2023 at 11:59:11AM +0100, Boris Brezillon wrote: > On Fri, 24 Nov 2023 11:40:06 +0100 > Maxime Ripard wrote: >=20 > > On Mon, Oct 30, 2023 at 02:01:43AM +0300, Dmitry Osipenko wrote: > > > Add locked and remove unlocked postfixes from drm-shmem function name= s, > > > making names consistent with the drm/gem core code. > > >=20 > > > Reviewed-by: Boris Brezillon > > > Suggested-by: Boris Brezillon > > > Signed-off-by: Dmitry Osipenko =20 > >=20 > > This contradicts my earlier ack on a patch but... > >=20 > > > --- > > > drivers/gpu/drm/drm_gem_shmem_helper.c | 64 +++++++++--------= -- > > > drivers/gpu/drm/lima/lima_gem.c | 8 +-- > > > drivers/gpu/drm/panfrost/panfrost_drv.c | 2 +- > > > drivers/gpu/drm/panfrost/panfrost_gem.c | 6 +- > > > .../gpu/drm/panfrost/panfrost_gem_shrinker.c | 2 +- > > > drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +- > > > drivers/gpu/drm/v3d/v3d_bo.c | 4 +- > > > drivers/gpu/drm/virtio/virtgpu_object.c | 4 +- > > > include/drm/drm_gem_shmem_helper.h | 36 +++++------ > > > 9 files changed, 64 insertions(+), 64 deletions(-) > > >=20 > > > diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm= /drm_gem_shmem_helper.c > > > index 0d61f2b3e213..154585ddae08 100644 > > > --- a/drivers/gpu/drm/drm_gem_shmem_helper.c > > > +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c > > > @@ -43,8 +43,8 @@ static const struct drm_gem_object_funcs drm_gem_sh= mem_funcs =3D { > > > .pin =3D drm_gem_shmem_object_pin, > > > .unpin =3D drm_gem_shmem_object_unpin, > > > .get_sg_table =3D drm_gem_shmem_object_get_sg_table, > > > - .vmap =3D drm_gem_shmem_object_vmap, > > > - .vunmap =3D drm_gem_shmem_object_vunmap, > > > + .vmap =3D drm_gem_shmem_object_vmap_locked, > > > + .vunmap =3D drm_gem_shmem_object_vunmap_locked, =20 > >=20 > > While I think we should indeed be consistent with the names, I would > > also expect helpers to get the locking right by default. >=20 > Wait, actually I think this patch does what you suggest already. The > _locked() prefix tells the caller: "you should take care of the locking, > I expect the lock to be held when this is hook/function is called". So > helpers without the _locked() prefix take care of the locking (which I > guess matches your 'helpers get the locking right' expectation), and > those with the _locked() prefix don't. What I meant by "getting the locking right" is indeed a bit ambiguous, sorry. What I'm trying to say I guess is that, in this particular case, I don't think you can expect the vmap implementation to be called with or without the locks held. The doc for that function will say that it's either one or the other, but not both. So helpers should follow what is needed to provide a default vmap/vunmap implementation, including what locking is expected from a vmap/vunmap implementation. If that means that vmap is always called with the locks taken, then drm_gem_shmem_object_vmap can just assume that it will be called with the locks taken and there's no need to mention it in the name (and you can probably sprinkle a couple of lockdep assertion to make sure the locking is indeed consistent). > > I'm not sure how reasonable it is, but I think I'd prefer to turn this > > around and keep the drm_gem_shmem_object_vmap/unmap helpers name, and > > convert whatever function needs to be converted to the unlock suffix so > > we get a consistent naming. >=20 > That would be an _unlocked() prefix if we do it the other way around. I > think the main confusion comes from the names of the hooks in > drm_gem_shmem_funcs. Some of them, like drm_gem_shmem_funcs::v[un]map() > are called with the GEM resv lock held, and locking is handled by the > core, others, like drm_gem_shmem_funcs::[un]pin() are called > without the GEM resv lock held, and locking is deferred to the > implementation. As I said, I don't mind prefixing hooks/helpers with > _unlocked() for those that take care of the locking, and no prefix for > those that expects locks to be held, as long as it's consistent, but I > just wanted to make sure we're on the same page :-). What about _nolock then? It's the same number of characters than _locked, plus it expresses what the function is (not) doing, not what context it's supposed to be called in? Maxime --4o4oj77z6epqtcan Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZWXLogAKCRDj7w1vZxhR xdPLAP0bk4jcd19Kcw1HVEeKM+/ZsKBusXZ3qgtT2fHoMh5QUQEAsOV0Jvb2c6uk 6hLo3uAZKWG2e93N+kwfw1XjMKiwpQA= =DFKK -----END PGP SIGNATURE----- --4o4oj77z6epqtcan--