* [soc:broadcom/drivers 2/4] drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:45: sparse: sparse: cast to restricted __le32
@ 2021-02-10 21:48 kernel test robot
2021-02-11 6:44 ` Rafał Miłecki
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2021-02-10 21:48 UTC (permalink / raw)
To: Rafał Miłecki
Cc: Florian Fainelli, arm, kbuild-all, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 3039 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git broadcom/drivers
head: 8b8f095b9076ca61107c0910c9273afd1dfa1f04
commit: 8bcac4011ebe0dbdd46fd55b036ee855c95702d3 [2/4] soc: bcm: add PM driver for Broadcom's PMB
config: i386-randconfig-s002-20210211 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-215-g0fb77bb6-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git/commit/?id=8bcac4011ebe0dbdd46fd55b036ee855c95702d3
git remote add soc https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git
git fetch --no-tags soc broadcom/drivers
git checkout 8bcac4011ebe0dbdd46fd55b036ee855c95702d3
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
"sparse warnings: (new ones prefixed by >>)"
drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
>> drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:45: sparse: sparse: cast to restricted __le32
>> drivers/soc/bcm/bcm63xx/bcm-pmb.c:115:36: sparse: sparse: restricted __le32 degrades to integer
drivers/soc/bcm/bcm63xx/bcm-pmb.c:115:55: sparse: sparse: restricted __be32 degrades to integer
vim +103 drivers/soc/bcm/bcm63xx/bcm-pmb.c
90
91 static int bcm_pmb_bpcm_read(struct bcm_pmb *pmb, int bus, u8 device,
92 int offset, u32 *val)
93 {
94 void __iomem *base = pmb->base + bus * 0x20;
95 unsigned long flags;
96 int err;
97
98 spin_lock_irqsave(&pmb->lock, flags);
99 err = bpcm_rd(base, device, offset, val);
100 spin_unlock_irqrestore(&pmb->lock, flags);
101
102 if (!err)
> 103 *val = pmb->little_endian ? le32_to_cpu(*val) : be32_to_cpu(*val);
104
105 return err;
106 }
107
108 static int bcm_pmb_bpcm_write(struct bcm_pmb *pmb, int bus, u8 device,
109 int offset, u32 val)
110 {
111 void __iomem *base = pmb->base + bus * 0x20;
112 unsigned long flags;
113 int err;
114
> 115 val = pmb->little_endian ? cpu_to_le32(val) : cpu_to_be32(val);
116
117 spin_lock_irqsave(&pmb->lock, flags);
118 err = bpcm_wr(base, device, offset, val);
119 spin_unlock_irqrestore(&pmb->lock, flags);
120
121 return err;
122 }
123
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 52791 bytes --]
[-- Attachment #3: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [soc:broadcom/drivers 2/4] drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:45: sparse: sparse: cast to restricted __le32
2021-02-10 21:48 [soc:broadcom/drivers 2/4] drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:45: sparse: sparse: cast to restricted __le32 kernel test robot
@ 2021-02-11 6:44 ` Rafał Miłecki
2021-02-11 11:05 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Rafał Miłecki @ 2021-02-11 6:44 UTC (permalink / raw)
To: kernel test robot; +Cc: Florian Fainelli, arm, kbuild-all, linux-arm-kernel
On 10.02.2021 22:48, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git broadcom/drivers
> head: 8b8f095b9076ca61107c0910c9273afd1dfa1f04
> commit: 8bcac4011ebe0dbdd46fd55b036ee855c95702d3 [2/4] soc: bcm: add PM driver for Broadcom's PMB
> config: i386-randconfig-s002-20210211 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> reproduce:
> # apt-get install sparse
> # sparse version: v0.6.3-215-g0fb77bb6-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git/commit/?id=8bcac4011ebe0dbdd46fd55b036ee855c95702d3
> git remote add soc https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git
> git fetch --no-tags soc broadcom/drivers
> git checkout 8bcac4011ebe0dbdd46fd55b036ee855c95702d3
> # save the attached .config to linux build tree
> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> "sparse warnings: (new ones prefixed by >>)"
> drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
> drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
> drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
> drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
> drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
> drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:65: sparse: sparse: cast to restricted __be32
>>> drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:45: sparse: sparse: cast to restricted __le32
>>> drivers/soc/bcm/bcm63xx/bcm-pmb.c:115:36: sparse: sparse: restricted __le32 degrades to integer
> drivers/soc/bcm/bcm63xx/bcm-pmb.c:115:55: sparse: sparse: restricted __be32 degrades to integer
>
> vim +103 drivers/soc/bcm/bcm63xx/bcm-pmb.c
>
> 90
> 91 static int bcm_pmb_bpcm_read(struct bcm_pmb *pmb, int bus, u8 device,
> 92 int offset, u32 *val)
> 93 {
> 94 void __iomem *base = pmb->base + bus * 0x20;
> 95 unsigned long flags;
> 96 int err;
> 97
> 98 spin_lock_irqsave(&pmb->lock, flags);
> 99 err = bpcm_rd(base, device, offset, val);
> 100 spin_unlock_irqrestore(&pmb->lock, flags);
> 101
> 102 if (!err)
> > 103 *val = pmb->little_endian ? le32_to_cpu(*val) : be32_to_cpu(*val);
> 104
> 105 return err;
> 106 }
> 107
> 108 static int bcm_pmb_bpcm_write(struct bcm_pmb *pmb, int bus, u8 device,
> 109 int offset, u32 val)
> 110 {
> 111 void __iomem *base = pmb->base + bus * 0x20;
> 112 unsigned long flags;
> 113 int err;
> 114
> > 115 val = pmb->little_endian ? cpu_to_le32(val) : cpu_to_be32(val);
> 116
> 117 spin_lock_irqsave(&pmb->lock, flags);
> 118 err = bpcm_wr(base, device, offset, val);
> 119 spin_unlock_irqrestore(&pmb->lock, flags);
> 120
> 121 return err;
> 122 }
> 123
Florian: can you review above code & verify my logic is correct there?
That I need to use le32_to_cpu() / be32_to_cpu() on the readl() value?
Assuming my logic is correct, above code doesn't use __le32 / __be32 as
that would require extra variables and code paths. Current code is quite
simple & clear.
Is there any way of avoiding those sparse warnings?
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [soc:broadcom/drivers 2/4] drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:45: sparse: sparse: cast to restricted __le32
2021-02-11 6:44 ` Rafał Miłecki
@ 2021-02-11 11:05 ` Arnd Bergmann
0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2021-02-11 11:05 UTC (permalink / raw)
To: Rafał Miłecki
Cc: Florian Fainelli, kbuild-all, kernel test robot, Linux ARM, arm-soc
On Thu, Feb 11, 2021 at 7:44 AM Rafał Miłecki <rafal@milecki.pl> wrote:
> On 10.02.2021 22:48, kernel test robot wrote:
>
> Florian: can you review above code & verify my logic is correct there?
> That I need to use le32_to_cpu() / be32_to_cpu() on the readl() value?
I'm fairly sure the logic is incorrect.
> Assuming my logic is correct, above code doesn't use __le32 / __be32 as
> that would require extra variables and code paths. Current code is quite
> simple & clear.
The problem is that readl() assumes that a register is little-endian in
hardware, and it performs a byteswap when running on a big-endian
machine (on most architectures).
The usual way to encode this is to use
if (device->big_endian)
return ioread32be(device->reg + offset);
else
return ioread32(device->reg + offset);
You can treat ioread32() as an alias for readl() in practice, while
ioread32be() produces the byte-reversed result of that.
If you however also need to run this on big-endian mips, you
might need to wrap this in another #ifdef that accounts for
the different behavior on that architecture, where readl()
sometimes sometimes assumes the register is cpu-endian
rather than little-endian.
Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-11 11:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 21:48 [soc:broadcom/drivers 2/4] drivers/soc/bcm/bcm63xx/bcm-pmb.c:103:45: sparse: sparse: cast to restricted __le32 kernel test robot
2021-02-11 6:44 ` Rafał Miłecki
2021-02-11 11:05 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).