LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] dma_heap: use sg_table.orig_nents in sg_table release flow
@ 2021-11-25 12:46 guangming.cao
  2021-11-25 13:28 ` Robin Murphy
  0 siblings, 1 reply; 11+ messages in thread
From: guangming.cao @ 2021-11-25 12:46 UTC (permalink / raw)
  To: Sumit Semwal, Benjamin Gaignard, Liam Mark, Laura Abbott,
	Brian Starkey, John Stultz, Christian König,
	Matthias Brugger, open list:DMA-BUF HEAPS FRAMEWORK,
	open list:DMA-BUF HEAPS FRAMEWORK,
	moderated list:DMA-BUF HEAPS FRAMEWORK, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support
  Cc: wsd_upstream, Guangming

From: Guangming <Guangming.Cao@mediatek.com>

Use (sg_table.orig_nents) rather than (sg_table.nents) to traverse
sg_table to free sg_table.
Use (sg_table.nents) maybe will casuse some pages can't be freed.

Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
---
 drivers/dma-buf/heaps/system_heap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
index 23a7e74ef966..ce10d4eb674c 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
 	int i;
 
 	table = &buffer->sg_table;
-	for_each_sg(table->sgl, sg, table->nents, i) {
+	for_each_sg(table->sgl, sg, table->orig_nents, i) {
 		struct page *page = sg_page(sg);
 
 		__free_pages(page, compound_order(page));
-- 
2.17.1


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

* Re: [PATCH] dma_heap: use sg_table.orig_nents in sg_table release flow
  2021-11-25 12:46 [PATCH] dma_heap: use sg_table.orig_nents in sg_table release flow guangming.cao
@ 2021-11-25 13:28 ` Robin Murphy
  2021-11-25 13:49   ` [PATCH v2] dma_heap: use for_each_sgtable_sg " guangming.cao
  0 siblings, 1 reply; 11+ messages in thread
From: Robin Murphy @ 2021-11-25 13:28 UTC (permalink / raw)
  To: guangming.cao, Sumit Semwal, Benjamin Gaignard, Liam Mark,
	Laura Abbott, Brian Starkey, John Stultz, Christian König,
	Matthias Brugger, open list:DMA-BUF HEAPS FRAMEWORK,
	open list:DMA-BUF HEAPS FRAMEWORK,
	moderated list:DMA-BUF HEAPS FRAMEWORK, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support
  Cc: wsd_upstream

On 2021-11-25 12:46, guangming.cao@mediatek.com wrote:
> From: Guangming <Guangming.Cao@mediatek.com>
> 
> Use (sg_table.orig_nents) rather than (sg_table.nents) to traverse
> sg_table to free sg_table.
> Use (sg_table.nents) maybe will casuse some pages can't be freed.

...and this sort of bug is precisely why we have the 
for_each_sgtable_sg() helper ;)

Robin.

> Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
> ---
>   drivers/dma-buf/heaps/system_heap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
> index 23a7e74ef966..ce10d4eb674c 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
> @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
>   	int i;
>   
>   	table = &buffer->sg_table;
> -	for_each_sg(table->sgl, sg, table->nents, i) {
> +	for_each_sg(table->sgl, sg, table->orig_nents, i) {
>   		struct page *page = sg_page(sg);
>   
>   		__free_pages(page, compound_order(page));
> 

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

* [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow
  2021-11-25 13:28 ` Robin Murphy
@ 2021-11-25 13:49   ` guangming.cao
  2021-11-25 14:08     ` Robin Murphy
  2021-11-25 14:38     ` [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow Kuan-Ying Lee
  0 siblings, 2 replies; 11+ messages in thread
From: guangming.cao @ 2021-11-25 13:49 UTC (permalink / raw)
  To: robin.murphy
  Cc: Brian.Starkey, benjamin.gaignard, christian.koenig, dri-devel,
	guangming.cao, john.stultz, labbott, linaro-mm-sig,
	linux-arm-kernel, linux-kernel, linux-media, linux-mediatek,
	lmark, matthias.bgg, sumit.semwal, wsd_upstream, Guangming

From: Guangming <Guangming.Cao@mediatek.com>

Use (for_each_sgtable_sg) rather than (for_each_sg) to traverse
sg_table to free sg_table.
Use (for_each_sg) maybe will casuse some pages can't be freed
when send wrong nents number.

Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
---
 drivers/dma-buf/heaps/system_heap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
index 23a7e74ef966..8660508f3684 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
 	int i;
 
 	table = &buffer->sg_table;
-	for_each_sg(table->sgl, sg, table->nents, i) {
+	for_each_sgtable_sg(table, sg, i) {
 		struct page *page = sg_page(sg);
 
 		__free_pages(page, compound_order(page));
-- 
2.17.1


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

* Re: [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow
  2021-11-25 13:49   ` [PATCH v2] dma_heap: use for_each_sgtable_sg " guangming.cao
