[Armadillo:07772] Re: armadillo-420 usb cdc_acmのドライバが落ちる

辻 泰裕 email@hidden
2011年 12月 20日 (火) 17:05:42 JST


お世話になっております、辻です。

USB Serial 不具合報告です。

USBポートに、ELECOM UC-SGT S/Nを接続し、次のOPENプログラムを実行し、
OPEN中にUSBを引き抜くと、ttyACM接続/引き抜きと同様にHCが死んでしまう。

ttyACMでは全てのUSBポートが死んでしまったが、今回の場合、抜き差しを
行ったポートのみ死んでしまう。

USB Serial変換を3つの種類でテストしました。
不具合の発生しないものは、USB Serialのドライバは、ftdi_sioが使われて
おり、不具合の発生したものは、pl2303が使われております。

【OPENプログラム内容】
static void UsbTestOpen( void )
{
	int	pno;
	int	acm_or_usb = 1;
	
	pno = open("/dev/ttyACM0", O_RDWR | O_NOCTTY | O_NONBLOCK);
	if ( pno == -1 ) {
		pno = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NONBLOCK);
		if ( pno == -1 ) {
			printf("Open Error!!!\n");
			return;
		}
		printf("ttyUSB0 open\n");
		acm_or_usb = 0;
	} else {
		printf("ttyACM0 open\n");
	}
	
	sleep( 10 );
	
	if ( acm_or_usb ) {
		printf("ttyACM0 close\n");
	} else {
		printf("ttyUSB0 close\n");
	}
	close( pno );
}

■■ 実行結果1-1 ■■
【ELECOM UC-SGT S/N接続】
usb 1-1: new full speed USB device using fsl-ehci and address 2
usb 1-1: configuration #1 chosen from 1 choice
pl2303 1-1:1.0: pl2303 converter detected
usb 1-1: pl2303 converter now attached to ttyUSB0
【OPENプログラム実行】
[email@hidden (ttymxc1)]# ./usb_serial_open.sh
ttyUSB0 open
【USB引き抜き】
usb 1-1: USB disconnect, address 2
usb 1-1: pl2303_read_bulk_callback - failed resubmitting read urb, error -19
usb 1-1: pl2303_read_int_callback - usb_submit_urb failed with result -19
fsl-ehci fsl-ehci.0: HC died; cleaning up
irq 35: nobody cared (try booting with the "irqpoll" option)
[<c02ee2b4>] (dump_stack+0x0/0x14) from [<c0070738>] (__report_bad_irq+0x2c/0x98)
[<c007070c>] (__report_bad_irq+0x0/0x98) from [<c0070a9c>] (note_interrupt+0x2f8/0x34c)
 r4:c3c64000
[<c00707a4>] (note_interrupt+0x0/0x34c) from [<c007169c>] (handle_level_irq+0x120/0x150)
[<c007157c>] (handle_level_irq+0x0/0x150) from [<c002a048>] (__exception_text_start+0x48/0x60)
 r7:c3c65e08 r6:c040fe88 r5:00000023 r4:c03cc640
[<c002a000>] (__exception_text_start+0x0/0x60) from [<c002a7a4>] (__irq_svc+0x44/0x88)
Exception stack(0xc3c65d58 to 0xc3c65da0)
5d40:                                                       00000036 c0037528
5d60: c3c64000 20000013 c3c64000 00000002 0000000a c040bcc0 00000001 00000000
5d80: c040e548 c3c65dcc c3c65dd0 c3c65da0 c004a81c c004a728 20000013 ffffffff
 r7:00000104 r6:00230000 r5:fc400000 r4:ffffffff
[<c004a6dc>] (__do_softirq+0x0/0xe4) from [<c004a81c>] (irq_exit+0x5c/0x70)
[<c004a7c0>] (irq_exit+0x0/0x70) from [<c002a04c>] (__exception_text_start+0x4c/0x60)
 r4:c03cca68
[<c002a000>] (__exception_text_start+0x0/0x60) from [<c002a7a4>] (__irq_svc+0x44/0x88)
Exception stack(0xc3c65e08 to 0xc3c65e50)
5e00:                   00000001 a0000013 c03ca424 00000000 00000000 00000000
5e20: c0407805 c3c65ee4 00000026 c3c64000 c03ca478 c3c65ecc c03ca418 c3c65e50
5e40: c003f664 c0045704 60000013 ffffffff
 r7:00000002 r6:00360000 r5:fc400000 r4:ffffffff
[<c0045470>] (vprintk+0x0/0x3f4) from [<c02ee418>] (printk+0x1c/0x24)
[<c02ee3fc>] (printk+0x0/0x24) from [<c01ac2f4>] (usb_disconnect+0x4c/0x118)
 r3:00000002 r2:c3824cec r1:c0389374 r0:c038749c
[<c01ac2a8>] (usb_disconnect+0x0/0x118) from [<c01ace64>] (hub_thread+0x2b8/0x10d4)
[<c01acbac>] (hub_thread+0x0/0x10d4) from [<c005b5e4>] (kthread+0x58/0x8c)
[<c005b58c>] (kthread+0x0/0x8c) from [<c00484e0>] (do_exit+0x0/0x6ec)
 r7:00000000 r6:00000000 r5:00000000 r4:00000000
handlers:
[<c01ae7cc>] (usb_hcd_irq+0x0/0xac)
Disabling IRQ #35
pl2303 1-1:1.0: device disconnected
hub 1-0:1.0: hub_port_status failed (err = -19)
hub 1-0:1.0: connect-debounce failed, port 1 disabled
hub 1-0:1.0: cannot disable port 1 (err = -19)
ttyUSB0 close
pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0


