Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30852222rwd; Thu, 6 Jul 2023 11:37:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlFRoGozaMWPP/YtFIrodkh15c/65whKmyH6+Inydv6DIAtFKFZzv6+UvGepeqVi//vru14t X-Received: by 2002:a17:902:d486:b0:1b1:9802:a31b with SMTP id c6-20020a170902d48600b001b19802a31bmr2307054plg.41.1688668670763; Thu, 06 Jul 2023 11:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688668670; cv=none; d=google.com; s=arc-20160816; b=Ad3rZJ68oEi7Ci7gYJAsSr/LLuLdRCpP1/eeMzc957ypc7k8105s50BQrV96eMhW5D YXU6sqZ2j5KcWLVmbUjGfIxe1xu+Ue8ePhBvR4UtUPOj9tAyy2Rt8ybJELz98p7p/eAf H9qgDk6Yp2Qp4xXtYWE0efXJkNfdyJg1c4O1NLDN33KuP69JL6RG79Oeo+kgN5hSqE5D pg7MLDZHhxc2MhhpiZni/gDSP/sig923Q4FtJr9qeyJ5Yu3j+kYIV5RBcjMV+0apuCpl dqxyrnafeGqV32TNYvILFWDtP/5YzP8P11Cm7iCwKbzBBX8Li+fuJ1M5/1lWHEaCxOAd UftQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=xb83I2iObfDsc5m5c/5MMKeafKSqRDUxm4J5f66yKOs=; fh=MIMyUQeyTqrK1Wumm6tvaDSh1b2m+WvcHM+tNZ7jOoo=; b=xNqysT4OCMJ8pB3uT53kBbQpZle5beRqhPHvvDqdUkPkIbNr2CqV5n21jatbOWIIhM 8RCUOcbMWdFW+SjzH2M2HBm7iBVGIL6P1sh2TbODqJiPLLDHkAsZDU0rZNzIYSyjoBaI LmX3dJUlNPjfT/pf2Ow5huK+sPbFGb5DNhK14gIzkMEj3+NvYD6wq3Y9awDLb8cVS4bn F06NI2dmT+sdPRZa+2DSAhg+ahC5Re1Pmi/4UdCzUmLWchh3nec5TZtF7knRHXBI6H3T PxDiRWQlm0Av+u35alz7fQ/tQXXBh2KhrsodVsfGrigwxxjX2u4VU+DvpZsbfVimjgYz Wgqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="d4T/gG0M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020a170902ea0a00b001b69de1eae1si1824254plg.620.2023.07.06.11.37.33; Thu, 06 Jul 2023 11:37:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="d4T/gG0M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230040AbjGFS0u (ORCPT + 99 others); Thu, 6 Jul 2023 14:26:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbjGFS0t (ORCPT ); Thu, 6 Jul 2023 14:26:49 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ED181BF8; Thu, 6 Jul 2023 11:26:48 -0700 (PDT) Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by madras.collabora.co.uk (Postfix) with ESMTPSA id B59DC6606FD3; Thu, 6 Jul 2023 19:26:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688668006; bh=UHG+XPRdoANiLLft5ASgcfyQgCpm/H7FwKZnn28txqY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=d4T/gG0MYfdGPgNKM5K8IQDQx74OzhJhWKaDZXejR3+LT2VTyuuEfy6smeIDxdaGO m6FrOeH+uPsXXkSlT6cpMeU12M14If4nOeKrDIGUFYMJCSYeqxnv0p2onOinYuKaFR 10MHXerXhhUgQrjx30ZdecazE8N+Tqn7gbkUsEELf0xA8dkcLDWSlxTvpyZtLV1cwA UsqMGydu60eM4yq6ellXgU7rejxMkfDGf5TsTxExhOaQmWfMAKGNoPQEohPfWEUQG+ IUvRT7R8YP5FQMRqU06ckEUsfjStXc/l2GumaBiVJqMT1y84wMQwghZn2TuXVkoQ0F 50OGO31r/i18Q== Date: Thu, 6 Jul 2023 20:26:42 +0200 From: Boris Brezillon To: Danilo Krummrich Cc: airlied@gmail.com, daniel@ffwll.ch, tzimmermann@suse.de, mripard@kernel.org, corbet@lwn.net, christian.koenig@amd.com, bskeggs@redhat.com, Liam.Howlett@oracle.com, matthew.brost@intel.com, alexdeucher@gmail.com, ogabbay@kernel.org, bagasdotme@gmail.com, willy@infradead.org, jason@jlekstrand.net, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Donald Robson , Dave Airlie Subject: Re: [PATCH drm-next v6 02/13] drm: manager to keep track of GPUs VA mappings Message-ID: <20230706202642.4cbc7227@collabora.com> In-Reply-To: <20230629222651.3196-3-dakr@redhat.com> References: <20230629222651.3196-1-dakr@redhat.com> <20230629222651.3196-3-dakr@redhat.com> Organization: Collabora X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Jun 2023 00:25:18 +0200 Danilo Krummrich wrote: > +#ifdef CONFIG_LOCKDEP > +typedef struct lockdep_map *lockdep_map_p; > +#define drm_gpuva_manager_ext_assert_held(mgr) \ > + lockdep_assert(lock_is_held((mgr)->ext_lock) != LOCK_STATE_NOT_HELD) > +/** > + * drm_gpuva_manager_set_ext_lock - set the external lock according to > + * @DRM_GPUVA_MANAGER_LOCK_EXTERN > + * @mgr: the &drm_gpuva_manager to set the lock for > + * @lock: the lock to set > + * > + * If @DRM_GPUVA_MANAGER_LOCK_EXTERN is set, drivers need to call this function > + * to provide the lock used to lock linking and unlinking of &drm_gpuvas to the > + * &drm_gem_objects GPUVA list. > + */ > +#define drm_gpuva_manager_set_ext_lock(mgr, lock) \ > + (mgr)->ext_lock = &(lock)->dep_map Okay, so, IIUC, this is the lock protecting the GEM's active mappings list, meaning the lock is likely to be attached to the GEM object. Are we expected to call drm_gpuva_manager_set_ext_lock() every time we call drm_gpuva_[un]link(), or are we supposed to have some lock at the device level serializing all drm_gpuva_[un]link() calls across VMs? The later doesn't sound like a good option to me, and the former feels a bit weird. I'm wondering if we shouldn't just drop this assert_held() check when DRM_GPUVA_MANAGER_LOCK_EXTERN is set. Alternatively, we could say that any driver wanting to use a custom lock (which is basically all drivers modifying the VA space asynchronously in the ::run_job() path) has to provide its own variant of drm_gpuva_[un]link() (maybe with its own VA list too), which doesn't sound like a good idea either. > +#else > +typedef struct { /* nothing */ } lockdep_map_p; > +#define drm_gpuva_manager_ext_assert_held(mgr) do { (void)(mgr); } while (0) > +#define drm_gpuva_manager_set_ext_lock(mgr, lock) do { } while (0) > +#endif