DMA Engine development
 help / color / mirror / Atom feed
From: Basavaraj Natikar <bnatikar@amd.com>
To: Lee Jones <lee@kernel.org>,
	Basavaraj Natikar <Basavaraj.Natikar@amd.com>,
	Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	Philipp Stanner <pstanner@redhat.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH v2 03/11] dmaengine: ae4dma: Unregister DMA engine in ae4_pci_remove()
Date: Thu, 19 Nov 2026 11:06:36 +0530	[thread overview]
Message-ID: <36c48ade-ace8-466a-9967-1261f485cc4e@amd.com> (raw)
In-Reply-To: <20261117163809.622249-4-lee@kernel.org>


On 11/17/2026 10:07 PM, Lee Jones wrote:
> ae4_core_init() registers the DMA device and creates the descriptor slab
> cache via pt_dmaengine_register(), but ae4_pci_remove() never undoes
> either, leaking the descriptor cache and leaving a dangling DMA device
> registered after device removal.
>
> Unregister the DMA device first, so that no channels remain available to
> clients, then stop the per-queue completion work, which may still free
> descriptors into the cache, and only then destroy the descriptor cache.
> pt_dmaengine_unregister() is open-coded here because it destroys the
> cache immediately after unregistering, before the completion work has
> been stopped.
>
> Unregistering the DMA device also removes the ptdma debugfs entries,
> which were previously left behind after removal, pointing at freed
> device data.
>
> Fixes: 98f5a4432622 ("dmaengine: ae4dma: Register AE4DMA using pt_dmaengine_register")
> Closes: https://sashiko.dev/#/bug/linux-10d41112-e133-4bc5-8e53-b3e96592c70d
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>
> v1 => v2:
>   - Stop the completion work before destroying the descriptor cache
>   - Open-code the unregistration rather than exporting pt_dmaengine_unregister()
>
>   drivers/dma/amd/ae4dma/ae4dma-pci.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/drivers/dma/amd/ae4dma/ae4dma-pci.c b/drivers/dma/amd/ae4dma/ae4dma-pci.c
> index 2c63907db228..b97fd37bb87d 100644
> --- a/drivers/dma/amd/ae4dma/ae4dma-pci.c
> +++ b/drivers/dma/amd/ae4dma/ae4dma-pci.c
> @@ -131,8 +131,14 @@ static int ae4_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   static void ae4_pci_remove(struct pci_dev *pdev)
>   {
>   	struct ae4_device *ae4 = dev_get_drvdata(&pdev->dev);
> +	struct pt_device *pt = &ae4->pt;
>   
> +	dma_async_device_unregister(&pt->dma_dev);
> +
> +	/* Completion processing frees descriptors into the cache, so stop it first */
>   	ae4_destroy_work(ae4);
> +	kmem_cache_destroy(pt->dma_desc_cache);
> +
>   	ae4_deinit(ae4);
>   }
>   

Acked-by: Basavaraj Natikar<Basavaraj.Natikar@amd.com>


Thanks,
--
Basavaraj



  parent reply	other threads:[~2026-11-19  5:36 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 16:37 [PATCH v2 00/11] dmaengine: Fix teardown races, resource leaks, and error handling Lee Jones
2026-11-17 16:37 ` [PATCH v2 01/11] dmaengine: pl08x: Defer OF DMA controller registration until slave setup Lee Jones
2026-11-17 18:44   ` Linus Walleij
2026-11-17 19:37   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 02/11] dmaengine: ae4dma: Let the pending work exit before cancelling it Lee Jones
2026-11-17 19:38   ` Frank Li
2026-11-19  5:33   ` Basavaraj Natikar
2026-11-17 16:37 ` [PATCH v2 03/11] dmaengine: ae4dma: Unregister DMA engine in ae4_pci_remove() Lee Jones
2026-11-17 19:40   ` Frank Li
2026-11-19  5:36   ` Basavaraj Natikar [this message]
2026-11-17 16:37 ` [PATCH v2 04/11] dmaengine: ptdma: Unmap descriptor in pt_do_cleanup() Lee Jones
2026-11-17 19:41   ` Frank Li
2026-11-19  5:38   ` Basavaraj Natikar
2026-11-17 16:37 ` [PATCH v2 05/11] dmaengine: ptdma: Remove completed descriptor under vc.lock in pt_cmd_callback_work() Lee Jones
2026-11-17 19:42   ` Frank Li
2026-11-19  5:41   ` Basavaraj Natikar
2026-11-17 16:37 ` [PATCH v2 06/11] dmaengine: amlogic: Destroy free_wq after devres DMA device unregistration Lee Jones
2026-11-17 19:43   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 07/11] dmaengine: arm-dma350: Query dma_cookie_status() under vc.lock in d350_tx_status() Lee Jones
2026-11-17 19:44   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 08/11] dmaengine: bestcomm: Defer publishing bcom_eng until initialisation completes Lee Jones
2026-11-17 19:48   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 09/11] dmaengine: bestcomm: Check rh_create() return value in bcom_sram_init() Lee Jones
2026-11-17 19:49   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 10/11] dmaengine: jz4780: Fix descriptor cleanup on hwdesc setup failure Lee Jones
2026-11-17 19:50   ` Frank Li
2026-11-17 19:54   ` Paul Cercueil
2026-11-17 16:37 ` [PATCH v2 11/11] dmaengine: dmatest: Avoid unsigned underflow in min_odd() Lee Jones
2026-11-17 19:51   ` Frank Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36c48ade-ace8-466a-9967-1261f485cc4e@amd.com \
    --to=bnatikar@amd.com \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pstanner@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox