mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
drm/msm: Fix barriers accessing ctx vm
Don't rely on store ordering to protect us from caller seeing a partially initialized vm. Reported-by: Sashiko <sashiko-bot@kernel.org> Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com> Patchwork: https://patchwork.freedesktop.org/patch/743079/ Message-ID: <20260729155609.20190-2-robin.clark@oss.qualcomm.com>
This commit is contained in:
parent
83723f32cb
commit
ae88499d71
|
|
@ -224,18 +224,19 @@ struct drm_gpuvm *msm_context_vm(struct drm_device *dev, struct msm_context *ctx
|
|||
{
|
||||
static DEFINE_MUTEX(init_lock);
|
||||
struct msm_drm_private *priv = dev->dev_private;
|
||||
struct drm_gpuvm *vm = smp_load_acquire(&ctx->vm);
|
||||
|
||||
/* Once ctx->vm is created it is valid for the lifetime of the context: */
|
||||
if (ctx->vm)
|
||||
return ctx->vm;
|
||||
if (vm)
|
||||
return vm;
|
||||
|
||||
guard(mutex)(&init_lock);
|
||||
|
||||
mutex_lock(&init_lock);
|
||||
if (!ctx->vm) {
|
||||
ctx->vm = msm_gpu_create_private_vm(
|
||||
vm = msm_gpu_create_private_vm(
|
||||
priv->gpu, current, !ctx->userspace_managed_vm);
|
||||
|
||||
smp_store_release(&ctx->vm, vm);
|
||||
}
|
||||
mutex_unlock(&init_lock);
|
||||
|
||||
return ctx->vm;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user