]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dmaengine: qcom: bam_dma: Fix DT error handling for num-channels/ees
authorStephan Gerhold <stephan.gerhold@linaro.org>
Wed, 12 Feb 2025 17:03:54 +0000 (18:03 +0100)
committerVinod Koul <vkoul@kernel.org>
Mon, 11 Aug 2025 05:22:43 +0000 (10:52 +0530)
When we don't have a clock specified in the device tree, we have no way to
ensure the BAM is on. This is often the case for remotely-controlled or
remotely-powered BAM instances. In this case, we need to read num-channels
from the DT to have all the necessary information to complete probing.

However, at the moment invalid device trees without clock and without
num-channels still continue probing, because the error handling is missing
return statements. The driver will then later try to read the number of
channels from the registers. This is unsafe, because it relies on boot
firmware and lucky timing to succeed. Unfortunately, the lack of proper
error handling here has been abused for several Qualcomm SoCs upstream,
causing early boot crashes in several situations [1, 2].

Avoid these early crashes by erroring out when any of the required DT
properties are missing. Note that this will break some of the existing DTs
upstream (mainly BAM instances related to the crypto engine). However,
clearly these DTs have never been tested properly, since the error in the
kernel log was just ignored. It's safer to disable the crypto engine for
these broken DTBs.

[1]: https://lore.kernel.org/r/CY01EKQVWE36.B9X5TDXAREPF@fairphone.com/
[2]: https://lore.kernel.org/r/20230626145959.646747-1-krzysztof.kozlowski@linaro.org/

Cc: stable@vger.kernel.org
Fixes: 48d163b1aa6e ("dmaengine: qcom: bam_dma: get num-channels and num-ees from dt")
Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250212-bam-dma-fixes-v1-8-f560889e65d8@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/qcom/bam_dma.c

index bbc3276992bb012a1b79937bdbd069fc01f75331..2cf060174795fe326abaf053a7a7a10022455586 100644 (file)
@@ -1283,13 +1283,17 @@ static int bam_dma_probe(struct platform_device *pdev)
        if (!bdev->bamclk) {
                ret = of_property_read_u32(pdev->dev.of_node, "num-channels",
                                           &bdev->num_channels);
-               if (ret)
+               if (ret) {
                        dev_err(bdev->dev, "num-channels unspecified in dt\n");
+                       return ret;
+               }
 
                ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-ees",
                                           &bdev->num_ees);
-               if (ret)
+               if (ret) {
                        dev_err(bdev->dev, "num-ees unspecified in dt\n");
+                       return ret;
+               }
        }
 
        ret = clk_prepare_enable(bdev->bamclk);