Message ID | 20230601213246.3271412-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp630696vqr; Thu, 1 Jun 2023 14:45:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BXOhPDnpYkFaugdWJs0f6irr0H4qjUp2p6k49BiT6slAp7VBbLnf/Rfb21uRuZYvyVOtJ X-Received: by 2002:a17:902:e744:b0:1af:a349:3f0d with SMTP id p4-20020a170902e74400b001afa3493f0dmr675968plf.23.1685655925813; Thu, 01 Jun 2023 14:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685655925; cv=none; d=google.com; s=arc-20160816; b=Ge3kWTxr1cK80vGjpf46wxvD17MiXRmFgniXmbHs+0g0LjDaYYoCOAiCBtZ6ut/l+o 0vin4OZt0pmdT/2tdxVkR4gWifHn5+ndichBkjoCBoZIdAUczz4IT955DmKqkLHJ2js7 U9qqXzx5vz2zNQWhncPUwma4WhoLnEwsVbVVnIpfvbvnrLocTNjlThmeC8HnCdWwgil7 6lJAPVnwJnTCccsvyiwnzElzcoIE+U2Qk7XQd0jzgtJkgK+Qxp5/+Jbhkmep+do8lk84 d3l1en1r3GS2Q6ai9W+dCh93NE/GUTHpjMCmkIP6b0h/4powFAL4Oaul07J5DMh8u1WF WB9w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=IUlNAHdeUEPxzXeRfoiIAhRyJGN3WCZJNbFnzu56qME=; b=MC8O9A48BLOWztYF+21SJDTCy+QNJj/lBE36EkLYINkyJEDFAS+8NCGWPUBDb1LJHZ B9zCngKhS//x5BL7SfZlR9rsJha2O+5O2OayfKW+c1DGIZUNo27bZJUtOofMQK2wW6mA zhWRH3NY2U7f+OvsQGqnLc9/oGhMbP4K1zankClz4+KHDaN/faeaFoptRl8aOlctqvsV k3HICe4KlqcPuxugZPuPTqOaXq6CHpcIxD8OWrdAc6sc7LU5swe+QXgxGwHVFnsxc7OR d3NaRYLc1kkhGzglnMDc3KS5pzp0istj7T9A845k4/FT3lv7mDXDMM9ZJi+ugS/BEUXG OREA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qt2KlGyj; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jb18-20020a170903259200b001b02ce8470dsi3142817plb.543.2023.06.01.14.45.08; Thu, 01 Jun 2023 14:45: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=@kernel.org header.s=k20201202 header.b=Qt2KlGyj; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbjFAVcz (ORCPT <rfc822;limurcpp@gmail.com> + 99 others); Thu, 1 Jun 2023 17:32:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbjFAVcy (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 1 Jun 2023 17:32:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB6F6184; Thu, 1 Jun 2023 14:32:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5F45164A01; Thu, 1 Jun 2023 21:32:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4923C433EF; Thu, 1 Jun 2023 21:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685655171; bh=g2rzy9p5nDkRT5WQ+jqTex7ivDzoyB3d1o/6rkyQ008=; h=From:To:Cc:Subject:Date:From; b=Qt2KlGyjZVky0lAKv82opTBW9mUDkM0Vd5xFaNjCWso1aWryPa/Nb4exeTSfkSDTH GW1Jw1c0j3TeKqjmlsh5ccslCVjDMlnzCLX2YBzVnoUIrD3+viiRt7LloUH63oM/+/ 18jNbCe4745xU19oWfP0BkDw5RXimB4jgzkd6ZMCBVPRhzRkvK9Gi+rIdUIxutt8iZ CvncHntkYE6bnLHhCULprPYzhr46zG/GQxwDU80HRnFS7ckLmzC4p2Kr5qMj4fwwtO LZ0VUlvFlDY9sacDCiCIvMJtqjyF/pCYOCsbnF8wzC0ahpWlktBeRX7mTgWfJxdaDE fsxzgrF0KAnLQ== From: Arnd Bergmann <arnd@kernel.org> To: "Rafael J. Wysocki" <rafael@kernel.org>, Zhang Rui <rui.zhang@intel.com> Cc: Arnd Bergmann <arnd@arndb.de>, Lukasz Luba <lukasz.luba@arm.com>, Cristian Marussi <cristian.marussi@arm.com>, Sudeep Holla <sudeep.holla@arm.com>, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] powercap: intel_rapl: fix CONFIG_IOSF_MBI dependency Date: Thu, 1 Jun 2023 23:32:41 +0200 Message-Id: <20230601213246.3271412-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767538348172243487?= X-GMAIL-MSGID: =?utf-8?q?1767538348172243487?= |
Series |
powercap: intel_rapl: fix CONFIG_IOSF_MBI dependency
|
|
Commit Message
Arnd Bergmann
June 1, 2023, 9:32 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> When the intel_rapl driver is built-in, but iosf_mbi is a loadable module, the kernel fails to link: x86_64-linux-ld: vmlinux.o: in function `set_floor_freq_atom': intel_rapl_common.c:(.text+0x2dac9b8): undefined reference to `iosf_mbi_write' x86_64-linux-ld: intel_rapl_common.c:(.text+0x2daca66): undefined reference to `iosf_mbi_read' The driver can work with iosf_mbi completely disabled, so add a dependency that still allows this configuration, but otherwise forces it to not be built-in when iosf_mbi is a loadable module. Fixes: 9eef7f9da928c ("powercap: intel_rapl: Introduce RAPL TPMI interface driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/powercap/Kconfig | 1 + 1 file changed, 1 insertion(+)
Comments
Hi, Arnd, On Thu, 2023-06-01 at 23:32 +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > When the intel_rapl driver is built-in, but iosf_mbi is a loadable > module, > the kernel fails to link: > > x86_64-linux-ld: vmlinux.o: in function `set_floor_freq_atom': > intel_rapl_common.c:(.text+0x2dac9b8): undefined reference to > `iosf_mbi_write' > x86_64-linux-ld: intel_rapl_common.c:(.text+0x2daca66): undefined > reference to `iosf_mbi_read' > IMO, it is the intel_rapl_common.c that calls IOSF APIs without specifying the dependency. Thus it should be fixed by something like below, From 28de4c7d3d4f9fed75a7ecdcf5eea5b89ed77bab Mon Sep 17 00:00:00 2001 From: Zhang Rui <rui.zhang@intel.com> Date: Fri, 2 Jun 2023 09:02:15 +0800 Subject: [PATCH] powercap/intel_rapl: Fix CONFIG_IOSF_MBI dependency After commit 3382388d7148 ("intel_rapl: abstract RAPL common code"), accessing to IOSF interface is done in the RAPL common code. Thus it is the CONFIG_INTEL_RAPL_CORE that has dependency of CONFIG_IOSF_MBI, while CONFIG_INTEL_RAPL_MSR does not. This problem was not exposed previously because all the previous RAPL common code users, aka, the RAPL MSR and MMIO I/F drivers, have CONFIG_IOSF_MBI selected. Fix the CONFIG_IOSF_MBI dependency in RAPL code. This also fixes a build time failure when the RAPL TPMI I/F driver is introduced without selecting CONFIG_IOSF_MBI. x86_64-linux-ld: vmlinux.o: in function `set_floor_freq_atom': intel_rapl_common.c:(.text+0x2dac9b8): undefined reference to `iosf_mbi_write' x86_64-linux-ld: intel_rapl_common.c:(.text+0x2daca66): undefined reference to `iosf_mbi_read' Fixes: 3382388d7148 ("intel_rapl: abstract RAPL common code") Reported-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Zhang Rui <rui.zhang@intel.com> --- drivers/powercap/Kconfig | 3 ++- drivers/powercap/intel_rapl_msr.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/powercap/Kconfig b/drivers/powercap/Kconfig index e71399804c14..adefdd8a4e12 100644 --- a/drivers/powercap/Kconfig +++ b/drivers/powercap/Kconfig @@ -18,10 +18,11 @@ if POWERCAP # Client driver configurations go here. config INTEL_RAPL_CORE tristate + select IOSF_MBI config INTEL_RAPL tristate "Intel RAPL Support via MSR Interface" - depends on X86 && IOSF_MBI + depends on X86 select INTEL_RAPL_CORE help This enables support for the Intel Running Average Power Limit (RAPL) diff --git a/drivers/powercap/intel_rapl_msr.c b/drivers/powercap/intel_rapl_msr.c index cff5c6e8d570..b536144726f9 100644 --- a/drivers/powercap/intel_rapl_msr.c +++ b/drivers/powercap/intel_rapl_msr.c @@ -22,7 +22,6 @@ #include <linux/processor.h> #include <linux/platform_device.h> -#include <asm/iosf_mbi.h> #include <asm/cpu_device_id.h> #include <asm/intel-family.h> -- 2.25.1 > The driver can work with iosf_mbi completely disabled, so add a > dependency > that still allows this configuration, but otherwise forces it to not > be > built-in when iosf_mbi is a loadable module. On the other side, I agree with you that the TPMI driver should work with iosf_mbi completely disabled. A cleaner way to do this is to move the rapl_defaults setting (even the rapl_primitive_info setting) from intel_rapl_common.c to the I/F drivers, as this is really interface specific. Maybe we can use the above patch as a quick fix, and remove the IOSF_MBI dependency from RAPL common code as a long term solution? thanks, rui
On Fri, Jun 2, 2023, at 10:04, Zhang, Rui wrote: > On Thu, 2023-06-01 at 23:32 +0200, Arnd Bergmann wrote: >> From: Arnd Bergmann <arnd@arndb.de> >> >> When the intel_rapl driver is built-in, but iosf_mbi is a loadable >> module, >> the kernel fails to link: >> >> x86_64-linux-ld: vmlinux.o: in function `set_floor_freq_atom': >> intel_rapl_common.c:(.text+0x2dac9b8): undefined reference to >> `iosf_mbi_write' >> x86_64-linux-ld: intel_rapl_common.c:(.text+0x2daca66): undefined >> reference to `iosf_mbi_read' >> > > IMO, it is the intel_rapl_common.c that calls IOSF APIs without > specifying the dependency. Thus it should be fixed by something like > below, > > --- a/drivers/powercap/Kconfig > +++ b/drivers/powercap/Kconfig > @@ -18,10 +18,11 @@ if POWERCAP > # Client driver configurations go here. > config INTEL_RAPL_CORE > tristate > + select IOSF_MBI > > config INTEL_RAPL > tristate "Intel RAPL Support via MSR Interface" > - depends on X86 && IOSF_MBI > + depends on X86 > select INTEL_RAPL_CORE > help > This enables support for the Intel Running Average Power Limit I think that has the logic slightly backwards from a usability point of view: The way I read the arch/x86/Kconfig description, IOSF_MBI is a feature of specific Intel hardware implementations, which gets enabled when any of these SoC platforms are enabled in the build, and the INTEL_RAPL driver specifically only works on those, while the new INTEL_RAPL_TPMI driver works on other hardware. More generally speaking, I think it is a mistake for a device driver in one subsystem to use 'select' to enforce a build dependency on a driver in another subsystem when the other symbol is user-visible. >> The driver can work with iosf_mbi completely disabled, so add a >> dependency >> that still allows this configuration, but otherwise forces it to not >> be >> built-in when iosf_mbi is a loadable module. > > On the other side, I agree with you that the TPMI driver should work > with iosf_mbi completely disabled. > > A cleaner way to do this is to move the rapl_defaults setting (even the > rapl_primitive_info setting) from intel_rapl_common.c to the I/F > drivers, as this is really interface specific. > > Maybe we can use the above patch as a quick fix, and remove the > IOSF_MBI dependency from RAPL common code as a long term solution? I agree that your long-term solution is the best way to avoid the build dependency, but for the short-term fix I think my patch makes a little more sense than yours. Either approach is of course enough to address the build regression, so no objections to your patch if you still prefer that. Arnd
On Fri, Jun 2, 2023 at 11:11 AM Arnd Bergmann <arnd@arndb.de> wrote: > > On Fri, Jun 2, 2023, at 10:04, Zhang, Rui wrote: > > On Thu, 2023-06-01 at 23:32 +0200, Arnd Bergmann wrote: > >> From: Arnd Bergmann <arnd@arndb.de> > >> > >> When the intel_rapl driver is built-in, but iosf_mbi is a loadable > >> module, > >> the kernel fails to link: > >> > >> x86_64-linux-ld: vmlinux.o: in function `set_floor_freq_atom': > >> intel_rapl_common.c:(.text+0x2dac9b8): undefined reference to > >> `iosf_mbi_write' > >> x86_64-linux-ld: intel_rapl_common.c:(.text+0x2daca66): undefined > >> reference to `iosf_mbi_read' > >> > > > > IMO, it is the intel_rapl_common.c that calls IOSF APIs without > > specifying the dependency. Thus it should be fixed by something like > > below, > > > > --- a/drivers/powercap/Kconfig > > +++ b/drivers/powercap/Kconfig > > @@ -18,10 +18,11 @@ if POWERCAP > > # Client driver configurations go here. > > config INTEL_RAPL_CORE > > tristate > > + select IOSF_MBI > > > > config INTEL_RAPL > > tristate "Intel RAPL Support via MSR Interface" > > - depends on X86 && IOSF_MBI > > + depends on X86 > > select INTEL_RAPL_CORE > > help > > This enables support for the Intel Running Average Power Limit > > I think that has the logic slightly backwards from a usability point > of view: The way I read the arch/x86/Kconfig description, IOSF_MBI > is a feature of specific Intel hardware implementations, which > gets enabled when any of these SoC platforms are enabled in > the build, and the INTEL_RAPL driver specifically only works > on those, while the new INTEL_RAPL_TPMI driver works on other > hardware. > > More generally speaking, I think it is a mistake for a device > driver in one subsystem to use 'select' to enforce a build > dependency on a driver in another subsystem when the other > symbol is user-visible. IOSF_MBI is already selected from multiple places and while you can argue that they are all mistakes, this particular new one would not be worse than any of them. IMO it would be better if IOSF_MBI were not user-visible (and interestingly enough, whoever selects it should also select PCI or depend on it - I'm not really sure if that dependency is taken care of in all cases).
Hi, Rafael, On Fri, 2023-06-02 at 18:55 +0200, Rafael J. Wysocki wrote: > On Fri, Jun 2, 2023 at 11:11 AM Arnd Bergmann <arnd@arndb.de> wrote: > > > > On Fri, Jun 2, 2023, at 10:04, Zhang, Rui wrote: > > > On Thu, 2023-06-01 at 23:32 +0200, Arnd Bergmann wrote: > > > > From: Arnd Bergmann <arnd@arndb.de> > > > > > > > > When the intel_rapl driver is built-in, but iosf_mbi is a > > > > loadable > > > > module, > > > > the kernel fails to link: > > > > > > > > x86_64-linux-ld: vmlinux.o: in function `set_floor_freq_atom': > > > > intel_rapl_common.c:(.text+0x2dac9b8): undefined reference to > > > > `iosf_mbi_write' > > > > x86_64-linux-ld: intel_rapl_common.c:(.text+0x2daca66): > > > > undefined > > > > reference to `iosf_mbi_read' > > > > > > > > > > IMO, it is the intel_rapl_common.c that calls IOSF APIs without > > > specifying the dependency. Thus it should be fixed by something > > > like > > > below, > > > > > > --- a/drivers/powercap/Kconfig > > > +++ b/drivers/powercap/Kconfig > > > @@ -18,10 +18,11 @@ if POWERCAP > > > # Client driver configurations go here. > > > config INTEL_RAPL_CORE > > > tristate > > > + select IOSF_MBI > > > > > > config INTEL_RAPL > > > tristate "Intel RAPL Support via MSR Interface" > > > - depends on X86 && IOSF_MBI > > > + depends on X86 > > > select INTEL_RAPL_CORE > > > help > > > This enables support for the Intel Running Average Power > > > Limit > > > > I think that has the logic slightly backwards from a usability > > point > > of view: The way I read the arch/x86/Kconfig description, IOSF_MBI > > is a feature of specific Intel hardware implementations, which > > gets enabled when any of these SoC platforms are enabled in > > the build, and the INTEL_RAPL driver specifically only works > > on those, while the new INTEL_RAPL_TPMI driver works on other > > hardware. > > > > More generally speaking, I think it is a mistake for a device > > driver in one subsystem to use 'select' to enforce a build > > dependency on a driver in another subsystem when the other > > symbol is user-visible. > > IOSF_MBI is already selected from multiple places and while you can > argue that they are all mistakes, this particular new one would not > be > worse than any of them. > > IMO it would be better if IOSF_MBI were not user-visible (and > interestingly enough, whoever selects it should also select PCI or > depend on it - I'm not really sure if that dependency is taken care > of > in all cases). Agreed. Even the previous RAPL code does not select PCI or depend on it. Let me refresh the patch and resend. thanks, rui
diff --git a/drivers/powercap/Kconfig b/drivers/powercap/Kconfig index e71399804c143..21ad50b22d6b9 100644 --- a/drivers/powercap/Kconfig +++ b/drivers/powercap/Kconfig @@ -36,6 +36,7 @@ config INTEL_RAPL config INTEL_RAPL_TPMI tristate "Intel RAPL Support via TPMI Interface" depends on X86 + depends on IOSF_MBI || IOSF_MBI=n depends on INTEL_TPMI select INTEL_RAPL_CORE help