Skip to contentSkip to conversation

ARM: Gemini: Add support for PCI BUS

PATCH In review Hans Ulli Kroll 5 participants 18 messages Nov 27, 2010 – Dec 6, 2010

Subsystems (3)
lore
Share & tools
lore

Hans Ulli Kroll

author maintainer
#0 lore raw

PATCH 1/1 ARM: Gemini: Add support for PCI BUS

Add support for PCI Bux on Gemini Devices SL3516 -changed Paulius Zaleckas mail address
-changed #include <asm/gpio.h> to #include <linux/gpio.h>

---
 arch/arm/Kconfig                             |    1 +
 arch/arm/mach-gemini/Makefile                |    2 +
 arch/arm/mach-gemini/include/mach/hardware.h |    8 +
 arch/arm/mach-gemini/include/mach/irqs.h     |    7 +-
 arch/arm/mach-gemini/mm.c                    |    5 +
 arch/arm/mach-gemini/pci.c                   |  319 ++++++++++++++++++++++++++
 6 files changed, 340 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-gemini/pci.c
arch/arm/Kconfig +1 -0
index a19a526..5d4b398 100644
@@ -307,6 +307,7 @@ config ARCH_GEMINI
 	select CPU_FA526
 	select ARCH_REQUIRE_GPIOLIB
 	select ARCH_USES_GETTIMEOFFSET
+	select PCI
 	help
 	  Support for the Cortina Systems Gemini family SoCs
 
arch/arm/mach-gemini/Makefile +2 -0
index c5b24b9..c263f48 100644
@@ -6,6 +6,8 @@
 
 obj-y			:= irq.o mm.o time.o devices.o gpio.o
 
+obj-$(CONFIG_PCI)	+= pci.o
+
 # Board-specific support
 obj-$(CONFIG_MACH_NAS4220B)	+= board-nas4220b.o
 obj-$(CONFIG_MACH_RUT100)	+= board-rut1xx.o
arch/arm/mach-gemini/include/mach/hardware.h +8 -0
index 213a4fc..38c530f 100644
@@ -71,4 +71,12 @@
  */
 #define IO_ADDRESS(x)	((((x) & 0xFFF00000) >> 4) | ((x) & 0x000FFFFF) | 0xF0000000)
 
+/*
+ * PCI subsystem macros
+ */
+#define PCIBIOS_MIN_IO		0x00000100
+#define PCIBIOS_MIN_MEM		0x00000000
+
+#define pcibios_assign_all_busses()	1
+
 #endif
arch/arm/mach-gemini/include/mach/irqs.h +5 -2
index 06bc47e..c737673 100644
@@ -43,11 +43,14 @@
 
 #define NORMAL_IRQ_NUM	32
 
-#define GPIO_IRQ_BASE	NORMAL_IRQ_NUM
+#define PCI_IRQ_BASE	NORMAL_IRQ_NUM
+#define PCI_IRQ_NUM	4
+
+#define GPIO_IRQ_BASE	(NORMAL_IRQ_NUM + PCI_IRQ_NUM)
 #define GPIO_IRQ_NUM	(3 * 32)
 
 #define ARCH_TIMER_IRQ	IRQ_TIMER2
 
-#define NR_IRQS		(NORMAL_IRQ_NUM + GPIO_IRQ_NUM)
+#define NR_IRQS		(NORMAL_IRQ_NUM + PCI_IRQ_NUM + GPIO_IRQ_NUM)
 
 #endif /* __MACH_IRQS_H__ */
