From patchwork Tue Nov 17 00:51:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 7631551 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9CC439F1C2 for ; Tue, 17 Nov 2015 00:52:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95E6D2053C for ; Tue, 17 Nov 2015 00:52:13 +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 AA22E2042C for ; Tue, 17 Nov 2015 00:52:12 +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 1ZyUVI-0002E3-4y; Tue, 17 Nov 2015 00:52:12 +0000 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyUVA-00026Q-DM for linux-rockchip@lists.infradead.org; Tue, 17 Nov 2015 00:52:08 +0000 Received: by pacej9 with SMTP id ej9so85138304pac.2 for ; Mon, 16 Nov 2015 16:51:48 -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=ARJWSayAkdVnI3hqJaMqFfoGI2pZvT2sWp9LQaKjGUU=; b=MiAu6HLmmqmR7hT6qT2wTxt8gk3pEPWOsktRnHmrU/gTAsPiZF8xULafjWZekRi1GE +8zIJSHAL4zJruYrFxOMY+GNMhpSskMVb59XGV/llk61ijbQAYUboAZN+a+eKWjTZEJd 1pCtLn2rDEM+73zXXyDFWMzMDd0kvI1dyA1Ks= 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=ARJWSayAkdVnI3hqJaMqFfoGI2pZvT2sWp9LQaKjGUU=; b=BCu3xPYkD7a1B8qTJnv5XJeM7cWUZcjwegHK2PWLE26oqhxIl5fBQAKbFm+G2Q1I0P c7I6uM2FGwihbhcM03JgPkhzPAM1C3oqzjm+gafTjLJClFrUKyaZTDk3CBnUsefnDxYg XHEpZfQG0Evuy0mRExS78K7D9PbSMt4GQqj/1a1+ohQpzNMNtUuZ5PgEp5p8ZcYCata4 0BwTxvk5+ia13DeyH0c4h7erlPH9x6gn9GtAgZuoL4Fvmul1yc7L1xcCUYMS9KM6p50f W/NfSRIYVYGVTkPbL8jJvcVWDk6LlEKZbtM8ZnilE6TxIqdE/yDkdDEFPlcuT/oo0Kg0 MTbw== X-Gm-Message-State: ALoCoQn8gr9nB3F1FCf6zt6wxcUPpDYY9gcd0ZNpJf7IhgMLWgEKuEdI4B9q332SyxKbKj8qm5ui X-Received: by 10.66.148.67 with SMTP id tq3mr59315391pab.124.1447721508175; Mon, 16 Nov 2015 16:51:48 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id hg2sm16316243pbb.7.2015.11.16.16.51.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Nov 2015 16:51:47 -0800 (PST) From: Douglas Anderson To: John Youn , balbi@ti.com Subject: [PATCH v3 6/8] usb: dwc2: host: Assume all devices are on one single_tt hub Date: Mon, 16 Nov 2015 16:51:22 -0800 Message-Id: <1447721484-22548-7-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1447721484-22548-1-git-send-email-dianders@chromium.org> References: <1447721484-22548-1-git-send-email-dianders@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151116_165204_597069_30802252 X-CRM114-Status: GOOD ( 17.95 ) 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, Yunzhi Li , 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.9 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 Until we have logic to determine which devices share the same TT let's add logic to assume that all devices on a given dwc2 controller are on one single_tt hub. This is better than the previous code that assumed that all devices were on one multi_tt hub, since single_tt hubs appear (in my experience) to be much more common and any schedule that would work on a single_tt hub will also work on a multi_tt hub. This will prevent more than 8 total low/full speed devices to be on the bus at one time, but that's a reasonable restriction until we've made things smarter. Signed-off-by: Douglas Anderson Acked-by: John Youn Tested-by: John Youn --- Changes in v3: - Assuming single_tt is new for v3; not terribly well tested (yet). Changes in v2: None drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/hcd_queue.c | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 567ee2c9e69f..09aa2b5ae29e 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -782,6 +782,7 @@ struct dwc2_hsotg { u16 periodic_usecs; unsigned long periodic_bitmap[DIV_ROUND_UP(TOTAL_PERIODIC_USEC, BITS_PER_LONG)]; + bool has_split[8]; u16 frame_number; u16 periodic_qh_count; bool bus_suspended; diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index 4c1d9cf482d0..c5a2edb04bec 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c @@ -372,10 +372,33 @@ static int dwc2_find_single_uframe(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) */ static int dwc2_find_multi_uframe(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) { + unsigned long tmp_bmp[DIV_ROUND_UP(TOTAL_PERIODIC_USEC, BITS_PER_LONG)]; + unsigned long *bmp; unsigned short utime = qh->usecs; unsigned long start; + int i; + + if (qh->do_split) { + /* + * Eventually we'll only want to exclude out microframes used by + * other people on the same TT as us, and then only if we're on + * a single_tt hub. ...but until we have that logic, just + * schedule everyone together. + */ + bmp = tmp_bmp; + memcpy(bmp, hsotg->periodic_bitmap, sizeof(tmp_bmp)); + start = 0; + + for (i = 0; i < ARRAY_SIZE(max_uframe_usecs); i++) { + if (hsotg->has_split[i]) + bitmap_set(bmp, start, max_uframe_usecs[i]); + start += max_uframe_usecs[i]; + } + } else { + bmp = hsotg->periodic_bitmap; + } - start = bitmap_find_next_zero_area(hsotg->periodic_bitmap, + start = bitmap_find_next_zero_area(bmp, TOTAL_PERIODIC_USEC, 0, utime, 0); if (start >= TOTAL_PERIODIC_USEC) { dwc2_sch_dbg(hsotg, "%s: failed to assign %d us\n", @@ -386,6 +409,13 @@ static int dwc2_find_multi_uframe(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) bitmap_set(hsotg->periodic_bitmap, start, qh->usecs); qh->start_usecs = start; + if (qh->do_split) { + for (i = start / EARLY_FRAME_USEC; + i < DIV_ROUND_UP(start + utime - 1, EARLY_FRAME_USEC); + i++) + hsotg->has_split[i] = true; + } + dwc2_sch_dbg(hsotg, "%s: assigned %d us @ %d us\n", __func__, qh->usecs, qh->start_usecs); @@ -533,6 +563,7 @@ static void dwc2_deschedule_periodic(struct dwc2_hsotg *hsotg, { int start = qh->start_usecs; int utime = qh->usecs; + int i; list_del_init(&qh->qh_list_entry); @@ -546,6 +577,13 @@ static void dwc2_deschedule_periodic(struct dwc2_hsotg *hsotg, } bitmap_clear(hsotg->periodic_bitmap, start, utime); + + if (qh->do_split) { + for (i = start / EARLY_FRAME_USEC; + i < DIV_ROUND_UP(start + utime - 1, EARLY_FRAME_USEC); + i++) + hsotg->has_split[i] = false; + } } /**