aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRichard Ash <richard@audacityteam.org>2009-08-20 06:24:59 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 15:01:36 -0400
commiteba1aaddc0fd427d62f51747c6ec5f965ef5dc56 (patch)
tree7c10af5bb4ef45d47d1257ee86fa54e9f3cea502 /drivers
parentd3f0e10a702defea05b6c3277ec6326c87138e82 (diff)
Staging: quatech_usb2: Improve debug output and fix write_room
This patch contains changes made in the course of successfully reading data from the device. These consist of a number of corrections and additions to debug messages, and a fix for incorrect calculation of the number of characters in the device FIFO which affected the operation of the write_room method. The use of semaphores to control access to port settings is replaced by the preferred use of mutexes as this is the only code that uses them. Aug 18 17:09:32 [kernel] BUG: unable to handle kernel paging request at f82f122c Aug 18 17:09:32 [kernel] IP: [<c11e1a63>] tty_port_close_start+0x8c/0x15e Aug 18 17:09:32 [kernel] *pde = 00000000 Aug 18 17:09:32 [kernel] Modules linked in: snd_seq snd_seq_device snd_pcm_oss snd_mixer_oss nls_iso8859_1 cifs xt_limit xt_NFLOG nfnetlink_log nfnetlink xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4 xt_state nf_conntrack iptable_filter ip_tables x_tables i915 fb drm i2c_algo_bit cfbcopyarea i2c_core video backlight output cfbimgblt cfbfillrect quatech_usb2(C) usbserial uhci_hcd ehci_hcd snd_intel8x0 snd_ac97_codec ac97_bus usbcore tg3 snd_pcm snd_timer libphy snd intel_agp psmouse evdev ohci1394 soundcore ide_cd_mod cdrom ieee1394 snd_page_alloc agpgart floppy Aug 18 17:09:32 [kernel] Pid: 4192, comm: cat Tainted: G C (2.6.31-rc6-gkh #9) HP Compaq dc5100 MT(PW097ET) Aug 18 17:09:32 [kernel] EIP: 0060:[<c11e1a63>] EFLAGS: 00010046 CPU: 0 Aug 18 17:09:32 [kernel] EIP is at tty_port_close_start+0x8c/0x15e Aug 18 17:09:32 [kernel] EAX: 00000000 EBX: 00000246 ECX: ebacc380 EDX: 00000000 Aug 18 17:09:32 [kernel] ESI: f72f1204 EDI: e6073000 EBP: e60b3ce4 ESP: e60b3ccc Aug 18 17:09:32 [kernel] DS: 007b ES: 007b FS: 0000 GS: 00e0 SS: 0068 Aug 18 17:09:32 [kernel] bcc17886 e60b3d2c bcc17886 f72f1200 f72f1204 e6073000 e60b3d10 f8b01a67 Aug 18 17:09:32 [kernel] <0> 00000000 e60b3d10 c11d9343 e60730a0 ebacc380 bcc17886 e6073000 00000000 Aug 18 17:09:32 [kernel] <0> ebacc380 e60b3d90 c11da71c 00000000 f7802480 bcc17886 ebacc380 00000000 Aug 18 17:09:32 [kernel] [<f8b01a67>] ? serial_close+0x3c/0x9a [usbserial] Aug 18 17:09:32 [kernel] [<c11d9343>] ? tty_fasync+0x63/0xe3 Aug 18 17:09:32 [kernel] [<c11da71c>] ? tty_release_dev+0x159/0x47d Aug 18 17:09:32 [kernel] [<c11804c5>] ? prio_tree_remove+0x6c/0xc5 Aug 18 17:09:32 [kernel] [<c1081c5f>] ? put_object+0x46/0x5e Aug 18 17:09:32 [kernel] [<c11daa59>] ? tty_release+0x19/0x35 Aug 18 17:09:32 [kernel] [<c1086836>] ? __fput+0xed/0x1e4 Aug 18 17:09:32 [kernel] [<c1086951>] ? fput+0x24/0x39 Aug 18 17:09:32 [kernel] [<c108375e>] ? filp_close+0x4c/0x7b Aug 18 17:09:32 [kernel] [<c1028076>] ? put_files_struct+0xc3/0xd2 Aug 18 17:09:32 [kernel] [<c10280b1>] ? exit_files+0x2c/0x40 Aug 18 17:09:32 [kernel] [<c1028551>] ? do_exit+0xd0/0x5f5 Aug 18 17:09:32 [kernel] [<c1031751>] ? recalc_sigpending+0x1b/0x4b Aug 18 17:09:32 [kernel] [<c1031b8b>] ? dequeue_signal+0x96/0x154 Aug 18 17:09:32 [kernel] [<c1028ab1>] ? do_group_exit+0x3b/0x77 Aug 18 17:09:32 [kernel] [<c1032ec3>] ? get_signal_to_deliver+0x140/0x31b Aug 18 17:09:32 [kernel] [<c11d90af>] ? tty_put_char+0x43/0x4b Aug 18 17:09:32 [kernel] [<c1002633>] ? do_notify_resume+0xae/0x7fb Aug 18 17:09:32 [kernel] [<c11dabcd>] ? tty_read+0x8f/0xb5 Aug 18 17:09:32 [kernel] [<c11dd0be>] ? n_tty_read+0x0/0x5d2 Aug 18 17:09:32 [kernel] [<c1085560>] ? vfs_read+0xb4/0x178 Aug 18 17:09:32 [kernel] [<c11dab3e>] ? tty_read+0x0/0xb5 Aug 18 17:09:32 [kernel] [<c10856e4>] ? sys_read+0x52/0x8b Aug 18 17:09:32 [kernel] [<c1002f6a>] ? work_notifysig+0x13/0x19 Aug 18 17:09:32 [kernel] ---[ end trace 16f434ec7e2925bc ]--- Aug 18 17:09:32 [kernel] Fixing recursive fault but reboot is needed! My guess is that my driver is doing something "wrong" in terms of it's interface to the higher level layers and so is causing the oops. Are there any mechanisms to turn on more checking / debugging in the layers above the usb-serial layer to try and catch the cause of the problem? I've already got USB_DEBUG enabled, what others might be relevant (presumably USB_SERIAL_DEBUG isn't)? Signed-off-by: Richard Ash <richard@audacityteam.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/quatech_usb2/quatech_usb2.c82
1 files changed, 42 insertions, 40 deletions
diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c
index b06e90d3cef..deb222c7186 100644
--- a/drivers/staging/quatech_usb2/quatech_usb2.c
+++ b/drivers/staging/quatech_usb2/quatech_usb2.c
@@ -163,7 +163,7 @@ static struct usb_driver quausb2_usb_driver = {
163 * each time a write urb is dispatched. 163 * each time a write urb is dispatched.
164 * - is decremented each time a "transmit empty" message is received 164 * - is decremented each time a "transmit empty" message is received
165 * by the driver in the data stream. 165 * by the driver in the data stream.
166 * @sem: Semaphore to lock access to this structure when we need to ensure that 166 * @lock: Mutex to lock access to this structure when we need to ensure that
167 * races don't occur to access bits of it. 167 * races don't occur to access bits of it.
168 * @open_count: The number of uses of the port currently having 168 * @open_count: The number of uses of the port currently having
169 * it open, i.e. the reference count. 169 * it open, i.e. the reference count.
@@ -177,13 +177,12 @@ struct quatech2_port {
177 bool rcv_flush; 177 bool rcv_flush;
178 bool xmit_flush; 178 bool xmit_flush;
179 int tx_pending_bytes; 179 int tx_pending_bytes;
180 struct semaphore sem; 180 struct mutex modelock;
181 int open_count; 181 int open_count;
182 182
183 char active; /* someone has this device open */ 183 char active; /* someone has this device open */
184 unsigned char *xfer_to_tty_buffer; 184 unsigned char *xfer_to_tty_buffer;
185 wait_queue_head_t wait; 185 wait_queue_head_t wait;
186
187 __u8 shadowLCR; /* last LCR value received */ 186 __u8 shadowLCR; /* last LCR value received */
188 __u8 shadowMCR; /* last MCR value received */ 187 __u8 shadowMCR; /* last MCR value received */
189 char RxHolding; 188 char RxHolding;
@@ -263,11 +262,6 @@ static int qt2_box_flush(struct usb_serial *serial, unsigned char uart_number,
263 unsigned short rcv_or_xmit); 262 unsigned short rcv_or_xmit);
264static int qt2_boxsetuart(struct usb_serial *serial, unsigned short Uart_Number, 263static int qt2_boxsetuart(struct usb_serial *serial, unsigned short Uart_Number,
265 unsigned short default_divisor, unsigned char default_LCR); 264 unsigned short default_divisor, unsigned char default_LCR);
266/*static int qt2_write(struct tty_struct *tty, struct usb_serial_port *port,
267 const unsigned char *buf, int count);
268static int qt2_tiocmget(struct tty_struct *tty, struct file *file);
269static int qt2_tiocmset(struct tty_struct *tty, struct file *file,
270 unsigned int set, unsigned int clear);*/
271static int qt2_boxsethw_flowctl(struct usb_serial *serial, 265static int qt2_boxsethw_flowctl(struct usb_serial *serial,
272 unsigned int UartNumber, bool bSet); 266 unsigned int UartNumber, bool bSet);
273static int qt2_boxsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber, 267static int qt2_boxsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber,
@@ -356,6 +350,7 @@ static int qt2_attach(struct usb_serial *serial)
356 /* initialise stuff in the structure */ 350 /* initialise stuff in the structure */
357 qt2_port->open_count = 0; /* port is not open */ 351 qt2_port->open_count = 0; /* port is not open */
358 spin_lock_init(&qt2_port->lock); 352 spin_lock_init(&qt2_port->lock);
353 mutex_init(&qt2_port->modelock);
359 qt2_set_port_private(port, qt2_port); 354 qt2_set_port_private(port, qt2_port);
360 } 355 }
361 356
@@ -535,7 +530,6 @@ int qt2_open(struct tty_struct *tty, struct usb_serial_port *port)
535 * Finally we need a bulk in URB to use for background reads from the 530 * Finally we need a bulk in URB to use for background reads from the
536 * device, which will deal with uplink data from the box to host. 531 * device, which will deal with uplink data from the box to host.
537 */ 532 */
538 dbg("serial number is %d", port->serial->minor);
539 dbg("port0 bulk in endpoint is %#.2x", port0->bulk_in_endpointAddress); 533 dbg("port0 bulk in endpoint is %#.2x", port0->bulk_in_endpointAddress);
540 dbg("port0 bulk out endpoint is %#.2x", 534 dbg("port0 bulk out endpoint is %#.2x",
541 port0->bulk_out_endpointAddress); 535 port0->bulk_out_endpointAddress);
@@ -700,7 +694,12 @@ static void qt2_close(struct usb_serial_port *port)
700 dev_extra->open_ports); 694 dev_extra->open_ports);
701} 695}
702 696
703/* called to deliver writes from the next layer up to the device */ 697/**
698 * qt2_write - write bytes from the tty layer out to the USB device.
699 * @buf: The data to be written, size at least count.
700 * @count: The number of bytes requested for transmission.
701 * @return The number of bytes actually accepted for transmission to the device.
702 */
704static int qt2_write(struct tty_struct *tty, struct usb_serial_port *port, 703static int qt2_write(struct tty_struct *tty, struct usb_serial_port *port,
705 const unsigned char *buf, int count) 704 const unsigned char *buf, int count)
706{ 705{
@@ -708,20 +707,19 @@ static int qt2_write(struct tty_struct *tty, struct usb_serial_port *port,
708 __u8 header_array[5]; /* header used to direct writes to the correct 707 __u8 header_array[5]; /* header used to direct writes to the correct
709 port on the device */ 708 port on the device */
710 struct quatech2_port *port_extra; /* extra data for this port */ 709 struct quatech2_port *port_extra; /* extra data for this port */
711
712 int result; 710 int result;
713 711
714 /* get the parent device of the port */ 712 serial = port->serial; /* get the parent device of the port */
715 serial = port->serial; 713 port_extra = qt2_get_port_private(port); /* port extra info */
716 if (serial == NULL) 714 if (serial == NULL)
717 return -ENODEV; 715 return -ENODEV;
718 dbg("%s(): port %d", __func__, port->number); 716 dbg("%s(): port %d, requested to write %d bytes, %d already pending",
717 __func__, port->number, count, port_extra->tx_pending_bytes);
719 718
720 if (count <= 0) { 719 if (count <= 0) {
721 dbg("%s(): write request of <= 0 bytes", __func__); 720 dbg("%s(): write request of <= 0 bytes", __func__);
722 return 0; /* no bytes written */ 721 return 0; /* no bytes written */
723 } 722 }
724 port_extra = qt2_get_port_private(port);
725 723
726 /* check if the write urb is already in use, i.e. data already being 724 /* check if the write urb is already in use, i.e. data already being
727 * sent to this port */ 725 * sent to this port */
@@ -747,13 +745,19 @@ static int qt2_write(struct tty_struct *tty, struct usb_serial_port *port,
747 * the maximum we will ever write to the device as 5 bytes less than 745 * the maximum we will ever write to the device as 5 bytes less than
748 * one URB's worth, by reducing the value of the count argument 746 * one URB's worth, by reducing the value of the count argument
749 * appropriately*/ 747 * appropriately*/
750 if (count > port->bulk_out_size - QT2_TX_HEADER_LENGTH) 748 if (count > port->bulk_out_size - QT2_TX_HEADER_LENGTH) {
751 count = port->bulk_out_size - QT2_TX_HEADER_LENGTH; 749 count = port->bulk_out_size - QT2_TX_HEADER_LENGTH;
750 dbg("%s(): write request bigger than urb, only accepting "
751 "%d bytes", __func__, count);
752 }
752 /* we must also ensure that the FIFO at the other end can cope with the 753 /* we must also ensure that the FIFO at the other end can cope with the
753 * URB we send it, otherwise it will have problems. As above, we can 754 * URB we send it, otherwise it will have problems. As above, we can
754 * restrict the write size by just shrinking count.*/ 755 * restrict the write size by just shrinking count.*/
755 if (count > (QT2_FIFO_DEPTH - port_extra->tx_pending_bytes)) 756 if (count > (QT2_FIFO_DEPTH - port_extra->tx_pending_bytes)) {
756 count = QT2_FIFO_DEPTH - port_extra->tx_pending_bytes; 757 count = QT2_FIFO_DEPTH - port_extra->tx_pending_bytes;
758 dbg("%s(): not enough room in buffer, only accepting %d bytes",
759 __func__, count);
760 }
757 /* now build the header for transmission */ 761 /* now build the header for transmission */
758 header_array[0] = 0x1b; 762 header_array[0] = 0x1b;
759 header_array[1] = 0x1b; 763 header_array[1] = 0x1b;
@@ -778,17 +782,15 @@ static int qt2_write(struct tty_struct *tty, struct usb_serial_port *port,
778 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 782 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
779 if (result) { 783 if (result) {
780 /* error couldn't submit urb */ 784 /* error couldn't submit urb */
781 result = 0; 785 result = 0; /* return 0 as nothing got written */
782 dbg("%s(): failed submitting write urb, error %d", 786 dbg("%s(): failed submitting write urb, error %d",
783 __func__, result); 787 __func__, result);
784 } else { 788 } else {
785 port_extra->tx_pending_bytes += (count - QT2_TX_HEADER_LENGTH); 789 port_extra->tx_pending_bytes += count;
786 /*port->fifo_empty_flag = false; 790 result = count; /* return number of bytes written, i.e. count */
787 port->xmit_fifo_room_bytes = FIFO_DEPTH - 791 dbg("%s(): submitted write urb, wrote %d bytes, "
788 port->xmit_pending_bytes;*/ 792 "total pending bytes %d",
789 result = count; 793 __func__, result, port_extra->tx_pending_bytes);
790 dbg("%s(): submitted write urb, returning %d",
791 __func__, result);
792 } 794 }
793 return result; 795 return result;
794} 796}
@@ -1178,7 +1180,7 @@ static void qt2_break(struct tty_struct *tty, int break_state)
1178 dbg("%s(): port %d, break_value %d", __func__, port->number, 1180 dbg("%s(): port %d, break_value %d", __func__, port->number,
1179 break_value); 1181 break_value);
1180 1182
1181 down(&port_extra->sem); 1183 mutex_lock(&port_extra->modelock);
1182 if (!port_extra->open_count) { 1184 if (!port_extra->open_count) {
1183 dbg("%s(): port not open", __func__); 1185 dbg("%s(): port not open", __func__);
1184 goto exit; 1186 goto exit;
@@ -1188,7 +1190,7 @@ static void qt2_break(struct tty_struct *tty, int break_state)
1188 QT2_BREAK_CONTROL, 0x40, break_value, 1190 QT2_BREAK_CONTROL, 0x40, break_value,
1189 port->number, NULL, 0, 300); 1191 port->number, NULL, 0, 300);
1190exit: 1192exit:
1191 up(&port_extra->sem); 1193 mutex_unlock(&port_extra->modelock);
1192 dbg("%s(): exit port %d", __func__, port->number); 1194 dbg("%s(): exit port %d", __func__, port->number);
1193 1195
1194} 1196}
@@ -1209,7 +1211,7 @@ static void qt2_throttle(struct tty_struct *tty)
1209 return; 1211 return;
1210 } 1212 }
1211 1213
1212 down(&port_extra->sem); /* lock structure */ 1214 mutex_lock(&port_extra->modelock); /* lock structure */
1213 if (!port_extra->open_count) { 1215 if (!port_extra->open_count) {
1214 dbg("%s(): port not open", __func__); 1216 dbg("%s(): port not open", __func__);
1215 goto exit; 1217 goto exit;
@@ -1224,7 +1226,7 @@ static void qt2_throttle(struct tty_struct *tty)
1224 1226
1225 port->throttled = 1; 1227 port->throttled = 1;
1226exit: 1228exit:
1227 up(&port_extra->sem); 1229 mutex_unlock(&port_extra->modelock);
1228 dbg("%s(): port %d: setting port->throttled", __func__, port->number); 1230 dbg("%s(): port %d: setting port->throttled", __func__, port->number);
1229 return; 1231 return;
1230} 1232}
@@ -1251,7 +1253,7 @@ static void qt2_unthrottle(struct tty_struct *tty)
1251 port_extra = qt2_get_port_private(port); 1253 port_extra = qt2_get_port_private(port);
1252 port0 = serial->port[0]; /* get the first port's device structure */ 1254 port0 = serial->port[0]; /* get the first port's device structure */
1253 1255
1254 down(&port_extra->sem); 1256 mutex_lock(&port_extra->modelock);
1255 if (!port_extra->open_count) { 1257 if (!port_extra->open_count) {
1256 dbg("%s(): port %d not open", __func__, port->number); 1258 dbg("%s(): port %d not open", __func__, port->number);
1257 goto exit; 1259 goto exit;
@@ -1275,7 +1277,7 @@ static void qt2_unthrottle(struct tty_struct *tty)
1275 } 1277 }
1276 } 1278 }
1277exit: 1279exit:
1278 up(&port_extra->sem); 1280 mutex_unlock(&port_extra->modelock);
1279 dbg("%s(): exit port %d", __func__, port->number); 1281 dbg("%s(): exit port %d", __func__, port->number);
1280 return; 1282 return;
1281} 1283}
@@ -1442,9 +1444,8 @@ static void qt2_read_bulk_callback(struct urb *urb)
1442 bool escapeflag; /* flag set to true if this loop iteration is 1444 bool escapeflag; /* flag set to true if this loop iteration is
1443 * parsing an escape sequence, rather than 1445 * parsing an escape sequence, rather than
1444 * ordinary data */ 1446 * ordinary data */
1445 1447 dbg("%s(): callback running, active port is %d", __func__,
1446 1448 active->number);
1447 dbg("%s(): callback running", __func__);
1448 1449
1449 if (urb->status) { 1450 if (urb->status) {
1450 /* read didn't go well */ 1451 /* read didn't go well */
@@ -1502,7 +1503,7 @@ __func__);
1502 /* single port device, input is already stopped, so we don't 1503 /* single port device, input is already stopped, so we don't
1503 * need any more input data */ 1504 * need any more input data */
1504 dev_extra->ReadBulkStopped = true; 1505 dev_extra->ReadBulkStopped = true;
1505 return; 1506 return;
1506 } 1507 }
1507 /* finally, we are in a situation where we might consider the data 1508 /* finally, we are in a situation where we might consider the data
1508 * that is contained within the URB, and what to do about it. 1509 * that is contained within the URB, and what to do about it.
@@ -1512,14 +1513,12 @@ __func__);
1512 1513
1513 /* active is a usb_serial_port. It has a member port which is a 1514 /* active is a usb_serial_port. It has a member port which is a
1514 * tty_port. From this we get a tty_struct pointer which is what we 1515 * tty_port. From this we get a tty_struct pointer which is what we
1515 * actually wanted, and keep it on tty_st */ 1516 * actually wanted, and keep it on tty_st */
1516 tty_st = tty_port_tty_get(&active->port); 1517 tty_st = tty_port_tty_get(&active->port);
1517 if (!tty_st) { 1518 if (!tty_st) {
1518 dbg("%s - bad tty pointer - exiting", __func__); 1519 dbg("%s - bad tty pointer - exiting", __func__);
1519 return; 1520 return;
1520 } 1521 }
1521 dbg("%s(): active port %d, tty_st =0x%p\n", __func__, active->number,
1522 tty_st);
1523 RxCount = urb->actual_length; /* grab length of data handy */ 1522 RxCount = urb->actual_length; /* grab length of data handy */
1524 1523
1525 if (RxCount) { 1524 if (RxCount) {
@@ -1663,6 +1662,7 @@ __func__);
1663 dbg("%s(): failed resubmitting read urb, error %d", 1662 dbg("%s(): failed resubmitting read urb, error %d",
1664 __func__, result); 1663 __func__, result);
1665 } else { 1664 } else {
1665 dbg("%s() sucessfully resumitted read urb", __func__);
1666 if (tty_st && RxCount) { 1666 if (tty_st && RxCount) {
1667 /* if some inbound data was processed, then 1667 /* if some inbound data was processed, then
1668 * we need to push that through the tty layer 1668 * we need to push that through the tty layer
@@ -1675,7 +1675,7 @@ __func__);
1675 /* cribbed from serqt_usb2 driver, but not sure which work needs 1675 /* cribbed from serqt_usb2 driver, but not sure which work needs
1676 * scheduling - port0 or currently active port? */ 1676 * scheduling - port0 or currently active port? */
1677 /* schedule_work(&port->work); */ 1677 /* schedule_work(&port->work); */
1678 1678 dbg("%s() completed", __func__);
1679 return; 1679 return;
1680} 1680}
1681 1681
@@ -1699,7 +1699,9 @@ static void qt2_write_bulk_callback(struct urb *urb)
1699 __func__, urb->status); 1699 __func__, urb->status);
1700 return; 1700 return;
1701 } 1701 }
1702 1702 /* FIXME What is supposed to be going on here?
1703 * does this actually do anything useful, and should it?
1704 */
1703 /*port_softint((void *) serial); commented in vendor driver */ 1705 /*port_softint((void *) serial); commented in vendor driver */
1704 schedule_work(&port->work); 1706 schedule_work(&port->work);
1705 dbg("%s(): port %d exit", __func__, port->number); 1707 dbg("%s(): port %d exit", __func__, port->number);