Skip to contentSkip to conversation

clocksource: clint: Avoid remove __iomem in get_cycles_hi()

PATCH In review Palmer Dabbelt 3 participants 5 messages Dec 22, 2020 – Dec 24, 2020

Subsystems (2)
lore
Share & tools
lore

Palmer Dabbelt

author maintainer
#0 lore raw

PATCH 1/1 clocksource: clint: Avoid remove __iomem in get_cycles_hi()

From: Palmer Dabbelt <[email protected]>

This cast loses the __iomem qualifier from clint_timer_val, which triggers an sparse warning.

---
 drivers/clocksource/timer-clint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-clint.c +1 -1
index 6cfe2ab73eb0..83a8b38d46f6 100644
@@ -63,7 +63,7 @@ static struct riscv_ipi_ops clint_ipi_ops = {
 #define clint_get_cycles()	readq_relaxed(clint_timer_val)
 #else
 #define clint_get_cycles()	readl_relaxed(clint_timer_val)
-#define clint_get_cycles_hi()	readl_relaxed(((u32 *)clint_timer_val) + 1)
+#define clint_get_cycles_hi()	readl_relaxed(((u32 __iomem *)clint_timer_val) + 1)
 #endif
 
 #ifdef CONFIG_64BIT
Signature · 7 lines
2.29.2.729.g45daf8777d-goog


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#1 lore raw

From: Palmer Dabbelt

Quoted 18 lines

Sent: 22 December 2020 05:33

From: Palmer Dabbelt <[email protected]>

This cast loses the __iomem qualifier from clint_timer_val, which triggers an sparse warning.

---
 drivers/clocksource/timer-clint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-clint.c +0 -0
index 6cfe2ab73eb0..83a8b38d46f6 100644

drivers/clocksource/timer-clint.c static struct riscv_ipi_ops clint_ipi_ops = { · line 67

Quoted 6 lines
drivers/clocksource/timer-clint.c +1 -1
@@ -63,7 +63,7 @@ static struct riscv_ipi_ops clint_ipi_ops = {
 #define clint_get_cycles()	readq_relaxed(clint_timer_val)
 #else
 #define clint_get_cycles()	readl_relaxed(clint_timer_val)
-#define clint_get_cycles_hi()	readl_relaxed(((u32 *)clint_timer_val) + 1)
+#define clint_get_cycles_hi()	readl_relaxed(((u32 __iomem *)clint_timer_val) + 1)
 #endif

The correct fix is (probably) to define clint_timer_val as u32 on 32bit systems.

Oh - and get rid of those #defines, they are only used in the functions just below them.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#2 lore raw
In reply to Palmer Dabbelt
Quoted 4 lines · Palmer Dabbelt

From: Palmer Dabbelt <[email protected]>

This cast loses the __iomem qualifier from clint_timer_val, which triggers an sparse warning.

I'm not a native speaker, but the subject line sounds strange to me. Shouldn't this be:

"don't cast away the __iommu annotation"

or something similar?

Also this adds an overly long line. Otherwise it looks fine.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

author maintainer
#3 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Palmer Dabbelt

From: Palmer Dabbelt <[email protected]>

This cast loses the __iomem qualifier from clint_timer_val, which triggers an sparse warning.

Quoted 6 lines

I'm not a native speaker, but the subject line sounds strange to me. Shouldn't this be:

"don't cast away the __iommu annotation"

or something similar?

The title is also nonsense, I was probably trying to do two things at once when I wrote this. I'll send another one.

Quoted 1 line

Also this adds an overly long line. Otherwise it looks fine.

Aren't we OK with lines longer than 80 characters now? Or was that some other project? checkpatch doesn't complain, which I guess is why I didn't notice, so hopefully that means I'm not crazy (though I guess the commit message and title don't provide the best argument there... ;)).

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#4 lore raw
Quoted 4 lines · Palmer Dabbelt

Aren't we OK with lines longer than 80 characters now? Or was that some other project? checkpatch doesn't complain, which I guess is why I didn't notice, so hopefully that means I'm not crazy (though I guess the commit message and title don't provide the best argument there... ;)).

They are allowed as an exception, not the norm. Take a look at the coding style document. And checkpath has for a while not been doing the right thing unfortunately.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv