The main difference is DRM drivers attach to a vgapci bus rather than a
pci bus. However, for now we need to override the vgapci ivars with the
grandparent's ivars in order for the rest of the LinuxKPI to work. This
is a hack, but it works fine for now.
Details
Tested with i915 and amdgpu.
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
sys/compat/linuxkpi/common/src/linux_pci.c | ||
---|---|---|
137 ↗ | (On Diff #31803) | Is this a more clear way to write the code? if (pdrv->isdrm) { dinfo = device_get_ivars(parent); device_set_ivars(dev, dinfo); } else { dinfo = device_get_ivars(dev); } |
267 ↗ | (On Diff #31803) | Is "linux_pci_register_driver_sub()" a better name than "_linux_pci_register_driver()" ? |
291 ↗ | (On Diff #31803) | You should add a NULL check here. "pci" might be missing! |
302 ↗ | (On Diff #31803) | Same here. Add a NULL check for systems without "vgapci". |
sys/compat/linuxkpi/common/src/linux_pci.c | ||
---|---|---|
267 ↗ | (On Diff #31803) | I don't feel strongly about this; the "_" prefix seems to be a relatively common way to give a name to an internal wrapper in FreeBSD. If you prefer "_sub" I'll change it. |
302 ↗ | (On Diff #31803) | Note that in this case, we create the vgapci devclass if it doesn't exist. In particular, it seems this function won't fail. |
sys/compat/linuxkpi/common/src/linux_pci.c | ||
---|---|---|
302 ↗ | (On Diff #31803) | Sorry, I skimmed too quickly. We can fail in at least the case where malloc() actually fails to allocate a devclass struct. |
- Get rid of bogus devclass.
sys/compat/linuxkpi/common/src/linux_pci.c | ||
---|---|---|
303 ↗ | (On Diff #31851) | Thanks, you're right. Works fine on i915. |
Looks good. Try to make the commit message a bit clearer:
DRM drivers need to attach to the vgapci bus rather than the PCI bus.
Make own PCI register driver for this purpose.
Further the DRM drivers require the vgapci device has the ivars of
the grandparent for the rest of the LinuxKPI PCI dependencies to
work correctly.