arch/arm/mach-gemini/mm.c +5 -0
index 5194824..2bf20b2 100644
@@ -59,6 +59,11 @@ static struct map_desc gemini_io_desc[] __initdata = {
 		.length		= SZ_512K,
 		.type 		= MT_DEVICE,
 	}, {
+		.virtual	= IO_ADDRESS(GEMINI_PCI_IO_BASE),
+		.pfn		= __phys_to_pfn(GEMINI_PCI_IO_BASE),
+		.length		= SZ_512K,
+		.type		= MT_DEVICE,
+	}, {
 		.virtual	= IO_ADDRESS(GEMINI_FLASH_CTRL_BASE),
 		.pfn		= __phys_to_pfn(GEMINI_FLASH_CTRL_BASE),
 		.length		= SZ_512K,
arch/arm/mach-gemini/pci.c new file +319 -0

319 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#1 lore raw

arch/arm/mach-gemini/pci.c line 57

Quoted 6 lines · On Saturday 27 November 2010 13:24:35 Hans Ulli Kroll wrote:
arch/arm/mach-gemini/pci.c new file +6 -0
+#define PCI_IOSIZE_REG         (IO_ADDRESS(GEMINI_PCI_IO_BASE))
+#define PCI_PROT_REG           (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x04)
+#define PCI_CTRL_REG           (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x08)
+#define PCI_SOFTRST_REG                (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x10)
+#define PCI_CONFIG_REG         (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x28)
+#define PCI_DATA_REG           (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x2C)

If you use the virtual address of the mapping instead of GEMINI_PCI_IO_BASE, you don't need to repeat the IO_ADDRESS() macro everywhere. I have a patch that gets rid of all the conflicting definitions of this macro because it breaks a multi-platform build once we get there.

arch/arm/mach-gemini/pci.c line 68

Quoted 9 lines
arch/arm/mach-gemini/pci.c new file +9 -0
+static DEFINE_SPINLOCK(gemini_pci_lock);
+
+static struct resource gemini_pci_resource_io = {
+       .name   = "PCI I/O Space",
+       .start  = IO_ADDRESS(GEMINI_PCI_IO_BASE),
+       .end    = IO_ADDRESS(GEMINI_PCI_IO_BASE) + SZ_1M - 1,
+       .flags  = IORESOURCE_IO,
+};
+

This looks wrong in multiple ways:

* resources are physical addresses, not virtual addresses
* GEMINI_PCI_IO_BASE is an address in memory space, so it needs to be IORESOURCE_MEM, not IORESOURCE_IO. You can also register the IORESOURCE_IO resource, but that would be .start=PCIBIOS_MIN_IO, .end=IO_SPACE_LIMIT.
* IO_SPACE_LIMIT is larger than the I/O window, which can cause overflows. Setting it to 0xffff is generally enough.

Quoted 14 lines
arch/arm/mach-gemini/pci.c new file +14 -0
+       spin_lock_irqsave(&gemini_pci_lock, irq_flags);
+
+       __raw_writel(PCI_CONF_BUS(bus->number) |
+                       PCI_CONF_DEVICE(PCI_SLOT(fn)) |
+                       PCI_CONF_FUNCTION(PCI_FUNC(fn)) |
+                       PCI_CONF_WHERE(config) |
+                       PCI_CONF_ENABLE,
+                       PCI_CONFIG_REG);
+
+       switch (size) {
+       case 4:
+               __raw_writel(value, PCI_DATA_REG);
+               break;
+       case 2:

arch/arm/mach-gemini/pci.c line 139

Quoted 10 lines
arch/arm/mach-gemini/pci.c new file +10 -0
+               __raw_writew(value, PCI_DATA_REG + (config & 3));
+               break;
+       case 1:
+               __raw_writeb(value, PCI_DATA_REG + (config & 3));
+               break;
+       default:
+               ret = PCIBIOS_BAD_REGISTER_NUMBER;
+       }
+
+       spin_unlock_irqrestore(&gemini_pci_lock, irq_flags);

The I/O ordering is probably not what you think it is. There is no ordering guarantee between __raw_writel and spin_lock/spin_unlock, so you really should be using readl/writel.

Note that the pci_ops are called under another spinlock, so you also don't need to take gemini_pci_lock here.

Arnd

author maintainer
#2 lore raw
Quoted 26 lines · Arnd Bergmann

arch/arm/mach-gemini/pci.c line 57

Quoted 6 lines · On Saturday 27 November 2010 13:24:35 Hans Ulli Kroll wrote:
arch/arm/mach-gemini/pci.c new file +6 -0
+#define PCI_IOSIZE_REG         (IO_ADDRESS(GEMINI_PCI_IO_BASE))
+#define PCI_PROT_REG           (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x04)
+#define PCI_CTRL_REG           (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x08)
+#define PCI_SOFTRST_REG                (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x10)
+#define PCI_CONFIG_REG         (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x28)
+#define PCI_DATA_REG           (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x2C)

If you use the virtual address of the mapping instead of GEMINI_PCI_IO_BASE, you don't need to repeat the IO_ADDRESS() macro everywhere. I have a patch that gets rid of all the conflicting definitions of this macro because it breaks a multi-platform build once we get there.

arch/arm/mach-gemini/pci.c line 68

Quoted 9 lines
arch/arm/mach-gemini/pci.c new file +9 -0
+static DEFINE_SPINLOCK(gemini_pci_lock);
+
+static struct resource gemini_pci_resource_io = {
+       .name   = "PCI I/O Space",
+       .start  = IO_ADDRESS(GEMINI_PCI_IO_BASE),
+       .end    = IO_ADDRESS(GEMINI_PCI_IO_BASE) + SZ_1M - 1,
+       .flags  = IORESOURCE_IO,
+};
+

This looks wrong in multiple ways:

Quoted 8 lines

* resources are physical addresses, not virtual addresses
* GEMINI_PCI_IO_BASE is an address in memory space, so it needs to be IORESOURCE_MEM, not IORESOURCE_IO. You can also register the IORESOURCE_IO resource, but that would be .start=PCIBIOS_MIN_IO, .end=IO_SPACE_LIMIT.
* IO_SPACE_LIMIT is larger than the I/O window, which can cause overflows. Setting it to 0xffff is generally enough.

So I must remove these lines ??

	}, {
		.virtual	= IO_ADDRESS(GEMINI_PCI_IO_BASE),
		.pfn		= __phys_to_pfn(GEMINI_PCI_IO_BASE),
		.length		= SZ_512K,
		.type		= MT_DEVICE,
	},

These are from arch/arm/mach-gemini/mm.c

Quoted 35 lines
Quoted 14 lines
arch/arm/mach-gemini/pci.c new file +14 -0
+       spin_lock_irqsave(&gemini_pci_lock, irq_flags);
+
+       __raw_writel(PCI_CONF_BUS(bus->number) |
+                       PCI_CONF_DEVICE(PCI_SLOT(fn)) |
+                       PCI_CONF_FUNCTION(PCI_FUNC(fn)) |
+                       PCI_CONF_WHERE(config) |
+                       PCI_CONF_ENABLE,
+                       PCI_CONFIG_REG);
+
+       switch (size) {
+       case 4:
+               __raw_writel(value, PCI_DATA_REG);
+               break;
+       case 2:

arch/arm/mach-gemini/pci.c line 139

Quoted 10 lines
arch/arm/mach-gemini/pci.c new file +10 -0
+               __raw_writew(value, PCI_DATA_REG + (config & 3));
+               break;
+       case 1:
+               __raw_writeb(value, PCI_DATA_REG + (config & 3));
+               break;
+       default:
+               ret = PCIBIOS_BAD_REGISTER_NUMBER;
+       }
+
+       spin_unlock_irqrestore(&gemini_pci_lock, irq_flags);

The I/O ordering is probably not what you think it is. There is no ordering guarantee between __raw_writel and spin_lock/spin_unlock, so you really should be using readl/writel.

Note that the pci_ops are called under another spinlock, so you also don't need to take gemini_pci_lock here.

Arnd

#3 lore raw
Quoted 12 lines · Hans Ulli Kroll
Quoted 11 lines

This looks wrong in multiple ways:

* resources are physical addresses, not virtual addresses
* GEMINI_PCI_IO_BASE is an address in memory space, so it needs to be IORESOURCE_MEM, not IORESOURCE_IO. You can also register the IORESOURCE_IO resource, but that would be .start=PCIBIOS_MIN_IO, .end=IO_SPACE_LIMIT.
* IO_SPACE_LIMIT is larger than the I/O window, which can cause overflows. Setting it to 0xffff is generally enough.

Quoted 8 lines

