From nobody Sun Dec 28 21:15:37 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4B9FC4167B for ; Tue, 5 Dec 2023 17:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345351AbjLERL3 (ORCPT ); Tue, 5 Dec 2023 12:11:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232194AbjLERLV (ORCPT ); Tue, 5 Dec 2023 12:11:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33538D43 for ; Tue, 5 Dec 2023 09:11:27 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C0D1C433C9; Tue, 5 Dec 2023 17:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701796286; bh=SHRKGwDoVF1G5pI2uXdiU2j2HD1GhNV1bFDWy1EgiQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oz7aiQkW8Riza4Ilemm9GNYNXNd8o78kRd0umW+FYYavHtzRjmbSvhY+XnsuAKS1R ETZ16KI3ktKyiPVGQCwWVQBMIPBb2ORwdv6fczHVgAS7FW+cz762RTMkuog4P9izWu VtyKND0Rh/0Xi7QGg9VKSIMYbkpjcOHEBleijIaF+MzndkG9HRYO6GFmamuOTxp/f1 SPCRqil0ia6q41yeHBm3eq493FY9BE6I2kNLIKBaJmvG3eyvBx9AuZREcYEFFOj3CI zqPVpyKAmXs2ddX26uJIDty1pUDfVpIUbGdIt8AbqXaoZLohjHGt9ZhNS8DOSAyUS1 z4RjwMjEX6+lA== From: Bjorn Helgaas To: linux-pci@vger.kernel.org Cc: Puranjay Mohan , linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH 1/7] PCI: Log device type during enumeration Date: Tue, 5 Dec 2023 11:11:13 -0600 Message-Id: <20231205171119.680358-2-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231205171119.680358-1-helgaas@kernel.org> References: <20231205171119.680358-1-helgaas@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bjorn Helgaas Log the device type when enumeration a device. Sample output changes: - pci 0000:00:00.0: [8086:1237] type 00 class 0x060000 + pci 0000:00:00.0: [8086:1237] type 00 class 0x060000 conventional PCI e= ndpoint - pci 0000:00:1c.0: [8086:a110] type 01 class 0x060400 + pci 0000:00:1c.0: [8086:a110] type 01 class 0x060400 PCIe Root Port Signed-off-by: Bjorn Helgaas --- drivers/pci/probe.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ed6b7f48736a..1dbc06f0305c 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1817,6 +1817,43 @@ static void early_dump_pci_device(struct pci_dev *pd= ev) value, 256, false); } =20 +static const char *pci_type_str(struct pci_dev *dev) +{ + static const char *str[] =3D { + "PCIe Endpoint", + "PCIe Legacy Endpoint", + "PCIe unknown", + "PCIe unknown", + "PCIe Root Port", + "PCIe Upstream Switch Port", + "PCIe Downstream Switch Port", + "PCIe to PCI/PCI-X bridge", + "PCI/PCI-X to PCIe bridge", + "PCIe Root Complex Integrated Endpoint", + "PCIe Root Complex Event Collector", + }; + int type; + + if (pci_is_pcie(dev)) { + type =3D pci_pcie_type(dev); + if (type < ARRAY_SIZE(str)) + return str[type]; + + return "PCIe unknown"; + } + + switch (dev->hdr_type) { + case PCI_HEADER_TYPE_NORMAL: + return "conventional PCI endpoint"; + case PCI_HEADER_TYPE_BRIDGE: + return "conventional PCI bridge"; + case PCI_HEADER_TYPE_CARDBUS: + return "CardBus bridge"; + default: + return "conventional PCI"; + } +} + /** * pci_setup_device - Fill in class and map information of a device * @dev: the device structure to fill @@ -1887,8 +1924,9 @@ int pci_setup_device(struct pci_dev *dev) =20 pci_set_removable(dev); =20 - pci_info(dev, "[%04x:%04x] type %02x class %#08x\n", - dev->vendor, dev->device, dev->hdr_type, dev->class); + pci_info(dev, "[%04x:%04x] type %02x class %#08x %s\n", + dev->vendor, dev->device, dev->hdr_type, dev->class, + pci_type_str(dev)); =20 /* Device class may be changed after fixup */ class =3D dev->class >> 8; --=20 2.34.1