From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755592AbcJFK2h (ORCPT + 2 others); Thu, 6 Oct 2016 06:28:37 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:46737 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754295AbcJFK2f (ORCPT ); Thu, 6 Oct 2016 06:28:35 -0400 X-AuditID: cbfee61a-f79786d000004c78-62-57f627503907 From: Kiwoong Kim To: 'Subhash Jadavani' , vinholikatti@gmail.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: "'open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER'" , 'open list' References: <1475720241-25836-1-git-send-email-subhashj@codeaurora.org> In-reply-to: <1475720241-25836-1-git-send-email-subhashj@codeaurora.org> Subject: RE: [PATCH v2] scsi: ufshcd: fix possible unclocked register access Date: Thu, 06 Oct 2016 19:28:32 +0900 Message-id: <000401d21fbc$62fd3600$28f7a200$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=ks_c_5601-1987 Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-index: AQFOnGX/Zetq6IYqPAlQ2BV7nZyRMQIih1vBoZEpyeA= Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCIsWRmVeSWpSXmKPExsVy+t9jAd0A9W/hBlP2ClqsmphncXnXHDaL 7us72CyWH//HZHFj8U42ix0LqxzYPC739TJ57Jx1l93jwaHNLB4fn95i8fi8SS6ANcrNJiM1 MSW1SCE1Lzk/JTMv3VYpNMRN10JJIS8xN9VWKULXNyRISaEsMacUyDMyQAMOzgHuwUr6dglu Gcd/PmArOClWsfjfZ6YGxm+CXYycHBICJhLHN+5hgrDFJC7cW8/WxcjFISSwlFHi9PU1rBDO e0aJaY0nGUGq2AQ0JZ7enArWISJQL3HizRZGkCJmgW5GibOPdrNAdMxllLi8YSpYB6eAh8TC G0uYQWxhAR+JW7vXg8VZBFQl3jw8xwpi8wpYSjy6uwnKFpT4MfkeC4jNLGAg8X5WHyuELS+x ec1bZohbFSR2fzrKCnGFlcT2zU+hakQk9r14xziBUWgWklGzkIyahWTULCQtCxhZVjFKpBYk FxQnpeca5qWW6xUn5haX5qXrJefnbmIEx+gzqR2MB3e5H2IU4GBU4uFNmPs1XIg1say4MvcQ owQHs5IIr4Tyt3Ah3pTEyqrUovz4otKc1OJDjKZAz05klhJNzgemj7ySeEMTcxNzYwMLc0tL EyMlcd7G2c/ChQTSE0tSs1NTC1KLYPqYODilGhjDlx37bBno2ZVl1vJp1iVr67DPxQ3sD1ff Uro+uXuxVrvv3ZBiaaaevytPa0xJ/yuvoNXu+s6pdXY9W/TzC/eaN5/V1Xv/tm/nriuq5yJD v82e5/+txlK7/8i/5ANnTLfaV/inXhPJ2/LnBmvzlndvjidyzzRSE/E58Pe79iX+M72vZI9G Ns9SYinOSDTUYi4qTgQAiNK8uecCAAA= X-MTR: 20000000000000000@CPGS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi, Subhash. Some UFS host controllers may need to call the vendor specific callback before and after controlling by clock control framework, regardless of whether available clocks are turned on or off. Is there any special reason to limit to invoke the callback only when the clocks are turned on or not? Besides, the callback is acknowledged from core driver because 2nd argument is whether the clocks are turned on or not. If you have any other idea, please let me know. Thanks Regards > Vendor specific setup_clocks callback may require the clocks managed > by ufshcd driver to be ON. So if the vendor specific setup_clocks callback > is called while the required clocks are turned off, it could result into > unclocked register access. > > To prevent possible unclock register access, this change makes sure that > required clocks remain enabled before calling into vendor specific > setup_clocks callback. > > Signed-off-by: Subhash Jadavani > --- > Changes from v2: > * Don't call ufshcd_vops_setup_clocks() again for clock off > --- > drivers/scsi/ufs/ufshcd.c | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 05c7456..c1a77d3 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -5389,6 +5389,17 @@ static int __ufshcd_setup_clocks(struct ufs_hba > *hba, bool on, > if (!head || list_empty(head)) > goto out; > > + /* > + * 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); > + if (ret) > + return ret; > + } > + > list_for_each_entry(clki, head, list) { > if (!IS_ERR_OR_NULL(clki->clk)) { > if (skip_ref_clk && !strcmp(clki->name, "ref_clk")) > @@ -5410,7 +5421,16 @@ static int __ufshcd_setup_clocks(struct ufs_hba > *hba, bool on, > } > } > > - ret = ufshcd_vops_setup_clocks(hba, on); > + /* > + * 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); > + if (ret) > + return ret; > + } > out: > if (ret) { > list_for_each_entry(clki, head, list) { > -- > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, > a Linux Foundation Collaborative Project > > -- > To unsubscribe from this list: send the line "unsubscribe linux-scsi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html