Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2401958pxu; Fri, 9 Oct 2020 16:37:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZDL6GAZvUi+nXPA/LC27mtiNTt7gpuBewKeeuH+Hb6r12vz3+ZR9AeiUkp4E0Ajmhgp5m X-Received: by 2002:a17:906:f28f:: with SMTP id gu15mr17284554ejb.291.1602286668273; Fri, 09 Oct 2020 16:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602286668; cv=none; d=google.com; s=arc-20160816; b=J0BsHYQOk5BZ2iZ6DzM7B0eG+F1uOO2fIBI0HTKSVpuMSd+5t3vmW93hvWQaLrHwLq vnAMaLw6UkF66UNl94IyaYeyyLX9/n4cHjBtOfRdXJgYapG1PlpI++2q7AIeKQ3lSpi/ aYC8kHmQ/5C5REVT+0gMY4dUQNXKr9VG0Mc06g+/KWbi8vMUg7LQ3fA9HKw5JluBqEsa Ru+V3x+bKKSI8ogbA9ybU6FTR1sfgtgs4dbfGBiZbUhrKKgh2OpPK+MGMweTgHu7zgHt pQ649t6RjnaPF4gB0QeuUE0yu4+j6yHekFFnpxEhL/dGZCmFeOtxNtCUmKkdm6dm64ft aSuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=G3VGC7vDynkeGNwKHTNsGvMEf4UQC0Q9VV/SPIKUSB4=; b=V0Fx4blrOV7gLUCl1J+kxCCnzr8YFaqFlVwlAuOSG1lrV8DZeLFMqyfa0KBJfndmcl +dEtBRvU/VX1o9oSmzLwJX6tmpbuKfoWd7Y9QEOOcBg06lL+zNgSQ13j64wIOex/llXe wcrdOhMeQvWgsnURkVqfhMYLt7XoWZhy5m/44IQqxHWh4BQuf/Z1Yi1DjCepzhYXMUOj ZZ47MiUzDdC0IEflYs6tOB5pTlpauVHVx+0ZNQKiSxUuVKaa62ZIDtZzRNvUFMeiUpzC ZjDhBbtixSXUscn4D06PBwzjAhnYwwhOgTIoJ1y/+RM+SlDnTwqjj5cS95uGq2ijoqc0 uVng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mkPqIcHI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id y20si7096832ejw.696.2020.10.09.16.37.25; Fri, 09 Oct 2020 16:37:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mkPqIcHI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2390237AbgJIR5s (ORCPT + 99 others); Fri, 9 Oct 2020 13:57:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:51712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731500AbgJIR5s (ORCPT ); Fri, 9 Oct 2020 13:57:48 -0400 Received: from localhost (170.sub-72-107-125.myvzw.com [72.107.125.170]) (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 B561F21D6C; Fri, 9 Oct 2020 17:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602266267; bh=fA1G6iaFDU8VitYbv4kHdSBjdwWgSXZzpv/yl/rHKUc=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=mkPqIcHIoP46GfkP4si6HrPvnVwqvUb7LVO24Rjd5RRYzdQ6NGgK4V3lp4H5S/JWf 3LRdWSyQ8jJ86RmZLdHwTMg0GyaGfMZ/6+cfdU2KOYbsScncWfp3RoIL87hNj7l1lM IqHksy9o0ZF7NHDkUkyAw44B4WeBPioEFD3WSxmY= Date: Fri, 9 Oct 2020 12:57:45 -0500 From: Bjorn Helgaas To: Sean V Kelley Cc: bhelgaas@google.com, Jonathan.Cameron@huawei.com, rafael.j.wysocki@intel.com, ashok.raj@intel.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@intel.com, qiuxu.zhuo@intel.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Sean V Kelley Subject: Re: [PATCH v8 11/14] PCI/RCEC: Add RCiEP's linked RCEC to AER/ERR Message-ID: <20201009175745.GA3489710@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201002184735.1229220-12-seanvk.dev@oregontracks.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 02, 2020 at 11:47:32AM -0700, Sean V Kelley wrote: > From: Qiuxu Zhuo > > When attempting error recovery for an RCiEP associated with an RCEC device, > there needs to be a way to update the Root Error Status, the Uncorrectable > Error Status and the Uncorrectable Error Severity of the parent RCEC. > In some non-native cases in which there is no OS visible device > associated with the RCiEP, there is nothing to act upon as the firmware > is acting before the OS. So add handling for the linked 'rcec' in AER/ERR > while taking into account non-native cases. > > Co-developed-by: Sean V Kelley > Signed-off-by: Sean V Kelley > Signed-off-by: Qiuxu Zhuo > Reviewed-by: Jonathan Cameron > --- > drivers/pci/pcie/aer.c | 9 +++++---- > drivers/pci/pcie/err.c | 39 ++++++++++++++++++++++++++++----------- > 2 files changed, 33 insertions(+), 15 deletions(-) > > diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c > index 65dff5f3457a..dccdba60b5d9 100644 > --- a/drivers/pci/pcie/aer.c > +++ b/drivers/pci/pcie/aer.c > @@ -1358,17 +1358,18 @@ static int aer_probe(struct pcie_device *dev) > static pci_ers_result_t aer_root_reset(struct pci_dev *dev) > { > int aer = dev->aer_cap; > + int rc = 0; > u32 reg32; > - int rc; > - > > /* Disable Root's interrupt in response to error messages */ > pci_read_config_dword(dev, aer + PCI_ERR_ROOT_COMMAND, ®32); > reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK; > pci_write_config_dword(dev, aer + PCI_ERR_ROOT_COMMAND, reg32); > > - rc = pci_bus_error_reset(dev); > - pci_info(dev, "Root Port link has been reset\n"); > + if (pci_pcie_type(dev) != PCI_EXP_TYPE_RC_EC) { > + rc = pci_bus_error_reset(dev); > + pci_info(dev, "Root Port link has been reset\n"); > + } > > /* Clear Root Error Status */ > pci_read_config_dword(dev, aer + PCI_ERR_ROOT_STATUS, ®32); > diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c > index 38abd7984996..956ad4c86d53 100644 > --- a/drivers/pci/pcie/err.c > +++ b/drivers/pci/pcie/err.c > @@ -149,7 +149,8 @@ static int report_resume(struct pci_dev *dev, void *data) > /** > * pci_walk_bridge - walk bridges potentially AER affected > * @bridge bridge which may be an RCEC with associated RCiEPs, > - * an RCiEP associated with an RCEC, or a Port. > + * or a Port. > + * @dev an RCiEP lacking an associated RCEC. > * @cb callback to be called for each device found > * @userdata arbitrary pointer to be passed to callback. > * > @@ -160,13 +161,20 @@ static int report_resume(struct pci_dev *dev, void *data) > * If the device provided has no subordinate bus, call the provided > * callback on the device itself. > */ > -static void pci_walk_bridge(struct pci_dev *bridge, int (*cb)(struct pci_dev *, void *), > +static void pci_walk_bridge(struct pci_dev *bridge, struct pci_dev *dev, > + int (*cb)(struct pci_dev *, void *), > void *userdata) > { > - if (bridge->subordinate) > + /* > + * In a non-native case where there is no OS-visible reporting > + * device the bridge will be NULL, i.e., no RCEC, no PORT. > + */ > + if (bridge && bridge->subordinate) > pci_walk_bus(bridge->subordinate, cb, userdata); > - else > + else if (bridge) > cb(bridge, userdata); > + else > + cb(dev, userdata); > } > > static pci_ers_result_t flr_on_rciep(struct pci_dev *dev) > @@ -196,16 +204,25 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, > type = pci_pcie_type(dev); > if (type == PCI_EXP_TYPE_ROOT_PORT || > type == PCI_EXP_TYPE_DOWNSTREAM || > - type == PCI_EXP_TYPE_RC_EC || > - type == PCI_EXP_TYPE_RC_END) > + type == PCI_EXP_TYPE_RC_EC) > bridge = dev; > + else if (type == PCI_EXP_TYPE_RC_END) > + bridge = dev->rcec; > else > bridge = pci_upstream_bridge(dev); > > pci_dbg(dev, "broadcast error_detected message\n"); > if (state == pci_channel_io_frozen) { > - pci_walk_bridge(bridge, report_frozen_detected, &status); > + pci_walk_bridge(bridge, dev, report_frozen_detected, &status); > if (type == PCI_EXP_TYPE_RC_END) { > + /* > + * The callback only clears the Root Error Status > + * of the RCEC (see aer.c). Only perform this for the > + * native case, i.e., an RCEC is present. > + */ > + if (bridge) > + reset_subordinate_devices(bridge); Help me understand this. There are lots of callbacks in this picture, but I guess this "callback only clears Root Error Status" must refer to aer_root_reset(), i.e., the reset_subordinate_devices pointer? Of course, the caller of pcie_do_recovery() supplied that pointer. And we can infer that it must be aer_root_reset(), not dpc_reset_link(), because RCECs and RCiEPs are not allowed to implement DPC. I wish we didn't have either this assumption about what reset_subordinate_devices points to, or the assumption about what aer_root_reset() does. They both seem a little bit tenuous. We already made aer_root_reset() smart enough to check for RCECs. Can we put the FLR there, too? Then we wouldn't have this weird situation where reset_subordinate_devices() does a reset and clears error status, EXCEPT for this case where it only clears error status and we do the reset here? > status = flr_on_rciep(dev); > if (status != PCI_ERS_RESULT_RECOVERED) { > pci_warn(dev, "function level reset failed\n"); > @@ -219,13 +236,13 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, > } > } > } else { > - pci_walk_bridge(bridge, report_normal_detected, &status); > + pci_walk_bridge(bridge, dev, report_normal_detected, &status); > } > > if (status == PCI_ERS_RESULT_CAN_RECOVER) { > status = PCI_ERS_RESULT_RECOVERED; > pci_dbg(dev, "broadcast mmio_enabled message\n"); > - pci_walk_bridge(bridge, report_mmio_enabled, &status); > + pci_walk_bridge(bridge, dev, report_mmio_enabled, &status); > } > > if (status == PCI_ERS_RESULT_NEED_RESET) { > @@ -236,14 +253,14 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, > */ > status = PCI_ERS_RESULT_RECOVERED; > pci_dbg(dev, "broadcast slot_reset message\n"); > - pci_walk_bridge(bridge, report_slot_reset, &status); > + pci_walk_bridge(bridge, dev, report_slot_reset, &status); > } > > if (status != PCI_ERS_RESULT_RECOVERED) > goto failed; > > pci_dbg(dev, "broadcast resume message\n"); > - pci_walk_bridge(bridge, report_resume, &status); > + pci_walk_bridge(bridge, dev, report_resume, &status); > > if (type == PCI_EXP_TYPE_ROOT_PORT || > type == PCI_EXP_TYPE_DOWNSTREAM || > -- > 2.28.0 >