Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp254864ybi; Wed, 29 May 2019 20:44:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDWWgSUb4L3sq6SoI6gs9jKqHQLQqAg01weChAGeSnMl7kC91/X2L9s2y0uOJUBo/KB28/ X-Received: by 2002:a65:6551:: with SMTP id a17mr1618208pgw.1.1559187888909; Wed, 29 May 2019 20:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187888; cv=none; d=google.com; s=arc-20160816; b=hHC3XZ4GPi/bB59QHWXgqD3JRFD3fFFEHOLf2R7AAsDvW80WUw8OwWxU4+jHTgU7Nk ldJQ1vjJ+VT1AcZpAre4uB+jP6mAh4QgJysW6W/e40iXT6jvRMPfQR6t9yHZ/fGN/9Bq P1b52p4Fo+cleo7EVpmgCAXUFHJaDqZAP7W6ubXW11EdsacSJyQLqz7aif0PLYKmBTHX 6L8DVn0f/jijKRS5CWb6LzNFZGiOQDkLN7py3fafO7AYJFKUI0dAFhuaTC6LaVLb4rXE 132+NRFORKZbuAii9XGatnnHL8e5KIftw0W0UuHyxIluKcVUwQ9mShRnTMP2L7HKhDGd LKGA== 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=kcbQv8AU6zO7FSOaP2VKbzX4hCmM4zIxhvymvhCJsUM=; b=VEjYUHiK4Bb5IKLkuBtYR8Lp7zehKeLJS8m5AhK2DZI3S0O7UKPp7kLghO6AsfLkbJ tuv2ZSWjsiEtQ3K3ufYlCtMYJhfcpJs0M8AWFsCjkb6EVQkKhi18mPAPYU2xsCEqYHT5 3/EqwuXu2i7Vik7ICeRE+TmMQwMUg+DAFDzXWL0VCdUfRBG5BxCd77jIrU35SQTv6k0L WzrbQ7kFgBjdZ0DD+zyqkYwdeK1rsj3rOsS8qYfVaWcBKUQwgK5VOgtVjp8rFf45B8iw OukiFlTMJzxc1WKrM8/7GAjD3mP0aga1tz52aWyugmxvmGKyRaVpCK38qNhEmA0SONcT CErg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rOAzmesR; 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 m4si1627978pjk.66.2019.05.29.20.44.32; Wed, 29 May 2019 20:44:48 -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=rOAzmesR; 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 S1732846AbfE3Dn0 (ORCPT + 99 others); Wed, 29 May 2019 23:43:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:33390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731802AbfE3DVL (ORCPT ); Wed, 29 May 2019 23:21:11 -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 908F0249CE; Thu, 30 May 2019 03:21:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186470; bh=yrLqvuy0Gi+/mqgwgslP0CMc1UikWllpQo7pWoDrmus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rOAzmesRWINBLlv4LX3fsrW1MIL8ttEiFIY37mAMx9xt8Xdh6QtpCbqotPFPN4rJ0 xD+kOcuRoxOruBzWIY0h6xhJ9VrmCkmBMkzbKEWlZGvFLMFc6bDL6ajGgOUc0vFaFp B6ZcZHAiDTLQNgSqTo6h0f7Yo546+jTxXg9VvLgM= 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.9 099/128] scsi: ufs: Fix regulator load and icc-level configuration Date: Wed, 29 May 2019 20:07:11 -0700 Message-Id: <20190530030452.380736501@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030432.977908967@linuxfoundation.org> References: <20190530030432.977908967@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 0b858414c558b..8869c666d458c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4875,19 +4875,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, @@ -5449,6 +5449,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