@ 2021-11-25 14:08     ` Robin Murphy
  2021-11-26  3:16       ` [PATCH v3] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow guangming.cao
  2021-11-25 14:38     ` [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow Kuan-Ying Lee
  1 sibling, 1 reply; 11+ messages in thread
From: Robin Murphy @ 2021-11-25 14:08 UTC (permalink / raw)
  To: guangming.cao
  Cc: Brian.Starkey, benjamin.gaignard, christian.koenig, dri-devel,
	john.stultz, labbott, linaro-mm-sig, linux-arm-kernel,
	linux-kernel, linux-media, linux-mediatek, lmark, matthias.bgg,
	sumit.semwal, wsd_upstream

On 2021-11-25 13:49, guangming.cao@mediatek.com wrote:
> From: Guangming <Guangming.Cao@mediatek.com>
> 
> Use (for_each_sgtable_sg) rather than (for_each_sg) to traverse
> sg_table to free sg_table.
> Use (for_each_sg) maybe will casuse some pages can't be freed
> when send wrong nents number.

It's still worth spelling out that this is fixing a bug where the 
current code should have been using table->orig_nents - it's just that 
switching to the sgtable helper is the best way to make the fix, since 
it almost entirely removes the possibility of making that (previously 
rather common) mistake.

If it helps, for the change itself:

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

Thanks,
Robin.

> Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
> ---
>   drivers/dma-buf/heaps/system_heap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
> index 23a7e74ef966..8660508f3684 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
> @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
>   	int i;
>   
>   	table = &buffer->sg_table;
> -	for_each_sg(table->sgl, sg, table->nents, i) {
> +	for_each_sgtable_sg(table, sg, i) {
>   		struct page *page = sg_page(sg);
>   
>   		__free_pages(page, compound_order(page));
> 

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

* Re: [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow
  2021-11-25 13:49   ` [PATCH v2] dma_heap: use for_each_sgtable_sg " guangming.cao
  2021-11-25 14:08     ` Robin Murphy
@ 2021-11-25 14:38     ` Kuan-Ying Lee
  1 sibling, 0 replies; 11+ messages in thread
From: Kuan-Ying Lee @ 2021-11-25 14:38 UTC (permalink / raw)
  To: guangming.cao, robin.murphy
  Cc: Brian.Starkey, benjamin.gaignard, christian.koenig, dri-devel,
	john.stultz, labbott, linaro-mm-sig, linux-arm-kernel,
	linux-kernel, linux-media, linux-mediatek, lmark, matthias.bgg,
	sumit.semwal, wsd_upstream, kuan-ying.lee

On Thu, 2021-11-25 at 21:49 +0800, guangming.cao@mediatek.com wrote:
> From: Guangming <Guangming.Cao@mediatek.com>
> 
> Use (for_each_sgtable_sg) rather than (for_each_sg) to traverse
> sg_table to free sg_table.
> Use (for_each_sg) maybe will casuse some pages can't be freed
> when send wrong nents number.

s/casuse/cause

