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: Zeng Tao X-Patchwork-Id: 153785 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1799612ljp; Fri, 14 Dec 2018 00:30:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/UsPgamThbYdNdcpaRBlnnUQoZsmY2WkfnVIvSyag0AuliR2IefuQTTkcMi+Yp4dMO5p0p3 X-Received: by 2002:a17:902:380c:: with SMTP id l12mr1971873plc.326.1544776200239; Fri, 14 Dec 2018 00:30:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544776200; cv=none; d=google.com; s=arc-20160816; b=GY9wGzuKVM+OkrcUiPfV1Gf8yNnx7ZwPiZFVl6ng3/xLy7iF2lsCFS3Oydcsh/HFFn bJXH4XUXfsQ8WRNBtnFIbWMniIIeQRHQjMYouhRYLsb8G/K2ZY62fiYCY7qyNSzqD607 JBCK866FVG/OoL7vYgrVTByJcNGGo8+ymsSAq0LIUcg4UiV4U3PQIhjU8LlEbR5GVn0T F7ErSh5pAegKM+JjOnkDss+Ovhs2OrcGeZqnvybZOhAIb6dPUr32feVvYI2oDrUxgkCc 0tGezxTdmVLIYeIGjuWxFKDZdZSaBnXNGlJnWzXraiqhDDiEyoIJV8weTv/rFeosGQeB Xh8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=6veDL45R1P5HXnVXPjyMMJJBBDNDDSG3QUX9H+JFNrc=; b=O/6DZMGjCnn3Ev9JzlRMt4OyjEkSe8cUpk2nJE9Roo4VmX05CpSjjkuOO66s8oPRbe 4mJFTZz36pXnreCf7PgVrVVR15HkOM3sZYRlBQa5V308DPpNcmJxKbRwD1K5v+q7RARF /3tR9KgMaJOYe7J+ewn5TAvOLXbFPNzITV70JDmcSfyFjLFcBpwE/Zs2O4iuYrrw3Ak0 zuxsjxBqXN3zzPrf4qLxeAq0JByeh0kQbWe4uSV6q0HpXxnZQcXYl91VETkMwWc6U/Lc LMYAN7uuLUnI6nB1vJdMvS2oxhSFBXfPDqq5zB2cs/hg9Q0K801NFRZwwOSSsH3NGjxK TXjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si1900348pls.348.2018.12.14.00.29.59; Fri, 14 Dec 2018 00:30:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727812AbeLNI36 (ORCPT + 31 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 2.7.4 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); }