Received: by 10.192.165.148 with SMTP id m20csp3752541imm; Mon, 7 May 2018 19:00:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqneJf4L6rWddVTWikUUQEJaIcFslskAA9pgpD7Gtnp6G31Lc9cACuv4gfFT5Q+DqY5YOQZ X-Received: by 10.98.152.203 with SMTP id d72mr38064284pfk.98.1525744827584; Mon, 07 May 2018 19:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525744827; cv=none; d=google.com; s=arc-20160816; b=iwC5wtCf13cN8tj0st5w/HXOHoiJS/MYMA+7tQcMh9TFuWfrIvk13WelLVeHfEovay MU+OedPzWu8yizLwyrNu929RhDUt9mkJpfiRyuYsZuU2c+b2yzkm5AgaSHSHOeHvb44I r4wElJbq57He4oDiBFG2y5HwLFzIek5Y5XeXK3Ijeu9Ij2MgfXAJdJXMxFLCAgWhrIA6 woJXIB+N5EguQ8q/LLqkv+j5WVqj5Vc+9GqXUSAkexTKwyBGpf7angmIe1AdAKXLn6gW EcBSVksMI/C4U3pASSuPVooYbt4POJ65hT7dMVqI8i50ODXo1++x6UaFBpiP7ZC20VVi oNrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :in-reply-to:subject:cc:to:user-agent:organization:from:date :message-id:content-transfer-encoding:mime-version:dkim-signature :dkim-filter:arc-authentication-results; bh=dcLVCNlkReb9vFUhFjROtu+0WIL+zthheeNJbn3gn6E=; b=bN3HAeboGUbUuKGi9DlQ1ZUdVbLLOSXwhXQpASwo5bTGT8mBMcEtrrNw6zZCn5+jrd s491fuzweUc3X9u4GYk5DoxqmK0i7JL4mSUA9wHOrQe7Bk7kN/050cjqN4aRFfoAOJvj 0pK875RNqdHnOjb+cGKhnwKlkuascSC8ryXRzJ6K6k7yFA2f33864mUiigSfDzBSuHAe VYF25NQG0LQhv3XLOCcYjSqt0ipAQNyCJu5GueEQ1JUCLMffkCwArnJl0YzECZzi0G+t yf1azxw21vBux8G1ePtkBidVRRV5lyfVrDXky6khzSGNh6GUae0h7RPGFuiORamiPGiT eVnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=INAorhi+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6-v6si23823280plp.386.2018.05.07.19.00.12; Mon, 07 May 2018 19:00:27 -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=@samsung.com header.s=mail20170921 header.b=INAorhi+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753824AbeEHCAB (ORCPT + 99 others); Mon, 7 May 2018 22:00:01 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:46583 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751828AbeEHB76 (ORCPT ); Mon, 7 May 2018 21:59:58 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20180508015956epoutp01f4c9f6645cf82cc647f359e24a769391~siM72cRnH2508325083epoutp01_; Tue, 8 May 2018 01:59:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20180508015956epoutp01f4c9f6645cf82cc647f359e24a769391~siM72cRnH2508325083epoutp01_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1525744796; bh=dcLVCNlkReb9vFUhFjROtu+0WIL+zthheeNJbn3gn6E=; h=Date:From:To:Cc:Subject:In-reply-to:References:From; b=INAorhi+746X0lkCdLINq11AAfpFOgm2CRadPLhN1sl5z/iK9sq+aROuucdEXqAs6 cR/4ny1APLEsvGbNxKOsVxVDJxzul6YxFM+ghrX6ZePpWhJ4V3SOPc3v3+Ry7r5YFc sAdmX+wuOhOWY7V+uD3hSsfv/RfyGjWhgn7cTnwI= Received: from epsmges1p2.samsung.com (unknown [182.195.40.154]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20180508015953epcas1p26b06612f01e9b8026e0c3a08e15b0964~siM5nZdnH1668616686epcas1p2c; Tue, 8 May 2018 01:59:53 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 9E.1C.04135.99401FA5; Tue, 8 May 2018 10:59:53 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180508015953epcas1p3cac2c96ba3868262a95404b3fd0346eb~siM5XW-zf0544805448epcas1p3o; Tue, 8 May 2018 01:59:53 +0000 (GMT) X-AuditID: b6c32a36-b55ff70000001027-cb-5af10499a0ae Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 55.FE.03822.99401FA5; Tue, 8 May 2018 10:59:53 +0900 (KST) MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset="UTF-8" Received: from [10.113.63.77] by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P8E003DQ07SNC30@mmp1.samsung.com>; Tue, 08 May 2018 10:59:53 +0900 (KST) Message-id: <5AF10498.1000408@samsung.com> Date: Tue, 08 May 2018 10:59:52 +0900 From: Chanwoo Choi Organization: Samsung Electronics User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 To: Bjorn Andersson , Vinayak Holikatti , "Martin K. Petersen" Cc: MyungJoo Ham , Kyungmin Park , linux-scsi@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vivek Gautam Subject: Re: [PATCH v2 1/2] scsi: ufs: Extract devfreq registration In-reply-to: <20180504224427.32606-2-bjorn.andersson@linaro.org> X-Brightmail-Tracker: H4sIAAAAAAAAA01SbUhTYRTm3b3ebeLqOr9ejHRdKXCw6d2cXcOJfRCD/GFEFAtZF71sptvk 3hklFJqR5VdaWTmstILEiKWZzGZZfmam9K1UJiHWsJJWWlpg3e0W9et9znOe57znHI4EkR/H oiW5NgfD2uh8AgtGO3rjVap61GdM/HBDTQ13z6LUyKGPYqq2e0RMPb3VgFFfq/oAVTHmxqgr g0si6lVJM0a5m4qo+4tuJD3Y8LS6SmTodE6IDa9fdGEG3/RL1FDd3gIMX9tiMjEjk2ph6ByG VTC2bHtOrs2sJ7ZsM2006ZITSRWZQq0lFDbayuiJTRmZqs25+XxnhGIvnV/IU5k0xxEJaams vdDBKCx2zqEndpGkRk0mrlVrNPyrzVqn0fGS3YzlwWQXKPgSvu/ZXY+4GAzg5UAigXgSvDss LQfBEjnuBnBhuhcIwXcAn72e4ANpQHSi7igiJDwA3r4+hPkTMjwULpx8g/orIXgs7HuS56cR PB7e9LjEgn4CQE99RZCgV8KZytIARvHVcPH9COLHGM93e8cDNZfjq+DzhanAxxH4Tth54Vug UDheC2B1Xb3IHyD4TwCvfGoMOMLwjfBhXynqx1I8Hd5x/gi0CvEPGDxd8hgVBt3EY5kwThic GWwXC/QK+KRfL8jLACy7ff6P9xSAo2NvRIJBC981lYuE2ZbB2fnKIMEsg0ePyAWJAY67G4IE vB62ehcxYfwhAEcmZ5AaEOP8b2POfxtz/rexRoC0gEim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Dj8/0TR/tzRd8nh/C 0OMzaRn7hZYV53wY/XuTTJ/1PM4MzI9YGB3lGHxQuF1rU/CJ8ixZKa9MyZgZMYUdTtOjlO5X KLEUZyQaajEXFScCAH45puuFAgAA X-CMS-MailID: 20180508015953epcas1p3cac2c96ba3868262a95404b3fd0346eb X-Msg-Generator: CA CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180504224510epcas4p2e6a1303ea814642ad851bc6072be6089 X-RootMTR: 20180504224510epcas4p2e6a1303ea814642ad851bc6072be6089 References: <20180504224427.32606-1-bjorn.andersson@linaro.org> <20180504224427.32606-2-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2018년 05월 05일 07:44, Bjorn Andersson wrote: > Failing to register with devfreq leaves hba->devfreq assigned, which > causes the error path to dereference the ERR_PTR(). Rather than bolting > on more conditionals, move the call of devm_devfreq_add_device() into > it's own function and only update hba->devfreq once it's successfully > registered. > > The subsequent patch builds upon this to make UFS actually work again, > as it's been broken since f1d981eaecf8 ("PM / devfreq: Use the available > min/max frequency") > > Reviewed-by: Subhash Jadavani > Signed-off-by: Bjorn Andersson > --- > > Changes since v1: > - None > > drivers/scsi/ufs/ufshcd.c | 31 ++++++++++++++++++++++--------- > 1 file changed, 22 insertions(+), 9 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 8f22a980b1a7..2253f24309ec 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -1255,6 +1255,26 @@ static struct devfreq_dev_profile ufs_devfreq_profile = { > .get_dev_status = ufshcd_devfreq_get_dev_status, > }; > > +static int ufshcd_devfreq_init(struct ufs_hba *hba) > +{ > + struct devfreq *devfreq; > + int ret; > + > + devfreq = devm_devfreq_add_device(hba->dev, > + &ufs_devfreq_profile, > + "simple_ondemand", You better to use 'DEVFREQ_GOV_SIMPLE_ONDEMAND' definition in include/linux/devfreq.h in order to prevent the some typo. - aa7c352f9841 ("PM / devfreq: Define the constant governor name") > + NULL); > + if (IS_ERR(devfreq)) { > + ret = PTR_ERR(devfreq); > + dev_err(hba->dev, "Unable to register with devfreq %d\n", ret); > + return ret; > + } > + > + hba->devfreq = devfreq; > + > + return 0; > +} > + > static void __ufshcd_suspend_clkscaling(struct ufs_hba *hba) > { > unsigned long flags; > @@ -6399,16 +6419,9 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) > sizeof(struct ufs_pa_layer_attr)); > hba->clk_scaling.saved_pwr_info.is_valid = true; > if (!hba->devfreq) { > - hba->devfreq = devm_devfreq_add_device(hba->dev, > - &ufs_devfreq_profile, > - "simple_ondemand", > - NULL); > - if (IS_ERR(hba->devfreq)) { > - ret = PTR_ERR(hba->devfreq); > - dev_err(hba->dev, "Unable to register with devfreq %d\n", > - ret); > + ret = ufshcd_devfreq_init(hba); > + if (ret) > goto out; > - } > } > hba->clk_scaling.is_allowed = true; > } > Reviewed-by: Chanwoo Choi -- Best Regards, Chanwoo Choi Samsung Electronics