Skip to contentSkip to conversation

media: verisilicon: Simplify error handling in tile_buffer_reallocate()

PATCH In review Benjamin Gaignard 2 participants 5 messages Mar 23, 2023 – Mar 24, 2023

Subsystems (4)
lore
Share & tools
lore

Benjamin Gaignard

author maintainer
#0 lore raw

PATCH 1/1 media: verisilicon: Simplify error handling in tile_buffer_reallocate()

Rework allocation errors cases handling to simply it by removing useless tests.

---
 .../media/platform/verisilicon/hantro_hevc.c  | 23 ++++++++-----------
 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/media/platform/verisilicon/hantro_hevc.c +9 -14
index 9383fb7081f6..2c14330bc562 100644
@@ -109,7 +109,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
 						       &hevc_dec->tile_filter.dma,
 						       GFP_KERNEL);
 	if (!hevc_dec->tile_filter.cpu)
-		goto err_free_tile_buffers;
+		return -ENOMEM;
 	hevc_dec->tile_filter.size = size;
 
 	size = (VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_depth) / 8;
@@ -125,31 +125,26 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
 						    &hevc_dec->tile_bsd.dma,
 						    GFP_KERNEL);
 	if (!hevc_dec->tile_bsd.cpu)
-		goto err_free_tile_buffers;
+		goto err_free_sao_buffers;
 	hevc_dec->tile_bsd.size = size;
 
 	hevc_dec->num_tile_cols_allocated = num_tile_cols;
 
 	return 0;
 
-err_free_tile_buffers:
-	if (hevc_dec->tile_filter.cpu)
-		dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size,
-				  hevc_dec->tile_filter.cpu,
-				  hevc_dec->tile_filter.dma);
-	hevc_dec->tile_filter.cpu = NULL;
-
+err_free_sao_buffers:
 	if (hevc_dec->tile_sao.cpu)
 		dma_free_coherent(vpu->dev, hevc_dec->tile_sao.size,
 				  hevc_dec->tile_sao.cpu,
 				  hevc_dec->tile_sao.dma);
 	hevc_dec->tile_sao.cpu = NULL;
 
-	if (hevc_dec->tile_bsd.cpu)
-		dma_free_coherent(vpu->dev, hevc_dec->tile_bsd.size,
-				  hevc_dec->tile_bsd.cpu,
-				  hevc_dec->tile_bsd.dma);
-	hevc_dec->tile_bsd.cpu = NULL;
+err_free_tile_buffers:
+	if (hevc_dec->tile_filter.cpu)
+		dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size,
+				  hevc_dec->tile_filter.cpu,
+				  hevc_dec->tile_filter.dma);
+	hevc_dec->tile_filter.cpu = NULL;
 
 	return -ENOMEM;
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines

Rework allocation errors cases handling to simply it by removing useless tests.

How do you think about to use a wording like “Simplify handling of allocation error cases by removing useless tests.” for your change description?

Quoted 3 lines
Reported-by …
---
 .../media/platform/verisilicon/hantro_hevc.c  | 23 ++++++++-----------

Would you like to add any links for corresponding information?

Regards,
Markus

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#2 lore raw

Le 24/03/2023 à 07:37, Markus Elfring a écrit :

Quoted 10 lines
Quoted 2 lines

Rework allocation errors cases handling to simply it by removing useless tests.

How do you think about to use a wording like “Simplify handling of allocation error cases by removing useless tests.” for your change description?

Quoted 3 lines
Reported-by …
---
  .../media/platform/verisilicon/hantro_hevc.c  | 23 ++++++++-----------

Would you like to add any links for corresponding information?

No, it was just to show that you have reported the possible clean up

Regards,
Benjamin

Quoted 4 lines

Regards,
Markus

#3 lore raw
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Rework allocation errors cases handling to simply it by removing useless tests.

How do you think about to use a wording like “Simplify handling of allocation error cases by removing useless tests.” for your change description?

I would appreciate another bit of fine-tuning for such text.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Reported-by …

---
  .../media/platform/verisilicon/hantro_hevc.c  | 23 ++++++++-----------

Would you like to add any links for corresponding information?

No, it was just to show that you have reported the possible clean up

I imagine that a bit of background information will be helpful in a tag like “Link:” also for your patch.

2023-03-22
[PATCH] media: hantro: HEVC: Fix exception handling in tile_buffer_reallocate()

Examples:
* https://lore.kernel.org/cocci/[email protected]/
https://sympa.inria.fr/sympa/arc/cocci/2023-03/msg00037.html

* https://lore.kernel.org/lkml/[email protected]/

Regards,
Markus

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#4 lore raw

Le 24/03/2023 à 10:55, Markus Elfring a écrit :

Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Rework allocation errors cases handling to simply it by removing useless tests.

How do you think about to use a wording like “Simplify handling of allocation error cases by removing useless tests.” for your change description?

I would appreciate another bit of fine-tuning for such text.

Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Reported-by …
---
   .../media/platform/verisilicon/hantro_hevc.c  | 23 ++++++++-----------

Would you like to add any links for corresponding information?

No, it was just to show that you have reported the possible clean up

I imagine that a bit of background information will be helpful in a tag like “Link:” also for your patch.

Quoted 8 lines

2023-03-22
[PATCH] media: hantro: HEVC: Fix exception handling in tile_buffer_reallocate()

Examples:
* https://lore.kernel.org/cocci/[email protected]/
https://sympa.inria.fr/sympa/arc/cocci/2023-03/msg00037.html

* https://lore.kernel.org/lkml/[email protected]/

You are welcome to propose a v3 for this patch :-)

Quoted 5 lines

Regards,
Markus

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip