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

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 10989
Build 11376: arc lint + arc unit

Event Timeline

markj added a reviewer: hselasky.
sys/compat/linuxkpi/common/src/linux_pci.c
137

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);
}
269

Is "linux_pci_register_driver_sub()" a better name than "_linux_pci_register_driver()" ?

293

You should add a NULL check here. "pci" might be missing!

304

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
269

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.

304

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
304

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
269

OK. Either way is fine.

303

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

  • Get rid of bogus devclass.
sys/compat/linuxkpi/common/src/linux_pci.c
303

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.