From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2778EB64D7 for ; Fri, 30 Jun 2023 09:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232859AbjF3JlA (ORCPT ); Fri, 30 Jun 2023 05:41:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232791AbjF3Jkw (ORCPT ); Fri, 30 Jun 2023 05:40:52 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 601502122; Fri, 30 Jun 2023 02:40:50 -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 319B76606FDE; Fri, 30 Jun 2023 10:40:48 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688118048; bh=4mCSpl5TSwRT4QEzUD6onxpjF3nWlrpqcwjcv/v8rH4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZdKVvs79F3YjxE7/n3BeI4Q4lUGR3mv0/B1Lv5RcZpK6+KHeh44X9pp4kgFNvHFkP wH8tS94eQ1gR2CO5/oBwTRsLZK7TcYgg5dy+yFbaku81oVaTH/DFpWyINrP2ChJnEC zGV02D6dLnBlGnbG1X9PEjXGyjH1cLD6KjhzFrZyYlNc+4n62qA8Ntn0NE8TVpZGgq uz629+ehC3eVEeomJCDvuPrBcHUBjs7xqEv7fW22vXQZoW3DdouEya2PUYc/bvgz3h Hy2iLVofyC05g1lQcouz1NvOcs5uIN9BeqA2roVNQBhm3b2bphG8UpS2zJC20Ia48k F4GMg7rhMWOVQ== Date: Fri, 30 Jun 2023 11:40:45 +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: <20230630114045.20743fab@collabora.com> In-Reply-To: <20230630100252.7ff6421d@collabora.com> References: <20230629222651.3196-1-dakr@redhat.com> <20230629222651.3196-3-dakr@redhat.com> <20230630100252.7ff6421d@collabora.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Jun 2023 10:02:52 +0200 Boris Brezillon wrote: > In practice, I don't expect things to deadlock, because the VM resv is > not supposed to be taken outside the VM context and the locking order > is always the same (VM lock first, and then each shared BO > taken/released independently), but I'm not super thrilled by this > nested lock, and I'm wondering if we shouldn't have a pass collecting > locks in a drm_exec context first, and then have > the operations executed. IOW, something like that: > > drm_exec_init(exec, DRM_EXEC_IGNORE_DUPLICATES) > drm_exec_until_all_locked(exec) { > // Dummy GEM is the dummy GEM object I use to make the VM > // participate in the locking without having to teach > // drm_exec how to deal with raw dma_resv objects. > ret = drm_exec_lock_obj(exec, vm->dummy_gem); > drm_exec_retry_on_contention(exec); > if (ret) > return ret; > > // Could take the form of drm_gpuva_sm_[un]map_acquire_locks() > // helpers Nevermind, I implemented a driver specific acquire_op_locks(), and it's fairly simple with the gpuva iter (we just have to iterate over all VAs covered by the operation range and call drm_exec_lock_obj() on the GEM attached to these VAs), so it's probably not worth providing a generic helper for that.