Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2660067pxj; Mon, 14 Jun 2021 04:16:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSZdijVe3RYnh8gS6K0KqCVJqLWadBzejyYu0nBdwlG26j6ByQbTA33x0M56+yjndrzqoO X-Received: by 2002:a17:906:2306:: with SMTP id l6mr14455156eja.362.1623669391554; Mon, 14 Jun 2021 04:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623669391; cv=none; d=google.com; s=arc-20160816; b=pYTQ/s5ef6o4qWhmKrRItboBtxA+9WJiiQkqTcGPQO5A+5mz93RVijjgjNwCdtd7I6 vTxuonBlXp3O1z5qwC+eLUjVF8NYsqfPAGHg6B2C4N68nF1RXHVH8EjL6C5ZLcfbYRZw tUT93f3SEXcyhetEZK0hwR4UFW8jXmwqr9qgT+FgurcVv6t5mbaEFf3fcOICYxnjhEeJ UhNtaG4ITT2TaFzjb4s8IvRRtzr6x389r9SydmF/fF0IY8PxSmQHexsB/629L1rjzwnn Rp3XHhhA7xpTva0NUJYBFJdb0Xc28KiI0APFtI0jONyO3WtesEo60ArFPVrz/N/uNV/0 mirg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9QgyBqak4vQWXmBa5wtzupCR/gSmo/fuHHmbldH2GBg=; b=DItFHZ0dhfQ4k8vYsCc6Rg18RlNm9fWE4WnV3a5w9GLJd9B+HW2WomBI3P1vmgghc/ YjmI3gPW1yPkjAGcFP5aVtLraeQq2ezc9KJ4rPYvQOzdntuf/4+G1HeVjIS7vns9SGlt 4r1oIafmznMtRC65ExP7sIAlv1UufphCBvkyjPbOJP55IpGrdfL5u7JWKNnc0LV4Nn28 AxWzf7OvcGUP7ew8ywgvPMyVC6hjgbFiX2jtCjlswUgTu43VksnIN5RrB3Cq8NcpBnDs nyzjz44f0ffYqGu4xjZKI8gpdrWtiS9WV1nD00pCFgG/B7/6xE7TigSF53Vkat4F4oTF ZRPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ItY5Dp/g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si11242885ejl.368.2021.06.14.04.16.08; Mon, 14 Jun 2021 04:16:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ItY5Dp/g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235224AbhFNLRH (ORCPT + 99 others); Mon, 14 Jun 2021 07:17:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:39218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235158AbhFNLEz (ORCPT ); Mon, 14 Jun 2021 07:04:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3C6E861922; Mon, 14 Jun 2021 10:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667504; bh=GZTvuJ4ltC2xa1h+xkROpdxuA/Sh+xJtoNitjtceiRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItY5Dp/grATxrdRpIzrydR4XdSP89HUZkv1OllMGEBVRgQQICyNuhogOzq3wZJD2G c3c6ftoZQAbCnhbTEwpY3J/hb52NUvawIMJuaU+xT5Q8wfoJJM+ZPFAfyrKzeT7koc ddwYBycSmusWXPULe5faOLnTJapiZm0zl/7WEOFk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wesley Cheng Subject: [PATCH 5.10 097/131] usb: dwc3: gadget: Disable gadget IRQ during pullup disable Date: Mon, 14 Jun 2021 12:27:38 +0200 Message-Id: <20210614102656.303490027@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102652.964395392@linuxfoundation.org> References: <20210614102652.964395392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wesley Cheng commit 8212937305f84ef73ea81036dafb80c557583d4b upstream. Current sequence utilizes dwc3_gadget_disable_irq() alongside synchronize_irq() to ensure that no further DWC3 events are generated. However, the dwc3_gadget_disable_irq() API only disables device specific events. Endpoint events can still be generated. Briefly disable the interrupt line, so that the cleanup code can run to prevent device and endpoint events. (i.e. __dwc3_gadget_stop() and dwc3_stop_active_transfers() respectively) Without doing so, it can lead to both the interrupt handler and the pullup disable routine both writing to the GEVNTCOUNT register, which will cause an incorrect count being read from future interrupts. Fixes: ae7e86108b12 ("usb: dwc3: Stop active transfers before halting the controller") Signed-off-by: Wesley Cheng Link: https://lore.kernel.org/r/1621571037-1424-1-git-send-email-wcheng@codeaurora.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2143,13 +2143,10 @@ static int dwc3_gadget_pullup(struct usb } /* - * Synchronize any pending event handling before executing the controller - * halt routine. + * Synchronize and disable any further event handling while controller + * is being enabled/disabled. */ - if (!is_on) { - dwc3_gadget_disable_irq(dwc); - synchronize_irq(dwc->irq_gadget); - } + disable_irq(dwc->irq_gadget); spin_lock_irqsave(&dwc->lock, flags); @@ -2187,6 +2184,8 @@ static int dwc3_gadget_pullup(struct usb ret = dwc3_gadget_run_stop(dwc, is_on, false); spin_unlock_irqrestore(&dwc->lock, flags); + enable_irq(dwc->irq_gadget); + pm_runtime_put(dwc->dev); return ret;