msm: kgsl: Store process private pointer in context
Store the process private pointer in the context. Earlier the process
private pointer was referenced through the dev_priv pointer in the
context, but the dev_priv pointer can be destroyed before the context
process private so store this pointer locally.
Change-Id: Ic07680b79db55d6306306bd61bda5a1288813914
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c
index 6988ee7..f2a0999 100644
--- a/drivers/gpu/msm/adreno.c
+++ b/drivers/gpu/msm/adreno.c
@@ -2497,7 +2497,8 @@
if (context == NULL)
break;
- if (kgsl_mmu_pt_equal(&device->mmu, context->pagetable,
+ if (kgsl_mmu_pt_equal(&device->mmu,
+ context->proc_priv->pagetable,
pt_base)) {
struct adreno_context *adreno_context;
diff --git a/drivers/gpu/msm/adreno_a2xx.c b/drivers/gpu/msm/adreno_a2xx.c
index cce4f91..ec4380e 100644
--- a/drivers/gpu/msm/adreno_a2xx.c
+++ b/drivers/gpu/msm/adreno_a2xx.c
@@ -1355,7 +1355,8 @@
tmp_ctx.gmem_base = adreno_dev->gmem_base;
result = kgsl_allocate(&drawctxt->context_gmem_shadow.gmemshadow,
- drawctxt->base.pagetable, drawctxt->context_gmem_shadow.size);
+ drawctxt->base.proc_priv->pagetable,
+ drawctxt->context_gmem_shadow.size);
if (result)
return result;
@@ -1410,7 +1411,7 @@
*/
ret = kgsl_allocate(&drawctxt->gpustate,
- drawctxt->base.pagetable, _context_size(adreno_dev));
+ drawctxt->base.proc_priv->pagetable, _context_size(adreno_dev));
if (ret)
return ret;
@@ -1629,7 +1630,7 @@
if (ret)
return ret;
- kgsl_mmu_setstate(&device->mmu, context->base.pagetable,
+ kgsl_mmu_setstate(&device->mmu, context->base.proc_priv->pagetable,
context->base.id);
/* restore gmem.
diff --git a/drivers/gpu/msm/adreno_a3xx.c b/drivers/gpu/msm/adreno_a3xx.c
index 856b90b..6a484a8 100644
--- a/drivers/gpu/msm/adreno_a3xx.c
+++ b/drivers/gpu/msm/adreno_a3xx.c
@@ -2321,7 +2321,8 @@
tmp_ctx.gmem_base = adreno_dev->gmem_base;
result = kgsl_allocate(&drawctxt->context_gmem_shadow.gmemshadow,
- drawctxt->base.pagetable, drawctxt->context_gmem_shadow.size);
+ drawctxt->base.proc_priv->pagetable,
+ drawctxt->context_gmem_shadow.size);
if (result)
return result;
@@ -2355,7 +2356,7 @@
*/
ret = kgsl_allocate(&drawctxt->gpustate,
- drawctxt->base.pagetable, CONTEXT_SIZE);
+ drawctxt->base.proc_priv->pagetable, CONTEXT_SIZE);
if (ret)
return ret;
@@ -2478,7 +2479,7 @@
if (ret)
return ret;
- kgsl_mmu_setstate(&device->mmu, context->base.pagetable,
+ kgsl_mmu_setstate(&device->mmu, context->base.proc_priv->pagetable,
context->base.id);
/*
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index fc92ea0..fc94225 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -459,8 +459,8 @@
if (!kref_get_unless_zero(&dev_priv->process_priv->refcount))
goto fail_free_id;
context->device = dev_priv->device;
- context->pagetable = dev_priv->process_priv->pagetable;
context->dev_priv = dev_priv;
+ context->proc_priv = dev_priv->process_priv;
context->pid = task_tgid_nr(current);
context->tid = task_pid_nr(current);
@@ -552,7 +552,7 @@
write_unlock(&device->context_lock);
kgsl_sync_timeline_destroy(context);
kgsl_put_process_private(device,
- context->dev_priv->process_priv);
+ context->proc_priv);
device->ftbl->drawctxt_destroy(context);
}
diff --git a/drivers/gpu/msm/kgsl_device.h b/drivers/gpu/msm/kgsl_device.h
index e907f3c..4dcffcb 100644
--- a/drivers/gpu/msm/kgsl_device.h
+++ b/drivers/gpu/msm/kgsl_device.h
@@ -325,6 +325,7 @@
/* the context has caused a pagefault */
#define KGSL_CONTEXT_PAGEFAULT 1
+struct kgsl_process_private;
/**
* struct kgsl_context - Master structure for a KGSL context object
* @refcount: kref object for reference counting the context
@@ -351,9 +352,9 @@
pid_t pid;
pid_t tid;
struct kgsl_device_private *dev_priv;
+ struct kgsl_process_private *proc_priv;
unsigned long priv;
struct kgsl_device *device;
- struct kgsl_pagetable *pagetable;
unsigned int reset_status;
bool wait_on_invalid_ts;
struct sync_timeline *timeline;