So I must remove these lines ??
}, {
.virtual = IO_ADDRESS(GEMINI_PCI_IO_BASE),
.pfn = __phys_to_pfn(GEMINI_PCI_IO_BASE),
.length = SZ_512K,
.type = MT_DEVICE,
},
These are from arch/arm/mach-gemini/mm.c

No, these look right, just fix the issues I mentioned, i.e. the definition of IO_SPACE_LIMIT and the resource registration.

Arnd

#4 lore raw
In reply to Arnd Bergmann
Quoted 55 lines · Arnd Bergmann

arch/arm/mach-gemini/pci.c line 57

Quoted 6 lines · On Saturday 27 November 2010 13:24:35 Hans Ulli Kroll wrote:
arch/arm/mach-gemini/pci.c new file +6 -0
+#define PCI_IOSIZE_REG         (IO_ADDRESS(GEMINI_PCI_IO_BASE))
+#define PCI_PROT_REG           (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x04)
+#define PCI_CTRL_REG           (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x08)
+#define PCI_SOFTRST_REG                (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x10)
+#define PCI_CONFIG_REG         (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x28)
+#define PCI_DATA_REG           (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x2C)

If you use the virtual address of the mapping instead of GEMINI_PCI_IO_BASE, you don't need to repeat the IO_ADDRESS() macro everywhere. I have a patch that gets rid of all the conflicting definitions of this macro because it breaks a multi-platform build once we get there.

arch/arm/mach-gemini/pci.c line 68

Quoted 9 lines
arch/arm/mach-gemini/pci.c new file +9 -0
+static DEFINE_SPINLOCK(gemini_pci_lock);
+
+static struct resource gemini_pci_resource_io = {
+       .name   = "PCI I/O Space",
+       .start  = IO_ADDRESS(GEMINI_PCI_IO_BASE),
+       .end    = IO_ADDRESS(GEMINI_PCI_IO_BASE) + SZ_1M - 1,
+       .flags  = IORESOURCE_IO,
+};
+

This looks wrong in multiple ways:

* resources are physical addresses, not virtual addresses
* GEMINI_PCI_IO_BASE is an address in memory space, so it needs to be IORESOURCE_MEM, not IORESOURCE_IO. You can also register the IORESOURCE_IO resource, but that would be .start=PCIBIOS_MIN_IO, .end=IO_SPACE_LIMIT.
* IO_SPACE_LIMIT is larger than the I/O window, which can cause overflows. Setting it to 0xffff is generally enough.

Quoted 21 lines
arch/arm/mach-gemini/pci.c new file +21 -0
+       spin_lock_irqsave(&gemini_pci_lock, irq_flags);
+
+       __raw_writel(PCI_CONF_BUS(bus->number) |
+                       PCI_CONF_DEVICE(PCI_SLOT(fn)) |
+                       PCI_CONF_FUNCTION(PCI_FUNC(fn)) |
+                       PCI_CONF_WHERE(config) |
+                       PCI_CONF_ENABLE,
+                       PCI_CONFIG_REG);
+
+       switch (size) {
+       case 4:
+               __raw_writel(value, PCI_DATA_REG);
+               break;
+       case 2:
+               __raw_writew(value, PCI_DATA_REG + (config&  3));
+               break;
+       case 1:
+               __raw_writeb(value, PCI_DATA_REG + (config&  3));
+               break;
+       default:
+               ret = PCIBIOS_BAD_REGISTER_NUMBER;
Quoted 8 lines

arch/arm/mach-gemini/pci.c line 139

Quoted 3 lines
arch/arm/mach-gemini/pci.c new file +3 -0
+       }
+
+       spin_unlock_irqrestore(&gemini_pci_lock, irq_flags);

The I/O ordering is probably not what you think it is. There is no ordering guarantee between __raw_writel and spin_lock/spin_unlock, so you really should be using readl/writel.

No he really should NOT use readl/writel. The ONLY difference between readl/writel and __raw_readl/__raw_writel is endianess conversion. __raw_*l is not doing it. Which to use depend only on HW.

Quoted 4 lines

Note that the pci_ops are called under another spinlock, so you also don't need to take gemini_pci_lock here.

Arnd

#5 lore raw
Quoted 9 lines · Paulius Zaleckas
Quoted 4 lines

The I/O ordering is probably not what you think it is. There is no ordering guarantee between __raw_writel and spin_lock/spin_unlock, so you really should be using readl/writel.

