Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp627210lqd; Wed, 24 Apr 2024 11:53:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW7tn8JwOfScXqJGUwg0C/bxMpyaxJk0bRec6KDor6eFGFWd9+bG34KNwbJ7COIPUuYYInlVXksBRJ8QKwg/tWCPJ+YYg079W9tSLKUGw== X-Google-Smtp-Source: AGHT+IEdQGrwrh1Kz0hjkwivew9Vc3qvTTqzL5MwzHSuRJ7CiTuq7Sm1aW6G4La2uy64qMtF76FT X-Received: by 2002:a05:6a20:968c:b0:1aa:7097:4ade with SMTP id hp12-20020a056a20968c00b001aa70974ademr3027850pzc.45.1713984782505; Wed, 24 Apr 2024 11:53:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713984782; cv=pass; d=google.com; s=arc-20160816; b=jSLIT7HFYUscnxoKiOrMpdJEBDt0Suw5x/IPEuDq64BqPVKXWTNJs1krdvrRXZc7ej vVjYOHk7XK+Fxhy4vck9sYR3icgzLPxt3PqH+Y3F4GtOVCfCWOxSPNCnJJTfAaB2xy5f PWsaY2PW1frm3xhG3n3d1qFn3EhXf4NJDbVtcwIZt2izl+w9yBmyVpBbyAUn1cPHdeBY 5DXu2IrOvf2cCFtkP+ItiJZEzdJnhda0em0udlYtuU4ic8X4aRcZgx89TPJpoEOmJgkK ZrVzgg0ssNi87vI+6CJ9h1R0vDunupz1Dqf9fyl6hIF3gmfL0jHF7dlI4CHJ7IukBvDf C90w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=s20tuiXq0ffHbA6P2JpkSIVq1dJybgJ8gllaRU/fQoc=; fh=y1FTiWJdUM5aQE8RXRw4hnSv90yCu1ngUyfaF0a7juc=; b=Gic2MFopbmT9ATRaH2Gl8i9ru6MJwBOtTvn/sHfz39j8am5k5nYMTFpF6eED/6wiIv J7BrFWuUB6DxCXC5URKtknIDeh32z3MEOv+57YaYhGhZYWe9Zcyctv3Notd5Efcb/BHz UgNWx+7RREARnFVNHaloPim7VlxaInzoZuuNZPZgmgthfFvq1PFHwKv2mTTG3fnE0zfE 5nyLoNbO8Wr6hQfzLy4YHzHRdvLRJrdba2EYtrb/JzjpmEC6OqN9Shd9kzbjc/r0v6OG epDj6/C1CsxVbc9ToqVdv+NYsitwUb1xxYGNqKALh5Jw4BDLM8iSZ8jhcnD/kTC+rz9d tE8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XvWR7gtv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-157524-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157524-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w1-20020a056a0014c100b006ed6b1140a3si11916129pfu.397.2024.04.24.11.53.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 11:53:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157524-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XvWR7gtv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-157524-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157524-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DDB64B2FC33 for ; Wed, 24 Apr 2024 18:30:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8724A16F265; Wed, 24 Apr 2024 18:22:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XvWR7gtv" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 D58FF16D9C6; Wed, 24 Apr 2024 18:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713982919; cv=none; b=r5h1lzbrrBxNtlpYOd36wPGe3mlMQClH8pQoB6lvs2Ps9mDSychoGgYRCU/zxuQ5nU/vsGr/AdxvjH483ZD5IvsVqMnX3dBhKf06sLAt/WcyRdla7oi4ozl7BqnTN1mILl8IyXxEJM5AIYfy7AGRRGVvV4VL1QTBkYWd25at2iw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713982919; c=relaxed/simple; bh=45JT3U+A+pw6Rj84krkAOL411GLomhc9RS5vjzjNpJ0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qUWqeSWbdKZJxgiCFXWcQ0yFbfsTGmT5EjHgkKbW3lMBeDRi6+FGHeN9mOisVaS61nymYQP3IH48OqufEfAdPj+Kxxvp4CKPkD7PA5Q9CL1xSerbLthhl5K8hzJ4Yp8Cnp06auEL+2V2jwwdlKI4EpQPf0cCODzpezY0Y8UgJT0= 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=XvWR7gtv; arc=none smtp.client-ip=209.85.210.171 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-pf1-f171.google.com with SMTP id d2e1a72fcca58-6ed691fb83eso198476b3a.1; Wed, 24 Apr 2024 11:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713982917; x=1714587717; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:from:to:cc:subject:date:message-id:reply-to; bh=s20tuiXq0ffHbA6P2JpkSIVq1dJybgJ8gllaRU/fQoc=; b=XvWR7gtvK00qf5d3hUI6VC/GUfx/gExBlbkBRfVkebgWlsQwfXxLDxujWgTzIWnL1x EqJct9nDHNc3RubcxoDisyBfUID1uV3X3GNfVdjgSdqEtfHx8aSEle2wf+81sVbg7wA4 eeUowBUGtdGRELGhj2nvQ72jhdylo9nHGwXGh4eW6cOtIDHMwVXVXsZoDMePUwrM0LlU aoq4PqxfQPueM3YTLmCf7GDvl0VLjucYcL7ujQ5aG9bPTtU4+BnAIzUIqUWhRKKadlYj dYazuSlo9VLjg+BhbLAQLHlv6oJ1uEBZnJGf6YhN236lBJmkvUcOCG4HCL6iprKZxltW U67A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713982917; x=1714587717; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=s20tuiXq0ffHbA6P2JpkSIVq1dJybgJ8gllaRU/fQoc=; b=m+gUXxavWrCnWsrACrjhOd+oZ1o0e7KMBO37+IiY5WMPEc1ZjW/HQBhp0FxE7d/IRD zpIKyvynfTP2Ww0TEMG2hEQT872qYkfs1PhX+h0XfsT4WqVn+LPZ0cYk3MJVHpCmeuRN fY+Jo3AE+UMBRBIiRaLigPSJOAD86tWD/EpNJMqB9B1aYeUFMlTZ8tLlQzqHDmpiyd/l Y4fHXRR+8uCGX1XCwY93HcKvVt/UKtwiz94wspP0a8i8bLY9yS+U8t1Qjg/1yreRvTqu GZrQA57loMGSXLhKuVLvgOje8AtRBAVf6YxPBDf8o9UlTvxrXrUkQy3Xfz7CRlzfv6Xi lnCw== X-Forwarded-Encrypted: i=1; AJvYcCWvrFQ+ZLdB1I5waTIhyGFLUqCpOOPyGbTG1+s7qRl/Hfle8s6jyZWlDuT8nJ8qksIKQQClzLqql1lMlBBTSTtsdsd2T/DrHBlbLbv+3dmIvtPCH6rAy5KTSGg/UjUO1EpbsA9XCpcw X-Gm-Message-State: AOJu0Yyff0eerGoEcdcTplHXCYOuSAsByERctcKbgFS1uUveI2N3Tpr2 C/G2soekRa0qQyr42CM+HAJb6oUORX3CjuYatkyQUXzU03y3vj+7 X-Received: by 2002:a05:6a00:2442:b0:6ea:d794:ccee with SMTP id d2-20020a056a00244200b006ead794cceemr3970237pfj.17.1713982917078; Wed, 24 Apr 2024 11:21:57 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b8-20020a056a000cc800b006ed4c430acesm11717299pfv.40.2024.04.24.11.21.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Apr 2024 11:21:56 -0700 (PDT) Sender: Guenter Roeck Message-ID: <1f94db3e-2ebd-4659-9f88-8591172c3cf0@roeck-us.net> Date: Wed, 24 Apr 2024 11:21:54 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] usb: ohci: Prevent missed ohci interrupts To: Alan Stern Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Gerd Hoffmann References: <20240424170250.3738037-1-linux@roeck-us.net> <57511487-e622-476d-adb2-5dfc725032d4@rowland.harvard.edu> Content-Language: en-US From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/W8Vk BIsJMaWOhks//7d92Uf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RnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <57511487-e622-476d-adb2-5dfc725032d4@rowland.harvard.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/24/24 11:15, Alan Stern wrote: > On Wed, Apr 24, 2024 at 10:02:50AM -0700, Guenter Roeck wrote: >> 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 >> Fixes: 306c54d0edb6 ("usb: hcd: Try MSI interrupts on PCI devices") >> Signed-off-by: Guenter Roeck >> --- >> drivers/usb/host/ohci-hcd.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c >> index 4f9982ecfb58..4d764eb6c1e5 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,11 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) >> } >> spin_unlock(&ohci->lock); >> >> + /* repeat until all enabled interrupts are handled */ >> + ints = ohci_readl(ohci, ®s->intrstatus); >> + if (ints & ohci_readl(ohci, ®s->intrenable)) >> + goto again; > > If we take the repeat, we don't want to return IRQ_NOTMINE by accident. To > prevent this, we should check that ohci->rh_state != OHCI_RH_HALTED before > re-reading ints and jumping back. > > (If rh_state _is_ OHCI_RH_HALTED, it means the device is supposedly stopped > and disabled for generating further interrupt requests, so we shouldn't > need to worry about any outstanding intrstatus bits still set.) > Makes sense. I'll send v2. Thanks, Guenter