From 9e7d323565bf286ad3467982779afb2d846b7885 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Parna Date: Wed, 5 Mar 2025 15:19:41 +0530 Subject: [PATCH 3/3] added early_dump_pci_device() through the acpiphp path --- drivers/pci/access.c | 24 ++++++++++++++++++++++-- drivers/pci/hotplug/acpiphp_glue.c | 15 ++++++++++++++- drivers/pci/probe.c | 2 +- include/linux/pci.h | 2 ++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 99d47d84f..6aa1d68bc 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -52,10 +52,12 @@ int noinline pci_bus_read_config_##size \ pci_unlock_config(flags); \ \ /* Log all reads for device 01:00.0 */ \ + /* if (bus->number == 1 && PCI_SLOT(devfn) == 0 && PCI_FUNC(devfn) == 0) { \ - pr_info("PCI READ: res=%d, bus=%02x dev=%02x func=%x pos=0x%02x len=%d data=0x%x\n", \ + pr_info("KERNEL PCI READ: res=%d, bus=%02x dev=%02x func=%x pos=0x%02x len=%d data=0x%x\n", \ res, bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), pos, len, data); \ } \ + */ \ return res; \ } @@ -75,10 +77,12 @@ int noinline pci_bus_write_config_##size \ pci_unlock_config(flags); \ \ /* Log all writes for device 01:00.0 */ \ + /* if (bus->number == 1 && PCI_SLOT(devfn) == 0 && PCI_FUNC(devfn) == 0) { \ - pr_info("PCI WRITE: res=%d, bus=%02x dev=%02x func=%x pos=0x%02x len=%d value=0x%x\n", \ + pr_info("KERNEL PCI WRITE: res=%d, bus=%02x dev=%02x func=%x pos=0x%02x len=%d value=0x%x\n", \ res, bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), pos, len, value); \ } \ + */ \ return res; \ } @@ -257,6 +261,14 @@ int pci_user_read_config_##size \ else \ *val = (type)data; \ \ + /* Log all user-space reads for device 01:00.0 */ \ + if (dev->bus->number == 1 && PCI_SLOT(dev->devfn) == 0 && \ + PCI_FUNC(dev->devfn) == 0) { \ + pr_info("USER PCI READ: ret=%d, bus=%02x dev=%02x func=%x pos=0x%02x len=%d data=0x%x\n", \ + ret, dev->bus->number, PCI_SLOT(dev->devfn), \ + PCI_FUNC(dev->devfn), pos, sizeof(type), data); \ + } \ + \ return pcibios_err_to_errno(ret); \ } \ EXPORT_SYMBOL_GPL(pci_user_read_config_##size); @@ -278,6 +290,14 @@ int pci_user_write_config_##size \ pos, sizeof(type), val); \ raw_spin_unlock_irq(&pci_lock); \ \ + /* Log all user-space writes for device 01:00.0 */ \ + if (dev->bus->number == 1 && PCI_SLOT(dev->devfn) == 0 && \ + PCI_FUNC(dev->devfn) == 0) { \ + pr_info("USER PCI WRITE: ret=%d, bus=%02x dev=%02x func=%x pos=0x%02x len=%d value=0x%x\n", \ + ret, dev->bus->number, PCI_SLOT(dev->devfn), \ + PCI_FUNC(dev->devfn), pos, sizeof(type), val); \ + } \ + \ return pcibios_err_to_errno(ret); \ } \ EXPORT_SYMBOL_GPL(pci_user_write_config_##size); diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index b6a57f101..e918f6963 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -721,17 +721,26 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge) if (PCI_SLOT(dev->devfn) == slot->device) trim_stale_devices(dev); + acpi_handle_debug(handle, "calling early_dump_pci_device() before enable_slot() in %s()\n", __func__); + early_dump_pci_device(bridge->pci_dev); /* configure all functions */ acpi_handle_debug(handle, "Enabling slot in %s()\n", __func__); enable_slot(slot, true); + acpi_handle_debug(handle, "calling early_dump_pci_device() after enable_slot() in %s()\n", __func__); + early_dump_pci_device(bridge->pci_dev); } else { acpi_handle_debug(handle, "Slot has an invalid device status, disabling in %s()\n", __func__); disable_slot(slot); + acpi_handle_debug(handle, "calling early_dump_pci_device() after disable_slot() in %s()\n", __func__); + early_dump_pci_device(bridge->pci_dev); } } - if (bridge->pci_dev) + if (bridge->pci_dev) { pm_runtime_put(&bridge->pci_dev->dev); + acpi_handle_debug(handle, "calling early_dump_pci_device() after pm_runtime_put() in %s()\n", __func__); + early_dump_pci_device(bridge->pci_dev); + } } /* @@ -845,8 +854,12 @@ static void hotplug_event(u32 type, struct acpiphp_context *context) pci_unlock_rescan_remove(); if (bridge) { + acpi_handle_debug(handle, "calling early_dump_pci_device() before put_bridge() in %s()\n", __func__); + early_dump_pci_device(bridge->pci_dev); acpi_handle_debug(handle, "Releasing bridge in %s()\n", __func__); put_bridge(bridge); + acpi_handle_debug(handle, "calling early_dump_pci_device() after put_bridge() in %s()\n", __func__); + early_dump_pci_device(bridge->pci_dev); } } diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 2e81ab0f5..a483d7c7a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1852,7 +1852,7 @@ static int pci_intx_mask_broken(struct pci_dev *dev) return 0; } -static void early_dump_pci_device(struct pci_dev *pdev) +void early_dump_pci_device(struct pci_dev *pdev) { u32 value[256 / 4]; int i; diff --git a/include/linux/pci.h b/include/linux/pci.h index db9b47ce3..de4ace714 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2712,4 +2712,6 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type); WARN_ONCE(condition, "%s %s: " fmt, \ dev_driver_string(&(pdev)->dev), pci_name(pdev), ##arg) +void early_dump_pci_device(struct pci_dev *pdev); + #endif /* LINUX_PCI_H */ -- 2.25.1