Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp796717pxb; Wed, 3 Feb 2021 19:11:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyf72YJpIjcER9ZBugQQcQqHfZp0N3IEC9LF+2KB2R3JcXNMDj0VDkkX4hK9xvBkO8/17cD X-Received: by 2002:a17:906:b28f:: with SMTP id q15mr6049990ejz.77.1612408270473; Wed, 03 Feb 2021 19:11:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612408270; cv=none; d=google.com; s=arc-20160816; b=mpudL6IDq/gNGrL1JdFbEI+fXzrtxjzFySgjoMZHbG+mZVF3dXgBNNmTR5CklyvTSF V8H8NbBKeiMS0o5Y0QWvI7B2QEFjDjzPKplC6cPlkacduIOKABjQxC+0HiGG+AdF8Xrl DcjQJCiJ1IAydFaFmaJTZyIHPMg1mhdDHnyNsJvAxLZTdKOTEqtQre80iTYZWi2flUCh 64kclx1FPlVdgHAGWDZGB1ikxMj8FfnDdQV+NmKYOyiwi638XG4sHlS/mQOKDNwmEryK NeP7fxqvRzKj2PSZ1if8YzS1eDprrP3HsS8Kh1P6gKY4aIjrEWl68Hzrgpop5r7jpij6 kMVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Bn5azreVFLQ7qN/StWsc+t91I2MG70w1jFYtpayCC+s=; b=Ym7YQ/nbH3pmEh9jnB9UpbNoHfXkWufj/RSYuYWPsmCU9jhQr44tUXIe/GemElHzZJ k/HRDIjA4lGkmWPnF+YlAU2+T6FrkGutN6tZNDREK2fLElxJ1RC8breR1zLBuSZLoyU8 +BBrIw4quNawxXSBoJ6MhogES52/N3KGRSVEhFJg/WC49xnKtR99NCBUxIEgAKSBt8un Xi6jS1oRA52/fyX1eqYtw7htnoxlig3zN4tdvD2JlRqkIJjawpQ3nsjDVzaaYErMBA7z 6jDqn+xQNkfXdLgbinLepEvNDkVKJUxZsJjXbE5pUK4QQu/ui4xLRW1OchMWpFjOLJkE mRxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F2SpybZc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si41754edr.604.2021.02.03.19.10.45; Wed, 03 Feb 2021 19:11:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F2SpybZc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231874AbhBDCuL (ORCPT + 99 others); Wed, 3 Feb 2021 21:50:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbhBDCuJ (ORCPT ); Wed, 3 Feb 2021 21:50:09 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7186DC0613D6 for ; Wed, 3 Feb 2021 18:49:29 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id f63so1139257pfa.13 for ; Wed, 03 Feb 2021 18:49:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Bn5azreVFLQ7qN/StWsc+t91I2MG70w1jFYtpayCC+s=; b=F2SpybZcrRPLQx8JKELEkQPQQnltU4dYlqWpY27vNrQ9LIP8SkDtmFOTbkGpCuULPn uqPG07R7uyqEPEkslR2Ok6ZPRlIziuWFk5O14JumEahpKSyg+GhPVpHg52Cy3swXWt0Y /PLe+1C1+JQfrY8AoOXAiSY58t8m1hSsj4TOM7rEOS8P2L9M87yq8tPGXU0SeAPdsIzp 5ZdumAj0SnEeU+mvSnuvFhNXoHP4BnrEHWQH9m9LETjspFsL44ttdoJMyjR6zOqIyM9k YyczDA4O4SPTsnac8RpoRMNcvasHlpUv5J7Sxsj3cvENxL/ACtZ7lioQEY9q0HquRlJJ vfaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Bn5azreVFLQ7qN/StWsc+t91I2MG70w1jFYtpayCC+s=; b=KY+dFF1F8jYuyvBKCckRWQFQkeuHspYuhBWpe5syswRFQ62ulQ7yUO1BSCwaFPDur8 zwWm2SO+4gO9TvvZn+3lPjsXX7AtBaTYAniyRnwo6Srko/sBjtU3yAl4B7jDQoprfREo T3mipV7mO0iXId8/4x9wVf4OjK4ht0G6u0TK/GeIGz7DGj2DFjSQiPvW7bOui5ps42cz JkcnBOrBHIEOrfaqWjRUBOdYCvFAf7Xwr5sD2SrPRTdUDsKtgWwiWa9oJAyQUEFg61wP 8hgzEyvSKZMFgvAD+Ke0g2cGK9YryhT74yVvLOFiRbIE6xumc5+dwI90zYK+rz1/R0bJ SVlQ== X-Gm-Message-State: AOAM530n44gjsG4wn9nJhOHTox7tWlrXtLwUudhdLjEO7hlUfy9NnNsa L85fei78O9vnN2fPvtlSkH4JlJKrjJi5jQ== X-Received: by 2002:a63:e101:: with SMTP id z1mr6684962pgh.190.1612406968511; Wed, 03 Feb 2021 18:49:28 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id dw23sm3446020pjb.3.2021.02.03.18.49.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2021 18:49:27 -0800 (PST) Date: Thu, 4 Feb 2021 08:19:25 +0530 From: Viresh Kumar To: Hsin-Yi Wang Cc: Viresh Kumar , linux-pm@vger.kernel.org, Nishanth Menon , Stephen Boyd , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, "MyungJoo Ham )" , Kyungmin Park , Chanwoo Choi , Saravana Kannan Subject: Re: [PATCH v5 3/3] PM / devfreq: Add required OPPs support to passive governor Message-ID: <20210204024925.teamzh3d6aq6qfln@vireshk-i7> References: <20210203092400.1791884-1-hsinyi@chromium.org> <20210203092400.1791884-4-hsinyi@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210203092400.1791884-4-hsinyi@chromium.org> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03-02-21, 17:24, Hsin-Yi Wang wrote: > From: Saravana Kannan > > Look at the required OPPs of the "parent" device to determine the OPP that > is required from the slave device managed by the passive governor. This > allows having mappings between a parent device and a slave device even when > they don't have the same number of OPPs. > > Signed-off-by: Saravana Kannan > Acked-by: MyungJoo Ham > Acked-by: Chanwoo Choi > Signed-off-by: Hsin-Yi Wang > --- > drivers/devfreq/governor_passive.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c > index 63332e4a65ae8..8d92b1964f9c3 100644 > --- a/drivers/devfreq/governor_passive.c > +++ b/drivers/devfreq/governor_passive.c > @@ -19,7 +19,7 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, > = (struct devfreq_passive_data *)devfreq->data; > struct devfreq *parent_devfreq = (struct devfreq *)p_data->parent; > unsigned long child_freq = ULONG_MAX; > - struct dev_pm_opp *opp; > + struct dev_pm_opp *opp = NULL, *p_opp = NULL; I would initialize p_opp to ERR_PTR(-ENODEV) to avoid using IS_ERR_OR_NULL. There is no need to initialize opp as well. > int i, count, ret = 0; > > /* > @@ -56,13 +56,20 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, > * list of parent device. Because in this case, *freq is temporary > * value which is decided by ondemand governor. > */ > - opp = devfreq_recommended_opp(parent_devfreq->dev.parent, freq, 0); > - if (IS_ERR(opp)) { > - ret = PTR_ERR(opp); > + p_opp = devfreq_recommended_opp(parent_devfreq->dev.parent, freq, 0); > + if (IS_ERR(p_opp)) { > + ret = PTR_ERR(p_opp); > goto out; Perhaps just return from here, the goto is useless here. > } > > - dev_pm_opp_put(opp); > + if (devfreq->opp_table && parent_devfreq->opp_table) > + opp = dev_pm_opp_xlate_required_opp(parent_devfreq->opp_table, > + devfreq->opp_table, p_opp); > + if (opp) { This needs to be part of the above if block itself, else the opp will always be NULL, isn't it ? > + *freq = dev_pm_opp_get_freq(opp); > + dev_pm_opp_put(opp); > + goto out; > + } > > /* > * Get the OPP table's index of decided freqeuncy by governor > @@ -89,6 +96,9 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, > *freq = child_freq; > > out: > + if (!IS_ERR_OR_NULL(opp)) you should be checking for p_opp here, isn't it ? And perhaps we don't need this check as well as p_opp can't be invalid here. > + dev_pm_opp_put(p_opp); > + > return ret; > } > > -- > 2.30.0.365.g02bc693789-goog -- viresh