Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp3544563ima; Tue, 23 Oct 2018 07:35:33 -0700 (PDT) X-Google-Smtp-Source: AJdET5djZkUMxR3QuB/5zL3plFxDtzYzE8cxa//OrzVI+ElqHRqZY0LDP14mVs5jP6cInP2CMZeG X-Received: by 2002:a17:902:904a:: with SMTP id w10-v6mr10267742plz.225.1540305333358; Tue, 23 Oct 2018 07:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540305333; cv=none; d=google.com; s=arc-20160816; b=sS30dfQGIePgq679ezJouT9Zyui2YJ9jrOCswbCjnVZ0JqIK1uf3+tyGArd8UEbRyo PwO64lO6VPkWmLYLsoe7ufe78hDjRROdGiyYv0jLrHdStc5PeLmmYywxVdT6jUdHmLKU bICrPQdG7AZTTSKWoCs6zngIVL0FveS/7XIpOrZ05NW/XXfAm87g/9ztXYuXMcvGx3Ds /Z5ysHGLgYwLWVA7uQSk52QfszIPHCkYwqGsdYIFj7X+NW9QiumTGV33nkr+P07QnUsi otiFCRxiKRRaRgSPiZbMz1Tv1uU9JL0oz/Z9nC5eAAoflk8WkeYpGcgp0jc8WjKyM1hE UJMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/SSS9ozVA6P6kTEYLpCg3rKNmIJ6zDXKRw+BpGdkn7Y=; b=DeWG2VXetT+VRqs0sG4QS8KkoXyoiym1Y6XoKqEElj/0mCs4/6pJ/NqQ/qZW39yQhw pceEu8RKfv/qSBtLoGJLixxG07f/cZC16n1iVo4aOL26EhyKXlr+DGxlOIuNr1J8jE1/ yfSu5spfyEbaSd6lIQaJYuOuVeS5vMP8Oc2VgdNhifIb3qakrzPXaSI2o4tMAWDbCqta ge5FaKg7PI1zwpzZtis1EtxJ4O6qfEUJe/47A1ummYS/fiKUpOpp9zt3cbq4/3qN0UFy yCCZkzG/HtwaEkx+QJNgXuSh2yHIsRGXU7hmpdnrnxolyqVslfkdKyUJdByngoTgsRKl UtAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@metanate.com header.s=stronger header.b=QOvT+kqo; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=metanate.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2-v6si1421009pln.232.2018.10.23.07.35.15; Tue, 23 Oct 2018 07:35:33 -0700 (PDT) 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; dkim=fail (test mode) header.i=@metanate.com header.s=stronger header.b=QOvT+kqo; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=metanate.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728233AbeJWWbC (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } } -- 2.19.1