[Prev][Next][Index][Thread]

Re: BUG (?) in oskit lance driver



> From: "Jonathan S. Shapiro" <shap@eros-os.org>
> To: "Mike Hibler" <mike@fast.cs.utah.edu>, <oskit-users@fast.cs.utah.edu>
> Cc: <k-abe@cs.utah.edu>
> Subject: Re: BUG (?) in oskit lance driver
> Date: Sat, 25 Nov 2000 18:47:58 -0500
> 
> While I'm grateful for a VMware solution, this looks to me like a pretty
> fishy fix. It is really possible to have multiple lance cards on the same
> PCI bus, and the fix doesn't address that at all.
> 

Included is a fix that is more in the spirit of the Linux drivers (i.e.,
I stole it out of another linux driver :-)

> For the benefit of those of us who may end up writing OsKit drivers someday,
> would it be possible to provide an explanation of how the configuration
> logic in the Linux driver emulator discovers that a device has already been
> configured?
> 

Caveat: I am not an x86 or Linux expert.  I believe the OSKit logic is
similar to what Linux does: keep calling probe routines until nothing else
is found.  The driver probe routine is supposed to return a negative value
if no cards were found, 0 if something was found.  It appears to be the
responsibility of individual drivers to Do The Right Thing when called
multiple times.  The drivers I looked at do this by checking the IO port
space to see if the range in question has already been allocated.  If so,
the particluar card has been successfully probed in a previous call and
is skipped on this call.

For the lance driver it looks like someone hacked in the PCI support later
and didn't observe this rule.  Later versions of the Linux lance driver
fixed this.

Anyway, here is a diff vs. the released version (i.e., before the last
attempted fix):

Index: lance.c
===================================================================
RCS file: /n/fast/usr/lsrc/flux/CVS/oskit/linux/src/drivers/net/lance.c,v
retrieving revision 1.6
retrieving revision 1.8
diff -u -r1.6 -r1.8
--- lance.c	1999/11/11 00:53:24	1.6
+++ lance.c	2000/12/15 00:26:14	1.8
@@ -383,6 +383,11 @@
 
 			pci_irq_line = pdev->irq;
 			pci_ioaddr = pdev->base_address[0] & PCI_BASE_ADDRESS_IO_MASK;
+#ifdef OSKIT
+			/* Avoid already found cards from previous calls */
+			if (check_region(pci_ioaddr, LANCE_TOTAL_SIZE))
+				continue;
+#endif
 			/* PCI Spec 2.1 states that it is either the driver or PCI card's
 	 		 * responsibility to set the PCI Master Enable Bit if needed.
 			 *	(From Mark Stockton <marks@schooner.sys.hou.compaq.com>)
@@ -805,7 +810,11 @@
 		struct sk_buff *skb;
 		void *rx_buff;
 
+#ifdef OSKIT
+		skb = alloc_skb(PKT_BUF_SZ, GFP_ATOMIC);
+#else
 		skb = alloc_skb(PKT_BUF_SZ, GFP_DMA | gfp);
+#endif
 		lp->rx_skbuff[i] = skb;
 		if (skb) {
 			skb->dev = dev;