From nobody Tue Oct 7 14:53:15 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 B98F724397A; Tue, 8 Jul 2025 21:26:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752009965; cv=none; b=kLKAHZ9rvGb79Ukm6ni3o40qnMtiLMLCqGa0gnqgR+zma1zx3NjvWsYDnvx0B1lSDzeNbOz/FzWjO9ZzmbnazDUvIlrnyXvGl3LCIKYKU6V+JZdcsvJzPSs07reiM6GYBKpbOCr4hy13H261GWdyoTrI07fYyq+bwa4eaNmuDqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752009965; c=relaxed/simple; bh=sdK745Vj3Y70qcYzUfHFCTbIE8JLEe6lZLmNzS2Lhb4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TAVqbY2pHkZY2ZhB7uHjZ3G1/HIaQKdZ/Ir2PONd7YBYvgRkkLaeAtloOBr/QmopVP5lN0uQ7nghNzOfIgdcgG4i+ZRT/sXHO5gHrzGswyHMx1E/nB/HEjRKVIu1GKykZItYq/v2zyjdRQrpdn+9KbnvlJxkxbZyaolVJ9HkKd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=nDUbCFiK; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="nDUbCFiK" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 568JFKiM012125; Tue, 8 Jul 2025 21:25:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=Embif+b7D2T 39Tf+uoO+bQc+oYLdcrGbbEu3UPB0XCE=; b=nDUbCFiK/yspgBayRompDe8fCkU SuqoWZzw8zch031qnCrbAaXM/Cya7g70VOiSqYSHpFhhM9TpBITn3AJHoEjSK6Yw 91ug3Yt+uNoZNb0f1xKZEA1wBMOXkfn6a7dfW4k9vay0/JBTyXewh7Zinb0A8G9b mT4S1kxEjTNappngdTX22ZDRJ6Nfr4WgTZfdn8myWJ/+q7AF04E6p7Zt8HDz4hve N7MCGLld9b42uiqk9k+S1LMlMB0Fu7X2gZrdfBrVeYvf/g8a+KyBDI/xIgQPKg8j Gyicidx+ppp82rk3fJDciHDdETJvDpUxkcfBfilAl6WOqSRoua5DArxu84A== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47pv97snqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Jul 2025 21:25:42 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 568LPdMC000892; Tue, 8 Jul 2025 21:25:39 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 47pw4kvamj-1; Tue, 08 Jul 2025 21:25:39 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 568LPcKR000886; Tue, 8 Jul 2025 21:25:38 GMT Received: from hu-maiyas-hyd.qualcomm.com (hu-nitirawa-hyd.qualcomm.com [10.213.109.152]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 568LPc5Z000883; Tue, 08 Jul 2025 21:25:38 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2342877) id 16B0757186F; Wed, 9 Jul 2025 02:55:38 +0530 (+0530) From: Nitin Rawat To: mani@kernel.org, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, bvanassche@acm.org, avri.altman@wdc.com, ebiggers@google.com, neil.armstrong@linaro.org, konrad.dybcio@oss.qualcomm.com Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, "Bao D. Nguyen" , Nitin Rawat Subject: [PATCH V3 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Date: Wed, 9 Jul 2025 02:55:32 +0530 Message-ID: <20250708212534.20910-2-quic_nitirawa@quicinc.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250708212534.20910-1-quic_nitirawa@quicinc.com> References: <20250708212534.20910-1-quic_nitirawa@quicinc.com> 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-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=FrUF/3rq c=1 sm=1 tr=0 ts=686d8cd6 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=VwQbUJbxAAAA:8 a=QKWVBJnHy1B2er2I7z8A:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA4MDE4MyBTYWx0ZWRfXwbnpjSXlFFPu DI82hFvxzFoVVuxhwo/hJJdb0vUOgenElLbIp/V8Kk3NGbaVV6fAzDzu0CdFm7gA3xBVlCK8N4A UJxS2VWeJt3VzNHdvznSf0cTYt0CIvEDKsaujKOidwAqbiWf6b2oFgvzSJsyDBMf0aJhW7A4JDo QurGqeNMLHi53qthnoq0cmDnTClTkO/xyhi1mDRuI+3BXzeCo/ZFFLEMvvyLCCaTEoliQfbDXSP KV0OBvX971UFkigBaxaVqnFPACwc7f+kSS8ZwGfdJBjIXXKaDleTdbPJO08MDVVZHdgTKO1ghBm Cikqaa++H2oUemvGgPSeocXnx0sgII3hXVdfJ8fU38k/F4ADYK1vgUjZZXXtKi+8+4Gv9hwSQO6 RQ323/U/oL+hGm97ZIBk5wl+a1ZRh7EGe2ET+NrhmhBXrTLjutWAVmQU8n1PTxLBPAvufqn3 X-Proofpoint-GUID: VyxMTO_Vi3D9Rvvu-444DikJQLeM5vvJ X-Proofpoint-ORIG-GUID: VyxMTO_Vi3D9Rvvu-444DikJQLeM5vvJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-08_06,2025-07-08_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 clxscore=1015 mlxscore=0 spamscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507080183 Content-Type: text/plain; charset="utf-8" From: "Bao D. Nguyen" The MCQ feature and ESI are supported by all Qualcomm UFS controller versions 6 and above. Therefore, update the ESI vector mask in the UFS_MEM_CFG3 register for platforms with major version number of 6 or higher. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Bao D. Nguyen Signed-off-by: Nitin Rawat --- drivers/ufs/host/ufs-qcom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 318dca7fe3d7..dfdc52333a96 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -2113,8 +2113,7 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba) retain_and_null_ptr(qi); - if (host->hw_ver.major =3D=3D 6 && host->hw_ver.minor =3D=3D 0 && - host->hw_ver.step =3D=3D 0) { + if (host->hw_ver.major >=3D 6) { ufshcd_rmwl(hba, ESI_VEC_MASK, FIELD_PREP(ESI_VEC_MASK, MAX_ESI_VEC - 1), REG_UFS_CFG3); } -- 2.48.1 From nobody Tue Oct 7 14:53:15 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 4E1932417E0; Tue, 8 Jul 2025 21:26:02 +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=1752009964; cv=none; b=o6jHGS8Nu8jJFOdRfFBQQRJhVlFe6sIujFvqBxyDkLwXPXJivA2rh5jebEfiiaHrI4y0d5GfdvfmeZABrxSuvV/pS0fiqvjMblwJBSxq2qYYspX/3PuiaVLZfhCk7LYmrYxAo1FT3/qxo5YVfCvKN0+WDUWCWzNS4URFk77NgBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752009964; c=relaxed/simple; bh=M2+GRVIJzzyVTSieGmh/70mZLHxM1uzhbevAoKQ1kqc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nwWhqrDngwYewxXHw67ToG6NGIGmWrVUZMtCgSetbeoSKCgEU1W4dROUeIDrjFNHan/hxHFnIP5zgLz4GXWBjaS+ABO7sy8VGB6NtXgHZNowE9/Q5/VJcnMPeicUcuPAwo6nJMnBLW4y7j/sD5Kt0DgaqJ7QRcPR6CCwlIYT2C0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=OdxSYtjD; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="OdxSYtjD" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 568I5bTj026767; Tue, 8 Jul 2025 21:25:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=dUpLre4Wxq3 86W+8Iqu5WY0XCFsd42rsQicFmCmD/ro=; b=OdxSYtjDNt8xE/63ZKbI7le41ep CFlmgPRwPyeiV6VNUIFW3CuZqBMui3cxzOl6lq+96hC2EANcjbOzlP1vYyGmSZBQ JuLBouGoBUIoGUsnEaoTX4ekRKhNHhyvIeaWFmMGU1Dm0N3MbJ08CvmCrAU8uzZf 4VdHp89B8hPTPfCQ8zFWgz0lbkh7ORyiOx7X6/Wh3EGJ15UO+LviQm4YRlWMfo4I zvC1i5Go0QvZ+Dnav6p/QZC8M9gxYxryvn5vCeobuLEeuJIw4tdnheGpCEsKTOH7 uHASX/mYKQs4AIJObJF2I5VdtjSWihLo6++ilnqkmTT05Rd06J2NPwI/CEw== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47psdr2ca7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Jul 2025 21:25:43 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 568LPb9x000876; Tue, 8 Jul 2025 21:25:39 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 47pw4kvamr-1; Tue, 08 Jul 2025 21:25:39 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 568LPdSW000901; Tue, 8 Jul 2025 21:25:39 GMT Received: from hu-maiyas-hyd.qualcomm.com (hu-nitirawa-hyd.qualcomm.com [10.213.109.152]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 568LPddl000900; Tue, 08 Jul 2025 21:25:39 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2342877) id DF236571870; Wed, 9 Jul 2025 02:55:38 +0530 (+0530) From: Nitin Rawat To: mani@kernel.org, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, bvanassche@acm.org, avri.altman@wdc.com, ebiggers@google.com, neil.armstrong@linaro.org, konrad.dybcio@oss.qualcomm.com Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Nitin Rawat Subject: [PATCH V3 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Date: Wed, 9 Jul 2025 02:55:33 +0530 Message-ID: <20250708212534.20910-3-quic_nitirawa@quicinc.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250708212534.20910-1-quic_nitirawa@quicinc.com> References: <20250708212534.20910-1-quic_nitirawa@quicinc.com> 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-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=ffSty1QF c=1 sm=1 tr=0 ts=686d8cd7 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=FKiQevh3cX4uHeHiuLsA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: KKOXwnarrAwigm4BI5zMio6WrSqiB_Id X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA4MDE4MyBTYWx0ZWRfX4rRZUll9j8KX fktMKjqdk5SwpzFtvwHvTnvLiiVvLU8ssPy6Eb2GvhmxmWPVZfv5JUpANPWeMDe24kFKV6HWwLM qcJ4JWYT6H2HmadtYVB8grAbPKMskuFshmUHL8qbH7rePxNaqeuOj9XWCKwGvM91OPl5xpAcIhD l1UQ076hoP4Q5HiZRUzWYiyMX0DdZpXojeh0Fx952TYVUIYtA4AZAXEx5W2wS31bLXanuPlHkXY CYMtlj0nyEXqnA7tz5zjZtVGr6zHBhYbjxv/H1jKe4UGdfXDdrNfIKJfgkv1xl/d+ihaFdb/6p2 ZlK8w0+oUbEr6RJQMV4NymnPcP7okPmOvYOgJMi6Uw1CpT5VnSERuBdtBA0CpkXdgJFzYqAeYLi E7orxVyRxJasersjXBufVeLzg5VOCdCS4qUj+we5eV3fUPo1PzIlHSWs2lhxXA+Q/S2dmGHD X-Proofpoint-GUID: KKOXwnarrAwigm4BI5zMio6WrSqiB_Id X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-08_06,2025-07-08_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 priorityscore=1501 phishscore=0 clxscore=1015 suspectscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507080183 Content-Type: text/plain; charset="utf-8" Introduce `ufshcd_dme_rmw` API to read, modify, and write DME attributes in UFS host controllers using a mask and value. Signed-off-by: Nitin Rawat --- drivers/ufs/core/ufshcd.c | 24 ++++++++++++++++++++++++ include/ufs/ufshcd.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 13f7e0469141..8964f8912fb2 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4251,6 +4251,30 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 att= r_sel, } EXPORT_SYMBOL_GPL(ufshcd_dme_get_attr); +/** + * ufshcd_dme_rmw - get modify set a DME attribute + * @hba - per adapter instance + * @mask - mask to apply on read value + * @val - actual value to write + * @attr - dme attribute + */ +int ufshcd_dme_rmw(struct ufs_hba *hba, u32 mask, + u32 val, u32 attr) +{ + u32 cfg =3D 0; + int err; + + err =3D ufshcd_dme_get(hba, UIC_ARG_MIB(attr), &cfg); + if (err) + return err; + + cfg &=3D ~mask; + cfg |=3D (val & mask); + + return ufshcd_dme_set(hba, UIC_ARG_MIB(attr), cfg); +} +EXPORT_SYMBOL_GPL(ufshcd_dme_rmw); + /** * ufshcd_uic_pwr_ctrl - executes UIC commands (which affects the link pow= er * state) and waits for it to take effect. diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 9b3515cee711..1d3943777584 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -1480,6 +1480,7 @@ void ufshcd_resume_complete(struct device *dev); bool ufshcd_is_hba_active(struct ufs_hba *hba); void ufshcd_pm_qos_init(struct ufs_hba *hba); void ufshcd_pm_qos_exit(struct ufs_hba *hba); +int ufshcd_dme_rmw(struct ufs_hba *hba, u32 mask, u32 val, u32 attr); /* Wrapper functions for safely calling variant operations */ static inline int ufshcd_vops_init(struct ufs_hba *hba) -- 2.48.1 From nobody Tue Oct 7 14:53:16 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 F418A241CA2; Tue, 8 Jul 2025 21:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752009964; cv=none; b=IQw0qxqoui5nEYGOAOSGgTGo4bU5C+nDHrkxjFUOYYYEIRu/pukutj0e1t67sacHTqwDLJaEn+ojU+vHL0ixvw+bxsL/yAXYMj1KMXjbPR3lzqPbVlppYVEmljaOPnYypASaOkPNiAe4mRPkQwjmlZKMHqfI7d/OelOUqlvy3TY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752009964; c=relaxed/simple; bh=1L3IixxcSwfogoS7JihmrYCjzc4HVU2/uBp6yic+InU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fEHfyLz3fcKtWuGdi1GaB+YLY6OUO5c7mYxESvXImX/T1o4P3Y6q6WXT0ZfuznIqH0VpFpHM1NW1NmqrDDZ/WxOYTtjqNhNjD/mQy+wRz65B6DAKtIJ4Nci3WhV6cdTR+DleYWrGK8S0BaVyQxtH6+p60l13ELcPlqBXNEor/2k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=BgRBodFK; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="BgRBodFK" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 568JFKiN012125; Tue, 8 Jul 2025 21:25:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=5y0EcV5lJzu HJYyi3eypnGM2WwiOKdaErNNPqTN3v5c=; b=BgRBodFKMO26KlZWdGfxsBXTsJo QQ/R8uzugb9ulO0ijoVjCXCju9+6M4bMBV3QMvUjie9g0AQjifJlBTu5DKQHFYs2 k1eHpz6W12u1fc9lEluRTsHbKrkZa2s3wNN09Kv4WIA9LDQvWKvfyawngOEAZlXY cyL55ssDbYJrrcYii9X3UqopWZmECegMSrDKLekw3jHW5FMx6Nm6m2qILvUTK/Uk Z9I6tHBfL0v+XE8qo8j1/BjW6Sub39U+ua4mvsPeYZZ07VjUFunMuQgKk/2aITYi nOQ17qsyXZTn/ZheiLdRxGFc1P5UtAgFIR3I1bStYOt1KMMOlNtb8G3gs8Q== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47pv97snr4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Jul 2025 21:25:43 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 568LPdMD000892; Tue, 8 Jul 2025 21:25:40 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 47pw4kvamw-1; Tue, 08 Jul 2025 21:25:40 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 568LPeMH000939; Tue, 8 Jul 2025 21:25:40 GMT Received: from hu-maiyas-hyd.qualcomm.com (hu-nitirawa-hyd.qualcomm.com [10.213.109.152]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 568LPee2000938; Tue, 08 Jul 2025 21:25:40 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2342877) id DA8F557186F; Wed, 9 Jul 2025 02:55:39 +0530 (+0530) From: Nitin Rawat To: mani@kernel.org, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, bvanassche@acm.org, avri.altman@wdc.com, ebiggers@google.com, neil.armstrong@linaro.org, konrad.dybcio@oss.qualcomm.com Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Nitin Rawat Subject: [PATCH V3 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating Date: Wed, 9 Jul 2025 02:55:34 +0530 Message-ID: <20250708212534.20910-4-quic_nitirawa@quicinc.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250708212534.20910-1-quic_nitirawa@quicinc.com> References: <20250708212534.20910-1-quic_nitirawa@quicinc.com> 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-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=FrUF/3rq c=1 sm=1 tr=0 ts=686d8cd8 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=qOmeOml8TDbB3g6YpnoA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA4MDE4MyBTYWx0ZWRfX8Ebkh1hKLjPl hRK1r0/iLZwggra7C7okZWO+QYHp9lpEVmUPm8z25g4CItuXUfPBX+yYRoH2t4nBdyN8BnT+Pzt P8pawEYdL/S37dO5vqju/8R/3gTt7LAbOgE85BhQ2J5JgWPSgG/cUVoS8RrY5buxrVb8pWV2fKN OG0lTTSMsBIrmXYBxIYe5YsKEA2fVRIrh3j6y0+fYTi9xCWbZcfcX4F8kiJZP1E/GFsb9cYcTcj g57c9hGu6mM6wMAVkybWBdNi8xFThT5hZjWMD0Dli2457AiWBpVtCXrX2dw00K2rOM8c4ec7Gya CnYAgodkf0EimcgHfAk6Kqo5+URSICJGN8XOrPQcnYgHzkGxhOdTF+Al4pIxe/IaB+jGF5IZPft 6Miir6vTrJ0sRMNzMH9jwkJPHavXVvCl3ln9fKBza3dXyf7batWGo6O0DZInhS67nXdxQKz/ X-Proofpoint-GUID: neuZG4UHQ6cb82edTmPyxoqdQLO9Uzt_ X-Proofpoint-ORIG-GUID: neuZG4UHQ6cb82edTmPyxoqdQLO9Uzt_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-08_06,2025-07-08_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 clxscore=1015 mlxscore=0 spamscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507080183 Content-Type: text/plain; charset="utf-8" Enable internal clock gating for QUnipro by setting the following attributes to 1 during host controller initialization: - DL_VS_CLK_CFG - PA_VS_CLK_CFG_REG - DME_VS_CORE_CLK_CTRL.DME_HW_CGC_EN This change is necessary to support the internal clock gating mechanism in Qualcomm UFS host controller. This is power saving feature and hence driver can continue to function correctly despite any error in enabling these feature. Signed-off-by: Nitin Rawat --- drivers/ufs/host/ufs-qcom.c | 21 +++++++++++++++++++++ drivers/ufs/host/ufs-qcom.h | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index dfdc52333a96..4bbe4de1679b 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -558,11 +558,32 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba = *hba) */ static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba) { + int err; + + /* Enable UTP internal clock gating */ ufshcd_rmwl(hba, REG_UFS_CFG2_CGC_EN_ALL, REG_UFS_CFG2_CGC_EN_ALL, REG_UFS_CFG2); /* Ensure that HW clock gating is enabled before next operations */ ufshcd_readl(hba, REG_UFS_CFG2); + + /* Enable Unipro internal clock gating */ + err =3D ufshcd_dme_rmw(hba, DL_VS_CLK_CFG_MASK, + DL_VS_CLK_CFG_MASK, DL_VS_CLK_CFG); + if (err) + goto out; + + err =3D ufshcd_dme_rmw(hba, PA_VS_CLK_CFG_REG_MASK, + PA_VS_CLK_CFG_REG_MASK, PA_VS_CLK_CFG_REG); + if (err) + goto out; + + err =3D ufshcd_dme_rmw(hba, DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN, + DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN, + DME_VS_CORE_CLK_CTRL); +out: + if (err) + dev_err(hba->dev, "hw clk gating enabled failed\n"); } static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index 0a5cfc2dd4f7..e0e129af7c16 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -24,6 +24,15 @@ #define UFS_QCOM_LIMIT_HS_RATE PA_HS_MODE_B +/* bit and mask definitions for PA_VS_CLK_CFG_REG attribute */ +#define PA_VS_CLK_CFG_REG 0x9004 +#define PA_VS_CLK_CFG_REG_MASK GENMASK(8, 0) + +/* bit and mask definitions for DL_VS_CLK_CFG attribute */ +#define DL_VS_CLK_CFG 0xA00B +#define DL_VS_CLK_CFG_MASK GENMASK(9, 0) +#define DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN BIT(9) + /* QCOM UFS host controller vendor specific registers */ enum { REG_UFS_SYS1CLK_1US =3D 0xC0, -- 2.48.1