Commit df86cdc5 authored by JiangShui Yang's avatar JiangShui Yang Committed by JiangShui
Browse files

Revert "uacce: use filep->f_mapping to replace inode->i_mapping"

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I87RJC


CVE: NA

----------------------------------------------------------------------

This reverts commit f29efbf3.
Use q->mapping instead of q->private_date to transfer parameters

Signed-off-by: default avatarJiangShui Yang <yangjiangshui@h-partners.com>
parent 22cb1432
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -349,8 +349,8 @@ static int uacce_fops_open(struct inode *inode, struct file *filep)

	init_waitqueue_head(&q->wait);
	filep->private_data = q;
	uacce->inode = inode;
	q->state = UACCE_Q_INIT;
	q->private_data = filep;
	mutex_init(&q->mutex);
	list_add(&q->list, &uacce->queues);
	mutex_unlock(&uacce->mutex);
@@ -1038,6 +1038,12 @@ void uacce_remove(struct uacce_device *uacce)

	if (!uacce)
		return;
	/*
	 * unmap remaining mapping from user space, preventing user still
	 * access the mmaped area while parent device is already removed
	 */
	if (uacce->inode)
		unmap_mapping_range(uacce->inode->i_mapping, 0, 0, 1);

	/*
	 * uacce_fops_open() may be running concurrently, even after we remove
@@ -1047,8 +1053,6 @@ void uacce_remove(struct uacce_device *uacce)
	mutex_lock(&uacce->mutex);
	/* ensure no open queue remains */
	list_for_each_entry_safe(q, next_q, &uacce->queues, list) {
		struct file *filep = q->private_data;

		/*
		 * Taking q->mutex ensures that fops do not use the defunct
		 * uacce->ops after the queue is disabled.
@@ -1057,12 +1061,6 @@ void uacce_remove(struct uacce_device *uacce)
		uacce_put_queue(q);
		mutex_unlock(&q->mutex);
		uacce_unbind_queue(q);

		/*
		 * unmap remaining mapping from user space, preventing user still
		 * access the mmaped area while parent device is already removed
		 */
		unmap_mapping_range(filep->f_mapping, 0, 0, 1);
	}

	/* disable sva now since no opened queues */
+2 −2
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@ enum uacce_q_state {
 * @state: queue state machine
 * @pasid: pasid associated to the mm
 * @handle: iommu_sva handle returned by iommu_sva_bind_device()
 * @private_data: private data for saving filep
 */
struct uacce_queue {
	struct uacce_device *uacce;
@@ -130,7 +129,6 @@ struct uacce_queue {
	enum uacce_q_state state;
	u32 pasid;
	struct iommu_sva *handle;
	void *private_data;
};

/**
@@ -148,6 +146,7 @@ struct uacce_queue {
 * @mutex: protects uacce operation
 * @priv: private pointer of the uacce
 * @queues: list of queues
 * @inode: core vfs
 */
struct uacce_device {
	const char *algs;
@@ -165,6 +164,7 @@ struct uacce_device {
	void *priv;
	struct uacce_err_isolate *isolate;
	struct list_head queues;
	struct inode *inode;
};

#if IS_ENABLED(CONFIG_UACCE)