Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp224847iog; Wed, 15 Jun 2022 00:36:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGJLFUiKbE55g3iXkaZB/TCetdW1RlwWRfEWV08I2W3UN2/22fdnSwEQ1PjFCqu9AVqDdS X-Received: by 2002:a17:906:1109:b0:711:d8fe:fe56 with SMTP id h9-20020a170906110900b00711d8fefe56mr7645952eja.261.1655278585071; Wed, 15 Jun 2022 00:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655278585; cv=none; d=google.com; s=arc-20160816; b=VCjcoC+lvnWVn2wIi/+ATktQSODiFDP2W+JtIOkR56rakYldPRaxu8GVT6MfkT6PVP kVRRoqylYmJageCC/boQzcFFzCkcYrcGkjSYp7OZCgVJn6lSwdmxdZm3DnkVKnUV2PKg yH8BGec3z5QHZk2UMoS8xVNj3QNd8feOFa6a2OmOIOxW7wO0vpAAroRY9kEfrF1w+Sde AXHmoyCAfqpL6Jei7TayvnFfBnRt/kizvVXkYpLIALY5CkYlVmKZ9dgQ7AhT1UbZQzGF rppCBYaGCnLsjyXgzJEVB0L1tf8+pmLzQtFgdY5lTAZ070dK+MtLWOYyUoRiL1T3zLFI 5K1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=jEzroN9krnUkZ2+Y46mqGxrDo8hTabqX3KY2I2rzfxE=; b=NKY/s2b5coD1jiGE4RvkLpFbPrvtuvzgOGp/KdTI209Bku5JjHTORPpoRof2ScEwQt wFKZCjnzQl/Af6iJDAbQb07zLXHoZfo2Tj/lfBEnEN7xj3PAFvuKpHjDO5VhLTTsnH7g Npqxh3zTPONuadWUiNDEQIK9OEpsbq/bzO6EmxeMe9r7BM+C+/oDMA/azT44cdJ48dzO dkLvq9enLqrFO/YTTkAy/S7DAGHM23ueKE//jRXFSP+hiVUwMmark/tON1t1oheJt0H6 KnGtv0MnmDEMj56CVE4iAK5VdXv2RffrYymFANMndHBh1y3QKA5Y6qmP2G4c7bxZxgmY REkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="KnRE/wBH"; 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 a21-20020a1709063e9500b0070eb188249bsi12072958ejj.358.2022.06.15.00.35.59; Wed, 15 Jun 2022 00:36:25 -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="KnRE/wBH"; 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 S237161AbiFOGsM (ORCPT + 99 others); Wed, 15 Jun 2022 02:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234799AbiFOGsL (ORCPT ); Wed, 15 Jun 2022 02:48:11 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 408012DA9C; Tue, 14 Jun 2022 23:48:08 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id c196so10604846pfb.1; Tue, 14 Jun 2022 23:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=jEzroN9krnUkZ2+Y46mqGxrDo8hTabqX3KY2I2rzfxE=; b=KnRE/wBH4kTNZhS7caskp/emMiN9IUW6MSHYhje8kK1JVkHgS89FZACYMwwnwH+ewB I2xFtQqCywvOVOKQn+prVpQgf9EiGWZoQSz42tLGMcfN8tVYCojY0iQ0ZmEbz8m66UXK w3u9vLaAumpSQ4THVWRo8v3eoWHdzNw0xDsS7A0CdyR7EjDViyjq0GxX8MO96+QtJwUZ 9U5C7c5QZt9c9ICvFrqEC5hdZge+Q7+rHCMbWn3VGncPk0DJxJTr4mZsk9+NNfCN9UAG KlsF1Mxu3OjsLWUYfyvBnVx9Kfn+B8zt/E9Pvuq4Fd28ONQjcrbJ8rcBzz79OgElXaYh qPYg== 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:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=jEzroN9krnUkZ2+Y46mqGxrDo8hTabqX3KY2I2rzfxE=; b=LAhrLQgLEfnQKzNrX4f2J/EqYCbwhXsku8A8MoGIvoOABp2a7Um++4R42rNH+dt8Gy h7tkeX/PQW0p8V2z0YL9i3ZALGu5lODMZqw5PogbzwcNuGA+6ctWzqBY3Fz06B/Cw8YP Yl77V3REoFC9xDxYj2bAqM027CGrVUABb9n1K7yvXqLXuE2rDis2i6MbRSq/LjdF4++Y BQuyX/q7WDzNZpSkYf5enHKXSP2Crn7f84XerDnqwCJUdI6vaWgVYN/EQvCJEwYJ+pB+ r0/gpieLDtRt81GPOn4DxwEYb9BPPU/T3kvke6ktQ9kUzJzD+yPQMKH8VUNdsHp5NeHy gQSQ== X-Gm-Message-State: AOAM533BSfZxQLaBuZJhtucsa6LPBOrorkgzE5+vsF3XvDbFto7wf/Id FEWxQyiAT2DfkZyk/yeSxno= X-Received: by 2002:a63:221b:0:b0:401:afc8:dbfc with SMTP id i27-20020a63221b000000b00401afc8dbfcmr7654908pgi.482.1655275687544; Tue, 14 Jun 2022 23:48:07 -0700 (PDT) Received: from [172.30.1.37] ([14.32.163.5]) by smtp.gmail.com with ESMTPSA id e4-20020a170903240400b00168f329b27dsm1414604plo.53.2022.06.14.23.48.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jun 2022 23:48:07 -0700 (PDT) Message-ID: <17cb21c6-317a-3f70-8c4d-4d8fe20604d4@gmail.com> Date: Wed, 15 Jun 2022 15:48:03 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v4 1/4] PM / devfreq: Fix cpufreq passive unregister erroring on PROBE_DEFER Content-Language: en-US To: Christian 'Ansuel' Marangi , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Sibi Sankar , Saravana Kannan , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220614230950.426-1-ansuelsmth@gmail.com> <20220614230950.426-2-ansuelsmth@gmail.com> From: Chanwoo Choi In-Reply-To: <20220614230950.426-2-ansuelsmth@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,NICE_REPLY_A,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 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; > + 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