Message ID | 20230704050238.712223-1-rui.zhang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp985794vqx; Mon, 3 Jul 2023 22:24:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlGCXUcbSact7Tc5DjD3mG99fSOgAUELN/KFZor6jPcNzdeC81P9ZceejDDGAammpQNhyJ6/ X-Received: by 2002:a17:902:bc88:b0:1b8:6987:de84 with SMTP id bb8-20020a170902bc8800b001b86987de84mr12413029plb.48.1688448286660; Mon, 03 Jul 2023 22:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688448286; cv=none; d=google.com; s=arc-20160816; b=u0AdGFi7jEbv5C/cfzIs78Xf1dl8ekr7eRdUNy9YS9+8DfEBHbRUzZJIzEKm6lW8W5 qWEsBC1KqH7xynXLqF6eW549Kq3Zz/KTS0M1fHRXGebhSHPkWZ5ILSNtehvw1sxaox4X swVjTtYo3vyBNuV3d0rFzOSp6j0jBbc4CM8h0ohrmnln583SI8Yy0v1wnOX7svaBLhZO iaPe5WM6sd8OstveHRB+D4s10XqcNls7UxCc8uFSQ8SX48qi5PIMEGIltqjiPjebfSxU C/vBvcF7ArU0lxr0J4n21FjwBRzy7DGWb2x3EZs/2ZZp4ssymdcXWZqEuuFc04cEzXE/ ktQQ== 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=kzLgYQIzBuxVu+Pc+kleOPkKoKBxaiSCvG8GJfxKWEY=; fh=pO+oSCh8w6gLu5HjA7rsNYia3UXwKZVErH1GkJviL/Q=; b=K54NRGMIWYSW98leqhCLv6DiwMz7xI1GGZ2j3LRImckd+slvE2w61kOggrOz0Sgn19 2hGOwdpptraFnwqAku5KEJFUyEPGbp8MNkwAboRjTmlxps83ofm1PQ41yiayjWvnSEeq VX1UvJ2MazbtT/sQQ0mkOVISIkx5BtXd5whNovyVOk88fNmJlGo56MOKNiu+OckF5/vp 0/heWoV7YnA0+n29ZkOXbjSz5oX5jXX+UGyyW9rr18lp42jFH6Lbg4YvRU8u0y4vRwPo Oqje9KzPjI841rBFxlrpglU38T5aIAQa2cFEhE5API1KBusNyX4SqIZPaSldbm9BoCtE 06wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iwTFMLng; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i15-20020a170902c94f00b001b87d0de22esi7948931pla.593.2023.07.03.22.24.31; Mon, 03 Jul 2023 22:24:46 -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=@intel.com header.s=Intel header.b=iwTFMLng; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230114AbjGDFCz (ORCPT <rfc822;gnulinuxfreebsd@gmail.com> + 99 others); Tue, 4 Jul 2023 01:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjGDFCx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 4 Jul 2023 01:02:53 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CE851B0; Mon, 3 Jul 2023 22:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688446972; x=1719982972; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=MvQSWM3JXLJmmP7PlmgAPhDJ4YePLKBMLemgFv7W6HA=; b=iwTFMLngiIm6yBaVEIrKIn7RkbgBilVmXG7KFDC3XQ1q1wWi/eTnoEwT u8RHsrpM2zcZwooHEShO+n0hTqcg+BL44qdtnzc64/s37YsZH2kO10rvF b1/NErtRg36Na3X/Fcn7aaFfyoSVY+GVhr4WmkjYHWZe7u1jUWnt2R1nE 5GzO+Zpw9XoON/EMe2dlD8w/uaeRP2CSPPX6G2vsYLE3oSuLc9KYgnE5g 0bSnXfo6odr5r4/ssJ+6RMZFLAODrZaNG55SWh6svuLPpkqvyzcXIvgrV VHR6gtf+Vn0dIc2ZQOkrivN5H/28b1LXG+x+VLq0GFuUlAQnNSaoAcdkc A==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="360512747" X-IronPort-AV: E=Sophos;i="6.01,179,1684825200"; d="scan'208";a="360512747" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 22:02:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="832032966" X-IronPort-AV: E=Sophos;i="6.01,179,1684825200"; d="scan'208";a="832032966" Received: from rzhang1-mobl7.sh.intel.com ([10.238.6.118]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 22:02:50 -0700 From: Zhang Rui <rui.zhang@intel.com> To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com Cc: daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org, lkp@intel.com Subject: [PATCH] powercap: intel_rapl_tpmi: Fix a sparse warning Date: Tue, 4 Jul 2023 13:02:38 +0800 Message-Id: <20230704050238.712223-1-rui.zhang@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 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_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1770466350393593876?= X-GMAIL-MSGID: =?utf-8?q?1770466350393593876?= |
Series |
powercap: intel_rapl_tpmi: Fix a sparse warning
|
|
Commit Message
Zhang, Rui
July 4, 2023, 5:02 a.m. UTC
Fix a sparse warning in intel_rapl_tpmi driver.
../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: warning: incorrect type in initializer (different address spaces)
../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: expected unsigned long long [usertype] *tpmi_rapl_regs
../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: got void [noderef] __iomem *
Fixes: 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI interface driver")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202307031405.dy3druuy-lkp@intel.com/
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/powercap/intel_rapl_tpmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Jul 4, 2023 at 7:02 AM Zhang Rui <rui.zhang@intel.com> wrote: > > Fix a sparse warning in intel_rapl_tpmi driver. > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: warning: incorrect type in initializer (different address spaces) > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: expected unsigned long long [usertype] *tpmi_rapl_regs > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: got void [noderef] __iomem * > > Fixes: 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI interface driver") > Reported-by: kernel test robot <lkp@intel.com> > Closes: https://lore.kernel.org/oe-kbuild-all/202307031405.dy3druuy-lkp@intel.com/ > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > --- > drivers/powercap/intel_rapl_tpmi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/powercap/intel_rapl_tpmi.c b/drivers/powercap/intel_rapl_tpmi.c > index 4f4f13ded225..05f664a096ab 100644 > --- a/drivers/powercap/intel_rapl_tpmi.c > +++ b/drivers/powercap/intel_rapl_tpmi.c > @@ -138,7 +138,7 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset) > enum tpmi_rapl_register reg_index; > enum rapl_domain_reg_id reg_id; > int tpmi_domain_size, tpmi_domain_flags; > - u64 *tpmi_rapl_regs = trp->base + offset; > + u64 *tpmi_rapl_regs = (u64 *)(trp->base + offset); > u64 tpmi_domain_header = readq((void __iomem *)tpmi_rapl_regs); > > /* Domain Parent bits are ignored for now */ > -- Applied as 6.5-rc material, thanks!
From: Rafael J. Wysocki > Sent: 11 July 2023 19:14 ... > On Tue, Jul 4, 2023 at 7:02 AM Zhang Rui <rui.zhang@intel.com> wrote: > > > > Fix a sparse warning in intel_rapl_tpmi driver. > > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: warning: incorrect type in initializer > (different address spaces) > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: expected unsigned long long [usertype] > *tpmi_rapl_regs > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: got void [noderef] __iomem * > > > > Fixes: 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI interface driver") > > Reported-by: kernel test robot <lkp@intel.com> > > Closes: https://lore.kernel.org/oe-kbuild-all/202307031405.dy3druuy-lkp@intel.com/ > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > > --- > > drivers/powercap/intel_rapl_tpmi.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/powercap/intel_rapl_tpmi.c b/drivers/powercap/intel_rapl_tpmi.c > > index 4f4f13ded225..05f664a096ab 100644 > > --- a/drivers/powercap/intel_rapl_tpmi.c > > +++ b/drivers/powercap/intel_rapl_tpmi.c > > @@ -138,7 +138,7 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset) > > enum tpmi_rapl_register reg_index; > > enum rapl_domain_reg_id reg_id; > > int tpmi_domain_size, tpmi_domain_flags; > > - u64 *tpmi_rapl_regs = trp->base + offset; > > + u64 *tpmi_rapl_regs = (u64 *)(trp->base + offset); > > u64 tpmi_domain_header = readq((void __iomem *)tpmi_rapl_regs); Isn't the correct fix to add __iomem to the definition of tpmi_rapi_regs and also remove the cast from the following readq() line? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Fri, Jul 14, 2023 at 3:34 PM David Laight <David.Laight@aculab.com> wrote: > > From: Rafael J. Wysocki > > Sent: 11 July 2023 19:14 > ... > > On Tue, Jul 4, 2023 at 7:02 AM Zhang Rui <rui.zhang@intel.com> wrote: > > > > > > Fix a sparse warning in intel_rapl_tpmi driver. > > > > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: warning: incorrect type in initializer > > (different address spaces) > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: expected unsigned long long [usertype] > > *tpmi_rapl_regs > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: got void [noderef] __iomem * > > > > > > Fixes: 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI interface driver") > > > Reported-by: kernel test robot <lkp@intel.com> > > > Closes: https://lore.kernel.org/oe-kbuild-all/202307031405.dy3druuy-lkp@intel.com/ > > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > > > --- > > > drivers/powercap/intel_rapl_tpmi.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/powercap/intel_rapl_tpmi.c b/drivers/powercap/intel_rapl_tpmi.c > > > index 4f4f13ded225..05f664a096ab 100644 > > > --- a/drivers/powercap/intel_rapl_tpmi.c > > > +++ b/drivers/powercap/intel_rapl_tpmi.c > > > @@ -138,7 +138,7 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset) > > > enum tpmi_rapl_register reg_index; > > > enum rapl_domain_reg_id reg_id; > > > int tpmi_domain_size, tpmi_domain_flags; > > > - u64 *tpmi_rapl_regs = trp->base + offset; > > > + u64 *tpmi_rapl_regs = (u64 *)(trp->base + offset); > > > u64 tpmi_domain_header = readq((void __iomem *)tpmi_rapl_regs); > > Isn't the correct fix to add __iomem to the definition of > tpmi_rapi_regs and also remove the cast from the following > readq() line? Good point. Rui, can you take another look at this, please?
Hi, David, Thanks for pointing this out, after digging into the problem further, I'm confused about how to address all the sparse warnings. In the RAPL framework, u64 regs[RAPL_DOMAIN_MAX][RAPL_DOMAIN_REG_MAX] is used to save the RAPL register addresses, because the register can either be a MMIO register or MSR. With sparse enabled, this becomes a problem for MMIO registers because we will get a warning anyway when saving an __iomem address to u64 regs[][], right? This problem is not new. The same warning is also there when compiling drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c, which also uses MMIO RAPL register. Any idea how to fix this? thanks, rui On Fri, 2023-07-14 at 16:39 +0200, Rafael J. Wysocki wrote: > On Fri, Jul 14, 2023 at 3:34 PM David Laight > <David.Laight@aculab.com> wrote: > > > > From: Rafael J. Wysocki > > > Sent: 11 July 2023 19:14 > > ... > > > On Tue, Jul 4, 2023 at 7:02 AM Zhang Rui <rui.zhang@intel.com> > > > wrote: > > > > > > > > Fix a sparse warning in intel_rapl_tpmi driver. > > > > > > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: warning: > > > > incorrect type in initializer > > > (different address spaces) > > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: > > > > expected unsigned long long [usertype] > > > *tpmi_rapl_regs > > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: got > > > > void [noderef] __iomem * > > > > > > > > Fixes: 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI > > > > interface driver") > > > > Reported-by: kernel test robot <lkp@intel.com> > > > > Closes: > > > > https://lore.kernel.org/oe-kbuild-all/202307031405.dy3druuy-lkp@intel.com/ > > > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > > > > --- > > > > drivers/powercap/intel_rapl_tpmi.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/powercap/intel_rapl_tpmi.c > > > > b/drivers/powercap/intel_rapl_tpmi.c > > > > index 4f4f13ded225..05f664a096ab 100644 > > > > --- a/drivers/powercap/intel_rapl_tpmi.c > > > > +++ b/drivers/powercap/intel_rapl_tpmi.c > > > > @@ -138,7 +138,7 @@ static int parse_one_domain(struct > > > > tpmi_rapl_package *trp, u32 offset) > > > > enum tpmi_rapl_register reg_index; > > > > enum rapl_domain_reg_id reg_id; > > > > int tpmi_domain_size, tpmi_domain_flags; > > > > - u64 *tpmi_rapl_regs = trp->base + offset; > > > > + u64 *tpmi_rapl_regs = (u64 *)(trp->base + offset); > > > > u64 tpmi_domain_header = readq((void __iomem > > > > *)tpmi_rapl_regs); > > > > Isn't the correct fix to add __iomem to the definition of > > tpmi_rapi_regs and also remove the cast from the following > > readq() line? > > Good point. > > Rui, can you take another look at this, please?
From: Zhang, Rui > Sent: 17 July 2023 10:13 > > Hi, David, > > Thanks for pointing this out, after digging into the problem further, > I'm confused about how to address all the sparse warnings. > > In the RAPL framework, u64 regs[RAPL_DOMAIN_MAX][RAPL_DOMAIN_REG_MAX] > is used to save the RAPL register addresses, because the register can > either be a MMIO register or MSR. > > With sparse enabled, this becomes a problem for MMIO registers because > we will get a warning anyway when saving an __iomem address to u64 > regs[][], right? To avoid those issues (which seem different from the one here) you could use a union of the __iomem address and the MSR number. That ought to let you remove all the __iomem casts. David > > This problem is not new. The same warning is also there when compiling > drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c, which > also uses MMIO RAPL register. > > Any idea how to fix this? > > thanks, > rui > > On Fri, 2023-07-14 at 16:39 +0200, Rafael J. Wysocki wrote: > > On Fri, Jul 14, 2023 at 3:34 PM David Laight > > <David.Laight@aculab.com> wrote: > > > > > > From: Rafael J. Wysocki > > > > Sent: 11 July 2023 19:14 > > > ... > > > > On Tue, Jul 4, 2023 at 7:02 AM Zhang Rui <rui.zhang@intel.com> > > > > wrote: > > > > > > > > > > Fix a sparse warning in intel_rapl_tpmi driver. > > > > > > > > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: warning: > > > > > incorrect type in initializer > > > > (different address spaces) > > > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: > > > > > expected unsigned long long [usertype] > > > > *tpmi_rapl_regs > > > > > ../drivers/powercap/intel_rapl_tpmi.c:141:41: sparse: got > > > > > void [noderef] __iomem * > > > > > > > > > > Fixes: 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI > > > > > interface driver") > > > > > Reported-by: kernel test robot <lkp@intel.com> > > > > > Closes: > > > > > https://lore.kernel.org/oe-kbuild-all/202307031405.dy3druuy-lkp@intel.com/ > > > > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > > > > > --- > > > > > drivers/powercap/intel_rapl_tpmi.c | 2 +- > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/powercap/intel_rapl_tpmi.c > > > > > b/drivers/powercap/intel_rapl_tpmi.c > > > > > index 4f4f13ded225..05f664a096ab 100644 > > > > > --- a/drivers/powercap/intel_rapl_tpmi.c > > > > > +++ b/drivers/powercap/intel_rapl_tpmi.c > > > > > @@ -138,7 +138,7 @@ static int parse_one_domain(struct > > > > > tpmi_rapl_package *trp, u32 offset) > > > > > enum tpmi_rapl_register reg_index; > > > > > enum rapl_domain_reg_id reg_id; > > > > > int tpmi_domain_size, tpmi_domain_flags; > > > > > - u64 *tpmi_rapl_regs = trp->base + offset; > > > > > + u64 *tpmi_rapl_regs = (u64 *)(trp->base + offset); > > > > > u64 tpmi_domain_header = readq((void __iomem > > > > > *)tpmi_rapl_regs); > > > > > > Isn't the correct fix to add __iomem to the definition of > > > tpmi_rapi_regs and also remove the cast from the following > > > readq() line? > > > > Good point. > > > > Rui, can you take another look at this, please? - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/drivers/powercap/intel_rapl_tpmi.c b/drivers/powercap/intel_rapl_tpmi.c index 4f4f13ded225..05f664a096ab 100644 --- a/drivers/powercap/intel_rapl_tpmi.c +++ b/drivers/powercap/intel_rapl_tpmi.c @@ -138,7 +138,7 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset) enum tpmi_rapl_register reg_index; enum rapl_domain_reg_id reg_id; int tpmi_domain_size, tpmi_domain_flags; - u64 *tpmi_rapl_regs = trp->base + offset; + u64 *tpmi_rapl_regs = (u64 *)(trp->base + offset); u64 tpmi_domain_header = readq((void __iomem *)tpmi_rapl_regs); /* Domain Parent bits are ignored for now */