linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
[parent not found: <20030911192550.7dfaf08c.ak@suse.de.suse.lists.linux.kernel>]
* Re: Memory mapped IO vs Port IO
@ 2003-09-12 16:41 John Bradford
  2003-09-12 21:52 ` Mike Fedyk
  0 siblings, 1 reply; 27+ messages in thread
From: John Bradford @ 2003-09-12 16:41 UTC (permalink / raw)
  To: anthony.truong, linux-kernel; +Cc: jamie, willy

> > My claim is basically:
> > 
> > Change everybody who currently does
> > 
> > #ifdef CONFIG_MMIO
> >         writel(... )
> >         readl(...)
> > #else
> >         outl( ... ) 
> >         inl ( ...) 
> > #endif
> > 
> > to 
> >         if (dev->mmio) { 
> >                 writel(); 
> >                 real();
> >         } else { 
> >                 outl();
> >                 inl();
> >         } 
> > 
> > and you will have a hard time to benchmark the difference on any non
> > ancient system
> > in actual driver operation.

Or an embedded system, maybe?

At the end of the day, it still means loosing a tiny amount of
performance just to make it easier for distributions to have one
generic kernel.  There is nothing wrong with that, but why force it on
systems that are not running a generic kernel?

What's wrong with:

#ifdef CONFIG_MMIO
	writel(... );
        readl(... );
#endif
#ifdef CONFIG_NO_MMIO
	outl(... );
	inl(...);
#endif
#ifdef CONFIG_DONT_CARE_MMIO
	if (dev->mmio) {	
		writel(... );
		readl(... );
	} else {
		outl(... );
		inl(... );
	}
#endif

Although I'm dubious of having a global switch for MMIO anyway.

> Wouldn't it be better if we set the IN and OUT function pointers to the
> right functions during driver init. based on the setting of dev->mmio.
> And throughout the driver, we just call the IN and OUT functions by
> their pointers.  Then we don't have to do if (dev->mmio) every time.
> It's similar to the concept of virtual member function in C++.

It's neater, but still means bloat, however small.

I know we're talking a few bytes here and there, but embedded systems
really care about them.

John.

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Memory mapped IO vs Port IO
@ 2003-09-11 16:01 Matthew Wilcox
  2003-09-11 16:14 ` Måns Rullgård
  2003-09-11 16:14 ` Jesse Barnes
  0 siblings, 2 replies; 27+ messages in thread
From: Matthew Wilcox @ 2003-09-11 16:01 UTC (permalink / raw)
  To: linux-kernel


There's a lot of drivers in the tree that allow you to access the device
either via IO port space or IO mem space.  Here's some examples:

config SCSI_SYM53C8XX_IOMAPPED
        bool "use normal IO"
        depends on SCSI_SYM53C8XX_2
        help
          If you say Y here, the driver will preferently use normal IO
	  rather than memory mapped IO.

config 8139TOO_PIO
        bool "Use PIO instead of MMIO"
        depends on 8139TOO
        help
          This instructs the driver to use programmed I/O ports (PIO) instead
          of PCI shared memory (MMIO).  This can possibly solve some problems
          in case your mainboard has memory consistency issues.  If unsure,
          say N.

config TULIP_MMIO
        bool "Use PCI shared mem for NIC registers"
        depends on TULIP
        help
          Use PCI shared memory for the NIC registers, rather than going through
          the Tulip's PIO (programmed I/O ports).  Faster, but could produce
          obscure bugs if your mainboard has memory controller timing issues.
          If in doubt, say N.

As you can see, everybody asks the question differently, and sometimes
you should answer Y and sometimes N to get MMIO.  There are other drivers
which don't ask the question at all and you have to edit the .c file to
turn it on or off.  I'll also note the acronym `PIO' is ambiguous --
sometimes it refers to Port IO and sometimes to Programmed IO (which
can be a memory access).

Personally, when I'm configuring a new kernel for a machine, I don't
want to learn about the suboptions for each device -- I've got dozens of
other things to configure right.  My favourite solution to this problem
wuld be to ask the question once only and have it apply to all devices:

config MMIO
	bool "Prefer Memory-mapped I/O accesses over Port I/O"
	help
	  Many devices are accessible via both memory mapped I/O and
	  port I/O.  Say Y here to access them via the slightly faster
	  memory mapped I/O method.  If you experience problems, you may
	  wish to say N here.

If that's not acceptable, can I suggest that we at least ask a standard
question?

config WWWW_MMIO
	bool "Use Memory mapped I/O in preference to Port I/O"
	depends on WWWW
	help
	  This device's registers can be accessed by either memory
	  mapped I/O or port I/O.  Memory mapped I/O is faster, so you
	  are advised to say Y here.

(yes, we could wordsmith these questions into the ground; the key point
of this mail is whether we ask one question at the start of configuration
or whether we ask one question per device.)

-- 
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk

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

end of thread, other threads:[~2003-09-13  4:01 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20030911160116.GI21596@parcelfarce.linux.theplanet.co.uk.suse.lists.linux.kernel>
2003-09-11 16:17 ` Memory mapped IO vs Port IO Andi Kleen
2003-09-11 16:25   ` Matthew Wilcox
2003-09-11 16:31     ` Andi Kleen
2003-09-11 16:42       ` Matthew Wilcox
2003-09-11 17:12       ` Jamie Lokier
2003-09-11 17:25         ` Andi Kleen
2003-09-12  1:39           ` jw schultz
2003-09-12 16:10           ` Anthony Dominic Truong
2003-09-12 16:22             ` Jamie Lokier
2003-09-12 16:27             ` Jesse Barnes
2003-09-12 17:48               ` Jesse Barnes
2003-09-11 17:13   ` Jamie Lokier
     [not found] ` <20030911161450.GA23536@sgi.com.suse.lists.linux.kernel>
2003-09-11 16:20   ` Andi Kleen
     [not found] <20030911192550.7dfaf08c.ak@suse.de.suse.lists.linux.kernel>
     [not found] ` <1063308053.4430.37.camel@huykhoi.suse.lists.linux.kernel>
     [not found]   ` <20030912162713.GA4852@sgi.com.suse.lists.linux.kernel>
     [not found]     ` <20030912174807.GA629@sgi.com.suse.lists.linux.kernel>
2003-09-12 18:00       ` Andi Kleen
2003-09-12 18:04         ` Jesse Barnes
2003-09-12 18:09           ` Andi Kleen
2003-09-12 18:11         ` Tim Hockin
2003-09-12 18:24           ` Jesse Barnes
2003-09-12 18:29             ` Andi Kleen
2003-09-12 18:58             ` Martin J. Bligh
2003-09-12 19:51               ` Jesse Barnes
2003-09-12 16:41 John Bradford
2003-09-12 21:52 ` Mike Fedyk
2003-09-13  4:01   ` Mike Fedyk
  -- strict thread matches above, loose matches on Subject: below --
2003-09-11 16:01 Matthew Wilcox
2003-09-11 16:14 ` Måns Rullgård
2003-09-11 16:14 ` Jesse Barnes

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).