linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] staging: android: ion: Minor clean ups and fixes
@ 2017-05-17  8:15 Archit Taneja
  2017-05-17  8:15 ` [PATCH 1/3] staging: android: ion: Remove unused members from ion_buffer Archit Taneja
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Archit Taneja @ 2017-05-17  8:15 UTC (permalink / raw)
  To: labbott, sumit.semwal
  Cc: gregkh, linux-kernel, devel, dri-devel, 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

 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] staging: android: ion: Remove unused members from ion_buffer
  2017-05-17  8:15 [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Archit Taneja
@ 2017-05-17  8:15 ` Archit Taneja
  2017-05-17  8:15 ` [PATCH 2/3] staging: android: ion: Remove ION_FLAG_CACHED_NEEDS_SYNC Archit Taneja
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Archit Taneja @ 2017-05-17  8:15 UTC (permalink / raw)
  To: labbott, sumit.semwal
  Cc: gregkh, linux-kernel, devel, dri-devel, Archit Taneja

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.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/staging/android/ion/ion.c |  2 --
 drivers/staging/android/ion/ion.h | 14 --------------
 2 files changed, 16 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 03d3a4fce0e2..90ae6ce466ed 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -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);
 }
 
diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
index ace8416bd509..fa9ed81ab972 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -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);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] staging: android: ion: Remove ION_FLAG_CACHED_NEEDS_SYNC
  2017-05-17  8:15 [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Archit Taneja
  2017-05-17  8:15 ` [PATCH 1/3] staging: android: ion: Remove unused members from ion_buffer Archit Taneja
@ 2017-05-17  8:15 ` Archit Taneja
  2017-05-17  8:15 ` [PATCH 3/3] staging: android: ion: Avoid calling free_duped_table() twice Archit Taneja
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Archit Taneja @ 2017-05-17  8:15 UTC (permalink / raw)
  To: labbott, sumit.semwal
  Cc: gregkh, linux-kernel, devel, dri-devel, Archit Taneja

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

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/staging/android/uapi/ion.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h
index b76db1b2e197..d415589757e7 100644
--- a/drivers/staging/android/uapi/ion.h
+++ b/drivers/staging/android/uapi/ion.h
@@ -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
  *
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] staging: android: ion: Avoid calling free_duped_table() twice
  2017-05-17  8:15 [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Archit Taneja
  2017-05-17  8:15 ` [PATCH 1/3] staging: android: ion: Remove unused members from ion_buffer Archit Taneja
  2017-05-17  8:15 ` [PATCH 2/3] staging: android: ion: Remove ION_FLAG_CACHED_NEEDS_SYNC Archit Taneja
@ 2017-05-17  8:15 ` Archit Taneja
  2017-05-17 16:39 ` [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Laura Abbott
  2017-05-18  4:40 ` Sumit Semwal
  4 siblings, 0 replies; 6+ messages in thread
From: Archit Taneja @ 2017-05-17  8:15 UTC (permalink / raw)
  To: labbott, sumit.semwal
  Cc: gregkh, linux-kernel, devel, dri-devel, 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.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/staging/android/ion/ion.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 90ae6ce466ed..b483e1081309 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -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,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] staging: android: ion: Minor clean ups and fixes
  2017-05-17  8:15 [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Archit Taneja
                   ` (2 preceding siblings ...)
  2017-05-17  8:15 ` [PATCH 3/3] staging: android: ion: Avoid calling free_duped_table() twice Archit Taneja
@ 2017-05-17 16:39 ` Laura Abbott
  2017-05-18  4:40 ` Sumit Semwal
  4 siblings, 0 replies; 6+ messages in thread
From: Laura Abbott @ 2017-05-17 16:39 UTC (permalink / raw)
  To: Archit Taneja, sumit.semwal; +Cc: gregkh, linux-kernel, devel, dri-devel

On 05/17/2017 01:15 AM, Archit Taneja wrote:
> 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(-)
> 

Acked-by: Laura Abbott <labbott@redhat.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] staging: android: ion: Minor clean ups and fixes
  2017-05-17  8:15 [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Archit Taneja
                   ` (3 preceding siblings ...)
  2017-05-17 16:39 ` [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Laura Abbott
@ 2017-05-18  4:40 ` Sumit Semwal
  4 siblings, 0 replies; 6+ messages in thread
From: Sumit Semwal @ 2017-05-18  4:40 UTC (permalink / raw)
  To: Archit Taneja
  Cc: Laura Abbott, Greg Kroah-Hartman, LKML, devel, DRI mailing list

Hi Archit,

On 17 May 2017 at 13:45, Archit Taneja <architt@codeaurora.org> wrote:
> 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
Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org>

>  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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-18  4:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17  8:15 [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Archit Taneja
2017-05-17  8:15 ` [PATCH 1/3] staging: android: ion: Remove unused members from ion_buffer Archit Taneja
2017-05-17  8:15 ` [PATCH 2/3] staging: android: ion: Remove ION_FLAG_CACHED_NEEDS_SYNC Archit Taneja
2017-05-17  8:15 ` [PATCH 3/3] staging: android: ion: Avoid calling free_duped_table() twice Archit Taneja
2017-05-17 16:39 ` [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Laura Abbott
2017-05-18  4:40 ` Sumit Semwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).