Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp746551rdh; Thu, 23 Nov 2023 17:56:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXbCsmy/kiwz4UUonh9Asl14InuLmfI5S+v3hekEQC6PN/3ZQJcPs19tmjmlMOerVS6QMt X-Received: by 2002:a05:6a20:13c8:b0:18b:c96b:a433 with SMTP id ho8-20020a056a2013c800b0018bc96ba433mr1262168pzc.56.1700791015541; Thu, 23 Nov 2023 17:56:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700791015; cv=none; d=google.com; s=arc-20160816; b=AxyF3k63r7VwYHRzg6BPTg7Pv32Ue8bEKIOX9zheLKKhzl8Cxdz5qEodvRDb2JeDp2 gXTXBZrW7ZZmcR/VZGMEDcXOrDpye44hTlwO3Fy9gAYd7OCQ6dDeWWa99PTPEajfjJK2 KMofcVT0ris1hySQdx+70iCRwFkctUGeV5tuFyAfwWaoKRTxy1ExoGvI36Cko9EDN3tn mBJNqOFOfC0gahC3+P65Fvukk6LrV+6HnpTwR7UdNHILfV2UdrnFAOrFiaDQ/HuRfh35 Zk0uUThFtcBa+rfDTPBBwUAoV7W6Mjdb7PtqiA29OEGKytQQYkDgN7Ks+IzHWeD5lwz9 Q46w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=bKXuh++ZqwEZA9C3H/cwpqmOWdyZdH7ObxuMLPbyP0M=; fh=QeBLSpfo5qw+s2TlY3J9XWEgMbxTAflsovaK4aox/X0=; b=Advoo7gLBi0u4JZmxF1IAScdhlaZTJyrdL0E91ShblFsIPtZKF0aAvl94qt87XCm4Z tVy3bJxeJ5rSwh1He4epdYk+FCb/aHbugYA65W691VMtOYjPJCW8gwfBDBdNEM6Q6NoZ Dw8tKTQ95qfAf8R2PEB0V/31GUg/AiLYkcq03AghwMfR/vqqT+GNtr21H5M+Kp3RzkB5 tcBFOag0MLgxvliNulu9sVtU11psmwbHjFpE8odDpMCCeb8J1Iys/bA31lr9F4sC8+2I 2e2H19BLyPEUUDmeWXShWnPZqDaKUNbtASPwOwJ9dLDVmDRCuGY0AVvVoxzJz+xAJvRp k+9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Nrltqsvz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id n30-20020aa7985e000000b006cba621ba41si2289621pfq.80.2023.11.23.17.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 17:56:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Nrltqsvz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 58B00805E121; Thu, 23 Nov 2023 17:56:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbjKXB4a (ORCPT + 99 others); Thu, 23 Nov 2023 20:56:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbjKXB43 (ORCPT ); Thu, 23 Nov 2023 20:56:29 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08BD1D7F; Thu, 23 Nov 2023 17:56:34 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AO1nrVc010703; Fri, 24 Nov 2023 01:55:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=bKXuh++ZqwEZA9C3H/cwpqmOWdyZdH7ObxuMLPbyP0M=; b=NrltqsvzXEr0EScQOlkOJ4CU2vS6y1/CQ9MWWeNUCEdP26gR8o/19tE7WR6yTWuLhCKE E2UMeMQQbgiHCCBaJtJ9b6J/19mWeMSBssUDYVo2vuCr3McUS1qhPDjR5rTI4n5dq44l rA6MmEJYckuC/AfBrPifNM5mWMZgug5bG2tc2StXkIu/+YW+zMmcVyrNLOPweFPnqi8n H3g2k5uXcceaz6r7wDz9OIX67e0B81Jy87jV2Ru46LcjDvdnEGie5/t+Eivpvth5nk98 rwtcxnSoC3Iaa9c8U0FDwVecNcZ0KzeJ4oLG/HyUfaLPBA7K1jlQWFMBjGt9JpWFWQJY Iw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uj7gjs46u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 01:55:38 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AO1taJK025184 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 01:55:37 GMT Received: from [10.253.9.129] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 23 Nov 2023 17:55:33 -0800 Message-ID: Date: Fri, 24 Nov 2023 09:55:31 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 09/10] phy: qualcomm: phy-qcom-qmp-ufs: Add High Speed Gear 5 support for SM8550 To: Dmitry Baryshkov CC: , , , , , , , , , Andy Gross , Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , "open list:GENERIC PHY FRAMEWORK" , open list References: <1700729190-17268-1-git-send-email-quic_cang@quicinc.com> <1700729190-17268-10-git-send-email-quic_cang@quicinc.com> Content-Language: en-US From: Can Guo In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: XrcMH2O--mJqxqQhl5NDSDkrHDBM6-O8 X-Proofpoint-GUID: XrcMH2O--mJqxqQhl5NDSDkrHDBM6-O8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-23_15,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311240012 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 23 Nov 2023 17:56:46 -0800 (PST) On 11/23/2023 8:35 PM, Dmitry Baryshkov wrote: > On Thu, 23 Nov 2023 at 10:47, Can Guo wrote: >> >> On SM8550, two sets of UFS PHY settings are provided, one set is to support >> HS-G5, another set is to support HS-G4 and lower gears. The two sets of PHY >> settings are programming different values to different registers, mixing >> the two sets and/or overwriting one set with another set is definitely not >> blessed by UFS PHY designers. >> >> To add HS-G5 support for SM8550, split the two sets of PHY settings into >> their dedicated overlay tables, only the common parts of the two sets of >> PHY settings are left in the .tbls. >> >> Consider we are going to add even higher gear support in future, to avoid >> adding more tables with different names, rename the .tbls_hs_g4 and make it >> an array, a size of 2 is enough as of now. >> >> In this case, .tbls alone is not a complete set of PHY settings, so either >> tbls_hs_overlay[0] or tbls_hs_overlay[1] must be applied on top of the >> .tbls to become a complete set of PHY settings. >> >> Signed-off-by: Can Guo >> >> -static void qmp_ufs_init_registers(struct qmp_ufs *qmp, const struct qmp_phy_cfg *cfg) >> +static bool qmp_ufs_match_gear_overlay(struct qmp_ufs *qmp, const struct qmp_phy_cfg *cfg, int *i) > > You can simply return int from this function. -EINVAL would mean that > the setting was not found. Also this can make max_supported_gear > unused. I will return int in next version, but I'd like to keep the max_support_gear, because for platforms which only .tbls is provided (no overlay case), we need the max_supported_gear to tell whether the requested submode is exceeding the capability provided by the PHY settings. > >> +{ >> + u32 max_gear, floor_max_gear = cfg->max_supported_gear; >> + bool found = false; >> + int j; >> + >> + for (j = 0; j < NUM_OVERLAY; j ++) { >> + max_gear = cfg->tbls_hs_overlay[j].max_gear; >> + >> + if (max_gear == 0) >> + continue; >> + >> + /* Direct matching, bail */ >> + if (qmp->submode == max_gear) { >> + *i = j; >> + return true; >> + } >> + >> + /* If no direct matching, the lowest gear is the best matching */ >> + if (max_gear < floor_max_gear) { >> + *i = j; >> + found = true; >> + floor_max_gear = max_gear; >> + } > > We know that the table is sorted. So we can return an index of the > first setting that fits. For SM8550, it is OK, because no-G5 settings are in overlay[0] and G5 settings are in overlay[1], applying one overlay is a must. .tbls | support nothing as it is incomplete .tbls + .tbls_hs_overlay[0] | support G4 and lower gears .tb.s + .tbls_hs_overlay[1] | support G5 But for previously added platforms, no. I put it this way for two reasons - 1. In case the tables are not sorted. 2. For previously added targets, whose configs support G4 and no-G4: .tbls | support G3 and lower gears .tbls + .tbls_hs_overlay | support G4 if we anways return an index of the first setting that fits, for these targets, the G4 settings would always be programmed, no matter UFS driver requests for G2/G3/G4. On these targets, as dual UFS init is there to find the most power saving PHY settings, when UFS driver requests for G2/G3, .tbls_hs_overlay should NOT be applied. Otherwise, it defeats all the efforts which Mani had spent for the dual UFS init. Thanks, Can Guo. > >> + } >> + >> + return found; >> +} >> + >> +static int qmp_ufs_init_registers(struct qmp_ufs *qmp, const struct qmp_phy_cfg *cfg) >> { >> + bool apply_overlay; >> + int i; >> + >> + if (qmp->submode > cfg->max_supported_gear || qmp->submode == 0) { >> + dev_err(qmp->dev, "Invalid PHY submode %u\n", qmp->submode); >> + return -EINVAL; >> + } >> + >> + apply_overlay = qmp_ufs_match_gear_overlay(qmp, cfg, &i); >> + >> qmp_ufs_serdes_init(qmp, &cfg->tbls); >> + if (apply_overlay) >> + qmp_ufs_serdes_init(qmp, &cfg->tbls_hs_overlay[i]); >> + >> if (qmp->mode == PHY_MODE_UFS_HS_B) >> qmp_ufs_serdes_init(qmp, &cfg->tbls_hs_b); >> + >> qmp_ufs_lanes_init(qmp, &cfg->tbls); >> - if (qmp->submode == UFS_HS_G4) >> - qmp_ufs_lanes_init(qmp, &cfg->tbls_hs_g4); >> + if (apply_overlay) >> + qmp_ufs_lanes_init(qmp, &cfg->tbls_hs_overlay[i]); >> + >> qmp_ufs_pcs_init(qmp, &cfg->tbls); >> - if (qmp->submode == UFS_HS_G4) >> - qmp_ufs_pcs_init(qmp, &cfg->tbls_hs_g4); >> + if (apply_overlay) >> + qmp_ufs_pcs_init(qmp, &cfg->tbls_hs_overlay[i]); >> + >> + return 0; >> } >> >> static int qmp_ufs_com_init(struct qmp_ufs *qmp) >> @@ -1331,7 +1461,9 @@ static int qmp_ufs_power_on(struct phy *phy) >> unsigned int val; >> int ret; >> >> - qmp_ufs_init_registers(qmp, cfg); >> + ret = qmp_ufs_init_registers(qmp, cfg); >> + if (ret) >> + return ret; >> >> ret = reset_control_deassert(qmp->ufs_reset); >> if (ret) >> -- >> 2.7.4 >> >> > >