From patchwork Tue Oct 23 13:43:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 10653241 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 D713B13B5 for ; Tue, 23 Oct 2018 14:07:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D40EA2959F for ; Tue, 23 Oct 2018 14:07:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5211298C1; Tue, 23 Oct 2018 14:07:27 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 E429F2959F for ; Tue, 23 Oct 2018 14:07:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728102AbeJWWbC (ORCPT ); Tue, 23 Oct 2018 18:31:02 -0400 Received: from dougal.metanate.com ([90.155.101.14]:49637 "EHLO metanate.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726277AbeJWWbB (ORCPT ); Tue, 23 Oct 2018 18:31:01 -0400 X-Greylist: delayed 1460 seconds by postgrey-1.27 at vger.kernel.org; Tue, 23 Oct 2018 18:30:56 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=odhuCzb/dOdWC5S9mjKZUkng4ktxpugMcjGnrB7yp+o=; b=QOvT+kqoExsrPnbRkaLz977CAE GfP8VOrUK2drgjRBEtrBFBmkJUobdIHx8fc+istkNDmtxadcLFBwY8CxjBfptnY5DgWU7xxvVY387 HAFn+YopqvFp69ArzumRzrEmSkXzgj4zSWxoF/nglpS/jbOaKRIMcWFbv4/6tb9WU5tZa7Eqnzgcy /HSuWinB3VDmBfmjhQzOgJxNLhExRdS0ZskgB+2Qxl1iNc5lJ2jeQTIW459o8hk84hz8OfNkA2KiE TRRiMOQDzm2JBk1vLU5BJ/9HvOPwBIaz4KbYSppkEVdO0wZs/zZoPeuUldOjN9W1Ep/RVZ+75YiDp O4fvRrPw==; Received: from dougal.metanate.com ([192.168.88.1] helo=localhost.localdomain) by shrek.metanate.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1gEwxZ-0004DG-4p; Tue, 23 Oct 2018 14:43:01 +0100 From: John Keeping To: Minas Harutyunyan Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, John Keeping Subject: [PATCH] usb: dwc2: gadget: fix ISOC frame overflow handling Date: Tue, 23 Oct 2018 14:43:55 +0100 Message-Id: <20181023134355.29829-1-john@metanate.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.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 By clearing the overrun flag as soon as the target frame is next incremented, we can end up incrementing the target frame more than expected in dwc2_gadget_handle_ep_disabled() when the endpoint's interval is greater than 1. This happens if the target frame has just wrapped at the point when the endpoint is disabled and the frame number has not yet done so. Instead, wait until the frame number also wraps and then clear the overrun flag. Signed-off-by: John Keeping --- drivers/usb/dwc2/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 2d6d2c8244de..8da2c052dfa1 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -117,7 +117,7 @@ static inline void dwc2_gadget_incr_frame_num(struct dwc2_hsotg_ep *hs_ep) if (hs_ep->target_frame > DSTS_SOFFN_LIMIT) { hs_ep->frame_overrun = true; hs_ep->target_frame &= DSTS_SOFFN_LIMIT; - } else { + } else if (hs_ep->parent->frame_number < hs_ep->target_frame) { hs_ep->frame_overrun = false; } }