From nobody Tue Oct 7 12:29:45 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 4921F23AB86; Wed, 9 Jul 2025 20:56:53 +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=1752094614; cv=none; b=W9dtUY6gp0PsWkcVgMAt9gB8bJJlvoRr9Mdfd96M1wIZRaPs3J3XRjO50Ha6fJmBl4AkL8HZN66UO9UHpWB9ghJQ/WHvtNQBbJzEUFQUK1c3qWBUGQNy+KfKCRIaSgRx9UgzYhctO+y9LPoiJUOkrOddd28BVh9Q/EfefEZR+4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752094614; c=relaxed/simple; bh=sdK745Vj3Y70qcYzUfHFCTbIE8JLEe6lZLmNzS2Lhb4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uy88uh2iKGqoDWHHcpCevBmn/EzVKIq5RWT0J8rX8LlXsgVWK2DUcbBF8QhgZ5LnfcR8iw6JYciY53ftdqFT5dh2CdyTDDfWK4qI+WftnsTATKo/vnYOMMtmuD5eqQqQKe2qLZvVyxMZWZ4i/yHU6yX5+y4ji/aR+4fVkGI4Z+o= 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=VAG6I94F; 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="VAG6I94F" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 569CobWx016794; Wed, 9 Jul 2025 20:56: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=VAG6I94FTt73z7ttOatEuZECm3l 4h8rNSUx4GqfzITSs9uu10w9ot59iOtN6Io6oSbbQqhcdoYItwRaKzzHry6Sb8Uw VujZ1ukvap0PJBjpEB1v6yJJsBHw5MzLNN/QVWb+IkgNx98wyzGn0ojR4U+hOEeB 7TR7Whq/kERX69Af+wQOytFB8mcyWbiKPyMozc6yCvVt/Uo6oaEN1DvsJ970WOid 1sz5JbUQUwhWnf97pSoBGcDlz0yJDec7d4+vhauYJp+phw0sdL/w/iCrCrhSqi70 W1EGF2XUleuy1qLIL3iUKVZVdiJI3aBfN7oI3oSrOK2qCdfOq84NN//Vu/w== 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 47smbntepb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Jul 2025 20:56: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 569Kudu5029896; Wed, 9 Jul 2025 20:56:39 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 47sdus4c7n-1; Wed, 09 Jul 2025 20:56: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 569KudWK029890; Wed, 9 Jul 2025 20:56: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 569KucsJ029886; Wed, 09 Jul 2025 20:56:39 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2342877) id 5C15A57186F; Thu, 10 Jul 2025 02:26: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 V4 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Date: Thu, 10 Jul 2025 02:26:33 +0530 Message-ID: <20250709205635.3395-2-quic_nitirawa@quicinc.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250709205635.3395-1-quic_nitirawa@quicinc.com> References: <20250709205635.3395-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-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA5MDE4OCBTYWx0ZWRfX0hE0hVatRV0C YYl2Fnp0a4fA3hN4JUsxjgkvbkixTC6TD2wf6pGxC0xKECV9bDjha00BGoZXkn/jfo8Bk2urzg+ yf0qNkDo2Gom/MFbEa33GSngWg9wbOEvl9KcjytY4vglGMJB+kg6P2+SKK7Tr2Hnm1dZo8VyGhW VGMRrWcr8KkcxHKoorcmSLbIKBCytxrsXVXkQUMwU8iuCnno86wNMLa+eM+BIAVsFsOhC482cZX RVFoOL/dP1l6nJq6ZYRj47fq7lxc/DNJFUb2flHigIFWugY6fxqFbmgLH8oxyjXOEM8023X2OJd hxigAttXI0gFb3SF6ZplbMaYaRAaXTLhID+kgfr+8NvR2sXUO2RM1zGEac4Ro9FOFBpG9MI9/4l LdQ4fNithzM+gmB857R6O46Ybp/Cc2L25uKYQNehpWpcDETJ+bQCBXyib92gECgAQi3WCDQi X-Authority-Analysis: v=2.4 cv=QM1oRhLL c=1 sm=1 tr=0 ts=686ed78a 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-ORIG-GUID: yXGRr5bzM9082PkUlpN573GgOvr4Cn04 X-Proofpoint-GUID: yXGRr5bzM9082PkUlpN573GgOvr4Cn04 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-09_05,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507090188 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 12:29:45 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 228C224679F; Wed, 9 Jul 2025 20:56:55 +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=1752094617; cv=none; b=d/ojDjQwvPds1Y7F6t6Idzupzq2R5I+nhHngbQ3k4gzNk0XtDR05165D7NUUZmeRvvFV+hJ6tzISTakywV5DDPxeBovyDbdB+XWQsZtBkSjRMokP2kPYQ+sk8RWQEB2uCRTIKkSaEnjE/v84MCWgaKUjrN7dBRryWmpt8vzKpaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752094617; c=relaxed/simple; bh=CHwVxYD5o2KPSWWyuzrq+m8uu7HG9NIQ2Uo4BhoRAwI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OtdLU4rgSNH8KLV6sqWyESxIG/rRf7lrSPm/CK6Bz7URxZOSWlvUbzctjA5ameVp3dnvOviwCzP/ucchdYSmrgiOR2f0PmtTM4erTcREZxnfGNA+FNPVG2elxk5zhLF95b6B9c3gS60z33BOuGZpq/X9IrGT+iGBxPQ6+PtjBks= 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=jJTlluFn; 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="jJTlluFn" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 569Cp9xc015336; Wed, 9 Jul 2025 20:56: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=q0CBs4ZVtOU kYbBJDC2bi65n1zlWq+EK2iiNmO9MBIM=; b=jJTlluFn/WP91v1x3JyisPbNIq/ XZbEvd4GTipOL0XVkBqQPqREcfqKAFK612+iifj6V5fKhrK5ePqN8cyaB2Arm5bf HgeY9reqB7++Tle127SIirnvaJp8tDw5LctK1fg+2Z4wrBAMr9k3LJexZtOnel72 25HkYfZDV64J/L0oRJLITj+jQ6eaveo7EyY/49Sq+ihePf/OML1YUQPNg8v5+Mwd p+bAWUQd2iEbqlFPmZjNVrBpN3jTsSkIzXIK6jdLU+yDw45vjYAKCq/Jn+r4pB0Y DnXFs8RWedWjEMcwepY7m+sQDqxpIn+SUzEotp96Z3gyYPB04NClj4DyQHQ== 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 47r9b13c80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Jul 2025 20:56: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 569KueRi029929; Wed, 9 Jul 2025 20:56:40 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 47sdus4c7t-1; Wed, 09 Jul 2025 20:56: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 569Kue1f029924; Wed, 9 Jul 2025 20:56: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 569KudZi029921; Wed, 09 Jul 2025 20:56:40 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2342877) id 523F857186F; Thu, 10 Jul 2025 02:26: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 , kernel test robot Subject: [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Date: Thu, 10 Jul 2025 02:26:34 +0530 Message-ID: <20250709205635.3395-3-quic_nitirawa@quicinc.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250709205635.3395-1-quic_nitirawa@quicinc.com> References: <20250709205635.3395-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=dYuA3WXe c=1 sm=1 tr=0 ts=686ed78b cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=Wb1JkmetP80A:10 a=VwQbUJbxAAAA:8 a=QyXUC8HyAAAA:8 a=COk6AnOGAAAA:8 a=FKiQevh3cX4uHeHiuLsA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA5MDE4OCBTYWx0ZWRfX5uXVMk1P0M42 ygvKT66UaEcBPPWn/X0+5XPxES0EN8QK8B7iOTs1HR0VqFuwkJVzeoEocqGFZSGv6MqhhFpZ/WR PBlr4vuuusi1Cwz1R3GgbXL1PwEh4ibmzw/IfqlLkQmaDJ3IXkAAfkKZC+R5PDovVLpQoiyUgOj dfNBYfXXyRtLR6ieriF7hu3uIUDKZ2i9in2WtBs1OG5HXgzh1qcf9KaFQwp3s6dQLDFiI3zFxrK Ws1t0T67ANEcE121Q5mPXtkIBH8J4ckCUR+NKcHkknr2K90ixcNYhV+qktzsZSnYiVY456TW4yi y94P4HapvXDvfoCn9Wqv7pcO8HxgXoesGTX4K6B1w0Ci9sf/SrbJcpaHKrVPo8xV2cTmk5h6D3K tbNKAX+nlcdAlPPHELnyyYJ1dJttRsNc3g22Ak35vCe/2xFUAbii8gGm1bG2iHFe0RZgbxc4 X-Proofpoint-GUID: CUK8VXfwaCU3FRUO5jtywv3mca5sqoSk X-Proofpoint-ORIG-GUID: CUK8VXfwaCU3FRUO5jtywv3mca5sqoSk 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-09_05,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 suspectscore=0 clxscore=1011 impostorscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507090188 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. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202507091547.T2t1t8Wz-lkp@int= el.com/ 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..42b9b7b0ee7c 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 12:29:45 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 2B6B4235046; Wed, 9 Jul 2025 20:56:53 +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=1752094615; cv=none; b=M5Z2s4V2G8nl1YFEv2/IiKIn9C3yOiC11WoLI3fSEpl4MFwgRtFqcR4YG0tipDCfl4T7JdPFcUV74V5TWwNw+ZsBR7dH/qgSPL3FLV+HfAAsRevfYbjSPGtUO+VVZwHvA1n68huLB0x4rDGK2yCJOq3ApyVpGNqU268lv7RIT8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752094615; c=relaxed/simple; bh=1L3IixxcSwfogoS7JihmrYCjzc4HVU2/uBp6yic+InU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n/a1R1cwPofejP9gETA0SgSVT8lbnGooc4koWhSPK4kpTeJwPOw02tLMZgLqm+MPQIsRu3oDOE/tQHeXRzx5MdcT0CKeN89Cn6DHy/Li82aFwiBCIb58zxRQ7SFF2pzocw/2s0iaSoGOvU9PJ776o5lCAVfjC0j0dPv0GVM/CCI= 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=YPjNnN15; 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="YPjNnN15" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 569Cp2FQ032001; Wed, 9 Jul 2025 20:56:45 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=YPjNnN15i9NKTq6nEAmsIuBOBuW ZiDir1ac/TIvFrKC6jJSZBrgzisLxwFHjeTQNv7sN/gEOODFW2uZY+62c+Z+eflk 7DwgvBaP/dYjpz68+EXd9Wn8F7qrJrZXMlB74t3+LF3SsaHQe1ngiOyeigjHGdUC 60vC8pxBd7dP9cDDRogiW5GFRKyxXp/jtSMShvEwADN2ESApidkYuzl6qwmV+gw3 Z8DRM5zaInGWT9jTWsMsI3wMphYeIH3ze5BNJYdADY9Q+IuUwzel+zrmh+Qu1H/f yexnZD/f5oaFhDOUzp7DoHY39XDNTGwhGufqA6JC0/5nTRpfQA4JsZvC/8w== 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 47pw7qw41y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Jul 2025 20:56:44 +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 569KufEc029941; Wed, 9 Jul 2025 20:56:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 47sdus4c7y-1; Wed, 09 Jul 2025 20:56:41 +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 569KuePB029936; Wed, 9 Jul 2025 20:56: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 569Kuesr029935; Wed, 09 Jul 2025 20:56:40 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2342877) id 1ADFA571870; Thu, 10 Jul 2025 02:26:40 +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 V4 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating Date: Thu, 10 Jul 2025 02:26:35 +0530 Message-ID: <20250709205635.3395-4-quic_nitirawa@quicinc.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250709205635.3395-1-quic_nitirawa@quicinc.com> References: <20250709205635.3395-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-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA5MDE4NyBTYWx0ZWRfX7E+5KeJFhJaZ 1N+G12A/yL30zEOFj5k4g2eXqacyBxV0WGUC8wdEpQIAHkyYNmANeSDjBjWzrQq/7dxGfuxz8+t urPELGpxRfu/Yw0zOxc7KV0kX7kncmD8yp6KZyBcv56eLUb4LPMroimgYmccpUp7pFRd9Jv23ny MuIm39ec4w9u+DfQU7bYqd9fzby32TeubBrlcC+8mlIIJOBnRHWqtpNNsQjHPZ2T/TX8h9PRx+/ kug/LkVqDQc+RTHd0jiJ4F4LFpU5yF3PwrdawmFMUmuNHScPsw4vqkNvltBQnmcZiSEWCjnFojI nYcBsI6QHgpLQnKqHGMQP3Qvah64V2zkbjNRS/hAkGwbglhQu3mfbnpgc038SzGSVTs9Mp369X1 KzPJJngf2Ag1iFrnQC0OTTs5XVj62p8DPobrO1KLEHpKoOB8sekUBUVzr3IDTPFF4e+wf2Q4 X-Proofpoint-GUID: eo5R2XO7uslK_ImJp56HyD_sEXX2owuK X-Proofpoint-ORIG-GUID: eo5R2XO7uslK_ImJp56HyD_sEXX2owuK X-Authority-Analysis: v=2.4 cv=SOBCVPvH c=1 sm=1 tr=0 ts=686ed78c 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-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-09_05,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507090187 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