fix-stop-sitting-printing-in-time-critical-context.patch
authorAndy Green <andy@openmoko.com>
Fri, 1 Aug 2008 06:47:19 +0000 (07:47 +0100)
committerAndy Green <andy@openmoko.com>
Fri, 1 Aug 2008 06:47:19 +0000 (07:47 +0100)
Someone left us a big fat warning in USB device code

/* Don't ever put [serial] debugging in non-error codepaths here, it
 * will violate the tight timing constraints of this USB Device
 * controller (and lead to bus enumeration failures) */

these "non-error codepaths" go all over the shop, this patch nukes some
serial printf()s that can do what we must never do.

Signed-off-by: Andy Green <andy@openmoko.com>

board/neo1973/gta02/gta02.c
drivers/serial/usbtty.c
drivers/usb/usbdcore.c
drivers/usb/usbdcore_s3c2410.c

index c4766b0..84eb8c5 100644 (file)
@@ -398,8 +398,8 @@ static void wait_for_power(void)
                poll_charger();
 
                /* track what the time-critical udc callback allows us */
-               if (pcf50633_usb_last_maxcurrent != udc_usb_maxcurrent)
-                       pcf50633_usb_maxcurrent(udc_usb_maxcurrent);
+//             if (pcf50633_usb_last_maxcurrent != udc_usb_maxcurrent)
+//                     pcf50633_usb_maxcurrent(udc_usb_maxcurrent);
 
                /* we have plenty of external power -> try to boot */
                if (pcf50633_usb_last_maxcurrent >= 500)
index b6c0403..7ef7eb5 100644 (file)
@@ -1162,7 +1162,13 @@ static void usbtty_event_handler (struct usb_device_instance *device,
                usbtty_configured_flag = 0;
                break;
        case DEVICE_CONFIGURED:
-               printf("DEVICE_CONFIGURED: %u\n", device->configuration);
+#if 0
+       /* we can't afford sitting here and printing stuff.  This code runs
+        * in a time-critical context and printing stuff is a synchronous
+        * serial activity... bad things can happen to USB peripheral
+        */
+       printf("DEVICE_CONFIGURED: %u\n", device->configuration);
+#endif
                if (device->configuration == 1)
                        udc_ctrl(UDC_CTRL_500mA_ENABLE, 1);
                else
@@ -1170,7 +1176,13 @@ static void usbtty_event_handler (struct usb_device_instance *device,
                usbtty_configured_flag = 1;
                break;
        case DEVICE_DE_CONFIGURED:
-               printf("DEVICE_DE_CONFIGURED\n");
+#if 0
+       /* we can't afford sitting here and printing stuff.  This code runs
+        * in a time-critical context and printing stuff is a synchronous
+        * serial activity... bad things can happen to USB peripheral
+        */
+               printf("DEVICE_DECONFIGURED: %u\n", device->configuration);
+#endif
                udc_ctrl(UDC_CTRL_500mA_ENABLE, 0);
                break;
        case DEVICE_ADDRESS_ASSIGNED:
index a2e6711..28b1a9a 100644 (file)
@@ -616,7 +616,13 @@ void usbd_device_event_irq (struct usb_device_instance *device, usb_device_event
 
        state = device->device_state;
 
+#if 0
+       /* we can't afford sitting here and printing stuff.  This code can run
+        * in a time-critical context and printing stuff is a synchronous
+        * serial activity... bad things can happen to USB peripheral
+        */
        usbinfo("%s", usbd_device_events[event]);
+#endif
 
        switch (event) {
        case DEVICE_UNKNOWN:
index a18e7e1..13cd3d6 100644 (file)
@@ -191,7 +191,7 @@ static void s3c2410_udc_ep0(void)
 
        /* clear stall status */
        if (ep0csr & S3C2410_UDC_EP0_CSR_SENTSTL) {
-               serial_printf("Clearing SENT_STALL\n");
+               /* serial_printf("Clearing SENT_STALL\n"); */
                clear_ep0_sst();
                if (ep0csr & S3C2410_UDC_EP0_CSR_SOPKTRDY)
                        clear_ep0_opr();
@@ -202,7 +202,7 @@ static void s3c2410_udc_ep0(void)
        /* clear setup end */
        if (ep0csr & S3C2410_UDC_EP0_CSR_SE
            /* && ep0->state != EP0_IDLE */) {
-               serial_printf("Clearing SETUP_END\n");
+               /* serial_printf("Clearing SETUP_END\n"); */
                clear_ep0_se();
 #if 1
                if (ep0csr & S3C2410_UDC_EP0_CSR_SOPKTRDY) {