[RFC] setting resources available to pcmcia

Russell King rmk at arm.linux.org.uk
Thu Jun 12 23:12:45 BST 2003

On Thu, Jun 12, 2003 at 03:46:20PM -0400, Pavel Roskin wrote:
> I don't understand that.  I see no reason for PCMCIA to be different from
> all other buses, which can be configured completely in the kernel space.

Take a moment to think about these cases.  They're certainly not the
only ones, but they're the ones that I know will definitely cause
problems if/when they are encountered:

- ISA NE2K card at 0x300
- i82365-based PCMCIA controller with PCMCIA network inserted
- ISA NE2K card driver built as a module

You need to ensure that PCMCIA does not use the 0x300-0x31f region.  If
you happen use it, you'll clash with the ISA card.  Your machine locks
solid requiring a power cycle.

- ISA NE2K card at 0x300
- PCI-based PCMCIA controller with PCMCIA network inserted
- ISA NE2K card driver built as a module

This works, since the PCMCIA controller will claim the accesses before
they go anywhere near the bus _as long as_ the PCMCIA card is inserted.
If you unplug it and your driver makes an access (eg, due to a pending
interrupt) you hit the NE2K card.  Your machine locks solid requiring
a power cycle.

In both of these situations, the resources used by the ISA NE2K card will
only appear once the NE2K driver is loaded.  Another way around the problem
would be to use the reserve= parameter to reserve the ISA NE2K region.
That unfortunately prevents the ISA driver getting the resource, and at
that point you might as well discard the card.

I'm sure Alan Cox can provide some further (and probably more credible)
illustrations. 8)

> I can mount the root filesystem over NFS using a PCI network card, but not
> a PCMCIA card unless I use an initial ramdrive.  It may sound like a bad
> idea, but some embedded devices may need to use a PCMCIA card because
> there are no better connectors on the board or because only PCMCIA cards
> support the necessary protocol (e.g. GPRS).

I agree in the static windowed socket case - there should be nothing
which can clash with them, and I hope we'll move in a direction where
these can be used without cardmgr or any setup at all.

> The user can take control of the devices later.

... unless the resources PCMCIA decides to use need to be reallocated
somewhere else because there's something the user knows about the system
which the kernel doesn't.

> > b) new mode [requires new userspace helper]
> >
> > The resources are set by passing some arguments to sysfs files. To
> > even create the files neccessary to fill these arguments to the
> > kernel, another sysfs file will need to be echo'ed 1
> > (e.g. pcmcia_set_resources ); after all is done a command "echo 1 >
> > pcmcia_start" is issued [1 to pcmcia_stop will be called upon
> > shutdown], and then ds.c may start doing all sorts of wonderful stuff.
> Oh, please!  Even microkernel OSes handle resources in the microkernel.
> It seems to me that you are trying to replace cardmgr without replacing
> the broken model behind it.

The Linux resource layer does not, and I believe can never accurately
describe the resource usage situation.  To illustrate this, let me take
an example.  VGA cards.  In addition to the standard VGA registers, they
make use of a range of scattered IO addresses like:

0x0102, 0x42e8, 0x46e8, 0x4ae8, 0x82e8, 0x86e8, 0x8ae8, 0x8ee8, 0x92e8,
0x96e8, 0x9ae8, 0x9ee8, 0xa2e8, 0xa6e8, 0xaae8, 0xaee8, 0xb2e8, 0xb6e8,
0xbae8, 0xbee8, 0xe2e8, 0xe2ea, 0x8180 - 0x81a0, 0x81c0-0x81fc,

Bear in mind that these addresses tend to be card specific, so is not
an exhaustive list.

Now, plug such a card into Linux, and what do you see in /proc/ioport?

03c0-03df : vga+

and that's it; we don't have the full resource usage information.  It
follows that the Linux resource subsystem can not be relied upon when
allocating ISA resources.

Lets suppose you had a modem card, which had 10-bit address decoding,
and wanted to use an offset of 0x3f8, 0x2f8, 0x3e8, 0x2e8.  I have
such a card.  How can we be sure we won't hit a VGA port, eg 0x42e8?

How do we reliably handle allocation of PCI resources?  Since these
VGA resources are found reflecting the 0x100-0x3ff modulo 1K regions, we
simply avoid all of them.  We can't do that with PCMCIA, because cards
specify offset + number of address lines, and we have to use one of the
card supported offsets.

Note that I'm mostly repeating information here that I've gained over the
years from various discussions with people.

Russell King (rmk at arm.linux.org.uk)                The developer of ARM Linux

More information about the linux-pcmcia mailing list