* [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function @ 2015-01-04 7:11 Feng Tang 2015-01-04 7:11 ` [PATCH 2/2] staging: android: ion: Add pss info for each ion_client Feng Tang 2015-01-05 14:24 ` [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function One Thousand Gnomes 0 siblings, 2 replies; 7+ messages in thread From: Feng Tang @ 2015-01-04 7:11 UTC (permalink / raw) To: Greg KH, John Stultz Cc: Colin Cross, Heesub Shin, Mitchel Humpherys, linux-kernel, Feng Tang There is user case that user only knows the ion_handle idand needs to get the physical addr and len. So add this wrapper to meet this requirement. Signed-off-by: Feng Tang <feng.tang@intel.com> --- drivers/staging/android/ion/ion.c | 16 ++++++++++++++++ drivers/staging/android/ion/ion.h | 14 ++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 296d347..3d378ef 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -577,6 +577,22 @@ int ion_phys(struct ion_client *client, struct ion_handle *handle, } EXPORT_SYMBOL(ion_phys); +int ion_phys_get_by_id(struct ion_client *client, int id, + ion_phys_addr_t *addr, size_t *len) +{ + struct ion_handle *handle; + int ret; + + handle = ion_handle_get_by_id(client, id); + if (!handle) + return -EINVAL; + + ret = ion_phys(client, handle, addr, len); + ion_handle_put(handle); + return ret; +} +EXPORT_SYMBOL(ion_phys_get_by_id); + static void *ion_buffer_kmap_get(struct ion_buffer *buffer) { void *vaddr; diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index 443db84..9ef0f18 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -147,6 +147,20 @@ int ion_phys(struct ion_client *client, struct ion_handle *handle, ion_phys_addr_t *addr, size_t *len); /** + * ion_phys_get_by_id - returns the physical address and len of a handle + * @client: the client + * @id: id bound to ion_handle, which may be passed to user space + * @addr: a pointer to put the address in + * @len: a pointer to put the length in + * + * This function will first get ion_handle from the id, and then + * use upper ion_phys() to get the physical and len. + */ + +int ion_phys_get_by_id(struct ion_client *client, int id, + ion_phys_addr_t *addr, size_t *len); + +/** * ion_map_dma - return an sg_table describing a handle * @client: the client * @handle: the handle -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] staging: android: ion: Add pss info for each ion_client 2015-01-04 7:11 [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function Feng Tang @ 2015-01-04 7:11 ` Feng Tang 2015-01-05 14:24 ` [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function One Thousand Gnomes 1 sibling, 0 replies; 7+ messages in thread From: Feng Tang @ 2015-01-04 7:11 UTC (permalink / raw) To: Greg KH, John Stultz Cc: Colin Cross, Heesub Shin, Mitchel Humpherys, linux-kernel, Feng Tang In real ION buffer usage, many of the ion buffer are shared by several clients(imported and exported), and current ion debugfs only provides size of all buffers a client may use. This patch will considers the sharing and adds a "pss" info for each ion_client, which will help on profiling the ion memory usage. Actually we can do more aggressively in android world, in which the "surfaceflinger" is a main proxy to help other apps to do the ion buffer allocation, and we can consider this and extract "surfaceflinger" related size out. And this could be the next step. Signed-off-by: Feng Tang <feng.tang@intel.com> --- drivers/staging/android/ion/ion.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 3d378ef..0b8fd56 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1386,18 +1386,25 @@ static const struct file_operations ion_fops = { }; static size_t ion_debug_heap_total(struct ion_client *client, - unsigned int id) + unsigned int id, size_t *psize) { size_t size = 0; struct rb_node *n; + *psize = 0; + mutex_lock(&client->lock); for (n = rb_first(&client->handles); n; n = rb_next(n)) { struct ion_handle *handle = rb_entry(n, struct ion_handle, node); - if (handle->buffer->heap->id == id) + if (handle->buffer->heap->id == id) { size += handle->buffer->size; + if (handle->buffer->handle_count) + *psize += handle->buffer->size / + handle->buffer->handle_count; + } + } mutex_unlock(&client->lock); return size; @@ -1411,13 +1418,15 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) size_t total_size = 0; size_t total_orphaned_size = 0; - seq_printf(s, "%16.s %16.s %16.s\n", "client", "pid", "size"); + seq_printf(s, "%16.s %16.s %16.s %16.s\n", + "client", "pid", "size", "psize"); seq_puts(s, "----------------------------------------------------\n"); for (n = rb_first(&dev->clients); n; n = rb_next(n)) { struct ion_client *client = rb_entry(n, struct ion_client, node); - size_t size = ion_debug_heap_total(client, heap->id); + size_t psize; + size_t size = ion_debug_heap_total(client, heap->id, &psize); if (!size) continue; @@ -1425,11 +1434,11 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) char task_comm[TASK_COMM_LEN]; get_task_comm(task_comm, client->task); - seq_printf(s, "%16.s %16u %16zu\n", task_comm, - client->pid, size); + seq_printf(s, "%16.s %16u %16zu %16zu\n", task_comm, + client->pid, size, psize); } else { - seq_printf(s, "%16.s %16u %16zu\n", client->name, - client->pid, size); + seq_printf(s, "%16.s %16u %16zu %16zu\n", client->name, + client->pid, size, psize); } } seq_puts(s, "----------------------------------------------------\n"); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function 2015-01-04 7:11 [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function Feng Tang 2015-01-04 7:11 ` [PATCH 2/2] staging: android: ion: Add pss info for each ion_client Feng Tang @ 2015-01-05 14:24 ` One Thousand Gnomes 2015-01-05 15:51 ` Tang, Feng 1 sibling, 1 reply; 7+ messages in thread From: One Thousand Gnomes @ 2015-01-05 14:24 UTC (permalink / raw) To: Feng Tang Cc: Greg KH, John Stultz, Colin Cross, Heesub Shin, Mitchel Humpherys, linux-kernel On Sun, 4 Jan 2015 15:11:51 +0800 Feng Tang <feng.tang@intel.com> wrote: > There is user case that user only knows the ion_handle idand > needs to get the physical addr and len. So add this wrapper to > meet this requirement. What is the in-tree upstream user of this new function ? I don't see one in your patches ? Alan ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function 2015-01-05 14:24 ` [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function One Thousand Gnomes @ 2015-01-05 15:51 ` Tang, Feng 2015-01-18 0:04 ` Greg KH 0 siblings, 1 reply; 7+ messages in thread From: Tang, Feng @ 2015-01-05 15:51 UTC (permalink / raw) To: One Thousand Gnomes Cc: Greg KH, John Stultz, Colin Cross, Heesub Shin, Mitchel Humpherys, linux-kernel@vger.kernel.org Hi Alan, Thanks for the review. > -----Original Message----- > From: One Thousand Gnomes [mailto:gnomes@lxorguk.ukuu.org.uk] > Sent: Monday, January 05, 2015 10:25 PM > To: Tang, Feng > Cc: Greg KH; John Stultz; Colin Cross; Heesub Shin; Mitchel Humpherys; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id > function > > On Sun, 4 Jan 2015 15:11:51 +0800 > Feng Tang <feng.tang@intel.com> wrote: > > > There is user case that user only knows the ion_handle idand > > needs to get the physical addr and len. So add this wrapper to > > meet this requirement. > > What is the in-tree upstream user of this new function ? I don't see one > in your patches ? That's true. We are working on enabling a new platform which heavily uses ION and some driver needs to use this API, so I guess there is some other plaforms may have the similar requirements. If you think this patch should be merged after there is an in-tree user, I'm OK with it :) I assume that driver's author will start to push his drivers in batch soon. Thanks, Feng ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function 2015-01-05 15:51 ` Tang, Feng @ 2015-01-18 0:04 ` Greg KH 2015-01-19 1:14 ` Tang, Feng 0 siblings, 1 reply; 7+ messages in thread From: Greg KH @ 2015-01-18 0:04 UTC (permalink / raw) To: Tang, Feng Cc: One Thousand Gnomes, John Stultz, Colin Cross, Heesub Shin, Mitchel Humpherys, linux-kernel@vger.kernel.org On Mon, Jan 05, 2015 at 03:51:54PM +0000, Tang, Feng wrote: > Hi Alan, > > Thanks for the review. > > > -----Original Message----- > > From: One Thousand Gnomes [mailto:gnomes@lxorguk.ukuu.org.uk] > > Sent: Monday, January 05, 2015 10:25 PM > > To: Tang, Feng > > Cc: Greg KH; John Stultz; Colin Cross; Heesub Shin; Mitchel Humpherys; > > linux-kernel@vger.kernel.org > > Subject: Re: [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id > > function > > > > On Sun, 4 Jan 2015 15:11:51 +0800 > > Feng Tang <feng.tang@intel.com> wrote: > > > > > There is user case that user only knows the ion_handle idand > > > needs to get the physical addr and len. So add this wrapper to > > > meet this requirement. > > > > What is the in-tree upstream user of this new function ? I don't see one > > in your patches ? > > That's true. We are working on enabling a new platform which heavily > uses ION and some driver needs to use this API, so I guess there is some > other plaforms may have the similar requirements. If you think this patch > should be merged after there is an in-tree user, I'm OK with it :) > > I assume that driver's author will start to push his drivers in batch soon. We need to see those patches first, we can't add apis for no in-tree user, otherwise they will just get ripped out. thanks, greg k-h ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function 2015-01-18 0:04 ` Greg KH @ 2015-01-19 1:14 ` Tang, Feng 2015-01-19 1:58 ` Greg KH 0 siblings, 1 reply; 7+ messages in thread From: Tang, Feng @ 2015-01-19 1:14 UTC (permalink / raw) To: Greg KH Cc: One Thousand Gnomes, John Stultz, Colin Cross, Heesub Shin, Mitchel Humpherys, linux-kernel@vger.kernel.org Hi Greg, Thanks for your review. > -----Original Message----- > From: Greg KH [mailto:gregkh@linuxfoundation.org] > Sent: Sunday, January 18, 2015 8:04 AM > To: Tang, Feng > Cc: One Thousand Gnomes; John Stultz; Colin Cross; Heesub Shin; Mitchel > Humpherys; linux-kernel@vger.kernel.org > Subject: Re: [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id > function > > > > > > > On Sun, 4 Jan 2015 15:11:51 +0800 > > > Feng Tang <feng.tang@intel.com> wrote: > > > > > > > There is user case that user only knows the ion_handle idand > > > > needs to get the physical addr and len. So add this wrapper to > > > > meet this requirement. > > > > > > What is the in-tree upstream user of this new function ? I don't see one > > > in your patches ? > > > > That's true. We are working on enabling a new platform which heavily > > uses ION and some driver needs to use this API, so I guess there is some > > other plaforms may have the similar requirements. If you think this patch > > should be merged after there is an in-tree user, I'm OK with it :) > > > > I assume that driver's author will start to push his drivers in batch soon. > > We need to see those patches first, we can't add apis for no in-tree > user, otherwise they will just get ripped out. I see. I'll repost this patch after our "user" driver get merged. How about the 2/2 patch, which improve the profiling info through debugfs? [PATCH 2/2] staging: android: ion: Add pss info for each ion_client Thanks, Feng ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function 2015-01-19 1:14 ` Tang, Feng @ 2015-01-19 1:58 ` Greg KH 0 siblings, 0 replies; 7+ messages in thread From: Greg KH @ 2015-01-19 1:58 UTC (permalink / raw) To: Tang, Feng Cc: One Thousand Gnomes, John Stultz, Colin Cross, Heesub Shin, Mitchel Humpherys, linux-kernel@vger.kernel.org On Mon, Jan 19, 2015 at 01:14:49AM +0000, Tang, Feng wrote: > Hi Greg, > > Thanks for your review. > > > -----Original Message----- > > From: Greg KH [mailto:gregkh@linuxfoundation.org] > > Sent: Sunday, January 18, 2015 8:04 AM > > To: Tang, Feng > > Cc: One Thousand Gnomes; John Stultz; Colin Cross; Heesub Shin; Mitchel > > Humpherys; linux-kernel@vger.kernel.org > > Subject: Re: [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id > > function > > > > > > > > > > On Sun, 4 Jan 2015 15:11:51 +0800 > > > > Feng Tang <feng.tang@intel.com> wrote: > > > > > > > > > There is user case that user only knows the ion_handle idand > > > > > needs to get the physical addr and len. So add this wrapper to > > > > > meet this requirement. > > > > > > > > What is the in-tree upstream user of this new function ? I don't see one > > > > in your patches ? > > > > > > That's true. We are working on enabling a new platform which heavily > > > uses ION and some driver needs to use this API, so I guess there is some > > > other plaforms may have the similar requirements. If you think this patch > > > should be merged after there is an in-tree user, I'm OK with it :) > > > > > > I assume that driver's author will start to push his drivers in batch soon. > > > > We need to see those patches first, we can't add apis for no in-tree > > user, otherwise they will just get ripped out. > I see. I'll repost this patch after our "user" driver get merged. > > How about the 2/2 patch, which improve the profiling info through > debugfs? > [PATCH 2/2] staging: android: ion: Add pss info for each ion_client I don't see it in my queue anywhere, sorry, feel free to resend it. thanks, greg k-h ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-01-19 2:02 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-01-04 7:11 [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function Feng Tang 2015-01-04 7:11 ` [PATCH 2/2] staging: android: ion: Add pss info for each ion_client Feng Tang 2015-01-05 14:24 ` [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function One Thousand Gnomes 2015-01-05 15:51 ` Tang, Feng 2015-01-18 0:04 ` Greg KH 2015-01-19 1:14 ` Tang, Feng 2015-01-19 1:58 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox