Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2419449ybi; Sun, 9 Jun 2019 11:17:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCnfdFm/mxzVckfNdLCtQ04tmW+KVAAzPTUVRdnViHy2deNCI1AQdsZEKIbPcB1WP0cgPA X-Received: by 2002:a65:62cc:: with SMTP id m12mr12312365pgv.237.1560104244035; Sun, 09 Jun 2019 11:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560104244; cv=none; d=google.com; s=arc-20160816; b=SXeeaL+blxTDTrthpwMg1NtRtVMV4Wirzfrmvue/avzFqGaJ7frt72g2oDoCV+AD0Q gnocxt2mikBP1esyZ0AEpGChAh1Kd6K1VGxWFJJ6JbmXazuS/JaevuuJT8kCCbiQmIjc cHHMKcZlh8hKrms5Gk8qDhz2PzHi2pjI+Qb/SCLEcckHZWUttSmPGEjQWM3vUE0oZdPV M+UTccfRgWqdvq6lcPqLkwh+Jeon6Ji+LKBD4DShxhBpJ+985N2u8tX4oW/QIyEO8/iB jStic3AISTKv+o09vcxAlOPTc7MarSsHaHdKqBfEWX4B7ML9o04lX1T+xlB6tVQIldGI 0gSA== 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=01FpMQTnDvXzdl61MUa+lrTspZ4A84tiitJ/IA3cXYs=; b=TwhhEM5eFc44QRLgrWOri3boj+ahthn35zVzqmdb82+i1OBS+RlG2X4nso1C7FeeKQ 3GZLMLVl+x4IwxpG5/m960lae30gcQpEJZnkxfHElscbMXyCUpTON3mVa1UgQgbVKiPs MbqpWYe9zTCCr77y7natujDx9/qlCuKimMY6ZPLEMk0TJ0r76U6nGYqvUsp7v9pzHL74 MDc29NDJ+dHcgOviBRvy65Mz0Oc/+elXgeeyCWT+h8Nkc7tIn8EAzGFsECHTzeM0UYV2 VFUYJRmiqTPw4pkfdb0D55KNSeX6AVADgaIKaPf5SnmoKb2FQyf2EI0D1FLv16NVhcvN iBGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nVydQy5q; 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 a18si3574373plm.171.2019.06.09.11.17.08; Sun, 09 Jun 2019 11:17:24 -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=nVydQy5q; 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 S2388294AbfFIRCo (ORCPT + 99 others); Sun, 9 Jun 2019 13:02:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:40726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388280AbfFIRCl (ORCPT ); Sun, 9 Jun 2019 13:02:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 5B57A206C3; Sun, 9 Jun 2019 17:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560099760; bh=Ysv8MVANL+aQS4kM+idzj4ZuPxGYH7yNlLHqDFbdGQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nVydQy5qwohcGLSA/Ib7HOFX9r3Ffpx8R3CsYaQjSyPuALERtvmMCBp8x5ZuDhn8b nAMsokeZWX1ihG+teYDsrydl+6Fx6OJAD0YCdsxrW6WP1Pj9gawnrwnSDraQcbF5Lg Eit2e8lpi+Yq31BTuGdCrmQ3Yt7P7HF7e/BQuA2o= 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.4 156/241] scsi: ufs: Fix regulator load and icc-level configuration Date: Sun, 9 Jun 2019 18:41:38 +0200 Message-Id: <20190609164152.271776031@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164147.729157653@linuxfoundation.org> References: <20190609164147.729157653@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 c94d465de941e..ed76381fce4cc 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4144,19 +4144,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, @@ -4390,6 +4390,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