From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00881C43381 for ; Thu, 4 Feb 2021 07:08:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C7B564F64 for ; Thu, 4 Feb 2021 07:08:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234104AbhBDHId (ORCPT ); Thu, 4 Feb 2021 02:08:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbhBDHI2 (ORCPT ); Thu, 4 Feb 2021 02:08:28 -0500 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 335F0C061573 for ; Wed, 3 Feb 2021 23:07:48 -0800 (PST) Received: by mail-io1-xd34.google.com with SMTP id f67so350294ioa.1 for ; Wed, 03 Feb 2021 23:07:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gwShMW7VakppNtamo5qslqRnez5wOdtbVlLT+hSRpfg=; b=S9ub4QTW0HD0Cdk+VbWFIuLHzN8ySxxEzYql7gewsK1tSSIfZdRkSkghx9nojf63Uv 10boAezBQxLoLEt3Ui4ja2OJD+4t/2ixQgnn6Mdzp70ODxILjpcISAdpllmdQb1ZaIiX mcu39on4BQlCGCS6G+41hJBq0Rqm4NQezEEr8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gwShMW7VakppNtamo5qslqRnez5wOdtbVlLT+hSRpfg=; b=GsaZOcgInXVKu4goszQAbOT16WOuEoWBfmPSXwxgmUu4XuiQRfK70zOsvtwP9bM5YW B7r6+BOja6TEfkJoXYms/tPC3FVsyydT5xWlgtcW32CyWjHOM1vo5xzhSH5KvzcM3cLG PXQHKKKPF5GHYkzrDRvliYx0xRletMzgq7Lyneo26fIOX/BpEc89pK6G7ZdfDxNavIl7 DYJOBDiT4LxlydUIL53msi65c7KGvtapeM/ftMsOdvjbR+KSugI8AtSk35Dmt/x1iETj i9ZM7t3txpEV8BfVG9Qcf39HrYizH+2+o89qzeViKa+1x6O/s8McNl2NtFxK1Nh4iy0+ amIA== X-Gm-Message-State: AOAM532PJ7C+zVRnYUfXe+Itnx+SIyA92Wf2EJJCA5pP/w+kiklYQ9ys 1IVdLw0fwAy51RfBedNaqe7UIqzlTszknpDmoYKteQ== X-Google-Smtp-Source: ABdhPJyaBwO5cx5qL0Jinl0WSZXLwj+DqPa0HN0Zc+exdYGqMx/QERfvdvzqT0+dx7TSBowbGvlKTX7vAoUudFMpCgc= X-Received: by 2002:a5e:a911:: with SMTP id c17mr5247460iod.20.1612422467611; Wed, 03 Feb 2021 23:07:47 -0800 (PST) MIME-Version: 1.0 References: <20210203092400.1791884-1-hsinyi@chromium.org> <20210203092400.1791884-4-hsinyi@chromium.org> <20210204024925.teamzh3d6aq6qfln@vireshk-i7> In-Reply-To: <20210204024925.teamzh3d6aq6qfln@vireshk-i7> From: Hsin-Yi Wang Date: Thu, 4 Feb 2021 15:07:21 +0800 Message-ID: Subject: Re: [PATCH v5 3/3] PM / devfreq: Add required OPPs support to passive governor To: Viresh Kumar Cc: Viresh Kumar , Linux PM , Nishanth Menon , Stephen Boyd , "Rafael J . Wysocki" , lkml , "MyungJoo Ham )" , Kyungmin Park , Chanwoo Choi , Saravana Kannan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 4, 2021 at 10:49 AM Viresh Kumar wrote: > > 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 > Thanks for the review. I'll fix them and send next version > -- > viresh