Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1108861imm; Wed, 1 Aug 2018 10:19:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdq8XC/8uhb3MXIzg+lZyD4aYkoWUk493ZUv9S2LK0emLVvS1liUHu6ixOLP16lUa1gR7/i X-Received: by 2002:a62:b0c:: with SMTP id t12-v6mr27829819pfi.36.1533143956017; Wed, 01 Aug 2018 10:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533143955; cv=none; d=google.com; s=arc-20160816; b=EsPxHmqDH52jw0uu59KGJXGgmG6lwvYcubxSW27Msa5fHE8wa2SI5L6+DyD2UfUP3W gfNYN2J127BBgD4jDbOL8gzobcmOVZvswBuSmNJS8BIfgEoPI4r/IeV+TqoKi0vQGgmq IveA4jSs+e1Lq09Xj5BOdiDOG40enurPSgkmY7UAd1X2robeHV7CifN6yVW3GMbs+jNA rWWqA7BvGPDfmiMUsWSIcvhSlpTfP6ES/ULKblbswIDCa/9jSaZotwGtd81ufEy4jft8 AgKtsvPbsix1ac10Nc3Sj4XSHIIBqZ2var6guaHV511jcxw9FHoL45JqzDNnhGkPhPfJ iVnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=X9mGUwMKlP8dHJJ9mpD0C8+i7BPhPgAWzXDxIOcM91U=; b=s1uRVJYuJrYzThC6GT+S+YeSglXnZPY2RkpkqKULGSTAo/2pbKNavkzZ7wXKIfhE5R FMAhwFBr067yhtljNbZ2DrxSbansTj8aM2QAzm/xGcVD7MdTy1YZpS+LB46zP6inNCqu lrbBK+XVpiZYvmiHz6PUH1bAcaVxkvSaoWx3J0ddXgGDTlIXl48SBDyGqXGj+Co32y2y t8KK7t0s4ShP5WiOYgLx2fin/zvLvk5xphJIl6bwWOgo1y9clp4n5kc5UV6uizKOWzv7 1fcpruxfmpxYOAMBHeoNqvP7Yh6GGVJZsNDN6ynmmeetymwM80yWrIUElpMA97sIWpUJ nsuQ== ARC-Authentication-Results: i=1; mx.google.com; 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 p67-v6si17020029pfg.295.2018.08.01.10.19.01; Wed, 01 Aug 2018 10:19:15 -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; 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 S2404724AbeHATER (ORCPT + 99 others); Wed, 1 Aug 2018 15:04:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46476 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404028AbeHATEQ (ORCPT ); Wed, 1 Aug 2018 15:04:16 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C850BC96; Wed, 1 Aug 2018 17:17:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Subhash Jadavani , Venkat Gopalakrishnan , Can Guo , Asutosh Das , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.14 117/246] scsi: ufs: ufshcd: fix possible unclocked register access Date: Wed, 1 Aug 2018 18:50:27 +0200 Message-Id: <20180801165017.306957819@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Subhash Jadavani [ Upstream commit b334456ec2021b1addc19806990115e69ec4ac32 ] Vendor specific setup_clocks ops may depend on clocks managed by ufshcd driver so if the vendor specific setup_clocks callback is called when the required clocks are turned off, it results into unclocked register access. This change make sure that required clocks are enabled before vendor specific setup_clocks callback is called. Signed-off-by: Subhash Jadavani Signed-off-by: Venkat Gopalakrishnan Signed-off-by: Can Guo Signed-off-by: Asutosh Das Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/ufs/ufshcd.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6761,9 +6761,16 @@ static int __ufshcd_setup_clocks(struct if (list_empty(head)) goto out; - ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE); - if (ret) - return ret; + /* + * vendor specific setup_clocks ops may depend on clocks managed by + * this standard driver hence call the vendor specific setup_clocks + * before disabling the clocks managed here. + */ + if (!on) { + ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE); + if (ret) + return ret; + } list_for_each_entry(clki, head, list) { if (!IS_ERR_OR_NULL(clki->clk)) { @@ -6787,9 +6794,16 @@ static int __ufshcd_setup_clocks(struct } } - ret = ufshcd_vops_setup_clocks(hba, on, POST_CHANGE); - if (ret) - return ret; + /* + * vendor specific setup_clocks ops may depend on clocks managed by + * this standard driver hence call the vendor specific setup_clocks + * after enabling the clocks managed here. + */ + if (on) { + ret = ufshcd_vops_setup_clocks(hba, on, POST_CHANGE); + if (ret) + return ret; + } out: if (ret) {