Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp51563pxk; Tue, 15 Sep 2020 17:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb+f/UAxVi/5waqfhXRXgeJDRZ9R7zR8wBEy32VzbJ8Hsf1lTY3C7/KQDcwcOmpop+m8p2 X-Received: by 2002:aa7:c511:: with SMTP id o17mr25667534edq.300.1600216258878; Tue, 15 Sep 2020 17:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600216258; cv=none; d=google.com; s=arc-20160816; b=1KhdAsR9eZ7HhJdpXzsP65SCmt8+iG45gz2j3ZAhsgxlqjQrL4JqL7S9KmvELz5yPn HfPFUdx/1SiFIpY8uwT5t77BBaQavFbABXbSdio4j7Kca9RXn/B5hZ8qNdd4L6/iy0mm 35EvvgdECWbGeN686kUqdx4Y38IW43c9gc/uTNxjtT7fQoVkfZXPHTlGQxbhJutsyPy5 1/eMrGAAYTNqOKvXVMVFwoqs6IUV5CO7y92tokudwjJRPA0G1viYHba5SMNdmAGsHhYJ nJnPHFy+aa+ioav12UdP2a95V2u3YWDQFYZEV4QQ/kJC6JQb16MixyIyUh7XL9/IR7hU 1YQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ttARGbDHmVnJ0g6Br9D8cEVRotoN7PzoX1uzLIImtD4=; b=cqvQh0hCHGsAwUQXvcv1bmXqO7kFlhDxk5SjgKI/Bubfcj8/aScOAi+gYYZYUKR5np RbpZXkk465VH1vr57ymLklxhm+NBdb7JnS7hSQv+QyO3+WM/9kbaTooRUZ7MUwIbqVF2 gSojgtcLsOg4Ex3xYn9lSNYm667ZWMOrNiWAeQ3wmarJ/u/+lJZtA9fDSavL09rULiRH nLBqy8mA1tni0x4zvfcKOg1vXdsfEy3BljHNwMoZM9/YNtXFaJbmI7S35RTWBV0Aiufk UP77EPUCp1Q1P0Nebybcxc0x6cJI/MECpeTCMLlx2ulA7nOOl0E5+6ntOEx/xyW4n6DE c8PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P4iMu1hR; 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 p2si10487979ejw.176.2020.09.15.17.30.36; Tue, 15 Sep 2020 17:30:58 -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=P4iMu1hR; 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 S1726694AbgIPA3w (ORCPT + 99 others); Tue, 15 Sep 2020 20:29:52 -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-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 > > >