Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3565631pxu; Sun, 11 Oct 2020 15:07:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx05cuQAzEc3Vjyx+6ob8kgYkYGKH1yaBYUY0QG5QfbSKSWrJOb2wSTqoFAX4PV9kPZKK8r X-Received: by 2002:a05:6402:b72:: with SMTP id cb18mr10598691edb.129.1602454021597; Sun, 11 Oct 2020 15:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602454021; cv=none; d=google.com; s=arc-20160816; b=TZ6/+3fytbetls9YuGmrzQVjBXKUXMcABIeKRejFK5JS9ptmaynlCwSG1gciVRM8Nv +Vdvvi+x0RlB+LCj6y6h41FmP37MiiIr2vC3+a90JaWmGVfqqYqf6vCK2h1PTK7dc5b3 K++yVCkkj2RwXhTy1MPZQUA5e6U+mL71pITdmmkl90V8f+F+ipw5Vb4wUkduyXzfvcZV kzYt0DBvjqAh9byYwuRbwqSfILp18RlTmnHPYPXCBApKUZzU6cX/2G8UF1ENhc4lfmEE k6AwLvxcV+eS7GT6ZoNviBL4pL9OJAPfPulXAenNTk41nQnp6iDqLdT6dC5wij4HDOug 2rtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject:dkim-signature; bh=LlD/YHfT17ZKGsvdafGMOJ6htg2Ozi9xq7/PQhFxcPQ=; b=jhhyQEsq4sFXjAadBqTkP/x1K4Yut3t8XEkf3lgF+V52PUNBMNWEKQPqfEBd2/scbM CDQz6iNllBfxrCMdZqhKsbbOzI2GIIEXQpMe/xtxaUI/L+gIeOxxoEB9ocUb6e3U+DgF GZcPjfHBrJ+sK9ROP5qQg/Ci1zw55el90IDRfn+eOzZU4o3ioL2mo2SIjFsOziQEbfyy GME2jqOg+myBxYd26jyOU8Y3fbg5VOMJDkEPpIwIaPDNlLHRmk8yuRuYHZ9n2qAMH8Rn ARIp5rg1wQEPkWRGatOSSSzwOH+PiANlYBFkE1GGfdoHcmbDs8nLnutKcQeQUzf8Lo9Z 3X6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vdQMvO01; 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 i6si7009146edv.483.2020.10.11.15.06.12; Sun, 11 Oct 2020 15:07:01 -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=vdQMvO01; 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 S2388340AbgJKR4Q (ORCPT + 99 others); Sun, 11 Oct 2020 13:56:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:47232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388329AbgJKR4Q (ORCPT ); Sun, 11 Oct 2020 13:56:16 -0400 Received: from [192.168.0.112] (75-58-59-55.lightspeed.rlghnc.sbcglobal.net [75.58.59.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7EE4C2222A; Sun, 11 Oct 2020 17:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602438975; bh=3swoFZnk6eoJR33A60KKudC95FI10RHpWVJDChX64ag=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=vdQMvO0197ufHU2Xnm012dowy74xeJ4qOTOh6me0mBnoaSWAa4nxG6SBhENXxKdNh sGYP0th9GLnAinFbAxH82Y3ptXEJ8YEYu4MRK4PH8muTdxMqyCSERDJuHhuChvVbOn UzILR5BuW3HHoDlMEfn94BSbMgfJZy6HEsSHld04= Subject: Re: [RESEND PATCH v3 1/1] PCI/ERR: don't clobber status after reset_link() To: Hedi Berriche , sathyanarayanan.kuppuswamy@linux.intel.com Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Russ Anderson , Bjorn Helgaas , Ashok Raj , Joerg Roedel , stable@kernel.org References: <20201010221653.2782993-1-hedi.berriche@hpe.com> <20201010221653.2782993-2-hedi.berriche@hpe.com> From: Sinan Kaya Autocrypt: addr=okaya@kernel.org; keydata= mQENBFrnOrUBCADGOL0kF21B6ogpOkuYvz6bUjO7NU99PKhXx1MfK/AzK+SFgxJF7dMluoF6 uT47bU7zb7HqACH6itTgSSiJeSoq86jYoq5s4JOyaj0/18Hf3/YBah7AOuwk6LtV3EftQIhw 9vXqCnBwP/nID6PQ685zl3vH68yzF6FVNwbDagxUz/gMiQh7scHvVCjiqkJ+qu/36JgtTYYw 8lGWRcto6gr0eTF8Wd8f81wspmUHGsFdN/xPsZPKMw6/on9oOj3AidcR3P9EdLY4qQyjvcNC V9cL9b5I/Ud9ghPwW4QkM7uhYqQDyh3SwgEFudc+/RsDuxjVlg9CFnGhS0nPXR89SaQZABEB AAG0HVNpbmFuIEtheWEgPG9rYXlhQGtlcm5lbC5vcmc+iQFOBBMBCAA4FiEEYdOlMSE+a7/c ckrQvGF4I+4LAFcFAlztcAoCGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQvGF4I+4L AFfidAf/VKHInxep0Z96iYkIq42432HTZUrxNzG9IWk4HN7c3vTJKv2W+b9pgvBF1SmkyQSy 8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: Sun, 11 Oct 2020 13:56:13 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20201010221653.2782993-2-hedi.berriche@hpe.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/10/2020 6:16 PM, Hedi Berriche wrote: > Commit 6d2c89441571 ("PCI/ERR: Update error status after reset_link()") > broke pcie_do_recovery(): updating status after reset_link() has the ill > side effect of causing recovery to fail if the error status is > PCI_ERS_RESULT_CAN_RECOVER or PCI_ERS_RESULT_NEED_RESET as the following > code will *never* run in the case of a successful reset_link() > > 177 if (status == PCI_ERS_RESULT_CAN_RECOVER) { > ... > 181 } > > 183 if (status == PCI_ERS_RESULT_NEED_RESET) { > ... > 192 } > > For instance in the case of PCI_ERS_RESULT_NEED_RESET we end up not > calling ->slot_reset() (because we skip report_slot_reset()) thus > breaking driver (re)initialisation. > > Don't clobber status with the return value of reset_link(); set status > to PCI_ERS_RESULT_RECOVERED, in case of successful link reset, if and > only if the initial value of error status is PCI_ERS_RESULT_DISCONNECT > or PCI_ERS_RESULT_NO_AER_DRIVER. > > Fixes: 6d2c89441571 ("PCI/ERR: Update error status after reset_link()") > Signed-off-by: Hedi Berriche > Cc: Russ Anderson > Cc: Kuppuswamy Sathyanarayanan > Cc: Bjorn Helgaas > Cc: Ashok Raj > Cc: Joerg Roedel > > Cc: stable@kernel.org # v5.7+ > --- > drivers/pci/pcie/err.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c > index c543f419d8f9..2730826cfd8a 100644 > --- a/drivers/pci/pcie/err.c > +++ b/drivers/pci/pcie/err.c > @@ -165,10 +165,13 @@ 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) { > + if (reset_link(dev) != PCI_ERS_RESULT_RECOVERED) { > pci_warn(dev, "link reset failed\n"); > goto failed; > + } else { > + if (status == PCI_ERS_RESULT_DISCONNECT || > + status == PCI_ERS_RESULT_NO_AER_DRIVER) > + status = PCI_ERS_RESULT_RECOVERED; > } > } else { > pci_walk_bus(bus, report_normal_detected, &status); > Reviewed-by: Sinan Kaya