drm/msm: Un-break multi-context gl
Subsystems (4)
cover drm/msm: Un-break multi-context gl
From: Rob Clark <[email protected]>
Userspace is expecting that a single thread doing rendering against multiple contexts does not need additional synchronization between those contexts beyond ensuring work is flushed to the kernel in the correct order. But if we have a sched-entity per-context, and are not using implicit sync, GPU jobs from different contexts can execute in a different order than they were flushed to the kernel.
To solve that, share sched-entities for a given priority level between submitqueues (which map to gl contexts).
Rob Clark (2):
drm/msm: A bit more docs + cleanup drm/msm: One sched entity per process per priority
drivers/gpu/drm/msm/msm_drv.h | 44 ----------------- drivers/gpu/drm/msm/msm_gem_submit.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 66 +++++++++++++++++++++++++- drivers/gpu/drm/msm/msm_submitqueue.c | 68 +++++++++++++++++++++++---- 4 files changed, 123 insertions(+), 57 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/2 drm/msm: A bit more docs + cleanup
From: Rob Clark <[email protected]>
msm_file_private is more gpu related, and in the next commit it will need access to other GPU specific #defines. While we're at it, add some comments.
--- drivers/gpu/drm/msm/msm_drv.h | 44 -------------------------- drivers/gpu/drm/msm/msm_gpu.h | 58 ++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 45 deletions(-)
drivers/gpu/drm/msm/msm_drv.h +0 -44
@@ -53,15 +53,6 @@ struct msm_disp_state;#define FRAC_16_16 (mult, div) (((mult) << 16) / (div)) -struct msm_file_private { -rwlock_t queuelock; -struct list_head submitqueues; -int queueid; -struct msm_gem_address_space *aspace; -struct kref ref; -int seqno; -}; -enum msm_mdp_plane_property {PLANE_PROP_ZPOS ,PLANE_PROP_ALPHA ,
@@ -511,41 +502,6 @@ void msm_hrtimer_work_init(struct msm_hrtimer_work *work,clockid_t clock_id, enum hrtimer_mode mode); -struct msm_gpu_submitqueue ; -int msm_submitqueue_init (struct drm_device *drm,struct msm_file_private *ctx); -struct msm_gpu_submitqueue *msm_submitqueue_get (struct msm_file_private *ctx, -u32 id); -int msm_submitqueue_create (struct drm_device *drm, -struct msm_file_private *ctx, -u32 prio,u32 flags,u32 *id); -int msm_submitqueue_query (struct drm_device *drm,struct msm_file_private *ctx, -struct drm_msm_submitqueue_query *args); -int msm_submitqueue_remove (struct msm_file_private *ctx,u32 id); -void msm_submitqueue_close (struct msm_file_private *ctx); - -void msm_submitqueue_destroy (struct kref *kref); - -static inline void __msm_file_private_destroy (struct kref *kref) -{ -struct msm_file_private *ctx =container_of (kref, - struct msm_file_private, ref); - -msm_gem_address_space_put (ctx->aspace); -kfree (ctx); -} - -static inline void msm_file_private_put (struct msm_file_private *ctx) -{ -kref_put (&ctx->ref, __msm_file_private_destroy); -} - -static inline struct msm_file_private *msm_file_private_get ( -struct msm_file_private *ctx) -{ -kref_get (&ctx->ref); -return ctx; -} -#define DBG (fmt, ...) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)#define VERB (fmt, ...) if (0) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)
drivers/gpu/drm/msm/msm_gpu.h +57 -1
82 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 2/2 drm/msm: One sched entity per process per priority
In reply to Rob ClarkFrom: Rob Clark <[email protected]>
Some userspace apps make assumptions that rendering against multiple contexts within the same process (from the same thread, with appropriate MakeCurrent() calls) provides sufficient synchronization without any external synchronization (ie. glFenceSync()/glWaitSync()). Since a submitqueue maps to a gl/vk context, having multiple sched entities of the same priority only works with implicit sync enabled.
To fix this, limit things to a single sched entity per priority level per process.
An alternative would be sharing submitqueues between contexts in userspace, but tracking of per-context faults (ie. GL_EXT_robustness) is already done at the submitqueue level, so this is not an option.
---
Unfortunately, due to a finch experiment (a sort of A/B experiment) all my testing of the drm/scheduler with chrome(ium) was using SkiaRenderer which does not trigger this bug. It wasn't until folks started reporting misrendering on dev channel, and I tracked it down to legacy GLRenderer vs SkiaRenderer, that I realized the problem :-(
drivers/gpu/drm/msm/msm_gem_submit.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 24 ++++++---- drivers/gpu/drm/msm/msm_submitqueue.c | 68 +++++++++++++++++++++++---- 3 files changed, 74 insertions(+), 20 deletions(-)
drivers/gpu/drm/msm/msm_gem_submit.c +1 -1
@@ -46,7 +46,7 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,if (!submit)return ERR_PTR (-ENOMEM ); - ret =drm_sched_job_init (&submit->base, &queue->entity, queue); + ret =drm_sched_job_init (&submit->base, queue->entity, queue);if (ret) {kfree (submit);return ERR_PTR (ret);
drivers/gpu/drm/msm/msm_gpu.h +15 -9
@@ -290,6 +290,19 @@ struct msm_file_private {struct msm_gem_address_space *aspace;struct kref ref;int seqno; + +/** +* entities: +* +* Table of per-priority-level sched entities used by submitqueues +* associated with this &drm_file. Because some userspace apps +* make assumptions about rendering from multiple gl contexts +* (of the same priority) within the process happening in FIFO +* order without requiring any fencing beyond MakeCurrent(), we +* create at most one &drm_sched_entity per-process per-priority- +* level. +*/ +struct drm_sched_entity *entities[NR_SCHED_PRIORITIES *MSM_GPU_MAX_RINGS ]; };/**
@@ -370,7 +383,7 @@ struct msm_gpu_submitqueue {struct idr fence_idr;struct mutex lock;struct kref ref; -struct drm_sched_entity entity; +struct drm_sched_entity *entity; };struct msm_gpu_state_bo {
@@ -471,14 +484,7 @@ void msm_submitqueue_close(struct msm_file_private *ctx);void msm_submitqueue_destroy (struct kref *kref); -static inline void __msm_file_private_destroy (struct kref *kref) -{ -struct msm_file_private *ctx =container_of (kref, - struct msm_file_private, ref); - -msm_gem_address_space_put (ctx->aspace); -kfree (ctx); -} +void __msm_file_private_destroy (struct kref *kref);static inline void msm_file_private_put (struct msm_file_private *ctx) {
drivers/gpu/drm/msm/msm_submitqueue.c +58 -10
97 lines not on this page · raw message
Signature · 1 line
2.31.1