Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp473051pxm; Wed, 2 Mar 2022 02:14:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBJLhUi7pc0IQZuoi6DJ7kwUsUP+c+S8zTUS9jM7+Jtm3hlLxNVdyvhJG3faPjEK6ePxyP X-Received: by 2002:a17:906:2695:b0:6ce:b94d:9f07 with SMTP id t21-20020a170906269500b006ceb94d9f07mr22972772ejc.297.1646216063319; Wed, 02 Mar 2022 02:14:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646216063; cv=none; d=google.com; s=arc-20160816; b=vKGikDGzKi2H77T8xBA0r+HG7geGtWiyrjH/+iFvdFh5/5vgQqTyWj4mIr3SfFDkEz 9uMtp1EfiQQUW/oMf9xwTybFVId0obcTLf31IyCHNcWu5UAdtZgo2hdxx45EUb0yXdgx vnBVLSlg2quVKD/tWyx5mcVxCbRcukmmAIF+bYpNJeOhZ5HO2EOPp+hr+ZCRQkL/YSuN CVhoX5GYO6a6jw2DRme8ldM85pn+rLT8WzPLpt2wpv6y2vYL8gT4UyfstP2aOMFBCU+z xc6eRUgCQIA2UOUzutnQS8bvpfiPsIsCGn5PerCaqOBFA1beBldrS0gspMV32r0o0RJW 69jw== 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:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=RAHufmsmi8RI5vaOnGKwZ+3pxZ3Thlwjptg8PjW6M3M=; b=BTBX9fWulpBX1qGCcGC2p+F2ntMULwP+0y4bt0t0CXPYSWKQLf6xG1AOkukzNS6J51 n0yvuwUCGAkrqvgtSP+8awezoT0fhtAqx2/Tl/m5MQno3u6y1eonMrsnaRDu+jFbd1cn sGJbU6tfIIAzz+AcecZe73yi9m7qsi4o9lx/H8Eh5yoHhoYjs7+FCSs5i4QzTWByODKi 1UpzQI56VW8cpYqK0loklG/WLp0Ifkj35i1tvKd8xGLDHYlB9nUUJYMJOYKFLtMrs6Ff +Tc2g49dkTxCVNnnJZRgYp7wD3TU4ldbOZRIVeyi8Qj5a2xpsIOm1vYbusqoO6wWGIPP G8yg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i25-20020a50fc19000000b0041083e611f7si10529858edr.564.2022.03.02.02.13.59; Wed, 02 Mar 2022 02:14:23 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240227AbiCBIuz (ORCPT + 99 others); Wed, 2 Mar 2022 03:50:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232272AbiCBIuy (ORCPT ); Wed, 2 Mar 2022 03:50:54 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DDD435C34E; Wed, 2 Mar 2022 00:50:10 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 82E551396; Wed, 2 Mar 2022 00:50:10 -0800 (PST) Received: from [10.57.21.27] (unknown [10.57.21.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 858FA3F66F; Wed, 2 Mar 2022 00:50:08 -0800 (PST) Message-ID: Date: Wed, 2 Mar 2022 08:50:06 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 3/4] OPP: Add support of "opp-microwatt" for advanced EM registration Content-Language: en-US To: Viresh Kumar Cc: linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com, rafael@kernel.org, daniel.lezcano@linaro.org, nm@ti.com, sboyd@kernel.org, mka@chromium.org, dianders@chromium.org, robh+dt@kernel.org, devicetree@vger.kernel.org, linux-pm@vger.kernel.org References: <20220301093524.8870-1-lukasz.luba@arm.com> <20220301093524.8870-4-lukasz.luba@arm.com> <20220302074515.dqzoutfiobildiph@vireshk-i7> From: Lukasz Luba In-Reply-To: <20220302074515.dqzoutfiobildiph@vireshk-i7> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,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 3/2/22 07:45, Viresh Kumar wrote: > On 01-03-22, 09:35, Lukasz Luba wrote: >> /** >> * dev_pm_opp_of_register_em() - Attempt to register an Energy Model >> * @dev : Device for which an Energy Model has to be registered >> @@ -1517,6 +1567,12 @@ int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus) >> goto failed; >> } >> >> + /* First, try to find more precised Energy Model in DT */ >> + if (_of_has_opp_microwatt_property(dev)) { >> + em_cb.active_power = _get_dt_power; > > You can also do (to fix the warning) this instead: > > em_cb = EM_DATA_CB(_get_dt_power); > > Similar for the else part. > Unfortunately, not for this case. When we declare that em_cb it can handle the brackets '{ }', but not later in the code no. In both configs it won't fly: EM: drivers/opp/of.c: In function ‘dev_pm_opp_of_register_em’: ./include/linux/energy_model.h:118:38: error: expected expression before ‘{’ token #define EM_DATA_CB(_active_power_cb) { .active_power = &_active_power_cb } ^ drivers/opp/of.c:1573:11: note: in expansion of macro ‘EM_DATA_CB’ em_cb = EM_DATA_CB(_get_dt_power); ^~~~~~~~~~ ./include/linux/energy_model.h:118:38: error: expected expression before ‘{’ token #define EM_DATA_CB(_active_power_cb) { .active_power = &_active_power_cb } ^ drivers/opp/of.c:1600:10: note: in expansion of macro ‘EM_DATA_CB’ em_cb = EM_DATA_CB(_get_power); ^~~~~~~~~~ !EM: drivers/opp/of.c: In function ‘dev_pm_opp_of_register_em’: ./include/linux/energy_model.h:266:38: error: expected expression before ‘{’ token #define EM_DATA_CB(_active_power_cb) { } ^ drivers/opp/of.c:1573:11: note: in expansion of macro ‘EM_DATA_CB’ em_cb = EM_DATA_CB(_get_dt_power); ^~~~~~~~~~ ./include/linux/energy_model.h:266:38: error: expected expression before ‘{’ token #define EM_DATA_CB(_active_power_cb) { } ^ drivers/opp/of.c:1600:10: note: in expansion of macro ‘EM_DATA_CB’ em_cb = EM_DATA_CB(_get_power); ^~~~~~~~~~ If you like, I can introduce new dual-macro implementation in energy_modle.h which would sole this issue: ifdef EM: #define EM_SET_ACTIVE_POWER_CB(em_cb, cb) ((em_cb).active_power = cb) ifndef EM: #define EM_SET_ACTIVE_POWER_CB(em_cb, cb) do { } while (0) Then we would keep the single call to the registration EM and we would have: if (_of_has_opp_microwatt_property(dev)) { EM_SET_ACTIVE_POWER_CB(em_cb, _get_dt_power); goto register_em; } EM_SET_ACTIVE_POWER_CB(em_cb, _get_power); register_em: ret = em_dev_register_perf_domain(dev, nr_opp, &em_cb, cpus, true); I can do that, please let me know.