From patchwork Thu Jan 21 05:04:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 8077551 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 8E850BEEE5 for ; Thu, 21 Jan 2016 05:05:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 741F8205DC for ; Thu, 21 Jan 2016 05:05:43 +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 6C5CD20374 for ; Thu, 21 Jan 2016 05:05:42 +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 1aM7RF-0000l7-Tz; Thu, 21 Jan 2016 05:05:41 +0000 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aM7R5-0000Yw-9L for linux-rockchip@lists.infradead.org; Thu, 21 Jan 2016 05:05:34 +0000 Received: by mail-pf0-x22b.google.com with SMTP id 65so16895560pff.2 for ; Wed, 20 Jan 2016 21:05:11 -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=mJD3uxicbFHM1VoCOQ2YcV0yLJwpYY9OpYxmmmN1mDM=; b=bxAKAtVqWq6IMrnQjSqdJYWNjOPDY47PuIZ4hOx4KtEHb0XzBTwEYu6/owW4MbB/c2 zVmtDhaq9w32ebca+G63RTIQRRCBWDEgpL3cErXTRpksxuS2iC8Sh6Xl1jP+PE3BK74x reWseYdmjpmKR3zO3nWXoySy6s05zSP3IfkGo= 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=mJD3uxicbFHM1VoCOQ2YcV0yLJwpYY9OpYxmmmN1mDM=; b=CP7kfMUnq2I+pMW+hBmwo3jzqN1kbWZWLQFgN0jAhhWTUJvBSp59/GHNhS7h1BFsqU wKnf2dmYz1vvwenG6+46fUGrRhZiygtVYlNdVe9WPypLJdsR5z0TPFXVOk7ecRqlXPkR r6wzFDX/km1BKwQChWiLne31N9NtRhEVtk0VvltUyMqT6skKoR4yQeObqWn85maKBjeP hnwifGhVoNEV9htrANHMk0SYsmev8XO1NqMq2rYQW1rAgu/PKovRIchvm57FCqN+KAJh Pg8YiE1b6wU+a4vzZzKY8F+260tbga3UzHV+dhokmwda3AWnXxf/WvSQ4yPL61171iMv oz1A== X-Gm-Message-State: ALoCoQlKAT/3bcYzh9u8CIdQpt6RnRPGtfWt+VVXfzvi97hIQwq8GHCb2g35ET4Fj73nSK8dFkKM05xMnrP0iTlcsYolGml8WA== X-Received: by 10.98.86.67 with SMTP id k64mr58962798pfb.50.1453352710563; Wed, 20 Jan 2016 21:05:10 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id z28sm52255589pfi.19.2016.01.20.21.05.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jan 2016 21:05:10 -0800 (PST) From: Douglas Anderson To: John Youn , balbi@ti.com, kever.yang@rock-chips.com Subject: [PATCH v4 08/21] usb: dwc2: host: Add scheduler tracing Date: Wed, 20 Jan 2016 21:04:19 -0800 Message-Id: <1453352672-27890-9-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1453352672-27890-1-git-send-email-dianders@chromium.org> References: <1453352672-27890-1-git-send-email-dianders@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160120_210531_547231_385A809C X-CRM114-Status: GOOD ( 14.64 ) 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: gregory.herrero@intel.com, =?UTF-8?q?Heiko=20St=C3=BCbner?= , 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, 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 --- 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)); } /*