Page MenuHomeFreeBSD

Add LinuxKPI support for attaching DRM drivers
ClosedPublic

Authored by markj on Aug 9 2017, 5:24 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 6:49 PM
Unknown Object (File)
Wed, Apr 17, 6:13 PM
Unknown Object (File)
Wed, Apr 17, 6:05 PM
Unknown Object (File)
Wed, Apr 17, 12:31 PM
Unknown Object (File)
Wed, Apr 17, 12:27 PM
Unknown Object (File)
Wed, Apr 17, 12:21 PM
Unknown Object (File)
Wed, Apr 17, 12:14 PM
Unknown Object (File)
Wed, Apr 17, 11:02 AM
Subscribers

Details

Summary

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.

Test Plan

Tested with i915 and amdgpu.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added a reviewer: hselasky.
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".

markj marked an inline comment as done.
  • Address review comments.
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.

  • Handle devclass_create() failure.
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.

sys/compat/linuxkpi/common/src/linux_pci.c
303 ↗(On Diff #31851)

This static drm_devclass seems redundant. devclass_add_driver() always assigns the devclass and never reads this one! Can you remove and test?

267 ↗(On Diff #31803)

OK. Either way is fine.

  • 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.

This revision is now accepted and ready to land.Aug 10 2017, 6:40 AM
This revision was automatically updated to reflect the committed changes.