Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp326535iog; Wed, 15 Jun 2022 03:05:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u4oOJ/dYEdLH+UJnbXmBwAKIFtsh45IAVJTOs8vTnsJjOG48WM7+P8ruAHAHX75zwBzcuR X-Received: by 2002:a17:90a:728c:b0:1e2:e386:4448 with SMTP id e12-20020a17090a728c00b001e2e3864448mr9322557pjg.167.1655287552048; Wed, 15 Jun 2022 03:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655287552; cv=none; d=google.com; s=arc-20160816; b=ILHBhNlwmak6cAjLb2Qr2JOrFLbaVn3kMmNQq552rI0LpNzmNJsF61MjPdGT/xnyBb g1FAIMdB16NqLwSxXjs+K1/omAIz+dZLrtW2P5jIfSWrxQTwflexCKo8nQ5RfzQGBwm8 +nBpo2otSnAL4LU5Q9UjQCNMxS63FsNIcuJJprBFqtDT8IKL6I1n2Y9GrUuVDqbhc7um sa2Bc+pazg6HRULbeI+b/8FbEKVWHJAgPuQyYOHnHMhJsz/Woy7n9hwy25ga5JK91SyM oiwwPZ3EjKTXZYu7JZiemXdZ88W0wuqSFItT8NJtAnYT40VKwjWypQoH3xvCacRvf8iU 8RBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:subject:cc:to:from:date:message-id:dkim-signature; bh=+o+NJBHdLQtZQM+UxtBaEFTjpeaUrX4loLW3tV0gO1s=; b=kj3WHYPxPLiSjd14FT/oJKyjdYQLbAbUMMKYsCTYbkqN/RmEZraE5P9jkBNA1cTv0J sRKAnPDA6TKz66ibXmo/THx1qgmiBN8M34WqHUVgaflkFdKmfPR9gLDln7d5YI/VYA8H /MyPcDTl6qYToLf3miAShGY2ppij3a+L7IVou1UmYXaKXvwgHKD0/3VTcqml5VPX7LjT YAEVogK2xeKOasT5mNXJKAb90rbHE38g4BinEyZOm5w5VDsaw2zikGq348gemsAtFDvB HHqOlp38upMVa5t6Y762YgQlSQOolHTgCVVCUqdEHbSmR5333mDHjjLYcU4KwPAo3TPJ oDaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QVeMBRfG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m26-20020a638c1a000000b00408d622b82dsi539267pgd.136.2022.06.15.03.05.39; Wed, 15 Jun 2022 03:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QVeMBRfG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237820AbiFOKBS (ORCPT + 99 others); Wed, 15 Jun 2022 06:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiFOKBQ (ORCPT ); Wed, 15 Jun 2022 06:01:16 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39563B023; Wed, 15 Jun 2022 03:01:15 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id v14so14649266wra.5; Wed, 15 Jun 2022 03:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:from:to:cc:subject:references:mime-version :content-disposition:in-reply-to; bh=+o+NJBHdLQtZQM+UxtBaEFTjpeaUrX4loLW3tV0gO1s=; b=QVeMBRfG3BUToGU1v1XZ7CJ9QLI63+40lCKkSLmLQXfgGTHxyMFt0n7AjX+Pz3N9Wx knxlRQIuqPkudGPlE/XLxxZhB3bi25I2J5P+4dJQzflaD7kiUK3N2R17+TT6B7RGaJSw mMLMOSSviRGDemiKOknuGtP6El5Egxsx1ievkQlfC+/twjNRd96r9BDHhHsCUpdGyM4P 1U7iMfi+0HIu8YXy5ouyZ2oH/tL2d8d52ey4CFoBaYHC2EX5p5cCik32mN8d6HlhJx1U XNdgVYmsvHYog0ib8Djdms/nLQ9NFPqvNrtOaT390NEiKeMPJEqN227Vjs0IKnCr6SCV 42Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:from:to:cc:subject:references :mime-version:content-disposition:in-reply-to; bh=+o+NJBHdLQtZQM+UxtBaEFTjpeaUrX4loLW3tV0gO1s=; b=jziw+Bw1/3Mu9HTU6XLNOF7h6mF8h4owHDuSdrszGunt9ZwTGU8665wORSuRTuqUOc SxBLvP6RKFj9IEl5T2fjE1a4B0xiLPQvZJqNjrqe8lfjQ1WFyxur2WJMqH0+3OkVvv4J zNwjWHCcs/Qhnt1Oz6hSnRmcIvNrpDZXxZ0zVSwkZ8DQg8rCdw8q8lLyyHRsynqglt0k PjKBfxHTQ55WSS5y7HKqhdHDMdIdJZ1N5VeF4vDRtTB5SVW4+ZhwBCQoEttn25DJRFWU UBlOVRej5+5dv+G5gT8Hh/bOaH0g0Dh7BBYUZkOaQ1a2mKxq/lmaZ1Y++tkLV3jf9A6B OQZg== X-Gm-Message-State: AJIora/g7E/8/ppXR34Gm3DA+uRVlm17HMTssoVNDwIJS+GIfjGYVKzO uYaHUMSeJqY6Fuk29AdnbDkhZBIks5o= X-Received: by 2002:a05:6000:244:b0:210:cc02:889a with SMTP id m4-20020a056000024400b00210cc02889amr9398786wrz.141.1655287273944; Wed, 15 Jun 2022 03:01:13 -0700 (PDT) Received: from Ansuel-xps. (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.gmail.com with ESMTPSA id j20-20020adfa554000000b002100316b126sm14655002wrb.6.2022.06.15.03.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:01:12 -0700 (PDT) Message-ID: <62a9ade8.1c69fb81.76bfd.ae0b@mx.google.com> X-Google-Original-Message-ID: Date: Wed, 15 Jun 2022 11:13:06 +0200 From: Ansuel Smith To: Chanwoo Choi Cc: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Sibi Sankar , Saravana Kannan , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/4] PM / devfreq: Fix cpufreq passive unregister erroring on PROBE_DEFER References: <20220614230950.426-1-ansuelsmth@gmail.com> <20220614230950.426-2-ansuelsmth@gmail.com> <17cb21c6-317a-3f70-8c4d-4d8fe20604d4@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17cb21c6-317a-3f70-8c4d-4d8fe20604d4@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 15, 2022 at 03:48:03PM +0900, Chanwoo Choi wrote: > On 22. 6. 15. 08:09, Christian 'Ansuel' Marangi wrote: > > With the passive governor, the cpu based scaling can PROBE_DEFER due to > > the fact that CPU policy are not ready. > > The cpufreq passive unregister notifier is called both from the > > GOV_START errors and for the GOV_STOP and assume the notifier is > > successfully registred every time. With GOV_START failing it's wrong to > > loop over each possible CPU since the register path has failed for > > some CPU policy not ready. Change the logic and unregister the notifer > > based on the current allocated parent_cpu_data list to correctly handle > > errors and the governor unregister path. > > > > Fixes: a03dacb0316f ("PM / devfreq: Add cpu based scaling support to passive governor") > > Signed-off-by: Christian 'Ansuel' Marangi > > --- > > drivers/devfreq/governor_passive.c | 39 +++++++++++++----------------- > > 1 file changed, 17 insertions(+), 22 deletions(-) > > > > diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c > > index 72c67979ebe1..95de336f20d5 100644 > > --- a/drivers/devfreq/governor_passive.c > > +++ b/drivers/devfreq/governor_passive.c > > @@ -34,6 +34,20 @@ get_parent_cpu_data(struct devfreq_passive_data *p_data, > > return NULL; > > } > > > > +static void delete_parent_cpu_data(struct devfreq_passive_data *p_data) > > +{ > > + struct devfreq_cpu_data *parent_cpu_data, *tmp; > > + > > Need to add the validation checking of argument as following: > > if (!p_data) > return; > Considering this is called only by cpufreq_passive_unregister_notifier and cpufreq_passive_unregister_notifier is called only by devfreq_passive_event_handler where the check is already done, isn't that redundant. We should never reach delete_parent_cpu_data with no p_data. (Unless you want to use that function somewhere else) > > + list_for_each_entry_safe(parent_cpu_data, tmp, &p_data->cpu_data_list, node) { > > + list_del(&parent_cpu_data->node); > > + > > + if (parent_cpu_data->opp_table) > > + dev_pm_opp_put_opp_table(parent_cpu_data->opp_table); > > + > > + kfree(parent_cpu_data); > > + } > > +} > > + > > static unsigned long get_target_freq_by_required_opp(struct device *p_dev, > > struct opp_table *p_opp_table, > > struct opp_table *opp_table, > > @@ -222,8 +236,7 @@ static int cpufreq_passive_unregister_notifier(struct devfreq *devfreq) > > { > > struct devfreq_passive_data *p_data > > = (struct devfreq_passive_data *)devfreq->data; > > - struct devfreq_cpu_data *parent_cpu_data; > > - int cpu, ret = 0; > > + int ret; > > > > if (p_data->nb.notifier_call) { > > ret = cpufreq_unregister_notifier(&p_data->nb, > > @@ -232,27 +245,9 @@ static int cpufreq_passive_unregister_notifier(struct devfreq *devfreq) > > return ret; > > } > > > > - for_each_possible_cpu(cpu) { > > - struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); > > - if (!policy) { > > - ret = -EINVAL; > > - continue; > > - } > > - > > - parent_cpu_data = get_parent_cpu_data(p_data, policy); > > - if (!parent_cpu_data) { > > - cpufreq_cpu_put(policy); > > - continue; > > - } > > - > > - list_del(&parent_cpu_data->node); > > - if (parent_cpu_data->opp_table) > > - dev_pm_opp_put_opp_table(parent_cpu_data->opp_table); > > - kfree(parent_cpu_data); > > - cpufreq_cpu_put(policy); > > - } > > + delete_parent_cpu_data(p_data); > > > > - return ret; > > + return 0; > > } > > > > static int cpufreq_passive_register_notifier(struct devfreq *devfreq) > > > -- > Best Regards, > Samsung Electronics > Chanwoo Choi -- Ansuel