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

Commit f43806fb authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: kgsl: Use a lock when updating the sparse bindings"

parents cb474c53 ccd73c76
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -3439,6 +3439,7 @@ long kgsl_ioctl_sparse_virt_free(struct kgsl_device_private *dev_priv,
	return 0;
}

/* entry->bind_lock must be held by the caller */
static int _sparse_add_to_bind_tree(struct kgsl_mem_entry *entry,
		uint64_t v_offset,
		struct kgsl_memdesc *memdesc,
@@ -3467,10 +3468,16 @@ static int _sparse_add_to_bind_tree(struct kgsl_mem_entry *entry,
		parent = *node;
		this = rb_entry(parent, struct sparse_bind_object, node);

		if (new->v_off < this->v_off)
		if ((new->v_off < this->v_off) &&
			((new->v_off + new->size) <= this->v_off))
			node = &parent->rb_left;
		else if (new->v_off > this->v_off)
		else if ((new->v_off > this->v_off) &&
			(new->v_off >= (this->v_off + this->size)))
			node = &parent->rb_right;
		else {
			kfree(new);
			return -EADDRINUSE;
		}
	}

	rb_link_node(&new->node, parent, node);
@@ -3691,8 +3698,11 @@ static int _sparse_bind(struct kgsl_process_private *process,
		return ret;
	}

	spin_lock(&virt_entry->bind_lock);
	ret = _sparse_add_to_bind_tree(virt_entry, v_offset, memdesc,
			p_offset, size, flags);
	spin_unlock(&virt_entry->bind_lock);

	if (ret == 0)
		memdesc->cur_bindings += size / PAGE_SIZE;