[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200723100136.GB30472@kozik-lap>
Date: Thu, 23 Jul 2020 12:01:36 +0200
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Olof Johansson <olof@...om.net>, arm-soc <arm@...nel.org>,
SoC Team <soc@...nel.org>, Markus Mayer <mmayer@...adcom.com>,
bcm-kernel-feedback-list <bcm-kernel-feedback-list@...adcom.com>,
Florian Fainelli <f.fainelli@...il.com>,
Santosh Shilimkar <ssantosh@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Roger Quadros <rogerq@...com>,
Tony Lindgren <tony@...mide.com>,
Vladimir Zapolskiy <vz@...ia.com>,
Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
"moderated list:ARM/Mediatek SoC..."
<linux-mediatek@...ts.infradead.org>,
linux-omap <linux-omap@...r.kernel.org>,
"open list:TEGRA ARCHITECTURE SUPPORT" <linux-tegra@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH 14/23] memory: ti-emif-pm: Fix cast to iomem pointer
On Thu, Jul 23, 2020 at 11:14:02AM +0200, Arnd Bergmann wrote:
> On Thu, Jul 23, 2020 at 11:02 AM Krzysztof Kozlowski <krzk@...nel.org> wrote:
> > On Thu, Jul 23, 2020 at 10:48:19AM +0200, Arnd Bergmann wrote:
> > > On Thu, Jul 23, 2020 at 9:39 AM Krzysztof Kozlowski <krzk@...nel.org> wrote:
> > > >
> > > > Cast pointer to iomem memory properly to fix sparse warning:
> > > >
> > > > drivers/memory/ti-emif-pm.c:251:38: warning: incorrect type in argument 1 (different address spaces)
> > > > drivers/memory/ti-emif-pm.c:251:38: expected void const volatile [noderef] __iomem *addr
> > > > drivers/memory/ti-emif-pm.c:251:38: got void *
> > > >
> > > > Signed-off-by: Krzysztof Kozlowski <krzk@...nel.org>
> > > > ---
> > > > drivers/memory/ti-emif-pm.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/memory/ti-emif-pm.c b/drivers/memory/ti-emif-pm.c
> > > > index 9c90f815ad3a..6c747c1e98cb 100644
> > > > --- a/drivers/memory/ti-emif-pm.c
> > > > +++ b/drivers/memory/ti-emif-pm.c
> > > > @@ -248,7 +248,7 @@ MODULE_DEVICE_TABLE(of, ti_emif_of_match);
> > > > static int ti_emif_resume(struct device *dev)
> > > > {
> > > > unsigned long tmp =
> > > > - __raw_readl((void *)emif_instance->ti_emif_sram_virt);
> > > > + __raw_readl((void __iomem *)emif_instance->ti_emif_sram_virt);
> > > >
> > >
> > > Maybe this shouldn't even be __raw_readl(), but instead READ_ONCE()?
> >
> > Won't readl() be enough? Indeed it looks problematic.
>
> readl() won't work on big-endian kernels, since this is a byte comparison.
Ah, right.
>
> > > The other accesses in this file don't use MMIO wrappers either but just treat
> > > it as a pointer. The effect would be the same though.
> >
> > I think all the reads and writes are with readl() and writel().
>
> I actually see only one other access:
>
> copy_addr = sram_exec_copy(emif_data->sram_pool_code,
> (void *)emif_data->ti_emif_sram_virt,
> &ti_emif_sram, ti_emif_sram_sz);
>
> and this one ends up in a memcpy() that does not perform any byte
> swapping or barriers.
At least the barrier would come through mutex in sram_exec_copy() and
later spin locks for page table manipulation.
Anyway, I do not have the HW to test the changes or to confirm whether
this is real issue. I guess the driver author/owner should follow up on
this report.
Best regards,
Krzysztof
Powered by blists - more mailing lists