From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3314D1FFC76 for ; Wed, 12 Feb 2025 22:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739398757; cv=none; b=r5ux2DZf+kte3yjmddujA5c8IOricZqQSvbbXym1E+VKYFQMrNa617ur4T5r5DtCK7ikjyPGGvuj9LdOgwJTWVSMI1Lfv9biWJrNq3GpTR6Mddk28owKO9BS1DdDWjw3znOVb0XBRSwjvfHEorFKcaHpk65BBX6i0iSMz3VGMZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739398757; c=relaxed/simple; bh=yT1WThL1jBPrtugQr7EiuZsrp6TpMNWAICvvKnpVO3w=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dn01AHnVA0khpsK2qb46ELqxnvmBgkAlg92uSovIWkIivmcv6r8YJ7cz8F+urxCCuZXyYqH1JBuL6eSdXTol6QLTWyf0COQPXH5yafIWiNnD8hAqpsGYRtGYLdseWnnN3u0HCTE48xyEBtWEyE79tExpPkD+08zuzAf0cSmiByY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=gwn3f6J/; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="gwn3f6J/" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51CCC3Ur010163 for ; Wed, 12 Feb 2025 22:19:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 4HSI5ASZ9NS3VrXEUw0edbnKWJTKfnfNBpv34oiqKVg=; b=gwn3f6J/hc8jAOFb gOixYwhjRvLJ/C4/Zc6kF5j6KSueL184g6MVJoGbBo3u7YeZdnidQl4sh8jDM9Bl mTxSOkyh/HtvgD2nt67PJngnNIPlQgmmXr3+W2m5esTG5r1U9WaxZQjEHe8prDZk xDQdOAil7Z8ElJJNBT3VMl2Fpi1xB/TyBFd6qm/1pIa9KNhgbOj/pyqqsogiqf4+ A7ykpd2USb6tQvPx4zoaDMzv8sP40OwPAqQ3pa7va1ZB6o2iFCDdEldC4V7lmwJC ZQZgA4wtARelaFPKKyeelyMWPOzPNlcCZY5TBsTHxOZHsRFoIzSWjwpVVoFxRsxh mxTsvA== Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44qcs5h6ma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 12 Feb 2025 22:19:14 +0000 (GMT) Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6e1b2251f36so793316d6.3 for ; Wed, 12 Feb 2025 14:19:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739398754; x=1740003554; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4HSI5ASZ9NS3VrXEUw0edbnKWJTKfnfNBpv34oiqKVg=; b=g+Y+GJZThVoqMGbBqxCSrPuBJw66m7FgoVEMDJSnjH5DngouCcM7QkLXx08Q0kHaMU ptyt9hCfQuBQeDEbCuDiC4Rlas4Ok17h8hzaB626DSw8nHQYk72CYxDROsVDo6kVywts WsVEPBmbNKq84BRGE2I5Utjn2ww4O7Q4qk1H6CIaOe/s+1lBtFO/C8EcAl8087U7V+xw SstvuODY/I0hMZ0ovq+B5Adqn6/M+i69gtzbGrE669QXOHtMC+MOJCU3WQgOv9tWZnLp yjKzRmbHKQ90fHRKyfbZTjPLXY2mKVcWDsK/IUj1tOptmE1CFZU0V3bMdv5uNx0xg2zM 3PoQ== X-Forwarded-Encrypted: i=1; AJvYcCXLoFlbbBs0bfmwZKALizpS+iR2CgqijxIKKQkIl3oEdC1Pz19dCeuNRGPgY5S6NpKFXN4Lj0WbZoOB/Po=@vger.kernel.org X-Gm-Message-State: AOJu0YyfKP5NzHmhm3T4xTf6gCgdeM+ezfzQkgzwcugPP7IjjYR1D7BL q4Rz1gM+ZqnBKnjdULIS7FbgNONETU1K690v9jTqll+DAicfXRDLz0upB8B84BdAjtCCk/rHmI9 LHVvssTy3NZZndvgWXVMDgMa6BZEubPMZAKz2aoYXYcUsIa+7uA2yd9FV9b234xs= X-Gm-Gg: ASbGncuCfn+VTSTL12Hi9lajpx587PrUMJ9GUsHO1L0sbrGtPRrMPKnhf9Oiyuk0cIY IynGXi7mycp+ROTdK0GgvXrYgIkSHlVw7zm6C5dVJCXBuECATmUN5UHCnSWuoML5VDekbfh/fOU uFrVwrF2IqEaD1WDv/rxMa6j2iXvUdGeX/JPX4XEsWWKHPVRKKqnlPA5TGCBHg3PL1cMEpR8Y48 D38SJfFKt+IR1aCBrXUIqynfRV5SA5SgkUauZATBP4ipLDXXdrbvYtNgHle3mz5mp/XCEN3sm5+ xKvI7ULcahm8tvFJ5wCQ0FnrsD65ppMo4WgZ3HMtMmN0vAnM/CFvpauiCT8= X-Received: by 2002:ac8:59ce:0:b0:467:6bbf:c1ab with SMTP id d75a77b69052e-471afdf1d29mr30712901cf.3.1739398753960; Wed, 12 Feb 2025 14:19:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGK6Ge4ebchMzt0HUQfcJ6HYI/Xh1Ud54kYJSjBnEpQ0vQMeGzVjf5lSNzNOHaDSn8ZJvY5bg== X-Received: by 2002:ac8:59ce:0:b0:467:6bbf:c1ab with SMTP id d75a77b69052e-471afdf1d29mr30712721cf.3.1739398753478; Wed, 12 Feb 2025 14:19:13 -0800 (PST) Received: from [192.168.65.90] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aba5337653fsm3419966b.102.2025.02.12.14.19.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Feb 2025 14:19:13 -0800 (PST) Message-ID: Date: Wed, 12 Feb 2025 23:19:10 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 8/8] dmaengine: qcom: bam_dma: Fix DT error handling for num-channels/ees To: Stephan Gerhold , Vinod Koul , Bjorn Andersson , Konrad Dybcio Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Gross , Srinivas Kandagatla , Neil Armstrong , Yuvaraj Ranganathan , Anusha Rao , Md Sadre Alam , linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss References: <20250212-bam-dma-fixes-v1-0-f560889e65d8@linaro.org> <20250212-bam-dma-fixes-v1-8-f560889e65d8@linaro.org> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20250212-bam-dma-fixes-v1-8-f560889e65d8@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: ujXcoCzV472jYFCtSO8pZumEmDigmU_m X-Proofpoint-GUID: ujXcoCzV472jYFCtSO8pZumEmDigmU_m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-12_07,2025-02-11_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015 mlxscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502120158 On 12.02.2025 6:03 PM, Stephan Gerhold wrote: > 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 > --- > drivers/dma/qcom/bam_dma.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c > index c14557efd577046adc74fa83fd45eb239977b5fa..a2f1f8902c7f88398a5412e8673e24b3c10bb86f 100644 > --- a/drivers/dma/qcom/bam_dma.c > +++ b/drivers/dma/qcom/bam_dma.c > @@ -1291,13 +1291,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; > + } I like dev_err_probe, but this works too Reviewed-by: Konrad Dybcio Konrad