From nobody Tue Dec 2 00:46:52 2025 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 275D123908B for ; Sun, 23 Nov 2025 14:19:44 +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=1763907585; cv=none; b=KWzr9c1o72EqftC/Xg0sfD150y2wmIywT6xzFGCNJfNfbC+zzWjDheUtI746f+pqrOVJlnYVYTq8bVGnfOlys/595G1xNFbauQFx353OCGyfXuB6yJY1h9raPGem6qVxK47Qy6/MWZpRsdjyyV8BpgX1NooJS6Z0lZ7T2ra5dXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763907585; c=relaxed/simple; bh=ATUG8G3yQbf4mBIb5MogIZlnc2dGMSIJGAgAWTfqlWg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u1ov+AjSL7w5/osi7x2QuDDCpZVHB+/uQDHBCoR9dyS4EDpudMJKDdzM7C7HMZQJ5Ox+RutjOuv9FrzaCGx4iA3YC52GvzqWTWOiqNfu/JcGRjFtpY8AzBSnJ+3GN4kEdFHTnki8RkNDyg3qx/D+9yAsLDLQoW/i7JpPhWDivBc= 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=Zq5byRrS; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=jm6l/jeQ; 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="Zq5byRrS"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="jm6l/jeQ" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5ANA6jDW1131475 for ; Sun, 23 Nov 2025 14:19:43 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= Q8L4Z0sGRBsxvlfEy+AM5sITeDHdZpr64GpjFCroDCU=; b=Zq5byRrSZdzawPWX RVyJprAfQycsapAOjdtlnF+G1Y3sSwzWJ7vLqUs4VKX9K9X6NYKh+BoP+3DdAmUM 5BP/SAlr4RNnEzvraXnvCBRrTJxFz2DGqfIxR6clxbRoW1MRvdTMHJnTy2bDQG2T OqiqWc1e1XTHi1Lx0JZOqiyRs4/HXGCWikjXt8kffZmeeLKRSZUWPUE12lZ/RNeL XV+EO39S+5wF0gjdRzrF2RdKAA+nEN9Eml/lW94yoSpKg7tortd1gE3MBCTHT0yA SCxHTNYI4o9EBg3W5SkCfxsWV99f+Zq3h/a5cbseH6/tSov8APNF/mwzc8jx6SpQ zpNGEg== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ak6a52ftj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 23 Nov 2025 14:19:43 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2958c80fcabso104489825ad.0 for ; Sun, 23 Nov 2025 06:19:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1763907582; x=1764512382; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Q8L4Z0sGRBsxvlfEy+AM5sITeDHdZpr64GpjFCroDCU=; b=jm6l/jeQl0ga2XnvK/lLDw7aMkuYt8XBbnswejVBKDGvGmjYMzJ++hOsXcuKUdtOIk g6C5wrM2SD4bgjiLjvYXiCpmvlxefTNc75Kz59u94yxxHqIZU6xl+9WqKXM2lCNipoe8 NUpeP/BZdRXNQv+4/fM8NKH2r3+glFgR+Sqz0XocQ4cfeLQr72tbgG/yPjWePHXPeSL/ J5XjgYsEmgLDHGd6LjKbzhdt8E6AUt8wGrFgYlmis1KHz7OqYtgtcCgQWititfuuHUpF 9OQs4OAOluHwKecfqKjbVhrPSck1V4DqtRtR6Ep7guxiY2KiQXvTsRwCOELPcSfShhaD MXUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763907582; x=1764512382; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Q8L4Z0sGRBsxvlfEy+AM5sITeDHdZpr64GpjFCroDCU=; b=ayKiXWzzYuqA6jBjbumm37YZmeRpF42WSFVOh0f7T1VJVZs+HD2gbGQmBxGMvHdA0A MUecY0AHkgFGZ/2cbo8D4NMne3zFys7+yxEKMizQ/me4IBGG6aCEwjGVFLLpGXe68QBT yCZhIJcttb7PPUQPC7MQZtpqbYYAc0AT2OihvNFhBRJvQX9A3rPOGyH/r+UgwZv+an28 gWr/+HCmJ8ARVF557Ax99EdUnu1W6Skreqebh/ZcMq2/Sge/9uxSsJXMgn8ptDI6ax14 kdOzIgOJDQQKDClx0uaHzJfMTLWqmCDlvcmjLlcLfCTiCq8jKV71+YRXeBMqGVtGjmsY JKlA== X-Forwarded-Encrypted: i=1; AJvYcCVHq2xH3Uaac8CQ8BXJM6uJ6eseEW+P0mdTX1/Fq8hScivmLoWp/KjWTRkG8Tdq4/OpvbO8o4poY3+UFxk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9po0yi79bNYfwyufYz10YdLfP+3w/49mf0+pPxoufyN9OdpVG EOpKtHgyXJg9hMYZ+xcdcnar3drCqM39t0EnyfCFWKx4njPoQNikOainIrLRIW7HqPXbVnopbr1 niY1xuy7PBVmXoVaZ4HmJQYcV1rH4+rbB+dh57vsROm7CS+l9f0AUlJv5q8GoFycKG28= X-Gm-Gg: ASbGncuyRpusVT/JX1VjOmGlr5VMYJF4/w32cRI4GKRzoYQ7BtGzukHaR1j4Rd+B6Ls XJV4ovY21UusRkh5tv319Ci5Ld+nYVJtvz0rcf3/mYqcuqlFbmVILuhWps3H1br82zdHe5wjC4p 0vjfLPcbMR1/WQsRIuhUd7p3/n0pEv6vK52kOFm5/NTbj+LqSMJk3tWmvErxm3kwCYTEC3EDEC5 lIdQ5y6cAJ6HmUjQeZpAJ8bN8Cfb8q9GDxvVKl3vBvyjXyMj7aLcdXKxkyZVc+7nU/SqquUj4l+ hYyRWc3K6l5C+FemtGOisyGRn9mUW0m10XnFfgcK2UXeC4r9HA7YiqrZ9aJRO+TMg0QU43BHfEp b9IvuAou4s58Sbq9TpdRBCD5Y+73j6SdBSJ2oEGNnQqdk6w== X-Received: by 2002:a17:903:11c7:b0:296:ec5:ab3d with SMTP id d9443c01a7336-29b6bfa0be1mr102162495ad.61.1763907582144; Sun, 23 Nov 2025 06:19:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpBpE03zXiQm6rcmqhHUAY+NdIY52OOwJtrCquv0KZBY69pNF7OiasvzF3UAAUEZ/5tOARNw== X-Received: by 2002:a17:903:11c7:b0:296:ec5:ab3d with SMTP id d9443c01a7336-29b6bfa0be1mr102162235ad.61.1763907581648; Sun, 23 Nov 2025 06:19:41 -0800 (PST) Received: from hu-spratap-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-345af0ca952sm10135992a91.0.2025.11.23.06.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Nov 2025 06:19:41 -0800 (PST) From: Shivendra Pratap Date: Sun, 23 Nov 2025 19:49:30 +0530 Subject: [PATCH v9 1/3] firmware: qcom_scm: Add API to get waitqueue IRQ info Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251123-multi_waitq_scm-v9-1-0080fc259d4d@oss.qualcomm.com> References: <20251123-multi_waitq_scm-v9-0-0080fc259d4d@oss.qualcomm.com> In-Reply-To: <20251123-multi_waitq_scm-v9-0-0080fc259d4d@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Unnathi Chalicheemala , Shivendra Pratap , Bartosz Golaszewski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763907576; l=4472; i=shivendra.pratap@oss.qualcomm.com; s=20250710; h=from:subject:message-id; bh=1W8lqsQnD+0CQBLBPVZ0rCrv7zv7DVNbei5NYedDBcs=; b=yPwRYzvwIi+ElqCqLlQp8iNw4lRhL/ugJfJL6VRJVYJcbiuiWTJP++29w7SeCDqhgmUjQwh4Y 0kcvRFfhoXmAU3JBummILSXdx3xBRbiAg3/hUXAse6VHRoQOyVZxsaY X-Developer-Key: i=shivendra.pratap@oss.qualcomm.com; a=ed25519; pk=CpsuL7yZ8NReDPhGgq6Xn/SRoa59mAvzWOW0QZoo4gw= X-Authority-Analysis: v=2.4 cv=Hup72kTS c=1 sm=1 tr=0 ts=692317ff cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=KKAkSRfTAAAA:8 a=l69UaY8b6P0ZDUfUprYA:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: gNmVO9C_VURJYziOtKJK8g52nI2qIevS X-Proofpoint-ORIG-GUID: gNmVO9C_VURJYziOtKJK8g52nI2qIevS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIzMDEyOSBTYWx0ZWRfX3rJsO5w0viTf 6ZVgFA1WXtaNvQiHE735p16iDCoBbv8ezCtfoCYWks8Ce1lnECPaeWDRZ6LPx3v1MJQ3aki47PB m62iqzjFn3wSoCX9Ob8Aprg/oO3al3yIOINrhTpjPhxtExn2E40moUcj0ndnh7e9JrNnqnYnYX3 q5ObPTROHVVa3/7zohnfOBCcAdqxkzL8WCr9S5QC9STdrnUtU+2dNnDIiiDLAEyu9bK2KyYXzMQ aPcoXWW5Tv0BJj3ynEgAsxRdBlCIXlqTNUxURJU2wetfo9V32gzoB9r8qb5MVmAlOsBx7CD/IyZ y9fdec7ygDBGZAEuWzSPMIHIGRcbbOwby7JRSHyw9P2M34cbRCqg1ZpgzrhxX6HVGJKghgMgX6+ Q/phOJthdMSq6jEVl+UtiRKZSt4fEQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-23_05,2025-11-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 phishscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511230129 From: Unnathi Chalicheemala Bootloader and firmware for SM8650 and older chipsets expect node name as "qcom_scm", in order to patch the wait queue IRQ information. However, DeviceTree uses node name "scm" and this mismatch prevents firmware from correctly identifying waitqueue IRQ information. Waitqueue IRQ is used for signaling between secure and non-secure worlds. To resolve this, introduce qcom_scm_get_waitq_irq() that'll get the hardware IRQ number to be used from firmware instead of relying on data provided by devicetree, thereby bypassing the DeviceTree node name mismatch. This hardware IRQ number is converted to a Linux IRQ number using newly defined fill_irq_fwspec_params(). This Linux IRQ number is then supplied to the threaded_irq call. Reviewed-by: Bartosz Golaszewski Signed-off-by: Unnathi Chalicheemala Signed-off-by: Shivendra Pratap --- drivers/firmware/qcom/qcom_scm.c | 62 ++++++++++++++++++++++++++++++++++++= +++- drivers/firmware/qcom/qcom_scm.h | 1 + 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_= scm.c index e777b7cb9b127944fe112f453cae9cbc40c06cae..28979f95e51fbee94b84c1570a4= d88a76f72db4e 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -29,12 +29,18 @@ #include #include #include +#include =20 #include "qcom_scm.h" #include "qcom_tzmem.h" =20 static u32 download_mode; =20 +#define GIC_SPI_BASE 32 +#define GIC_MAX_SPI 1019 // SPIs in GICv3 spec range from 32..1019 +#define GIC_ESPI_BASE 4096 +#define GIC_MAX_ESPI 5119 // ESPIs in GICv3 spec range from 4096..5119 + struct qcom_scm { struct device *dev; struct clk *core_clk; @@ -2223,6 +2229,57 @@ bool qcom_scm_is_available(void) } EXPORT_SYMBOL_GPL(qcom_scm_is_available); =20 +static int qcom_scm_fill_irq_fwspec_params(struct irq_fwspec *fwspec, u32 = virq) +{ + if (virq >=3D GIC_SPI_BASE && virq <=3D GIC_MAX_SPI) { + fwspec->param[0] =3D GIC_SPI; + fwspec->param[1] =3D virq - GIC_SPI_BASE; + } else if (virq >=3D GIC_ESPI_BASE && virq <=3D GIC_MAX_ESPI) { + fwspec->param[0] =3D GIC_ESPI; + fwspec->param[1] =3D virq - GIC_ESPI_BASE; + } else { + WARN(1, "Unexpected virq: %d\n", virq); + return -ENXIO; + } + fwspec->param[2] =3D IRQ_TYPE_EDGE_RISING; + fwspec->param_count =3D 3; + + return 0; +} + +static int qcom_scm_get_waitq_irq(struct qcom_scm *scm) +{ + int ret; + u32 hwirq; + struct qcom_scm_desc desc =3D { + .svc =3D QCOM_SCM_SVC_WAITQ, + .cmd =3D QCOM_SCM_WAITQ_GET_INFO, + .owner =3D ARM_SMCCC_OWNER_SIP + }; + struct qcom_scm_res res; + struct irq_fwspec fwspec; + struct device_node *parent_irq_node; + + ret =3D qcom_scm_call_atomic(scm->dev, &desc, &res); + if (ret) + return ret; + + hwirq =3D res.result[1] & GENMASK(15, 0); + + ret =3D qcom_scm_fill_irq_fwspec_params(&fwspec, hwirq); + if (ret) + return ret; + parent_irq_node =3D of_irq_find_parent(scm->dev->of_node); + if (!parent_irq_node) + return -ENODEV; + + fwspec.fwnode =3D of_fwnode_handle(parent_irq_node); + + ret =3D irq_create_fwspec_mapping(&fwspec); + + return ret; +} + static int qcom_scm_assert_valid_wq_ctx(u32 wq_ctx) { /* FW currently only supports a single wq_ctx (zero). @@ -2396,7 +2453,10 @@ static int qcom_scm_probe(struct platform_device *pd= ev) return dev_err_probe(scm->dev, PTR_ERR(scm->mempool), "Failed to create the SCM memory pool\n"); =20 - irq =3D platform_get_irq_optional(pdev, 0); + irq =3D qcom_scm_get_waitq_irq(scm); + if (irq < 0) + irq =3D platform_get_irq_optional(pdev, 0); + if (irq < 0) { if (irq !=3D -ENXIO) return irq; diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_= scm.h index a56c8212cc0c41021e5a067d52b7d5dcc49107ea..8b1e2ea18a59ac143907a381b73= 236148bace189 100644 --- a/drivers/firmware/qcom/qcom_scm.h +++ b/drivers/firmware/qcom/qcom_scm.h @@ -152,6 +152,7 @@ int qcom_scm_shm_bridge_enable(struct device *scm_dev); #define QCOM_SCM_SVC_WAITQ 0x24 #define QCOM_SCM_WAITQ_RESUME 0x02 #define QCOM_SCM_WAITQ_GET_WQ_CTX 0x03 +#define QCOM_SCM_WAITQ_GET_INFO 0x04 =20 #define QCOM_SCM_SVC_GPU 0x28 #define QCOM_SCM_SVC_GPU_INIT_REGS 0x01 --=20 2.34.1 From nobody Tue Dec 2 00:46:52 2025 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 DE4F72D7DE1 for ; Sun, 23 Nov 2025 14:19:46 +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=1763907588; cv=none; b=rNKcCmgvlsWiaZ7mnFjnzcCjP+wvV1nDOr1VuqWNL+dc7BPr7dZvyI4Pi86ncCMFUdaHMaedc7FM879lQ6Uc5UkbgJUkmufu2fBV6TFGSekGbKQjz3rQPrN/Amu15NLqMYg2I/BpwGjf3An6wGfXI/qiAGawXa309FZjOeT20VI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763907588; c=relaxed/simple; bh=VWfQc5BZbIwnD7HFRfx9d6Vuelk597XYQ25h6fQm2O8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZmUNuRR5QQqHu/5Hde7QcJqJMv28eJMfkPaBu6jXxDz2bTsBxOC562tEahyNQFo9qdpdsL2shFasSlA82cFgO66ubX3D0+mjB/vyktuZUP7Nh/vi7bBCemvizxZMP6aKBjX9kyr5ZMSg6h5QpFdRTYuRBIQOwtNKWAkOADsPmv8= 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=K8Kp3vqO; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ARIYhOQd; 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="K8Kp3vqO"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ARIYhOQd" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5AN9cEjq1076440 for ; Sun, 23 Nov 2025 14:19:46 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= cI76CvmHHMELmH2oLlkSsdIIMgj/IOI288biHSI0Pxg=; b=K8Kp3vqOf6Q/Wi7o j/7e4cvLjAfePEHHnSKTOWR6nCs1v9sdiJXiSAQtg4SmF6I1E/7yiGBrdwqoOF9S 8/PvOZ2U9mcw7xVtFuZX1JZNFI3j8CijZeycjsnIF3fxzXhuEJGycBnfS8F+qvPv lPWki36DZNZmqfw8f/9VcgQUxEHnzkV+p6LIXeBC4R3TTngQkx995Q0DOd7KvLAj 6r2Bxbpt+JvBQP7O8GyyC1yL+oxjtJJ/Zu6g7arcZ8gtuU1AXFRbwrZFQjY/AwKj Y4/e0NMD92ATaYfMXo9xCn+I/AA+lxZhnVkKykL7fKAXLY9nLT1nJxg1yAJw4rEO SjFwGw== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ak6a52ftm-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 23 Nov 2025 14:19:45 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3438b1220bcso3886807a91.2 for ; Sun, 23 Nov 2025 06:19:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1763907585; x=1764512385; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=cI76CvmHHMELmH2oLlkSsdIIMgj/IOI288biHSI0Pxg=; b=ARIYhOQd+BiRTaC2SQHzlRUOFH20JGMpj1Ael3QByBiNfpctbwJZuHaAgNgz1K99/6 UaeOOwDzjETh/o4/6tmmdbHy0nujzanEizefOnLtpMYSz9LDMRRNEjU75+2/ZremqPs9 ZszKl98ZafZA25G/fnYrS5MjFbXNSDjwp1Dd63oj7pZ71S2J/DYJlj45m0UchLK6sVee JcpehAay+HdL28qhb23ynKAEIEjGzeCknVZ8Fc39DdpZz2iZu8B+aZw4qu0So0Be3YCm JrAR6Gw4DnzDgjVLNJDEa5qUhG2SMACn7XkixLdH0CGi8Pk2/uUHZ1x/V+Mb7jnKp5cr pBrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763907585; x=1764512385; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=cI76CvmHHMELmH2oLlkSsdIIMgj/IOI288biHSI0Pxg=; b=Hhh+fwbMXC2JEFpDnmO/wmSYupVZ0ub84oMuCCIv7oCkAorOY6bw+pBOTfJEX5Zfoh RMHnc4BdAdfo5NY2Gd32uVFxAvn6BiaTVbZzEY2Be+3Msd2uES5HRG7qzVmKuEIZA7gj 7wqqCUBjelku5PjC/NcaDZe7Hz92WkVkXM682/Y1jqfEXcDro+G2JhOH3ZvFxl43W8o2 2hznPLai6UuZtajpU3hGo4tEkE9Lg1DzrEubBgDNBlvDJVIdQDt6gaaGlbv9HFpm+Z6h kASzMWIvMq5eEoxjzQPcUurmfwUWznY25UvjaZ/vZBWEGErB6MWbQnY+LWJNJyKACnVC 3QCw== X-Forwarded-Encrypted: i=1; AJvYcCWEu6QkCmLX64OBLmfp8O2TmTLfzp5Qekw6oVqd8jX54VpvkzJt2iC3SUlYT1JhrgowIuszO6Jl6wKUtao=@vger.kernel.org X-Gm-Message-State: AOJu0YykYJDFTVg+SSjqbzbwoHYsTBd+CDeS7oJio1gSWdHRx8cWVopt ZlxuaqrxrjwMwlhF1X54ScE3UY0fORxLuDFUfjJe7Xd4b5qCAPq4db14/8uVZz0WY5tAsK8daZI x989hHf69qxJ7wsgyvfOjenJjjJUOoQ1uaAUvs2+3QzZTPo59crweG+Izjo32cFQUVl8= X-Gm-Gg: ASbGncu//lJ/kqe7D/GSmtQbtcZFxZ5dSgFoPJhGlNTqHQs7s/VpQyrY4nKdoEBzKvC ppCZWPKF9qH97x11XmfSR9yvXe+zUP79fzhnvg+yILz6P05/u/0hB6KM6dDAI9Rwg2VONBbg3R/ bhjyAEGaYXTpbP8Za8A9bXpGzum/cMgnpjwCamvFxid7LV6sYkQiaafzTt3myRQ1XtGQd9MRFn5 xTeYWaD0qZm5eOkp/36AppDkMqMSQmEhbFXvIJwpIRrfErmm+u7mL9Ie9/uvwojPV+G5jRAQMDw zAKh5l0MJ/nq+RvdR5gUnmpBaEKwR5JPf9VlLGnIyHs5jsQPSQMN3WXPBIvsAGA0yRBCHciRDjO 4Y85B6VUQZETBDVrin2uFItrCz73avMoT+/yu5Fcszp1pqA== X-Received: by 2002:a17:90b:3841:b0:32e:a8b7:e9c with SMTP id 98e67ed59e1d1-34733f3d1ffmr8017761a91.29.1763907584758; Sun, 23 Nov 2025 06:19:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHa7GoWiQzcPIOP1Al9nvBo7LmLvBsNdSNsbET1/efKSwpai3tKC85VypYSqMq2KwEYy6/LgQ== X-Received: by 2002:a17:90b:3841:b0:32e:a8b7:e9c with SMTP id 98e67ed59e1d1-34733f3d1ffmr8017738a91.29.1763907584197; Sun, 23 Nov 2025 06:19:44 -0800 (PST) Received: from hu-spratap-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-345af0ca952sm10135992a91.0.2025.11.23.06.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Nov 2025 06:19:43 -0800 (PST) From: Shivendra Pratap Date: Sun, 23 Nov 2025 19:49:31 +0530 Subject: [PATCH v9 2/3] firmware: qcom_scm: Support multiple waitq contexts Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251123-multi_waitq_scm-v9-2-0080fc259d4d@oss.qualcomm.com> References: <20251123-multi_waitq_scm-v9-0-0080fc259d4d@oss.qualcomm.com> In-Reply-To: <20251123-multi_waitq_scm-v9-0-0080fc259d4d@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Unnathi Chalicheemala , Shivendra Pratap X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763907576; l=5927; i=shivendra.pratap@oss.qualcomm.com; s=20250710; h=from:subject:message-id; bh=MTXV4biGU2m/VveAT3FCxiawD238PKh6quPNNW4oQ/0=; b=r0K+uUCt9prvD89u74QQb4pqmbw/Wt2eZG/ok1/ukzrg/8MfzQCK/U39LmJ2WrDazpnOhH8N+ veig/hOeJtrCZwl8xQaMM7ghWdx1oJPCsBxnoIJDtacGdnjKyuQ9TbC X-Developer-Key: i=shivendra.pratap@oss.qualcomm.com; a=ed25519; pk=CpsuL7yZ8NReDPhGgq6Xn/SRoa59mAvzWOW0QZoo4gw= X-Authority-Analysis: v=2.4 cv=Hup72kTS c=1 sm=1 tr=0 ts=69231801 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=QwukUx79tW4PgYOutgUA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-GUID: 679ohVmkC-f2IUabPeFWsCWc3TuyjC1R X-Proofpoint-ORIG-GUID: 679ohVmkC-f2IUabPeFWsCWc3TuyjC1R X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIzMDEyOSBTYWx0ZWRfX4vaDxhyxHCeb pxjSqdYaKs2BQQLrsN8SbVQ2VyTMhE75o3lmZLBEYFBEEfb4EzpUhSQ1AyTfQYm21mphNFFDCdc joWwEikgoVUk5Dl+o45LJSg7qbIFOYPewN93HVrC3orVyA/9SoNRpuS/Zf1ADbeVBqpGPgJk5KE 7rg7t65QchzT9cAefuMLZvqZetBWsH1Jg7FJkOTlZPinhyjBmmC8CWeGKA+FP7LQ5jJEgD5/oph iaoXn1IlfXZmvqizDcANCBW9RNoqddciqML2qyuR1pjQjGp3ALo5sOpzZ5E8/QGwwpogMzBY3B5 TxAR9om0UbjYDFBuskQkijcYAc5HSb77hGjLOaFChe8LDQMRtVX8/68QLQQ/meRUosi7+9AJVV7 hU2zVkbPhUTv7DuriLZFUhVs5VYsJQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-23_05,2025-11-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 phishscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511230129 From: Unnathi Chalicheemala Currently, only a single waitqueue context exists in the driver. Multi-waitqueue mechanism is added in firmware to support the case, when multiple VMs make SMC calls or single VM making multiple calls on same CPU. Enhance the driver to support multiple waitqueue when support is present in the firmware. When VMs make a SMC call, firmware allocates a waitqueue context, assuming the SMC call to be a blocking call. The SMC calls that cannot acquire resources, while execution in firmware, are returned to sleep in the calling VM. When the resource becomes available in the firmware, the VM gets notified to wake the sleeping thread and resume SMC call. The current qcom_scm driver supports single waitqueue as the old firmwares support only single waitqueue with waitqueue id zero. Multi-waitqueue mechanism is added in firmware starting SM8650 to support the case when multiple VMs make SMC calls or single VM making multiple calls on same CPU. To enable this support in qcom_scm driver, add support for handling multiple waitqueues. For instance, SM8650 firmware can allocate two such waitq contexts, so the driver needs to implement two waitqueue contexts. For a generalized approach, the number of supported waitqueues can be queried from the firmware using a SMC call. Introduce qcom_scm_query_waitq_count to get the number of waitqueue contexts supported by the firmware and allocate =E2=80=9CN=E2=80=9D unique = waitqueue contexts with a dynamic sized array where each unique wq_ctx is associated with a struct completion variable for easy lookup. Older targets which support only a single waitqueue, may return an error for qcom_scm_query_waitq_count, set the wq_cnt to one for such failures. Signed-off-by: Unnathi Chalicheemala Signed-off-by: Shivendra Pratap Reviewed-by: Bartosz Golaszewski --- drivers/firmware/qcom/qcom_scm.c | 76 ++++++++++++++++++++++++++++--------= ---- 1 file changed, 54 insertions(+), 22 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_= scm.c index 28979f95e51fbee94b84c1570a4d88a76f72db4e..149c2ccec2a5ff77054178fa021= fd0b721d9f8d7 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -47,7 +47,7 @@ struct qcom_scm { struct clk *iface_clk; struct clk *bus_clk; struct icc_path *path; - struct completion waitq_comp; + struct completion *waitq_comps; struct reset_controller_dev reset; =20 /* control access to the interconnect path */ @@ -57,6 +57,7 @@ struct qcom_scm { u64 dload_mode_addr; =20 struct qcom_tzmem_pool *mempool; + unsigned int wq_cnt; }; =20 struct qcom_scm_current_perm_info { @@ -2247,6 +2248,25 @@ static int qcom_scm_fill_irq_fwspec_params(struct ir= q_fwspec *fwspec, u32 virq) return 0; } =20 +static int qcom_scm_query_waitq_count(struct qcom_scm *scm) +{ + int ret; + struct qcom_scm_desc desc =3D { + .svc =3D QCOM_SCM_SVC_WAITQ, + .cmd =3D QCOM_SCM_WAITQ_GET_INFO, + .owner =3D ARM_SMCCC_OWNER_SIP + }; + struct qcom_scm_res res; + + ret =3D qcom_scm_call_atomic(scm->dev, &desc, &res); + if (ret) { + dev_info(scm->dev, "Multi-waitqueue support unavailable\n"); + return ret; + } + + return res.result[0] & GENMASK(7, 0); +} + static int qcom_scm_get_waitq_irq(struct qcom_scm *scm) { int ret; @@ -2280,42 +2300,40 @@ static int qcom_scm_get_waitq_irq(struct qcom_scm *= scm) return ret; } =20 -static int qcom_scm_assert_valid_wq_ctx(u32 wq_ctx) +static struct completion *qcom_scm_get_completion(u32 wq_ctx) { - /* FW currently only supports a single wq_ctx (zero). - * TODO: Update this logic to include dynamic allocation and lookup of - * completion structs when FW supports more wq_ctx values. - */ - if (wq_ctx !=3D 0) { - dev_err(__scm->dev, "Firmware unexpectedly passed non-zero wq_ctx\n"); - return -EINVAL; - } + struct completion *wq; =20 - return 0; + if (WARN_ON_ONCE(wq_ctx >=3D __scm->wq_cnt)) + return ERR_PTR(-EINVAL); + + wq =3D &__scm->waitq_comps[wq_ctx]; + + return wq; } =20 int qcom_scm_wait_for_wq_completion(u32 wq_ctx) { - int ret; + struct completion *wq; =20 - ret =3D qcom_scm_assert_valid_wq_ctx(wq_ctx); - if (ret) - return ret; + wq =3D qcom_scm_get_completion(wq_ctx); + if (IS_ERR(wq)) + return PTR_ERR(wq); =20 - wait_for_completion(&__scm->waitq_comp); + wait_for_completion(wq); =20 return 0; } =20 static int qcom_scm_waitq_wakeup(unsigned int wq_ctx) { - int ret; + struct completion *wq; =20 - ret =3D qcom_scm_assert_valid_wq_ctx(wq_ctx); - if (ret) - return ret; + wq =3D qcom_scm_get_completion(wq_ctx); + if (IS_ERR(wq)) + return PTR_ERR(wq); =20 - complete(&__scm->waitq_comp); + complete(wq); =20 return 0; } @@ -2391,6 +2409,7 @@ static int qcom_scm_probe(struct platform_device *pde= v) struct qcom_tzmem_pool_config pool_config; struct qcom_scm *scm; int irq, ret; + int i; =20 scm =3D devm_kzalloc(&pdev->dev, sizeof(*scm), GFP_KERNEL); if (!scm) @@ -2401,7 +2420,6 @@ static int qcom_scm_probe(struct platform_device *pde= v) if (ret < 0) return ret; =20 - init_completion(&scm->waitq_comp); mutex_init(&scm->scm_bw_lock); =20 scm->path =3D devm_of_icc_get(&pdev->dev, NULL); @@ -2453,6 +2471,20 @@ static int qcom_scm_probe(struct platform_device *pd= ev) return dev_err_probe(scm->dev, PTR_ERR(scm->mempool), "Failed to create the SCM memory pool\n"); =20 + ret =3D qcom_scm_query_waitq_count(scm); + if (ret <=3D 0) + scm->wq_cnt =3D 1; + else + scm->wq_cnt =3D ret; + + scm->waitq_comps =3D devm_kcalloc(&pdev->dev, scm->wq_cnt, sizeof(*scm->w= aitq_comps), + GFP_KERNEL); + if (!scm->waitq_comps) + return -ENOMEM; + + for (i =3D 0; i < scm->wq_cnt; i++) + init_completion(&scm->waitq_comps[i]); + irq =3D qcom_scm_get_waitq_irq(scm); if (irq < 0) irq =3D platform_get_irq_optional(pdev, 0); --=20 2.34.1 From nobody Tue Dec 2 00:46:52 2025 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 C52972D7DEC for ; Sun, 23 Nov 2025 14:19:49 +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=1763907591; cv=none; b=sg5ld9yQZetal/wz/CqoyZxBlBRvgdCNM2E93r2bX96br2fPIFr+uFJ371VXSx6iM/eLA754d7tTBLHm6ya5FJbF3pI7pzNdeIT6JQea6gZYxBAOSZYvQ/rU9BtWPvNCY1tFHBUEPYzVjC+6y2xM466DqIKkdevloa4bmIFFqSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763907591; c=relaxed/simple; bh=5rLIH0pbgZVGNRk8Y7MpYv7XibWR+Z+oJAscnT605F0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Je4PuuZoTn6cGxuOPuhMOK7bGh4ad4y0OgVAJmti1fmDRn3D6MKbPeQ0SEqeT9i03GtuVbsq2dN2EesPoQXutLGs7D1CtlsCUUCJOwQnDlf2TnrU6/Rb8go6ZAiQQTJ7PE4rtf6JNfmMbICbxXf6NaPjyQ+Y6X2sdkwi0QUIbhQ= 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=S2PF8B4p; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Ea54ub9t; 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="S2PF8B4p"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Ea54ub9t" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5AN9vN6f1306031 for ; Sun, 23 Nov 2025 14:19:48 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= tIUtGezLTYSmkaEQHiNfOZ5kJ5ICHqHIbG7wNlDi+U4=; b=S2PF8B4pKU/MWzM9 +h3RHovf/fzGplgwu0yaa7dgL4k9wpAOaMOAH4VTZybSP7c4lONxhq69gwOHscs9 z9hZDu2Q2nwBZflUSKhf49uLjSGEkLRNJO1ldamvOinCvk2joNRUV2pS/TdkxlgQ UlFFdK83/twIaC5LglI2kcwT5FmOrrdAFLWCQ8oEW3tqDuGinHqvrfSEkXOoqOYA UVU6yr+P9Mj8QT7/YDAYaM4ZY9Pj38YwFMr53BiEJreojVmyKpmV4X6/Uqi8h2HP 7CKAY29lgXY1R0Ol2AVLHLVyfoBvyMZStGGM6oNut9BGDrT4ZCcqexwxjcqeKUSA Y1S+3g== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ak69sjga1-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 23 Nov 2025 14:19:48 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-341cd35b0f3so4443769a91.0 for ; Sun, 23 Nov 2025 06:19:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1763907588; x=1764512388; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=tIUtGezLTYSmkaEQHiNfOZ5kJ5ICHqHIbG7wNlDi+U4=; b=Ea54ub9tMH/xMh8CZrNVGpAhIWTnqE3HrVmEXU0clhx5XHqr4nb3NHIQH21e4ZS+f6 aP6/BHpDLIrb1lpWH4ywk9Di5dIV++QWPvIDlBMNRq8/RN9LPAgrD67JbaTOWhu2EadX vxBgyXHc2ZWSNEntbVSXw8UUo7WKu9L7ecipwVCv1R5EUNR2wKie/oersHIhXXEPDfod CphvGmZQZ0WcdzI055lkMrCxS8nE4n5Nrggnq73cUWsLZPDVuakd92xBMyKNB7bzmGx5 /IbbNs8L/18Gax0a8DvoDmGJmLwY+Xq2qEF5cbfZLeVeJPtGwp5VDQIOVXgmkVg+jYaS Ps3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763907588; x=1764512388; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=tIUtGezLTYSmkaEQHiNfOZ5kJ5ICHqHIbG7wNlDi+U4=; b=uAGaR/g1+5KDxPjpLR8xaLIJY9hDHBhMjVTFjGJuvfHTZTQy4Lw2zRWl9OH2msfhbl WG8VaV6mG2iehSReKBtedaxc9vdVb6spVL/4kQ6X8KJMZhEscIOPMQuAC+Jgk3ZVXTP9 OEnbGxEN0yBRE4XLX5TSi/VG4uibhHT7FTYesNu41DEeo086HtEV7cR8HOqC0oviC+8s 6WzRBodHEg47WVTw+G9ZvjjTUTAEbiZxlxKHnIzYA9fPmIRe1tMtcTAsuEgXMSDLfymN 1NLpu6Qk0iUywz9HN5okGGhjn6y+tMYcwPm90NS8nhOcn+CbF/lbTZCWll8f2G8RXYUQ axsw== X-Forwarded-Encrypted: i=1; AJvYcCW6QW71FzEnyM572ihZQ8DeW1l3J037KXD1B2D8HGS6xoVR1KzybfdNyL1T9xRa/0UpgqLjDVXYnjxGLJQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzZFuXw6PoE4RvDXquo1NSxTNJcdc2DfkA45U24MWrke7XoGT+V nko8b7Ubv19zMkqxFtV46t5tDtosQRKmYiMSvjtV1A/cAw1HTrRMffpEB4Tou1itKXjV7HcbjAE cRCJKQjzS1Gr5ODD/l31SzYREa0w8lfKwV5W+ggIKMyICUALfz3lP2+KldjqIPgdeiGk= X-Gm-Gg: ASbGnctvXYCRVv6HUjfW2Su5RNqSGM971hPeDUWnDX02oJ0MzAt6jht2Rq8VuzZ4+C0 4aSI2XwWLJzLu3VxEGP7iVd2Q13VlqGwQNO3zkZ6ZaBT5c/sZttPEjggb4rK2V016RJp96cZEls pueL7BwAH2v4ZKyHGDTlIf3DXw1Q3Ehj0n1P0RncQQHqCZRG9+btDSck1gq673Leh5K72ENmyz9 LB2ep6P04QmVnGcuN5EfFVO7E56rSRes+B4hlb23RC0KH7O6By+l9sihlW+dI/3uH7NCyGVnyI9 IDb0RMZ6Oji1QegcojmnxBccYHUTu0vMr8U1btTVXFDZHw0QpaMdaP7mtqYezFtD+2u0ZsmRr4u pZlGRkI5u6+ESbBdNuIxGvpTczyWblmbFcsqftQ6aW2B89Q== X-Received: by 2002:a17:90b:3bc4:b0:343:7410:5b66 with SMTP id 98e67ed59e1d1-347298a9f91mr11492035a91.11.1763907587750; Sun, 23 Nov 2025 06:19:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8+iw9JEE8KL8V2QvoLa7/4Y0GF8+Y5R2fOPNQ23o+4pOOjfTQhH5KQZFUI73ZVRLcgefsQw== X-Received: by 2002:a17:90b:3bc4:b0:343:7410:5b66 with SMTP id 98e67ed59e1d1-347298a9f91mr11492011a91.11.1763907587170; Sun, 23 Nov 2025 06:19:47 -0800 (PST) Received: from hu-spratap-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-345af0ca952sm10135992a91.0.2025.11.23.06.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Nov 2025 06:19:46 -0800 (PST) From: Shivendra Pratap Date: Sun, 23 Nov 2025 19:49:32 +0530 Subject: [PATCH v9 3/3] firmware: qcom_scm: Use TASK_IDLE state in wait_for_wq_completion() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251123-multi_waitq_scm-v9-3-0080fc259d4d@oss.qualcomm.com> References: <20251123-multi_waitq_scm-v9-0-0080fc259d4d@oss.qualcomm.com> In-Reply-To: <20251123-multi_waitq_scm-v9-0-0080fc259d4d@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Unnathi Chalicheemala , Shivendra Pratap X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763907576; l=1328; i=shivendra.pratap@oss.qualcomm.com; s=20250710; h=from:subject:message-id; bh=muVZyS/ZI96TOitovzS/6m9ldXptICgjgmgqz4hzF0Y=; b=sh5nb3RAWPn/vaCaXuixCnnOdhSzRgbViCdbwqzaXFqPjzk3iUKqKJtvTHcNrWUZnjNn17DYE mB3ruW6MV+wAP6IWDAlf6ipRG/K77DQ971d5glZJ1FWjbv1AL6L+E82 X-Developer-Key: i=shivendra.pratap@oss.qualcomm.com; a=ed25519; pk=CpsuL7yZ8NReDPhGgq6Xn/SRoa59mAvzWOW0QZoo4gw= X-Authority-Analysis: v=2.4 cv=PNMCOPqC c=1 sm=1 tr=0 ts=69231804 cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=CXMSIrXqJIVyGMYrj-4A:9 a=QEXdDO2ut3YA:10 a=iS9zxrgQBfv6-_F4QbHw:22 X-Proofpoint-ORIG-GUID: 7vl2tqS9_v4ervEvacxtQZMgh4X_FDbK X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIzMDEyOSBTYWx0ZWRfX6frlIsvGGpik x15ZaX1KbEQhRGXrZjcnDm8Zo1lyzO4XuyYOiFDtPF9pD1I9WUGrT+wcm9UOJR+le3zhHap3Gcs Oop0B8Ao0Md4ZChN8RLGNpFeZ9Vc79Qi48pNR9O6niHUvzaAyR0Q3KNNozRmFnzd8rqsPMZ0YuP YXZ7BDEUbaKTPMbuORLSrnK9nxOWVqSoRfInukvotnMQ/1Apz8C5iS8S3qyOOaJDnZma3CxXfhj 8bH8b5E313faUZJbsPDkMUUxssGdSS8C7Lds8TJ5KB26ZLXOd2z0dIhafidlpcOAM50EFF+buQu /XwFQ1L0cuDvrIPAVnLEOiQIcizzokUXnxkycAja+sBW3TGjQaJuAj5FHJACzb5Towqir7fuSQ3 F92nB8ICpe9fv7KdmP+KDKaxa8uyVw== X-Proofpoint-GUID: 7vl2tqS9_v4ervEvacxtQZMgh4X_FDbK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-23_05,2025-11-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 suspectscore=0 adultscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511230129 From: Unnathi Chalicheemala When the kernel issues an SMC (Secure Monitor Call) and the firmware requests the kernel to wait, the waiting thread enters an uninterruptible (D) state. In case of an extended wait request by the firmware, any device suspend request, cannot proceed because of the thread stuck in D state. This blocks the device suspend. Replace wait_for_completion() with wait_for_completion_state(..., TASK_IDLE), so that the waiting thread, show up in TASK_IDLE state, instead of TASK_UNINTERRUPTIBLE (D state). This allows the thread to block until completion, without blocking the device suspend. Signed-off-by: Unnathi Chalicheemala Signed-off-by: Shivendra Pratap Reviewed-by: Bartosz Golaszewski --- drivers/firmware/qcom/qcom_scm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_= scm.c index 149c2ccec2a5ff77054178fa021fd0b721d9f8d7..dfe0410fa9f965b16f8b0a9d98f= 3046e80b8b97b 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -2320,7 +2320,7 @@ int qcom_scm_wait_for_wq_completion(u32 wq_ctx) if (IS_ERR(wq)) return PTR_ERR(wq); =20 - wait_for_completion(wq); + wait_for_completion_state(wq, TASK_IDLE); =20 return 0; } --=20 2.34.1