Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp562865lqa; Sat, 27 Apr 2024 14:01:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMH0MqaKuVg/W5eZxj/xbm+lmLF0s1kSEmOzDvrKD8F/CArjA35XSMhmtBF5pAmnSksGIacAUUPxeJ1xV2+PShIvQOBT3FmTDiderIPA== X-Google-Smtp-Source: AGHT+IFPYRriLLrROLbq9uM01Ozom3i29WWuoddfB5dFJNvyAGL6HoPDZ9gQT2lM8Es2+F3XbmaD X-Received: by 2002:ac8:57d3:0:b0:43a:bd5b:9657 with SMTP id w19-20020ac857d3000000b0043abd5b9657mr2389962qta.1.1714251702407; Sat, 27 Apr 2024 14:01:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714251702; cv=pass; d=google.com; s=arc-20160816; b=aluFEFjYoSzolKSnac/Uud/TXIlcenFsYn7mhFlLmB92L4X/+tkQhColVoMQ5z8TfF YlsdTZN0+Io/CXhBj4V6+2mPYpV5nTZrTpqWrymy3nRu2/0Z5seCX41MvoLtdGY3C0nx 30PwfBIs+UbXosal7l2b+SXTvYvRCRwRCsxy0kev74pR74luo1QP3asx1oI7QfFacbzj MSZ/gOtBnKPhHjgkJTC3FHH7m3h9c7RF9yK3vQudolkOTX5fLYNCP6tJx7P2mShX0OSO owSyyYhIiOYZ/G5bxTTopkct8z+bv/R68UNRv8J1kbVb8X9r0Co+HhExiH8ZfLN3qFwD dj8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=gBkVFjlXwRa2YA0q8fuL/wrfH9s3c7oBrFVTozG8aWc=; fh=ygvC+QbFdrJ62GDJ+2IXb7hPo2aGM3V0L0gnsLL6T58=; b=EjKmPK4KLmrlR0L2G4jIaGb+bb4Z3CITQIzp4PsiF2rlombFx8jKoJxXalWloKQm2/ bL4q4jup2KaaNelNtsYgQP0jQm2rrbeOGyuwZqlo/6QSUbw0CqBLufNxYTc5CtMqng72 rMd/d1Qh1EJn/1wqGagpHAP9GRY48JaJqr8mnBWkRVUy1fb1A1HkgbpUsyLwgun6+XZo 0vVomjfqWU5IqgYh8IBV0H/1ib/mjw2H0ihWciDeJEI3Ssvb0mRjiYL05KhcmVOv74AB ED5vTeCE49HRnfjCFagMVnA3UlJ1HoS08qzQwJ8ZditMMCm0GASc9lmvgNTJYwK/ryXf HBOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-161189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 21-20020ac85915000000b0043ab1e49c30si1450768qty.84.2024.04.27.14.01.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 14:01:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-161189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 259A41C20BF6 for ; Sat, 27 Apr 2024 21:01:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 586FD145B30; Sat, 27 Apr 2024 21:01:33 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) (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 7689710E6 for ; Sat, 27 Apr 2024 21:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.85.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714251692; cv=none; b=LIAckZuDrwXPqkDcX9M9ra9zBj09NoQv63yjSALHAobRRVG0I773AdnaXeu2M3VROytVFIngm8Aq1C72hG3ro3gomadCmVSr/FEutUmZEq1spozjRMZQhXY1MYGuzoUDW1xMf+q0JRwbT4439ICOjzdOlLysnLo8dZ6owMfRzj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714251692; c=relaxed/simple; bh=ypscR+3qCxpM1RhQ3YAYgMq1bVR/OwF890AX19OR/fA=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=S0S2DugCa4Kfh89uPy5sPnuLsacoe7lcoof6llvxiDxOm6Yhp0BI1GE3P7lbOSgi0rl9aNi089Trc8bNB9z+kdwyeQLwvj78+XBEuN8BC+PJ0oulhCpgl0u6ERRc1K4QnXmcq2dGTN19P7/XcXWe6u5yqRdkU1e7yFJRQQlDAj0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM; spf=pass smtp.mailfrom=aculab.com; arc=none smtp.client-ip=185.58.85.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aculab.com Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-184-vJTZZFxDOK-mjlH1jpPhsQ-1; Sat, 27 Apr 2024 22:01:19 +0100 X-MC-Unique: vJTZZFxDOK-mjlH1jpPhsQ-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sat, 27 Apr 2024 22:00:48 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sat, 27 Apr 2024 22:00:48 +0100 From: David Laight To: 'Guenter Roeck' , Alan Stern CC: Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Gerd Hoffmann Subject: RE: [PATCH v2] usb: ohci: Prevent missed ohci interrupts Thread-Topic: [PATCH v2] usb: ohci: Prevent missed ohci interrupts Thread-Index: AQHaloHtuZ6Ib4ELhkipVPWjjF4HNLF8nf2w Date: Sat, 27 Apr 2024 21:00:48 +0000 Message-ID: References: <20240424195951.3749388-1-linux@roeck-us.net> In-Reply-To: <20240424195951.3749388-1-linux@roeck-us.net> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From: Guenter Roeck > Sent: 24 April 2024 21:00 >=20 > Testing ohci functionality with qemu's pci-ohci emulation often results > in ohci interface stalls, resulting in hung task timeouts. >=20 > 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. >=20 > Ensure that the ohci interrupt code handles all pending interrupts before > returning to solve the problem. >=20 > Cc: Gerd Hoffmann > Fixes: 306c54d0edb6 ("usb: hcd: Try MSI interrupts on PCI devices") > Signed-off-by: Guenter Roeck > --- > v2: Only repeat if the interface is still active >=20 > drivers/usb/host/ohci-hcd.c | 8 ++++++++ > 1 file changed, 8 insertions(+) >=20 > diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c > index 4f9982ecfb58..bb6b50b4a356 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) > =09/* Check for an all 1's result which is a typical consequence > =09 * of dead, unclocked, or unplugged (CardBus...) devices > =09 */ > +again: > =09if (ints =3D=3D ~(u32)0) { > =09=09ohci->rh_state =3D OHCI_RH_HALTED; > =09=09ohci_dbg (ohci, "device removed!\n"); > @@ -982,6 +983,13 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) > =09} > =09spin_unlock(&ohci->lock); >=20 > +=09/* repeat until all enabled interrupts are handled */ > +=09if (ohci->rh_state !=3D OHCI_RH_HALTED) { > +=09=09ints =3D ohci_readl(ohci, ®s->intrstatus); > +=09=09if (ints & ohci_readl(ohci, ®s->intrenable)) Doesn't the driver know which interrupts are enabled? So it should be able to avoid doing two (likely) slow io reads? (PCIe reads are pretty much guaranteed to be high latency.) =09David > +=09=09=09goto again; > +=09} > + > =09return IRQ_HANDLED; > } >=20 > -- > 2.39.2 >=20 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)