From patchwork Fri Jan 29 02:19:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 8157531 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B5BD9BEEE5 for ; Fri, 29 Jan 2016 02:21:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E3902037F for ; Fri, 29 Jan 2016 02:21:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5844320374 for ; Fri, 29 Jan 2016 02:21:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOygY-0006qa-Vw; Fri, 29 Jan 2016 02:21:19 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOygH-0006fq-2J for linux-rockchip@lists.infradead.org; Fri, 29 Jan 2016 02:21:07 +0000 Received: by mail-pa0-x22a.google.com with SMTP id ho8so32843449pac.2 for ; Thu, 28 Jan 2016 18:20:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UtgimOrOSrcafIPvL/ThGGsWT6YWmaCro0TbAMwd6x0=; b=Cjk1+hAt2HxjeLRtv3izNlsZsudkbHm7cqEDlTCR8+aTNVChWo3FJUCSOuK6/mwtEn 2hndsGAZWtLQYbBKHg9OxJQk3SDly2dMmyp1Y3r/NNh/hgeyiFa6seKV01qFNPW7SGHI W56MmWDZ3OcoCU8Bwbv/MVhinbBR+srEOXhaw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UtgimOrOSrcafIPvL/ThGGsWT6YWmaCro0TbAMwd6x0=; b=IsNQFZ/6ZZN4vF48L414pmAcLSKEhMaLdOrS3neZCtWUVCGTmjVwb70AMbFaJ1Qo+k jjZUiBdlbClQ81qnZS2siCN4W0RLTioBjrdmfy3gkd/u7jQtBMcmDzQXKuZrClY5/zv2 us/ohufdCwqHVco93q4I9VbIdYs/stsnz9O45IYXzVFP13TZ/l7JKfi3MCCQ5Luu6gKF WR4OsWZUKuPCNGda4PMxEWlxnEBrTjmmwoQiA+WYxrDyL3KSI7fZsGx/fRbwqRbJwHto jm5Ay2W7HTM/rl+PSmqHG7/rNhbSpPfsdXIRaNADgvMBaBsRwcOfcBmVNBCLt6QOH7YN hdMw== X-Gm-Message-State: AG10YOT28RpEUYzVAhsAMnjDIZUmtFPhfJmBXYMse2Ok3skITJUAaPvdFg1T47l/HXjetg== X-Received: by 10.66.54.78 with SMTP id h14mr9654620pap.59.1454034043888; Thu, 28 Jan 2016 18:20:43 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id ux2sm19314864pac.46.2016.01.28.18.20.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jan 2016 18:20:43 -0800 (PST) From: Douglas Anderson To: John Youn , balbi@ti.com, kever.yang@rock-chips.com Subject: [PATCH v6 07/22] usb: dwc2: host: Add scheduler tracing Date: Thu, 28 Jan 2016 18:19:58 -0800 Message-Id: <1454034013-24657-8-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1454034013-24657-1-git-send-email-dianders@chromium.org> References: <1454034013-24657-1-git-send-email-dianders@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160128_182101_391891_6634EE59 X-CRM114-Status: GOOD ( 14.36 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangtao@rock-chips.com, stefan.wahren@i2se.com, heiko@sntech.de, johnyoun@synopsys.com, gregkh@linuxfoundation.org, ming.lei@canonical.com, linux-usb@vger.kernel.org, Douglas Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, yousaf.kaukab@intel.com, stern@rowland.harvard.edu, linux-rpi-kernel@lists.infradead.org, gregory.herrero@intel.com, william.wu@rock-chips.com, Julius Werner , dinguyen@opensource.altera.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for future changes to the scheduler let's add some tracing that makes it easy for us to see what's happening. By default this tracing will be off. By changing "core.h" you can easily trace to ftrace, the console, or nowhere. Signed-off-by: Douglas Anderson Reviewed-by: Kever Yang Tested-by: Heiko Stuebner Tested-by: Stefan Wahren --- Changes in v6: - Add Kever's Reviewed-by. - Add Heiko's Tested-by. - Add Stefan's Tested-by. Changes in v5: None Changes in v4: - Retooled scheduler tracing a bit, so left off John's Ack from v3. Changes in v3: None Changes in v2: None drivers/usb/dwc2/core.h | 20 ++++++++++++++++++++ drivers/usb/dwc2/hcd.h | 5 +++++ drivers/usb/dwc2/hcd_intr.c | 6 +++++- drivers/usb/dwc2/hcd_queue.c | 24 +++++++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 538cf38af0e4..18f9e4045643 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -44,6 +44,26 @@ #include #include "hw.h" +/* + * Suggested defines for tracers: + * - no_printk: Disable tracing + * - pr_info: Print this info to the console + * - trace_printk: Print this info to trace buffer (good for verbose logging) + */ + +#define DWC2_TRACE_SCHEDULER no_printk +#define DWC2_TRACE_SCHEDULER_VB no_printk + +/* Detailed scheduler tracing, but won't overwhelm console */ +#define dwc2_sch_dbg(hsotg, fmt, ...) \ + DWC2_TRACE_SCHEDULER(pr_fmt("%s: SCH: " fmt), \ + dev_name(hsotg->dev), ##__VA_ARGS__) + +/* Verbose scheduler tracing */ +#define dwc2_sch_vdbg(hsotg, fmt, ...) \ + DWC2_TRACE_SCHEDULER_VB(pr_fmt("%s: SCH: " fmt), \ + dev_name(hsotg->dev), ##__VA_ARGS__) + static inline u32 dwc2_readl(const void __iomem *addr) { u32 value = __raw_readl(addr); diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h index 1b46e2e617cc..809bc4ff9116 100644 --- a/drivers/usb/dwc2/hcd.h +++ b/drivers/usb/dwc2/hcd.h @@ -563,6 +563,11 @@ static inline u16 dwc2_frame_num_inc(u16 frame, u16 inc) return (frame + inc) & HFNUM_MAX_FRNUM; } +static inline u16 dwc2_frame_num_dec(u16 frame, u16 dec) +{ + return (frame + HFNUM_MAX_FRNUM + 1 - dec) & HFNUM_MAX_FRNUM; +} + static inline u16 dwc2_full_frame_num(u16 frame) { return (frame & HFNUM_MAX_FRNUM) >> 3; diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c index 577c91096a51..5d25a5ec9736 100644 --- a/drivers/usb/dwc2/hcd_intr.c +++ b/drivers/usb/dwc2/hcd_intr.c @@ -138,13 +138,17 @@ static void dwc2_sof_intr(struct dwc2_hsotg *hsotg) while (qh_entry != &hsotg->periodic_sched_inactive) { qh = list_entry(qh_entry, struct dwc2_qh, qh_list_entry); qh_entry = qh_entry->next; - if (dwc2_frame_num_le(qh->sched_frame, hsotg->frame_number)) + if (dwc2_frame_num_le(qh->sched_frame, hsotg->frame_number)) { + dwc2_sch_vdbg(hsotg, "QH=%p ready fn=%04x, sch=%04x\n", + qh, hsotg->frame_number, qh->sched_frame); + /* * Move QH to the ready list to be executed next * (micro)frame */ list_move_tail(&qh->qh_list_entry, &hsotg->periodic_sched_ready); + } } tr_type = dwc2_hcd_select_transactions(hsotg); if (tr_type != DWC2_TRANSACTION_NONE) diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index bc632a72f611..0e9faa75593c 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c @@ -113,6 +113,9 @@ static void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, qh->sched_frame = dwc2_frame_num_inc(hsotg->frame_number, SCHEDULE_SLOP); qh->interval = urb->interval; + dwc2_sch_dbg(hsotg, "QH=%p init sch=%04x, fn=%04x, int=%#x\n", + qh, qh->sched_frame, hsotg->frame_number, + qh->interval); #if 0 /* Increase interrupt polling rate for debugging */ if (qh->ep_type == USB_ENDPOINT_XFER_INT) @@ -126,6 +129,11 @@ static void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, qh->interval *= 8; qh->sched_frame |= 0x7; qh->start_split_frame = qh->sched_frame; + dwc2_sch_dbg(hsotg, + "QH=%p init*8 sch=%04x, fn=%04x, int=%#x\n", + qh, qh->sched_frame, hsotg->frame_number, + qh->interval); + } dev_dbg(hsotg->dev, "interval=%d\n", qh->interval); } @@ -482,6 +490,8 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) if (frame >= 0) { qh->sched_frame &= ~0x7; qh->sched_frame |= (frame & 7); + dwc2_sch_dbg(hsotg, "QH=%p sched_p sch=%04x, uf=%d\n", + qh, qh->sched_frame, frame); } if (status > 0) @@ -583,10 +593,16 @@ int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) if (!dwc2_frame_num_le(qh->sched_frame, hsotg->frame_number) && !hsotg->frame_number) { + u16 new_frame; + dev_dbg(hsotg->dev, "reset frame number counter\n"); - qh->sched_frame = dwc2_frame_num_inc(hsotg->frame_number, + new_frame = dwc2_frame_num_inc(hsotg->frame_number, SCHEDULE_SLOP); + + dwc2_sch_vdbg(hsotg, "QH=%p reset sch=%04x=>%04x\n", + qh, qh->sched_frame, new_frame); + qh->sched_frame = new_frame; } /* Add the new QH to the appropriate schedule */ @@ -652,6 +668,7 @@ static void dwc2_sched_periodic_split(struct dwc2_hsotg *hsotg, int sched_next_periodic_split) { u16 incr; + u16 old_frame = qh->sched_frame; if (sched_next_periodic_split) { qh->sched_frame = frame_number; @@ -677,6 +694,11 @@ static void dwc2_sched_periodic_split(struct dwc2_hsotg *hsotg, qh->sched_frame |= 0x7; qh->start_split_frame = qh->sched_frame; } + + dwc2_sch_vdbg(hsotg, "QH=%p next(%d) fn=%04x, sch=%04x=>%04x (%+d)\n", + qh, sched_next_periodic_split, frame_number, old_frame, + qh->sched_frame, + dwc2_frame_num_dec(qh->sched_frame, old_frame)); } /*