x86/early_printk: Use __iomem address space for IO
PATCH v2 1/1 x86/early_printk: Use __iomem address space for IO
There are following warnings on unpatched code:
arch/x86/kernel/early_printk.c:198:32: warning: incorrect type in initializer (different address spaces)arch/x86/kernel/early_printk.c:198:32: expected void [noderef] <asn:2>*vaddrarch/x86/kernel/early_printk.c:198:32: got unsigned int [usertype] *<noident>arch/x86/kernel/early_printk.c:205:32: warning: incorrect type in initializer (different address spaces)arch/x86/kernel/early_printk.c:205:32: expected void [noderef] <asn:2>*vaddrarch/x86/kernel/early_printk.c:205:32: got unsigned int [usertype] *<noident>
---
v2:
- amend subject line
arch/x86/kernel/early_printk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/early_printk.c +2 -2
@@ -195,14 +195,14 @@ static __init void early_serial_init(char *s)#ifdef CONFIG_PCI static void mem32_serial_out (unsigned long addr,int offset,int value) { -u32 *vaddr = (u32 *)addr; +void __iomem *vaddr = (void __iomem *)addr;/* shift implied by pointer type */ writel (value, vaddr + offset); }static unsigned int mem32_serial_in (unsigned long addr,int offset) { -u32 *vaddr = (u32 *)addr; +void __iomem *vaddr = (void __iomem *)addr;/* shift implied by pointer type */ return readl (vaddr + offset); }
Signature · 1 line
2.5.3
Quoted 14 lines · Andy Shevchenko
There are following warnings on unpatched code:
arch/x86/kernel/early_printk.c:198:32: warning: incorrect type in initializer (different address spaces)arch/x86/kernel/early_printk.c:198:32: expected void [noderef]
<asn:2>*vaddrarch/x86/kernel/early_printk.c:198:32: got unsigned int [usertype]
*<noident>arch/x86/kernel/early_printk.c:205:32: warning: incorrect type in initializer (different address spaces)arch/x86/kernel/early_printk.c:205:32: expected void [noderef]
<asn:2>*vaddrarch/x86/kernel/early_printk.c:205:32: got unsigned int [usertype]
*<noident>
This one is wrong, sorry for noise.
Quoted 31 lines
Signed-off-by Andy Shevchenko <[email protected]>---
v2:
- amend subject linearch/x86/kernel/early_printk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/kernel/early_printk.c +2
-2@@ -195,14 +195,14 @@ static __init void early_serial_init(char *s)#ifdef CONFIG_PCI static void mem32_serial_out (unsigned long addr,int offset,int value) { -u32 *vaddr = (u32 *)addr; +void __iomem *vaddr = (void __iomem *)addr;/* shift implied by pointer type */ writel (value, vaddr + offset); }static unsigned int mem32_serial_in (unsigned long addr,int offset) { -u32 *vaddr = (u32 *)addr; +void __iomem *vaddr = (void __iomem *)addr;/* shift implied by pointer type */ return readl (vaddr + offset);}
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Andy,
arch/x86/kernel/early_printk.c static __init void early_serial_init(char *s) · line 200
Quoted 7 lines · Andy Shevchenko
#ifdef
CONFIG_PCI
static voidmem32_serial_out(unsigned long addr, int offset, int value){arch/x86/kernel/early_printk.c +1
-1-u32 *vaddr = (u32 *)addr; +void __iomem *vaddr = (void __iomem *)addr;/* shift implied by pointer type */ writel (value, vaddr + offset);
This is broken. Assume vaddr = 0x1000 and offset = 1
==> u32 *vaddr = 0x1000;
==> vaddr + offset = 0x1004
with your change
==> void __iomem *vaddr = 0x1000;
==> vaddr + offset = 0x1001
This comment is there for a reason:
Quoted 1 line
/* shift implied by pointer type */
Thanks,
tglx
Quoted 5 lines · Thomas Gleixner
Andy,
Quoted 2 lines · Andy Shevchenko
#ifdef
CONFIG_PCI
static void mem32_serial_out(unsigned long addr, int offset, int
Quoted 8 lines
value)
arch/x86/kernel/early_printk.c static __init void early_serial_init(char *s) · line 200
Quoted 5 lines
{
arch/x86/kernel/early_printk.c +1
-1-u32 *vaddr = (u32 *)addr; +void __iomem *vaddr = (void __iomem *)addr;/* shift implied by pointer type */ writel (value, vaddr + offset);This is broken. Assume vaddr =
0x1000and offset = 1
Yes, I noticed in reply to myself
http://www.spinics.net/lists/kernel/msg2094143.html
Tests were okay because platform I have is using 8-bit I/O.
Does it make sense to use the following approach?
void __iomem *vaddr = (void __iomem *)addr;
writel(value, vaddr + offset << 2);
Quoted 16 lines
==> u32 *vaddr =
0x1000;
==> vaddr + offset =0x1004with your change
==> void
__iomem*vaddr =0x1000;==> vaddr + offset =
0x1001This comment is there for a reason:
Quoted 1 line
/* shift implied by pointer type */Thanks,
tglx
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 18 lines · Andy Shevchenko
Quoted 5 lines · Thomas Gleixner
Andy,
Quoted 2 lines · Andy Shevchenko
#ifdef
CONFIG_PCI
static void mem32_serial_out(unsigned long addr, int offset, intQuoted 8 lines
value)
arch/x86/kernel/early_printk.c static __init void early_serial_init(char *s) · line 200
Quoted 5 lines
{
arch/x86/kernel/early_printk.c +1
-1-u32 *vaddr = (u32 *)addr; +void __iomem *vaddr = (void __iomem *)addr;/* shift implied by pointer type */ writel (value, vaddr + offset);This is broken. Assume vaddr =
0x1000and offset = 1Yes, I noticed in reply to myself
http://www.spinics.net/lists/kernel/msg2094143.html
Quoted 6 lines
Tests were okay because platform I have is using 8-bit I/O.
Does it make sense to use the following approach?
void
__iomem*vaddr = (void__iomem*)addr;
writel(value, vaddr + offset << 2);
What's wrong with: u32 __iomem *vaddr ?
Thanks,
tglx