From: "Christian König" <christian.koenig@amd.com>
To: Danilo Krummrich <dakr@redhat.com>
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
Subject: Re: [PATCH drm-misc-next 4/5] drm/gpuvm: fall back to drm_exec_lock_obj()
Date: Mon, 27 Nov 2023 14:52:51 +0100 [thread overview]
Message-ID: <762bb5f4-f9f5-4ebc-84d3-5465df3ffbf6@amd.com> (raw)
In-Reply-To: <3c7b7683-da36-4ffe-a250-91eef019499f@redhat.com>
Am 25.11.23 um 00:40 schrieb Danilo Krummrich:
> Hi Christian,
>
> do you think it makes sense to handle this in drm_exec_prepare_obj() or
> even dma_resv_reserve_fences() even?
IIRC for drm_exec the discussion has gone a bit back and forth between
handling 0 and having a separate function which doesn't allocate fences.
We ended up with the solution using separate calls since you either know
that you don't need fences (because you for example only need to look
something up) or you need fences and eventually calculate the number you
need dynamically and if you then end up with 0 it's a bug.
So to sum it up the conclusion was that it's more defensive to complain
about 0 fences to reserve (which reminds me that
dma_resv_reserve_fences() still needs to get a warning for 0 fences as
well).
Regards,
Christian.
>
> - 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 <christian.koenig@amd.com>
>> Signed-off-by: Danilo Krummrich <dakr@redhat.com>
>> ---
>> 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,
>
next prev parent reply other threads:[~2023-11-27 13:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 23:36 [PATCH drm-misc-next 0/5] PowerVR VM fixes Danilo Krummrich
2023-11-24 23:36 ` [PATCH drm-misc-next 1/5] drm/imagination: vm: prevent duplicate drm_gpuvm_bo instances Danilo Krummrich
2023-11-28 10:34 ` [EXTERNAL] " Donald Robson
2023-11-28 13:00 ` (subset) " Maxime Ripard
2023-11-24 23:36 ` [PATCH drm-misc-next 2/5] drm/imagination: vm: check for drm_gpuvm_range_valid() Danilo Krummrich
2023-11-28 10:34 ` [EXTERNAL] " Donald Robson
2023-11-28 13:00 ` (subset) " Maxime Ripard
2023-11-24 23:36 ` [PATCH drm-misc-next 3/5] drm/imagination: vm: fix drm_gpuvm reference count Danilo Krummrich
2023-11-28 10:36 ` Donald Robson
2023-11-28 13:01 ` (subset) " Maxime Ripard
2023-11-24 23:36 ` [PATCH drm-misc-next 4/5] drm/gpuvm: fall back to drm_exec_lock_obj() Danilo Krummrich
2023-11-24 23:40 ` Danilo Krummrich
2023-11-27 13:52 ` Christian König [this message]
2023-11-27 17:50 ` Danilo Krummrich
2023-11-24 23:36 ` [PATCH drm-misc-next 5/5] drm/imagination: vm: make use of GPUVM's drm_exec helper Danilo Krummrich
2023-11-28 10:47 ` [EXTERNAL] " Donald Robson
2023-11-28 19:02 ` Danilo Krummrich
2023-11-27 10:53 ` [PATCH drm-misc-next 0/5] PowerVR VM fixes Frank Binns
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=762bb5f4-f9f5-4ebc-84d3-5465df3ffbf6@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=dakr@redhat.com \
--cc=daniel@ffwll.ch \
--cc=donald.robson@imgtec.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=frank.binns@imgtec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.coster@imgtec.com \
--cc=mripard@kernel.org \
--cc=sarah.walker@imgtec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®