Page MenuHomeFreeBSD
Paste P538

D34248 format-patch
ActivePublic

Authored by val_packett.cool on Feb 11 2022, 3:46 PM.
Tags
None
Referenced Files
F55920158: D34248 format-patch
Feb 5 2023, 9:01 PM
F36761337: D34248 format-patch
Feb 11 2022, 3:46 PM
Subscribers
None
From cf0117f6fa269a0ee4c2fdee150bd4cd234edacf Mon Sep 17 00:00:00 2001
From: Val Packett <val@packett.cool>
Date: Fri, 11 Feb 2022 17:14:39 +0300
Subject: [PATCH] LinuxKPI: return an address string in pci_name
amdgpu's virtual display feature uses pci_name to match a module parameter string,
and the documentation shows an example of '0000:26:00.0' for the name.
In our case the name was just 'drmn', which is silly and not actually unique
across devices. Let's generate the expected string.
---
sys/compat/linuxkpi/common/include/linux/pci.h | 4 ++--
sys/compat/linuxkpi/common/src/linux_pci.c | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index 5dfdfa2e86c..94db1d84a37 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -277,6 +277,7 @@ struct pci_dev {
size_t romlen;
TAILQ_HEAD(, pci_mmio_region) mmio;
+ char *path_name;
};
/* We need some meta-struct to keep track of these for devres. */
@@ -378,8 +379,7 @@ pci_resource_flags(struct pci_dev *pdev, int bar)
static inline const char *
pci_name(struct pci_dev *d)
{
-
- return device_get_desc(d->dev.bsddev);
+ return d->path_name;
}
static inline void *
diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
index c388da87ac1..dc90f281459 100644
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -277,6 +277,8 @@ lkpifill_pci_dev(device_t dev, struct pci_dev *pdev)
pdev->subsystem_device = pci_get_subdevice(dev);
pdev->class = pci_get_class(dev);
pdev->revision = pci_get_revid(dev);
+ pdev->path_name = kasprintf(GFP_KERNEL, "%04d:%02d:%02d.%d",
+ pci_get_domain(dev), pci_get_bus(dev), pci_get_slot(dev), pci_get_function(dev));
pdev->bus = malloc(sizeof(*pdev->bus), M_DEVBUF, M_WAITOK | M_ZERO);
pdev->bus->self = pdev;
pdev->bus->number = pci_get_bus(dev);
@@ -302,6 +304,7 @@ lkpinew_pci_dev_release(struct device *dev)
if (pdev->root != NULL)
pci_dev_put(pdev->root);
free(pdev->bus, M_DEVBUF);
+ kfree(pdev->path_name);
free(pdev, M_DEVBUF);
}
--
2.30.0