Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp223169iog; Wed, 15 Jun 2022 00:33:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAY7/rgDdmdCorJFO9YkNvhJ2mJHcpsHXSSN0rwJ+BXX1wlmMZb5pN0eMLGUlY4igvpqM6 X-Received: by 2002:a17:906:e19:b0:708:e523:5c24 with SMTP id l25-20020a1709060e1900b00708e5235c24mr7354944eji.706.1655278439530; Wed, 15 Jun 2022 00:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655278439; cv=none; d=google.com; s=arc-20160816; b=isZ2OWTr2glY1np3m7+lnOlQTkzySiJXphisCrbGfWuLG96LKluBV3gK8ajXxQ073u +faUnj+qN0cfs6ZyUBXNdL2KFIaewOkkx1y6kU7N8Uy7c6CE4iYJB92i3LqRrPZ+z4KR ZtQnY9yAXblbANkeZ/aHA4QjgdfGtXeh4nRHq1RnIkcL9MDs19x70U2gOgaGQPXgZB2e zpnR/5gLq65CkoAruKWXJ15Zbr2dUphpeqXRglTXSaM1xI/HIUFy7pwQUuepikao4WNf 4XsFCUe/ncDQ9ND3cbRcj27/RafGs+r/C3fJDb9Zkxo8MnVSDUVPVR5bnkbxhcrsmKyZ f7kQ== 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=GMOK2pdGM9oBo0DGilUdzXqbnHYsB6SYWCWDSNKdZOw=; b=kicZQECIDiwRtwojATL7LYcFPO48XeMY8VP3IGdgJLqA+1qTJ3k56E8FWEuydarYMr Czs7Ouxd4nWNsI2AiwwYq0V90VNmi6McOvvJKzk9L7+oYkF6RvoL4BKEYIQrCffsv7ek 427fsn5mdNakcqTbHXlqG1aUGFXx/vrHeXyvXMo0IAF8wFAs1u1/Epqz1QeJY2+WhSwe pwgK44K0nL01VnYfUgOVELMcHQwjZdIEiaclozUPu9SfqhbilEO6QYwmbQ+T5XQPNoL7 7bmEZi81B0H49rqA+ybfI+Y8QYEQDqVHg8jsduLG6pPZmq/3V2qAO9WVPW1ZHDMTx1bQ 4AWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZrQ7LY8y; 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 sa17-20020a1709076d1100b0071076a14dbcsi14619199ejc.772.2022.06.15.00.33.33; Wed, 15 Jun 2022 00:33:59 -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=ZrQ7LY8y; 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 S1346050AbiFOHLY (ORCPT + 99 others); Wed, 15 Jun 2022 03:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346072AbiFOHLT (ORCPT ); Wed, 15 Jun 2022 03:11:19 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10D2645AC9; Wed, 15 Jun 2022 00:11:18 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id t3-20020a17090a510300b001ea87ef9a3dso1189960pjh.4; Wed, 15 Jun 2022 00:11:18 -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=GMOK2pdGM9oBo0DGilUdzXqbnHYsB6SYWCWDSNKdZOw=; b=ZrQ7LY8ytWI1IHWrHOJxAIMxwrLeNe2D9sJtl67o/S5gDFIrQo7hp3jtCtgnJ4v/2v /GDAgmj3Y06vlmR6Hu4Q6jJXoyhFmwa2iyOkv0GTGH24g6DcJjaFTMDdIFJt/9FH7mqC xdJkbmY+2wFIbgK7VjaU+H2/E3pmRorapsItFuKzEDyrEt0UYGLH4GDNnuyurN77otB0 45ZeoDRTpWNVuUkqA8Y+D5x3glKhHlqbU2MaHS0VOcy9lfXlquITRGZ3iakmmd8JnxA9 nXPC7OUH+KtkixpKEF1VXyANqK6LvIgwCZ6Zrc5CoO5g2KYQ8ipEbKsrThY4eCbXSsuC xBjw== 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=GMOK2pdGM9oBo0DGilUdzXqbnHYsB6SYWCWDSNKdZOw=; b=ASga3gVwpMyYe3qJiTOji8E3AlYm1KSTAL/J2gZa7NiHB4lPMZCqF4ZJZzVcd0pvPq DClhDcsjChgEmiGOpfyruu5xmimWj1OJUREmKMStXqNU3pK1IYdJqSCbdDO2WIRshLZi s1Z3/sXTvqrVjROPWnC7qp8cd6UJ1uq+tu9+sd95+vBnOK0fy0lkoPCCnYpB7IC8Hm7/ wQwFVicq9S8+Zh+1mrFOp1CdsEjYpkBXaR9fv2nm5DrLQZqa8WqEmaZEgmSPpBYoF3eQ ZTLMyLJmgUMB9LVg+TTGNCrisP7Sl/bMpYm2HXiy1lXOjCIv8TgeHfl3otWwCFQsuP02 cR2A== X-Gm-Message-State: AJIora/0QtngOxZVcSbTetD9djZhLZ6uvMluZlylLZbOBmVy7ArItkw7 L79pLwr+tjXdXu5FNf9cpOw= X-Received: by 2002:a17:902:9f98:b0:168:abe3:c23d with SMTP id g24-20020a1709029f9800b00168abe3c23dmr8145323plq.131.1655277077392; Wed, 15 Jun 2022 00:11:17 -0700 (PDT) Received: from [172.30.1.37] ([14.32.163.5]) by smtp.gmail.com with ESMTPSA id x29-20020aa79a5d000000b0050dc76281a2sm8916595pfj.124.2022.06.15.00.11.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jun 2022 00:11:16 -0700 (PDT) Message-ID: <5848a10e-e5bf-108f-3e3e-15e16332922d@gmail.com> Date: Wed, 15 Jun 2022 16:11:13 +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 2/4] PM / devfreq: Fix kernel warning with cpufreq passive register fail 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-3-ansuelsmth@gmail.com> From: Chanwoo Choi In-Reply-To: <20220614230950.426-3-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: > When the cpufreq passive register path from the passive governor fails, > the cpufreq_passive_unregister is called and a kernel WARNING is always > reported. > This is caused by the fact that the devfreq driver already call the > governor unregister with the GOV_STOP, for this reason the second > cpufreq_passive_unregister always return error and a WARN is printed > from the WARN_ON function. > Remove the unregister call from the error handling of the cpufreq register > notifier as it's fundamentally wrong and already handled by the devfreq > core code. > > Fixes: a03dacb0316f ("PM / devfreq: Add cpu based scaling support to passive governor") > Signed-off-by: Christian 'Ansuel' Marangi > --- > drivers/devfreq/governor_passive.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c > index 95de336f20d5..dcc9dd518197 100644 > --- a/drivers/devfreq/governor_passive.c > +++ b/drivers/devfreq/governor_passive.c > @@ -331,7 +331,6 @@ static int cpufreq_passive_register_notifier(struct devfreq *devfreq) > err_put_policy: > cpufreq_cpu_put(policy); > err: > - WARN_ON(cpufreq_passive_unregister_notifier(devfreq)); > > return ret; > } I think that it is necessary to free the resource when error happen. Also, after merging the your patch1, I think that cpufreq_passive_unregister_notifier(devfreq) will not return error. Instead, just 0 for success. Instead, 'err_free_cpu_data' and 'err_put_policy' goto statement are wrong exception handling. If fix the exception handling code in cpufreq_passive_register_notifier as following and with your patch1, I'll handle the resource for free/un-registration when error happen during cpufreq_passive_register_notifier. diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index a35b39ac656c..0246e0731fc0 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -289,22 +289,23 @@ static int cpufreq_passive_register_notifier(struct devfreq *devfreq) parent_cpu_data = kzalloc(sizeof(*parent_cpu_data), GFP_KERNEL); if (!parent_cpu_data) { + cpufreq_cpu_put(policy); ret = -ENOMEM; - goto err_put_policy; + goto err; } cpu_dev = get_cpu_device(cpu); if (!cpu_dev) { dev_err(dev, "failed to get cpu device\n"); ret = -ENODEV; - goto err_free_cpu_data; + goto err; } opp_table = dev_pm_opp_get_opp_table(cpu_dev); if (IS_ERR(opp_table)) { dev_err(dev, "failed to get opp_table of cpu%d\n", cpu); ret = PTR_ERR(opp_table); - goto err_free_cpu_data; + goto err; } parent_cpu_data->dev = cpu_dev; @@ -326,10 +327,6 @@ static int cpufreq_passive_register_notifier(struct devfreq *devfreq) return ret; -err_free_cpu_data: - kfree(parent_cpu_data); -err_put_policy: - cpufreq_cpu_put(policy); err: WARN_ON(cpufreq_passive_unregister_notifier(devfreq)); -- Best Regards, Samsung Electronics Chanwoo Choi