UPSTREAM: usb: dwc2: host: Add scheduler logging for missed SOFs
authorDouglas Anderson <dianders@chromium.org>
Fri, 29 Jan 2016 02:20:07 +0000 (18:20 -0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 10:48:20 +0000 (18:48 +0800)
We'll use the new "scheduler verbose debugging" macro to log missed
SOFs.  This is fast enough (assuming you configure it to use the ftrace
buffer) that we can do it without worrying about the speed hit.  The
overhead hit if the scheduler tracing is set to "no_printk" should be
near zero.

Change-Id: I2b4fa9ec5b4ddf15f9ff28d7a876cb4e6341a55d
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 483bb2544c470aebdcc41199c0b145d05058a3bd)

drivers/usb/dwc2/core.h
drivers/usb/dwc2/hcd.c
drivers/usb/dwc2/hcd_intr.c

index dad35c8fed32394c375c49fc2ceab7ff2f20a5b2..9d04e6fe602a7053c41fa7f1b9cbb42008e84f2a 100644 (file)
@@ -837,9 +837,10 @@ struct dwc2_hsotg {
        bool bus_suspended;
        bool new_connection;
 
+       u16 last_frame_num;
+
 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
 #define FRAME_NUM_ARRAY_SIZE 1000
-       u16 last_frame_num;
        u16 *frame_num_array;
        u16 *last_frame_num_array;
        int frame_num_idx;
index fd731347daf7639f77ebfa2c7a5c2cfc3f5eb2b3..f48da015fa5e35ea5de6c2996df663522443f716 100644 (file)
@@ -3084,8 +3084,8 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
                        FRAME_NUM_ARRAY_SIZE, GFP_KERNEL);
        if (!hsotg->last_frame_num_array)
                goto error1;
-       hsotg->last_frame_num = HFNUM_MAX_FRNUM;
 #endif
+       hsotg->last_frame_num = HFNUM_MAX_FRNUM;
 
        /* Check if the bus driver or platform code has setup a dma_mask */
        if (hsotg->core_params->dma_enable > 0 &&
index 97aa6ca3a12e5bd018c7151dc716a56d0cc8f41a..5fc024f2092aa4d38735793e1af2c76bf7314f69 100644 (file)
 /* This function is for debug only */
 static void dwc2_track_missed_sofs(struct dwc2_hsotg *hsotg)
 {
-#ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
        u16 curr_frame_number = hsotg->frame_number;
+       u16 expected = dwc2_frame_num_inc(hsotg->last_frame_num, 1);
+
+       if (expected != curr_frame_number)
+               dwc2_sch_vdbg(hsotg, "MISSED SOF %04x != %04x\n",
+                       expected, curr_frame_number);
 
+#ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
        if (hsotg->frame_num_idx < FRAME_NUM_ARRAY_SIZE) {
-               if (((hsotg->last_frame_num + 1) & HFNUM_MAX_FRNUM) !=
-                   curr_frame_number) {
+               if (expected != curr_frame_number) {
                        hsotg->frame_num_array[hsotg->frame_num_idx] =
                                        curr_frame_number;
                        hsotg->last_frame_num_array[hsotg->frame_num_idx] =
@@ -79,8 +83,8 @@ static void dwc2_track_missed_sofs(struct dwc2_hsotg *hsotg)
                }
                hsotg->dumped_frame_num_array = 1;
        }
-       hsotg->last_frame_num = curr_frame_number;
 #endif
+       hsotg->last_frame_num = curr_frame_number;
 }
 
 static void dwc2_hc_handle_tt_clear(struct dwc2_hsotg *hsotg,