Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3392015pxt; Tue, 10 Aug 2021 02:30:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp0W1FkllzHc+U3gkg7IGL59YH4IdVvL0BYrzIXUjlXb0/fFZmIie24U5RasU4t8irr+lr X-Received: by 2002:a05:6402:2709:: with SMTP id y9mr533630edd.149.1628587815919; Tue, 10 Aug 2021 02:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628587815; cv=none; d=google.com; s=arc-20160816; b=e/7N3FeMs26yKSCr3iuhIQ3Q2E5VIpsUY/IvYx6w8zxGsZYmMhshLg8PqoHsv/v+R9 m2SK93hp8hjEu4IvNCUqxEVlkB6/K9319twvATudi5kguKCyqcq3W1vrDqP/nyrZbwOb p5vlsnJYboB1cGbxgIsVbSe4b05sMMAoJHeOZvyGj7NdUZP0Sx31vTral2XUyU+eyQdx eRXy5irZn99K9bV+Fa4g+Z2UizQ+KgPOqo5BJ99wPJbDc8SS70gdnpFO8jE+jkogwk9T 8WpDql2p+c1x0QFmh+HNaA1yPWKpOhxMNdb1lcY4eLVyeKy4A6exLU+/WIDw4V3DjTBL pGJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aZMnI+ITVBnBcneBIgvhNm4piucoB9ecl6DZQEqepNc=; b=vI07oi3llhxuDyD1R43Q6KRMfFLz5d5ABBcY0wsiHriwjP43xUb3NEjxuxv4J9EKvq t2Rahl/F8O3DKjkTpwDwD5paC5J+zkWW7OE0xWGnbk9b6o84P4fdrZO1TOVSp2HCgf1/ 9csjDH2k/kYX4fdVNb/1j5KYuDK7E/JIGWps4MdQH0pRhX12A1f2HtK11pUr27H30o/6 EMrPX9Qvdb7r9bVIkFYn4FjFaGMZW9o0BT9ifxfd6N1O1svWi9o8ph2O6u8UviswRIlO JQi9O+/Snr0DTAYuQir2VxRuogOYDAuwv3T/gO7HKJQRKtb5epMamjM34/f6NEBWrZVm 2EmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ussZDGKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n26si9337720edr.521.2021.08.10.02.29.49; Tue, 10 Aug 2021 02:30:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ussZDGKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235014AbhHJHh3 (ORCPT + 99 others); Tue, 10 Aug 2021 03:37:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234958AbhHJHh2 (ORCPT ); Tue, 10 Aug 2021 03:37:28 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66F7EC0613D3 for ; Tue, 10 Aug 2021 00:37:07 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id fa24-20020a17090af0d8b0290178bfa69d97so4133530pjb.0 for ; Tue, 10 Aug 2021 00:37:07 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=aZMnI+ITVBnBcneBIgvhNm4piucoB9ecl6DZQEqepNc=; b=ussZDGKOXX/2mkZH5nS13YeUAqSCGfAjQ1/Hs72syBDUyUK1jzDkKS8xsyVvLvyjE9 CIZjQNxPnkyuvb0DAV/4sxnkxL2IjezejN73dFjQ5l/W9fRT07jA2hTRbRGMlOyIMDJQ mLkaA21gaqA1IwLRHBAdu2MTsLg3uAOz2CRAbPc93WzsMjUc29tQKIDD8XvpNSo+s8zn njTVprhkFudNvMEhJskzmhUVJ/r9IkbGRzxKGwICtyK4pDZJetllqkLA6BhaAb+MC3fb VnNOojFgtp/C+bHo0FYwxoTnqF8lvywlatxLoFMZXm5vTs9xLaSAGiOl05ml64ADSrGj TAFQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=aZMnI+ITVBnBcneBIgvhNm4piucoB9ecl6DZQEqepNc=; b=TJS5gR8jnyeRpg324MG8f9WW9oZ5i0VqLhWC3BYpnhlxTvHTRYqq35+yEZmT+vhq/V 6zmO/b0fU+gkdBCf334DDfdX0lpF8vl7sO24S2DdcDIz2KrqyXaPoBFD/cSyHy00G7J3 r2eunPmc6KuipeElzvzRUvO0NmTQtWZ4yAuQ9YfC/eE/bm4vBJAaxCThneQLlCNzBpuy J5xwOPbZcgwmW/wRJodZlkxm4PANSoP2tAvDJouvh0gG+GR8ftjJ6fSR2HPzx5kFZueh 0Aed/llBAN2XyXvqirH8tsLkTmKv2A/Q3pI1sZG7funu7gi3o45TSkDV2C8YQl46g7uy 892Q== X-Gm-Message-State: AOAM531aIalGGB9xLUqTOA9nybXeIbJ6NfEOksz/DsXLamxIpHMldM+W QYFYNUk39N7XpiKqN7fRITs4vg== X-Received: by 2002:a17:902:70c6:b029:12c:c0f3:605c with SMTP id l6-20020a17090270c6b029012cc0f3605cmr23934208plt.70.1628581026997; Tue, 10 Aug 2021 00:37:06 -0700 (PDT) Received: from localhost ([122.172.201.85]) by smtp.gmail.com with ESMTPSA id a185sm5054759pfa.205.2021.08.10.00.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 00:37:06 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Vincent Donnefort , lukasz.luba@arm.com, Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 1/8] cpufreq: Auto-register with energy model if asked Date: Tue, 10 Aug 2021 13:06:48 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 cpufreq driver flag so drivers can ask the cpufreq core to register with the EM core on their behalf. This allows us to get rid of duplicated code in the drivers. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 9 +++++++++ include/linux/cpufreq.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 06c526d66dd3..a060dc2aa2f2 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1511,6 +1512,11 @@ static int cpufreq_online(unsigned int cpu) if (cpufreq_thermal_control_enabled(cpufreq_driver)) policy->cdev = of_cpufreq_cooling_register(policy); + if (cpufreq_driver->flags & CPUFREQ_REGISTER_WITH_EM) { + dev_pm_opp_of_register_em(get_cpu_device(policy->cpu), + policy->related_cpus); + } + pr_debug("initialization complete\n"); return 0; @@ -1602,6 +1608,9 @@ static int cpufreq_offline(unsigned int cpu) goto unlock; } + if (cpufreq_driver->flags & CPUFREQ_REGISTER_WITH_EM) + dev_pm_opp_of_unregister_em(get_cpu_device(cpu)); + if (cpufreq_thermal_control_enabled(cpufreq_driver)) { cpufreq_cooling_unregister(policy->cdev); policy->cdev = NULL; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 9fd719475fcd..f11723cd4cca 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -424,6 +424,12 @@ struct cpufreq_driver { */ #define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING BIT(6) +/* + * Set by drivers that want the core to automatically register the CPU device + * with Energy Model. + */ +#define CPUFREQ_REGISTER_WITH_EM BIT(7) + int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); -- 2.31.1.272.g89b43f80a514