git: 368a398b9c3e - releng/13.2 - LinuxKPI: return an address string in pci_name()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Feb 2023 19:34:41 UTC
The branch releng/13.2 has been updated by bz:
URL: https://cgit.FreeBSD.org/src/commit/?id=368a398b9c3e01359d9997aaa3ccff6415129f74
commit 368a398b9c3e01359d9997aaa3ccff6415129f74
Author: Val Packett <val@packett.cool>
AuthorDate: 2023-02-06 21:50:13 +0000
Commit: Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-02-23 19:33:31 +0000
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 not actually unique across
devices.
The other consumers are wireless drivers, which will benefit from this
change.
Generate the expected string for pci_name() to return.
Related to: https://github.com/freebsd/drm-kmod/issues/134
Sponsored by: https://www.patreon.com/valpackett
Reviewed by: bz, hselasky, manu (earlier)
Approved by: re (cperciva)
Differential Revision: https://reviews.freebsd.org/D34248
(cherry picked from commit 393b0ba25f1a54dcc3f94244933c665f1c471d1a)
(cherry picked from commit 30960c51e646c51134fcb72e0adc881f36a41c38)
---
sys/compat/linuxkpi/common/include/linux/pci.h | 4 ++--
sys/compat/linuxkpi/common/src/linux_pci.c | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index 3d43595df047..e050cb5021cf 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -351,6 +351,7 @@ struct pci_dev {
bool msix_enabled;
uint8_t msi_cap;
struct msi_desc **msi_desc;
+ char *path_name;
};
/* XXX add kassert here on the mmio offset */
@@ -470,8 +471,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 a66627612778..3dbcf5cfbce0 100644
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -309,6 +309,9 @@ 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);
/*
* This should be the upstream bridge; pci_upstream_bridge()
@@ -352,6 +355,7 @@ lkpinew_pci_dev_release(struct device *dev)
free(pdev->msi_desc[i], M_DEVBUF);
free(pdev->msi_desc, M_DEVBUF);
}
+ kfree(pdev->path_name);
free(pdev, M_DEVBUF);
}