Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2575019imm; Thu, 11 Oct 2018 12:29:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV62d9BYszIgJz5+6hTlXQBtZc5ZPB+mpxw/pSHRvCjuq6gRtNoS8e4+Y7+lyqDoXPOETFOxw X-Received: by 2002:a17:902:740a:: with SMTP id g10-v6mr2729492pll.198.1539286179081; Thu, 11 Oct 2018 12:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539286179; cv=none; d=google.com; s=arc-20160816; b=cAoyseCUdWLRePqRsd+8Wb7jTWnnHwGPQx/trog/2vSJ76WJUiu2J5Ew45VxTWNSU/ TA2+nBAdZUzIwZLWh7Z/Sn82k31YCnt4S9iVBT/HMhGjhupZ7smEiwj60bRlXbVxldL/ YP2lz0+k3SHRHtTARLsx9GFxVOeIiD8bLkcKjRQvdx+iYDII8iEmgf7BRYjkxXYKA0fd XtvueoYUwjnCk7jUCyvQJ5Q27I0/m7Q8IfLDZ2it1FLTYAy5PGFJwWeHXlwf/GqbMLyw DjCwQKVeDR7Ka8J4R3HDFskB0IknkahuGdpaVCQmjGer0IZlxFbAnzYDeBTcibFOiBAQ yJuQ== 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=9JbPT69O+bUgpPIsZKaLC5ArgAFLbCrLIjtJ7eyoirw=; b=Ddy3wB1dh8Ab5cG8VtBYELlqv/RLuao1mH0cmAw/BYLRqzU6lidACVS8Fq47tmWnbT keCC0KuRfWyZP6S5wDeUewDzpNTWHiZZGdk0skuz4p8w9WAx4nnrKAKmlIbaxQEI9I1H Q6uNt8YBf0E73UnHko25g6qneTqZ1PeVOypx++dbNrKzA52CQGIyPHD/x5t2LeQyMSyN TQ3KbF33iDQY4+Xr/zE0JvADMkGLqriq+2VEEIHhmKhhQowDtygnoieIGMyM/QV//1Z/ W0f1x0D5ctMMUdYVLoF/P5KdMVzFB8iCY1SIacamWoIJ4DVlr05ao3s8t5eUd3bcPd+V sGHA== 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 m12-v6si27518703pll.105.2018.10.11.12.29.23; Thu, 11 Oct 2018 12:29:39 -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 S1729708AbeJKXbv (ORCPT + 99 others); Thu, 11 Oct 2018 19:31:51 -0400 Received: from mga05.intel.com ([192.55.52.43]:10426 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729014AbeJKXbv (ORCPT ); Thu, 11 Oct 2018 19:31:51 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 09:04:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="80672084" Received: from unknown (HELO localhost.localdomain) ([10.232.112.69]) by orsmga008.jf.intel.com with ESMTP; 11 Oct 2018 09:00:16 -0700 Date: Thu, 11 Oct 2018 09:57:16 -0600 From: Keith Busch To: Bjorn Helgaas Cc: "Derrick, Jonathan" , Dongdong Liu , Sinan Kaya , Oza Pawandeep , Matthew Wilcox , Lukas Wunner , Christoph Hellwig , Mika Westerberg , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3] PCI/AER: Enable reporting for ports enumerated after AER driver registration Message-ID: <20181011155715.GD11034@localhost.localdomain> References: <153927123657.40414.9802241131940995491.stgit@bhelgaas-glaptop.roam.corp.google.com> <153927157816.40414.5263399018962087014.stgit@bhelgaas-glaptop.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <153927157816.40414.5263399018962087014.stgit@bhelgaas-glaptop.roam.corp.google.com> 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 Thu, Oct 11, 2018 at 08:26:18AM -0700, Bjorn Helgaas wrote: > From: Bjorn Helgaas > > Previously we enabled AER error reporting only for Switch Ports that were > enumerated prior to registering the AER service driver. Switch Ports > enumerated after AER driver registration were left with error reporting > disabled. > > A common order, which works correctly, is that we enumerate devices before > registering portdrv and the AER driver: > > - Enumerate all the devices at boot-time > > - Register portdrv and bind it to all Root Ports and Switch Ports, which > disables error reporting for these Ports > > - Register AER service driver and bind it to all Root Ports, which > enables error reporting for the Root Ports and any Switch Ports below > them > > But if we enumerate devices *after* registering portdrv and the AER driver, > e.g., if a host bridge driver is loaded as a module, error reporting is not > enabled correctly: > > - Register portdrv and AER driver (this happens at boot-time) > > - Enumerate a Root Port > > - Bind portdrv to Root Port, disabling its error reporting > > - Bind AER service driver to Root Port, enabling error reporting for it > and its children (there are no children, since we haven't enumerated > them yet) > > - Enumerate Switch Port below the Root Port > > - Bind portdrv to Switch Port, disabling its error reporting > > - AER service driver doesn't bind to Switch Ports, so error reporting > remains disabled > > Hot-adding a Switch fails similarly: error reporting is enabled correctly > for the Root Port, but when the Switch is enumerated, the AER service > driver doesn't claim it, so there's nothing to enable error reporting for > the Switch Ports. > > Change the AER service driver so it binds to *all* PCIe Ports, including > Switch Upstream and Downstream Ports. Enable AER error reporting for all > these Ports, but not for any children. > > Link: https://lore.kernel.org/linux-pci/1536085989-2956-1-git-send-email-jonathan.derrick@intel.com > Based-on-patch-by: Jon Derrick > Signed-off-by: Bjorn Helgaas > --- > drivers/pci/pcie/aer.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c > index 90b53abf621d..c40c6607849b 100644 > --- a/drivers/pci/pcie/aer.c > +++ b/drivers/pci/pcie/aer.c > @@ -1316,12 +1316,6 @@ static void aer_enable_rootport(struct aer_rpc *rpc) > pci_read_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, ®32); > pci_write_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, reg32); > > - /* > - * Enable error reporting for the root port device and downstream port > - * devices. > - */ > - set_downstream_devices_error_reporting(pdev, true); > - > /* Enable Root Port's interrupt in response to error messages */ > pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_COMMAND, ®32); > reg32 |= ROOT_PORT_INTR_ON_MESG_MASK; > @@ -1378,10 +1372,17 @@ static void aer_remove(struct pcie_device *dev) > */ > static int aer_probe(struct pcie_device *dev) > { > + struct pci_dev *pdev = dev->port; > + int type = pci_pcie_type(pdev); > int status; > struct aer_rpc *rpc; > struct device *device = &dev->device; > > + if (type == PCI_EXP_TYPE_UPSTREAM || type == PCI_EXP_TYPE_DOWNSTREAM) { > + pci_enable_pcie_error_reporting(pdev); > + return 0; > + } I think we need to either return an error in this case so that the pcie_device won't be eligable for the .remove() callback, or add a similiar type check in aer_remove().