Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp713420ybl; Fri, 9 Aug 2019 12:37:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyy2oJxp/YHL+0L5p/RuddY8NIwweIPb3DSlK+MAWOpeP1PqPFunRN0Le0Tfdcnm0LnKfRX X-Received: by 2002:a62:1ac8:: with SMTP id a191mr23129974pfa.164.1565379431927; Fri, 09 Aug 2019 12:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565379431; cv=none; d=google.com; s=arc-20160816; b=ACTdYSAozLcigSmsDj9uLvnCaIu4VAMQ1wRJzwa5Ka5mkjLlfDThwfxIW38WerxfQA w4Qo+nEbzEHOJ+B9RErEKRhY/5zng1ihgIAoFHyLoSZiIlSSESEwE3o9C64r4CHM+4AF y9fGLM3+jA9YMu0WZITimhnuxX7REFkQqmiplewkPjRDWUDYi1mV1hRpNozfWls4wWiK NIG677xqREgXg4d/II6EOO+Gm0tswJR/tyd+IMbcpYahDPRa8lnHvdozUZSMHRBArrrf TdJY9tmVMHCjKubj2GErInp7Gw0JjfVy7+1LDuoEWv43gQUXGUzgOgI7P+4M1KfC78xc 39ag== 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=VZZatTdyYZtyKs0aKdAz/FkHE05QTI5sI9yPnVUzjGA=; b=dzrTIu9u3BkUnW15rWNcFdbhjMNF83kwq6w4UBVgiTpvLZBHD8n/1LWNFDlL2/C5xp 9SBvGrjwxq+hLsuUel/GvP3v83lNAj0X9OXKQP9s+W8SnUC3+RTH/UQtU+jaVZXh+IQX B308fRltEfE2w8NdH+N3sXvHE8L3LGdhJEcTjVztocWqLCfKt1G0wRsC2h4YHc+WSwpI TCd5IYQgKxwStg2t1mvhXN9n2rp5mkFkF0VPsgf4Jq/wInNb3JxfzqlN/Re5Lo5y5S3y bH91T4PVDyyMma9Zy66pQg/NMwJyVQ/nhB5xNz+RTG0MbEdFSUwwBPGXvEvE1kGagSch XSgA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142si57524932pgf.35.2019.08.09.12.36.56; Fri, 09 Aug 2019 12:37:11 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726125AbfHITew (ORCPT + 99 others); Fri, 9 Aug 2019 15:34:52 -0400 Received: from mga12.intel.com ([192.55.52.136]:33782 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbfHITew (ORCPT ); Fri, 9 Aug 2019 15:34:52 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2019 12:34:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,366,1559545200"; d="scan'208";a="204021417" Received: from unknown (HELO localhost.localdomain) ([10.232.112.69]) by fmsmga002.fm.intel.com with ESMTP; 09 Aug 2019 12:34:39 -0700 Date: Fri, 9 Aug 2019 13:32:16 -0600 From: Keith Busch To: Lukas Wunner 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: <20190809193216.GD28515@localhost.localdomain> References: <4174210466e27eb7e2243dd1d801d5f75baaffd8.1565345211.git.lukas@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4174210466e27eb7e2243dd1d801d5f75baaffd8.1565345211.git.lukas@wunner.de> User-Agent: Mutt/1.9.1 (2017-09-22) 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 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?