■■ 実行結果2-1 ■■
【Arvel SRC06-USB接続】
usb 1-1: new full speed USB device using fsl-ehci and address 3
usb 1-1: configuration #1 chosen from 1 choice
ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
ftdi_sio: Detected FT232BM
usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
【OPENプログラム実行】
[email@hidden (ttymxc1) /mnt/rms/bin]# ./usb_serial_open.sh
ttyUSB0 open
【USB引き抜き】
usb 1-1: USB disconnect, address 3
ftdi_sio 1-1:1.0: device disconnected
ttyUSB0 close
ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0


■■ 実行結果3-1 ■■
【RATOC REX-USB60F接続】
usb 1-1: new full speed USB device using fsl-ehci and address 2
usb 1-1: configuration #1 chosen from 1 choice
ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
ftdi_sio: Detected FT232BM
usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
【OPENプログラム実行】
[email@hidden (ttymxc1) /mnt/rms/bin]# ./usb_serial_open.sh
ttyUSB0 open
【USB引き抜き】
usb 1-1: USB disconnect, address 2
ftdi_sio 1-1:1.0: device disconnected
ttyUSB0 close
ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0


同じテストをKernelに以下の変更を加えたもので行った結果は以下のとおりです。
実行結果1-2では、1-1と同じようにcallbackでエラーが発生していますが、HCが
死んでしまうことは発生しません。

【変更内容】
ファイル:drivers/usb/host/ehci-hcd.c
static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr,
				       u32 mask, u32 done, int usec)
{
	int error = handshake(ehci, ptr, mask, done, usec);
#if 1
	/* 暫定対応 */
	if (error) {
//		printk("====	drivers/usb/host/ehci-hcd.c handshake_on_error_set_halt set HC_STATE_HALT\n");
//		printk("		mask=0x%04X, done=0x%04X count=%d\n", mask, done, ehci->periodic_sched );
		if ( ehci->periodic_sched == 0 ) {
			error = 0;
		} else {
			ehci_to_hcd(ehci)->state = HC_STATE_HALT;
		}
	}
#else
	/* オリジナル */
	if (error)
		ehci_to_hcd(ehci)->state = HC_STATE_HALT;
#endif

	return error;
}

■■ 実行結果1-2 ■■
【ELECOM UC-SGT S/N接続】
usb 1-1: new full speed USB device using fsl-ehci and address 2
usb 1-1: configuration #1 chosen from 1 choice
pl2303 1-1:1.0: pl2303 converter detected
usb 1-1: pl2303 converter now attached to ttyUSB0
【OPENプログラム実行】
[email@hidden (ttymxc1)]# ./usb_serial_open.sh
ttyUSB0 open
【USB引き抜き】
usb 1-1: USB disconnect, address 2
usb 1-1: pl2303_read_bulk_callback - failed resubmitting read urb, error -19
usb 1-1: pl2303_read_int_callback - usb_submit_urb failed with result -19
pl2303 1-1:1.0: device disconnected
ttyUSB0 close
pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0


■■ 実行結果2-2 ■■
【Arvel SRC06-USB接続】
usb 1-1: new full speed USB device using fsl-ehci and address 3
usb 1-1: configuration #1 chosen from 1 choice
ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
ftdi_sio: Detected FT232BM
usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
【OPENプログラム実行】
[email@hidden (ttymxc1)]# ./usb_serial_open.sh
ttyUSB0 open
【USB引き抜き】
usb 1-1: USB disconnect, address 3
ftdi_sio 1-1:1.0: device disconnected
ttyUSB0 close
ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0


■■ 実行結果3-2 ■■
【RATOC REX-USB60F接続】
usb 1-1: new full speed USB device using fsl-ehci and address 4
usb 1-1: configuration #1 chosen from 1 choice
ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
ftdi_sio: Detected FT232BM
usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
【OPENプログラム実行】
[email@hidden (ttymxc1)]# ./usb_serial_open.sh
ttyUSB0 open
【USB引き抜き】
usb 1-1: USB disconnect, address 4
ftdi_sio 1-1:1.0: device disconnected
ttyUSB0 close
ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0



HCのSTATUSをHALTにしてしまう処理ですが、
drivers/usb/host/ehci-sched.c 関数:disable_periodicにて発生します。
USB Serialでは、不具合の発生しないパターンでは、この関数は呼び出されません。
不具合の発生するパターンでは、USB引き抜き後、3回この関数が呼び出され、最後の
呼び出しにて、HC_STATE_HALTとなっています。
以下、デバッグ表示を入れた実行結果です。
[email@hidden (ttymxc1)]# ./usb_serial_open.sh
ttyUSB0 open
usb 1-1: USB disconnect, address 2
usb 1-1: pl2303_read_bulk_callback - failed resubmitting read urb, error -19
usb 1-1: pl2303_read_int_callback - usb_submit_urb failed with result -19
====    drivers/usb/host/ehci-sched.c disable_periodic
====    drivers/usb/host/ehci-sched.c disable_periodic
====    drivers/usb/host/ehci-sched.c disable_periodic
====    drivers/usb/host/ehci-hcd.c handshake_on_error_set_halt set HC_STATE_HALT
>>>>    drivers/usb/core/hcd.c usb_hcd_irq call usb_hc_died
fsl-ehci fsl-ehci.0: HC died; cleaning up

以上 宜しくお願いします。






armadillo メーリングリストの案内