From patchwork Fri Jan 22 18:18:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 8091791 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 6E279BEEED for ; Fri, 22 Jan 2016 18:20:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 609B520595 for ; Fri, 22 Jan 2016 18:20:07 +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 0998B204DE for ; Fri, 22 Jan 2016 18:20:06 +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 1aMgJZ-0004Fs-Iw; Fri, 22 Jan 2016 18:20:05 +0000 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aMgJS-0003tb-6B for linux-rockchip@lists.infradead.org; Fri, 22 Jan 2016 18:20:01 +0000 Received: by mail-pf0-x22a.google.com with SMTP id q63so47321674pfb.1 for ; Fri, 22 Jan 2016 10:19:37 -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=83BQREc2w9TEKbgEowEPwhPhTuOvBmvX/QsViiwQppw=; b=c6yeK664nbGt+E562CfvCvmNxtYEP0YGtekayfzRlYsmQz/SZ3hxZweO85Rc7WwpVU HvH7f0me1v11SkEwO7n1kFOfLzYxm2WzbwEWM22oiuQ47JEO8RdJZefiOCgE5ntEFVhK Z8+U47FQxQIJFjCMFK2JO9cdlUdfwdzCw4JJA= 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=83BQREc2w9TEKbgEowEPwhPhTuOvBmvX/QsViiwQppw=; b=KxTm+p/7/yySHKrFmrT/Rt8UOv3HcsOcjcoYnG31k7ks1ECQNjMqq8g93KQ6gO/Kg8 M1sQ9CS8wporFk5vlq45qt1rVcDAn5Kdh/NfyS+/b8/cdntLzbqBfOZZpLpHng2glRA4 uQvVWBWGUlbGc77hODrka/8j8lTdaLOqmmpwSA4d86k8mXbXJI8uL4kZhp9JQNCYkXE6 GAFM0Xhk6VGqIvl5A5kTH/dLfW9cP5Ffchm2LL4GrKJyUSrSxeUtD52RTPxqdGoXndJ9 ZYFfsAbWsVQxTUu6Emo+MRNyYlCp7ZkwEVx825i2HCdHY6Y/WF1IC6CVgp1VsQKrtNyP HCUA== X-Gm-Message-State: AG10YOSSv132kwsGR7A4X7p8aqaEKbAdXB24/VgWh7Xmm/eqsZN9LU7v4YqqYPgO1XGP5A== X-Received: by 10.98.87.20 with SMTP id l20mr6410565pfb.70.1453486777502; Fri, 22 Jan 2016 10:19:37 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id y86sm11276415pfa.26.2016.01.22.10.19.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jan 2016 10:19:36 -0800 (PST) From: Douglas Anderson To: John Youn , balbi@ti.com, kever.yang@rock-chips.com Subject: [PATCH v5 08/21] usb: dwc2: host: Add scheduler tracing Date: Fri, 22 Jan 2016 10:18:43 -0800 Message-Id: <1453486736-15358-9-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1453486736-15358-1-git-send-email-dianders@chromium.org> References: <1453486736-15358-1-git-send-email-dianders@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160122_101958_526195_7EBCBDB9 X-CRM114-Status: GOOD ( 14.22 ) 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, gregory.herrero@intel.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, 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=unavailable 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 --- 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)); } /*