No he really should NOT use readl/writel. The ONLY difference between readl/writel and __raw_readl/__raw_writel is endianess conversion. __raw_*l is not doing it. Which to use depend only on HW.

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is fixed little-endian, just as the hardware is in this case. The endian-conversion is a NOP on little-endian ARM, but required if you actually run on a big-endian ARM (you don't).
* __raw_readl may not be atomic, gcc is free to split the access into byte wise reads (it normally does not, unless you mark the pointer __attribute__((packed))).

In essence, it is almost never a good idea to use __raw_readl, and the double underscores should tell you so.

Arnd

#6 lore raw
Quoted 23 lines · Arnd Bergmann
Quoted 9 lines · Paulius Zaleckas
Quoted 4 lines

The I/O ordering is probably not what you think it is. There is no ordering guarantee between __raw_writel and spin_lock/spin_unlock, so you really should be using readl/writel.

No he really should NOT use readl/writel. The ONLY difference between readl/writel and __raw_readl/__raw_writel is endianess conversion. __raw_*l is not doing it. Which to use depend only on HW.

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is fixed little-endian, just as the hardware is in this case. The endian-conversion is a NOP on little-endian ARM, but required if you actually run on a big-endian ARM (you don't).
* __raw_readl may not be atomic, gcc is free to split the access into byte wise reads (it normally does not, unless you mark the pointer __attribute__((packed))).

Quoted 2 lines

In essence, it is almost never a good idea to use __raw_readl, and the double underscores should tell you so.

You are wrong:

Since CONFIG_ARM_DMA_MEM_BUFFERABLE is NOT defined for FA526 core, no barriers are in use when using readl. It just translates into le32_to_cpu(__raw_readl(x)). Now this CPU has physical pin for endianess configuration and if you will chose big-endian you will fail to read internal registers, because they ALSO change endianess and le32_to_cpu() will screw it. However it is different when accessing registers through PCI bus, then you need to use readl().

#7 lore raw
Quoted 18 lines · On Monday 29 November 2010 19:52:55 Paulius Zaleckas wrote:
Quoted 12 lines · Arnd Bergmann

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is fixed little-endian, just as the hardware is in this case. The endian-conversion is a NOP on little-endian ARM, but required if you actually run on a big-endian ARM (you don't).
* __raw_readl may not be atomic, gcc is free to split the access into byte wise reads (it normally does not, unless you mark the pointer __attribute__((packed))).

Quoted 2 lines

In essence, it is almost never a good idea to use __raw_readl, and the double underscores should tell you so.

You are wrong:

Quoted 7 lines

Since CONFIG_ARM_DMA_MEM_BUFFERABLE is NOT defined for FA526 core, no barriers are in use when using readl. It just translates into le32_to_cpu(__raw_readl(x)). Now this CPU has physical pin for endianess configuration and if you will chose big-endian you will fail to read internal registers, because they ALSO change endianess and le32_to_cpu() will screw it. However it is different when accessing registers through PCI bus, then you need to use readl().

Ok, I only checked that the platform does not support big-endian Linux kernel, not if the HW designers screwed up their registers, sorry about that.

The other points are of course still valid: If the code ever gets used on an out of order CPU, it is broken. More importantly, if someone looks at the code as an example for writing another PCI support code, it may end up getting copied to some place where it ends up causing trouble.

The typical way to deal with mixed-endian hardware reliably is to have a header file containing code like

#ifdef CONFIG_GEMINI_BIG_ENDIAN_IO
#define gemini_readl(x) __swab32(readl(x))
#define ...
#else
#define gemini_readl(x) readl(x))
#endif

This also takes care of the (not as unlikely as you'd hope) case that the next person reusing the PCI hardware wires its endianess different from the CPU endianess.

Arnd

#8 lore raw
Quoted 47 lines · Arnd Bergmann
Quoted 18 lines · On Monday 29 November 2010 19:52:55 Paulius Zaleckas wrote:
Quoted 12 lines · Arnd Bergmann

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is fixed little-endian, just as the hardware is in this case. The endian-conversion is a NOP on little-endian ARM, but required if you actually run on a big-endian ARM (you don't).
* __raw_readl may not be atomic, gcc is free to split the access into byte wise reads (it normally does not, unless you mark the pointer __attribute__((packed))).

Quoted 2 lines

In essence, it is almost never a good idea to use __raw_readl, and the double underscores should tell you so.

You are wrong:

Quoted 7 lines

Since CONFIG_ARM_DMA_MEM_BUFFERABLE is NOT defined for FA526 core, no barriers are in use when using readl. It just translates into le32_to_cpu(__raw_readl(x)). Now this CPU has physical pin for endianess configuration and if you will chose big-endian you will fail to read internal registers, because they ALSO change endianess and le32_to_cpu() will screw it. However it is different when accessing registers through PCI bus, then you need to use readl().

Ok, I only checked that the platform does not support big-endian Linux kernel, not if the HW designers screwed up their registers, sorry about that.

The other points are of course still valid: If the code ever gets used on an out of order CPU, it is broken. More importantly, if someone looks at the code as an example for writing another PCI support code, it may end up getting copied to some place where it ends up causing trouble.

The typical way to deal with mixed-endian hardware reliably is to have a header file containing code like

#ifdef CONFIG_GEMINI_BIG_ENDIAN_IO
#define gemini_readl(x) __swab32(readl(x))
#define ...
#else
#define gemini_readl(x) readl(x))
#endif

Quoted 3 lines

This also takes care of the (not as unlikely as you'd hope) case that the next person reusing the PCI hardware wires its endianess different from the CPU endianess.

Actually I am not very sure how CPU works in big endian mode :)
I have never tried it and I think only some guys who made it did that. So readl will work for 99.99% of cases. In datasheet they say that:
"All registers in Gemini use Little Endian and must be accessed by aligned 32-bit word operations. The bus connection interface logic provides an Endian Conversion function."
For me it looks like it can mean whatever you want :)

author maintainer
#9 lore raw
Quoted 52 lines · Paulius Zaleckas
Quoted 47 lines · Arnd Bergmann
Quoted 18 lines · On Monday 29 November 2010 19:52:55 Paulius Zaleckas wrote:
Quoted 12 lines · Arnd Bergmann

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is fixed little-endian, just as the hardware is in this case. The endian-conversion is a NOP on little-endian ARM, but required if you actually run on a big-endian ARM (you don't).
* __raw_readl may not be atomic, gcc is free to split the access into byte wise reads (it normally does not, unless you mark the pointer __attribute__((packed))).

Quoted 2 lines

In essence, it is almost never a good idea to use __raw_readl, and the double underscores should tell you so.

You are wrong:

Quoted 7 lines

Since CONFIG_ARM_DMA_MEM_BUFFERABLE is NOT defined for FA526 core, no barriers are in use when using readl. It just translates into le32_to_cpu(__raw_readl(x)). Now this CPU has physical pin for endianess configuration and if you will chose big-endian you will fail to read internal registers, because they ALSO change endianess and le32_to_cpu() will screw it. However it is different when accessing registers through PCI bus, then you need to use readl().

Ok, I only checked that the platform does not support big-endian Linux kernel, not if the HW designers screwed up their registers, sorry about that.

The other points are of course still valid: If the code ever gets used on an out of order CPU, it is broken. More importantly, if someone looks at the code as an example for writing another PCI support code, it may end up getting copied to some place where it ends up causing trouble.

The typical way to deal with mixed-endian hardware reliably is to have a header file containing code like

#ifdef CONFIG_GEMINI_BIG_ENDIAN_IO
#define gemini_readl(x) __swab32(readl(x))
#define ...
#else
#define gemini_readl(x) readl(x))
#endif

Quoted 3 lines

This also takes care of the (not as unlikely as you'd hope) case that the next person reusing the PCI hardware wires its endianess different from the CPU endianess.

Quoted 8 lines

Actually I am not very sure how CPU works in big endian mode :)
I have never tried it and I think only some guys who made it did that. So readl will work for 99.99% of cases. In datasheet they say that:
"All registers in Gemini use Little Endian and must be accessed by aligned 32-bit word operations. The bus connection interface logic provides an Endian Conversion function."
For me it looks like it can mean whatever you want :)

I think the endianes pin switched only the cpu, not the hardware registers.

Here is some sample code from the ethernet devive on Gemini typedef union

{
	unsigned int bits32;
	struct bit
	{
#if (BIG_ENDIAN==1)
		unsigned int reserved		: 15;	// bit 31:17
		unsigned int v_bit_mode		: 1;	// bit 16
		unsigned int device_id		: 12;	// bit 15:4
		unsigned int revision_id	: 4;	// bit  3:0
#else
		unsigned int revision_id	: 4;	// bit  3:0
		unsigned int device_id		: 12;	// bit 15:4
		unsigned int v_bit_mode		: 1;	// bit 16
		unsigned int reserved		: 15;	// bit 31:17
#endif
	} bits;
} TOE_VERSION_T;
#10 lore raw
Quoted 65 lines · Hans Ulli Kroll
Quoted 52 lines · Paulius Zaleckas
Quoted 47 lines · Arnd Bergmann
Quoted 18 lines · On Monday 29 November 2010 19:52:55 Paulius Zaleckas wrote:
Quoted 12 lines · Arnd Bergmann

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with ? ? spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is ? ? fixed little-endian, just as the hardware is in this case. ? ? The endian-conversion is a NOP on little-endian ARM, but required ? ? if you actually run on a big-endian ARM (you don't).
* __raw_readl may not be atomic, gcc is free to split the access ? ? into byte wise reads (it normally does not, unless you mark ? ? the pointer __attribute__((packed))).

Quoted 2 lines

In essence, it is almost never a good idea to use __raw_readl, and the double underscores should tell you so.

You are wrong:

Quoted 7 lines

Since CONFIG_ARM_DMA_MEM_BUFFERABLE is NOT defined for FA526 core, no barriers are in use when using readl. It just translates into le32_to_cpu(__raw_readl(x)). Now this CPU has physical pin for endianess configuration and if you will chose big-endian you will fail to read internal registers, because they ALSO change endianess and le32_to_cpu() will screw it. However it is different when accessing registers through PCI bus, then you need to use readl().

Ok, I only checked that the platform does not support big-endian Linux kernel, not if the HW designers screwed up their registers, sorry about that.

The other points are of course still valid: If the code ever gets used on an out of order CPU, it is broken. More importantly, if someone looks at the code as an example for writing another PCI support code, it may end up getting copied to some place where it ends up causing trouble.

The typical way to deal with mixed-endian hardware reliably is to have a header file containing code like

#ifdef CONFIG_GEMINI_BIG_ENDIAN_IO
#define gemini_readl(x) __swab32(readl(x))
#define ...
#else
#define gemini_readl(x) readl(x))
#endif

Quoted 3 lines

This also takes care of the (not as unlikely as you'd hope) case that the next person reusing the PCI hardware wires its endianess different from the CPU endianess.

Quoted 8 lines

Actually I am not very sure how CPU works in big endian mode :)
I have never tried it and I think only some guys who made it did that. So readl will work for 99.99% of cases. In datasheet they say that:
"All registers in Gemini use Little Endian and must be accessed by aligned 32-bit word operations. The bus connection interface logic provides an Endian Conversion function."
For me it looks like it can mean whatever you want :)

Quoted 2 lines

I think the endianes pin switched only the cpu, not the hardware registers.

Yes, but original driver used readl/writel and it does le32_to_cpu, so that structure definition is just reversing it.
If you will use __raw_readl/__raw_writel than there will be no need for this redefinition.

Quoted 9 lines

Here is some sample code from the ethernet devive on Gemini typedef union
{
? ? ? ?unsigned int bits32;
? ? ? ?struct bit
? ? ? ?{
#if (BIG_ENDIAN==1)
? ? ? ? ? ? ? ?unsigned int reserved ? ? ? ? ? : 15; ? // bit 31:17 ? ? ? ? ? ? ? ?unsigned int v_bit_mode ? ? ? ? : 1; ? ?// bit 16

Quoted 8 lines

? ? ? ? ? ? ? ?unsigned int device_id ? ? ? ? ?: 12; ? // bit 15:4 ? ? ? ? ? ? ? ?unsigned int revision_id ? ? ? ?: 4; ? ?// bit ?3:0 #else
? ? ? ? ? ? ? ?unsigned int revision_id ? ? ? ?: 4; ? ?// bit ?3:0 ? ? ? ? ? ? ? ?unsigned int device_id ? ? ? ? ?: 12; ? // bit 15:4 ? ? ? ? ? ? ? ?unsigned int v_bit_mode ? ? ? ? : 1; ? ?// bit 16 ? ? ? ? ? ? ? ?unsigned int reserved ? ? ? ? ? : 15; ? // bit 31:17 #endif

The other thing is that this endianess redefinition is very starnge since it should swap bytes and not bits inside this struct. So I assume that big endian was never tested on this driver and it will not work. But ofcouse I can be wrong here :)

Quoted 5 lines

? ? ? ?} bits;
} TOE_VERSION_T;

author maintainer
#11 lore raw
Quoted 93 lines · Paulius Zaleckas
Quoted 65 lines · Hans Ulli Kroll
Quoted 52 lines · Paulius Zaleckas
Quoted 47 lines · Arnd Bergmann
Quoted 18 lines · On Monday 29 November 2010 19:52:55 Paulius Zaleckas wrote:
Quoted 12 lines · Arnd Bergmann

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with ? ? spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is ? ? fixed little-endian, just as the hardware is in this case. ? ? The endian-conversion is a NOP on little-endian ARM, but required ? ? if you actually run on a big-endian ARM (you don't).
* __raw_readl may not be atomic, gcc is free to split the access ? ? into byte wise reads (it normally does not, unless you mark ? ? the pointer __attribute__((packed))).

Quoted 2 lines

In essence, it is almost never a good idea to use __raw_readl, and the double underscores should tell you so.

You are wrong:

Quoted 7 lines

Since CONFIG_ARM_DMA_MEM_BUFFERABLE is NOT defined for FA526 core, no barriers are in use when using readl. It just translates into le32_to_cpu(__raw_readl(x)). Now this CPU has physical pin for endianess configuration and if you will chose big-endian you will fail to read internal registers, because they ALSO change endianess and le32_to_cpu() will screw it. However it is different when accessing registers through PCI bus, then you need to use readl().

Ok, I only checked that the platform does not support big-endian Linux kernel, not if the HW designers screwed up their registers, sorry about that.

The other points are of course still valid: If the code ever gets used on an out of order CPU, it is broken. More importantly, if someone looks at the code as an example for writing another PCI support code, it may end up getting copied to some place where it ends up causing trouble.

The typical way to deal with mixed-endian hardware reliably is to have a header file containing code like

#ifdef CONFIG_GEMINI_BIG_ENDIAN_IO
#define gemini_readl(x) __swab32(readl(x))
#define ...
#else
#define gemini_readl(x) readl(x))
#endif

Quoted 3 lines

This also takes care of the (not as unlikely as you'd hope) case that the next person reusing the PCI hardware wires its endianess different from the CPU endianess.

Quoted 8 lines

Actually I am not very sure how CPU works in big endian mode :)
I have never tried it and I think only some guys who made it did that. So readl will work for 99.99% of cases. In datasheet they say that:
"All registers in Gemini use Little Endian and must be accessed by aligned 32-bit word operations. The bus connection interface logic provides an Endian Conversion function."
For me it looks like it can mean whatever you want :)

Quoted 2 lines

I think the endianes pin switched only the cpu, not the hardware registers.

Yes, but original driver used readl/writel and it does le32_to_cpu, so that structure definition is just reversing it.
If you will use __raw_readl/__raw_writel than there will be no need for this redefinition.

Quoted 9 lines

Here is some sample code from the ethernet devive on Gemini typedef union
{
? ? ? ?unsigned int bits32;
? ? ? ?struct bit
? ? ? ?{
#if (BIG_ENDIAN==1)
? ? ? ? ? ? ? ?unsigned int reserved ? ? ? ? ? : 15; ? // bit 31:17 ? ? ? ? ? ? ? ?unsigned int v_bit_mode ? ? ? ? : 1; ? ?// bit 16

Quoted 8 lines

? ? ? ? ? ? ? ?unsigned int device_id ? ? ? ? ?: 12; ? // bit 15:4 ? ? ? ? ? ? ? ?unsigned int revision_id ? ? ? ?: 4; ? ?// bit ?3:0 #else
? ? ? ? ? ? ? ?unsigned int revision_id ? ? ? ?: 4; ? ?// bit ?3:0 ? ? ? ? ? ? ? ?unsigned int device_id ? ? ? ? ?: 12; ? // bit 15:4 ? ? ? ? ? ? ? ?unsigned int v_bit_mode ? ? ? ? : 1; ? ?// bit 16 ? ? ? ? ? ? ? ?unsigned int reserved ? ? ? ? ? : 15; ? // bit 31:17 #endif

Quoted 5 lines

The other thing is that this endianess redefinition is very starnge since it should swap bytes and not bits inside this struct. So I assume that big endian was never tested on this driver and it will not work. But ofcouse I can be wrong here :)

At this momment my brain restarts in very slow motion mode ;-) This can't work. The definition Storlinksemi uses for swapping bits and bytes are totaly wrong.
They never _even_ testet this, or understand little endian or big endian. Take this simple sample

typedef union {
	unsigned int bits32;
	struct bit {
#if (BIG_ENDIAN==0) 
		unsigned int a	: 1;		
		unsigned int b  : 31;
#else
		unsigned int b  : 31;
		unsigned int a  : 1;
#endif
	};
} TEST;

They swaped the bits inside one byte

Quoted 6 lines
Quoted 5 lines

? ? ? ?} bits;
} TOE_VERSION_T;

#12 lore raw
Quoted 122 lines · Hans Ulli Kroll
Quoted 93 lines · Paulius Zaleckas
Quoted 65 lines · Hans Ulli Kroll
Quoted 52 lines · Paulius Zaleckas
Quoted 47 lines · Arnd Bergmann
Quoted 18 lines · On Monday 29 November 2010 19:52:55 Paulius Zaleckas wrote:
Quoted 12 lines · Arnd Bergmann

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with ? ? spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is ? ? fixed little-endian, just as the hardware is in this case. ? ? The endian-conversion is a NOP on little-endian ARM, but required ? ? if you actually run on a big-endian ARM (you don't).
* __raw_readl may not be atomic, gcc is free to split the access ? ? into byte wise reads (it normally does not, unless you mark ? ? the pointer __attribute__((packed))).

Quoted 2 lines

In essence, it is almost never a good idea to use __raw_readl, and the double underscores should tell you so.

You are wrong:

Quoted 7 lines

Since CONFIG_ARM_DMA_MEM_BUFFERABLE is NOT defined for FA526 core, no barriers are in use when using readl. It just translates into le32_to_cpu(__raw_readl(x)). Now this CPU has physical pin for endianess configuration and if you will chose big-endian you will fail to read internal registers, because they ALSO change endianess and le32_to_cpu() will screw it. However it is different when accessing registers through PCI bus, then you need to use readl().

Ok, I only checked that the platform does not support big-endian Linux kernel, not if the HW designers screwed up their registers, sorry about that.

The other points are of course still valid: If the code ever gets used on an out of order CPU, it is broken. More importantly, if someone looks at the code as an example for writing another PCI support code, it may end up getting copied to some place where it ends up causing trouble.

The typical way to deal with mixed-endian hardware reliably is to have a header file containing code like

#ifdef CONFIG_GEMINI_BIG_ENDIAN_IO
#define gemini_readl(x) __swab32(readl(x))
#define ...
#else
#define gemini_readl(x) readl(x))
#endif

Quoted 3 lines

This also takes care of the (not as unlikely as you'd hope) case that the next person reusing the PCI hardware wires its endianess different from the CPU endianess.

Quoted 8 lines

Actually I am not very sure how CPU works in big endian mode :)
I have never tried it and I think only some guys who made it did that. So readl will work for 99.99% of cases. In datasheet they say that:
"All registers in Gemini use Little Endian and must be accessed by aligned 32-bit word operations. The bus connection interface logic provides an Endian Conversion function."
For me it looks like it can mean whatever you want :)

Quoted 2 lines

I think the endianes pin switched only the cpu, not the hardware registers.

Yes, but original driver used readl/writel and it does le32_to_cpu, so that structure definition is just reversing it.
If you will use __raw_readl/__raw_writel than there will be no need for this redefinition.

Quoted 9 lines

Here is some sample code from the ethernet devive on Gemini typedef union
{
? ? ? ?unsigned int bits32;
? ? ? ?struct bit
? ? ? ?{
#if (BIG_ENDIAN==1)
? ? ? ? ? ? ? ?unsigned int reserved ? ? ? ? ? : 15; ? // bit 31:17 ? ? ? ? ? ? ? ?unsigned int v_bit_mode ? ? ? ? : 1; ? ?// bit 16

Quoted 8 lines

? ? ? ? ? ? ? ?unsigned int device_id ? ? ? ? ?: 12; ? // bit 15:4 ? ? ? ? ? ? ? ?unsigned int revision_id ? ? ? ?: 4; ? ?// bit ?3:0 #else
? ? ? ? ? ? ? ?unsigned int revision_id ? ? ? ?: 4; ? ?// bit ?3:0 ? ? ? ? ? ? ? ?unsigned int device_id ? ? ? ? ?: 12; ? // bit 15:4 ? ? ? ? ? ? ? ?unsigned int v_bit_mode ? ? ? ? : 1; ? ?// bit 16 ? ? ? ? ? ? ? ?unsigned int reserved ? ? ? ? ? : 15; ? // bit 31:17 #endif

Quoted 5 lines

The other thing is that this endianess redefinition is very starnge since it should swap bytes and not bits inside this struct. So I assume that big endian was never tested on this driver and it will not work. But ofcouse I can be wrong here :)

At this momment my brain restarts in very slow motion mode ;-) This can't work. The definition Storlinksemi uses for swapping bits and bytes are totaly wrong.
They never _even_ testet this, or understand little endian or big endian. Take this simple sample

typedef union {
? ? ? ?unsigned int bits32;
? ? ? ?struct bit {
#if (BIG_ENDIAN==0)
? ? ? ? ? ? ? ?unsigned int a ?: 1;
? ? ? ? ? ? ? ?unsigned int b ?: 31;
#else
? ? ? ? ? ? ? ?unsigned int b ?: 31;
? ? ? ? ? ? ? ?unsigned int a ?: 1;
#endif
? ? ? ?};
} TEST;

Quoted 1 line

They swaped the bits inside one byte

Ha! Wait a minute. Looks like we are both wrong...
Read the beginning of: http://thread.gmane.org/gmane.linux.kernel/1037608

So it means we should use readl/writel and get rid of these non-portable bit-fields...

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

? ? ? ?} bits;
} TOE_VERSION_T;

