Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1413563ybl; Sat, 10 Aug 2019 03:14:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXpvxVexaSLzE3jh32Q36mV43+imnhYQxBZACkNOjT/7r1Q7dfl+FaB/aHy+UPSlT9MWRK X-Received: by 2002:a62:28b:: with SMTP id 133mr26094743pfc.251.1565432093710; Sat, 10 Aug 2019 03:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565432093; cv=none; d=google.com; s=arc-20160816; b=Ab8JzR6bepDa+qZq8ynR9ijUhckgagSIhu+F/PX8Bpl1IwB8BrNfX2lVT99KzSfz1E jy3iLQ5E+gt+oLWF4eBC2CHlt1SQ8aD0yB2fINbggd3LdOYQX7bN/PY6im/ufOqKLW1E td3aq9HqXqIIbCVSI3NqtcC3mk/21OAc+lbkZYfNXRJB9JeONBYNmeX/JuDiNPgcfDgg C+fgh4IUY1THB8qIuwKoYaTLasrPToYYhwIHM/7tF8qj8dlgVlkn09ZBuvMZF7V0hYWa KSImJ1OuxJ0H8tEgYy6kuqXnaG5P1DG2j/gPnc+pWW0Rv5Plw00XOsw8AHSeAjcKES/Y gfMw== 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=vFk5pOoVPA94dSAWECC4q3RDyGG7Doh3ASHhNc9uW9Q=; b=nwvg2bmb/sI0VDNBgPmdSsJfnXsXMadCkAIS085hJjW6X+3wYHmU9mX7QnD87f3lnv ZtRVyy1xI9dQLstSYMkkUsavEDbC5e3TRhR/ye3UgE8dcn5ecXN+LHnvxenR9khbSibE wOcnESEyKR2VPgU1/EQgbTJvDHf3JC1geVtfLnL+UdynY3maft6yrbmQAYQs28R4n4my 9NRrKErbqf+rSBg0l8XBgSj3kdXq5Y7LzJ/gdR9AZsZP2/9CTkkzxB1qd8+7GJKj3dbt js23RIGZVPACHw8HlvNdg34BW7Ips354vA6kTMMfoKY9JUOu47O0wR1269WjL4AMbDI5 pqJw== 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 k13si31121604pgt.285.2019.08.10.03.14.38; Sat, 10 Aug 2019 03:14:53 -0700 (PDT) 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 S1726196AbfHJKMf (ORCPT + 99 others); Sat, 10 Aug 2019 06:12:35 -0400 Received: from bmailout2.hostsharing.net ([83.223.78.240]:38555 "EHLO bmailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbfHJKMe (ORCPT ); Sat, 10 Aug 2019 06:12:34 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (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 bmailout2.hostsharing.net (Postfix) with ESMTPS id 596A02800B6CA; Sat, 10 Aug 2019 12:12:32 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 259F91DD45E; Sat, 10 Aug 2019 12:12:32 +0200 (CEST) Date: Sat, 10 Aug 2019 12:12:32 +0200 From: Lukas Wunner To: Keith Busch Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Xiongfeng Wang Subject: Re: [PATCH] PCI: pciehp: Avoid returning prematurely from sysfs requests Message-ID: <20190810101232.3fdqrbi3tdd27dwx@wunner.de> References: <4174210466e27eb7e2243dd1d801d5f75baaffd8.1565345211.git.lukas@wunner.de> <20190809193216.GD28515@localhost.localdomain> <20190809202815.4jtpdsnnmztins34@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190809202815.4jtpdsnnmztins34@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 Fri, Aug 09, 2019 at 10:28:15PM +0200, Lukas Wunner wrote: > On Fri, Aug 09, 2019 at 01:32:16PM -0600, Keith Busch wrote: > > On Fri, Aug 09, 2019 at 12:28:43PM +0200, Lukas Wunner wrote: > > > A sysfs request to enable or disable a PCIe hotplug slot should not > > > return before it has been carried out. That is sought to be achieved > > > by waiting until the controller's "pending_events" have been cleared. > > > > > > However the IRQ thread pciehp_ist() clears the "pending_events" before > > > it acts on them. If pciehp_sysfs_enable_slot() / _disable_slot() happen > > > to check the "pending_events" after they have been cleared but while > > > pciehp_ist() is still running, the functions may return prematurely > > > with an incorrect return value. > > > > > > Fix by introducing an "ist_running" flag which must be false before a > > > sysfs request is allowed to return. > > > > Can you instead just call synchronize_irq(ctrl->pcie->irq) after the > > pending events is cleared? > > You mean call synchronize_irq() from pciehp_sysfs_enable_slot() / > disable_slot()? That's a good idea, let me think that through and > try to make it work that way. After a bit of thinking: synchronize_irq() doesn't work for poll mode. A secondary concern is that if the IRQ is shared, synchronize_irq() waits for all the other (unrelated) IRQ threads to finish, i.e. longer than necessary. So I can't think of a better way to solve this. Thanks, Lukas