From patchwork Thu Feb 13 08:00:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ziqi Chen X-Patchwork-Id: 13972892 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 5036620B21B; Thu, 13 Feb 2025 08:00:59 +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=1739433662; cv=none; b=XwxnSKQ+WTSK77PKy2fBvMEpCa+jlU8dG+3yNVa/shjQFqjRLmq2Is0CUn0KePXNimZO/dEfOlJ3yU1gGv9H+6b+/Qqp+WT820G5pfNwsFj1SxgAvPTt17bB78Ri9Slp14UXZVpwTvKAWr+95QlO0RklHVdx/oZAnHl+0MMdkTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739433662; c=relaxed/simple; bh=DUVoWE3MlxwKn9JLSYBDq7XIxpsu4JPylDv8x7E5Axw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=LqrfAg/s5Cld0cIxgC/50M+WEeLqjnIh/Ulo+bIFbjHvtALseVMY2e2yiueFnO5V3QCWTRkoS0mN+NeYu7sFiFZV195oQlen1iomzYfN31bHtgeMgTmtH6S6OhSmoh6fj0Gb/0OQYkYEsA7a8ZOP5UhRvYbQ0sllIsw8tQjBr2M= 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=G4IWGxr6; 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="G4IWGxr6" 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 51CKjX3d026555; Thu, 13 Feb 2025 08:00:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=Ui7oXgJHmBzyYBQ9MLjgFn 4kXsRVlqIXqja6N/N7R2E=; b=G4IWGxr6el43hKrsAa1rS35HBoJaDFQej5CDhb DSaRYbXfKANgF7v6nQc6dCnmctCVa0e3pWyxoj+gw0/c1QVZyxmo3tV7huyNtxMd 1jmS4A+wAtg2p41MqIBpSPvXOjqSy/JUovUVCk5OQ7Puz+CKa8vVqXN63Hpv1reH VnIQ6qr7MW5bubqomTNHepYpj+55NllSlkMA1JkMaBTUZVCjmHQbJFAkDG2iR5I1 T9q+OEjdkZwWx8JeVCn9AGwVYt4alkOhiW0pUtaTjJ2glRxTqCpGstJuYbn78Dp9 zs9YYCAdzDupZPJCSwXmOKBj9yP2foAfIt8zURg8P6UNLeRQ== Received: from aptaippmta02.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com [103.229.16.4]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44r5j5ea0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Feb 2025 08:00:30 +0000 (GMT) Received: from pps.filterd (APTAIPPMTA02.qualcomm.com [127.0.0.1]) by APTAIPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 51D80KBj020791; Thu, 13 Feb 2025 08:00:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA02.qualcomm.com (PPS) with ESMTPS id 44p0bkxyaq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Feb 2025 08:00:20 +0000 Received: from APTAIPPMTA02.qualcomm.com (APTAIPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 51D80KW9020786; Thu, 13 Feb 2025 08:00:20 GMT Received: from cbsp-sh-gv.ap.qualcomm.com (CBSP-SH-gv.ap.qualcomm.com [10.231.249.68]) by APTAIPPMTA02.qualcomm.com (PPS) with ESMTPS id 51D80J5n020784 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Feb 2025 08:00:20 +0000 Received: by cbsp-sh-gv.ap.qualcomm.com (Postfix, from userid 393357) id E17CE40C04; Thu, 13 Feb 2025 16:00:18 +0800 (CST) From: Ziqi Chen To: quic_cang@quicinc.com, bvanassche@acm.org, mani@kernel.org, beanhuo@micron.com, avri.altman@wdc.com, junwoo80.lee@samsung.com, martin.petersen@oracle.com, quic_ziqichen@quicinc.com, quic_nguyenb@quicinc.com, quic_nitirawa@quicinc.com, peter.wang@mediatek.com, quic_rampraka@quicinc.com Cc: linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, Neil Armstrong , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org (open list:ARM/Mediatek SoC support:Keyword:mediatek), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support:Keyword:mediatek), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support:Keyword:mediatek) Subject: [PATCH v5 0/8] Support Multi-frequency scale for UFS Date: Thu, 13 Feb 2025 16:00:00 +0800 Message-Id: <20250213080008.2984807-1-quic_ziqichen@quicinc.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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-ORIG-GUID: XpbLdaNEn4r3hqkMCw3_q-3ZRgTqx9RN X-Proofpoint-GUID: XpbLdaNEn4r3hqkMCw3_q-3ZRgTqx9RN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-13_02,2025-02-11_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 spamscore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502130060 With OPP V2 enabled, devfreq can scale clocks amongst multiple frequency plans. However, the gear speed is only toggled between min and max during clock scaling. Enable multi-level gear scaling by mapping clock frequencies to gear speeds, so that when devfreq scales clock frequencies we can put the UFS link at the appropraite gear speeds accordingly. This series has been tested on below platforms - sm8550 mtp + UFS3.1 SM8650 MTP + UFS3.1 SM8750 MTP + UFS4.0 Tested-by: Neil Armstrong # on SM8550-QRD Tested-by: Neil Armstrong # on SM8550-HDK Tested-by: Neil Armstrong # on SM8650-HDK v1 -> v2: 1. Withdraw old patch 8/8 "ARM: dts: msm: Use Operation Points V2 for UFS on SM8650" 2. Add new patch 8/8 "ABI: sysfs-driver-ufs: Add missing UFS sysfs addributes" 3. Modify commit message for "scsi: ufs: core: Pass target_freq to clk_scale_notify() vops" and "scsi: ufs: qcom: Pass target_freq to clk scale pre and post change" 4. In "scsi: ufs: qcom: Pass target_freq to clk scale pre and post change", use common Macro HZ_PER_MHZ in function ufs_qcom_set_core_clk_ctrl() 5. In "scsi: ufs: qcom: Implement the freq_to_gear_speed() vops", print out freq and gear info as debugging message 6. In "scsi: ufs: core: Enable multi-level gear scaling", rename the lable "do_pmc" to "config_pwr_mode" 7. In "scsi: ufs: core: Toggle Write Booster during clock", initialize the local variables "wb_en" as "false" v2 -> v3: 1. Change 'vops' to 'vop' in all commit message 2. keep the indentation consistent for clk_scale_notify() definition. 3. In "scsi: ufs: core: Add a vop to map clock frequency to gear speed", "scsi: ufs: qcom: Implement the freq_to_gear_speed() vop" and "scsi: ufs: core: Enable multi-level gear scaling", remove the parameter 'gear' and use it as return result in function freq_to_gear_speed() 4. In "scsi: ufs: qcom: Implement the freq_to_gear_speed(), removed the variable 'ret' in function ufs_qcom_freq_to_gear_speed() 5. In "scsi: ufs: core: Enable multi-level gear scaling", use assignment instead memcpy() in function ufshcd_scale_gear() 6. Improve the grammar of attributes' descriptions in “ABI: sysfs-driver-ufs: Add missing UFS sysfs attributes” 7. Typo fixed for some commit messages. v3 -> v4: 1. In "scsi: ufs: core: Toggle Write Booster during clock scaling base on gear speed": a. Add comment for default initialized wb_gear b. Remove the unnecessary variable “wb_en" in function ufshcd_clock_scaling_unprepare() 2. Typo fixed for commit message of "scsi: ufs: core: Enable multi-level gear scaling" 3. Make the description words are more standardized in "ABI: sysfs-driver-ufs: Add missing UFS sysfs attributes" v4 -> v5: 1. keep the identation consistent 2. Change the data type from 'int' to 'u32' vop freq_to_gear_speed() return value Can Guo (6): scsi: ufs: core: Pass target_freq to clk_scale_notify() vop scsi: ufs: qcom: Pass target_freq to clk scale pre and post change scsi: ufs: core: Add a vop to map clock frequency to gear speed scsi: ufs: qcom: Implement the freq_to_gear_speed() vop scsi: ufs: core: Enable multi-level gear scaling scsi: ufs: core: Toggle Write Booster during clock scaling base on gear speed Ziqi Chen (2): scsi: ufs: core: Check if scaling up is required when disable clkscale ABI: sysfs-driver-ufs: Add missing UFS sysfs attributes Documentation/ABI/testing/sysfs-driver-ufs | 33 +++++++++++ drivers/ufs/core/ufshcd-priv.h | 15 ++++- drivers/ufs/core/ufshcd.c | 64 ++++++++++++++++------ drivers/ufs/host/ufs-mediatek.c | 1 + drivers/ufs/host/ufs-qcom.c | 62 ++++++++++++++++----- include/ufs/ufshcd.h | 9 ++- 6 files changed, 149 insertions(+), 35 deletions(-)