author maintainer
#13 lore raw
Quoted 124 lines · Paulius Zaleckas
Quoted 122 lines · Hans Ulli Kroll
Quoted 93 lines · Paulius Zaleckas
Quoted 65 lines · Hans Ulli Kroll
Quoted 52 lines · Paulius Zaleckas
Quoted 47 lines · Arnd Bergmann
Quoted 18 lines · On Monday 29 November 2010 19:52:55 Paulius Zaleckas wrote:
Quoted 12 lines · Arnd Bergmann

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with ? ? spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is ? ? fixed little-endian, just as the hardware is in this case. ? ? The endian-conversion is a NOP on little-endian ARM, but required ? ? if you actually run on a big-endian ARM (you don't).
* __raw_readl may not be atomic, gcc is free to split the access ? ? into byte wise reads (it normally does not, unless you mark ? ? the pointer __attribute__((packed))).

Quoted 2 lines

In essence, it is almost never a good idea to use __raw_readl, and the double underscores should tell you so.

You are wrong:

Quoted 7 lines

Since CONFIG_ARM_DMA_MEM_BUFFERABLE is NOT defined for FA526 core, no barriers are in use when using readl. It just translates into le32_to_cpu(__raw_readl(x)). Now this CPU has physical pin for endianess configuration and if you will chose big-endian you will fail to read internal registers, because they ALSO change endianess and le32_to_cpu() will screw it. However it is different when accessing registers through PCI bus, then you need to use readl().

Ok, I only checked that the platform does not support big-endian Linux kernel, not if the HW designers screwed up their registers, sorry about that.

The other points are of course still valid: If the code ever gets used on an out of order CPU, it is broken. More importantly, if someone looks at the code as an example for writing another PCI support code, it may end up getting copied to some place where it ends up causing trouble.

The typical way to deal with mixed-endian hardware reliably is to have a header file containing code like

#ifdef CONFIG_GEMINI_BIG_ENDIAN_IO
#define gemini_readl(x) __swab32(readl(x))
#define ...
#else
#define gemini_readl(x) readl(x))
#endif

Quoted 3 lines

This also takes care of the (not as unlikely as you'd hope) case that the next person reusing the PCI hardware wires its endianess different from the CPU endianess.

Quoted 8 lines

Actually I am not very sure how CPU works in big endian mode :)
I have never tried it and I think only some guys who made it did that. So readl will work for 99.99% of cases. In datasheet they say that:
"All registers in Gemini use Little Endian and must be accessed by aligned 32-bit word operations. The bus connection interface logic provides an Endian Conversion function."
For me it looks like it can mean whatever you want :)