> 
> Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
> ---
>  drivers/dma-buf/heaps/system_heap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-
> buf/heaps/system_heap.c
> index 23a7e74ef966..8660508f3684 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
> @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct
> dma_buf *dmabuf)
>  	int i;
>  
>  	table = &buffer->sg_table;
> -	for_each_sg(table->sgl, sg, table->nents, i) {
> +	for_each_sgtable_sg(table, sg, i) {
>  		struct page *page = sg_page(sg);
>  
>  		__free_pages(page, compound_order(page));


If this is a fix, I think we should add Fixes: xxxx ("...") in the
commit message and Cc stable.

Thanks,
Kuan-Ying Lee



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

* [PATCH v3] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow
  2021-11-25 14:08     ` Robin Murphy
@ 2021-11-26  3:16       ` guangming.cao
  2021-11-26  6:31         ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: guangming.cao @ 2021-11-26  3:16 UTC (permalink / raw)
  To: robin.murphy
  Cc: Brian.Starkey, benjamin.gaignard, christian.koenig, dri-devel,
	guangming.cao, john.stultz, labbott, linaro-mm-sig,
	linux-arm-kernel, linux-kernel, linux-media, linux-mediatek,
	lmark, matthias.bgg, sumit.semwal, wsd_upstream, stable,
	Guangming

From: Guangming <Guangming.Cao@mediatek.com>

For previous version, it uses 'sg_table.nent's to traverse sg_table in pages
free flow.
However, 'sg_table.nents' is reassigned in 'dma_map_sg', it means the number of
created entries in the DMA adderess space.
So, use 'sg_table.nents' in pages free flow will case some pages can't be freed.

Here we should use sg_table.orig_nents to free pages memory, but use the
sgtable helper 'for each_sgtable_sg'(, instead of the previous rather common
helper 'for_each_sg' which maybe cause memory leak) is much better.

Fixes: d963ab0f15fb0 ("dma-buf: system_heap: Allocate higher order pages if available")

Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
---
 drivers/dma-buf/heaps/system_heap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
index 23a7e74ef966..8660508f3684 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
 	int i;
 
 	table = &buffer->sg_table;
-	for_each_sg(table->sgl, sg, table->nents, i) {
+	for_each_sgtable_sg(table, sg, i) {
 		struct page *page = sg_page(sg);
 
 		__free_pages(page, compound_order(page));
-- 
2.17.1


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

* Re: [PATCH v3] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow
  2021-11-26  3:16       ` [PATCH v3] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow guangming.cao
@ 2021-11-26  6:31         ` Greg KH
  2021-11-26  7:49           ` [PATCH v4] " guangming.cao
  0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2021-11-26  6:31 UTC (permalink / raw)
  To: guangming.cao
  Cc: robin.murphy, Brian.Starkey, benjamin.gaignard, christian.koenig,
	dri-devel, john.stultz, labbott, linaro-mm-sig, linux-arm-kernel,
	linux-kernel, linux-media, linux-mediatek, lmark, matthias.bgg,
	sumit.semwal, wsd_upstream, stable

On Fri, Nov 26, 2021 at 11:16:05AM +0800, guangming.cao@mediatek.com wrote:
> From: Guangming <Guangming.Cao@mediatek.com>
> 
> For previous version, it uses 'sg_table.nent's to traverse sg_table in pages
> free flow.
> However, 'sg_table.nents' is reassigned in 'dma_map_sg', it means the number of
> created entries in the DMA adderess space.
> So, use 'sg_table.nents' in pages free flow will case some pages can't be freed.
> 
> Here we should use sg_table.orig_nents to free pages memory, but use the
> sgtable helper 'for each_sgtable_sg'(, instead of the previous rather common
> helper 'for_each_sg' which maybe cause memory leak) is much better.
> 
> Fixes: d963ab0f15fb0 ("dma-buf: system_heap: Allocate higher order pages if available")
> 
> Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
> ---
>  drivers/dma-buf/heaps/system_heap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
> index 23a7e74ef966..8660508f3684 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
> @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
>  	int i;
>  
>  	table = &buffer->sg_table;
> -	for_each_sg(table->sgl, sg, table->nents, i) {
> +	for_each_sgtable_sg(table, sg, i) {
>  		struct page *page = sg_page(sg);
>  
>  		__free_pages(page, compound_order(page));
> -- 
> 2.17.1
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

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

* [PATCH v4] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow
  2021-11-26  6:31         ` Greg KH
@ 2021-11-26  7:49           ` guangming.cao
  2021-11-26 10:05             ` Christian König
  2021-11-29 18:05             ` John Stultz
  0 siblings, 2 replies; 11+ messages in thread
From: guangming.cao @ 2021-11-26  7:49 UTC (permalink / raw)
  To: greg
  Cc: Brian.Starkey, benjamin.gaignard, christian.koenig, dri-devel,
	guangming.cao, john.stultz, labbott, linaro-mm-sig,
	linux-arm-kernel, linux-kernel, linux-media, linux-mediatek,
	lmark, matthias.bgg, robin.murphy, stable, sumit.semwal,
	wsd_upstream, kuan-ying.lee, Guangming

From: Guangming <Guangming.Cao@mediatek.com>

For previous version, it uses 'sg_table.nent's to traverse sg_table in pages
free flow.
However, 'sg_table.nents' is reassigned in 'dma_map_sg', it means the number of
created entries in the DMA adderess space.
So, use 'sg_table.nents' in pages free flow will case some pages can't be freed.

Here we should use sg_table.orig_nents to free pages memory, but use the
sgtable helper 'for each_sgtable_sg'(, instead of the previous rather common
helper 'for_each_sg' which maybe cause memory leak) is much better.

Fixes: d963ab0f15fb0 ("dma-buf: system_heap: Allocate higher order pages if available")
Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Cc: <stable@vger.kernel.org> # 5.11.*
---
v4: Correct commit message
    1. Cc stable@vger.kernel.org in commit message and add required kernel version.
    2. Add reviewed-by since patch V2 and V4 are same and V2 is reviewed by Robin.
    3. There is no new code change in V4.
V3: Cc stable@vger.kernel.org
    1. This patch needs to be merged stable branch, add stable@vger.kernel.org
       in mail list.
    2. Correct some spelling mistake.
    3. There is No new code change in V3.
V2: use 'for_each_sgtable_sg' to 'replece for_each_sg' as suggested by Robin.

---
 drivers/dma-buf/heaps/system_heap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
index 23a7e74ef966..8660508f3684 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
 	int i;
 
 	table = &buffer->sg_table;
-	for_each_sg(table->sgl, sg, table->nents, i) {
+	for_each_sgtable_sg(table, sg, i) {
 		struct page *page = sg_page(sg);
 
 		__free_pages(page, compound_order(page));
-- 
2.17.1


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

* Re: [PATCH v4] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow
  2021-11-26  7:49           ` [PATCH v4] " guangming.cao
@ 2021-11-26 10:05             ` Christian König
  2021-11-29 18:05             ` John Stultz
  1 sibling, 0 replies; 11+ messages in thread
From: Christian König @ 2021-11-26 10:05 UTC (permalink / raw)
  To: guangming.cao, greg
  Cc: Brian.Starkey, benjamin.gaignard, dri-devel, john.stultz,
	labbott, linaro-mm-sig, linux-arm-kernel, linux-kernel,
	linux-media, linux-mediatek, lmark, matthias.bgg, robin.murphy,
	stable, sumit.semwal, wsd_upstream, kuan-ying.lee

Am 26.11.21 um 08:49 schrieb guangming.cao@mediatek.com:
> From: Guangming <Guangming.Cao@mediatek.com>
>
> For previous version, it uses 'sg_table.nent's to traverse sg_table in pages
> free flow.
> However, 'sg_table.nents' is reassigned in 'dma_map_sg', it means the number of
> created entries in the DMA adderess space.
> So, use 'sg_table.nents' in pages free flow will case some pages can't be freed.
>
> Here we should use sg_table.orig_nents to free pages memory, but use the
> sgtable helper 'for each_sgtable_sg'(, instead of the previous rather common
> helper 'for_each_sg' which maybe cause memory leak) is much better.
>
> Fixes: d963ab0f15fb0 ("dma-buf: system_heap: Allocate higher order pages if available")
> Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
> Reviewed-by: Robin Murphy <robin.murphy@arm.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> Cc: <stable@vger.kernel.org> # 5.11.*
> ---
> v4: Correct commit message
>      1. Cc stable@vger.kernel.org in commit message and add required kernel version.
>      2. Add reviewed-by since patch V2 and V4 are same and V2 is reviewed by Robin.
>      3. There is no new code change in V4.
> V3: Cc stable@vger.kernel.org
>      1. This patch needs to be merged stable branch, add stable@vger.kernel.org
>         in mail list.
>      2. Correct some spelling mistake.
>      3. There is No new code change in V3.
> V2: use 'for_each_sgtable_sg' to 'replece for_each_sg' as suggested by Robin.
>
> ---
>   drivers/dma-buf/heaps/system_heap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
> index 23a7e74ef966..8660508f3684 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
> @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
>   	int i;
>   
>   	table = &buffer->sg_table;
> -	for_each_sg(table->sgl, sg, table->nents, i) {
> +	for_each_sgtable_sg(table, sg, i) {
>   		struct page *page = sg_page(sg);
>   
>   		__free_pages(page, compound_order(page));


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

* Re: [PATCH v4] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow
  2021-11-26  7:49           ` [PATCH v4] " guangming.cao
  2021-11-26 10:05             ` Christian König
@ 2021-11-29 18:05             ` John Stultz
  2021-12-01 10:09               ` Sumit Semwal
  1 sibling, 1 reply; 11+ messages in thread
From: John Stultz @ 2021-11-29 18:05 UTC (permalink / raw)
  To: guangming.cao
  Cc: greg, Brian.Starkey, benjamin.gaignard, christian.koenig,
	dri-devel, labbott, linaro-mm-sig, linux-arm-kernel,
	linux-kernel, linux-media, linux-mediatek, lmark, matthias.bgg,
	robin.murphy, stable, sumit.semwal, wsd_upstream, kuan-ying.lee

On Thu, Nov 25, 2021 at 11:48 PM <guangming.cao@mediatek.com> wrote:
>
> From: Guangming <Guangming.Cao@mediatek.com>
>
> For previous version, it uses 'sg_table.nent's to traverse sg_table in pages
> free flow.
> However, 'sg_table.nents' is reassigned in 'dma_map_sg', it means the number of
> created entries in the DMA adderess space.
> So, use 'sg_table.nents' in pages free flow will case some pages can't be freed.
>
> Here we should use sg_table.orig_nents to free pages memory, but use the
> sgtable helper 'for each_sgtable_sg'(, instead of the previous rather common
> helper 'for_each_sg' which maybe cause memory leak) is much better.
>
> Fixes: d963ab0f15fb0 ("dma-buf: system_heap: Allocate higher order pages if available")
> Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
> Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Cc: <stable@vger.kernel.org> # 5.11.*

Thanks so much for catching this and sending in all the revisions!

Reviewed-by: John Stultz <john.stultz@linaro.org>

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

* Re: [PATCH v4] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow
  2021-11-29 18:05             ` John Stultz
@ 2021-12-01 10:09               ` Sumit Semwal
  0 siblings, 0 replies; 11+ messages in thread
From: Sumit Semwal @ 2021-12-01 10:09 UTC (permalink / raw)
  To: John Stultz
  Cc: guangming.cao, greg, brian.starkey, benjamin.gaignard,
	christian.koenig, dri-devel, labbott, linaro-mm-sig,
	linux-arm-kernel, linux-kernel, linux-media, linux-mediatek,
	lmark, matthias.bgg, robin.murphy, stable, wsd_upstream,
	kuan-ying.lee

Hello Guangming,

On Mon, 29 Nov 2021 at 23:35, John Stultz <john.stultz@linaro.org> wrote:
>
> On Thu, Nov 25, 2021 at 11:48 PM <guangming.cao@mediatek.com> wrote:
> >
> > From: Guangming <Guangming.Cao@mediatek.com>
> >
> > For previous version, it uses 'sg_table.nent's to traverse sg_table in pages
> > free flow.
> > However, 'sg_table.nents' is reassigned in 'dma_map_sg', it means the number of
> > created entries in the DMA adderess space.
> > So, use 'sg_table.nents' in pages free flow will case some pages can't be freed.
> >
> > Here we should use sg_table.orig_nents to free pages memory, but use the
> > sgtable helper 'for each_sgtable_sg'(, instead of the previous rather common
> > helper 'for_each_sg' which maybe cause memory leak) is much better.

Thanks for catching this and the patch; applied to drm-misc-fixes.
> >
> > Fixes: d963ab0f15fb0 ("dma-buf: system_heap: Allocate higher order pages if available")
> > Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
> > Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> > Cc: <stable@vger.kernel.org> # 5.11.*
>
> Thanks so much for catching this and sending in all the revisions!
>
> Reviewed-by: John Stultz <john.stultz@linaro.org>


Best,
Sumit.

-- 
Thanks and regards,

Sumit Semwal (he / him)
Tech Lead - LCG, Vertical Technologies
Linaro.org │ Open source software for ARM SoCs

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

end of thread, other threads:[~2021-12-01 10:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 12:46 [PATCH] dma_heap: use sg_table.orig_nents in sg_table release flow guangming.cao
2021-11-25 13:28 ` Robin Murphy
2021-11-25 13:49   ` [PATCH v2] dma_heap: use for_each_sgtable_sg " guangming.cao
2021-11-25 14:08     ` Robin Murphy
2021-11-26  3:16       ` [PATCH v3] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow guangming.cao
2021-11-26  6:31         ` Greg KH
2021-11-26  7:49           ` [PATCH v4] " guangming.cao
2021-11-26 10:05             ` Christian König
2021-11-29 18:05             ` John Stultz
2021-12-01 10:09               ` Sumit Semwal
2021-11-25 14:38     ` [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow Kuan-Ying Lee

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