linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Dan Malek <dan@mvista.com>
Cc: paulus@linuxcare.com.au,
	Linux/PPC Development <linuxppc-dev@lists.linuxppc.org>
Subject: Re: __ioremap_at() in 2.4.0-test9-pre2
Date: Thu, 21 Sep 2000 16:03:26 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.10.10009211544591.375-100000@cassiopeia.home> (raw)
In-Reply-To: <39C9AFE2.25CB0ADA@mvista.com>


On Thu, 21 Sep 2000, Dan Malek wrote:
> > I think my basic point is that a setup where you can't do inb(n) to
> > read the byte at address n in PCI I/O space is broken.
>
> I agree.  I am not suggesting you shouldn't.  I'm just discussing
> what 'n' should be :-).

`n' is the offset as accepted by the bus bridge, being it a host bridge or a
PCI-PCI bridge, or a PCI-ISA bridge (with subtractive decoding (`claim all
accesses that are not claimed by any other device on the bus') for legacy I/O.

The first bridge (`host bridge 1') takes I/O addresses 0..n1-1, the next one
n1..n2, and so on.

> > We could do that too, we would just have to make sure that we assigned
> > PCI I/O addresses so that no two bridges had devices in the same 4k
> > range, then we could set up the virtual->physical mapping to give the
> > illusion of a single I/O space.
>
> I think we agree that we just use the PCI bridges to the best of
> their ability, and let the MMU do the reset.  There are combinations
> of this that are more efficient on some systems that others.  I have
> no illusion of requiring a single I/O space (that's what MMUs are for :-).

And how to access PCI I/O space from user space? There the MMU doesn't help,
since the user application (usually XFree86) just look at the BARs from
/proc/bus/pci/...

> > Huh???  the drivers won't have to be changed, they just go on doing
> > inb(pci_dev->resource[0].start) or whatever
>
> Ahhhh...OK....here we go...examples :-).  I contend that access is
> wrong...
>
> Somewhere (and I thought it was in that resource structure), you need
> the BAR of that device on it's PCI bus.  You also need something that
> indicates how that device is mapped through PCI bridges.  If
> 	pci_dev->resource[0].start is the BAR of the device
> this isn't likely to work on many platforms.  I believe what a
> device needs to do is something like:
>
> 	base = how_do_I_get_to(pci_dev, resource0);
> 	inb(base);
>
> Or, even better (if you don't know the spaces):
>
> 	requires_io = is_pcidev_io(pci_dev, resource0);
> 	base = how_do_I_get_to(pci_dev, resource0);
> 	if (requires_io)
> 		inb(base)
> 	else
> 		readb(base)

This is very similar to what many people already suggested on linux-kernel
years ago: inb() and friends should take an additional argument pci_dev *.

> Yes, you can map the PCI speces through the MMU and hack up the
> pci_dev resources to make the address work.  I believe you need to
> have this abstraction, not assume in/out or read/write will perform
> address computation, and have hooks into the platform specific
> support to efficiently "map" this as resources allow.

For kernel space. This doesn't work for user space, unless you mmap
/dev/pci_{io,mem}_space, which don't exist at the moment.

> You can extrapolate this into other busses, and I am sure somehow
> get something like the ISA serial port to return 0x3f8 (I memorized
> this now :-) for the PC, or whatever is appropriate for other systems.

Currently the serial driver relies on the arch-specific #define
SERIAL_PORT_DFNS to know which legacy ports to probe. This should at least
become machine-specific, to support PowerMacs.

BTW, I have Linus' tree only here, and I see it still has STD_COM_FLAGS for
ttyS[0-2] and STD_COM4_FLAGS for ttyS3. The difference between these is that
STD_COM_FLAGS contains ASYNC_SKIP_TEST to skip some presence detect. IIRC,
this was the reason serial.c found a bogus ttyS2 on my LongTrail. So touching
non-existent ports on non-PCs can give weird results...

> > inb(n) should do whatever is necessary to access address n in PCI I/O
> > space.
>
> Ummm...no :-).  inb is an x86 instruction and you have to use it on
> that platform.  It's a wart they have to live with.  I think Linux
> should have a isa_io() macro or something (that works like I want :-),
> but we have sort of implied inb/outb will do that for us....
>
> > I don't believe there are any systems with multiple ISA buses.  That
> > would be an abomination. :-)
>
> How about microchannel :-).

Microchannel is something different.

inb() resp. readb() and friends are explicitly meant for PCI I/O resp. memory
space only.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

  reply	other threads:[~2000-09-21 14:03 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-17 18:59 __ioremap_at() in 2.4.0-test9-pre2 Geert Uytterhoeven
2000-09-19  3:59 ` Paul Mackerras
2000-09-19  5:56   ` Michel Lanners
2000-09-19 14:28   ` Dan Malek
2000-09-19 18:31     ` Roman Zippel
2000-09-19 20:09       ` Dan Malek
2000-09-19 23:42         ` Roman Zippel
2000-09-20  0:10           ` Dan Malek
2000-09-20 17:18             ` Roman Zippel
2000-09-20 18:11               ` Dan Malek
2000-09-20 20:22                 ` Roman Zippel
2000-09-20 20:41                 ` David Edelsohn
2000-09-21  2:16                   ` Dan Malek
2000-09-21  2:26                     ` David Edelsohn
2000-09-21  2:40                       ` Dan Malek
2000-09-21  3:53                         ` David Edelsohn
2000-09-19 22:06   ` Matt Porter
2000-09-19 22:58     ` Paul Mackerras
2000-09-20  6:12       ` Matt Porter
2000-09-20 12:15         ` Geert Uytterhoeven
2000-09-20 23:08         ` Paul Mackerras
2000-09-21 20:12           ` Matt Porter
2000-09-20  8:34       ` Roman Zippel
2000-09-20 22:54         ` Paul Mackerras
2000-09-20 15:56       ` Dan Malek
2000-09-20 23:22         ` Paul Mackerras
2000-09-21  2:13           ` Dan Malek
2000-09-21  2:35             ` Paul Mackerras
2000-09-21  3:57               ` Dan Malek
2000-09-21  5:06                 ` Paul Mackerras
2000-09-21  6:51                   ` Dan Malek
2000-09-21 14:03                     ` Geert Uytterhoeven [this message]
2000-09-21 22:40                       ` Benjamin Herrenschmidt
2000-09-22  3:53                       ` Dan Malek
2000-09-22 11:58                         ` Geert Uytterhoeven
2000-09-22 18:46                           ` Dan Malek
2000-09-22 20:06                             ` Frank Rowand
2000-09-23 21:38                             ` Matt Porter
2000-09-21 20:22                     ` Matt Porter
2000-09-22  3:49                     ` Paul Mackerras
2000-09-22  4:16                       ` Dan Malek
2000-09-23 12:34                       ` Geert Uytterhoeven
2000-09-27 10:37                         ` Benjamin Herrenschmidt
2000-09-28  9:59                           ` Geert Uytterhoeven
2000-09-28 19:19                             ` Benjamin Herrenschmidt
2000-09-28 23:33                               ` Benjamin Herrenschmidt
2000-09-29  5:08                               ` Dan Malek
2000-09-29 11:37                               ` Geert Uytterhoeven
2000-09-29 17:12                                 ` Kostas Gewrgiou
2000-09-29 17:18                                 ` Benjamin Herrenschmidt
2000-09-29 21:35                                 ` Michel Lanners
2000-09-30  0:11                                 ` Matt Porter
2000-09-29  0:22                             ` Paul Mackerras
2000-09-29  0:40                               ` Benjamin Herrenschmidt
2000-09-29  1:17                                 ` Paul Mackerras
2000-09-29  4:22                                   ` Dan Malek
2000-09-29  4:29                               ` Dan Malek
2000-09-29  4:36                                 ` Paul Mackerras
2000-09-29  5:40                                   ` Dan Malek
2000-09-29 19:07                                   ` Frank Rowand
2000-09-30  1:39                                     ` Paul Mackerras
2000-09-30 22:50                                       ` Frank Rowand
2000-10-01  1:09                                         ` Dan Malek
2000-10-01  8:16                                           ` Paul Mackerras
2000-10-01 21:30                                             ` Dan Malek
2000-10-01 22:50                                               ` Paul Mackerras
2000-10-02  9:04                                                 ` Dan Malek
2000-09-28 23:24                           ` Frank Rowand
2000-09-21 13:44                   ` Geert Uytterhoeven
2000-09-21 22:41                     ` Benjamin Herrenschmidt
2000-09-22 21:59                       ` Michel Lanners
2000-09-20 12:08     ` Geert Uytterhoeven
2000-09-20 16:31       ` Matt Porter
  -- strict thread matches above, loose matches on Subject: below --
2000-09-21  7:30 Iain Sandoe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.10.10009211544591.375-100000@cassiopeia.home \
    --to=geert@linux-m68k.org \
    --cc=dan@mvista.com \
    --cc=linuxppc-dev@lists.linuxppc.org \
    --cc=paulus@linuxcare.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).