Re: [PATCH 2/2] dmaengine: qcom: bam_dma: Do not touch remote BAM in remove()
From: Frank Li
Date: Tue Oct 20 2026 - 14:49:05 EST
On Tue, Oct 20, 2026 at 06:08:03PM +0000, Mostafa Saleh wrote:
> [You don't often get email from smostafa@xxxxxxxxxx. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Unbinding the crypto BAM through sysfs on X1P42100 resets the board.
> bam_dma_remove() clears BAM_IRQ_SRCS_MSK_EE unconditionally. For a BAM
> that is controlled or powered remotely the register may not be
> accessible: the clock and power of the block belong to the remote side
> or to the consumer of the BAM, which is why bam_init() already avoids
> every register access for such a BAM when the DT provides num-channels
> and qcom,num-ees.
>
> The write is also unnecessary. On a remotely controlled BAM the driver
> only ever sets per channel bits in the EE mask, in bam_chan_init_hw(),
> and bam_free_chan() clears them again. Both run on behalf of a
> consumer, which keeps the block clocked while they do.
>
> Skip the write for both kinds of remotely managed BAM, using the same
> condition as bam_init().
>
> Fixes: 5172c9eb89d4 ("dmaengine: qcom: bam_dma: add controlled-remotely dt property")
> Signed-off-by: Mostafa Saleh <smostafa@xxxxxxxxxx>
> ---
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
> drivers/dma/qcom/bam_dma.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
> index bd583f78e0c1..d818fa1dba57 100644
> --- a/drivers/dma/qcom/bam_dma.c
> +++ b/drivers/dma/qcom/bam_dma.c
> @@ -1407,8 +1407,15 @@ static void bam_dma_remove(struct platform_device *pdev)
> dma_async_device_unregister(&bdev->common);
>
> pm_runtime_get_sync(&pdev->dev);
> - /* mask all interrupts for this execution environment */
> - writel_relaxed(0, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE));
> +
> + /*
> + * Mask all interrupts for this execution environment. A remotely
> + * controlled or powered BAM is left alone: it may be unclocked, and
> + * the only bits this driver sets in its mask are the per channel
> + * ones that bam_free_chan() cleared.
> + */
> + if (!bdev->controlled_remotely && !bdev->powered_remotely)
> + writel_relaxed(0, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE));
>
> free_irq(bdev->irq, bdev);
>
> --
> 2.56.0.212.g129ede20d9-goog
>