From nobody Mon Feb 9 01:43:08 2026 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 6569F392C31 for ; Tue, 3 Feb 2026 08:07:25 +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=1770106047; cv=none; b=nBgmuo2aj1YsiTTyGqJ9RaTjmVNkstFhsElLWmpmk3fdDNq7t5abEGa2OyA4+ZyIHx/iBm9MJxk3OhT4kLLD4hf1BZ3KWqtxnsnJwM4wx8kYSy7WqdfjdEF2qZzHKLuRC9xjj3p4PMTW/UOhM5CR7jy2ZBYP0QMeBIvav8P8jqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770106047; c=relaxed/simple; bh=Qq04aMyR2RaVOIZIp8efbqCAIMKGNTY8acMbrQE2EXM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=J6rL4asOMa81hWgPb0b/onlxdJDVj0pSquGryf1ChxDrlTJt3lzF+E3moSMfUwPDfRGWIpmbmvbLO/riqDcpvOJQ/BWzkXgquNxwBu6MaaHQbcC7mNSdI8y9W3Byna0ZiaZfc8i4S4Me5VzpWbnS270HPrx+3I0qZQ9yDi/IU+c= 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=cJdzSjKQ; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=SqnBjJXk; 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="cJdzSjKQ"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="SqnBjJXk" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6132fHbp3387813 for ; Tue, 3 Feb 2026 08:07:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=aj8+pAYTZe6c5Ex+saB41vaGVimbskW7CCO dDiVYdno=; b=cJdzSjKQbg/hlj20+hQ9vWMNDsyCeU2PnKUtX3bzEzILLXRjyRT 8k4bvQ5upj/IXvBIeMo6u+QHIq+D3nJIwyyWjcB4lsSeHlKatLL6Q6frtMUTqJgU /a56LD70rVBYuk5HvVXtuhmTWixgdGWzhMl6hcvNPt0rZlqfQA5jEvHxRJNvRy9j 53vNx5pIgZCX8cTbCYsz4zQxtHPUS//t2P69jab6eJ8KB5XIivGYeKPddAcBDS4B 9G3jb7Fk6ZOy5ApRiusBkyMQLgVO2d9y2xqfTYqlAKvKs9vTnOgvSAJmVplhyDbN UlljN+baqzk85ixRlr20pm+E+UzLjJhHHVA== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4c2xvbtndf-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 03 Feb 2026 08:07:24 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-34c48a76e75so4698783a91.1 for ; Tue, 03 Feb 2026 00:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1770106043; x=1770710843; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=aj8+pAYTZe6c5Ex+saB41vaGVimbskW7CCOdDiVYdno=; b=SqnBjJXkd8ACeYGevAyNdMpi+iAoehlOcx+DpIXnyjXE57THGKNU6h0UNpfYov13gX YstIxmbIooDy763rsoF1NtqERtK+hDRunQoJfKgc/wE776StfWbh69/VadweliGmiCVl 7DRsAZinkRB5+AzIt9/ni2CR1fVdKZykRsa8r89BHtO36bGtdVEDHWTM/h9VMXJIKALY 3od/1l6LyTD4dO00EVbflQSeZ8cY0Jl0SPqkM46rG09eZZckl/JdxRTn4cADr/2/cFbr Lyx1c1oJzYNYjACKokvdJaJmwxWhV6UimUkHJoXhxym8BQA5WFtNuwET7QBH0kEj+al1 QaMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770106043; x=1770710843; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aj8+pAYTZe6c5Ex+saB41vaGVimbskW7CCOdDiVYdno=; b=g3tQGPnmShBCiuhgG+FYzd49/19tBAYZGHA65FMKm/kZZ1xXzaUkWG78zM8MzbeXPH o2kr5LqaBPCx0gR2DRLCgkvv8Z9r4Ogajs3KJm5r0JyHTqSafAmxlJ4GaHeaEOtegbGX SMoO72wnFdhBjnKyDY80YbCjMI02FK052O9iUNi3KvgudgM1dK+f7Qa/3wtmfNWrHHst t+/J5xMlBK2I+rkim+rYfK3jfsD/IH7iZGxrSnBgGJn8OvLYmbNA8Okt//ll6VZ/9SEn 38Ba0lRFu1yttEqqvx7Z413tZ66c+fnNDiq6SeadcWo0aGUEnpch0klXYawIvKgcZPa+ HNYw== X-Forwarded-Encrypted: i=1; AJvYcCWlluWCyYHRDm27O/Q9c4uhGTypfVY2chATnyFWZlEp+m4wnd5pmhuZW3sOJERn/tefF0xy5gkKXEzTEEM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywb5CIPGdn65A34tO+JZaRtQVq0CyGeh1MJwWnoFXNPPM6GKFeT ZalEpIKihoubFtYdQjaVm4NLcy0W5qgkwAnfdAMOmQDb+gVj4DTNoD5CPdaKiS43W7qoQ1aypnl sFDWsAQF0O50c1jz1sBBIzZjEFDScaoY7bo6PWiUpghg4ppTqxTKtjvI8CpwD04jV5iM= X-Gm-Gg: AZuq6aLj2UxVkqnbxqSONyY+1DPUeGaHeJYhUNPvLS8AD1bxX1Dq1xsDPIAztQQTJ5R kmYksDS9iC5o2f10f8gx/WtV+wzhet9talGz7jwmldz2yW1mfnrSpPu1VvOrOzbg3SOcXnJik0N n3axeXVgBK9J/e6AyiQi0iwkOE3gdfbSSKvVOxRSFQCtW4bfWUJAmJyef6y35hrgZN+YaA5A63t 5DWeJFbqruH/XLggJe+RI+r15Dx3HCSsBp0pf7obfNUMqjmNbphu6EaTzgc14Zgx8fLw+s8uhkz 118XCZEt1P+w58WFZeFFAIR/1/cl5CLNc7tjTxzlINPgAg3psI3U9Md/UDIJT8QclKIeesMovbf 6z0xw5D2s8GLBpAjZWoOnND8m X-Received: by 2002:a17:90a:e710:b0:353:5c16:aa7 with SMTP id 98e67ed59e1d1-3543b4007c8mr13225244a91.25.1770106043131; Tue, 03 Feb 2026 00:07:23 -0800 (PST) X-Received: by 2002:a17:90a:e710:b0:353:5c16:aa7 with SMTP id 98e67ed59e1d1-3543b4007c8mr13225210a91.25.1770106042541; Tue, 03 Feb 2026 00:07:22 -0800 (PST) Received: from work ([120.60.74.100]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82379c22672sm17865275b3a.51.2026.02.03.00.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 00:07:22 -0800 (PST) From: Manivannan Sadhasivam To: andersson@kernel.org, konradybcio@kernel.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, mani@kernel.org, Manivannan Sadhasivam , stable@vger.kernel.org, Abel Vesa , Sumit Garg Subject: [PATCH] soc: qcom: ice: Remove platform_driver support and expose as a pure library Date: Tue, 3 Feb 2026 13:37:12 +0530 Message-ID: <20260203080712.15480-1-manivannan.sadhasivam@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: SA9Bo0QNfCEqHtbmYHNLaZPGfFVLPhqw X-Proofpoint-ORIG-GUID: SA9Bo0QNfCEqHtbmYHNLaZPGfFVLPhqw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjAzMDA2NCBTYWx0ZWRfXy3psu2n8l2o8 a9rvNpROk6RIxOsPaYxfWDpPE4ua06/NvikPB2PSpV70o87k3DZSqAxlOVpAberPlXr3mhV98n0 SUv54m4rN8zXXhYTN3oUZ11mkmtZJGDv6glZdG3Gupb3cWw0NeVZK/kE2p7N4nQ+ZtxWV2THyHx cb3IgFCs3sLaIutN72HMw5FdL3H+jDU/hWWw+K26u6pYka/mKJgqSMcMjzxDoM5RCAZjuqOEHvu p/ewdr6UMOUvZIiy56I5SfDj+3QREhDghnr7vv03j8trQtagsoujJwJygwV05GTrzXapdnuJop9 zgkBP0r87LulGCkUW6qByf6vE+M8pUnYfD+X5Ri9I/N/2t7OirvxMw0GxWNfJWGIu3ekKAn81J3 1U/0owwNq76UzBHwv8QvSlMm+g9eVx2YyYplk3ElgxRizJlRxwB4T3HlY9TBmioGLefszlvyjlk +A+Z2vunrea6CoF6GAQ== X-Authority-Analysis: v=2.4 cv=AurjHe9P c=1 sm=1 tr=0 ts=6981acbc cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=A3/yxVAzUcVmDczBgoabkA==:17 a=HzLeVaNsDn8A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=8UEKqKzBqzOYgcocWCkA:9 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-03_02,2026-02-02_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602030064 Content-Type: text/plain; charset="utf-8" The current platform driver design causes probe ordering races with clients (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 clients non-functional even when ICE should be gracefully disabled. devm_of_qcom_ice_get() cannot 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 client drivers as 'qcom,ice' is not considered as a DT 'supplier'. So the client drivers have no idea of when the ICE driver is going to probe. To avoid all this hassle, remove the platform driver support altogether and just expose the ICE driver as a pure library to client drivers. With this design, when devm_of_qcom_ice_get() is called, it will check if the ICE instance is available or not. If not, it will create one based on the ICE DT node, increase the refcount and return the handle. When the next client calls the API again, the ICE instance would be available. So this function will just increment the refcount and return the instance. Finally, when the client devices get destroyed, refcount will be decremented and finally the cleanup will happen once all clients are destroyed. For the clients using the old DT binding of providing the separate 'ice' register range in their node, this change has no impact. Cc: stable@vger.kernel.org Cc: Abel Vesa Reported-by: Sumit Garg Fixes: 2afbf43a4aec ("soc: qcom: Make the Qualcomm UFS/SDCC ICE a dedicated= driver") Signed-off-by: Manivannan Sadhasivam --- drivers/soc/qcom/ice.c | 100 ++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 61 deletions(-) diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c index b203bc685cad..b5a9cf8de6e4 100644 --- a/drivers/soc/qcom/ice.c +++ b/drivers/soc/qcom/ice.c @@ -107,12 +107,16 @@ struct qcom_ice { struct device *dev; void __iomem *base; =20 + struct kref refcount; struct clk *core_clk; bool use_hwkm; bool hwkm_init_complete; u8 hwkm_version; }; =20 +static DEFINE_MUTEX(ice_mutex); +struct qcom_ice *ice_handle; + static bool qcom_ice_check_supported(struct qcom_ice *ice) { u32 regval =3D qcom_ice_readl(ice, QCOM_ICE_REG_VERSION); @@ -599,8 +603,8 @@ static struct qcom_ice *qcom_ice_create(struct device *= dev, * This function will provide an ICE instance either by creating one for t= he * consumer device if its DT node provides the 'ice' reg range and the 'ic= e' * clock (for legacy DT style). On the other hand, if consumer provides a - * phandle via 'qcom,ice' property to an ICE DT, the ICE instance will alr= eady - * be created and so this function will return that instead. + * phandle via 'qcom,ice' property to an ICE DT node, then the ICE instanc= e will + * be created if not already done and will be returned. * * Return: ICE pointer on success, NULL if there is no ICE data provided b= y the * consumer or ERR_PTR() on error. @@ -611,11 +615,12 @@ static struct qcom_ice *of_qcom_ice_get(struct device= *dev) struct qcom_ice *ice; struct resource *res; void __iomem *base; - struct device_link *link; =20 if (!dev || !dev->of_node) return ERR_PTR(-ENODEV); =20 + guard(mutex)(&ice_mutex); + /* * In order to support legacy style devicetree bindings, we need * to create the ICE instance using the consumer device and the reg @@ -631,6 +636,16 @@ static struct qcom_ice *of_qcom_ice_get(struct device = *dev) return qcom_ice_create(&pdev->dev, base); } =20 + /* + * If the ICE node has been initialized already, just increase the + * refcount and return the handle. + */ + if (ice_handle) { + kref_get(&ice_handle->refcount); + + 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 @@ -643,41 +658,43 @@ static struct qcom_ice *of_qcom_ice_get(struct device= *dev) =20 pdev =3D of_find_device_by_node(node); if (!pdev) { - dev_err(dev, "Cannot find device node %s\n", node->name); + dev_err(dev, "Cannot find ICE platform device\n"); + platform_device_put(pdev); return ERR_PTR(-EPROBE_DEFER); } =20 - ice =3D platform_get_drvdata(pdev); - if (!ice) { - dev_err(dev, "Cannot get ice instance from %s\n", - dev_name(&pdev->dev)); + base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) { + dev_warn(&pdev->dev, "ICE registers not found\n"); platform_device_put(pdev); - return ERR_PTR(-EPROBE_DEFER); + return base; } =20 - link =3D 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)); + ice =3D qcom_ice_create(&pdev->dev, base); + if (IS_ERR(ice)) { platform_device_put(pdev); - ice =3D ERR_PTR(-EINVAL); + return ice_handle; } =20 - return ice; + ice_handle =3D ice; + kref_init(&ice_handle->refcount); + + return ice_handle; } =20 -static void qcom_ice_put(const struct qcom_ice *ice) +static void qcom_ice_put(struct kref *kref) { - struct platform_device *pdev =3D to_platform_device(ice->dev); - - if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice")) - platform_device_put(pdev); + platform_device_put(to_platform_device(ice_handle->dev)); + ice_handle =3D NULL; } =20 static void devm_of_qcom_ice_put(struct device *dev, void *res) { - qcom_ice_put(*(struct qcom_ice **)res); + const struct qcom_ice *ice =3D *(struct qcom_ice **)res; + struct platform_device *pdev =3D to_platform_device(ice->dev); + + if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice")) + kref_put(&ice_handle->refcount, qcom_ice_put); } =20 /** @@ -713,42 +730,3 @@ struct qcom_ice *devm_of_qcom_ice_get(struct device *d= ev) return ice; } EXPORT_SYMBOL_GPL(devm_of_qcom_ice_get); - -static int qcom_ice_probe(struct platform_device *pdev) -{ - struct qcom_ice *engine; - void __iomem *base; - - base =3D devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(base)) { - dev_warn(&pdev->dev, "ICE registers not found\n"); - return PTR_ERR(base); - } - - engine =3D qcom_ice_create(&pdev->dev, base); - if (IS_ERR(engine)) - return PTR_ERR(engine); - - platform_set_drvdata(pdev, engine); - - return 0; -} - -static const struct of_device_id qcom_ice_of_match_table[] =3D { - { .compatible =3D "qcom,inline-crypto-engine" }, - { }, -}; -MODULE_DEVICE_TABLE(of, qcom_ice_of_match_table); - -static struct platform_driver qcom_ice_driver =3D { - .probe =3D qcom_ice_probe, - .driver =3D { - .name =3D "qcom-ice", - .of_match_table =3D qcom_ice_of_match_table, - }, -}; - -module_platform_driver(qcom_ice_driver); - -MODULE_DESCRIPTION("Qualcomm Inline Crypto Engine driver"); -MODULE_LICENSE("GPL"); --=20 2.51.0