From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73067C433E2 for ; Wed, 16 Sep 2020 00:29:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31C54206DB for ; Wed, 16 Sep 2020 00:29:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="P4iMu1hR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727019AbgIPA3z (ORCPT ); Tue, 15 Sep 2020 20:29:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbgIONsb (ORCPT ); Tue, 15 Sep 2020 09:48:31 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4551EC061A2D for ; Tue, 15 Sep 2020 06:37:34 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id w16so3900306oia.2 for ; Tue, 15 Sep 2020 06:37:34 -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=ttARGbDHmVnJ0g6Br9D8cEVRotoN7PzoX1uzLIImtD4=; b=P4iMu1hRBC5Lq/Gsju/uOwqOCm78IqbBrXKblX1kH+6k5Kbezqh1Wq6Gh+8GjYG3Gf E/c6KaLLnzqGlL6bcou+LtU65EFYrQyZhY02LU2ksp5T8r1mmsNsfaeXZnO5975n7rnE kY9NpNAjXndInQBjmq/FC14J8665OALEqcHkeQU9dI2tjzSeITtyr7+hSQVkxAimoso3 4ilRgwsf0k2QRNQeY1qVuDCjCGCetlOHAY+a9bH7T2r7hxwPAd87Job/JFPNb4c7Dmp2 /zmn4o+qH/iaooeHCY3kqOFyT1fbUoYdbKXs4D9erDo1LgH9JEH51s10XA7gGi4zOWfP 1j7g== 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=ttARGbDHmVnJ0g6Br9D8cEVRotoN7PzoX1uzLIImtD4=; b=MxXZZ+b+g7+6XjFb6JkqlA7seGIIW/mVHkCChWpUoaxDlJQgxfwGBX5q4GIDc6qAbv x+kH2oug/11RLQXYJGCaXAXnjsQ0jkvTiwti9KAEqD5Jv/wsafD8R/6IZ4/bX9dEsimt 1Gvat4F5Jc/oBTTNNU62zLtzt/vEpN4HtacHvTL74i4T+wQk8cRS0xYZc3wN3pKT2FlG OA1UbB4G9Eoe+MpwWqDDI3ylb5pDfN4GkbpARH4FzoRTPp/cJ59tZmWo8G5xDbl4ypNL 1BY3xCxWOIFoNVt3UlgnjI/DL9tR57paD4qY7MZ4Q+U+IJcS+KiukYEYt3l3OIXKBWuv E4jg== X-Gm-Message-State: AOAM531H9J9cJtuipE6dpixF51Xh7UMKAFEeuGnt5aHVtpOm0limUqKA ZUcWQtP2cefoYujo3SVY+grPQg== X-Google-Smtp-Source: ABdhPJxisvq6caWh5L4EG6TGFxDpwY6jGGBJ+sNGZgHWBV118w2EVtYOtdNF6lKC5Rac05XL7IXV6A== X-Received: by 2002:a05:6808:a05:: with SMTP id n5mr3418167oij.154.1600177053525; Tue, 15 Sep 2020 06:37:33 -0700 (PDT) Received: from yoga ([2605:6000:e5cb:c100:8898:14ff:fe6d:34e]) by smtp.gmail.com with ESMTPSA id 91sm1156918ott.55.2020.09.15.06.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 06:37:32 -0700 (PDT) Date: Tue, 15 Sep 2020 08:37:29 -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: <20200915133729.GD670377@yoga> References: <5c9d6f76303bbe5188bf839b2ea5e5bf530e7281.1598923023.git.nguyenb@codeaurora.org> <20200915025401.GD471@uller> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 > > >