Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2388254imm; Thu, 18 Oct 2018 13:51:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV63YddJ7alzH3hZ/zNR21pgbZWR5oQYWFM8RF8VPdnTYn2s02hy6e6k6qH5XZzjYxtzRqR/6 X-Received: by 2002:a65:664e:: with SMTP id z14-v6mr28874412pgv.347.1539895889978; Thu, 18 Oct 2018 13:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539895889; cv=none; d=google.com; s=arc-20160816; b=NwtP7WNmkkXdfBDqDqZE9MX8qdbt++cqHRrB1EmljFUff05RYat4GXkj1LzywG9i5M C01uS4E1G3c9gIF/1cZ2pryxNq60Xziikv6v+KVCicf61TtmLP821KJeZ9640n7je6o3 xv2TVYxmMGFQa+96zK+xlGXGrhKTj67gDiZqv0FwJwj2wUmBRSyhMkDWynh8GmLk0x/5 V5Ak6NoPUgX8Q2YZ5G3/iKD5pXnSjBpwCrMf4Sx24+weEH68WZE14QeqRZh/MT0CBUXi 2RmAT2fGW+LkqKv3/aOkh/u+oRzIOVQOgzAoniBUzhLZxIkXfV+gHZgnxTfQlm/nywsz F5+A== 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:dkim-signature; bh=LNNo9AztzBTdxWIp6cH4hcl7q5lNnZwQOqYqGuv3YEQ=; b=omWanaHobVFKel+7P2nZxVnmTSm6yY5nMCJbqlFiXsdEF40ORwVeEL2NlVCeZVWKY5 5NQUFed98+xsaSm/mcMddTreLh2V86GVRp29fHwrm3f/52tt3wjiyQXrW6FgLRlUsugT nmioPo7HG0xEyxx+pm+9tPtPSyQOFarasrZcnCsrXsv0PnY1U6xSRwwoGyKPHlrB6fp9 9yTBj5XZPKWLsQgjirIlAh67JXxMPd5Ekg8CXaWAIpM3EPPJXC3BSfxwI60I8pKbI2+/ tATtnDNr1n3IIwLfCehHtE1Pa/ysCVgVwRPiIRq9dj6a/jBWEW0QJdFsYHFMwk49l1jr UQeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DFHV5iqS; 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=pass (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 cb15-v6si22938900plb.104.2018.10.18.13.51.11; Thu, 18 Oct 2018 13:51:29 -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; dkim=pass header.i=@kernel.org header.s=default header.b=DFHV5iqS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726589AbeJSEwF (ORCPT + 99 others); Fri, 19 Oct 2018 00:52:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:46042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725738AbeJSEwF (ORCPT ); Fri, 19 Oct 2018 00:52:05 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B86820658; Thu, 18 Oct 2018 20:49:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539895757; bh=YoMH39JP+KIl5vfa8x4renibZiFO7FX13rG2odnkKC8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DFHV5iqShAmPRrN9ksXy2aMOfIyjb3cXO33BCv7IILTfRAnG3MWhiNr+Jr1I9TEnd xKs5gEsVpRH3Vpmil/34z3Nk6X5NsqreRccE/PAQv8rPwT6yuzojsCyU8bQ2hroxdL lnSALCSHERye/CioizIyb2rlDZFwIjVNZinQFrSw= Date: Thu, 18 Oct 2018 15:49:16 -0500 From: Bjorn Helgaas To: Keith Busch 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: <20181018204915.GK5906@bhelgaas-glaptop.roam.corp.google.com> References: <153927123657.40414.9802241131940995491.stgit@bhelgaas-glaptop.roam.corp.google.com> <153927157816.40414.5263399018962087014.stgit@bhelgaas-glaptop.roam.corp.google.com> <20181011155715.GD11034@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181011155715.GD11034@localhost.localdomain> User-Agent: Mutt/1.10.1 (2018-07-13) 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 09:57:16AM -0600, Keith Busch wrote: > 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(). Indeed, thanks! I think a check in aer_remove() seems nicer. It doesn't seem right to return an error here, since everything is working correctly. Bjorn