Re: EHCI: mtools stuck in state 'physrd' or panic

2005-06-26 Thread Stefan Walter
FYI: I have just sent a PR for this problem.

http://www.freebsd.org/cgi/query-pr.cgi?pr=82660

Stefan
-- 
No reading beyond this point


pgpnIhmnGEEx6.pgp
Description: PGP signature


Re: EHCI: mtools stuck in state 'physrd' or panic

2005-06-26 Thread Ian Dowse
In message [EMAIL PROTECTED], Stefan Walter write
s:
FYI: I have just sent a PR for this problem.

http://www.freebsd.org/cgi/query-pr.cgi?pr=82660

OpenBSD have a workaround for problems with VIA EHCI controllers
that can cause the hanging symptoms you describe. Below is a patch
that implements their change in FreeBSD's driver. Could you try it
to see if it helps?

Thanks,

Ian

Index: sys/dev/usb/ehci.c
===
RCS file: /dump/FreeBSD-CVS/src/sys/dev/usb/ehci.c,v
retrieving revision 1.14.2.9
diff -u -r1.14.2.9 ehci.c
--- sys/dev/usb/ehci.c  31 Mar 2005 19:47:11 -  1.14.2.9
+++ sys/dev/usb/ehci.c  26 Jun 2005 16:21:11 -
@@ -155,6 +155,7 @@
 Static voidehci_idone(struct ehci_xfer *);
 Static voidehci_timeout(void *);
 Static voidehci_timeout_task(void *);
+Static voidehci_intrlist_timeout(void *);
 
 Static usbd_status ehci_allocm(struct usbd_bus *, usb_dma_t *, u_int32_t);
 Static voidehci_freem(struct usbd_bus *, usb_dma_t *);
@@ -491,6 +492,7 @@
EOWRITE4(sc, EHCI_ASYNCLISTADDR, sqh-physaddr | EHCI_LINK_QH);
 
usb_callout_init(sc-sc_tmo_pcd);
+   usb_callout_init(sc-sc_tmo_intrlist);
 
lockinit(sc-sc_doorbell_lock, PZERO, ehcidb, 0, 0);
 
@@ -694,6 +696,11 @@
ehci_check_intr(sc, ex);
}
 
+   /* Schedule a callout to catch any dropped transactions. */
+   if ((sc-sc_flags  EHCI_SCFLG_LOSTINTRBUG) 
+   !LIST_EMPTY(sc-sc_intrhead))
+   usb_callout(sc-sc_tmo_intrlist, hz, ehci_intrlist_timeout, sc);
+
 #ifdef USB_USE_SOFTINTR
if (sc-sc_softwake) {
sc-sc_softwake = 0;
@@ -942,6 +949,7 @@
EOWRITE4(sc, EHCI_USBINTR, sc-sc_eintrs);
EOWRITE4(sc, EHCI_USBCMD, 0);
EOWRITE4(sc, EHCI_USBCMD, EHCI_CMD_HCRESET);
+   usb_uncallout(sc-sc_tmo_intrlist, ehci_intrlist_timeout, sc);
usb_uncallout(sc-sc_tmo_pcd, ehci_pcd_enable, sc);
 
 #if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -2701,6 +2708,30 @@
splx(s);
 }
 
+
+/*
+ * Some EHCI chips from VIA seem to trigger interrupts before writing back the
+ * qTD status, or miss signalling occasionally under heavy load.  If the host
+ * machine is too fast, we we can miss transaction completion - when we scan
+ * the active list the transaction still seems to be active.  This generally
+ * exhibits itself as a umass stall that never recovers.
+ *
+ * We work around this behaviour by setting up this callback after any softintr
+ * that completes with transactions still pending, giving us another chance to
+ * check for completion after the writeback has taken place.
+ */
+void
+ehci_intrlist_timeout(void *arg)
+{
+   ehci_softc_t *sc = arg;
+   int s = splusb();
+
+   DPRINTFN(3, (ehci_intrlist_timeout\n));
+   usb_schedsoftintr(sc-sc_bus);
+
+   splx(s);
+}
+
 //
 
 Static usbd_status
Index: sys/dev/usb/ehci_pci.c
===
RCS file: /dump/FreeBSD-CVS/src/sys/dev/usb/ehci_pci.c,v
retrieving revision 1.14.2.2
diff -u -r1.14.2.2 ehci_pci.c
--- sys/dev/usb/ehci_pci.c  13 Jun 2005 09:00:19 -  1.14.2.2
+++ sys/dev/usb/ehci_pci.c  26 Jun 2005 16:21:11 -
@@ -303,6 +303,10 @@
return ENXIO;
}
 
