From patchwork Fri Dec 14 16:32:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zengtao (B)" X-Patchwork-Id: 10730699 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 9559B14BD for ; Fri, 14 Dec 2018 08:30:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BAA62CF33 for ; Fri, 14 Dec 2018 08:30:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7011B2CF60; Fri, 14 Dec 2018 08:30:04 +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=-6.0 required=2.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, 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 4821C2CE3E for ; Fri, 14 Dec 2018 08:30:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726634AbeLNI36 (ORCPT ); Fri, 14 Dec 2018 03:29:58 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:16126 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726494AbeLNI36 (ORCPT ); Fri, 14 Dec 2018 03:29:58 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 7F973D1C09A30; Fri, 14 Dec 2018 16:29:54 +0800 (CST) Received: from dessert.huawei.com (10.69.192.158) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Fri, 14 Dec 2018 16:29:47 +0800 From: Zeng Tao To: CC: , Zeng Tao , "Greg Kroah-Hartman" , , Subject: [PATCH] usb: dwc3: gadget: fix miss isoc issue introduced by IRQ latency Date: Sat, 15 Dec 2018 00:32:58 +0800 Message-ID: <1544805179-2248-1-git-send-email-prime.zeng@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.69.192.158] X-CFilter-Loop: Reflected 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 If it's a busy system, some times when we start an isoc transfer, the framenumber get from the event buffer may be already elasped, in this case, we will get all the packets dropped due to miss isoc. And we turn into transfer nothing, to fix this issue, we need to fix the framenumber to make sure that it's not out of date. Signed-off-by: Liang Shengjun Signed-off-by: Zeng Tao --- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/gadget.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 5bfb625..8742d96 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -452,6 +452,9 @@ #define DWC3_DSTS_RXFIFOEMPTY BIT(17) +#define DWC3_EVENT_PRAM_MAX_SOFFN 0x3fff +#define DWC3_EVENT_PRAM_SOFFN_MASK 0x3fff + #define DWC3_DSTS_SOFFN_MASK (0x3fff << 3) #define DWC3_DSTS_SOFFN(n) (((n) & DWC3_DSTS_SOFFN_MASK) >> 3) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 9f92ee0..b63bd72 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1263,6 +1263,15 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc) return DWC3_DSTS_SOFFN(reg); } +static bool __dwc3_gadget_target_frame_elapsed(struct dwc3_ep *dep) +{ + u16 cframe = __dwc3_gadget_get_frame(dep->dwc); + u16 eframe = dep->frame_number & DWC3_EVENT_PRAM_SOFFN_MASK; + + return (((eframe - cframe) & DWC3_EVENT_PRAM_SOFFN_MASK) + > DWC3_EVENT_PRAM_MAX_SOFFN / 2); +} + static void __dwc3_gadget_start_isoc(struct dwc3_ep *dep) { if (list_empty(&dep->pending_list)) { @@ -1272,6 +1281,9 @@ static void __dwc3_gadget_start_isoc(struct dwc3_ep *dep) return; } + while (__dwc3_gadget_target_frame_elapsed(dep)) + dep->frame_number = DWC3_ALIGN_FRAME(dep); + dep->frame_number = DWC3_ALIGN_FRAME(dep); __dwc3_gadget_kick_transfer(dep); }