All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] x86/early_printk: Use __iomem address space for IO
@ 2015-10-09 14:29 Andy Shevchenko
  2015-10-09 14:35 ` Andy Shevchenko
  2015-10-11 19:18 ` Thomas Gleixner
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-10-09 14:29 UTC (permalink / raw)
  To: linux-kernel, Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86
  Cc: 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>*vaddr
arch/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>*vaddr
arch/x86/kernel/early_printk.c:205:32:    got unsigned int [usertype] *<noident>

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2:
- amend subject line
 arch/x86/kernel/early_printk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index 076a4a7..77f2f5c 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -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);
 }
-- 
2.5.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/1] x86/early_printk: Use __iomem address space for IO
  2015-10-09 14:29 [PATCH v2 1/1] x86/early_printk: Use __iomem address space for IO Andy Shevchenko
@ 2015-10-09 14:35 ` Andy Shevchenko
  2015-10-11 19:18 ` Thomas Gleixner
  1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-10-09 14:35 UTC (permalink / raw)
  To: linux-kernel, Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86

On Fri, 2015-10-09 at 17:29 +0300, Andy Shevchenko wrote:
> 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>*vaddr
> arch/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>*vaddr
> arch/x86/kernel/early_printk.c:205:32:    got unsigned int [usertype] 
> *<noident>

This one is wrong, sorry for noise.

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2:
> - amend subject line
>  arch/x86/kernel/early_printk.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/early_printk.c 
> b/arch/x86/kernel/early_printk.c
> index 076a4a7..77f2f5c 100644
> --- a/arch/x86/kernel/early_printk.c
> +++ b/arch/x86/kernel/early_printk.c
> @@ -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);
>  }

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/1] x86/early_printk: Use __iomem address space for IO
  2015-10-09 14:29 [PATCH v2 1/1] x86/early_printk: Use __iomem address space for IO Andy Shevchenko
  2015-10-09 14:35 ` Andy Shevchenko
@ 2015-10-11 19:18 ` Thomas Gleixner
  2015-10-12  8:12   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2015-10-11 19:18 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Ingo Molnar, H . Peter Anvin, x86

Andy,

On Fri, 9 Oct 2015, Andy Shevchenko wrote:
>  #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);

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:
>  	/* shift implied by pointer type */

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/1] x86/early_printk: Use __iomem address space for IO
  2015-10-11 19:18 ` Thomas Gleixner
@ 2015-10-12  8:12   ` Andy Shevchenko
  2015-10-12  9:11     ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2015-10-12  8:12 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Ingo Molnar, H . Peter Anvin, x86

On Sun, 2015-10-11 at 21:18 +0200, Thomas Gleixner wrote:
> Andy,
> 
> On Fri, 9 Oct 2015, Andy Shevchenko wrote:
> >  #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);
> 
> This is broken. Assume vaddr = 0x1000 and 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);
 

> 
> ==>  u32 *vaddr = 0x1000;
> ==>  vaddr + offset = 0x1004
> 
> with your change
> 
> ==>  void __iomem *vaddr = 0x1000;
> 
> ==>  vaddr + offset = 0x1001
> 
> This comment is there for a reason:
> >       /* shift implied by pointer type */
> 
> Thanks,
> 
>         tglx

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/1] x86/early_printk: Use __iomem address space for IO
  2015-10-12  8:12   ` Andy Shevchenko
@ 2015-10-12  9:11     ` Thomas Gleixner
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2015-10-12  9:11 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Ingo Molnar, H . Peter Anvin, x86

On Mon, 12 Oct 2015, Andy Shevchenko wrote:
> On Sun, 2015-10-11 at 21:18 +0200, Thomas Gleixner wrote:
> > Andy,
> > 
> > On Fri, 9 Oct 2015, Andy Shevchenko wrote:
> > >  #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);
> > 
> > This is broken. Assume vaddr = 0x1000 and 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);

What's wrong with: u32 __iomem *vaddr ?

Thanks,

	tglx



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-12  9:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-09 14:29 [PATCH v2 1/1] x86/early_printk: Use __iomem address space for IO Andy Shevchenko
2015-10-09 14:35 ` Andy Shevchenko
2015-10-11 19:18 ` Thomas Gleixner
2015-10-12  8:12   ` Andy Shevchenko
2015-10-12  9:11     ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.