From patchwork Mon Jan 23 14:47:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niel Fourie X-Patchwork-Id: 1730533 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=FAW4CYQ7; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=Dy0YnKzN; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P0vVl5cDcz23gd for ; Tue, 24 Jan 2023 02:42:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 720908574D; Mon, 23 Jan 2023 16:42:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1674488523; bh=y89r8ZMzsn3tEqAL7ZcsIFftVkOnGlwBrHhmLRKDqII=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=FAW4CYQ74Id2ZINBEyiNiPV942POWPtG+Q0U4BL6+CJuX31xsUsNWVmxafF3xuwVy 5A4ifnO0OMRYM3i5BYqGkJmZlrY5Im0HQhuw52Pis4Dh0Oog3HpPf2PNtys3YAbkQS PhmdkufBMlgk7ZEPYVTj5OEtFF0Pz1Yu8rnPFn80csgvCUTh4l3W79Ia03ADjLeAW9 /qj5kbxkIxtlCSLkxLmFW4UFyEHwxjIHlDqqHgzmePjUe6Xz22UwGBX2nZdYPfr2nm 14JeZs7bli8iLl46ishx5eyiJApFAaUgLq6YFnrAPWplB0ClcN8+b1VDt0YssKx5BK 6x0jU61YzFtuQ== Received: from aldebaran.denx.de (unknown [62.91.23.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lusus@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 33FC08550A; Mon, 23 Jan 2023 15:47:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1674485254; bh=y89r8ZMzsn3tEqAL7ZcsIFftVkOnGlwBrHhmLRKDqII=; h=From:To:Cc:Subject:Date:From; b=Dy0YnKzNovPeK4rrv7+KrxrjAaUaV0s7o10naAFQG0lfOnD+Ans0BCGbux66oHi9a 7ty7XiGGXUqcngfRja5tpk2mT2gCqwPSSHxRmmQy1fzK8S9RQHJL8fSvxJFTpRXVAi /mEoKpz4Zqu/YofmJ1AcIJIjwzu0i9EOvOpdgJUeT3/PlqhjsuvI9yptxkw8Oi+P/H Ew2fEC2f+iuAbJQt+x/1cj2pDAc+iX1cm/m8H+lTrF2EfFI2Ec/GDH/2JD3tD2r/nw QBSWNWsHE9l+HmGuKP/aCFqV8zXGcrZfOpD2c6FOqzrAOP904B0PoVzPmY9aQVCWd+ cRX+X4qFnLF0w== From: Niel Fourie To: u-boot@lists.denx.de Cc: Niel Fourie , Marek Vasut Subject: [RFC][PATCH] usb: dwc3: gadget: workaround for Netconsole hang Date: Mon, 23 Jan 2023 15:47:24 +0100 Message-Id: <20230123144724.1291327-1-lusus@denx.de> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean In dwc3_remove_requests(), the while loops clearing out request lists req_queued and request_list may loop infinitely as the last remaining elements in these lists end up not pointing to their respective list_head structures. This workaround detects and replaces the last element with the expected list_head to break out of these loops. No memory is leaked as the previous last element gets reused. This issue occurs when Netconsole is active over Ethernet gadget, and the cause it is still unclear. Any ideas? Signed-off-by: Niel Fourie Cc: Marek Vasut --- drivers/usb/dwc3/gadget.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index eb416b832a..61f3e367cb 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -538,6 +538,14 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) req = next_request(&dep->req_queued); dwc3_gadget_giveback(dep, req, -ESHUTDOWN); + /* FIXME! */ + if (dep->req_queued.next == dep->req_queued.prev && + dep->req_queued.next != &dep->req_queued) { + printf("Stuck? Emptying req_queued... head=%lx, next=%lx;\n", + (ulong)&dep->req_queued, (ulong)dep->req_queued.next); + dep->req_queued.next = &dep->req_queued; + dep->req_queued.prev = &dep->req_queued; + } } } @@ -545,6 +553,14 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) req = next_request(&dep->request_list); dwc3_gadget_giveback(dep, req, -ESHUTDOWN); + /* FIXME! */ + if (dep->request_list.next == dep->request_list.prev && + dep->request_list.next != &dep->request_list) { + printf("Stuck? Emptying request_list... head=%lx, next=%lx;\n", + (ulong)&dep->request_list, (ulong)dep->request_list.next); + dep->request_list.next = &dep->request_list; + dep->request_list.prev = &dep->request_list; + } } }