Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'pci/misc'

- Fix whitespace issues (Li Jun)

- Fix pci_acpi_preserve_config() memory leak (Nirmoy Das)

- Add sysfs 'serial_number' file to expose the Device Serial Number
(Matthew Wood)

* pci/misc:
PCI/sysfs: Expose PCI device serial number
PCI/ACPI: Fix pci_acpi_preserve_config() memory leak

+34 -2
+9
Documentation/ABI/testing/sysfs-bus-pci
··· 612 612 613 613 # ls doe_features 614 614 0001:01 0001:02 doe_discovery 615 + 616 + What: /sys/bus/pci/devices/.../serial_number 617 + Date: December 2025 618 + Contact: Matthew Wood <thepacketgeek@gmail.com> 619 + Description: 620 + This is visible only for PCI devices that support the serial 621 + number extended capability. The file is read only and due to 622 + the possible sensitivity of accessible serial numbers, admin 623 + only.
+4 -2
drivers/pci/pci-acpi.c
··· 122 122 123 123 bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge) 124 124 { 125 + bool ret = false; 126 + 125 127 if (ACPI_HANDLE(&host_bridge->dev)) { 126 128 union acpi_object *obj; 127 129 ··· 137 135 1, DSM_PCI_PRESERVE_BOOT_CONFIG, 138 136 NULL, ACPI_TYPE_INTEGER); 139 137 if (obj && obj->integer.value == 0) 140 - return true; 138 + ret = true; 141 139 ACPI_FREE(obj); 142 140 } 143 141 144 - return false; 142 + return ret; 145 143 } 146 144 147 145 /* _HPX PCI Setting Record (Type 0); same as _HPP */
+21
drivers/pci/pci-sysfs.c
··· 30 30 #include <linux/msi.h> 31 31 #include <linux/of.h> 32 32 #include <linux/aperture.h> 33 + #include <linux/unaligned.h> 33 34 #include "pci.h" 34 35 35 36 #ifndef ARCH_PCI_DEV_GROUPS ··· 719 718 IORESOURCE_ROM_SHADOW)); 720 719 } 721 720 static DEVICE_ATTR_RO(boot_vga); 721 + 722 + static ssize_t serial_number_show(struct device *dev, 723 + struct device_attribute *attr, char *buf) 724 + { 725 + struct pci_dev *pci_dev = to_pci_dev(dev); 726 + u64 dsn; 727 + u8 bytes[8]; 728 + 729 + dsn = pci_get_dsn(pci_dev); 730 + if (!dsn) 731 + return -EIO; 732 + 733 + put_unaligned_be64(dsn, bytes); 734 + return sysfs_emit(buf, "%8phD\n", bytes); 735 + } 736 + static DEVICE_ATTR_ADMIN_RO(serial_number); 722 737 723 738 static ssize_t pci_read_config(struct file *filp, struct kobject *kobj, 724 739 const struct bin_attribute *bin_attr, char *buf, ··· 1746 1729 1747 1730 static struct attribute *pci_dev_dev_attrs[] = { 1748 1731 &dev_attr_boot_vga.attr, 1732 + &dev_attr_serial_number.attr, 1749 1733 NULL, 1750 1734 }; 1751 1735 ··· 1757 1739 struct pci_dev *pdev = to_pci_dev(dev); 1758 1740 1759 1741 if (a == &dev_attr_boot_vga.attr && pci_is_vga(pdev)) 1742 + return a->mode; 1743 + 1744 + if (a == &dev_attr_serial_number.attr && pci_get_dsn(pdev)) 1760 1745 return a->mode; 1761 1746 1762 1747 return 0;