Received: by 10.192.165.148 with SMTP id m20csp5122739imm; Tue, 24 Apr 2018 14:11:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+oNb4IoxiGwpbWf3XWnUTZDJOcDndIFPk/y/gQR7BDS3EllbXkQaYIjhtq8P9HFYOXtjO/ X-Received: by 10.101.71.132 with SMTP id e4mr18379355pgs.196.1524604292114; Tue, 24 Apr 2018 14:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524604292; cv=none; d=google.com; s=arc-20160816; b=mM00rhRcZC/3S7U/S4EhT6gZ/uVjaUws7IxuzrynMeTsoyUV/ZGzrJIUdQJ1YZyvJ6 yt4cn6fMLPV0qtgLzZxi/K3sHCaZPVhoEO1vwG/DAyUtClwuPFUouNW0HP/4t0oPMYKa T1ILzBmzXLhqqfmCiDVD3UIT+daefQa0LRB0Q0m2ukRXjDn6+z7M+2P5LZBIRBYhMwek q7etvS5UVz4vGCaRiFH11+mn2Uwufb1REMYG6B2cjwMqbpnSRArQTzUWYkf9aEbUm49N Ddem8kIBm5Ilff3Wrkhr0o3XWKLl0GN6TDyGEDTKSKidy4dtHtQswH1WUGIOUvp+yoNb tLlQ== 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=wjXOOAYKldB6VVUFwI2KwC/fvZjIZWbJzldd3ryAizs=; b=OxB1pXOFv6PVnV42DK2hY4hoMt01aUQCVlWQ93MFANwBbTZYxYyslvzv6NyUovjrLD t+aQaMtv6SZzLeK+N8gUWrFO7IBhS4jCAHvspWkMIvZyF8IG8HnT/bLwkfubOBZzDMaX YP0ygfBLp8b/dzhVt6Pd4oZAPZ/dj0oZPTbhNfR2MonhsVjfb9LchmlAxotenLFvdb1B wxw8umH/G0X3tt/Nr98xDCb42sF8IXW4ya68y+eqZpaZN1FzO+hE7asOX3RdmoF5RPWb y9oHx0+ceC5lqeYpG9+/+a9FU8KQFJsoy3mnYqP96FeWVJxoiRupOo8koK2ZBUu5CZ46 rUyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=n7WiBNel; dkim=pass header.i=@codeaurora.org header.s=default header.b=n7WiBNel; 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 f11-v6si2594726plj.58.2018.04.24.14.11.17; Tue, 24 Apr 2018 14:11:32 -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=n7WiBNel; dkim=pass header.i=@codeaurora.org header.s=default header.b=n7WiBNel; 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 S1752531AbeDXVIx (ORCPT + 99 others); Tue, 24 Apr 2018 17:08:53 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:42970 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752045AbeDXVIK (ORCPT ); Tue, 24 Apr 2018 17:08:10 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id DF6F66090E; Tue, 24 Apr 2018 21:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524604089; bh=FEt0Db3/2/M8+bxJR+RbNw1LpfL053fXK9RcD0w1RNk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=n7WiBNelivB1ZjfHasNQL7e0nAbKUSGIz5fVKQ3TBPTpxphUMypKIR2Pq1LP5TaMO lAdWQV9gvAR7Mrtg2n5dEoq0c6BWIas5mCH7jX3cJAuVeo9YzZ8RchQ7SO130ZN1iY i6Fcw46jFPjSOxkw8Zh8ffq4dK4VgqGvkk0F+crI= 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 20BAA60500; Tue, 24 Apr 2018 21:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524604089; bh=FEt0Db3/2/M8+bxJR+RbNw1LpfL053fXK9RcD0w1RNk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=n7WiBNelivB1ZjfHasNQL7e0nAbKUSGIz5fVKQ3TBPTpxphUMypKIR2Pq1LP5TaMO lAdWQV9gvAR7Mrtg2n5dEoq0c6BWIas5mCH7jX3cJAuVeo9YzZ8RchQ7SO130ZN1iY i6Fcw46jFPjSOxkw8Zh8ffq4dK4VgqGvkk0F+crI= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 24 Apr 2018 14:08:09 -0700 From: Subhash Jadavani To: Bjorn Andersson Cc: Vinayak Holikatti , "James E.J. Bottomley" , "Martin K. Petersen" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , linux-scsi@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vivek Gautam , linux-scsi-owner@vger.kernel.org Subject: Re: [PATCH 2/3] scsi: ufs: Extract devfreq registration In-Reply-To: <20180424002016.9205-3-bjorn.andersson@linaro.org> References: <20180424002016.9205-1-bjorn.andersson@linaro.org> <20180424002016.9205-3-bjorn.andersson@linaro.org> Message-ID: <41c6fd36826ee853c86b3fb3e069903c@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-04-23 17:20, 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") > > Signed-off-by: Bjorn Andersson > --- > 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", > + 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; > } Looks good to me. Reviewed-by: Subhash Jadavani -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project