From: Steven Price <steven.price@arm.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: "Nicolas Boichat" <drinkcat@chromium.org>,
"Daniel Stone" <daniels@collabora.com>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Liviu Dudau" <Liviu.Dudau@arm.com>,
dri-devel@lists.freedesktop.org,
"Clément Péron" <peron.clem@gmail.com>,
"Marty E . Plummer" <hanetzer@startmail.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Faith Ekstrand" <faith.ekstrand@collabora.com>
Subject: Re: [PATCH v2 12/15] drm/panthor: Add the driver frontend block
Date: Thu, 31 Aug 2023 15:42:05 +0100 [thread overview]
Message-ID: <9b28946d-3614-d8bd-4976-a2a3a64a66f1@arm.com> (raw)
In-Reply-To: <20230829194625.2845f463@collabora.com>
On 29/08/2023 18:46, Boris Brezillon wrote:
> On Mon, 21 Aug 2023 12:31:29 +0100
> Steven Price <steven.price@arm.com> wrote:
>
>> On 09/08/2023 17:53, Boris Brezillon wrote:
[...]
>>> + * // Collect signal operations on all jobs, such that each job can pick
>>> + * // from it for its dependencies and update the fence to signal when
>>> + * // the job is submitted.
>>
>> I can't figure out here how we avoid depedency loops within a batch.
>> What stops two jobs from each depending on each other?
>>
>> Or do we "allow" this but rely on the loop in panthor_submit_ctx_add_deps_and_arm_jobs()
>> to effectively enforce that a job cannot actually depend on a job
>> which is later in the batch.
>
> You can't have circular dependencies because the job fence is created
> after its dependencies have been registered, so a job at the beginning
> of the array can't depend on a job that's coming after. It might be
> passed the same syncobj, but since a syncobj is just a container, the
> fence attached to the syncobj at the time the first job adds it as a
> dependency will point to a different dma_fence.
>
>> In which case why bother with this
>> complexity rather than just performing all the steps on each job
>> in order?
>
> Because, before submitting a set of jobs, we want to make sure all jobs
> that are passed to a submit request are valid and enough resources are
> available for their execution to proceed. We could allow partial
> execution (and that's actually the approach I had taken in one of the
> patch I proposed to allow submitting multiple jobs in one call to
> panfrost), but then you potentially have to figure out where things
> failed, not to mention that the syncobjs might point to intermediate
> dma_fence objects instead of the final one.
>
>>
>> Being able to submit a forward dependency, but then having it
>> ignored seems like an odd design. So I feel like I must be
>> missing something.
>
> It's not about allowing forward dependencies (that would be mess), but
> allowing one job to take a dependency on a job that was appearing
> earlier in the job array of the same submit call.
>
>>
>>> + * ret = panthor_submit_ctx_collect_jobs_signal_ops(&ctx);
>
> Here panthor_submit_ctx_collect_jobs_signal_ops() is not registering
> job out_fences to the syncobjs, it's just collecting all signal
> operations from all jobs in an array. Each entry in this array contains
> the syncobj handle, the syncobj object, and the fence that was attached
> to it at the time the collection happens, and that's it.
>
> Now, when a job are populated, and after we made sure it had
> everything it needs to be submitted, for each signal operation passed
> to this specific job, we update the corresponding entry in the signal
> array with the job finished fence, but the syncobj is not updated at
> that point, because we want to make sure all jobs belonging to a submit
> can be submitted before exposing their fences to the outside world.
>
> For jobs happening later in the array, when we see a WAIT operation,
> we will first check the signal array to see if there's a
> corresponding entry cached there for the given syncobj handle, if there
> is, we take the dma_fence from here (this dma_fence might come from a
> job submitted earlier in this submit context, or it might be the fence
> that was there initially), if not, we call drm_syncobj_find_fence() to
> get the dependency.
>
> Once all jobs have been parsed/checked/populated, we start the
> non-failing step => job submission. And after that point, we can start
> exposing the job fences to the outside world. This is what happens in
> panthor_submit_ctx_push_fences(): we iterate over the signal
> operations, and update each syncobj with the fence that was last
> attached to it (the last job in the submit array having a SIGNAL
> operation on that syncobj).
Thanks for the detailed explanation. I guess I hadn't considered the
benefits of checking everything is valid and obtaining resources before
submitting anything. That makes sense and I guess justifies this complexity.
[...]
>>> +static int
>>> +panthor_submit_ctx_add_job(struct panthor_submit_ctx *ctx, u32 idx,
>>> + struct drm_sched_job *job,
>>> + const struct drm_panthor_obj_array *syncs)
>>> +{
>>> + struct panthor_device *ptdev = container_of(ctx->file->minor->dev,
>>> + struct panthor_device,
>>> + base);
>>> + int ret;
>>> +
>>> + if (drm_WARN_ON(&ptdev->base,
>>> + idx >= ctx->job_count ||
>>> + ctx->jobs[idx].job ||
>>> + ctx->jobs[idx].syncops ||
>>> + ctx->jobs[idx].syncop_count))
>>> + return -EINVAL;
>>> +
>>> + ctx->jobs[idx].job = job;
>>
>> While the WARN_ON obviously shouldn't happen, this positioning of the
>> ctx->jobs[].job assignment means the caller has no idea if the
>> assignment has happened. AFAICT in the case of the WARN_ON the job isn't
>> cleaned up properly.
>
> It's not really about cleanup not happening, more about being passed an
> index that was already populated.
>
>>
>> The options I can see are to move this line further down (and make the
>> caller clean up that one job if this function fails), or to clean up the
>> job in the case where the WARN_ON fails.
>
> Maybe I should drop this WARN_ON() and assume the caller passed a valid
> index...
I'd be fine with that. My reordering suggestion is a bit pointless I
must admit ;)
[...]
>>> +
>>> + for (u32 i = 0; i < sync_op_count; i++) {
>>> + struct panthor_sync_signal *sig_sync;
>>> + struct dma_fence *fence;
>>> +
>>> + if (sync_ops[i].flags & DRM_PANTHOR_SYNC_OP_SIGNAL)
>>> + continue;
>>
>> NIT: It might be worth having a helper for the operation type. It's a
>> little confusing that we have !(flags & SIGNAL) and (flags & SIGNAL) but
>> not (flags & WAIT) - obviously looking at the definition shows why. Also
>> there'll be a lot of careful refactoring needed if a third operation is
>> ever added.
>
> I had the operation as a separate field initially, but I couldn't think
> of any other operations we could do on a syncobj, so I decided to make
> it a flag, and mimic what Xe does.
A flag is fine, I just find it harder to read:
if (sync_ops[i].flags & DRM_PANTHOR_SYNC_OP_SIGNAL)
[...]
if (!(sync_ops[i].flags & DRM_PANTHOR_SYNC_OP_SIGNAL)
vs
bool is_signal_op(struct drm_panthor_sync_op *op)
{
return !!(op->flags & DRM_PANTHOR_SYNC_OP_SIGNAL);
}
bool is_wait_op(struct drm_panthor_sync_op *op)
{
return !(op->flags & DRM_PANTHOR_SYNC_OP_SIGNAL);
}
if (is_signal_op(&sync_ops[i]))
[...]
if (is_wait_op(&sync_ops[i]))
And it avoid anyone accidentally writing:
if (sync_ops[i].flags & DRM_PANTHOR_SYNC_OP_WAIT)
which in my quick test the compiler doesn't even warn on :(
Although on the subject of the flag, apparently the enumeration type
value doesn't compile with -pedantic as it overflows into the sign bit:
include/drm/panthor_drm.h:237:31: warning: enumerator value for
‘DRM_PANTHOR_SYNC_OP_SIGNAL’ is not an integer constant expression
[-Wpedantic]
237 | DRM_PANTHOR_SYNC_OP_SIGNAL = 1 << 31,
Changing it to "(int)(1u << 31)" seems to be workaround. This affects
DRM_PANTHOR_VM_BIND_OP_TYPE_MASK too.
>>
[...]
>>> +#define PANTHOR_VM_CREATE_FLAGS 0
>>> +
>>> +static int panthor_ioctl_vm_create(struct drm_device *ddev, void *data,
>>> + struct drm_file *file)
>>> +{
>>> + struct panthor_device *ptdev = container_of(ddev, struct panthor_device, base);
>>> + u32 va_bits = GPU_MMU_FEATURES_VA_BITS(ptdev->gpu_info.mmu_features);
>>> + struct panthor_file *pfile = file->driver_priv;
>>> + struct drm_panthor_vm_create *args = data;
>>> + u64 kernel_va_start = 0;
>>> + int cookie, ret;
>>> +
>>> + if (!drm_dev_enter(ddev, &cookie))
>>> + return -ENODEV;
>>> +
>>> + if (args->flags & ~PANTHOR_VM_CREATE_FLAGS) {
>>> + ret = -EINVAL;
>>> + goto out_dev_exit;
>>> + }
>>> +
>>> + if (drm_WARN_ON(ddev, !va_bits) || args->kernel_va_range > (1ull << (va_bits - 1))) {
>>
>> The check for !va_bits would be better done at probe time. I'd also be
>> tempted to move the change for kernel_va_range down to
>> panthor_vm_create() as that has to repeat the va_bits calculation.
>>
>>> + ret = -EINVAL;
>>> + goto out_dev_exit;
>>> + }
>>> +
>>> + if (args->kernel_va_range)
>>> + kernel_va_start = (1 << (va_bits - 1)) - args->kernel_va_range;
>>
>> And also push the calculation of va_start down to
>> panthor_vm_create() as well.
>
> panthor_vm_create() is used internally, for the MCU VM creation, and
> I'd prefer to keep it uAPI agnostic. I don't mind moving it to
> panthor_vm_pool_create_vm() but we'd still have to do the va_bits
> calculation twice.
Ah true, for panthor_vm_create() you need to be able to pass in the VA
range for the MCU. We do have the "for_mcu" flag so the
CSF_MCU_SHARED_REGION_START/SIZE #defines could be used directly in
panthor_vm_create(). But I'd be happy with it in
panthor_vm_pool_create_vm() if you'd prefer.
Steve
next prev parent reply other threads:[~2023-08-31 14:42 UTC|newest]
Thread overview: 93+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 16:53 [PATCH v2 00/15] drm: Add a driver for FW-based Mali GPUs Boris Brezillon
2023-08-09 16:53 ` [PATCH v2 01/15] drm/shmem-helper: Make pages_use_count an atomic_t Boris Brezillon
2023-08-11 13:08 ` Steven Price
2023-08-19 2:13 ` Dmitry Osipenko
2023-08-28 9:03 ` Boris Brezillon
2023-08-09 16:53 ` [PATCH v2 02/15] drm/panthor: Add uAPI Boris Brezillon
2023-08-11 14:13 ` Steven Price
2023-09-01 13:59 ` Liviu Dudau
2023-09-01 16:10 ` Boris Brezillon
2023-09-04 7:42 ` Steven Price
2023-09-04 8:26 ` Boris Brezillon
2023-09-04 9:26 ` Boris Brezillon
2023-09-04 15:22 ` Steven Price
2023-09-04 16:16 ` Boris Brezillon
2023-09-04 16:25 ` Robin Murphy
2023-09-06 10:55 ` Steven Price
2023-09-04 16:06 ` Robin Murphy
2023-09-06 12:18 ` Ketil Johnsen
2023-08-09 16:53 ` [PATCH v2 03/15] drm/panthor: Add GPU register definitions Boris Brezillon
2023-08-11 14:13 ` Steven Price
2023-08-29 13:00 ` Boris Brezillon
2023-08-09 16:53 ` [PATCH v2 04/15] drm/panthor: Add the device logical block Boris Brezillon
2023-08-11 15:47 ` Steven Price
2023-08-29 14:00 ` Boris Brezillon
2023-08-30 13:17 ` Steven Price
2023-08-30 14:06 ` Boris Brezillon
2023-09-04 11:46 ` Liviu Dudau
2023-08-09 16:53 ` [PATCH v2 05/15] drm/panthor: Add the GPU " Boris Brezillon
2023-08-14 10:54 ` Steven Price
2023-08-21 16:09 ` Robin Murphy
2023-08-23 8:48 ` Steven Price
2023-08-29 14:42 ` Boris Brezillon
2023-08-29 14:40 ` Boris Brezillon
2023-08-09 16:53 ` [PATCH v2 06/15] drm/panthor: Add GEM " Boris Brezillon
2023-08-14 13:40 ` Steven Price
2023-08-29 14:45 ` Boris Brezillon
2023-08-09 16:53 ` [PATCH v2 07/15] drm/panthor: Add the devfreq " Boris Brezillon
2023-08-14 13:45 ` Steven Price
2023-08-09 16:53 ` [PATCH v2 08/15] drm/panthor: Add the MMU/VM " Boris Brezillon
2023-08-14 15:53 ` Steven Price
2023-08-29 15:33 ` Boris Brezillon
2023-08-30 14:12 ` Steven Price
2023-08-30 14:53 ` Boris Brezillon
2023-08-30 15:55 ` Steven Price
2023-08-09 16:53 ` [PATCH v2 09/15] drm/panthor: Add the FW " Boris Brezillon
2023-08-16 16:01 ` Steven Price
2023-08-29 16:15 ` Boris Brezillon
2023-08-30 15:20 ` Steven Price
2023-08-09 16:53 ` [PATCH v2 10/15] drm/panthor: Add the heap " Boris Brezillon
2023-08-18 14:39 ` Steven Price
2023-08-29 16:21 ` Boris Brezillon
2023-08-09 16:53 ` [PATCH v2 11/15] drm/panthor: Add the scheduler " Boris Brezillon
2023-08-18 15:38 ` Steven Price
2023-08-29 16:36 ` Boris Brezillon
2023-08-09 16:53 ` [PATCH v2 12/15] drm/panthor: Add the driver frontend block Boris Brezillon
2023-08-21 11:31 ` Steven Price
2023-08-29 17:46 ` Boris Brezillon
2023-08-31 14:42 ` Steven Price [this message]
2023-09-06 12:38 ` Ketil Johnsen
2023-09-06 13:05 ` Boris Brezillon
2023-08-09 16:53 ` [PATCH v2 13/15] drm/panthor: Allow driver compilation Boris Brezillon
2023-08-11 16:35 ` Robin Murphy
2023-08-11 16:56 ` Daniel Stone
2023-08-11 19:26 ` Robin Murphy
2023-08-14 11:18 ` Steven Price
2023-08-21 17:56 ` Robin Murphy
2023-08-23 9:17 ` Steven Price
2023-08-29 12:51 ` Boris Brezillon
2023-08-21 12:47 ` Steven Price
2023-08-09 16:53 ` [PATCH v2 14/15] dt-bindings: gpu: mali-valhall-csf: Add initial bindings for panthor driver Boris Brezillon
2023-08-09 16:53 ` Boris Brezillon
2023-08-20 8:01 ` Krzysztof Kozlowski
2023-08-20 8:01 ` Krzysztof Kozlowski
2023-09-20 13:41 ` Liviu Dudau
2023-09-20 13:41 ` Liviu Dudau
2023-09-20 13:51 ` Krzysztof Kozlowski
2023-09-20 13:51 ` Krzysztof Kozlowski
2023-09-20 14:25 ` Liviu Dudau
2023-09-20 14:25 ` Liviu Dudau
2023-09-20 15:31 ` Krzysztof Kozlowski
2023-09-20 15:31 ` Krzysztof Kozlowski
2023-09-20 13:56 ` Boris Brezillon
2023-09-20 13:56 ` Boris Brezillon
2023-09-20 14:03 ` Liviu Dudau
2023-08-09 16:53 ` [PATCH v2 15/15] drm/panthor: Add an entry to MAINTAINERS Boris Brezillon
2023-08-11 16:08 ` Steven Price
2023-08-29 17:48 ` Boris Brezillon
2023-08-31 13:18 ` Liviu Dudau
2023-08-31 13:25 ` Boris Brezillon
2023-08-09 20:22 ` [PATCH v2 00/15] drm: Add a driver for FW-based Mali GPUs Rob Herring
2023-08-10 15:44 ` Boris Brezillon
2023-08-21 14:01 ` Rob Herring
2023-09-27 15:47 ` Steven Price
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=9b28946d-3614-d8bd-4976-a2a3a64a66f1@arm.com \
--to=steven.price@arm.com \
--cc=Liviu.Dudau@arm.com \
--cc=boris.brezillon@collabora.com \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=drinkcat@chromium.org \
--cc=faith.ekstrand@collabora.com \
--cc=hanetzer@startmail.com \
--cc=neil.armstrong@linaro.org \
--cc=peron.clem@gmail.com \
--cc=robin.murphy@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.