From patchwork Thu Jan 21 05:04:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 8077631 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 DC074BEEE5 for ; Thu, 21 Jan 2016 05:06:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6A0F20374 for ; Thu, 21 Jan 2016 05:05:59 +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 0CFA4205DB for ; Thu, 21 Jan 2016 05:05:59 +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 1aM7RW-0000wl-Jg; Thu, 21 Jan 2016 05:05:58 +0000 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aM7RB-0000ZE-9O for linux-rockchip@lists.infradead.org; Thu, 21 Jan 2016 05:05:45 +0000 Received: by mail-pf0-x229.google.com with SMTP id n128so16841469pfn.3 for ; Wed, 20 Jan 2016 21:05:16 -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=EOHsX0O8L5daCOPb3q2grVRESB/lDAe5+VWlzanG8fY=; b=dj15huqWkO7pvwF8vKncVezZtf9PN0Q8TAOAg+ZWddTEnSjHsbPDPjLFi/xcNqc6+1 wyrmnzequ/xZm0gf72ISSNGfU/kT7i7EFMKavVlJ/FXvK4ZJw5L7q5W6TJ0Ax3mcpABH O+UoGLpXoNEWZyU1430AcVukgDyehRgFUmgIU= 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=EOHsX0O8L5daCOPb3q2grVRESB/lDAe5+VWlzanG8fY=; b=N6t447Q/9QFlZCaNpbefZAUy0jQuyDcxGtfSqGl4qISceKIWGoyNJTm7e/C7LWM4Mo M38L4QiFQ2fa/2IejS+OPi383lA2h8Tv637QB7cR/+0/fgfn8z0FsrvDMs2bx8/3s1Fi BY2aEn5l0D4D3Bt/6rwIcUfLjlqHNFQlZI5DiA1ixG0/0N25lTzyvWtQWCq4CPp8AzeP C4sBG+CP4NH99dOxXxa7sV2XT7Krjc/HuNaMa+bxSTGXkD/4iDX5muIAROuYhYSPn/Tm ZjGalBEvUhY/RJxKFKURFH12+wjwmA+3e88+EZqQ4m6EJOH3RzgXGIeAF7DBqBs7mYoY uhxA== X-Gm-Message-State: ALoCoQnc2DR0VrxopdAcAKeL49Jtz5Aq0iN67BOtctZ6NA5AjIVyVA28Npknsd+bx+VJhDZ7bppUf9I/J96Do0gA0pk+GcTFVQ== X-Received: by 10.98.18.89 with SMTP id a86mr57470584pfj.143.1453352716689; Wed, 20 Jan 2016 21:05:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jan 2016 21:05:16 -0800 (PST) From: Douglas Anderson To: John Youn , balbi@ti.com, kever.yang@rock-chips.com Subject: [PATCH v4 14/21] usb: dwc2: host: Split code out to make dwc2_do_reserve() Date: Wed, 20 Jan 2016 21:04:25 -0800 Message-Id: <1453352672-27890-15-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_210537_499568_FDB8866D X-CRM114-Status: GOOD ( 15.37 ) X-Spam-Score: -2.0 (--) 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 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 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; } /**