drm/v3d: add multiple in/out syncobjs support
Subsystems (3)
Melissa Wen
maintainercover drm/v3d: add multiple in/out syncobjs support
Hi,
Currently, v3d only supports single in/out syncobj per submission (in v3d_submit_cl we have two in_sync, one for bin and another for render job); however, Vulkan queue submit operations expect multiples wait and signal semaphores. This series extending v3d interface and job dependency operations to handle more than one in/out syncobj.
The first patch just decouples the steps to add job dependency from the job init code since the operation repeats for every syncobj that a job should wait before starting. So, we can just reuse it when handling multiples wait for semaphores in the third patch of this series.
The second patch extends our interface by using a generic extension. We chose this approach inspired by i915_user_extension[1] and amd_cs_chunks[2] to give a little more flexibility in adding other submission features in the future. Therefore, the list of extensions will work as a hub of features that use an id to determine the corresponding feature data type.
With this base, the third patch adds multiple wait/signal semaphores support. For this, we add to the list of the generic extensions a new data type (drm_v3d_multi_sync) that points to two arrays of syncobjs (in/out) and also determines (flags) if the dependencies must be added to the bin job or render job (in the case of v3d_submit_cl). An auxiliary struct (v3d_submit_ext) is used when parsing submission extensions. Finally, we reserve some space in the semaphore struct (drm_v3d_sem) to accommodate timeline semaphores that we aim to add support soon (same reason for already defining v3d_submit_outsync).
[1] https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/i915/i915_user_extensions.c?id=9d1305ef80b95dde0337106ed8b826604e2155ad
[2] https://cgit.freedesktop.org/drm/drm-misc/tree/include/uapi/drm/amdgpu_drm.h#n556
PS: I'm cc'ing more people to get any comments for the generic extension approach and the multiple semaphores support too.
Melissa Wen (3):
drm/v3d: decouple adding job dependencies from job init drm/v3d: add generic ioctl extension
drm/v3d: add multiple syncobjs support
drivers/gpu/drm/v3d/v3d_drv.c | 7 +- drivers/gpu/drm/v3d/v3d_drv.h | 14 ++ drivers/gpu/drm/v3d/v3d_gem.c | 304 +++++++++++++++++++++++++++++----- include/uapi/drm/v3d_drm.h | 76 ++++++++- 4 files changed, 355 insertions(+), 46 deletions(-)
Signature · 1 line
2.30.2
Melissa Wen
maintainerRFC PATCH 1/3 drm/v3d: decouple adding job dependencies from job init
Prep work to enable multiple syncobj as job dependency. Also get rid of old checkpatch warnings in the v3d_gem file. No functional changes.
--- drivers/gpu/drm/v3d/v3d_gem.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
drivers/gpu/drm/v3d/v3d_gem.c +18 -10
@@ -417,7 +417,7 @@ v3d_wait_bo_ioctl(struct drm_device *dev, void *data,return -EINVAL ; ret =drm_gem_dma_resv_wait (file_priv, args->handle, - true, timeout_jiffies); + true, timeout_jiffies);/* Decrement the user's timeout, in case we got interrupted * such that the ioctl will be restarted.
@@ -435,12 +435,25 @@ v3d_wait_bo_ioctl(struct drm_device *dev, void *data,return ret; } +static int +v3d_job_add_deps (struct drm_file *file_priv,struct v3d_job *job, +u32 in_sync,u32 point) +{ +struct dma_fence *in_fence =NULL ; +int ret; + + ret =drm_syncobj_find_fence (file_priv, in_sync, point,0 , &in_fence); +if (ret == -EINVAL ) +return ret; + +return drm_gem_fence_array_add (&job->deps, in_fence); +} +static int v3d_job_init (struct v3d_dev *v3d,struct drm_file *file_priv,struct v3d_job *job,void (*free)(struct kref *ref),u32 in_sync) { -struct dma_fence *in_fence =NULL ;int ret; job->v3d = v3d;
@@ -452,11 +465,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,xa_init_flags (&job->deps,XA_FLAGS_ALLOC ); - ret =drm_syncobj_find_fence (file_priv, in_sync,0 ,0 , &in_fence); -if (ret == -EINVAL ) - goto fail; - - ret =drm_gem_fence_array_add (&job->deps, in_fence); + ret =v3d_job_add_deps (file_priv, job, in_sync,0 );if (ret) goto fail;
@@ -503,7 +512,7 @@ v3d_attach_fences_and_unlock_reservation(struct drm_file *file_priv,for (i =0 ; i < job->bo_count; i++) {/* XXX: Use shared fences for read-only objects. */ dma_resv_add_excl_fence (job->bo[i]->resv, - job->done_fence); + job->done_fence); }drm_gem_unlock_reservations (job->bo, job->bo_count, acquire_ctx);
@@ -924,8 +933,7 @@ v3d_gem_init(struct drm_device *dev)if (!v3d->pt) {drm_mm_takedown (&v3d->mm);dev_err (v3d->drm.dev, -"Failed to allocate page tables. " -"Please ensure you have CMA enabled.\n" ); +"Failed to allocate page tables. Please ensure you have CMA enabled.\n" );return -ENOMEM ; }
Signature · 1 line
2.30.2
Melissa Wen
maintainerRFC PATCH 2/3 drm/v3d: add generic ioctl extension
In reply to Melissa WenAdd support to attach generic extensions on job submission. This patch is a second prep work to enable multiple syncobjs on job submission. With this work, when the job submission interface needs to be extended to accomodate a new feature, we will use a generic extension struct where an id determines the data type to be pointed. The first application is to enable multiples in/out syncobj (next patch), but the base is already done for future features.
--- drivers/gpu/drm/v3d/v3d_drv.c | 4 +- drivers/gpu/drm/v3d/v3d_gem.c | 84 ++++++++++++++++++++++++++++++++--- include/uapi/drm/v3d_drm.h | 38 +++++++++++++++- 3 files changed, 115 insertions(+), 11 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.c +1 -3
@@ -83,7 +83,6 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,return 0 ; } -switch (args->param) {case DRM_V3D_PARAM_SUPPORTS_TFU : args->value =1 ;
@@ -147,7 +146,7 @@ v3d_postclose(struct drm_device *dev, struct drm_file *file)DEFINE_DRM_GEM_FOPS (v3d_drm_fops);/* DRM_AUTH is required on SUBMIT_CL for now, while we don't have GMP -* protection between clients. Note that render nodes would be be +* protection between clients. Note that render nodes would be * able to submit CLs that could access BOs from clients authenticated * with the master node. The TFU doesn't use the GMP, so it would * need to stay DRM_AUTH until we do buffer size/offset validation.
@@ -222,7 +221,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)u32 mmu_debug;u32 ident1; - v3d = devm_drm_dev_alloc(dev, &v3d_drm_driver, struct v3d_dev, drm);if (IS_ERR (v3d))return PTR_ERR (v3d);
drivers/gpu/drm/v3d/v3d_gem.c +77 -7
116 lines not on this page · raw message
include/uapi/drm/v3d_drm.h +37 -1
@@ -58,6 +58,19 @@ extern "C" { struct drm_v3d_perfmon_get_values)#define DRM_V3D_SUBMIT_CL_FLUSH_CACHE 0x01 +#define DRM_V3D_SUBMIT_EXTENSION 0x02 + +/* struct drm_v3d_extension - ioctl extensions +* +* Linked-list of generic extensions where the id identify which struct is +* pointed by ext_data. Therefore, DRM_V3D_EXT_ID_* is used on id to identify +* the extension type. +*/ +struct drm_v3d_extension { +__u64 next; +__u64 ext_data; +__u32 id; +};/** * struct drm_v3d_submit_cl - ioctl argument for submitting commands to the 3D
@@ -135,12 +148,17 @@ struct drm_v3d_submit_cl {/* Number of BO handles passed in (size is that times 4). */ __u32 bo_handle_count; +/* DRM_V3D_SUBMIT_* properties */ __u32 flags;/* ID of the perfmon to attach to this job. 0 means no perfmon. */ __u32 perfmon_id; -__u32 pad; +/* Number of extensions*/ +__u32 extension_count; + +/* Pointer to a list of ioctl extensions*/ +__u64 extensions; };/**
@@ -248,6 +266,15 @@ struct drm_v3d_submit_tfu {__u32 in_sync;/* Sync object to signal when the TFU job is done. */ __u32 out_sync; + +/* Number of extensions*/ +__u32 extension_count; + +/* Pointer to an array of ioctl extensions*/ +__u64 extensions; + +/* DRM_V3D_SUBMIT_* properties */ +__u32 flags; };/* Submits a compute shader for dispatch. This job will block on any
@@ -276,6 +303,15 @@ struct drm_v3d_submit_csd {/* ID of the perfmon to attach to this job. 0 means no perfmon. */ __u32 perfmon_id; + +/* DRM_V3D_SUBMIT_* properties */ +__u32 flags; + +/* Number of extensions*/ +__u32 extension_count; + +/* Pointer to a list of ioctl extensions*/ +__u64 extensions; };enum {
Signature · 1 line
2.30.2
Melissa Wen
maintainerRFC PATCH 3/3 drm/v3d: add multiple syncobjs support
In reply to Melissa WenUsing the generic extension support set in the previous patch, this patch enables more than one in/out binary syncobj per job submission. Arrays of syncobjs are set in a specific extension type (multisync) that also cares of determining the stage for sync (bin/render) through a flag - when this is the case.
--- drivers/gpu/drm/v3d/v3d_drv.c | 3 + drivers/gpu/drm/v3d/v3d_drv.h | 14 +++ drivers/gpu/drm/v3d/v3d_gem.c | 210 ++++++++++++++++++++++++++++------ include/uapi/drm/v3d_drm.h | 38 ++++++ 4 files changed, 231 insertions(+), 34 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.c +3 -0
@@ -96,6 +96,9 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,case DRM_V3D_PARAM_SUPPORTS_PERFMON : args->value = (v3d->ver >=40 );return 0 ; +case DRM_V3D_PARAM_SUPPORTS_MULTISYNC_EXT : + args->value =1 ; +return 0 ;default :DRM_DEBUG ("Unknown parameter %d\n" , args->param);return -EINVAL ;
drivers/gpu/drm/v3d/v3d_drv.h +14 -0
@@ -299,6 +299,20 @@ struct v3d_csd_job {struct drm_v3d_submit_csd args; }; +struct v3d_submit_outsync { +struct drm_syncobj *syncobj; +}; + +struct v3d_submit_ext { +u32 flags; + +u32 in_sync_count; +u64 in_syncs; + +u32 out_sync_count; +struct v3d_submit_outsync *out_syncs; +}; +/** * __wait_for - magic wait macro *
drivers/gpu/drm/v3d/v3d_gem.c +176 -34
396 lines not on this page · raw message
include/uapi/drm/v3d_drm.h +38 -0
@@ -60,6 +60,42 @@ extern "C" {#define DRM_V3D_SUBMIT_CL_FLUSH_CACHE 0x01#define DRM_V3D_SUBMIT_EXTENSION 0x02 +/* struct drm_v3d_sem - wait/signal semaphore +* +* If binary semaphore, it only takes syncobj handle and ignores flags and +* point fields. Point is defined for timeline syncobj feature. +*/ +struct drm_v3d_sem { +__u32 handle;/* syncobj */ +/* rsv below, for future uses */ +__u32 flags; +__u64 point;/* for timeline sem support */ +__u64 mbz[2 ];/* must be zero, rsv */ +}; + +/** +* struct drm_v3d_multi_sync - ioctl extension to add support multiples +* syncobjs for commands submission. +* +* When an extension of DRM_V3D_EXT_ID_MULTI_SYNC id is defined, it points to +* this extension to define wait and signal dependencies, instead of single +* in/out sync entries on submitting commands. The field flags is used to +* determine the stage to set wait dependencies. +*/ +struct drm_v3d_multi_sync { +/* Array of wait and signal semaphores */ +__u64 in_syncs; +__u64 out_syncs; + +/* Number of entries */ +__u32 in_sync_count; +__u32 out_sync_count; + +/* in_sync on render stage */ +__u32 flags; +#define DRM_V3D_IN_SYNC_RCL 0x01 +}; +/* struct drm_v3d_extension - ioctl extensions * * Linked-list of generic extensions where the id identify which struct is
@@ -70,6 +106,7 @@ struct drm_v3d_extension {__u64 next;__u64 ext_data;__u32 id; +#define DRM_V3D_EXT_ID_MULTI_SYNC 0x01 };/**
@@ -228,6 +265,7 @@ enum drm_v3d_param {DRM_V3D_PARAM_SUPPORTS_CSD ,DRM_V3D_PARAM_SUPPORTS_CACHE_FLUSH ,DRM_V3D_PARAM_SUPPORTS_PERFMON , + DRM_V3D_PARAM_SUPPORTS_MULTISYNC_EXT, }; struct drm_v3d_get_param {
Signature · 1 line
2.30.2