From: Neeraj Soni <neeraj.soni@oss.qualcomm.com>
To: manivannan.sadhasivam@oss.qualcomm.com,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Manivannan Sadhasivam <mani@kernel.org>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Abel Vesa <abelvesa@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mmc@vger.kernel.org, linux-scsi@vger.kernel.org,
Sumit Garg <sumit.garg@oss.qualcomm.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v3 1/4] soc: qcom: ice: Fix race between qcom_ice_probe() and of_qcom_ice_get()
Date: Mon, 2 Mar 2026 15:41:54 +0530 [thread overview]
Message-ID: <5e9a399a-074b-4b41-2e10-f2ed654eafcf@oss.qualcomm.com> (raw)
In-Reply-To: <20260223-qcom-ice-fix-v3-1-6ca5846329f7@oss.qualcomm.com>
On 2/23/2026 1:32 PM, Manivannan Sadhasivam via B4 Relay wrote:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
> The current platform driver design causes probe ordering races with
> consumers (UFS, eMMC) due to ICE's dependency on SCM firmware calls. If ICE
> probe fails (missing ICE SCM or DT registers), devm_of_qcom_ice_get() loops
> with -EPROBE_DEFER, leaving consumers non-functional even when ICE should
> be gracefully disabled. devm_of_qcom_ice_get() doesn't know if the ICE
> driver probe has failed due to above reasons or it is waiting for the SCM
> driver.
>
> Moreover, there is no devlink dependency between ICE and consumer drivers
> as 'qcom,ice' is not considered as a DT 'supplier'. So the consumer drivers
> have no idea of when the ICE driver is going to probe.
>
> To address these issues, introduce a global ice_handle to store the valid
> ICE handle pointer, and set during successful ICE driver probe. On probe
> failure, set it to an error pointer and propagate the error from
> of_qcom_ice_get().
>
> Additionally, add a global ice_mutex to synchronize qcom_ice_probe() and
> of_qcom_ice_get().
>
> Note that this change only fixes the standalone ICE DT node bindings and
> not the ones with 'ice' range embedded in the consumer nodes, where there
> is no issue.
>
> Cc: <stable@vger.kernel.org> # 6.4
> Fixes: 2afbf43a4aec ("soc: qcom: Make the Qualcomm UFS/SDCC ICE a dedicated driver")
> Reported-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> drivers/soc/qcom/ice.c | 44 +++++++++++++++++++++++++++-----------------
> 1 file changed, 27 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
> index b203bc685cad..3c3c189e24f9 100644
> --- a/drivers/soc/qcom/ice.c
> +++ b/drivers/soc/qcom/ice.c
> @@ -113,6 +113,9 @@ struct qcom_ice {
> u8 hwkm_version;
> };
>
> +static DEFINE_MUTEX(ice_mutex);
> +static struct qcom_ice *ice_handle;
> +
> static bool qcom_ice_check_supported(struct qcom_ice *ice)
> {
> u32 regval = qcom_ice_readl(ice, QCOM_ICE_REG_VERSION);
> @@ -608,7 +611,6 @@ static struct qcom_ice *qcom_ice_create(struct device *dev,
> static struct qcom_ice *of_qcom_ice_get(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> - struct qcom_ice *ice;
> struct resource *res;
> void __iomem *base;
> struct device_link *link;
> @@ -631,6 +633,22 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
> return qcom_ice_create(&pdev->dev, base);
> }
>
> + guard(mutex)(&ice_mutex);
> +
> + /*
> + * If ice_handle is NULL, then it means the ICE driver is not probed
> + * yet. So return -EPROBE_DEFER to let the client try later.
> + */
> + if (!ice_handle)
> + return ERR_PTR(-EPROBE_DEFER);
> +
> + /*
> + * If ice_handle has error code, then it means the ICE driver has probe
> + * failed. So return the handle for the client to digest it.
> + */
> + if (IS_ERR(ice_handle))
> + return ice_handle;
> +
> /*
> * If the consumer node does not provider an 'ice' reg range
> * (legacy DT binding), then it must at least provide a phandle
> @@ -647,24 +665,16 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
> return ERR_PTR(-EPROBE_DEFER);
> }
>
> - ice = platform_get_drvdata(pdev);
> - if (!ice) {
> - dev_err(dev, "Cannot get ice instance from %s\n",
> - dev_name(&pdev->dev));
> - platform_device_put(pdev);
> - return ERR_PTR(-EPROBE_DEFER);
> - }
> -
> link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
> if (!link) {
> dev_err(&pdev->dev,
> "Failed to create device link to consumer %s\n",
> dev_name(dev));
> platform_device_put(pdev);
> - ice = ERR_PTR(-EINVAL);
> + return ERR_PTR(-EINVAL);
> }
>
> - return ice;
> + return ice_handle;
> }
>
> static void qcom_ice_put(const struct qcom_ice *ice)
> @@ -716,20 +726,20 @@ EXPORT_SYMBOL_GPL(devm_of_qcom_ice_get);
>
> static int qcom_ice_probe(struct platform_device *pdev)
> {
> - struct qcom_ice *engine;
> void __iomem *base;
>
> + guard(mutex)(&ice_mutex);
> +
> base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(base)) {
> dev_warn(&pdev->dev, "ICE registers not found\n");
> + ice_handle = base;
> return PTR_ERR(base);
> }
>
> - engine = qcom_ice_create(&pdev->dev, base);
> - if (IS_ERR(engine))
> - return PTR_ERR(engine);
> -
> - platform_set_drvdata(pdev, engine);
This allows the driver to set the data per ICE device instance which allows
the addition of multiple ICE platform devices. For example this patch:
https://lore.kernel.org/all/20260217052526.2335759-1-neeraj.soni@oss.qualcomm.com/
utilizes this capability. I think it doesen't harm to keep this support.
Moreover, the issue which your patch intends to address do not need this to be removed.
> + ice_handle = qcom_ice_create(&pdev->dev, base);
> + if (IS_ERR(ice_handle))
> + return PTR_ERR(ice_handle);
>
> return 0;
> }
>
Regards,
Neeraj
next prev parent reply other threads:[~2026-03-02 10:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 8:02 [PATCH v3 0/4] " Manivannan Sadhasivam via B4 Relay
2026-02-23 8:02 ` [PATCH v3 1/4] " Manivannan Sadhasivam via B4 Relay
2026-02-23 20:35 ` Bjorn Andersson
2026-02-24 4:46 ` Manivannan Sadhasivam
2026-03-02 9:28 ` Neeraj Soni
2026-03-02 10:11 ` Neeraj Soni [this message]
2026-03-02 13:02 ` Manivannan Sadhasivam
2026-02-23 8:02 ` [PATCH v3 2/4] soc: qcom: ice: Return proper error codes from devm_of_qcom_ice_get() instead of NULL Manivannan Sadhasivam via B4 Relay
2026-02-23 8:02 ` [PATCH v3 3/4] mmc: sdhci-msm: Remove NULL check from devm_of_qcom_ice_get() Manivannan Sadhasivam via B4 Relay
2026-02-23 8:02 ` [PATCH v3 4/4] scsi: ufs: ufs-qcom: " Manivannan Sadhasivam via B4 Relay
2026-02-24 21:30 ` Martin K. Petersen
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=5e9a399a-074b-4b41-2e10-f2ed654eafcf@oss.qualcomm.com \
--to=neeraj.soni@oss.qualcomm.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=abelvesa@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=andersson@kernel.org \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@oss.qualcomm.com \
--cc=martin.petersen@oracle.com \
--cc=stable@vger.kernel.org \
--cc=sumit.garg@oss.qualcomm.com \
--cc=ulf.hansson@linaro.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
all inboxes | Powered by JetHome®