diff mbox series

dmaengine: ptdma: Remove unused pointer dma_cmd_cache

Message ID 20250409114019.42026-1-ezulian@redhat.com (mailing list archive)
State Superseded
Headers show
Series dmaengine: ptdma: Remove unused pointer dma_cmd_cache | expand

Commit Message

Eder Zulian April 9, 2025, 11:40 a.m. UTC
The pointer 'struct kmem_cache *dma_cmd_cache' was introduced in commit
b0b4a6b10577 ("dmaengine: ptdma: register PTDMA controller as a DMA
resource") but it was never used.

Signed-off-by: Eder Zulian <ezulian@redhat.com>
---
 drivers/dma/amd/ptdma/ptdma-dmaengine.c | 3 ---
 drivers/dma/amd/ptdma/ptdma.h           | 1 -
 2 files changed, 4 deletions(-)

Comments

Nathan Lynch April 14, 2025, 10:58 p.m. UTC | #1
Eder Zulian <ezulian@redhat.com> writes:
> The pointer 'struct kmem_cache *dma_cmd_cache' was introduced in commit
> b0b4a6b10577 ("dmaengine: ptdma: register PTDMA controller as a DMA
> resource") but it was never used.
>
> Signed-off-by: Eder Zulian <ezulian@redhat.com>
> ---
>  drivers/dma/amd/ptdma/ptdma-dmaengine.c | 3 ---
>  drivers/dma/amd/ptdma/ptdma.h           | 1 -
>  2 files changed, 4 deletions(-)
>
> diff --git a/drivers/dma/amd/ptdma/ptdma-dmaengine.c b/drivers/dma/amd/ptdma/ptdma-dmaengine.c
> index 715ac3ae067b..3f7f6da05142 100644
> --- a/drivers/dma/amd/ptdma/ptdma-dmaengine.c
> +++ b/drivers/dma/amd/ptdma/ptdma-dmaengine.c
> @@ -656,8 +656,6 @@ int pt_dmaengine_register(struct pt_device *pt)
>  	kmem_cache_destroy(pt->dma_desc_cache);
>  
>  err_cache:
> -	kmem_cache_destroy(pt->dma_cmd_cache);
> -

I think you could remove the 'err_cache' label and convert the users of it
to return -ENOMEM directly, since there aren't any unmanaged allocations
to unwind:

	desc_cache_name = devm_kasprintf(pt->dev, GFP_KERNEL,
					 "%s-dmaengine-desc-cache",
					 dev_name(pt->dev));
	if (!desc_cache_name) {
		ret = -ENOMEM;
		goto err_cache;
	}

	pt->dma_desc_cache = kmem_cache_create(desc_cache_name,
					       sizeof(struct pt_dma_desc), 0,
					       SLAB_HWCACHE_ALIGN, NULL);
	if (!pt->dma_desc_cache) {
		ret = -ENOMEM;
		goto err_cache;
	}

Otherwise LGTM.
Eder Zulian April 15, 2025, 12:23 p.m. UTC | #2
Hello Nathan,

On Mon, Apr 14, 2025 at 05:58:40PM -0500, Nathan Lynch wrote:
> Eder Zulian <ezulian@redhat.com> writes:
> > The pointer 'struct kmem_cache *dma_cmd_cache' was introduced in commit
> > b0b4a6b10577 ("dmaengine: ptdma: register PTDMA controller as a DMA
> > resource") but it was never used.
> >
> > Signed-off-by: Eder Zulian <ezulian@redhat.com>
> > ---
> >  drivers/dma/amd/ptdma/ptdma-dmaengine.c | 3 ---
> >  drivers/dma/amd/ptdma/ptdma.h           | 1 -
> >  2 files changed, 4 deletions(-)
> >
> > diff --git a/drivers/dma/amd/ptdma/ptdma-dmaengine.c b/drivers/dma/amd/ptdma/ptdma-dmaengine.c
> > index 715ac3ae067b..3f7f6da05142 100644
> > --- a/drivers/dma/amd/ptdma/ptdma-dmaengine.c
> > +++ b/drivers/dma/amd/ptdma/ptdma-dmaengine.c
> > @@ -656,8 +656,6 @@ int pt_dmaengine_register(struct pt_device *pt)
> >  	kmem_cache_destroy(pt->dma_desc_cache);
> >  
> >  err_cache:
> > -	kmem_cache_destroy(pt->dma_cmd_cache);
> > -
> 
> I think you could remove the 'err_cache' label and convert the users of it
> to return -ENOMEM directly, since there aren't any unmanaged allocations
> to unwind:
> 
> 	desc_cache_name = devm_kasprintf(pt->dev, GFP_KERNEL,
> 					 "%s-dmaengine-desc-cache",
> 					 dev_name(pt->dev));
> 	if (!desc_cache_name) {
> 		ret = -ENOMEM;
> 		goto err_cache;
> 	}
> 
> 	pt->dma_desc_cache = kmem_cache_create(desc_cache_name,
> 					       sizeof(struct pt_dma_desc), 0,
> 					       SLAB_HWCACHE_ALIGN, NULL);
> 	if (!pt->dma_desc_cache) {
> 		ret = -ENOMEM;
> 		goto err_cache;
> 	}
> 
> Otherwise LGTM.
> 
Thank you for your review and suggestion. Please find a link to the v2.

https://lore.kernel.org/dmaengine/20250415121312.870124-1-ezulian@redhat.com/

Eder
diff mbox series

Patch

diff --git a/drivers/dma/amd/ptdma/ptdma-dmaengine.c b/drivers/dma/amd/ptdma/ptdma-dmaengine.c
index 715ac3ae067b..3f7f6da05142 100644
--- a/drivers/dma/amd/ptdma/ptdma-dmaengine.c
+++ b/drivers/dma/amd/ptdma/ptdma-dmaengine.c
@@ -656,8 +656,6 @@  int pt_dmaengine_register(struct pt_device *pt)
 	kmem_cache_destroy(pt->dma_desc_cache);
 
 err_cache:
-	kmem_cache_destroy(pt->dma_cmd_cache);
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(pt_dmaengine_register);
@@ -669,5 +667,4 @@  void pt_dmaengine_unregister(struct pt_device *pt)
 	dma_async_device_unregister(dma_dev);
 
 	kmem_cache_destroy(pt->dma_desc_cache);
-	kmem_cache_destroy(pt->dma_cmd_cache);
 }
diff --git a/drivers/dma/amd/ptdma/ptdma.h b/drivers/dma/amd/ptdma/ptdma.h
index 0a7939105e51..ef3f55632107 100644
--- a/drivers/dma/amd/ptdma/ptdma.h
+++ b/drivers/dma/amd/ptdma/ptdma.h
@@ -254,7 +254,6 @@  struct pt_device {
 	/* Support for the DMA Engine capabilities */
 	struct dma_device dma_dev;
 	struct pt_dma_chan *pt_dma_chan;
-	struct kmem_cache *dma_cmd_cache;
 	struct kmem_cache *dma_desc_cache;
 
 	wait_queue_head_t lsb_queue;