From patchwork Fri Jul 19 11:00:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvarasu Ganesan X-Patchwork-Id: 13737201 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 394D486131 for ; Fri, 19 Jul 2024 11:10:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721387440; cv=none; b=UEmYcq8A+V737G4t3JtKvjtagRClQOCcWlyOPK2xbiQ7YgPQQRjbjECSy9ybyz3u8rs6/JKPVgrj1wMTZ+l5he0sOVExhCmKMNVjZ949cX3RhKDPvzePNEKUhvU81TKMvfYGJer+ZRNkqMenixJHgDbsXqOv0z5pyn8YsDLI0xg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721387440; c=relaxed/simple; bh=FLpC8utwEIJQLiEshcqIPSR5PVM/wZvPxXyaAC6uHsc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: References; b=CGd1cleHM2t2C7NAQ9B2qPWx1I9BQNbuwEmdxMlo17VNSEJxtITrH+dIK0gTgwS9bEUNt7r4oZzQFH/00dF+i3ddzQEt/IP6KcEjJerQ0xcCjkjVcEvHumfHm4pZ+ujlZ1ecob4b7mfJMLd5a2oAp8bu8icUkFoxWB4bt6i72tc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=moKWrtoP; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="moKWrtoP" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240719110234epoutp048afdeae7286d3baaef3142ef76744b5d~jmFCTh2BM2888828888epoutp04P for ; Fri, 19 Jul 2024 11:02:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240719110234epoutp048afdeae7286d3baaef3142ef76744b5d~jmFCTh2BM2888828888epoutp04P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1721386954; bh=tcuRRKl9VdtIuqpxCnve4eFVQA4up3PEYahY4FJVRzI=; h=From:To:Cc:Subject:Date:References:From; b=moKWrtoPH7Rxg8mbqoMZBa35TA6D5e0xzBFWbXvQj98N7sGTZu+/sleo5x4h+AwT2 SUl3KTnKah/NWdHIqrM4AeIgsSGgxF9wYQqWTcsvcx9sAvWsbsvihmOb2p6U0cZ+D7 tFo0FuEXlGENDOPpySnFAeT5W2Y4YWD1tVqygAAA= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240719110234epcas5p38d1d74df6ad45f6e034449db901cd3ee~jmFB7KYtE0712207122epcas5p3a; Fri, 19 Jul 2024 11:02:34 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.182]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4WQRbD5sMnz4x9Pr; Fri, 19 Jul 2024 11:02:32 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id E8.7C.09989.8C74A966; Fri, 19 Jul 2024 20:02:32 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240719110149epcas5p3dd468685a095c094ed2e540279bf3ec2~jmEYmHhz02242422424epcas5p34; Fri, 19 Jul 2024 11:01:49 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240719110149epsmtrp25c08edf6ec93b393aa106dc5111b81b6~jmEYkGekN1989019890epsmtrp2i; Fri, 19 Jul 2024 11:01:49 +0000 (GMT) X-AuditID: b6c32a4a-bffff70000002705-0c-669a47c80f32 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E5.84.07412.D974A966; Fri, 19 Jul 2024 20:01:49 +0900 (KST) Received: from INBRO002811.samsungds.net (unknown [107.122.5.126]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240719110146epsmtip2d040cbc2bf24a38e8310d9f22193ebb0~jmEVwip5h0667406674epsmtip2J; Fri, 19 Jul 2024 11:01:46 +0000 (GMT) From: Selvarasu Ganesan To: Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jh0801.jung@samsung.com, dh10.jung@samsung.com, naushad@samsung.com, akash.m5@samsung.com, rc93.raju@samsung.com, taehyun.cho@samsung.com, hongpooh.kim@samsung.com, eomji.oh@samsung.com, shijie.cai@samsung.com, Selvarasu Ganesan Subject: [PATCH] usb: dwc3: Potential fix of possible dwc3 interrupt storm Date: Fri, 19 Jul 2024 16:30:55 +0530 Message-ID: <20240719110100.329-1-selvarasu.g@samsung.com> X-Mailer: git-send-email 2.45.2.windows.1 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIJsWRmVeSWpSXmKPExsWy7bCmuu4J91lpBks/qlm8ubqK1eLOgm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ceaIQskXsb8/72WYm5DM+uHF73Qoml OCPRUIu5qDgRAJBasAzfAgAA X-CMS-MailID: 20240719110149epcas5p3dd468685a095c094ed2e540279bf3ec2 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240719110149epcas5p3dd468685a095c094ed2e540279bf3ec2 References: In certain scenarios, there is a chance that the CPU may not be scheduled the bottom half of dwc3 interrupt. This is because the CPU may hang up where any work queue lockup has happened for the same CPU that is trying to schedule the dwc3 thread interrupt. In this scenario, the USB can enter runtime suspend as the bus may idle for a longer time , or user can reconnect the USB cable. Then, the dwc3 event interrupt can be enabled when runtime resume is happening with regardless of the previous event status. This can lead to a dwc3 IRQ storm due to the return from the interrupt handler by checking only the evt->flags as DWC3_EVENT_PENDING, where the same flag was set as DWC3_EVENT_PENDING in previous work queue lockup. Let's consider the following sequences in this scenario, Call trace of dwc3 IRQ after workqueue lockup scenario ====================================================== IRQ #1: ->dwc3_interrupt() ->dwc3_check_event_buf() ->if (evt->flags & DWC3_EVENT_PENDING) return IRQ_HANDLED; ->evt->flags |= DWC3_EVENT_PENDING; ->/* Disable interrupt by setting DWC3_GEVNTSIZ_INTMASK in DWC3_GEVNTSIZ ->return IRQ_WAKE_THREAD; // No workqueue scheduled for dwc3 thread_fu due to workqueue lockup even after return IRQ_WAKE_THREAD from top-half. Thread #2: ->dwc3_runtime_resume() ->dwc3_resume_common() ->dwc3_gadget_resume() ->dwc3_gadget_soft_connect() ->dwc3_event_buffers_setup() ->/*Enable interrupt by clearing DWC3_GEVNTSIZ_INTMASK in DWC3_GEVNTSIZ*/ Start IRQ Storming after enable dwc3 event in resume path ========================================================= CPU0: IRQ dwc3_interrupt() dwc3_check_event_buf() if (evt->flags & DWC3_EVENT_PENDING) return IRQ_HANDLED; CPU0: IRQ dwc3_interrupt() dwc3_check_event_buf() if (evt->flags & DWC3_EVENT_PENDING) return IRQ_HANDLED; .. .. To fix this issue by avoiding enabling of the dwc3 event interrupt in the runtime resume path if dwc3 event processing is in progress. Signed-off-by: Selvarasu Ganesan Signed-off-by: Selvarasu Ganesan --- drivers/usb/dwc3/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index cb82557678dd..610792a70805 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -549,8 +549,12 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc) lower_32_bits(evt->dma)); dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), upper_32_bits(evt->dma)); - dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), - DWC3_GEVNTSIZ_SIZE(evt->length)); + + /* Skip enable dwc3 event interrupt if event is processing in middle */ + if (!(evt->flags & DWC3_EVENT_PENDING)) + dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), + DWC3_GEVNTSIZ_SIZE(evt->length)); + dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); return 0;