Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2903719ybv; Sun, 9 Feb 2020 10:08:11 -0800 (PST) X-Google-Smtp-Source: APXvYqx4Jnh9XFOTFw6PTfF7D1p2QusZ7lxWc2qH2XG+EeiefVlfhGyDyg3seTsUWoaqDQqg+bGb X-Received: by 2002:a9d:7cd0:: with SMTP id r16mr7814537otn.50.1581271691327; Sun, 09 Feb 2020 10:08:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581271691; cv=none; d=google.com; s=arc-20160816; b=oS6UeTPpIJBZqzJVVtmnffBBKUkVZzZq8O5QL5SLqz5XlKXFs6d9jo39D9XVB3gAQs ny01NXX9kwI/RZdNt//AtHvkZkmSx9rj7/XY1juPn9lgXpUJwyEJpelPOUI+soLDtzhr 54qUSsk6X7vqq+M9LilnsaJmFLni1riSAqFTHTA6ubFxT858AELklIBECZ+PAMkDcMzQ pDyDsrIrHYVrj/ed7ckL1WtE6kGfcIXHgopwSQHqNNsrnT7SL5WwgSjT7cLwCyobp0Ci Ia2o1gUnejEdT8Dtl4cQrEoez2A2BFBZdqqrJYizdNjpNk2pRHqv8imKKUNvBGe90Hd7 6+Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7G8M2G3kbLvFqpscY7mctVq+C8nfQ98lcLak5du+rr4=; b=qfDVFCZyc5vFmO/CIOwmXyreeXtWxJAXMqkMmjtm9YwfaGq/M8xg0QnZSHuTGmxuRY llYhH/6gs3MT0NkGNg1omMRDGa7qwpfWdiKeJAEmP6WGUusnwsigDPxqWt/bUXPDcxbC lw8Hz/4jVVMyAIhorkG2jdMMkbBLMBBk1xXyEmTOL8qKeqngdn+3mooFDqHcNPT6XuDA bILPoGxqmC17pRkBhul13uSVC+9il17qkx/rzNiiknHrQDPJe8DJyLH0RQjYw+6prA9p z8hg1xTkbquql3YBXaGZSVoCYVRZtqoWoFiZB9m40+IVFXIw8PfG13hhJtaV7vMNBRit SXkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x12si3386468oto.194.2020.02.09.10.07.59; Sun, 09 Feb 2020 10:08:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727427AbgBISHZ (ORCPT + 99 others); Sun, 9 Feb 2020 13:07:25 -0500 Received: from bmailout1.hostsharing.net ([83.223.95.100]:42517 "EHLO bmailout1.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727388AbgBISHY (ORCPT ); Sun, 9 Feb 2020 13:07:24 -0500 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id 0296530002521; Sun, 9 Feb 2020 19:07:23 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id CC881132E50; Sun, 9 Feb 2020 19:07:22 +0100 (CET) Date: Sun, 9 Feb 2020 19:07:22 +0100 From: Lukas Wunner To: Stuart Hayes Cc: Bjorn Helgaas , Austin Bolen , Keith Busch , Alexandru Gagniuc , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , "Gustavo A . R . Silva" , Sinan Kaya , Oza Pawandeep , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, narendra_k@dell.com Subject: Re: [PATCH v3] PCI: pciehp: Make sure pciehp_isr clears interrupt events Message-ID: <20200209180722.ikuyjignnd7ddfp5@wunner.de> References: <20200207195450.52026-1-stuart.w.hayes@gmail.com> <20200209150328.2x2zumhqbs6fihmc@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200209150328.2x2zumhqbs6fihmc@wunner.de> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 09, 2020 at 04:03:28PM +0100, Lukas Wunner wrote: > Using a for (;;) or do/while loop that you jump out of if > (!status || !pci_dev_msi_enabled(pdev)) might be more readable > than a goto, but I'm not sure. Actually, scratch that. After thinking about this problem for a day I've come up with a much simpler and more elegant solution. Could you test if the below works for you? This solution has the added benefit that the IRQ thread is started up once the first event bits have been collected. If more event bits are found in the additional loop iterations, they're added to the collected event bits and the IRQ thread will pick them up asynchronously. Once no more bits are found, the hardirq handler exits with IRQ_NONE. This means that the genirq code won't wake the IRQ thread but that doesn't matter because the ISR has already done that itself. Should also work correctly in poll mode and the behavior in INTx mode should be as before. -- >8 -- diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index c3e3f53..707324d 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -553,6 +553,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) } } +read_status: pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &status); if (status == (u16) ~0) { ctrl_info(ctrl, "%s: no response from device\n", __func__); @@ -609,6 +610,17 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) /* Save pending events for consumption by IRQ thread. */ atomic_or(events, &ctrl->pending_events); + + /* + * In MSI mode, all event bits must be zero before the port will send + * a new interrupt (PCIe Base Spec r5.0 sec 6.7.3.4). So re-read the + * Slot Status register in case a bit was set between read and write. + */ + if (pci_dev_msi_enabled(pdev) && !pciehp_poll_mode) { + irq_wake_thread(irq, ctrl); + goto read_status; + } + return IRQ_WAKE_THREAD; }