Quoted 2 lines

I think the endianes pin switched only the cpu, not the hardware registers.

Yes, but original driver used readl/writel and it does le32_to_cpu, so that structure definition is just reversing it.
If you will use __raw_readl/__raw_writel than there will be no need for this redefinition.

Quoted 9 lines

Here is some sample code from the ethernet devive on Gemini typedef union
{
? ? ? ?unsigned int bits32;
? ? ? ?struct bit
? ? ? ?{
#if (BIG_ENDIAN==1)
? ? ? ? ? ? ? ?unsigned int reserved ? ? ? ? ? : 15; ? // bit 31:17 ? ? ? ? ? ? ? ?unsigned int v_bit_mode ? ? ? ? : 1; ? ?// bit 16

Quoted 8 lines

? ? ? ? ? ? ? ?unsigned int device_id ? ? ? ? ?: 12; ? // bit 15:4 ? ? ? ? ? ? ? ?unsigned int revision_id ? ? ? ?: 4; ? ?// bit ?3:0 #else
? ? ? ? ? ? ? ?unsigned int revision_id ? ? ? ?: 4; ? ?// bit ?3:0 ? ? ? ? ? ? ? ?unsigned int device_id ? ? ? ? ?: 12; ? // bit 15:4 ? ? ? ? ? ? ? ?unsigned int v_bit_mode ? ? ? ? : 1; ? ?// bit 16 ? ? ? ? ? ? ? ?unsigned int reserved ? ? ? ? ? : 15; ? // bit 31:17 #endif

Quoted 5 lines

The other thing is that this endianess redefinition is very starnge since it should swap bytes and not bits inside this struct. So I assume that big endian was never tested on this driver and it will not work. But ofcouse I can be wrong here :)

At this momment my brain restarts in very slow motion mode ;-) This can't work. The definition Storlinksemi uses for swapping bits and bytes are totaly wrong.
They never _even_ testet this, or understand little endian or big endian. Take this simple sample

