From patchwork Thu Aug 12 04:35:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12432433 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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 54185C432BE for ; Thu, 12 Aug 2021 04:39:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3A9060F91 for ; Thu, 12 Aug 2021 04:38:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E3A9060F91 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=VjVjrHTkptz3qCD7iG2xuHZ9ZfXA1pGeGQo1Kt6pe1Y=; b=BwhbbU4ZiHMr12 y2iX18h/V0vsc9yY9locoT1y5qJFF/Akod4Xs3nCwPKI7EUfBO6xqHIk6Hr0pJyYCfHaWNqRxbmua 5cmmYK38MSTjGSGyacEw9WKURXz9y0S1OpEYEEh5PezyfNsERBLZVKAewqVox+tcrvxklk0MVUu+P ewjSwkvKg0/CfhcEora0X98Fm6xT39eslSnQiqNV9h3f9HfUs2XhjmLiX2WBke81zsEgygk4sWnW5 wScd36Zcq7/pqCEe+ZT16eGb8Lp1eu0QC0HlN/P9m3hN7UHyivOq8hdwGX07w4C18lbFDSv9dWsSq K411dDYo+E5YxkCFNjOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mE2Rf-008aW6-Gl; Thu, 12 Aug 2021 04:35:55 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mE2RY-008aUt-5e for linux-arm-kernel@lists.infradead.org; Thu, 12 Aug 2021 04:35:52 +0000 Received: by mail-pl1-x632.google.com with SMTP id d1so5645876pll.1 for ; Wed, 11 Aug 2021 21:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gxr+kN6SetTz50b/VYivr0ZuxkSNxFN7jKWgrcYWkys=; b=S1St+GitlDcWedfmRSFXGJimehgFJFlFJwttWDdN3zwMXbC6pb4l3lsPKEyWRkGHT4 hj9LanR1X1hmDGTxbFNTh/HHOKWVEnuDZfgYbxGVXo3MUos0btzQLY1ssDN9j0N7AHhL Pu44FndYuRVG9rtcQMyDyV4EmtQs4oqkIkFl+XfKvg6+Vao0c8+3kx8PqON9bX+JdMBl aIq7jZYDN4rflT6LH0T9TIARx4Mxgc/yDJfjP//GgTvrgmSqM04S+JVjOmKlX7saeAp5 5ADWwmehJpMTRJ9Re+vvybV419/uXAoHdupfeo6URKjlLwTxfWFuma6Rv1rECl3+e0gB 0TEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gxr+kN6SetTz50b/VYivr0ZuxkSNxFN7jKWgrcYWkys=; b=RFXpsEV5bgTt5dM+oqN5wCEby3vCpG4tOE8051XCwcrLS/L6O5vHQTaItTXYzY7prg wQZE6GNZvp1GpHjrztSj0HmiZ+fDOXQ7yQDEDN1JQB2OeKinjao6jvTEu+7GvAok1eoi /2pXVCKZ17psWdx5W252M7R5snmt/kN8qHB6YeP+LPxQb2J6gM7PTTpPPaZLbVkg6lBr yaUY0jXteZn9/H3p38ORa55TUL7/J0DAX5sE/LoouaATX7aS1LxrSBOGKs4sCOe16V7s RK8bq5Zzy3wTPSiVZkISSN53xLV/7W/u6Em0FPNBu2ZQCHB7/jgaX728yDbrDNby9GF5 rcKg== X-Gm-Message-State: AOAM530ERwrH78iXen2vn/6PssUkIYclrxsH93ff3UcO09HGTQLKUuPp qeqht+yrm/9Is5bMGGKCn60sodwz+S34gA== X-Google-Smtp-Source: ABdhPJydv+lAOJdvjzc80FCXMzAsQnjZgaDpNJlleVqm7BNMfhuu1ZD0GXkUb8D3PJVRnvy/JGxrcQ== X-Received: by 2002:a63:4423:: with SMTP id r35mr2089732pga.358.1628742945985; Wed, 11 Aug 2021 21:35:45 -0700 (PDT) Received: from localhost ([122.172.201.85]) by smtp.gmail.com with ESMTPSA id z13sm8264118pjd.44.2021.08.11.21.35.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 21:35:45 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Vincent Donnefort , lukasz.luba@arm.com, Quentin Perret , Andy Gross , Bjorn Andersson , Cristian Marussi , Fabio Estevam , Kevin Hilman , Matthias Brugger , NXP Linux Team , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Sudeep Holla , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-omap@vger.kernel.org Subject: [PATCH V3 0/9] Add callback to register with energy model Date: Thu, 12 Aug 2021 10:05:13 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210811_213548_278182_192E802B X-CRM114-Status: GOOD ( 13.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Many cpufreq drivers register with the energy model for each policy and do exactly the same thing. Follow the footsteps of thermal-cooling, to get it done from the cpufreq core itself. Provide a new callback, which will be called, if present, by the cpufreq core at the right moment (more on that in the code's comment). Also provide a generic implementation that uses dev_pm_opp_of_register_em(). This also allows us to register with the EM at a later point of time, compared to ->init(), from where the EM core can access cpufreq policy directly using cpufreq_cpu_get() type of helpers and perform other work, like marking few frequencies inefficient, this will be done separately. This is build/boot tested by the bot for a couple of boards. https://gitlab.com/vireshk/pmko/-/pipelines/351965580 FWIW, I have queued up the series for linux-next to get more testing, but your reviews are welcome. Thanks. V2->V3: - Drop the auto-register part from all logs, this isn't called auto registration anymore. - Call register_em() only for new policies. - Update scmi driver to register with EM only when required. - Add Rby tags. V1->V2: - Add a callback instead of flag. - Register before governor is initialized. - Update scmi driver as well. - Don't unregister from the EM core. Reviewed-by: Dietmar Eggemann --- Viresh Viresh Kumar (9): cpufreq: Add callback to register with energy model cpufreq: dt: Use .register_em() to register with energy model cpufreq: imx6q: Use .register_em() to register with energy model cpufreq: mediatek: Use .register_em() to register with energy model cpufreq: omap: Use .register_em() to register with energy model cpufreq: qcom-cpufreq-hw: Use .register_em() to register with energy model cpufreq: scpi: Use .register_em() to register with energy model cpufreq: vexpress: Use .register_em() to register with energy model cpufreq: scmi: Use .register_em() to register with energy model drivers/cpufreq/cpufreq-dt.c | 3 +- drivers/cpufreq/cpufreq.c | 13 ++++++ drivers/cpufreq/imx6q-cpufreq.c | 2 +- drivers/cpufreq/mediatek-cpufreq.c | 3 +- drivers/cpufreq/omap-cpufreq.c | 2 +- drivers/cpufreq/qcom-cpufreq-hw.c | 3 +- drivers/cpufreq/scmi-cpufreq.c | 65 +++++++++++++++++--------- drivers/cpufreq/scpi-cpufreq.c | 3 +- drivers/cpufreq/vexpress-spc-cpufreq.c | 3 +- include/linux/cpufreq.h | 14 ++++++ 10 files changed, 76 insertions(+), 35 deletions(-)