* [PATCH] clocksource: rtl-otto: Change driver to use __raw reads and writes
@ 2026-05-11 13:15 Rustam Adilov
2026-05-13 18:31 ` Rustam Adilov
0 siblings, 1 reply; 3+ messages in thread
From: Rustam Adilov @ 2026-05-11 13:15 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner, linux-kernel; +Cc: Rustam Adilov
As it stands, the driver uses ioread32 and iowrite32 for register
access and it works fine. However this stops working when the
SWAP_IO_SPACE config is enabled as this drivers expects ioread32 and
iowrite32 to be in native endian (that is big endian for currently
supported SoCs). RTL9607C is a big endian MIPS SoC that has identical
timer as the already supported chips but needs to have SWAP_IO_SPACE
to have a functioning little endian USB host.
Fix this by replacing all instances of ioread32 and iowrite32 with
__raw_readl and __raw_writel variants. Since they essentially do
the same register access, this shouldn't affect anything on other
machines.
Signed-off-by: Rustam Adilov <adilov@disroot.org>
---
drivers/clocksource/timer-rtl-otto.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/clocksource/timer-rtl-otto.c b/drivers/clocksource/timer-rtl-otto.c
index 6113d2fdd4de..bcb449ef0481 100644
--- a/drivers/clocksource/timer-rtl-otto.c
+++ b/drivers/clocksource/timer-rtl-otto.c
@@ -56,37 +56,37 @@ struct rttm_cs {
/* Simple internal register functions */
static inline unsigned int rttm_get_counter(void __iomem *base)
{
- return ioread32(base + RTTM_CNT);
+ return __raw_readl(base + RTTM_CNT);
}
static inline void rttm_set_period(void __iomem *base, unsigned int period)
{
- iowrite32(period, base + RTTM_DATA);
+ __raw_writel(period, base + RTTM_DATA);
}
static inline void rttm_disable_timer(void __iomem *base)
{
- iowrite32(0, base + RTTM_CTRL);
+ __raw_writel(0, base + RTTM_CTRL);
}
static inline void rttm_enable_timer(void __iomem *base, u32 mode, u32 divisor)
{
- iowrite32(RTTM_CTRL_ENABLE | mode | divisor, base + RTTM_CTRL);
+ __raw_writel(RTTM_CTRL_ENABLE | mode | divisor, base + RTTM_CTRL);
}
static inline void rttm_ack_irq(void __iomem *base)
{
- iowrite32(ioread32(base + RTTM_INT) | RTTM_INT_PENDING, base + RTTM_INT);
+ __raw_writel(__raw_readl(base + RTTM_INT) | RTTM_INT_PENDING, base + RTTM_INT);
}
static inline void rttm_enable_irq(void __iomem *base)
{
- iowrite32(RTTM_INT_ENABLE, base + RTTM_INT);
+ __raw_writel(RTTM_INT_ENABLE, base + RTTM_INT);
}
static inline void rttm_disable_irq(void __iomem *base)
{
- iowrite32(0, base + RTTM_INT);
+ __raw_writel(0, base + RTTM_INT);
}
/* Aggregated control functions for kernel clock framework */
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clocksource: rtl-otto: Change driver to use __raw reads and writes
2026-05-11 13:15 [PATCH] clocksource: rtl-otto: Change driver to use __raw reads and writes Rustam Adilov
@ 2026-05-13 18:31 ` Rustam Adilov
2026-05-13 21:05 ` Chris Packham
0 siblings, 1 reply; 3+ messages in thread
From: Rustam Adilov @ 2026-05-13 18:31 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner, linux-kernel; +Cc: Chris Packham
On 2026-05-11 13:15, Rustam Adilov wrote:
> As it stands, the driver uses ioread32 and iowrite32 for register
> access and it works fine. However this stops working when the
> SWAP_IO_SPACE config is enabled as this drivers expects ioread32 and
> iowrite32 to be in native endian (that is big endian for currently
> supported SoCs). RTL9607C is a big endian MIPS SoC that has identical
> timer as the already supported chips but needs to have SWAP_IO_SPACE
> to have a functioning little endian USB host.
>
> Fix this by replacing all instances of ioread32 and iowrite32 with
> __raw_readl and __raw_writel variants. Since they essentially do
> the same register access, this shouldn't affect anything on other
> machines.
>
> Signed-off-by: Rustam Adilov <adilov@disroot.org>
> ---
> drivers/clocksource/timer-rtl-otto.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/clocksource/timer-rtl-otto.c b/drivers/clocksource/timer-rtl-otto.c
> index 6113d2fdd4de..bcb449ef0481 100644
> --- a/drivers/clocksource/timer-rtl-otto.c
> +++ b/drivers/clocksource/timer-rtl-otto.c
> @@ -56,37 +56,37 @@ struct rttm_cs {
> /* Simple internal register functions */
> static inline unsigned int rttm_get_counter(void __iomem *base)
> {
> - return ioread32(base + RTTM_CNT);
> + return __raw_readl(base + RTTM_CNT);
> }
>
> static inline void rttm_set_period(void __iomem *base, unsigned int period)
> {
> - iowrite32(period, base + RTTM_DATA);
> + __raw_writel(period, base + RTTM_DATA);
> }
>
> static inline void rttm_disable_timer(void __iomem *base)
> {
> - iowrite32(0, base + RTTM_CTRL);
> + __raw_writel(0, base + RTTM_CTRL);
> }
>
> static inline void rttm_enable_timer(void __iomem *base, u32 mode, u32 divisor)
> {
> - iowrite32(RTTM_CTRL_ENABLE | mode | divisor, base + RTTM_CTRL);
> + __raw_writel(RTTM_CTRL_ENABLE | mode | divisor, base + RTTM_CTRL);
> }
>
> static inline void rttm_ack_irq(void __iomem *base)
> {
> - iowrite32(ioread32(base + RTTM_INT) | RTTM_INT_PENDING, base + RTTM_INT);
> + __raw_writel(__raw_readl(base + RTTM_INT) | RTTM_INT_PENDING, base + RTTM_INT);
> }
>
> static inline void rttm_enable_irq(void __iomem *base)
> {
> - iowrite32(RTTM_INT_ENABLE, base + RTTM_INT);
> + __raw_writel(RTTM_INT_ENABLE, base + RTTM_INT);
> }
>
> static inline void rttm_disable_irq(void __iomem *base)
> {
> - iowrite32(0, base + RTTM_INT);
> + __raw_writel(0, base + RTTM_INT);
> }
>
> /* Aggregated control functions for kernel clock framework */
It appears the get_maintainer.pl script didn't catch the Chris Packham, presumably
because i didn't touch the device bindings file. Added them to CC for review.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clocksource: rtl-otto: Change driver to use __raw reads and writes
2026-05-13 18:31 ` Rustam Adilov
@ 2026-05-13 21:05 ` Chris Packham
0 siblings, 0 replies; 3+ messages in thread
From: Chris Packham @ 2026-05-13 21:05 UTC (permalink / raw)
To: Rustam Adilov, Daniel Lezcano, Thomas Gleixner,
linux-kernel@vger.kernel.org, Markus Stockhausen
Hi Rustam,
On 14/05/2026 06:31, Rustam Adilov wrote:
> On 2026-05-11 13:15, Rustam Adilov wrote:
>> As it stands, the driver uses ioread32 and iowrite32 for register
>> access and it works fine. However this stops working when the
>> SWAP_IO_SPACE config is enabled as this drivers expects ioread32 and
>> iowrite32 to be in native endian (that is big endian for currently
>> supported SoCs). RTL9607C is a big endian MIPS SoC that has identical
>> timer as the already supported chips but needs to have SWAP_IO_SPACE
>> to have a functioning little endian USB host.
>>
>> Fix this by replacing all instances of ioread32 and iowrite32 with
>> __raw_readl and __raw_writel variants. Since they essentially do
>> the same register access, this shouldn't affect anything on other
>> machines.
>>
>> Signed-off-by: Rustam Adilov <adilov@disroot.org>
>> ---
>> drivers/clocksource/timer-rtl-otto.c | 14 +++++++-------
>> 1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/clocksource/timer-rtl-otto.c b/drivers/clocksource/timer-rtl-otto.c
>> index 6113d2fdd4de..bcb449ef0481 100644
>> --- a/drivers/clocksource/timer-rtl-otto.c
>> +++ b/drivers/clocksource/timer-rtl-otto.c
>> @@ -56,37 +56,37 @@ struct rttm_cs {
>> /* Simple internal register functions */
>> static inline unsigned int rttm_get_counter(void __iomem *base)
>> {
>> - return ioread32(base + RTTM_CNT);
>> + return __raw_readl(base + RTTM_CNT);
>> }
>>
>> static inline void rttm_set_period(void __iomem *base, unsigned int period)
>> {
>> - iowrite32(period, base + RTTM_DATA);
>> + __raw_writel(period, base + RTTM_DATA);
>> }
>>
>> static inline void rttm_disable_timer(void __iomem *base)
>> {
>> - iowrite32(0, base + RTTM_CTRL);
>> + __raw_writel(0, base + RTTM_CTRL);
>> }
>>
>> static inline void rttm_enable_timer(void __iomem *base, u32 mode, u32 divisor)
>> {
>> - iowrite32(RTTM_CTRL_ENABLE | mode | divisor, base + RTTM_CTRL);
>> + __raw_writel(RTTM_CTRL_ENABLE | mode | divisor, base + RTTM_CTRL);
>> }
>>
>> static inline void rttm_ack_irq(void __iomem *base)
>> {
>> - iowrite32(ioread32(base + RTTM_INT) | RTTM_INT_PENDING, base + RTTM_INT);
>> + __raw_writel(__raw_readl(base + RTTM_INT) | RTTM_INT_PENDING, base + RTTM_INT);
>> }
>>
>> static inline void rttm_enable_irq(void __iomem *base)
>> {
>> - iowrite32(RTTM_INT_ENABLE, base + RTTM_INT);
>> + __raw_writel(RTTM_INT_ENABLE, base + RTTM_INT);
>> }
>>
>> static inline void rttm_disable_irq(void __iomem *base)
>> {
>> - iowrite32(0, base + RTTM_INT);
>> + __raw_writel(0, base + RTTM_INT);
>> }
>>
>> /* Aggregated control functions for kernel clock framework */
> It appears the get_maintainer.pl script didn't catch the Chris Packham, presumably
> because i didn't touch the device bindings file. Added them to CC for review.
No problem. Has --git been dropped by default from get_maintainer.pl?
It doesn't actually help as even when explicitly using it that doesn't
seem to get me (initial commit ignored?), it does find Markus who I've
added to the Cc.
Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-13 21:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 13:15 [PATCH] clocksource: rtl-otto: Change driver to use __raw reads and writes Rustam Adilov
2026-05-13 18:31 ` Rustam Adilov
2026-05-13 21:05 ` Chris Packham
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox