linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* writel(), readl() in <asm-ppc/io.h>
@ 2005-08-13  1:11 Shawn Jin
  2005-08-13  3:33 ` Matt Porter
  0 siblings, 1 reply; 8+ messages in thread
From: Shawn Jin @ 2005-08-13  1:11 UTC (permalink / raw)
  To: ppcembed

Hi,

In <asm-ppc/io.h>, writew(), readw(), writel(), and readl() are
defined to little endian access for all platforms unless either
CONFIG_APUS or CONFIG_8260_PCI9 is defined.

Why? Aren't they correct in big endian systems, are they? Maybe I miss
something here.

Regards,
-Shawn.

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

* Re: writel(), readl() in <asm-ppc/io.h>
  2005-08-13  1:11 writel(), readl() in <asm-ppc/io.h> Shawn Jin
@ 2005-08-13  3:33 ` Matt Porter
  2005-08-14  3:56   ` Shawn Jin
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Porter @ 2005-08-13  3:33 UTC (permalink / raw)
  To: Shawn Jin; +Cc: ppcembed

On Fri, Aug 12, 2005 at 06:11:14PM -0700, Shawn Jin wrote:
> Hi,
> 
> In <asm-ppc/io.h>, writew(), readw(), writel(), and readl() are
> defined to little endian access for all platforms unless either
> CONFIG_APUS or CONFIG_8260_PCI9 is defined.
> 
> Why? Aren't they correct in big endian systems, are they? Maybe I miss
> something here.

I'm not sure what your qustion is but I'll take a stab at an answer. :)

read*()/write*() are accessors for PCI and PCI only.  PCI is little
endian. PPC is big endian.  All platforms must byte swap on access
to PCI memory space except in special cases.  The two exceptions
must byte swap in hardware. Looks like it is due to errata in the
8260 PCI bridge case. APUS is probably byte swapping in hardware
because APUS is simply odd.

-Matt

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

* Re: writel(), readl() in <asm-ppc/io.h>
  2005-08-13  3:33 ` Matt Porter
@ 2005-08-14  3:56   ` Shawn Jin
  2005-08-14  4:25     ` Eugene Surovegin
                       ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Shawn Jin @ 2005-08-14  3:56 UTC (permalink / raw)
  To: Matt Porter; +Cc: ppcembed

> read*()/write*() are accessors for PCI and PCI only.  PCI is little

If read*()/write*() are designed for PCI access only as you claimed,
that explains why they call in/out_leXX() funcitons.

The problem is that read*()/write*() are misused in some places, e.g.,
serial drivers such as serial8250. The serial_in() and serial_out()
call read*() and write*() respectively. So what's your recommendation
in such a case?

Regards,
-Shawn.

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

* Re: writel(), readl() in <asm-ppc/io.h>
  2005-08-14  3:56   ` Shawn Jin
@ 2005-08-14  4:25     ` Eugene Surovegin
  2005-08-14 18:16       ` Shawn Jin
  2005-08-14 16:14     ` Matt Porter
  2005-08-14 16:36     ` Arthur Othieno
  2 siblings, 1 reply; 8+ messages in thread
From: Eugene Surovegin @ 2005-08-14  4:25 UTC (permalink / raw)
  To: Shawn Jin; +Cc: ppcembed

On Sat, Aug 13, 2005 at 08:56:50PM -0700, Shawn Jin wrote:
> > read*()/write*() are accessors for PCI and PCI only.  PCI is little
> 
> If read*()/write*() are designed for PCI access only as you claimed,
> that explains why they call in/out_leXX() funcitons.
> 
> The problem is that read*()/write*() are misused in some places, e.g.,
> serial drivers such as serial8250. The serial_in() and serial_out()
> call read*() and write*() respectively. So what's your recommendation
> in such a case?

Why do you think this is a problem? Why do you think they are 
misused? Please explain. 

FYI, there _are_ serial PCI cards.

-- 
Eugene

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

* Re: writel(), readl() in <asm-ppc/io.h>
  2005-08-14  3:56   ` Shawn Jin
  2005-08-14  4:25     ` Eugene Surovegin
@ 2005-08-14 16:14     ` Matt Porter
  2005-08-14 16:36     ` Arthur Othieno
  2 siblings, 0 replies; 8+ messages in thread
From: Matt Porter @ 2005-08-14 16:14 UTC (permalink / raw)
  To: Shawn Jin; +Cc: ppcembed

On Sat, Aug 13, 2005 at 08:56:50PM -0700, Shawn Jin wrote:
> > read*()/write*() are accessors for PCI and PCI only.  PCI is little
> 
> If read*()/write*() are designed for PCI access only as you claimed,
> that explains why they call in/out_leXX() funcitons.
> 
> The problem is that read*()/write*() are misused in some places, e.g.,
> serial drivers such as serial8250. The serial_in() and serial_out()
> call read*() and write*() respectively. So what's your recommendation
> in such a case?

Keep misusing them. There's no generic accessors for memory mapped
I/O.  People just started using them in generic drivers because they
are convenient. I use the the __raw_read*() for non byte swapped access
(or in/outbe32() depending on my memory barrier requirements.

Also, portions of the 8250 serial driver using readl/writel are
assuming that the serial port in on PCI or other little endian bus.
readb/writeb usage doesn't matter in that driver.

-Matt

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

* Re: writel(), readl() in <asm-ppc/io.h>
  2005-08-14  3:56   ` Shawn Jin
  2005-08-14  4:25     ` Eugene Surovegin
  2005-08-14 16:14     ` Matt Porter
@ 2005-08-14 16:36     ` Arthur Othieno
  2005-08-14 18:53       ` Shawn Jin
  2 siblings, 1 reply; 8+ messages in thread
From: Arthur Othieno @ 2005-08-14 16:36 UTC (permalink / raw)
  To: Shawn Jin; +Cc: ppcembed

On Sat, Aug 13, 2005 at 08:56:50PM -0700, Shawn Jin wrote:
> > read*()/write*() are accessors for PCI and PCI only.  PCI is little
> 
> If read*()/write*() are designed for PCI access only as you claimed,
> that explains why they call in/out_leXX() funcitons.
> 
> The problem is that read*()/write*() are misused in some places, e.g.,
> serial drivers such as serial8250. The serial_in() and serial_out()
> call read*() and write*() respectively. So what's your recommendation
> in such a case?
 
See here for the gory details:

  http://lwn.net/Articles/102232/
  http://lwn.net/Articles/132804/

	Arthur

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

* Re: writel(), readl() in <asm-ppc/io.h>
  2005-08-14  4:25     ` Eugene Surovegin
@ 2005-08-14 18:16       ` Shawn Jin
  0 siblings, 0 replies; 8+ messages in thread
From: Shawn Jin @ 2005-08-14 18:16 UTC (permalink / raw)
  To: Shawn Jin, ppcembed

> > The problem is that read*()/write*() are misused in some places, e.g.,
> > serial drivers such as serial8250. The serial_in() and serial_out()
> > call read*() and write*() respectively. So what's your recommendation
> > in such a case?
>=20
> Why do you think this is a problem? Why do you think they are
> misused? Please explain.

IMHO, serial_in() and serial_out() should be able to handle all the
possilbilities. But the current implementation cannot achieve this by
simply calling read*() and write*() in the case that UART control
registers are 32-bit or 16-bit wide and can only be acessed in 32/16
bits in some big endian systems. As Matt pointed out before, read*()
and write*() are designed for PCI access only.

Regards,
-Shawn.

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

* Re: writel(), readl() in <asm-ppc/io.h>
  2005-08-14 16:36     ` Arthur Othieno
@ 2005-08-14 18:53       ` Shawn Jin
  0 siblings, 0 replies; 8+ messages in thread
From: Shawn Jin @ 2005-08-14 18:53 UTC (permalink / raw)
  To: Arthur Othieno; +Cc: ppcembed

>   http://lwn.net/Articles/132804/

This is what exactly I want. Thanks for the URL.

-Shawn.

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

end of thread, other threads:[~2005-08-14 18:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-13  1:11 writel(), readl() in <asm-ppc/io.h> Shawn Jin
2005-08-13  3:33 ` Matt Porter
2005-08-14  3:56   ` Shawn Jin
2005-08-14  4:25     ` Eugene Surovegin
2005-08-14 18:16       ` Shawn Jin
2005-08-14 16:14     ` Matt Porter
2005-08-14 16:36     ` Arthur Othieno
2005-08-14 18:53       ` Shawn Jin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).