Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp759432ybl; Fri, 9 Aug 2019 13:29:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRLFejNgWNbTFJKq6v1e0fTsaDXTyBRTtzBO5LB6HC4LQZ1DLm0QE6kmRNVToyztxYqgbR X-Received: by 2002:a17:90a:a00d:: with SMTP id q13mr10896625pjp.80.1565382549449; Fri, 09 Aug 2019 13:29:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565382549; cv=none; d=google.com; s=arc-20160816; b=AAdRqmuUFY4z0B70mSRDerFOlPEVF2Oq7f7DmV7mmw/2TnVqNtLjHBSxRTU3ACpt1c rkLQv5vgWN85RiIA0GVJt/5NOf5uudi02XEueuq748ApYovYOF7jE216th+CmZYFzBy8 R1gVfgxLXT+9n00wNAVflZr1FO4vclW1c3XnKeqY3COxrFpNHSO37qACBfLis3htgFBr pLYHZMqIwrUNo3mXw8beLxjvJ2gWqQjXdGnMxjvoyS8cFw5e530imJgd/XzFQ9v6tjqN NBcE7dH6+J3BTiouIr0UobNSMDKYJ77tVN78eMBhpmkm5TuGfYhu8N3h3u00r6ly4KYd X6/w== 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=0BJiup0xoDpY7BvYL69zvQNfSzVEF0fLbOaOXvfyOo0=; b=ChOH4mIZM9AD/HgmDv3pIDHFsmxGyxVTWCXHxVGn8xjRH8//lT+HKMG7mUQ0/oFUmv 6qIDC3hvp6D58y5jhWcVE/WQwWIg7NBVUlclHEPSl4tzICm5EM84+DubHhb67ZOHXJXL qzCgfiuWv5y7CJYWvnnkW00pjm60AEWU+qJk1stGNytRDNCR1/YRKtikRXC+GcUp+F/H wx5vv3Ei9Zlv3J2BF0YN0r5lZajtQbb44FuxaBGHouhjK/0phQenGLbOhc2Y/lrEqzl6 OfBQBhsysokxO+MDAp4oZHleEQNtnsGc6gLiYd9xgVhjWRnSt7/wbGDa/FFUuY7KnIUP P2Nw== 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 i2si56956837pfb.206.2019.08.09.13.28.53; Fri, 09 Aug 2019 13:29:09 -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 S1726537AbfHIU2R (ORCPT + 99 others); Fri, 9 Aug 2019 16:28:17 -0400 Received: from bmailout3.hostsharing.net ([176.9.242.62]:37231 "EHLO bmailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbfHIU2R (ORCPT ); Fri, 9 Aug 2019 16:28:17 -0400 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 bmailout3.hostsharing.net (Postfix) with ESMTPS id 895A8101E69DC; Fri, 9 Aug 2019 22:28:15 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 35D09DFE15; Fri, 9 Aug 2019 22:28:15 +0200 (CEST) Date: Fri, 9 Aug 2019 22:28:15 +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: <20190809202815.4jtpdsnnmztins34@wunner.de> References: <4174210466e27eb7e2243dd1d801d5f75baaffd8.1565345211.git.lukas@wunner.de> <20190809193216.GD28515@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190809193216.GD28515@localhost.localdomain> 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 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. Thanks! Lukas