drivers/irqchip/irq-realtek-rtl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
To make the interrupt driver operable with SWAP_IO_SPACE
config enabled, replace all instances of readl/writel with
their __raw variants. Otherwise readl/writel will do a byte
swap which this driver does not intend to do.
Tested-by: Carlo Szelinsky <github@szelinsky.de>
Signed-off-by: Rustam Adilov <adilov@disroot.org>
---
drivers/irqchip/irq-realtek-rtl.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/irqchip/irq-realtek-rtl.c b/drivers/irqchip/irq-realtek-rtl.c
index 4b59e0cd86bf..3077f4efb4e2 100644
--- a/drivers/irqchip/irq-realtek-rtl.c
+++ b/drivers/irqchip/irq-realtek-rtl.c
@@ -50,18 +50,18 @@ static inline void enable_gimr(unsigned int cpu, unsigned int hw_irq)
{
u32 gimr;
- gimr = readl(REG(cpu, RTL_ICTL_GIMR));
+ gimr = __raw_readl(REG(cpu, RTL_ICTL_GIMR));
gimr |= BIT(hw_irq);
- writel(gimr, REG(cpu, RTL_ICTL_GIMR));
+ __raw_writel(gimr, REG(cpu, RTL_ICTL_GIMR));
}
static inline void disable_gimr(unsigned int cpu, unsigned int hw_irq)
{
u32 gimr;
- gimr = readl(REG(cpu, RTL_ICTL_GIMR));
+ gimr = __raw_readl(REG(cpu, RTL_ICTL_GIMR));
gimr &= ~BIT(hw_irq);
- writel(gimr, REG(cpu, RTL_ICTL_GIMR));
+ __raw_writel(gimr, REG(cpu, RTL_ICTL_GIMR));
}
static void write_irr(unsigned int cpu, int hw_irq, u32 value)
@@ -71,9 +71,9 @@ static void write_irr(unsigned int cpu, int hw_irq, u32 value)
unsigned int shift = IRR_SHIFT(hw_irq);
u32 irr;
- irr = readl(irr0 + offset) & ~(0xf << shift);
+ irr = __raw_readl(irr0 + offset) & ~(0xf << shift);
irr |= (value & 0xf) << shift;
- writel(irr, irr0 + offset);
+ __raw_writel(irr, irr0 + offset);
}
static void realtek_ictl_unmask_irq(struct irq_data *i)
@@ -159,7 +159,8 @@ static void realtek_irq_dispatch(struct irq_desc *desc)
unsigned int hw_irq;
chained_irq_enter(chip, desc);
- pending = readl(REG(cpu, RTL_ICTL_GIMR)) & readl(REG(cpu, RTL_ICTL_GISR)) & output->mask;
+ pending = __raw_readl(REG(cpu, RTL_ICTL_GIMR)) &
+ __raw_readl(REG(cpu, RTL_ICTL_GISR)) & output->mask;
if (unlikely(!pending)) {
spurious_interrupt();
--
2.55.0
On Sat, Jul 11 2026 at 13:23, Rustam Adilov wrote:
> To make the interrupt driver operable with SWAP_IO_SPACE
> config enabled, replace all instances of readl/writel with
> their __raw variants. Otherwise readl/writel will do a byte
> swap which this driver does not intend to do.
Sorry, but this word salad does not qualify as a change log. See
https://docs.kernel.org/process/maintainer-tip.html#changelog
First you want to explain what the context:
When CONFIG_SWAP_IO_SPACE is enabled readl() and writel() imply a byte
swap.
Then you want to explain why this is not correct for this
driver/hardware. Just saying 'does not intend to do' contains zero
information:
This is incorrect for the RTL driver, because <Insert proper technical explanation>
Then you tell how you cure it:
Fix this by converting the MMIO accesses to __raw_readl() and
__raw_writel(), which do not byte swap the data.
Thanks,
tglx
On 2026-07-15 07:10, Thomas Gleixner wrote: > On Sat, Jul 11 2026 at 13:23, Rustam Adilov wrote: > >> To make the interrupt driver operable with SWAP_IO_SPACE >> config enabled, replace all instances of readl/writel with >> their __raw variants. Otherwise readl/writel will do a byte >> swap which this driver does not intend to do. > > Sorry, but this word salad does not qualify as a change log. See > > https://docs.kernel.org/process/maintainer-tip.html#changelog > > First you want to explain what the context: > > When CONFIG_SWAP_IO_SPACE is enabled readl() and writel() imply a byte > swap. > > Then you want to explain why this is not correct for this > driver/hardware. Just saying 'does not intend to do' contains zero > information: > > This is incorrect for the RTL driver, because <Insert proper technical explanation> > > Then you tell how you cure it: > > Fix this by converting the MMIO accesses to __raw_readl() and > __raw_writel(), which do not byte swap the data. Thanks for the review, Honestly my bad for not thinking a bit more on the commit message. That does mean i will have to change commit message in another patch as well as it is a essentially an almost copy of this one... Either way, would this commit message work? When CONFIG_SWAP_IO_SPACE is enabled, readl() and writel() are changed to perform a byte swap to little endian type. This is incorrect because the devices that use the irq-realtek-rtl driver are all big endian MIPS chips. Fix this by converting the MMIO accesses to __raw_readl() and __raw_writel(), which do not byte swap the data. I think just saying "big endian MIPS" should be enough info to tell why byte swapping to "little endian type" (dunno how know else to describe the __le type) is an issue. > Thanks, > > tglx Best, Rustam
© 2016 - 2026 Red Hat, Inc.