Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1531533rdh; Fri, 24 Nov 2023 15:40:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0TyDwg3sqKPawHnlztbVpxmTQKZ2XCm1DXB+TUCdmUgMTc9Rzm2DIvuAgNZKn5Wlp/WpK X-Received: by 2002:a05:6808:1645:b0:3b2:df82:812e with SMTP id az5-20020a056808164500b003b2df82812emr4195786oib.32.1700869243007; Fri, 24 Nov 2023 15:40:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700869242; cv=none; d=google.com; s=arc-20160816; b=GKI0jG1C9vAAZoZGulgnnm7B21gn7Q7j0RtMReBE36Go1xG7FpU2AQgU9IWSlAOl2r YeZdm1LocKR3iP5fQB9E3yEMT3aiMhDwg2YZ0n3M9vktEhLHoPOfW6SCiNqgI9uAHJkP aREWSUp0MaxAYv68pwFR/qJyKkYEuHgjYKxKBSdpM2ufVJUo7axPzSUH6aUC0i7/nDkZ wPfYLkRj8RIKAZQLAGrmvuzd3jcUPPRBklIIbkczqyjodxRGTB7L2xgZrrXOSYhnWrIV ZRx8Q9xDS9Kt7010D5QHTdDg5DkesmB07S4dfz7DTpUJNqM7UzuPcSDYToIF2VxXYCAS i2Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=fsNn83uVzegyrMAxmthRza05bc6xMx7My6riRjbiWxM=; fh=UsN1yDpsoILGQe+sD/9VrFANXcyqCDYTaXKaGvSYQ9E=; b=eNhuyamV6gnNIEzimJM6x1FwNsp83ZZ1NqzWGSll5MD+zt4uxeYA0RXtJWnlbbdyt9 lDZZT50STbc5HLIa3hAlwAGcEw+KMytF+lnqz62u23iztrrW0uiX05xJ8SrhotC24ImP 9uywIYSHJ3s1Oq0IRgEnvCGf8PqLTgY00Wz+VN2I6JnkGDBYtFq8mJwidOnk+RGnH9jN L/w6q9DhUxJ4D9kRT4cBHeY+NR1ETBWgHYa/yRUHp/CM3mG7w9fd6vcaczl+5Mt8vn8Q /ljp5cQJ33m6dD5llOLFiApkmSXxAxwyHjNS3rV9ytJmYPt1eMgdpdZEtcl57EYVtnGT zSUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bhMMOa88; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h5-20020a654045000000b005b8f1c4aa49si4596691pgp.895.2023.11.24.15.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 15:40:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bhMMOa88; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1ED1380C7AC5; Fri, 24 Nov 2023 15:40:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345616AbjKXXkV (ORCPT + 99 others); Fri, 24 Nov 2023 18:40:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231649AbjKXXkU (ORCPT ); Fri, 24 Nov 2023 18:40:20 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D42E71988 for ; Fri, 24 Nov 2023 15:40:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700869224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fsNn83uVzegyrMAxmthRza05bc6xMx7My6riRjbiWxM=; b=bhMMOa88q1XA4OTew6UlqbWK+raLc1IS3hoXERXJp0owovNvdEdfXLm/orhCBftLRWanq+ x/EbZa0iQcD6g4Q+7vW6HQ2UGRggwLL4HavcME+f6S503CQUMRtMUOnHSLhV+i0Cr6hVqr hnvNbkqvbgnqXhXAKz1FYvtd9s0ZsyM= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-HxeVTkc7MYe6-QPdleQNBA-1; Fri, 24 Nov 2023 18:40:22 -0500 X-MC-Unique: HxeVTkc7MYe6-QPdleQNBA-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-507cee14477so2390344e87.3 for ; Fri, 24 Nov 2023 15:40:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700869220; x=1701474020; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fsNn83uVzegyrMAxmthRza05bc6xMx7My6riRjbiWxM=; b=HkuEjfJrDV6nvxXRlU4UGgVeJ6BJ/gzx2nAsoF+3IhIF6hePKLZjEU5T6BGSkA7lw4 ZRb74IpA/3zV3IWdiPQNEh7YGDYSWy92KyjelqexJEC7Ud9kQqXmUdAaMvvURmicBudB +TdZajLw6Qw5C+OZ7+RjOs2BYMyMBtoCvl0fIWCLd+/ivCA9MKpkNXhtV/XUbXHmI7Qd 5vK2oi5Tqts8bbgeGQGVQasphao9RI/KNA+KlPgX+4yZOjvb8cmLkSoug42zZZJJHfsP 5f9nHLFb4yprFZm6n+D/zWT5oma9SPTwAsVPPPmwat2Z/aSEHLAN5VQRWjF1DKBhLssX zvKg== X-Gm-Message-State: AOJu0YzHXwkuPuGpI+kUbUSdO+5If7U3LxXr6NNVwWGX2ucV+wKLfMx6 Gc3JarK4p1CuvG/X74MnsqvZDiuSoxv7fHJW029f5zTqszCX/GdHjISV+PubhR5aqwJAkcLL7E4 u8eZCMKVF3bnsWf2yU/xqAXuHFJj2nXgE X-Received: by 2002:ac2:5e66:0:b0:509:115c:51de with SMTP id a6-20020ac25e66000000b00509115c51demr2442994lfr.25.1700869220281; Fri, 24 Nov 2023 15:40:20 -0800 (PST) X-Received: by 2002:ac2:5e66:0:b0:509:115c:51de with SMTP id a6-20020ac25e66000000b00509115c51demr2442983lfr.25.1700869219959; Fri, 24 Nov 2023 15:40:19 -0800 (PST) Received: from ?IPV6:2a02:810d:4b3f:de9c:abf:b8ff:feee:998b? ([2a02:810d:4b3f:de9c:abf:b8ff:feee:998b]) by smtp.gmail.com with ESMTPSA id j10-20020a170906050a00b009fc54390966sm2673473eja.145.2023.11.24.15.40.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Nov 2023 15:40:19 -0800 (PST) Message-ID: <3c7b7683-da36-4ffe-a250-91eef019499f@redhat.com> Date: Sat, 25 Nov 2023 00:40:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH drm-misc-next 4/5] drm/gpuvm: fall back to drm_exec_lock_obj() Content-Language: en-US To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch, frank.binns@imgtec.com, donald.robson@imgtec.com, matt.coster@imgtec.com, sarah.walker@imgtec.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20231124233650.152653-1-dakr@redhat.com> <20231124233650.152653-5-dakr@redhat.com> From: Danilo Krummrich Organization: RedHat In-Reply-To: <20231124233650.152653-5-dakr@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 howler.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 (howler.vger.email [0.0.0.0]); Fri, 24 Nov 2023 15:40:40 -0800 (PST) Hi Christian, do you think it makes sense to handle this in drm_exec_prepare_obj() or even dma_resv_reserve_fences() even? - Danilo On 11/25/23 00:36, Danilo Krummrich wrote: > Fall back to drm_exec_lock_obj() if num_fences is zero for the > drm_gpuvm_prepare_* function family. > > Otherwise dma_resv_reserve_fences() would actually allocate slots even > though num_fences is zero. > > Cc: Christian König > Signed-off-by: Danilo Krummrich > --- > drivers/gpu/drm/drm_gpuvm.c | 36 +++++++++++++++++++++++++++++++++--- > include/drm/drm_gpuvm.h | 23 +++-------------------- > 2 files changed, 36 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c > index 54f5e8851de5..d1d1c2379e44 100644 > --- a/drivers/gpu/drm/drm_gpuvm.c > +++ b/drivers/gpu/drm/drm_gpuvm.c > @@ -1085,6 +1085,36 @@ drm_gpuvm_put(struct drm_gpuvm *gpuvm) > } > EXPORT_SYMBOL_GPL(drm_gpuvm_put); > > +static int > +exec_prepare_obj(struct drm_exec *exec, struct drm_gem_object *obj, > + unsigned int num_fences) > +{ > + return num_fences ? drm_exec_prepare_obj(exec, obj, num_fences) : > + drm_exec_lock_obj(exec, obj); > +} > + > +/** > + * drm_gpuvm_prepare_vm() - prepare the GPUVMs common dma-resv > + * @gpuvm: the &drm_gpuvm > + * @exec: the &drm_exec context > + * @num_fences: the amount of &dma_fences to reserve > + * > + * Calls drm_exec_prepare_obj() for the GPUVMs dummy &drm_gem_object. > + * > + * Using this function directly, it is the drivers responsibility to call > + * drm_exec_init() and drm_exec_fini() accordingly. > + * > + * Returns: 0 on success, negative error code on failure. > + */ > +int > +drm_gpuvm_prepare_vm(struct drm_gpuvm *gpuvm, > + struct drm_exec *exec, > + unsigned int num_fences) > +{ > + return exec_prepare_obj(exec, gpuvm->r_obj, num_fences); > +} > +EXPORT_SYMBOL_GPL(drm_gpuvm_prepare_vm); > + > static int > __drm_gpuvm_prepare_objects(struct drm_gpuvm *gpuvm, > struct drm_exec *exec, > @@ -1095,7 +1125,7 @@ __drm_gpuvm_prepare_objects(struct drm_gpuvm *gpuvm, > int ret = 0; > > for_each_vm_bo_in_list(gpuvm, extobj, &extobjs, vm_bo) { > - ret = drm_exec_prepare_obj(exec, vm_bo->obj, num_fences); > + ret = exec_prepare_obj(exec, vm_bo->obj, num_fences); > if (ret) > break; > } > @@ -1116,7 +1146,7 @@ drm_gpuvm_prepare_objects_locked(struct drm_gpuvm *gpuvm, > > drm_gpuvm_resv_assert_held(gpuvm); > list_for_each_entry(vm_bo, &gpuvm->extobj.list, list.entry.extobj) { > - ret = drm_exec_prepare_obj(exec, vm_bo->obj, num_fences); > + ret = exec_prepare_obj(exec, vm_bo->obj, num_fences); > if (ret) > break; > > @@ -1186,7 +1216,7 @@ drm_gpuvm_prepare_range(struct drm_gpuvm *gpuvm, struct drm_exec *exec, > drm_gpuvm_for_each_va_range(va, gpuvm, addr, end) { > struct drm_gem_object *obj = va->gem.obj; > > - ret = drm_exec_prepare_obj(exec, obj, num_fences); > + ret = exec_prepare_obj(exec, obj, num_fences); > if (ret) > return ret; > } > diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h > index f94fec9a8517..b3f82ec7fb17 100644 > --- a/include/drm/drm_gpuvm.h > +++ b/include/drm/drm_gpuvm.h > @@ -544,26 +544,9 @@ struct drm_gpuvm_exec { > } extra; > }; > > -/** > - * drm_gpuvm_prepare_vm() - prepare the GPUVMs common dma-resv > - * @gpuvm: the &drm_gpuvm > - * @exec: the &drm_exec context > - * @num_fences: the amount of &dma_fences to reserve > - * > - * Calls drm_exec_prepare_obj() for the GPUVMs dummy &drm_gem_object. > - * > - * Using this function directly, it is the drivers responsibility to call > - * drm_exec_init() and drm_exec_fini() accordingly. > - * > - * Returns: 0 on success, negative error code on failure. > - */ > -static inline int > -drm_gpuvm_prepare_vm(struct drm_gpuvm *gpuvm, > - struct drm_exec *exec, > - unsigned int num_fences) > -{ > - return drm_exec_prepare_obj(exec, gpuvm->r_obj, num_fences); > -} > +int drm_gpuvm_prepare_vm(struct drm_gpuvm *gpuvm, > + struct drm_exec *exec, > + unsigned int num_fences); > > int drm_gpuvm_prepare_objects(struct drm_gpuvm *gpuvm, > struct drm_exec *exec,