Commit 7e31cea7 authored by Serge Semin's avatar Serge Semin Committed by Mark Brown

spi: dw: Use relaxed IO-methods to access FIFOs

In accordance with [1] the relaxed methods are guaranteed to be ordered
with respect to other accesses from the same CPU thread to the same
peripheral.  This is what we need during the data read/write from/to the
controller FIFOs being executed within a single IRQ handler or a kernel
task.

Such optimization shall significantly speed the data reader and writer up.
For instance, the relaxed IO-accessors utilization on Baikal-T1 lets the
driver to support the SPI memory operations with bus frequency three-fold
faster than if normal IO-accessors would be used.

[1] "LINUX KERNEL MEMORY BARRIERS", Documentation/memory-barriers.txt,
    Section "KERNEL I/O BARRIER EFFECTS"
Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
Link: https://lore.kernel.org/r/20200920112914.26501-8-Sergey.Semin@baikalelectronics.ruSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a1d5aa6f
...@@ -162,29 +162,19 @@ static inline u32 dw_readl(struct dw_spi *dws, u32 offset) ...@@ -162,29 +162,19 @@ static inline u32 dw_readl(struct dw_spi *dws, u32 offset)
return __raw_readl(dws->regs + offset); return __raw_readl(dws->regs + offset);
} }
static inline u16 dw_readw(struct dw_spi *dws, u32 offset)
{
return __raw_readw(dws->regs + offset);
}
static inline void dw_writel(struct dw_spi *dws, u32 offset, u32 val) static inline void dw_writel(struct dw_spi *dws, u32 offset, u32 val)
{ {
__raw_writel(val, dws->regs + offset); __raw_writel(val, dws->regs + offset);
} }
static inline void dw_writew(struct dw_spi *dws, u32 offset, u16 val)
{
__raw_writew(val, dws->regs + offset);
}
static inline u32 dw_read_io_reg(struct dw_spi *dws, u32 offset) static inline u32 dw_read_io_reg(struct dw_spi *dws, u32 offset)
{ {
switch (dws->reg_io_width) { switch (dws->reg_io_width) {
case 2: case 2:
return dw_readw(dws, offset); return readw_relaxed(dws->regs + offset);
case 4: case 4:
default: default:
return dw_readl(dws, offset); return readl_relaxed(dws->regs + offset);
} }
} }
...@@ -192,11 +182,11 @@ static inline void dw_write_io_reg(struct dw_spi *dws, u32 offset, u32 val) ...@@ -192,11 +182,11 @@ static inline void dw_write_io_reg(struct dw_spi *dws, u32 offset, u32 val)
{ {
switch (dws->reg_io_width) { switch (dws->reg_io_width) {
case 2: case 2:
dw_writew(dws, offset, val); writew_relaxed(val, dws->regs + offset);
break; break;
case 4: case 4:
default: default:
dw_writel(dws, offset, val); writel_relaxed(val, dws->regs + offset);
break; break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment