Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp715164ybk; Wed, 20 May 2020 10:07:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymhxQlgAve4GaJHMyGsW+hmV7EjTBjfTIaWW48Xtpo70/C0ciZezPaj9/NDaFfCp8go111 X-Received: by 2002:a17:906:6055:: with SMTP id p21mr65038ejj.316.1589994448427; Wed, 20 May 2020 10:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589994448; cv=none; d=google.com; s=arc-20160816; b=QzQtB3DNqym4PQ0rOHvWO7OYAh+Grd1h36AFw0Ql/8mIoDpwGIo0flKBwphpbQcVOY CQlbLNzu7QFJVqpN+vEo7caZCb3OGIZf1+Mdk6aAN/79f5wJK11O5a2nkr59ML9R7my+ vzc5F7L5jHZaEdd/d/a+II41aoyZFHavqN/AMc7kCBNnuAx0dUeYBjleOma1r4pa4Kva ++DQiCfTAuwygI1/iyBCt8b7l1LOObvlv3k7RqLvJDUPco3f5pt3pPl8op3a7Be20M6Z tgJpG83HX0xwTaK/tsyIekE29ptJPaVOjUONeKE8UWLRBj0ktabHhq3307VIoSE39Wi9 hU6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=4uuwyxL+/pWX50d4AEiuc4oQp1f3hDji+8cAUKVi8+k=; b=gnA/5HjZ7ifG50zWxPzduYJkObAbeEyJdyyXk+K3ATHIo7wKn+bJIL7q456GDUnugw t66HOeBkZ50GooACCuWI4vJ/Sjhonl1d3TAHluIlGhvN5oyjkuaxT8hZwHhl+knsUfaF UVz1CzHw+afy1ao1WRckksLrBeRaXHQYMy0tID9qYXe8pMG709nMvly6ryzGJ0H/q6JX 1t/hedXLs6yAUVTDP3MrDPXa88qO+A/cMdeG1tnUtjpFn4F6A5+z3AAzhhoy815ku5t0 5xHLwPDgjSknIaDsq7Ev08lNR4gzs96KTauKfw9qGDYKuk9GFEj808wvFw4+/nJyJrXU CCEQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p24si2005451eja.35.2020.05.20.10.07.05; Wed, 20 May 2020 10:07:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728018AbgETREj (ORCPT + 99 others); Wed, 20 May 2020 13:04:39 -0400 Received: from mga04.intel.com ([192.55.52.120]:41831 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728008AbgETREa (ORCPT ); Wed, 20 May 2020 13:04:30 -0400 IronPort-SDR: oAatfq2e2if+0VvXLVy39JWc9aLewljZReNKZ89T9QKknf4oc72q9jCsbbUc6vvUyIDPyRCFj9 hBDLV/iMJxQw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 10:04:27 -0700 IronPort-SDR: pdyaneSE1SvFnjbNJYj7WcmrqJFzGGDCv+m7p2ndD56MwaYdM7hDKuQLI0Isy44nsaoySN/B36 BeHx6RP12Ovg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,414,1583222400"; d="scan'208";a="264752424" Received: from kskolet-mobl1.amr.corp.intel.com (HELO [10.255.228.207]) ([10.255.228.207]) by orsmga003.jf.intel.com with ESMTP; 20 May 2020 10:04:26 -0700 Subject: Re: [PATCH v1 1/1] PCI/ERR: Handle fatal error recovery for non-hotplug capable devices To: Yicong Yang , bhelgaas@google.com Cc: jay.vosburgh@canonical.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, ashok.raj@intel.com References: <18609.1588812972@famine> From: "Kuppuswamy, Sathyanarayanan" Message-ID: <2569c75c-41a6-d0f3-ee34-0d288c4e0b61@linux.intel.com> Date: Wed, 20 May 2020 10:04:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/20/20 1:28 AM, Yicong Yang wrote: > On 2020/5/7 11:32, sathyanarayanan.kuppuswamy@linux.intel.com wrote: >> From: Kuppuswamy Sathyanarayanan >> >> If there are non-hotplug capable devices connected to a given >> port, then during the fatal error recovery(triggered by DPC or >> AER), after calling reset_link() function, we cannot rely on >> hotplug handler to detach and re-enumerate the device drivers >> in the affected bus. Instead, we will have to let the error >> recovery handler call report_slot_reset() for all devices in >> the bus to notify about the reset operation. Although this is >> only required for non hot-plug capable devices, doing it for >> hotplug capable devices should not affect the functionality. >> >> Along with above issue, this fix also applicable to following >> issue. >> >> Commit 6d2c89441571 ("PCI/ERR: Update error status after >> reset_link()") added support to store status of reset_link() >> call. Although this fixed the error recovery issue observed if >> the initial value of error status is PCI_ERS_RESULT_DISCONNECT >> or PCI_ERS_RESULT_NO_AER_DRIVER, it also discarded the status >> result from report_frozen_detected. This can cause a failure to >> recover if _NEED_RESET is returned by report_frozen_detected and >> report_slot_reset is not invoked. >> >> Such an event can be induced for testing purposes by reducing the >> Max_Payload_Size of a PCIe bridge to less than that of a device >> downstream from the bridge, and then initiating I/O through the >> device, resulting in oversize transactions. In the presence of DPC, >> this results in a containment event and attempted reset and recovery >> via pcie_do_recovery. After 6d2c89441571 report_slot_reset is not >> invoked, and the device does not recover. >> >> [original patch is from jay.vosburgh@canonical.com] >> [original patch link https://lore.kernel.org/linux-pci/18609.1588812972@famine/] >> Fixes: 6d2c89441571 ("PCI/ERR: Update error status after reset_link()") >> Signed-off-by: Jay Vosburgh >> Signed-off-by: Kuppuswamy Sathyanarayanan >> --- >> drivers/pci/pcie/err.c | 19 +++++++++++++++---- >> 1 file changed, 15 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c >> index 14bb8f54723e..db80e1ecb2dc 100644 >> --- a/drivers/pci/pcie/err.c >> +++ b/drivers/pci/pcie/err.c >> @@ -165,13 +165,24 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, >> pci_dbg(dev, "broadcast error_detected message\n"); >> if (state == pci_channel_io_frozen) { >> pci_walk_bus(bus, report_frozen_detected, &status); >> - status = reset_link(dev); >> - if (status != PCI_ERS_RESULT_RECOVERED) { >> + status = PCI_ERS_RESULT_NEED_RESET; >> + } else { >> + pci_walk_bus(bus, report_normal_detected, &status); >> + } >> + >> + if (status == PCI_ERS_RESULT_NEED_RESET) { >> + if (reset_link) { >> + if (reset_link(dev) != PCI_ERS_RESULT_RECOVERED) > > we'll call reset_link() only if link is frozen. so it may have problem here. you mean before this change right? After this change, reset_link() will be called as long as status is PCI_ERS_RESULT_NEED_RESET. > > Thanks, > Yicong > > >> + status = PCI_ERS_RESULT_DISCONNECT; >> + } else { >> + if (pci_bus_error_reset(dev)) >> + status = PCI_ERS_RESULT_DISCONNECT; >> + } >> + >> + if (status == PCI_ERS_RESULT_DISCONNECT) { >> pci_warn(dev, "link reset failed\n"); >> goto failed; >> } >> - } else { >> - pci_walk_bus(bus, report_normal_detected, &status); >> } >> >> if (status == PCI_ERS_RESULT_CAN_RECOVER) { >