Skip to contentSkip to conversation

yenta resource allocation fix

PATCH New Andreas Bombe 1 participant 1 message Aug 26, 2001 Pcmcia

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 yenta resource allocation fix

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.

drivers/pcmcia/yenta.c +8 -2
diff -ruN linux-2.4.orig/drivers/pcmcia/yenta.c linux-2.4/drivers/pcmcia/yenta.c
@@ -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;
 	if (start && end > start) {
 		res->start = start;
 		res->end = end;
Signature · 1 line
Andreas E. Bombe <[email protected]>    DSA key 0x04880A44