Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2513193imm; Wed, 16 May 2018 14:14:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrTACEO5G3KImYN3D87kqH4EA3ivwkz1Gv9inV4jycqbPq2ejg2zTz2UgyPfEpfiLjMzQHq X-Received: by 2002:a62:4544:: with SMTP id s65-v6mr2567039pfa.150.1526505252226; Wed, 16 May 2018 14:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526505252; cv=none; d=google.com; s=arc-20160816; b=FKqoL29YWv1ix00fxEf81ADs2NUAg866MG/V6JgrpdUqCdMZr0E4Euu+DlQFT/mxPc z6WZhDpnREg2UA1+w7x+Barcq9ZekCnrSA0MQPPbuxEhHdnvpiYI8qpSn6c9cFPJNbky GwKN+IZWiTs71rehY+lVBHpc6M9pUMfiuROSWMVU/FhgJLifgYZrfnRI7HCcYlDNZgvq BXW8JUi+R4nFuVCLq6wAVUcyH78z7ncFs0yyOL6XYABAAIY7IO3kWTxh9ScUzxvRF8y5 3/UFz08QfKNR8hA0PVqeFiGTZTpU1swx34EcPf6SIgm9w8L7DSPon5ixw+5Lw9NBqHMU 0Glw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=94gj1FwqjCsJG5E1kNYi1x3kkqH9U9bLVpCcuwMLHXA=; b=g7V3mgOTw+UI3twHY4XwUhQLh6GnbhGwRAyAJcN35rqifdRFa0OC9sGrOUMFNweBG9 2DagR8GxHG8BQfsVfVRIBpXzl9SWJuDHg9/9TWZQeFTGIfzhA066NfTnapFtQcBIZCDy U8012rY2Pv2sNivt18dhDewTtZPLv3qsmsqIgtdHeFU+Gs0t9blTtnx+FuVNJdvFwy4R 6rdTP1aEgHbM2M++S7D9WLtFMvFaPeyBY85cR7hg0jvH/3iROx6BV/8Ch7cqyLBu9nam +Gzrnn2x+SxSb5gtYErwMINzg1MlTJNG/toLacTiA1zk6aQFH/7QeGb2QXqii0xSJVyl MNJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=kq3KqvU/; dkim=pass header.i=@codeaurora.org header.s=default header.b=PfOT3f0T; 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 y25-v6si3418374pfn.248.2018.05.16.14.13.57; Wed, 16 May 2018 14:14:12 -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=@codeaurora.org header.s=default header.b=kq3KqvU/; dkim=pass header.i=@codeaurora.org header.s=default header.b=PfOT3f0T; 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 S1752284AbeEPVMg (ORCPT + 99 others); Wed, 16 May 2018 17:12:36 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54618 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132AbeEPVMe (ORCPT ); Wed, 16 May 2018 17:12:34 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3DE5C601EA; Wed, 16 May 2018 21:12:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526505154; bh=RTPGS5lVBltREkay1eA4KRWQ/5CLi8q5Gc9SE01Gv/k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kq3KqvU/mfIRwGBLvwlY81wZGscHj5cKQ98eOiPXuGN+IPKlRbuINfzIIxDw5Mmna 76i7L4buokRlkX490ejBy8QlLcBkrXPhFK94+0GVlr3EgBCgGHUNmf8K/AV6FTg+Be Lg4Dphh0pY8TZxJbYyxZYzb5wFZ7TGjrIIxciUDc= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 6DF0C601EA; Wed, 16 May 2018 21:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526505153; bh=RTPGS5lVBltREkay1eA4KRWQ/5CLi8q5Gc9SE01Gv/k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PfOT3f0TW+2bo213tDzYYl5B7ZIZ5lqjG1egg3qUkoo0ZcnQ4SBAQ2kfQP6ay00Hs NmrY2T6ZRBeOgIUUVHXTeQLBpzffSIqih6NYx0tx4jksSESmbmF2rb32gzQ77F7qxh zjSFNGy3SzYhG03G7q9EnP00Uxcg1MYoqamrvx+c= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 16 May 2018 14:12:33 -0700 From: Subhash Jadavani To: Asutosh Das Cc: cang@codeaurora.org, vivek.gautam@codeaurora.org, rnayak@codeaurora.org, vinholikatti@gmail.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, linux-mmc@vger.kernel.org, linux-scsi@vger.kernel.org, linux-arm-msm@vger.kernel.org, Venkat Gopalakrishnan , linux-kernel@vger.kernel.org, linux-scsi-owner@vger.kernel.org Subject: Re: [PATCH v2 05/10] scsi: ufshcd: fix possible unclocked register access In-Reply-To: <7f237069f86547afedcbbdf673cf85dfb20d05fa.1525343531.git.asutoshd@codeaurora.org> References: <7f237069f86547afedcbbdf673cf85dfb20d05fa.1525343531.git.asutoshd@codeaurora.org> Message-ID: <45d251138fac73f4776eae34d9e36def@codeaurora.org> X-Sender: subhashj@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-05-03 04:07, Asutosh Das wrote: > From: Subhash Jadavani > > 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 > --- > drivers/scsi/ufs/ufshcd.c | 26 ++++++++++++++++++++------ > 1 file changed, 20 insertions(+), 6 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 838ba8f0..dfeb194 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -6780,9 +6780,16 @@ static int __ufshcd_setup_clocks(struct ufs_hba > *hba, bool on, > 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)) { > @@ -6806,9 +6813,16 @@ static int __ufshcd_setup_clocks(struct ufs_hba > *hba, bool on, > } > } > > - 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) { Looks good to me. -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project