Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp30454pxk; Wed, 16 Sep 2020 18:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGUzwn/9d4EZ0wdp2xb4N7DRKDvdTEGuqYNRQ3ImGivQ5n+sl3HKmQop2dZLtZEevd+tVR X-Received: by 2002:aa7:c7c1:: with SMTP id o1mr31537486eds.368.1600304519608; Wed, 16 Sep 2020 18:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600304519; cv=none; d=google.com; s=arc-20160816; b=tyfL2fZknOhySxVvIzj6XcS0Qnti4LjmT/4of8f0B15SjkHqkCIxJyDyreJQPFpuRP 8KARRmqlRhuJXBHvVFIBQBDcg1n+btXFM67Ti6irk650w6ofZC2K93myCpwp369mRGYx iLbf/kTIdu/+1dW18ygT8PjhdaEJ0BkBeY6pkuJpdZX+CDodhyBcmi1CIbxGzLFEvjKl yB6xGET6/2Km8ep0OCu3wFNjxof2ienor720i0967bG10U0e5FzqsWkd+V+IEj8MxQ6H J8azuQuTp2oZFpf1eWFJUIcY2GF0m7Ld+JS3K9y2cSzfbVgJk9Zk10FMy5CzjoqStjBD l6Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=fVudm0/lgiiKwjiWJ16VOu7Farkh1dx277bHuq90WXc=; b=fTYwE7xbci6qYzv/Mj+yLH0tJ7bP17pjrRiHaewct7BkzNzYWfq82BsURW0E942NCf T9ETeH18SFL2jabuv0pQdgItsGVlTVkE9T+eWobmVXVMM6gqOOaqsrna8QE1JU5Fd+rR 19MeWvGW6w6YzTBLFTvCLS0ZZiLKH0vKY5I6NHruiCOcI3OMXJO/ZPrsIe1vTn0V2joU r3c4XlTRL1vC521rXclX9bI6iA0lyY5x6GwFM4lbjdYb2l4DEiWpCMRBaklguNn/OcBP 99a2hzbyWPwMt1ZDgO8P0cB9Kf9gKADuJqk4Mb//ICzERA1IhWQX9u6FNGlpfvKhdgR3 o7ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=N6XJJfFa; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gq14si12984391ejb.354.2020.09.16.18.01.36; Wed, 16 Sep 2020 18:01:59 -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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=N6XJJfFa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726130AbgIQBAG (ORCPT + 99 others); Wed, 16 Sep 2020 21:00:06 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:18983 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726072AbgIQBAD (ORCPT ); Wed, 16 Sep 2020 21:00:03 -0400 X-Greylist: delayed 304 seconds by postgrey-1.27 at vger.kernel.org; Wed, 16 Sep 2020 20:59:24 EDT DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1600304395; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=fVudm0/lgiiKwjiWJ16VOu7Farkh1dx277bHuq90WXc=; b=N6XJJfFa1WiFwdzYr0lzfRSxTDRmbCkQ7ILHGHh0z1fiT4tEKakk/vGlBJgkADc26P+Rtx9Z hA14J6mIuXd78kHkhzE6c3gQph3NT8c6zeFFKBkHc88VrS9jw9hBDG9OXIntd2Dq8OoBSoOY dWz8Td3xE21HuIiEBhExNiNYOs0= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-west-2.postgun.com with SMTP id 5f62b3944ab73023a7f6fd9e (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 17 Sep 2020 00:53:40 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 35E1EC433F0; Thu, 17 Sep 2020 00:53:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: nguyenb) by smtp.codeaurora.org (Postfix) with ESMTPSA id DCB40C433C8; Thu, 17 Sep 2020 00:53:37 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 16 Sep 2020 17:53:37 -0700 From: nguyenb@codeaurora.org To: Bjorn Andersson 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 In-Reply-To: <20200915133729.GD670377@yoga> References: <5c9d6f76303bbe5188bf839b2ea5e5bf530e7281.1598923023.git.nguyenb@codeaurora.org> <20200915025401.GD471@uller> <20200915133729.GD670377@yoga> Message-ID: <6e36f0a315c13429bdad1ce704cbe878@codeaurora.org> X-Sender: nguyenb@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 >> > >