Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1528420pxk; Fri, 2 Oct 2020 11:49:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg8h+YoQZ0PkvmsvG5IZjOJm4Ct/cZwC+lDgkI7PUKiOWo5uSsqs/f9hF2cNfp3zFdyCUt X-Received: by 2002:a17:906:4dc3:: with SMTP id f3mr3776881ejw.50.1601664576554; Fri, 02 Oct 2020 11:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601664576; cv=none; d=google.com; s=arc-20160816; b=J8i/JhbjiKmJcV4qbukk5EnlmTdCikdJ2bNARMVXYkN2MtQwFz4OJ4GzIuAtgzK73s KmNyjNZbdP8p8I6/b4tuv7eMAc+tOg+Uza0pB9FZL4kigCiM/pr3i13CZ2S+KhhuvrUe yFhnrk3HAeTrDu1pd51hQJsBrRoZH96A+VsMdfelpawbRpHpLRI7b8RWx58gtNuQL8LP bSjUL9siFA65+ATgSxdYwg2Tpz46JmEWDScEwEJo4xaifXjrC5+bfTKHfsdBpS7LSLcM nPNPIV8Y/XI42p+kZLLFXQq0/JydYFq+xYedq/4QNazvtKvnbAH1UpqsBuhqv1l2ITnp RxLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=RvNXChfCO49Huc+IA9ctJyJl6CuCZgjiaLEu9TFj2D0=; b=Va6xJZidzQd+PVpsF0Q84kPNJVtRlwgQZeXW7yf+4iT8EZNBiUn+5iyunzF1/9n3so 1FHjxqSX7UclAsyAhKCWMRCCMHO7yMmRabard1doAo5xfbMpP20ALJ+wqvh9L+BNCQbK w09J/uYms9uruz7eOjlfbJfyedzg4cfHntODQCL3Z3ZMUlCYk1ky2zTGBnA1w1fEnXSP ElOgG1SF95ul2x7fqgnyBkzsi8kRhHu/RwtT2lstdG6fM8ZfFPFIFcTFtrvWQUrvGyfI 0a1Ggkxezm7/gwsXUFzoMAJGzT7QUcNO8IA9nZ04nIOIVpw7cOYjaxNyqBtnOxrnRnHg wNzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oregontracks.org header.s=fm1 header.b=DtYcej5g; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="L2/9Es/x"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u3si1618585edp.313.2020.10.02.11.49.14; Fri, 02 Oct 2020 11:49:36 -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=@oregontracks.org header.s=fm1 header.b=DtYcej5g; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="L2/9Es/x"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388409AbgJBSsJ (ORCPT + 99 others); Fri, 2 Oct 2020 14:48:09 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:60973 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388336AbgJBSsF (ORCPT ); Fri, 2 Oct 2020 14:48:05 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 9CD945C014B; Fri, 2 Oct 2020 14:48:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 02 Oct 2020 14:48:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= oregontracks.org; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=fm1; bh=RvNXChfCO49Huc+IA9ctJyJl6CuCZgjiaLEu9TFj2D0=; b=DtYce j5gZ6xAbWl0T4dVpUPRolfUr/bCN5YI8jWBealz/czdj4JBTEF+ehOHDQGDz8rSq HUQHa6/aESpQaI54lLmGhpjdJrRSNiAvwpnf328J3iPnXYm0zXA6pMdL46nL8XWT W9+Xm06z9wE6OwXAByCgrDMpunJ9S4PLFPXc7TmCU+eA9oxYSPHFyouHFSkNaryW gfWoWKjqQgNjw0JOCkjve7mo1Xq04c2AQqfQLjJBk7iS4EgAJWyJ2RoM3PP7tNf7 AwZa5aa5CaU2anbB6kXwPHbflAIwgdh6ALIR9gh34aJKBj0/gaIkNSj+7ZnUizJ+ dV1HWMcJumMXa+W2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=RvNXChfCO49Huc+IA9ctJyJl6CuCZgjiaLEu9TFj2D0=; b=L2/9Es/x PXdwHqmXjmtoUyO/d7mHsxLdMrG28E6eB0DxkdCrQRe1jHPMY9JHktkaN0wxaEZb BG1NOWbXQ64E18HUJaePNpvHe5C+aOV3CKAihFIARrcPbAuyfJgl8Kjg0/4Lj4vL q8NebfP4ZQT8UgU5LxLXkQ75G8TIPaHkeSwOactUUjZ9X11zCwzKxVo0vHMIe/Yh khtlozjHmbnUPVFuQUnDhtBw65zJVaQrGnPDncrduL6X91Emzv9tIlkjtCTUyh92 sc3cXn2rh7cBSGvLtMnhZdt2EHvEH+Yqj2PdVg8YAMc6523SVlejHjhyAHZ2dF6e Jh3oMTo+nZZYPg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrfeeigdduvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepufgvrghnucggucfmvghllhgvhicuoehsvggrnhhvkhdruggv vhesohhrvghgohhnthhrrggtkhhsrdhorhhgqeenucggtffrrghtthgvrhhnpeehkeffte eiudeiffelkeelvefftdelhfeitdeigeffleeufedvgfegvdefvedtteenucfkphepvdeg rddvtddrudegkedrgeelnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrg hilhhfrhhomhepshgvrghnvhhkrdguvghvsehorhgvghhonhhtrhgrtghkshdrohhrgh X-ME-Proxy: Received: from arch-ashland-svkelley.hsd1.or.comcast.net (c-24-20-148-49.hsd1.or.comcast.net [24.20.148.49]) by mail.messagingengine.com (Postfix) with ESMTPA id 6915F3064680; Fri, 2 Oct 2020 14:48:01 -0400 (EDT) From: Sean V Kelley To: 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 Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Sean V Kelley Subject: [PATCH v8 06/14] PCI/ERR: Add pci_walk_bridge() to pcie_do_recovery() Date: Fri, 2 Oct 2020 11:47:27 -0700 Message-Id: <20201002184735.1229220-7-seanvk.dev@oregontracks.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201002184735.1229220-1-seanvk.dev@oregontracks.org> References: <20201002184735.1229220-1-seanvk.dev@oregontracks.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean V Kelley Consolidate subordinate bus checks with pci_walk_bus() into pci_walk_bridge() for walking below potentially AER affected bridges. Suggested-by: Bjorn Helgaas Signed-off-by: Sean V Kelley --- drivers/pci/pcie/err.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index e68ea5243ff2..9b2130725ab6 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -146,12 +146,28 @@ static int report_resume(struct pci_dev *dev, void *data) return 0; } +/** + * pci_walk_bridge - walk bridges potentially AER affected + * @bridge bridge which may be a Port. + * @cb callback to be called for each device found + * @userdata arbitrary pointer to be passed to callback. + * + * If the device provided is a bridge, walk the subordinate bus, + * including any bridged devices on buses under this bus. + * Call the provided callback on each device found. + */ +static void pci_walk_bridge(struct pci_dev *bridge, int (*cb)(struct pci_dev *, void *), + void *userdata) +{ + if (bridge->subordinate) + pci_walk_bus(bridge->subordinate, cb, userdata); +} + pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, pci_channel_state_t state, pci_ers_result_t (*reset_subordinate_devices)(struct pci_dev *pdev)) { pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER; - struct pci_bus *bus; struct pci_dev *bridge; int type; @@ -167,23 +183,22 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, else bridge = pci_upstream_bridge(dev); - bus = bridge->subordinate; pci_dbg(dev, "broadcast error_detected message\n"); if (state == pci_channel_io_frozen) { - pci_walk_bus(bus, report_frozen_detected, &status); + pci_walk_bridge(bridge, report_frozen_detected, &status); status = reset_subordinate_device(bridge); if (status != PCI_ERS_RESULT_RECOVERED) { pci_warn(dev, "subordinate device reset failed\n"); goto failed; } } else { - pci_walk_bus(bus, report_normal_detected, &status); + pci_walk_bridge(bridge, 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_bus(bus, report_mmio_enabled, &status); + pci_walk_bridge(bridge, report_mmio_enabled, &status); } if (status == PCI_ERS_RESULT_NEED_RESET) { @@ -194,14 +209,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_bus(bus, report_slot_reset, &status); + pci_walk_bridge(bridge, report_slot_reset, &status); } if (status != PCI_ERS_RESULT_RECOVERED) goto failed; pci_dbg(dev, "broadcast resume message\n"); - pci_walk_bus(bus, report_resume, &status); + pci_walk_bridge(bridge, report_resume, &status); if (pcie_aer_is_native(bridge)) pcie_clear_device_status(bridge); -- 2.28.0