{"id":2232187,"url":"http://patchwork.ozlabs.org/api/patches/2232187/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/patch/785c98b50a7a00d0698848c75d51b8f5669ad18f.1777814679.git.lukas@wunner.de/","project":{"id":28,"url":"http://patchwork.ozlabs.org/api/projects/28/?format=json","name":"Linux PCI development","link_name":"linux-pci","list_id":"linux-pci.vger.kernel.org","list_email":"linux-pci@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<785c98b50a7a00d0698848c75d51b8f5669ad18f.1777814679.git.lukas@wunner.de>","list_archive_url":null,"date":"2026-05-03T13:34:46","name":"PCI: Drop unnecessary retries when restoring BARs","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"871f16b29a222615173f1efafc5bf03eca4d7f34","submitter":{"id":68499,"url":"http://patchwork.ozlabs.org/api/people/68499/?format=json","name":"Lukas Wunner","email":"lukas@wunner.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-pci/patch/785c98b50a7a00d0698848c75d51b8f5669ad18f.1777814679.git.lukas@wunner.de/mbox/","series":[{"id":502576,"url":"http://patchwork.ozlabs.org/api/series/502576/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/list/?series=502576","date":"2026-05-03T13:34:46","name":"PCI: Drop unnecessary retries when restoring BARs","version":1,"mbox":"http://patchwork.ozlabs.org/series/502576/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2232187/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2232187/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-pci+bounces-53639-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-pci+bounces-53639-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=83.223.95.204","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=wunner.de","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=wunner.de"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g7m3j3RHRz1y04\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 03 May 2026 23:34:57 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 18C8E300380B\n\tfor <incoming@patchwork.ozlabs.org>; Sun,  3 May 2026 13:34:54 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 3A5603BF682;\n\tSun,  3 May 2026 13:34:51 +0000 (UTC)","from mailout1.hostsharing.net (mailout1.hostsharing.net\n [83.223.95.204])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F0DD40DFA7\n\tfor <linux-pci@vger.kernel.org>; Sun,  3 May 2026 13:34:47 +0000 (UTC)","from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384\n\t client-signature ECDSA (secp384r1) client-digest SHA384)\n\t(Client CN \"*.hostsharing.net\",\n Issuer \"GlobalSign GCC R6 AlphaSSL CA 2025\" (verified OK))\n\tby mailout1.hostsharing.net (Postfix) with ESMTPS id B7C9CF7D;\n\tSun, 03 May 2026 15:34:45 +0200 (CEST)","by h08.hostsharing.net (Postfix, from userid 100393)\n\tid 9B4D3600D3A1; Sun,  3 May 2026 15:34:45 +0200 (CEST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777815291; cv=none;\n b=P81PdBo/tWGDW3KYszn54dg34pdNTWvNqCmzJnRQzlf/IWEfxvNVmrb8P9ZXg8j5Z/H9h5YXD7ScziiDACQs7k6Acd226BYYnUv/YWCRM4uAFsPZM1znCqThpAD7qPDC/JKJrCeVvblTcmBXdlPBCCFfFrZwqi/h9jzdTDga+l4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777815291; c=relaxed/simple;\n\tbh=qIjIHC5+FujueOg7NuhmFe3oOOhObRieh18z5GOs5tg=;\n\th=Message-Id:From:Date:Subject:To:Cc;\n b=MOSLOk4sGhCQabZ8L2BNDP4PGmce/7hfCq6PNRs6GIJ7T21UZ1W0kO0APDAoFL766/0xnIlBy1KcvQ9KR5+2Irh7SnT4elKir7cigo7e/ua3BvIeTWJsU7bSOc/lT8ZpxLMuED2StyoWvFmjE37Zd3HaAHCs26VHdJolaYGS5Qg=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=wunner.de;\n spf=pass smtp.mailfrom=wunner.de; arc=none smtp.client-ip=83.223.95.204","Message-Id":"\n <785c98b50a7a00d0698848c75d51b8f5669ad18f.1777814679.git.lukas@wunner.de>","From":"Lukas Wunner <lukas@wunner.de>","Date":"Sun, 3 May 2026 15:34:46 +0200","Subject":"[PATCH] PCI: Drop unnecessary retries when restoring BARs","To":"Bjorn Helgaas <helgaas@kernel.org>","Cc":"linux-pci@vger.kernel.org, Marco Nenciarini <mnencia@kcore.it>,\n Michal Winiarski <michal.winiarski@intel.com>,\n Ilpo Jarvinen <ilpo.jarvinen@linux.intel.com>,\n \"Rafael J. Wysocki\" <rafael@kernel.org>, Eric Chanudet <echanude@redhat.com>,\n Jean Guyader <jean.guyader@gmail.com>, Alex Williamson <alex@shazbot.org>,\n Sinan Kaya <okaya@kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>"},"content":"In 2012, commit 26f41062f28d (\"PCI: check for pci bar restore completion\nand retry\") amended pci_restore_state() to attempt BAR restoration up to\n10 times.  This was necessary because back in the day, only a 100 msec\ndelay was observed after pcie_flr() carried out a Function Level Reset.\nThe retries ensured that BARs were restored even if devices needed more\ntime to come out of reset.\n\nIn 2016, commit 5adecf817dd6 (\"PCI: Wait for up to 1000ms after FLR\nreset\") extended the delay to 1 sec.  Commit a2758b6b8fdb (\"PCI: Rename\npci_flr_wait() to pci_dev_wait() and make it generic\") subsequently\nextended it further to 60 sec.\n\nThe lengthened delay makes it unnecessary to retry BAR restoration, so\ndrop it.\n\nReported-by: Bjorn Helgaas <bhelgaas@google.com>\nCloses: https://lore.kernel.org/r/20260416225745.GA41850@bhelgaas/\nSigned-off-by: Lukas Wunner <lukas@wunner.de>\n---\nJesse did ask \"why we don't do this delay/check when we perform the FLR\nin the first place\" when he applied the patch, but nobody followed up\nwith a patch until Alex did four years later:\n\nhttps://lore.kernel.org/r/003AAFE53969E14CB1F09B6FD68C3CD409A8B4F2@ORSMSX105.amr.corp.intel.com/\n\n drivers/pci/pci.c | 36 +++++++++++++-----------------------\n 1 file changed, 13 insertions(+), 23 deletions(-)","diff":"diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c\nindex 8f7cfcc..1e386df 100644\n--- a/drivers/pci/pci.c\n+++ b/drivers/pci/pci.c\n@@ -1764,7 +1764,7 @@ int pci_save_state(struct pci_dev *dev)\n EXPORT_SYMBOL(pci_save_state);\n \n static void pci_restore_config_dword(struct pci_dev *pdev, int offset,\n-\t\t\t\t     u32 saved_val, int retry, bool force)\n+\t\t\t\t     u32 saved_val, bool force)\n {\n \tu32 val;\n \n@@ -1772,52 +1772,42 @@ static void pci_restore_config_dword(struct pci_dev *pdev, int offset,\n \tif (!force && val == saved_val)\n \t\treturn;\n \n-\tfor (;;) {\n-\t\tpci_dbg(pdev, \"restore config %#04x: %#010x -> %#010x\\n\",\n-\t\t\toffset, val, saved_val);\n-\t\tpci_write_config_dword(pdev, offset, saved_val);\n-\t\tif (retry-- <= 0)\n-\t\t\treturn;\n+\tpci_dbg(pdev, \"restore config %#04x: %#010x -> %#010x\\n\", offset, val,\n+\t\tsaved_val);\n \n-\t\tpci_read_config_dword(pdev, offset, &val);\n-\t\tif (val == saved_val)\n-\t\t\treturn;\n-\n-\t\tmdelay(1);\n-\t}\n+\tpci_write_config_dword(pdev, offset, saved_val);\n }\n \n static void pci_restore_config_space_range(struct pci_dev *pdev,\n-\t\t\t\t\t   int start, int end, int retry,\n-\t\t\t\t\t   bool force)\n+\t\t\t\t\t   int start, int end, bool force)\n {\n \tint index;\n \n \tfor (index = end; index >= start; index--)\n \t\tpci_restore_config_dword(pdev, 4 * index,\n \t\t\t\t\t pdev->saved_config_space[index],\n-\t\t\t\t\t retry, force);\n+\t\t\t\t\t force);\n }\n \n static void pci_restore_config_space(struct pci_dev *pdev)\n {\n \tif (pdev->hdr_type == PCI_HEADER_TYPE_NORMAL) {\n-\t\tpci_restore_config_space_range(pdev, 10, 15, 0, false);\n+\t\tpci_restore_config_space_range(pdev, 10, 15, false);\n \t\t/* Restore BARs before the command register. */\n-\t\tpci_restore_config_space_range(pdev, 4, 9, 10, false);\n-\t\tpci_restore_config_space_range(pdev, 0, 3, 0, false);\n+\t\tpci_restore_config_space_range(pdev, 4, 9, false);\n+\t\tpci_restore_config_space_range(pdev, 0, 3, false);\n \t} else if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {\n-\t\tpci_restore_config_space_range(pdev, 12, 15, 0, false);\n+\t\tpci_restore_config_space_range(pdev, 12, 15, false);\n \n \t\t/*\n \t\t * Force rewriting of prefetch registers to avoid S3 resume\n \t\t * issues on Intel PCI bridges that occur when these\n \t\t * registers are not explicitly written.\n \t\t */\n-\t\tpci_restore_config_space_range(pdev, 9, 11, 0, true);\n-\t\tpci_restore_config_space_range(pdev, 0, 8, 0, false);\n+\t\tpci_restore_config_space_range(pdev, 9, 11, true);\n+\t\tpci_restore_config_space_range(pdev, 0, 8, false);\n \t} else {\n-\t\tpci_restore_config_space_range(pdev, 0, 15, 0, false);\n+\t\tpci_restore_config_space_range(pdev, 0, 15, false);\n \t}\n }\n \n","prefixes":[]}