Bug 67301 - [uftdi] [panic] RTS and system panic
Summary: [uftdi] [panic] RTS and system panic
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 5.2-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-usb (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-28 18:00 UTC by Mike Durian
Modified: 2018-03-04 18:38 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Durian 2004-05-28 18:00:46 UTC
	I've got two parts to this PR.  First, a patch to add support
	for Intrepid Control Systems' ValueCAN CAN bus interface.
	It uses a FTDI interface and will look like a ucom device
	when the attached USB product/vendor patch is applied.

	The second part is a bug that results in a system panic.
	When I try to execute the following user code to clear RTS
	in the ValueCAN device, I get a panic.  Here is the code
	snippet.

        /* XXX This panics the system */
        com_state &= ~TIOCM_RTS;
        if (ioctl(fd, TIOCMSET, &com_state) == -1) {
                fprintf(stderr, "ioctl failed: %s\n", strerror(errno));
                exit(EXIT_FAILURE);
        }

        if (ioctl(fd, TIOCMGET, &com_state) == -1) {
                fprintf(stderr, "ioctl failed: %s\n", strerror(errno));
                exit(EXIT_FAILURE);
        }


	I enabled some USB debugging and collected the following data
	after the crash.  I've had to write it down and retype it, so
	there might be some minor typos, especially with white space.

	ucomioctl: cmd = 0x8004746d
	disc_optim: bypass l_rint
	ucomioctl: our cmd = 0x8004746d
	ucomioctl: TIOCMSET, 0x3
	ucomctl: bits = 0x3, how = 0
	ucom_dtr: onoff = 1
	uftdi_set: sc=0xc6216400, port=1 reg=1 onoff=1
	uftdi_set: reqtype=0x40 req=0x01 value=0x0101 index=0x0001 len=0
	ucomreadcb: status = 0
	ucomreadcb: got 2 chars, tp = 0xc61e5200
	uftdi_read: sc=0xc6216400, port=1 count=2
	uftdi_read: status change msr=0xb0(0xf0) lsr=0x60(0x60)
	uftdi_status: msr=0xb0 lsr=0x60
	ucom_status_change: DCD changed to 1
	ucomstartread: start
	ucomctl: bits = 0x2, how = 1
	ucom_dtr: onoff = 1
	uftdi_set: sc=0xc6216400, port=1 reg=1 onoff=1
	uftdi_set: reqtype=0x40 req=0x01 value=0x0101 index=0x0001 len=0
	panic: uhci_abort_xfer: not in process context
	at line 1943 in file /disk2/src/sys/dev/usb/uhci.c
	Debugger("panic")
	stopped at Debugger+0x45:	xchgl %ebx,in_Debugger.0

	Then a trace from the debugger prompt shows:
	Debugger(c06da6d9) at Debugger+0x45
	__panic(c06ce57c,797,c06ce554,c6212000,c6216700) at __panic+0xc7
	uhci_abort_xfer(c67dda00,f) at uhci_abort_xfer+0x8d
	uhci_timeout_task(c67dda00,c61faa50,c0f9bd34,c0526099,0) at uhci_timeout_task+0x28
	usb_task_thread(0,e0f9bd48) at usb_task_thread+0xb9
	fork_exit(c04f0d34,0,e0f9bd48) at fork_exit+0x71
	fork_trampoline() at fork_trampoline+0x8
	--- trap 0x1, eip = 0, esp = 0xe0f9bd7c, ebp = 0 ---

Fix: 

No work around, but the following patch does add support to uftdi
	for the ValueCAN device.

	--- usbdevs.orig	Thu May 20 19:36:48 2004
	+++ usbdevs	Thu May 27 14:37:43 2004
	@@ -316,6 +316,7 @@
	 vendor BIOMETRIC	0x0929	American Biometric Company
	 vendor TOSHIBA		0x0930	Toshiba Corporation
	 vendor PLEXTOR		0x093b  Plextor Corp.
	+vendor INTREPIDCS	0x093c	Intrepid Control Systems
	 vendor YANO		0x094f	Yano
	 vendor KINGSTON		0x0951	Kingston Technology
	 vendor BLUEWATER	0x0956	BlueWater Systems
	@@ -793,6 +794,9 @@
	 
	 /* Intersil products */
	 product INTERSIL PRISM_2X	0x3642	Prism2.x or Atmel WLAN
	+
	+/* Interpid Control Systems products */
	+product INTREPIDCS VALUECAN	0x0601	ValueCAN CAN bus interface
	 
	 /* I/O DATA products */
	 product IODATA USBETT		0x0901	USB ETT
	--- uftdi.c.orig	Wed Mar 17 18:02:46 2004
	+++ uftdi.c	Thu May 27 14:38:26 2004
	@@ -164,6 +164,14 @@
		     uaa->product == USB_PRODUCT_FTDI_LK204))
			return (UMATCH_VENDOR_PRODUCT);
	 
	+	/*
	+	 * The Intrepid Control Systems' ValueCAN CAN interface uses
	+	 * the FTDI interface.
	+	 */
	+	if (uaa->vendor == USB_VENDOR_INTREPIDCS &&
	+	    uaa->product == USB_PRODUCT_INTREPIDCS_VALUECAN)
	+		return (UMATCH_VENDOR_PRODUCT);
	+
		return (UMATCH_NONE);
	 }
	 
	@@ -223,6 +231,7 @@
		case USB_PRODUCT_FTDI_MX4_5:
		case USB_PRODUCT_FTDI_LK202:
		case USB_PRODUCT_FTDI_LK204:
	+	case USB_PRODUCT_INTREPIDCS_VALUECAN:
			sc->sc_type = UFTDI_TYPE_8U232AM;
			sc->sc_hdrlen = 0;
			break;
How-To-Repeat: 	This problem is reproducable 100% of the time.  If I remove the
	code that clears RTS from my program, I do not get the panic.
	This is despite having other code that set RTS and clears/sets DTR.
	It is only clearing RTS that causes the problem.
Comment 1 Mike Durian 2004-05-29 22:14:16 UTC
I hope this makes it into GNATS.

Please see PR#67357 for a more complete patch to add support to uftdi(4)
for two Intrepid Control Systems vehicle bus interfaces.  Support for
selecting a 2000000 baud rate is also included (as these devices require
that baud rate).

mike
Comment 2 Gavin Atkinson freebsd_committer freebsd_triage 2008-06-21 13:35:46 UTC
State Changed
From-To: open->feedback

The patch in this PR was committed to FreeBSD before 5.3, so is in 
all supported FreeBSD releases. 

To submitter: are you still able to recreate the panic mentioned in 
this PR with a recent version of FreeBSD? 


Comment 3 Gavin Atkinson freebsd_committer freebsd_triage 2008-06-21 13:35:46 UTC
Responsible Changed
From-To: freebsd-bugs->gavin

Track
Comment 4 Gavin Atkinson freebsd_committer freebsd_triage 2008-06-21 18:51:28 UTC
State Changed
From-To: feedback->open

Feedback received from submitter: this is still a problem, the fragment 
of code included in the PR is sufficient to panic a system using the 
uftdi driver. 


Comment 5 Gavin Atkinson freebsd_committer freebsd_triage 2008-06-21 18:51:28 UTC
Responsible Changed
From-To: gavin->freebsd-usb

Over to maintainers
Comment 6 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:46 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 7 Ian Lepore freebsd_committer freebsd_triage 2018-03-04 18:38:22 UTC
This appears to have been fixed long ago.  The current uftdi driver does have the vendor/pid codes for the ValueCAN device.  I just ran a small test program using the code provided in the original report and confirmed that it no longer causes a panic.