From: Aravind Vijayakumar <quic_aprasann@quicinc.com>
To: Rob Clark <robdclark@chromium.org>
Cc: <will@kernel.org>, <joro@8bytes.org>, <robin.murphy@arm.com>,
<dmitry.baryshkov@linaro.org>, <quic_bjorande@quicinc.com>,
<konrad.dybcio@linaro.org>, <quic_eberman@quicinc.com>,
<quic_psodagud@quicinc.com>, <quic_rvishwak@quicinc.com>,
<quic_saipraka@quicinc.com>, <quic_molvera@quicinc.com>,
<marijn.suijten@somainline.org>, <mani@kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <iommu@lists.linux.dev>,
<linux-arm-msm@vger.kernel.org>
Subject: Re: [PATCH] iommu/arm-smmu-qcom: NULL pointer check for driver data
Date: Mon, 28 Aug 2023 14:35:09 -0700 [thread overview]
Message-ID: <c06a31fd-e3b5-1f58-9e4f-7fafd8aa3f28@quicinc.com> (raw)
In-Reply-To: <CAJs_Fx7132o3iHDH0ZR7L9G69o2YV2-jC0v15shQcEhH6=-6RA@mail.gmail.com>
On 8/16/2023 6:01 PM, Rob Clark wrote:
> On Wed, Aug 16, 2023 at 3:55 PM Aravind Vijayakumar
> <quic_aprasann@quicinc.com> wrote:
>> The driver_data is NULL when qcom_adreno_smmu_init_context()
>> is called before the dev_set_drvdata() from the client driver
>> and is resulting in kernel crash.
>>
>> So add a null pointer check to handle the scenario
>> where the client driver for the GPU SMMU device would
>> be setting the driver data after the smmu client device
>> probe is done and not necessarily before that. The function
>> qcom_adreno_smmu_init_context() assumes that the client
>> driver always set the driver data using dev_set_drvdata()
>> before the smmu client device probe, but this assumption
>> is not always true.
>>
>> Signed-off-by: Aravind Vijayakumar <quic_aprasann@quicinc.com>
>> ---
>> drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c
>> index c71afda79d64..5323f82264ca 100644
>> --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c
>> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c
>> @@ -231,6 +231,9 @@ static int qcom_adreno_smmu_init_context(struct arm_smmu_domain *smmu_domain,
>> */
>>
>> priv = dev_get_drvdata(dev);
>> + if (!priv)
>> + return 0;
> could this -EPROBE_DEFER instead, or something like that? I think you
> patch as proposed would result in per-process gpu pgtables silently
> failing
>
> BR,
> -R
Thanks for the review comments. Returning -EPROBE_DEFER wont work
because the probe of the client driver (which sets the driver data) will
never get triggered. However, the probe of the client driver succeeds if
we return -ENODATA. would that be acceptable?
Regards,
Aravind
>> +
>> priv->cookie = smmu_domain;
>> priv->get_ttbr1_cfg = qcom_adreno_smmu_get_ttbr1_cfg;
>> priv->set_ttbr0_cfg = qcom_adreno_smmu_set_ttbr0_cfg;
>> --
>> 2.40.1
>>
next prev parent reply other threads:[~2023-08-28 21:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 22:55 [PATCH] iommu/arm-smmu-qcom: NULL pointer check for driver data Aravind Vijayakumar
2023-08-17 1:01 ` Rob Clark
2023-08-28 21:35 ` Aravind Vijayakumar [this message]
2023-08-29 14:30 ` Rob Clark
2023-09-08 5:17 ` Aravind Vijayakumar
2023-09-08 12:21 ` Robin Murphy
2023-09-15 0:20 ` Aravind Vijayakumar
2023-09-15 10:08 ` Robin Murphy
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=c06a31fd-e3b5-1f58-9e4f-7fafd8aa3f28@quicinc.com \
--to=quic_aprasann@quicinc.com \
--cc=dmitry.baryshkov@linaro.org \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=mani@kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=quic_bjorande@quicinc.com \
--cc=quic_eberman@quicinc.com \
--cc=quic_molvera@quicinc.com \
--cc=quic_psodagud@quicinc.com \
--cc=quic_rvishwak@quicinc.com \
--cc=quic_saipraka@quicinc.com \
--cc=robdclark@chromium.org \
--cc=robin.murphy@arm.com \
--cc=will@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