Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1436613lqa; Mon, 29 Apr 2024 08:24:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBEfZj8jjqIFPojJI0d1sHws+N3qd87OsBWIeGZ05h5/YkyGQbrFZ4NMoyYZXUHdlsnWq4ITZez5Kqj+bppc30vg+WCdwZ5D7o80xjdw== X-Google-Smtp-Source: AGHT+IGytSM1zF1+ZmjX0J+46+rZXj9rW+XzXhJuwQb/49e5loOHXewWcIZBkJ+OOPB0OLh09JeW X-Received: by 2002:a05:6808:15a3:b0:3c8:3a7f:c842 with SMTP id t35-20020a05680815a300b003c83a7fc842mr10676202oiw.57.1714404289928; Mon, 29 Apr 2024 08:24:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714404289; cv=pass; d=google.com; s=arc-20160816; b=N31PxM1iJkfIro5sOlVHvkTXXB/xPkyZm8Khe72u1La+Ur7wcz+021Oo6nT17znfUp 1KWK0BWM9I14T4ytZlwwjU/YnXpvnSKQ7aWIl/0T89xpv/pS5B7nIPIlXbSyz3Tsxh6B 8pYgRGA/Wu2YNWcrXhLKEq1I/8v3jr5Oy1l726T12Tla10ImloGhD9krLwBALfQnz/b9 8veyxWWDBZvQqvdZfDeGZZ+nqGQqiU19JuBwVwh9yckg0Up6mZRuBQOFsEyNWmOj0UGJ Ds5bwokiRrG/qRSeCsbrFInUEExGxZGZl4d9XOS1RZ58zw0Ius/zs0oTgUu6WSoMpc9F wQoA== 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=3jBawfFhlA0UFRcAmeMLqv9bLy/zzapCJCHTZnIdO/k=; fh=7TuVuETyyEcuUc3DrAdr/W49ptAS22R9rPC78FH1H2s=; b=SbjTo0WZk6Y4z+L5up8k60+gDfhpqHSRwvQ0p6ccO0hSUBl6BGndfbbLF44Xa2Jq3u 4pvK6IIgCIYZNE5A7aVJFcyV0y6GbNv8xHAXsttJWZ5zftb2O7m2hEtJAlb0nB/TH6nV WrvDc13SOYMfziFcWAnFyuyOZfhADCb/sWqE/IXZ4uzRBvaKPcxTLrin0L0c78/J088z rRNdICrfIsMtfaAyUP1G/Kc57H3Wb81GceMFsRlO6wEa2RFl+ghS5JQ07rKLzRKv/a9M 9yjX5iQYDTZgI4S3ZoLKbCHmrlIJG4dmNrYEzESbBq+Ynhq4dXU6xzQbDGltvgwEobJ0 WaGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gDCBA2FL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-162570-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162570-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u11-20020a05622a010b00b0043ad3e63efdsi3634059qtw.383.2024.04.29.08.24.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:24:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162570-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gDCBA2FL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-162570-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162570-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 571F41C21C10 for ; Mon, 29 Apr 2024 15:24:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD14F83CCC; Mon, 29 Apr 2024 15:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gDCBA2FL" Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 27B4382D8E; Mon, 29 Apr 2024 15:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714404233; cv=none; b=C/Vq9FiXZSnuZBn15sptfrBIuMFbHhV7j1mUW2ryM7eVDJ13g2b+HQhcRq/LYGMkWcqWlXSY2oiar6mjlqP7AbGHnwdLta/futd/nuV8Cf0HvTutzxwd7TvHwXatmXbUDKxlFkNkPxCcbD1i6PucYDdmLIF4+mKeyuNvOEATSso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714404233; c=relaxed/simple; bh=UoOiVi6NxaqejEwIzDKtIZ5vgKiX5KkoRm7zE3CAe6w=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=b9Q6+EZQZVA67p5oqTrZt9E19NqGt+G8tCFetlKNmIk6S+A7o2hVRKZzlBBVl4gELvmQQw4s29RHvG3NRHGw5498ll92RmMzV5PZEW8vO7rCMI+YBO1Cct5DiNEmVTHgQPS+PwnlQIMNcjgqUbtj9yR+5VOZSZ2pLmD0jS+FoY4= 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=gDCBA2FL; arc=none smtp.client-ip=209.85.214.173 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-f173.google.com with SMTP id d9443c01a7336-1e834159f40so36442245ad.2; Mon, 29 Apr 2024 08:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714404231; x=1715009031; 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=3jBawfFhlA0UFRcAmeMLqv9bLy/zzapCJCHTZnIdO/k=; b=gDCBA2FL3PIt+vvkwrkWZhGRsfpU2c2oZF1HAKqLrHOabu6/qgS5yu07G59pVqwQDl SFzipIyxSnqJblhHrrcoEcnvJIr/D4mS7WF4kWCxMUg1FKLV8EiU9DoHoQ05nDJig11x ldIGVyzETzhLVbX7Fh5aDvxiI3dGYFVwGZkvGebf6dEbq1GgqEFcoBGHdJoP1nVRndE/ ccgSCfoOKhVwwLtExKCiJhmrvujRfy7x0NBJwPz0BFevDu3CHw+7Rlfs8WZ6ZRtHHdPX wrsyXpum9GrsEryzehX6TZS5LdQD4aCUGsidCvNwnCfXXkoa4jByEJBHCEw+nDonUGLc Kvrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714404231; x=1715009031; 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=3jBawfFhlA0UFRcAmeMLqv9bLy/zzapCJCHTZnIdO/k=; b=WecselXdrGBayVE5MJ1JCSF0LrzRoY/Jj1dZi+hEkItdiSx4/sGjdsv3JHPAGR+Yhu wYj2CFnTxi4+jKzGu+rl/SiaA6z/6kk2Dt3epwV0sXDJ6x1HlgEPueamC20ehqL6ljCA 1VXjwNXwnlC2wGT3dwtEBIN7Jvbg+jJ9XbW39RknMK0PrcEZlsrbS3/4YbDUXUFXnRag iDUGziO4+G9m8w3Ip/ktSL4An5QTrikliXCPp0SOTYhMpygBlf62p3HLGx67GnAZ3nmd matn3ruUK9G8aAbqB34AwHAFXhv6uNN6QrAObQu//TXdcQdFEL78PfzSYh+B9D/Vhyqc ZUTQ== X-Forwarded-Encrypted: i=1; AJvYcCUJK8lnRmyCGQUH55TmErJkE+zTFuw3dt5oe6an0HZBdb384BAgrh0stlj9tp6BgXWveDPJc4s9KOBZyttokXHWmmIvwyIRh2dFyfckv1wUK1uCaRKwikZQ1Z7v/qBiPgdddHUhnjba X-Gm-Message-State: AOJu0Yy1pfE/d0DZUr0AZM/gaLEQ3Ab8vEJFyg4R4s5db9VeE3KsjJuc p6eTaofOt/VVH3d+gued2gL+MB/sYnVKe14umKawqb1pfwQJnDTM X-Received: by 2002:a17:902:ec8a:b0:1e4:203d:ab80 with SMTP id x10-20020a170902ec8a00b001e4203dab80mr11995464plg.57.1714404231247; Mon, 29 Apr 2024 08:23:51 -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 jz15-20020a170903430f00b001e4e8278847sm20440680plb.56.2024.04.29.08.23.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Apr 2024 08:23:50 -0700 (PDT) Sender: Guenter Roeck Message-ID: Date: Mon, 29 Apr 2024 08:23:48 -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 v2] usb: ohci: Prevent missed ohci interrupts To: David Laight , Gerd Hoffmann Cc: Alan Stern , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20240424195951.3749388-1-linux@roeck-us.net> <2adc91aebb3a433997e13bd479d4b4b3@AcuMS.aculab.com> 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//7d92Uf3EArDlDShwR2+D+AMon8NULuLBHiE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FKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <2adc91aebb3a433997e13bd479d4b4b3@AcuMS.aculab.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/29/24 07:01, David Laight wrote: > From: Guenter Roeck >> Sent: 29 April 2024 14:34 >> >> On 4/28/24 23:49, Gerd Hoffmann wrote: >>> Hi, >>> >>>>>> + /* repeat until all enabled interrupts are handled */ >>>>>> + if (ohci->rh_state != OHCI_RH_HALTED) { >>>>>> + ints = ohci_readl(ohci, ®s->intrstatus); >>>>>> + if (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.) >>>> >>>> No, the driver does not cache intrenable. >>> >>> Does the driver ever change intrenable after initialization? >>> >> >> $ git grep -e intrenable -e intrdisable drivers/usb/host/*ohci*c | grep ohci_writel >> drivers/usb/host/ohci-hcd.c: ohci_writel(ohci, (u32) ~0, &ohci->regs->intrdisable); >> drivers/usb/host/ohci-hcd.c: ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable); >> drivers/usb/host/ohci-hcd.c: ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); >> drivers/usb/host/ohci-hcd.c: ohci_writel (ohci, mask, &ohci->regs->intrenable); >> drivers/usb/host/ohci-hcd.c: ohci_writel (ohci, OHCI_INTR_UE, ®s->intrdisable); >> drivers/usb/host/ohci-hcd.c: ohci_writel(ohci, OHCI_INTR_RHSC, ®s->intrdisable); >> drivers/usb/host/ohci-hcd.c: ohci_writel (ohci, OHCI_INTR_SF, ®s->intrdisable); >> drivers/usb/host/ohci-hcd.c: ohci_writel (ohci, OHCI_INTR_MIE, ®s->intrenable); >> drivers/usb/host/ohci-hcd.c: ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); >> drivers/usb/host/ohci-hcd.c: ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); >> drivers/usb/host/ohci-hcd.c: ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable); >> drivers/usb/host/ohci-hub.c: ohci_writel(ohci, OHCI_INTR_SF, &ohci->regs->intrdisable); >> drivers/usb/host/ohci-hub.c: ohci_writel (ohci, OHCI_INTR_INIT, &ohci->regs->intrenable); >> drivers/usb/host/ohci-hub.c: ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable); >> drivers/usb/host/ohci-hub.c: ohci_writel(ohci, rhsc_enable, &ohci->regs->intrenable); >> drivers/usb/host/ohci-hub.c: ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); >> drivers/usb/host/ohci-q.c: ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable); > > At least the hardware has separate enable/disable registers > so the driver isn't doing RMW cycles. > > I'd guess that the normal condition is that no interrupts are pending. > So it can be held to one (slow) read by checking: > if (ints && (ints & ohci_readl(ohci, ®s->intrenable))) Guess that can't hurt. I'll send v3. Thanks, Guenter