Skip to contentSkip to conversation

staging: android: ion: Minor clean ups and fixes

PATCH In review Archit Taneja 3 participants 6 messages May 17, 2017 – May 18, 2017 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: android: ion: Minor clean ups and fixes

The recent ION clean ups introduced some leftover code that can be removed, and a bug that comes up if the call to dma_buf_map_attachment() from an importer fails. Fix these.

Archit Taneja (3):
staging: android: ion: Remove unused members from ion_buffer
staging: android: ion: Remove ION_FLAG_CACHED_NEEDS_SYNC
staging: android: ion: Avoid calling free_duped_table() twice

 drivers/staging/android/ion/ion.c  | 14 +++-----------
 drivers/staging/android/ion/ion.h  | 14 --------------
 drivers/staging/android/uapi/ion.h |  6 ------
 3 files changed, 3 insertions(+), 31 deletions(-)
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 1/3 staging: android: ion: Remove unused members from ion_buffer

A few members in ion_buffer struct are unused after features like page faulting, ion_handle and ion_client were removed. Remove these members and the leftover references to them.

---
 drivers/staging/android/ion/ion.c |  2 --
 drivers/staging/android/ion/ion.h | 14 --------------
 2 files changed, 16 deletions(-)
drivers/staging/android/ion/ion.c +0 -2
index 03d3a4fce0e2..90ae6ce466ed 100644
@@ -115,7 +115,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 
 	buffer->dev = dev;
 	buffer->size = len;
-	INIT_LIST_HEAD(&buffer->vmas);
 	INIT_LIST_HEAD(&buffer->attachments);
 	mutex_init(&buffer->lock);
 	mutex_lock(&dev->buffer_lock);
@@ -135,7 +134,6 @@ void ion_buffer_destroy(struct ion_buffer *buffer)
 	if (WARN_ON(buffer->kmap_cnt > 0))
 		buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
 	buffer->heap->ops->free(buffer);
-	vfree(buffer->pages);
 	kfree(buffer);
 }
 
drivers/staging/android/ion/ion.h +0 -14
index ace8416bd509..fa9ed81ab972 100644
@@ -68,14 +68,6 @@ struct ion_platform_heap {
  * @kmap_cnt:		number of times the buffer is mapped to the kernel
  * @vaddr:		the kernel mapping if kmap_cnt is not zero
  * @sg_table:		the sg table for the buffer if dmap_cnt is not zero
- * @pages:		flat array of pages in the buffer -- used by fault
- *			handler and only valid for buffers that are faulted in
- * @vmas:		list of vma's mapping this buffer
- * @handle_count:	count of handles referencing this buffer
- * @task_comm:		taskcomm of last client to reference this buffer in a
- *			handle, used for debugging
- * @pid:		pid of last client to reference this buffer in a
- *			handle, used for debugging
  */
 struct ion_buffer {
 	union {
@@ -92,13 +84,7 @@ struct ion_buffer {
 	int kmap_cnt;
 	void *vaddr;
 	struct sg_table *sg_table;
-	struct page **pages;
-	struct list_head vmas;
 	struct list_head attachments;
-	/* used to track orphaned buffers */
-	int handle_count;
-	char task_comm[TASK_COMM_LEN];
-	pid_t pid;
 };
 void ion_buffer_destroy(struct ion_buffer *buffer);
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#2 lore raw

PATCH 2/3 staging: android: ion: Remove ION_FLAG_CACHED_NEEDS_SYNC

In reply to Archit Taneja

The flag ION_FLAG_CACHED_NEEDS_SYNC isn't used anymore. Remove it.

---
 drivers/staging/android/uapi/ion.h | 6 ------
 1 file changed, 6 deletions(-)
drivers/staging/android/uapi/ion.h +0 -6
index b76db1b2e197..d415589757e7 100644
@@ -57,12 +57,6 @@ enum ion_heap_type {
  */
 #define ION_FLAG_CACHED 1
 
-/*
- * mappings of this buffer will created at mmap time, if this is set
- * caches must be managed manually
- */
-#define ION_FLAG_CACHED_NEEDS_SYNC 2
-
 /**
  * DOC: Ion Userspace API
  *
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 3/3 staging: android: ion: Avoid calling free_duped_table() twice

In reply to Archit Taneja

Currently, the duplicated sg table is freed in the detach() and the error path of map_dma_buf() ion's dma_buf_ops.

If a call to dma_buf_map_attachment() fails, the importer is expected to call dma_buf_detach() to remove the attachment. This will result in us trying to free the duped sg table twice.

Don't call free_duped_table() in ion_map_dma_buf() to avoid this.

---
 drivers/staging/android/ion/ion.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/staging/android/ion/ion.c +3 -9
index 90ae6ce466ed..b483e1081309 100644
@@ -268,20 +268,14 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
 {
 	struct ion_dma_buf_attachment *a = attachment->priv;
 	struct sg_table *table;
-	int ret;
 
 	table = a->table;
 
 	if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
-			direction)){
-		ret = -ENOMEM;
-		goto err;
-	}
-	return table;
+			direction))
+		return ERR_PTR(-ENOMEM);
 
-err:
-	free_duped_table(table);
-	return ERR_PTR(ret);
+	return table;
 }
 
 static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on the v1 series
#4 lore raw
In reply to Archit Taneja
Quoted 9 lines · Archit Taneja

The recent ION clean ups introduced some leftover code that can be removed, and a bug that comes up if the call to dma_buf_map_attachment() from an importer fails. Fix these.

Archit Taneja (3):
staging: android: ion: Remove unused members from ion_buffer
staging: android: ion: Remove ION_FLAG_CACHED_NEEDS_SYNC
staging: android: ion: Avoid calling free_duped_table() twice

Quoted 5 lines
 drivers/staging/android/ion/ion.c  | 14 +++-----------
 drivers/staging/android/ion/ion.h  | 14 --------------
 drivers/staging/android/uapi/ion.h |  6 ------
 3 files changed, 3 insertions(+), 31 deletions(-)

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on the v1 series
#5 lore raw
In reply to Archit Taneja

Hi Archit,

Quoted 9 lines · Archit Taneja

The recent ION clean ups introduced some leftover code that can be removed, and a bug that comes up if the call to dma_buf_map_attachment() from an importer fails. Fix these.

Archit Taneja (3):
staging: android: ion: Remove unused members from ion_buffer
staging: android: ion: Remove ION_FLAG_CACHED_NEEDS_SYNC
staging: android: ion: Avoid calling free_duped_table() twice

Thanks for these patches! Please feel free to add my

Quoted 9 lines
 drivers/staging/android/ion/ion.c  | 14 +++-----------
 drivers/staging/android/ion/ion.h  | 14 --------------
 drivers/staging/android/uapi/ion.h |  6 ------
 3 files changed, 3 insertions(+), 31 deletions(-)

--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation

Best,
Sumit.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel