Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1426752 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: kgsl: Correctly limit max number of contexts per process"

parents 08481074 b210e6e0
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -532,14 +532,21 @@ int kgsl_context_init(struct kgsl_device_private *dev_priv,
	int ret = 0, id;
	struct kgsl_process_private  *proc_priv = dev_priv->process_priv;

	/*
	 * Read and increment the context count under lock to make sure
	 * no process goes beyond the specified context limit.
	 */
	spin_lock(&proc_priv->ctxt_count_lock);
	if (atomic_read(&proc_priv->ctxt_count) > KGSL_MAX_CONTEXTS_PER_PROC) {
		KGSL_DRV_ERR(device,
			"Per process context limit reached for pid %u",
			dev_priv->process_priv->pid);
		spin_unlock(&proc_priv->ctxt_count_lock);
		return -ENOSPC;
	}

	atomic_inc(&proc_priv->ctxt_count);
	spin_unlock(&proc_priv->ctxt_count_lock);

	id = _kgsl_get_context_id(device);
	if (id == -ENOSPC) {
@@ -919,6 +926,7 @@ static struct kgsl_process_private *kgsl_process_private_new(

	spin_lock_init(&private->mem_lock);
	spin_lock_init(&private->syncsource_lock);
	spin_lock_init(&private->ctxt_count_lock);

	idr_init(&private->mem_idr);
	idr_init(&private->syncsource_idr);
+2 −0
Original line number Diff line number Diff line
@@ -443,6 +443,7 @@ struct kgsl_context {
 * @syncsource_lock: Spinlock to protect the syncsource idr
 * @fd_count: Counter for the number of FDs for this process
 * @ctxt_count: Count for the number of contexts for this process
 * @ctxt_count_lock: Spinlock to protect ctxt_count
 */
struct kgsl_process_private {
	unsigned long priv;
@@ -463,6 +464,7 @@ struct kgsl_process_private {
	spinlock_t syncsource_lock;
	int fd_count;
	atomic_t ctxt_count;
	spinlock_t ctxt_count_lock;
};

/**