Skip to content

Commit

Permalink
LinuxKPI: return an address string in pci_name()
Browse files Browse the repository at this point in the history
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:	freebsd/drm-kmod#134
Sponsored by:	https://www.patreon.com/valpackett
Reviewed by:	bz, hselasky, manu (earlier)
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D34248

(cherry picked from commit 393b0ba)
  • Loading branch information
valpackett authored and Bjoern A. Zeeb committed Feb 17, 2023
1 parent 7b65e6f commit 30960c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sys/compat/linuxkpi/common/include/linux/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,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 */
Expand Down Expand Up @@ -475,8 +476,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 *
Expand Down
4 changes: 4 additions & 0 deletions sys/compat/linuxkpi/common/src/linux_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 30960c5

Please sign in to comment.