[PATCH] yenta resource allocation fix

Andreas Bombe
2001-08-26T23:01:16Z

This fixes the problem of the yenta_socket driver not allocating IO port
windows if they weren't already. This caused no ports to be available
to a inserted CardBus card which in turn made the tulip driver complain
since it can't run without IO ports.

I'm no expert on the PCI/CardBus bridge stuff, but let's see: The OR
operation on the range end register with 0xfff seems pretty bogus to me.
Also the "if (start && ..." was always true since start included the 32
bit IO flag. What my patch does is to mask out the IO flags on both
start and end if the resource is indeed an IO resource, which seems
correct to me.

Now everything works for me. If I had known the fix was so easy I would
never have bothered with pcmcia-cs. Well, there is a problem that it
only picks up every second card insertion, so I have to
insert/remove/insert for my card to be recognized, but then it works.

diff -ruN linux-2.4.orig/drivers/pcmcia/yenta.c linux-2.4/drivers/pcmcia/yenta.c
--- linux-2.4.orig/drivers/pcmcia/yenta.c Fri Jul 27 02:21:28 2001
+++ linux-2.4/drivers/pcmcia/yenta.c Sun Aug 26 23:26:17 2001
@@ -701,8 +701,14 @@
struct resource *root, *res;
u32 start, end;
u32 align, size, min, max;
+ u32 mask;
unsigned offset;

+ if (type & IORESOURCE_IO)
+ mask = PCI_CB_IO_RANGE_MASK;
+ else
+ mask = ~0U;
+
offset = 0x1c + 8*nr;
bus = socket->dev->subordinate;
res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr;
@@ -715,8 +721,8 @@
if (!root)
return;

- start = config_readl(socket, offset);
- end = config_readl(socket, offset+4) | 0xfff;
+ start = config_readl(socket, offset) & mask;
+ end = config_readl(socket, offset+4) & mask;