Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp79541pxk; Wed, 16 Sep 2020 19:33:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1wGNxhsJDiCZRORTC8NjGws6qKv1/AREZhtTV0fYiujxGGPf2wxn0Fi/lyXsuRuSW56di X-Received: by 2002:a17:906:82d1:: with SMTP id a17mr28281167ejy.385.1600310011703; Wed, 16 Sep 2020 19:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600310011; cv=none; d=google.com; s=arc-20160816; b=jZ1GMH+nPtUyrgJKhEIEBUo6HW3iSdhbBRuMEJuhOkFG6UEcQWViUk3IwpLF5rMfue 8L1hGrg5TBjxuiS3EdIbHHH/3b65DMh42GMXa0uz5yjoujIlzS0YAzUS2rL5d8BQsNu6 7ANK5qKttlWiwWXKX2hsA1+rSb7A2082lRk0kc+kmGtHbsPJL1SzyyMJpzh56cSkTc3H jiHfbFdCeJf7BRDiBMXBO0v+9kwujLDIR7Up0fiHJAkRoZ/6MFXw6UrK3OTnxvSkiVh8 S1TuK5p93tHGbsuiS+v2iQsOsvbRxQTP79Z0kMtOf93WZe52aF8mXBmjd/GyVdJiQmyI 1Rcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VE5n3jGn2FvmnuiKIkLlfMO4cq4htPGZqkOIyp7oCTk=; b=JEP+fmFbRFwRB98XkX3ZAz0EvJHhbRiNr4/mgxzftPQbixIgvSIBleX0Zb3ZP9spe6 obEgUU6qOecmpgR17AlrKQZ/u1HyKXcvN8VGMEwz7JPwyqol/ABsFiInl7bLc2rabY6s AMdgen0lQP+H/LrSpXVLOIhMcil42Cxo4DkEIu69ypcSygeA0SscXW8UTBEW5yE8fzzF lXarzqFRLp4VdFC0lp6sLQC7HtgEEpbVMEidpC0sJvBn8zVnSFPxjCPlcvbeQ+IGN8y6 GaD2fwKmROEelc0Q5AcTt8N8yOi8ajcgl9pyWigtsJ0b6XHUpUs20p0WVqNjsoinkTSt WyjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hR2nePbg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si11677698ejg.90.2020.09.16.19.33.08; Wed, 16 Sep 2020 19:33:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hR2nePbg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726149AbgIQC3n (ORCPT + 99 others); Wed, 16 Sep 2020 22:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgIQC3i (ORCPT ); Wed, 16 Sep 2020 22:29:38 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84E6AC061353 for ; Wed, 16 Sep 2020 19:29:37 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id z1so202225ooj.3 for ; Wed, 16 Sep 2020 19:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VE5n3jGn2FvmnuiKIkLlfMO4cq4htPGZqkOIyp7oCTk=; b=hR2nePbgnTCUSqe41FcHVgNm6Xjz7Zcw43IyQiS21NSCRJrlVvCvgXCGKY+F16FJ/s JvtIF9bPYtgc+XzhdG1AsItCFVfZL8eNSdQZnJtJztmCrTvdiuFRUwhVQJrf3EHb4Exg TbdUZWZ13gZ6yAqUVIj6VR+oPYAHBpPuD9kfvPH7tpKx54iQW8pOi3aw1D7ll99udSB+ WvK7Vtcqsd2QFjYl90EpyOXrWUNhSHGWTPaSbp+/HIqUfdl5vM9jd+FuP7CUF/clPBu6 dpANmsKilhkPW5hKKW9R/IL6BQQf50CljJqXlVAxo+DWHLiTzOkJEgqQB4tPcgDS1LTA g9Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VE5n3jGn2FvmnuiKIkLlfMO4cq4htPGZqkOIyp7oCTk=; b=niTkyT1rcoGZP4O1Y6Lw/WC0LGsCGghNrOggcedeVnOWMZBnM8mu/ch2+P934S8oxd Dz0x1tAqUTEZwZQH6oaWNQGcrne4tsx3q4FfU7aXh1qK/4JikJdIFxc3aRD3D9sYtgqh 5nu9WimNgT2A/R7qYkNBpy0/Bn93x8XsoHwmYF4oG+XELgUpL4d5RP0KAo00w94me8Hc FnOSG27uxKRnffm9YfCO5BKK+y3GSZ8+TOWNkf9YdFM0sq9t40qv1M+cjojKE5kBAebF XYH5aQ+op0GQ9Azq63eEc6taVnXiUGDh/Z7W0PA+lTu/I65VR6W+xXIpclC3Qf6gUuPp b8mg== X-Gm-Message-State: AOAM532UMYbuAYyAbKRuGme8mpLIcCE7yIkunfp4nfK21gL5HsG+v2Kt YbXUF/RTE/7/ylUE858sCHLKfg== X-Received: by 2002:a4a:5d84:: with SMTP id w126mr17892143ooa.1.1600309776351; Wed, 16 Sep 2020 19:29:36 -0700 (PDT) Received: from yoga ([2605:6000:e5cb:c100:7cad:6eff:fec8:37e4]) by smtp.gmail.com with ESMTPSA id a22sm5143467oie.13.2020.09.16.19.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 19:29:35 -0700 (PDT) Date: Wed, 16 Sep 2020 21:29:31 -0500 From: Bjorn Andersson To: nguyenb@codeaurora.org Cc: cang@codeaurora.org, asutoshd@codeaurora.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-arm-msm@vger.kernel.org, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , Stanley Chu , Bean Huo , Bart Van Assche , open list Subject: Re: [PATCH v1 1/1] scsi: ufshcd: Properly set the device Icc Level Message-ID: <20200917022931.GK1893@yoga> References: <5c9d6f76303bbe5188bf839b2ea5e5bf530e7281.1598923023.git.nguyenb@codeaurora.org> <20200915025401.GD471@uller> <20200915133729.GD670377@yoga> <6e36f0a315c13429bdad1ce704cbe878@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6e36f0a315c13429bdad1ce704cbe878@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 16 Sep 19:53 CDT 2020, nguyenb@codeaurora.org wrote: > On 2020-09-15 06:37, Bjorn Andersson wrote: > > On Tue 15 Sep 03:49 CDT 2020, nguyenb@codeaurora.org wrote: > > > > > On 2020-09-14 19:54, Bjorn Andersson wrote: > > > > On Tue 01 Sep 01:19 UTC 2020, Bao D. Nguyen wrote: > > > > > > > > > UFS version 3.0 and later devices require Vcc and Vccq power supplies > > > > > with Vccq2 being optional. While earlier UFS version 2.0 and 2.1 > > > > > devices, the Vcc and Vccq2 are required with Vccq being optional. > > > > > Check the required power supplies used by the device > > > > > and set the device's supported Icc level properly. > > > > > > > > > > Signed-off-by: Can Guo > > > > > Signed-off-by: Asutosh Das > > > > > Signed-off-by: Bao D. Nguyen > > > > > --- > > > > > drivers/scsi/ufs/ufshcd.c | 5 +++-- > > > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > > > > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > > > > > index 06e2439..fdd1d3e 100644 > > > > > --- a/drivers/scsi/ufs/ufshcd.c > > > > > +++ b/drivers/scsi/ufs/ufshcd.c > > > > > @@ -6845,8 +6845,9 @@ static u32 > > > > > ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba, > > > > > { > > > > > u32 icc_level = 0; > > > > > > > > > > - if (!hba->vreg_info.vcc || !hba->vreg_info.vccq || > > > > > - !hba->vreg_info.vccq2) { > > > > > + if (!hba->vreg_info.vcc || > > > > > > > > How did you test this? > > > > > > > > devm_regulator_get() never returns NULL, so afaict this conditional will > > > > never be taken with either the old or new version of the code. > > > Thanks for your comment. The call flow is as follows: > > > ufshcd_pltfrm_init->ufshcd_parse_regulator_info->ufshcd_populate_vreg > > > In the ufshcd_populate_vreg() function, it looks for DT entries > > > "%s-supply" > > > For UFS3.0+ devices, "vccq2-supply" is optional, so the vendor may > > > choose > > > not to provide vccq2-supply in the DT. > > > As a result, a NULL is returned to hba->vreg_info.vccq2. > > > Same for UFS2.0 and UFS2.1 devices, a NULL may be returned to > > > hba->vreg_info.vccq if vccq-supply is not provided in the DT. > > > The current code only checks for !hba->vreg_info.vccq OR > > > !hba->vreg_info.vccq2. It will skip the setting for icc_level > > > if either vccq or vccq2 is not provided in the DT. > > > > > > > > Thanks for the pointers, I now see that the there will only be struct > > ufs_vreg objects allocated for the items that has an associated > > %s-supply. > > > > FYI, the idiomatic way to handle optional regulators is to use > > regulator_get_optional(), which will return -ENODEV for regulators not > > specified. > Thanks for the regulator_get_optional() suggestion. Do you have a strong > opinion about > using regulator_get_optional() or would my proposal be ok? With > regulator_get_optional(), > we need to make 3 calls and check each result while the current > implementation is also reliable > simple quick check for NULL without any potential problem. > I think the changes to the conditional that you're proposing in this patch is reasonable. Regards, Bjorn > Thanks, > Bao > > > > Regards, > > Bjorn > > > > > > Regards, > > > > Bjorn > > > > > > > > > + (!hba->vreg_info.vccq && hba->dev_info.wspecversion >= 0x300) || > > > > > + (!hba->vreg_info.vccq2 && hba->dev_info.wspecversion < 0x300)) { > > > > > dev_err(hba->dev, > > > > > "%s: Regulator capability was not set, actvIccLevel=%d", > > > > > __func__, icc_level); > > > > > -- > > > > > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora > > > > > Forum, > > > > > a Linux Foundation Collaborative Project > > > > >