Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1335209

Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio

From khalasa@piap.pl (Krzysztof Hałasa)
Newsgroups linux.kernel
Subject Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio
Date 2016-02-16 10:30 +0100
Message-ID <r2K7g-5XK-3@gated-at.bofh.it> (permalink)
References <qVXsB-5Xs-5@gated-at.bofh.it> <r2nNn-7tb-1@gated-at.bofh.it> <r2rR1-1Jl-23@gated-at.bofh.it> <r2u2u-3n5-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Arnd Bergmann <arnd@arndb.de> writes:

> The barriers on a spinlock synchronize between CPUs but not an external
> bus, so (on some architectures) a spinlock protecting an MMIO register
> does not guarantee that two CPUs doing
>
> 	spin_lock();
> 	__raw_writel(address);
> 	__raw_writel(data);
> 	spin_unlock();
>
> would cause pairs of address/data to be seen on the bus.
>
> Of course this is meaningless on ixp4xx, as there is only one CPU.

I still don't get it. If the spinlocks synchronize between CPUs, there
can only be one CPU (or core) doing the pair of raw_writel(), so how
would it be possible to not get the address/data pair written out?
IOW, how is it different from a system with a single CPU?

> On powerpc, we have in_le32/in_be32 for SoC-internal register access,
> while only PCI devices are allowed to be accessed using readl().

Yeah, this seems like a sane solution.

> I would suggest using an ixp4xx specific set of accessors that comes down
> to either readl() or ioread32_be(), depending on whether CONFIG_CPU_BIG_ENDIAN
> is set. That makes it clear that there is a magic bus involved and that it
> works on this platform but not in portable code.

Hmm. This is actually the opposite - while there may be some magic
(swapping) in readl() and friends, there is absolutely no magic in the
__raw_readl() etc. They are essentially equivalent to
*(volatile u32 *)ptr. This is constant and doesn't depend on endianess,
PCI, anything.
-- 
Krzysztof Halasa

Industrial Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio khalasa@piap.pl (Krzysztof Hałasa) - 2016-02-15 08:40 +0100
  Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio Arnd Bergmann <arnd@arndb.de> - 2016-02-15 10:40 +0100
    Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio khalasa@piap.pl (Krzysztof Hałasa) - 2016-02-15 15:00 +0100
      Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio Arnd Bergmann <arnd@arndb.de> - 2016-02-15 17:20 +0100
        Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio khalasa@piap.pl (Krzysztof Hałasa) - 2016-02-16 10:30 +0100
          Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio Arnd Bergmann <arnd@arndb.de> - 2016-02-16 12:30 +0100
            Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio khalasa@piap.pl (Krzysztof Hałasa) - 2016-02-16 14:30 +0100
              Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio Arnd Bergmann <arnd@arndb.de> - 2016-02-16 15:00 +0100
                Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio khalasa@piap.pl (Krzysztof Hałasa) - 2016-02-17 09:40 +0100
                Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio Arnd Bergmann <arnd@arndb.de> - 2016-02-17 11:40 +0100
                Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio khalasa@piap.pl (Krzysztof Hałasa) - 2016-02-17 17:20 +0100
                Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio Robert Jarzmik <robert.jarzmik@free.fr> - 2016-02-20 22:00 +0100

csiph-web