From patchwork Fri Jan 22 18:18:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 8091871 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 B27C39F96D for ; Fri, 22 Jan 2016 18:20:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A23520595 for ; Fri, 22 Jan 2016 18:20:25 +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 1A9962053D for ; Fri, 22 Jan 2016 18:20:24 +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 1aMgJr-0005NV-OG; Fri, 22 Jan 2016 18:20:23 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aMgJZ-0003us-5R for linux-rockchip@lists.infradead.org; Fri, 22 Jan 2016 18:20:09 +0000 Received: by mail-pf0-x22c.google.com with SMTP id e65so46172863pfe.0 for ; Fri, 22 Jan 2016 10:19: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=6BHXj43yU8ooP3+AQS9NQNX0q9W8tLkQ++lE3KyTsF4=; b=g+Jfv4KmU41dcHdnqC05qr92JjOxXjVZ4mSlyDUk/ijjydBOWh7EO+vZ+RNUM2MUOs mRiC/1u8bZxh0rBQPjDgAXkeGMPbO44TG9b41+zwUWguX1iIymKjXl3qi/s9fSWSiPv4 dKFmLQn3LrK5e2kLwWcdwL8+Q2fUumGIOUvWA= 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=6BHXj43yU8ooP3+AQS9NQNX0q9W8tLkQ++lE3KyTsF4=; b=MiRK/So0aZGlZizDT5jHMtX21UgwdvUnyXEPhQ92bcSKJ2Msa1kaNSr0kQ+81+PeAV h9mAfPoFDSJAYqIQlGPGfOwIhXEvdkw5HIX2TRbNidxZT+zQ+s0tPVyIpp9iWkcphhXT wU8Z4B+Imp9pY7ZOzpS4HP874URuxzSVryQHr0BKHRir9B42o9IY64RwwYU0utNBut+h xeNb2oVoOKSvKCZc1ErLjKmsuHO244Jc6xXJcW2ZAoMLVGDDs/W+/mk+XVT9r+YqCrx0 mkNeaTFokaaH43L/ClrsUHBkR/WuPot0ziEqewb9oAYkHF0ZKW/PAhDbkEGg5b/8RPIC fYfQ== X-Gm-Message-State: AG10YOR9+gpfdiMyaIErGrPNLL3K/Ev6oRA3bDnvq+BxNbs50oTKLEiKdSiCqT8QkOmgzw== X-Received: by 10.98.93.136 with SMTP id n8mr6388394pfj.88.1453486784479; Fri, 22 Jan 2016 10:19:44 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jan 2016 10:19:43 -0800 (PST) From: Douglas Anderson To: John Youn , balbi@ti.com, kever.yang@rock-chips.com Subject: [PATCH v5 14/21] usb: dwc2: host: Split code out to make dwc2_do_reserve() Date: Fri, 22 Jan 2016 10:18:49 -0800 Message-Id: <1453486736-15358-15-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_102005_530979_7DBADDC2 X-CRM114-Status: GOOD ( 14.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: 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=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 This no-op change splits code out of dwc2_schedule_periodic() into a dwc2_do_reserve() function. This makes it a little easier to follow the logic. Signed-off-by: Douglas Anderson --- Changes in v5: None Changes in v4: - Split code out to make dwc2_do_reserve() new for v4. Changes in v3: None Changes in v2: None drivers/usb/dwc2/hcd_queue.c | 112 ++++++++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 45 deletions(-) diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index 8a2067bc1e62..9ce407e5017d 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c @@ -245,6 +245,70 @@ static int dwc2_find_uframe(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) } /** + * dwc2_do_reserve() - Make a periodic reservation + * + * Try to allocate space in the periodic schedule. Depending on parameters + * this might use the microframe scheduler or the dumb scheduler. + * + * @hsotg: The HCD state structure for the DWC OTG controller + * @qh: QH for the periodic transfer. + * + * Returns: 0 upon success; error upon failure. + */ +static int dwc2_do_reserve(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) +{ + int status; + + if (hsotg->core_params->uframe_sched > 0) { + int frame = -1; + + status = dwc2_find_uframe(hsotg, qh); + if (status == 0) + frame = 7; + else if (status > 0) + frame = status - 1; + + /* Set the new frame up */ + if (frame >= 0) { + qh->next_active_frame &= ~0x7; + qh->next_active_frame |= (frame & 7); + dwc2_sch_dbg(hsotg, + "QH=%p sched_p nxt=%04x, uf=%d\n", + qh, qh->next_active_frame, frame); + } + + if (status > 0) + status = 0; + } else { + status = dwc2_periodic_channel_available(hsotg); + if (status) { + dev_info(hsotg->dev, + "%s: No host channel available for periodic transfer\n", + __func__); + return status; + } + + status = dwc2_check_periodic_bandwidth(hsotg, qh); + } + + if (status) { + dev_dbg(hsotg->dev, + "%s: Insufficient periodic bandwidth for periodic transfer\n", + __func__); + return status; + } + + if (hsotg->core_params->uframe_sched <= 0) + /* Reserve periodic channel */ + hsotg->periodic_channels++; + + /* Update claimed usecs per (micro)frame */ + hsotg->periodic_usecs += qh->host_us; + + return 0; +} + +/** * dwc2_do_unreserve() - Actually release the periodic reservation * * This function actually releases the periodic bandwidth that was reserved @@ -393,51 +457,9 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) * that case. */ if (!qh->unreserve_pending) { - if (hsotg->core_params->uframe_sched > 0) { - int frame = -1; - - status = dwc2_find_uframe(hsotg, qh); - if (status == 0) - frame = 7; - else if (status > 0) - frame = status - 1; - - /* Set the new frame up */ - if (frame >= 0) { - qh->next_active_frame &= ~0x7; - qh->next_active_frame |= (frame & 7); - dwc2_sch_dbg(hsotg, - "QH=%p sched_p nxt=%04x, uf=%d\n", - qh, qh->next_active_frame, frame); - } - - if (status > 0) - status = 0; - } else { - status = dwc2_periodic_channel_available(hsotg); - if (status) { - dev_info(hsotg->dev, - "%s: No host channel available for periodic transfer\n", - __func__); - return status; - } - - status = dwc2_check_periodic_bandwidth(hsotg, qh); - } - - if (status) { - dev_dbg(hsotg->dev, - "%s: Insufficient periodic bandwidth for periodic transfer\n", - __func__); + status = dwc2_do_reserve(hsotg, qh); + if (status) return status; - } - - if (hsotg->core_params->uframe_sched <= 0) - /* Reserve periodic channel */ - hsotg->periodic_channels++; - - /* Update claimed usecs per (micro)frame */ - hsotg->periodic_usecs += qh->host_us; } qh->unreserve_pending = 0; @@ -450,7 +472,7 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) list_add_tail(&qh->qh_list_entry, &hsotg->periodic_sched_inactive); - return status; + return 0; } /**