+   /* Enable workaround for dropped interrupts as required */
+   if (pci_get_vendor(self) == PCI_EHCI_VENDORID_VIA)
+   sc-sc_flags |= EHCI_SCFLG_LOSTINTRBUG;
+
/*
 * Find companion controllers.  According to the spec they always
 * have lower function numbers so they should be enumerated already.
Index: sys/dev/usb/ehcivar.h
===
RCS file: /dump/FreeBSD-CVS/src/sys/dev/usb/ehcivar.h,v
retrieving revision 1.4.2.4
diff -u -r1.4.2.4 ehcivar.h
--- sys/dev/usb/ehcivar.h   22 Mar 2005 00:56:54 -  1.4.2.4
+++ sys/dev/usb/ehcivar.h   26 Jun 2005 16:21:11 -
@@ -93,6 +93,7 @@
 #define EHCI_COMPANION_MAX 8
 
 #define EHCI_SCFLG_DONEINIT0x0001  /* ehci_init() has been called. */
+#define EHCI_SCFLG_LOSTINTRBUG 0x0002  /* workaround for VIA chipsets */
 
 typedef struct ehci_softc {
struct usbd_bus sc_bus; /* base device */
@@ -149,6 +150,7 @@
struct lock sc_doorbell_lock;
 
usb_callout_t sc_tmo_pcd;
+   usb_callout_t sc_tmo_intrlist;
 
device_ptr_t sc_child;  /* /dev/usb# device */

 
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: EHCI: mtools stuck in state 'physrd' or panic

2005-06-26 Thread Stefan Walter
Hi,

Ian Dowse, 26.06.05, 18:42h CEST:

 OpenBSD have a workaround for problems with VIA EHCI controllers
 that can cause the hanging symptoms you describe. Below is a patch
 that implements their change in FreeBSD's driver. Could you try it
 to see if it helps?

I just tried, but unfortunately it didn't help. I have exactly the same
symptoms with the patch applied.

Thanks anyway,
Stefan


pgpdEwMgsAYdh.pgp
Description: PGP signature


EHCI: mtools stuck in state 'physrd' or panic

2005-06-24 Thread Stefan Walter
Hi,

I just updated to this morning's RELENG_5 and thought I'd give USB 2.0 a
try to speed up data exchange with my USB sticks. The controller is
correctly identified, it seems:

ehci0: VIA VT6202 USB 2.0 controller mem 0xdbfdf700-0xdbfdf7ff irq 3 at 
device 16.3 on pci0

When plugging in a USB stick, it is correctly identified, too:

umass0: USB Flash Disk, rev 2.00/2.00, addr 2
da2 at umass-sim0 bus 0 target 0 lun 0
da2:  USB BAR 2.00 Removable Direct Access SCSI-2 device 
da2: 40.000MB/s transfers
da2: 124MB (255744 512 byte sectors: 64H 32S/T 124C)

I can also list the content of the FAT filesystem with mtools' mdir
command. When trying to copy a file from the stick to a local filesystem,
however, mcopy is almost immediately stuck in state physrd (according to
top(1)) after copying a varying number of bytes (between 100 and 2200 KB
is what I've seen so far). I cannot kill the mtools process, but pulling
out the USB stick helps - it panics after a few times of doing that,
though.

I thought it might have to do with IRQ sharing first, but according to
vmstat -i and dmesg, ehci0 doesn't share its IRQ with anything else.

I know that the ehci(4) man page says the driver is not finished and quite
buggy, but that doesn't mean I shouldn't report a problem, right? ;)

Any ideas?

Stefan


pgpuFhzD1g7Qh.pgp
Description: PGP signature


Re: EHCI: mtools stuck in state 'physrd' or panic

2005-06-24 Thread Mike Tancsa

At 08:50 AM 24/06/2005, Stefan Walter wrote:

I can also list the content of the FAT filesystem with mtools' mdir
command. When trying to copy a file from the stick to a local filesystem,
however, mcopy is almost immediately stuck in state physrd (according to
top(1)) after copying a varying number of bytes (between 100 and 2200 KB
is what I've seen so far). I cannot kill the mtools process, but pulling
out the USB stick helps - it panics after a few times of doing that,
though.


If you reformat the USB stick with UFS2, does IO still hang the box ?

---Mike 


___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: EHCI: mtools stuck in state 'physrd' or panic

2005-06-24 Thread Stefan Walter
Mike Tancsa in gmane.os.freebsd.stable:

 If you reformat the USB stick with UFS2, does IO still hang the box ?

I haven't tried that, but instead tried to just dump the whole USB stick
to a file with dd if=/dev/da2 of=stickimage bs=1024. The dd process also
hung in state physrd eventually, and about a minute after pulling out
the USB stick the system panic'd.

Furthermore, I tried the same (both mcopy and dd) on my notebook (Centrino
- Intel ICH4 chipset), which didn't have ehci in its kernel until then,
either. It worked flawlessly, multiple times.

Stefan
-- 
No reading beyond this point


pgpdMFKJF869g.pgp
Description: PGP signature