typedef union {
? ? ? ?unsigned int bits32;
? ? ? ?struct bit {
#if (BIG_ENDIAN==0)
? ? ? ? ? ? ? ?unsigned int a ?: 1;
? ? ? ? ? ? ? ?unsigned int b ?: 31;
#else
? ? ? ? ? ? ? ?unsigned int b ?: 31;
? ? ? ? ? ? ? ?unsigned int a ?: 1;
#endif
? ? ? ?};
} TEST;

Quoted 8 lines
Quoted 1 line

They swaped the bits inside one byte

Ha! Wait a minute. Looks like we are both wrong...
Read the beginning of: http://thread.gmane.org/gmane.linux.kernel/1037608

So it means we should use readl/writel and get rid of these non-portable bit-fields...

get rid of _endianes_.
Endianes is ordering of bytes (octets) in address space and _not_ bits in registers nor bytes.

With the above example :
a = 1;
b = 0;

you will get on little endian cpu this
0x01, 0x00, 0x00, 0x00 (0x00000001UL) in memory
on big endian
0x00, 0x00, 0x00, 0x01 (0x01000000UL)
_note_ the bits are not swapped, _only_ bytes.

but if we use this _strange_ register layout with BIG_ENDIAN is set
0x00, 0x00, 0x00, 0x80 (0x80000000UL)

