Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp271938ybi; Wed, 29 May 2019 21:06:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXCsuyZg5NwBJxQ8Fp+Vn39SzF4Hf5QDzLGr5iPVuxvlmOWCBvoHTV7bvbwA824Z5Qzsra X-Received: by 2002:a17:902:8c8c:: with SMTP id t12mr1793089plo.116.1559189196907; Wed, 29 May 2019 21:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189196; cv=none; d=google.com; s=arc-20160816; b=p701E9c3xj3oCkASGBGclVH5UXGHvb1aT0/B27B2h08BnupBHLZSdZ2n6Ywba1qtie rCP+G/VeyqTPCHvJexxpyIm3gc7dkUl4EzPhoQ9BLoRPH3w09dh62XOF8Hr2sfM4W2ex kECwu66uI3UloXhE7DHrE88Mt4+iI6kypXjSgRPjZxlq0oaWHWiJvKrIfrqI3nBk63Jg J1SHBhd8/V5i6gDi3bQ1KZ9mJ0Jjhjw6ftPI7Npd+iLZgvNk5WpMID4BS8rF8Rmx9q+P PvMaEbTvMuqP6W7cOaCFp1p5o0TrgXHsCqtJrGvZMlJ/HtEibvwx/QWzVm0Hms1K4dQV Lnjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fgr1A9EEEulVYK628sWzNdvX29kRfvKuJemJPuxdkgg=; b=BQmCBN5yFOz/bzJvD3372sdicuP8oP+0K/umOvzepGx2jRHP2hJYQeq6p3VPsah885 r9Csicbp+p90dl5FhJLJYsEMsO2kw5uBvlMsdmE+LOgPk6wqOb2DucSvBlZVhHWQQE0l zFgOlU7JyXfs7R79qtHGRpoGiaJdwN5PAhY2C8QDMF6LBBcgzgOswdm4spjDj+adF/Uh 1zigzbhnqWGHW6HDj4nSxBhK2i7S5RgLcB/9El1LbErFoJ3ixVaadzrVRJAuFUcJ+Yga zWu+y/upzGScH2JIeWgpnRrwah4RVpI05nYJLS/U965MoVNOegcbBB/aQKyH93cyQnGK ADTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pH598Tkb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m14si1927144pls.393.2019.05.29.21.06.21; Wed, 29 May 2019 21:06:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pH598Tkb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731895AbfE3EFV (ORCPT + 99 others); Thu, 30 May 2019 00:05:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:48276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731243AbfE3DRq (ORCPT ); Wed, 29 May 2019 23:17:46 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 52CB124715; Thu, 30 May 2019 03:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186265; bh=6pM+PNif8JYGgG7H6zUEqqTadsP929Buviyt5KO/yAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pH598TkbBT4SZzJoQbqKMJeKfv6VlgyQnQL4609whNDPuzbPONdpnyix6rnGkS0sI PgKPZDDc1l+G4IhGKbKtOmsbKf5BGgoZVHRt8wOOZNcdOe+yG3YnJgQdFMrpfsSb6f DJLBPsXgFwN3fQI/Jfm45iZhqWxYVuEYiR5No7J4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanley Chu , Avri Altman , Alim Akhtar , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 201/276] scsi: ufs: Fix regulator load and icc-level configuration Date: Wed, 29 May 2019 20:05:59 -0700 Message-Id: <20190530030537.691588710@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 0487fff76632ec023d394a05b82e87a971db8c03 ] Currently if a regulator has "-fixed-regulator" property in device tree, it will skip current limit initialization. This lead to a zero "max_uA" value in struct ufs_vreg. However, "regulator_set_load" operation shall be required on regulators which have valid current limits, otherwise a zero "max_uA" set by "regulator_set_load" may cause unexpected behavior when this regulator is enabled or set as high power mode. Similarly, in device's icc_level configuration flow, the target icc_level shall be updated if regulator also has valid current limit, otherwise a wrong icc_level will be calculated by zero "max_uA" and thus causes unexpected results after it is written to device. Signed-off-by: Stanley Chu Reviewed-by: Avri Altman Acked-by: Alim Akhtar Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 6e80dfe4fa979..73156579e9885 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6130,19 +6130,19 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba, goto out; } - if (hba->vreg_info.vcc) + if (hba->vreg_info.vcc && hba->vreg_info.vcc->max_uA) icc_level = ufshcd_get_max_icc_level( hba->vreg_info.vcc->max_uA, POWER_DESC_MAX_ACTV_ICC_LVLS - 1, &desc_buf[PWR_DESC_ACTIVE_LVLS_VCC_0]); - if (hba->vreg_info.vccq) + if (hba->vreg_info.vccq && hba->vreg_info.vccq->max_uA) icc_level = ufshcd_get_max_icc_level( hba->vreg_info.vccq->max_uA, icc_level, &desc_buf[PWR_DESC_ACTIVE_LVLS_VCCQ_0]); - if (hba->vreg_info.vccq2) + if (hba->vreg_info.vccq2 && hba->vreg_info.vccq2->max_uA) icc_level = ufshcd_get_max_icc_level( hba->vreg_info.vccq2->max_uA, icc_level, @@ -6767,6 +6767,15 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, if (!vreg) return 0; + /* + * "set_load" operation shall be required on those regulators + * which specifically configured current limitation. Otherwise + * zero max_uA may cause unexpected behavior when regulator is + * enabled or set as high power mode. + */ + if (!vreg->max_uA) + return 0; + ret = regulator_set_load(vreg->reg, ua); if (ret < 0) { dev_err(dev, "%s: %s set load (ua=%d) failed, err=%d\n", -- 2.20.1