summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-12-02 09:02:29 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-12-02 09:02:28 -0800
commit337e994ce3848bf7885b880d02a2352451e5b774 (patch)
tree57e7b98e4bcdaabbacb30279966c8969eea2ee78 /drivers/gpu
parent79ef4a7206632809dc98d15fa1a02a7381e2ae24 (diff)
parenteed663a48bec729bb66aaad18ab3fac3b7269581 (diff)
Merge "msm: kgsl: Reserve a context ID slot but don't populate immediately"
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/msm/kgsl.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index 6ef542416959..993f22b26294 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -493,21 +493,18 @@ void kgsl_context_dump(struct kgsl_context *context)
EXPORT_SYMBOL(kgsl_context_dump);
/* Allocate a new context ID */
-static int _kgsl_get_context_id(struct kgsl_device *device,
- struct kgsl_context *context)
+static int _kgsl_get_context_id(struct kgsl_device *device)
{
int id;
idr_preload(GFP_KERNEL);
write_lock(&device->context_lock);
- id = idr_alloc(&device->context_idr, context, 1,
+ /* Allocate the slot but don't put a pointer in it yet */
+ id = idr_alloc(&device->context_idr, NULL, 1,
KGSL_MEMSTORE_MAX, GFP_NOWAIT);
write_unlock(&device->context_lock);
idr_preload_end();
- if (id > 0)
- context->id = id;
-
return id;
}
@@ -531,7 +528,7 @@ int kgsl_context_init(struct kgsl_device_private *dev_priv,
char name[64];
int ret = 0, id;
- id = _kgsl_get_context_id(device, context);
+ id = _kgsl_get_context_id(device);
if (id == -ENOSPC) {
/*
* Before declaring that there are no contexts left try
@@ -540,7 +537,7 @@ int kgsl_context_init(struct kgsl_device_private *dev_priv,
*/
flush_workqueue(device->events_wq);
- id = _kgsl_get_context_id(device, context);
+ id = _kgsl_get_context_id(device);
}
if (id < 0) {
@@ -552,6 +549,8 @@ int kgsl_context_init(struct kgsl_device_private *dev_priv,
return id;
}
+ context->id = id;
+
kref_init(&context->refcount);
/*
* Get a refernce to the process private so its not destroyed, until
@@ -1735,6 +1734,12 @@ long kgsl_ioctl_drawctxt_create(struct kgsl_device_private *dev_priv,
goto done;
}
trace_kgsl_context_create(dev_priv->device, context, param->flags);
+
+ /* Commit the pointer to the context in context_idr */
+ write_lock(&device->context_lock);
+ idr_replace(&device->context_idr, context, context->id);
+ write_unlock(&device->context_lock);
+
param->drawctxt_id = context->id;
done:
return result;