I've done this _on_ paper to understand this.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

? ? ? ?} bits;
} TOE_VERSION_T;

#14 lore raw
In reply to Arnd Bergmann

Hello.

Quoted 10 lines · Arnd Bergmann
Quoted 9 lines
Quoted 4 lines

The I/O ordering is probably not what you think it is. There is no ordering guarantee between __raw_writel and spin_lock/spin_unlock, so you really should be using readl/writel.

No he really should NOT use readl/writel. The ONLY difference between readl/writel and __raw_readl/__raw_writel is endianess conversion. __raw_*l is not doing it. Which to use depend only on HW.

Quoted 6 lines

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is fixed little-endian,

I know I'm late but readl()/writel() are CPU-endian, not LE.

WBR, Sergei

#15 lore raw
Quoted 8 lines · Sergei Shtylyov
Quoted 6 lines

There are many differences between readl and __raw_readl, including

* __raw_readl does not have barriers and does not serialize with spinlocks, so it breaks on out-of-order CPUs.
* __raw_readl does not have a specific endianess, while readl is fixed little-endian,

I know I'm late but readl()/writel() are CPU-endian, not LE.

If that was the case, it would be a bug. readl/writel is defined to be the same endianess as PCI, which is little-endian. Otherwise you would not be able to use any PCI devices on big-endian ARM machines. The definition of readl is

#define readl(addr) __le32_to_cpu(__raw_readl(addr))

which converts the little-endian I/O register into a native endian CPU register.

Arnd

#16 lore raw
In reply to Paulius Zaleckas
Quoted 4 lines · Paulius Zaleckas

No he really should NOT use readl/writel. The ONLY difference between readl/writel and __raw_readl/__raw_writel is endianess conversion. __raw_*l is not doing it. Which to use depend only on HW.

Wrong. readl/writel have barriers too to guarantee ordering between device accesses and memory accesses. (device accesses are already ordered with respect to themselves.) __raw variants do not guarantee the relative ordering between memory accesses and device accesses.

#17 lore raw
Quoted 11 lines · Russell King - ARM Linux
Quoted 4 lines · Paulius Zaleckas

No he really should NOT use readl/writel. The ONLY difference between readl/writel and __raw_readl/__raw_writel is endianess conversion. __raw_*l is not doing it. Which to use depend only on HW.

Wrong. readl/writel have barriers too to guarantee ordering between device accesses and memory accesses. (device accesses are already ordered with respect to themselves.) __raw variants do not guarantee the relative ordering between memory accesses and device accesses.

#ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
#define __iormb() rmb()
#define __iowmb() wmb()
#else
#define __iormb() do { } while (0)
#define __iowmb() do { } while (0)
#endif

CONFIG_ARM_DMA_MEM_BUFFERABLE is NOT defined in this case. I don't see any other barriers.
readl does endianess conversion. What to do if you don't need it? Do it one more time?