Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1446620lqa; Mon, 29 Apr 2024 08:40:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBuBvzBi00eKWmbxG0+GniMWdQWZlRUCwZZ5oKGmCVxs0mFDmkz4w0thQ/LWUh42S/NDaKQoCmZsTlZvgAWzVeG7ni/8pee5BWL0e6zw== X-Google-Smtp-Source: AGHT+IFx+4D//F2evNGVRk7l23pd/5pZ7prr3iqwccwq+/ZOSLxCp2CmyIMLvCGbdL3WxlZZvdeG X-Received: by 2002:a17:903:124e:b0:1e4:2451:c2b5 with SMTP id u14-20020a170903124e00b001e42451c2b5mr22716plh.13.1714405226907; Mon, 29 Apr 2024 08:40:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714405226; cv=pass; d=google.com; s=arc-20160816; b=0sc8D4KTmtbBA/RaRPxigTUokdGSrSUag/e8x6rd1kJrXE842QgQ/TUTuTwcsDorNm 14jQCYvD3Z9bpOUELIOIunU0X6/bPHyPuM4PpwoLnI91Kz7QUdLt3IFSiPjYOxfJwf7F NWHscSfQi6iLQHcoilj3xEIZKyD/BCDkHg1+39tdVX10idXWUWeG6ZPQUnFmrTLkZFD8 fbSjL9cUsnT3NFxltPZExNUd2IKVIYwFCL7TDee2jId109D5XHRDFKs1cYTq9Y5gcpg5 9qtqzuy9654jCrWdDOjb3myUi1Jekie6bsNDljFPYpomeGnUz2nz6+ojWVlYZmchY4JV 6+eQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:sender:dkim-signature; bh=fBrnMC0Gct0UOxf9AGIaJ9EyFFBNBd1gd9JECoTWjF4=; fh=olL5Cj8DVIifAKrxGf3E/9r2pM01XXIFuNU4NbTIpDw=; b=VYue9Lke6DA6toCxKN2lsPHwxkUTq8lGHBh05equr9ABPXTEYYgdLio8DnwKT+mWU+ 61wgc8ptyDDtC4XYYCJFMRAKm2zL07wo+iuq9DrIk1zomB8hc1A8IXBioZ7kE0ykvnrx QtKtEq45R7709Nl9tVUlFQ+m6RKgAvWY7G0KBO3I14kFKW/CFmG6ssk+9LV9/Awf9Kiv 5AggfVGkZMbiM9FlXSH7GAIlHfFfEV2+EMIvmROY1OVq+GbeHjXBefCw2rkJqPKUieAT p0NBEDzpNvGyMFgazHXsSaNis+0onUV9yV2YBlNd1/xJqJ11W7/OzhelAaUVn1BBzTOA 2EdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FpCY4KKc; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-162603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162603-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b14-20020a170902650e00b001e29483faccsi19259247plk.635.2024.04.29.08.40.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:40:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FpCY4KKc; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-162603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162603-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 89394280FA3 for ; Mon, 29 Apr 2024 15:40:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A0EC8287C; Mon, 29 Apr 2024 15:40:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FpCY4KKc" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 142437E0F6; Mon, 29 Apr 2024 15:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714405216; cv=none; b=NsH8Vh8sNYby5zrTXFnvUYmx9vnFALtPzi8rgYZaR/B+iyWLv9+avF3C7p6vJdlzxyshW4Ypy8xEad1x/9+HjwzzifXewyMrvISRuxyq3Udl3GTeC5o/d7rjiydxNEhuVvQOK7fgt3hHQXvei+sr68AYE5qzzScw7mYgmBJxDZc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714405216; c=relaxed/simple; bh=zXY1ffgM5q+lSr46Op+3+XcAUtlsLSzt87wdaCFSWfw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=g9XVjq8ve7aD0AEsA5VqsOiwndC7vQJcev523PqH57xjfnb+NCjQCoxQA04Bk4B4MgWfBKolQZkmEltonEjfOFBGLHsZvsWByB/NIuXW+qF1ho4G+4bCkH0kQGTLFrG1GUv8aP9dAwZ15SV8bSZ8DXYAzgI9JOlzhLj8KplNOOo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FpCY4KKc; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1e9320c2ef6so33110085ad.2; Mon, 29 Apr 2024 08:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714405214; x=1715010014; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=fBrnMC0Gct0UOxf9AGIaJ9EyFFBNBd1gd9JECoTWjF4=; b=FpCY4KKcHaxCE9rgyiF5maCAMl7Ska+5gFg5rsrj2J2RNMivZo2Ej7/g49nY5/uw7n z/VYs2V9XpNhV4aU1jD+3IrSoS4xPgOKGAVKmBQ/QbtgLyMG6rv/LZ/6PRUrUQh81h1h ThbflVqGMGMUWFNjtXsfVBzcN4Rr/D5cQ/6V3hwkNYiJ2GhZMMAEIMXJ9EKtpUxFBOFH 47hCAdsDrSFGZLqRmo/CTCNqa0493Ep1eEG4YZ9BxdEXHK2w6J72PskbgXVjVyFjdbLl 1bJ2frHSnjuyHQI7QrSSsRxpBz+8ZNyVCfSBRAjz7kmIOqdD0IZSv8BW+MpkMNoD0+// mJpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714405214; x=1715010014; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fBrnMC0Gct0UOxf9AGIaJ9EyFFBNBd1gd9JECoTWjF4=; b=VAEYSZni1BMcDQKp9QI4fNE5pblr5Zl7TBKZbuds3vg4l5RLce7S8t4pe4MqyFGT2p qa8CJVBrg0uZzpHjk6dSEkf7EbEe8RKEWfsIJ1S0YQprm7V9zhVvv8Qs97QNlHxAoj6F aUOpXS98hkqwWaCainLRvfFcesrFe9YuJwrSaifsbgLg64zqphWREcjjCFUkxYuv6OR9 YKX730FXW5HAt19ikjk1Dim4dv9xUhr2gkg3lM1MHoCcOEC/H+1OGqhUYD9tdGqv6NER SbN7SAeZECht+sAjl7tG84Osry/l8snq8QYye4ayiIOnyGWKIpuSAQOOR1KB2rpe3H+h fHMg== X-Forwarded-Encrypted: i=1; AJvYcCVLJj3RzcE1Hy5s6K32e6llfyJuwwMOMIrBK9w9StMrleJDHIcQNRGPPhBtqnaor7glaAgWTnQgSDF08LCC+ZeJKhanJ3YwUsIBCEiWC2o+t/CUQl0t1SdWQPdamg+6mTPhMNlkgqyC X-Gm-Message-State: AOJu0YxhtxX3zUNz5n9YTgvWMf8lyZtips5oaLe7noDUTgnBrKwjHaV1 +Exd4PS2k4ZzrQ3LSH8zKMiC+5xiNr5IGECW+MrvG+n2wcfBJMre+SlNRQ== X-Received: by 2002:a17:902:a60a:b0:1e4:9d6f:593 with SMTP id u10-20020a170902a60a00b001e49d6f0593mr4767plq.36.1714405214379; Mon, 29 Apr 2024 08:40:14 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q12-20020a170902a3cc00b001dd707d5fe6sm20863719plb.158.2024.04.29.08.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:40:13 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Alan Stern Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, David Laight , Gerd Hoffmann , Guenter Roeck Subject: [PATCH v3] usb: ohci: Prevent missed ohci interrupts Date: Mon, 29 Apr 2024 08:40:10 -0700 Message-Id: <20240429154010.1507366-1-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Testing ohci functionality with qemu's pci-ohci emulation often results in ohci interface stalls, resulting in hung task timeouts. The problem is caused by lost interrupts between the emulation and the Linux kernel code. Additional interrupts raised while the ohci interrupt handler in Linux is running and before the handler clears the interrupt status are not handled. The fix for a similar problem in ehci suggests that the problem is likely caused by edge-triggered MSI interrupts. See commit 0b60557230ad ("usb: ehci: Prevent missed ehci interrupts with edge-triggered MSI") for details. Ensure that the ohci interrupt code handles all pending interrupts before returning to solve the problem. Cc: Gerd Hoffmann Cc: David Laight Cc: stable@vger.kernel.org Fixes: 306c54d0edb6 ("usb: hcd: Try MSI interrupts on PCI devices") Signed-off-by: Guenter Roeck --- v3: Check if any interrupts are pending before reading intrenable Add 'Cc: stable@vger.kernel.org' v2: Only repeat if the interface is still active Note that I did not apply Alan's Reviewed-by: tag since I was not sure if that was appropriate after the code change. drivers/usb/host/ohci-hcd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 4f9982ecfb58..5cec7640e913 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -888,6 +888,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) /* Check for an all 1's result which is a typical consequence * of dead, unclocked, or unplugged (CardBus...) devices */ +again: if (ints == ~(u32)0) { ohci->rh_state = OHCI_RH_HALTED; ohci_dbg (ohci, "device removed!\n"); @@ -982,6 +983,13 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) } spin_unlock(&ohci->lock); + /* repeat until all enabled interrupts are handled */ + if (ohci->rh_state != OHCI_RH_HALTED) { + ints = ohci_readl(ohci, ®s->intrstatus); + if (ints && (ints & ohci_readl(ohci, ®s->intrenable))) + goto again; + } + return IRQ_HANDLED; } -- 2.39.2