Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp710172imm; Sat, 1 Sep 2018 18:14:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdalJzv1V6K+e9F0s7JMzp5vI/l0So7UfXCzeOFzPUdo9Rv8itjS4dT6cCOxn9ES9IH94KGM X-Received: by 2002:a63:f309:: with SMTP id l9-v6mr20047361pgh.369.1535850850379; Sat, 01 Sep 2018 18:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535850850; cv=none; d=google.com; s=arc-20160816; b=QOry/TJy+vGLvBlrfYwQTUObV/7//4z+HSLz2leKOqc0jMJk1Fxmeiox2coGDQbwRO KtcnIXpf32Mr/JgFLLTcCcecNO6UAPWn4ROHcsGyzqun5HDiOblKwjsBH0th79QEwvpd u8jGa6iPmK+1N2QuHW7gvjf6Dlt3cJ4nacyImVrScZw1qHXPbdsT9vMkl/xtmfKXDnJM zNaEbtfLRvXHRxYr3W+0wxYPbHYEElCJ6R2mJTsM9njk30avm2K8BNIvSvpLprBhqNEo WnTCuSmf2wn/qDv6MIHprpaxZo1KnyyPpyNFJBmWKwo3sbU8RXIFaTY+fBoL6hJAbV47 yi6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=A6EgGpfUwUKFtYFQ9d8vCbcW+BByZPc9Zlc+D+hOYn4=; b=t3OWCI17j01whlDzq6pzKxKA2WvYZAjB9oNlN1+/mnzp48mT5dO0Kk6HZ73Gbcw99N Cijp7KoWnfRDHwaNhWe+VtfTJwvG9W/BXMUCm/9hQzmQLqtsAOGJUe1xYkRPOtTxdbNF hrMMzWbIfaYVfFFu0dsh9fVu5TEYGq7fn1ifQqoSv+L+T+uhAuuQd+lGmH0OZahL9JNN 2ATFIqLQOMoehK7gO5L8YwOw9K1cnfEiALoTD3i2BoGgIVDG0rHvnCMrHS0Mws0pxvdo 0A4DIiCBX4fcW65nQ9zWR52yeItH9JRvS+uaWnqf8IZAIKiqIGPFUJCIUZULtYjBlFao bBRA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ce1-v6si15778791plb.391.2018.09.01.18.13.54; Sat, 01 Sep 2018 18:14:10 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726007AbeIBF0g (ORCPT + 99 others); Sun, 2 Sep 2018 01:26:36 -0400 Received: from mga05.intel.com ([192.55.52.43]:9911 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725847AbeIBF0g (ORCPT ); Sun, 2 Sep 2018 01:26:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Sep 2018 18:12:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,318,1531810800"; d="scan'208";a="80203710" Received: from unknown (HELO localhost.localdomain.localdomain) ([10.232.117.194]) by orsmga003.jf.intel.com with ESMTP; 01 Sep 2018 18:12:29 -0700 From: Jon Derrick To: Cc: , Bjorn Helgaas , Keith Busch , Sinan Kaya , Oza Pawandeep , Matthew Wilcox , Lukas Winner , Christoph Hellwig , Mika Westerberg , Lorenzo Pieralisi , Jon Derrick Subject: [PATCH] PCI/AER: Fix an AER enabling/disabling race Date: Sat, 1 Sep 2018 19:06:52 -0600 Message-Id: <1535850412-3085-1-git-send-email-jonathan.derrick@intel.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a sequence with non-ACPI root ports where the AER driver can enable error reporting on the tree before port drivers have bound to ports on the tree. The port driver assumes the AER driver will set up error reporting afterwards, so instead add a check if error reporting was set up first. Example: [ 343.790573] pcieport 10000:00:00.0: pci_disable_pcie_error_reporting [ 343.809812] pcieport 10000:00:00.0: pci_enable_pcie_error_reporting [ 343.819506] pci 10000:01:00.0: pci_enable_pcie_error_reporting [ 343.828814] pci 10000:02:00.0: pci_enable_pcie_error_reporting [ 343.838089] pci 10000:02:01.0: pci_enable_pcie_error_reporting [ 343.847478] pci 10000:02:02.0: pci_enable_pcie_error_reporting [ 343.856659] pci 10000:02:03.0: pci_enable_pcie_error_reporting [ 343.865794] pci 10000:02:04.0: pci_enable_pcie_error_reporting [ 343.874875] pci 10000:02:05.0: pci_enable_pcie_error_reporting [ 343.883918] pci 10000:02:06.0: pci_enable_pcie_error_reporting [ 343.892922] pci 10000:02:07.0: pci_enable_pcie_error_reporting [ 343.918900] pcieport 10000:01:00.0: pci_disable_pcie_error_reporting [ 343.968426] pcieport 10000:02:00.0: pci_disable_pcie_error_reporting [ 344.028179] pcieport 10000:02:01.0: pci_disable_pcie_error_reporting [ 344.091269] pcieport 10000:02:02.0: pci_disable_pcie_error_reporting [ 344.156473] pcieport 10000:02:03.0: pci_disable_pcie_error_reporting [ 344.238042] pcieport 10000:02:04.0: pci_disable_pcie_error_reporting [ 344.321864] pcieport 10000:02:05.0: pci_disable_pcie_error_reporting [ 344.411601] pcieport 10000:02:06.0: pci_disable_pcie_error_reporting [ 344.505332] pcieport 10000:02:07.0: pci_disable_pcie_error_reporting [ 344.621824] nvme 10000:06:00.0: pci_enable_pcie_error_reporting Signed-off-by: Jon Derrick --- drivers/pci/pcie/aer.c | 1 + drivers/pci/pcie/portdrv_core.c | 5 ++++- include/linux/pci.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 83180ed..a4e36b6 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1333,6 +1333,7 @@ static int set_device_error_reporting(struct pci_dev *dev, void *data) if (enable) pcie_set_ecrc_checking(dev); + dev->aer_configured = 1; return 0; } diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 7c37d81..f5de554 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -224,8 +224,11 @@ static int get_port_device_capability(struct pci_dev *dev) /* * Disable AER on this port in case it's been enabled by the * BIOS (the AER service driver will enable it when necessary). + * Don't disable it if the AER service driver has already + * enabled it from the root port bus walking */ - pci_disable_pcie_error_reporting(dev); + if (!dev->aer_configured) + pci_disable_pcie_error_reporting(dev); } #endif diff --git a/include/linux/pci.h b/include/linux/pci.h index e72ca8d..c071622 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -402,6 +402,7 @@ struct pci_dev { unsigned int has_secondary_link:1; unsigned int non_compliant_bars:1; /* Broken BARs; ignore them */ unsigned int is_probed:1; /* Device probing in progress */ + unsigned int aer_configured:1; /* AER configured for device */ pci_dev_flags_t dev_flags; atomic_t enable_cnt; /* pci_enable_device has been called */ -- 1.8.3.1