From patchwork Mon Aug 20 10:29:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 10570131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E20C920 for ; Mon, 20 Aug 2018 10:33:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F276729271 for ; Mon, 20 Aug 2018 10:33:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E681529280; Mon, 20 Aug 2018 10:33:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D124F29271 for ; Mon, 20 Aug 2018 10:33:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726562AbeHTNsz (ORCPT ); Mon, 20 Aug 2018 09:48:55 -0400 Received: from mga05.intel.com ([192.55.52.43]:14320 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726156AbeHTNsz (ORCPT ); Mon, 20 Aug 2018 09:48:55 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2018 03:33:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,264,1531810800"; d="scan'208";a="84785335" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.72.128]) by orsmga002.jf.intel.com with ESMTP; 20 Aug 2018 03:33:49 -0700 From: Felipe Balbi To: linux-usb@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Felipe Balbi Subject: [PATCH 1/4] usb: dwc3: gadget: return errors from __dwc3_gadget_start_isoc() Date: Mon, 20 Aug 2018 13:29:58 +0300 Message-Id: <20180820103001.6453-1-felipe.balbi@linux.intel.com> X-Mailer: git-send-email 2.18.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes, errors happen when kicking transfers from __dwc3_gadget_start_isoc(). In those cases, we need to pass along the error so gadget driver can make informed decisions. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 69bf137aab37..f61a4250c883 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1255,17 +1255,17 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc) return DWC3_DSTS_SOFFN(reg); } -static void __dwc3_gadget_start_isoc(struct dwc3_ep *dep) +static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) { if (list_empty(&dep->pending_list)) { dev_info(dep->dwc->dev, "%s: ran out of requests\n", dep->name); dep->flags |= DWC3_EP_PENDING_REQUEST; - return; + return -EAGAIN; } dep->frame_number = DWC3_ALIGN_FRAME(dep); - __dwc3_gadget_kick_transfer(dep); + return __dwc3_gadget_kick_transfer(dep); } static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) @@ -1306,8 +1306,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) if ((dep->flags & DWC3_EP_PENDING_REQUEST)) { if (!(dep->flags & DWC3_EP_TRANSFER_STARTED)) { - __dwc3_gadget_start_isoc(dep); - return 0; + return __dwc3_gadget_start_isoc(dep); } } } @@ -2427,7 +2426,7 @@ static void dwc3_gadget_endpoint_transfer_not_ready(struct dwc3_ep *dep, const struct dwc3_event_depevt *event) { dwc3_gadget_endpoint_frame_from_event(dep, event); - __dwc3_gadget_start_isoc(dep); + (void) __dwc3_gadget_start_isoc(dep); } static void dwc3_endpoint_interrupt(struct dwc3 *dwc, From patchwork Mon Aug 20 10:29:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 10570135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35E6014E1 for ; Mon, 20 Aug 2018 10:34:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26BC429271 for ; Mon, 20 Aug 2018 10:34:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B36F29283; Mon, 20 Aug 2018 10:34:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B47D129271 for ; Mon, 20 Aug 2018 10:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726148AbeHTNtI (ORCPT ); Mon, 20 Aug 2018 09:49:08 -0400 Received: from mga01.intel.com ([192.55.52.88]:2440 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbeHTNtI (ORCPT ); Mon, 20 Aug 2018 09:49:08 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2018 03:34:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,264,1531810800"; d="scan'208";a="250267537" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.72.128]) by orsmga005.jf.intel.com with ESMTP; 20 Aug 2018 03:33:52 -0700 From: Felipe Balbi To: linux-usb@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Felipe Balbi Subject: [PATCH 2/4] usb: dwc3: gadget: check if dep->frame_number is still valid Date: Mon, 20 Aug 2018 13:29:59 +0300 Message-Id: <20180820103001.6453-2-felipe.balbi@linux.intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180820103001.6453-1-felipe.balbi@linux.intel.com> References: <20180820103001.6453-1-felipe.balbi@linux.intel.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Gadget driver may take an unbounded amount of time to queue requests after XferNotReady. This is important for isochronous endpoints which need to be started for a specific (micro-)frame. Before kicking the transfer, let's check if current frame number is still less than our aligned frame number that we got from the previous XferNotReady. If it isn't, then we'll increment dep->frame_number to make sure it's ahead of current frame number. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/gadget.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 285ce0ef3b91..3acf8788a680 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -685,6 +685,8 @@ struct dwc3_ep { u8 type; u8 resource_index; u32 frame_number; +#define DWC3_EP_FRAME_NUMBER_MASK 0x3fff + u32 interval; char name[20]; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index f61a4250c883..0bac9b02f28b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1257,6 +1257,9 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc) static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) { + u16 current_frame_number; + u16 frame_number; + if (list_empty(&dep->pending_list)) { dev_info(dep->dwc->dev, "%s: ran out of requests\n", dep->name); @@ -1265,6 +1268,14 @@ static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) } dep->frame_number = DWC3_ALIGN_FRAME(dep); + current_frame_number = __dwc3_gadget_get_frame(dep->dwc); + frame_number = dep->frame_number & DWC3_EP_FRAME_NUMBER_MASK; + + if (frame_number <= current_frame_number) { + dep->frame_number += current_frame_number - frame_number; + dep->frame_number = DWC3_ALIGN_FRAME(dep); + } + return __dwc3_gadget_kick_transfer(dep); } From patchwork Mon Aug 20 10:30:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 10570133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C937814E1 for ; Mon, 20 Aug 2018 10:33:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6EDB29271 for ; Mon, 20 Aug 2018 10:33:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A964629280; Mon, 20 Aug 2018 10:33:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B0D129271 for ; Mon, 20 Aug 2018 10:33:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbeHTNtA (ORCPT ); Mon, 20 Aug 2018 09:49:00 -0400 Received: from mga04.intel.com ([192.55.52.120]:33249 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbeHTNtA (ORCPT ); Mon, 20 Aug 2018 09:49:00 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2018 03:33:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,264,1531810800"; d="scan'208";a="83264383" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.72.128]) by orsmga001.jf.intel.com with ESMTP; 20 Aug 2018 03:33:53 -0700 From: Felipe Balbi To: linux-usb@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Felipe Balbi Subject: [PATCH 3/4] usb: dwc3: trace: log ep commands in hex Date: Mon, 20 Aug 2018 13:30:00 +0300 Message-Id: <20180820103001.6453-3-felipe.balbi@linux.intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180820103001.6453-1-felipe.balbi@linux.intel.com> References: <20180820103001.6453-1-felipe.balbi@linux.intel.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP They are much more useful in hexadecimal than in decimal. Moreover, generic commands are already logged in hex. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h index f22714cce070..50fb6f2d92dd 100644 --- a/drivers/usb/dwc3/trace.h +++ b/drivers/usb/dwc3/trace.h @@ -199,7 +199,7 @@ DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd, __entry->param2 = params->param2; __entry->cmd_status = cmd_status; ), - TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s", + TP_printk("%s: cmd '%s' [%x] params %08x %08x %08x --> status: %s", __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd), __entry->cmd, __entry->param0, __entry->param1, __entry->param2, From patchwork Mon Aug 20 10:30:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 10570143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CC05920 for ; Mon, 20 Aug 2018 10:34:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D0E729271 for ; Mon, 20 Aug 2018 10:34:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 116F329280; Mon, 20 Aug 2018 10:34:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A996B29271 for ; Mon, 20 Aug 2018 10:34:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726438AbeHTNta (ORCPT ); Mon, 20 Aug 2018 09:49:30 -0400 Received: from mga07.intel.com ([134.134.136.100]:56371 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbeHTNta (ORCPT ); Mon, 20 Aug 2018 09:49:30 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2018 03:34:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,264,1531810800"; d="scan'208";a="66352652" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.72.128]) by orsmga007.jf.intel.com with ESMTP; 20 Aug 2018 03:33:57 -0700 From: Felipe Balbi To: linux-usb@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Felipe Balbi Subject: [PATCH 4/4] usb: dwc3: gadget: remove unnecessary dev_info() Date: Mon, 20 Aug 2018 13:30:01 +0300 Message-Id: <20180820103001.6453-4-felipe.balbi@linux.intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180820103001.6453-1-felipe.balbi@linux.intel.com> References: <20180820103001.6453-1-felipe.balbi@linux.intel.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Running out of requests on isochronous endpoints is part of normal operation. We don't really need to know about it every time it happens. Signed-off-by: Felipe Balbi Reviewed-by: Laurent Pinchart --- drivers/usb/dwc3/gadget.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 0bac9b02f28b..8d3e0f2cde8b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1261,8 +1261,6 @@ static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) u16 frame_number; if (list_empty(&dep->pending_list)) { - dev_info(dep->dwc->dev, "%s: ran out of requests\n", - dep->name); dep->flags |= DWC3_EP_PENDING_REQUEST; return -EAGAIN; }