Page MenuHomeFreeBSD

linuxkpi: Add dma-buf subsystem
Needs ReviewPublic

Authored by manu on Aug 21 2022, 7:26 PM.
Referenced Files
Unknown Object (File)
Thu, Aug 13, 12:33 PM
Unknown Object (File)
Thu, Aug 13, 12:33 PM
Unknown Object (File)
Thu, Aug 13, 12:33 PM
Unknown Object (File)
Thu, Aug 13, 12:33 PM
Unknown Object (File)
Jul 5 2026, 2:34 PM
Unknown Object (File)
Jun 26 2026, 11:27 PM
Unknown Object (File)
Jun 26 2026, 5:21 AM
Unknown Object (File)
Jun 25 2026, 9:34 AM

Details

Reviewers
None
Group Reviewers
linuxkpi
Summary

dma-buf provides a way to share buffer between device drivers, subsystems
and for synchronizing asynchronous hardware access.
This is mostly used for GPU and Video related drivers (like Video input
devices).
Fences are used to signal when the device is finished with the buffer and
Reservation are used to share or not fences.

dma-resv.* are taken directly from linux and so all function aren't
prefixed with lkpi_/linux_ not style(9) have been applied to them so
it will be easier to sync.

Sponsored by: Beckhoff Automation GmbH & Co. KG

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

manu requested review of this revision.Aug 21 2022, 7:26 PM
bz added inline comments.
sys/compat/linuxkpi/common/include/linux/dma-buf.h
25

Can you remove the empty lines where the $FreeBSD$ was deleted? (all files)

28

I think @wulf normalized them all to _LINUXKPI_ , can we do that for all public files too?

sys/compat/linuxkpi/common/src/linux_dma-fence-array.c
33

this requires malloc.h (here and in some other files)

sys/compat/linuxkpi/common/src/linux_dma-fence.c
27

probably param.h

sys/compat/linuxkpi/common/src/linux_dma-resv.c
2

Wow, that's a new, a Linux file in src :)

hselasky added inline comments.
sys/compat/linuxkpi/common/include/linux/dma-fence.h
151

Should be:

do { } while (0)
sys/compat/linuxkpi/common/include/linux/dma-resv.h
84

Should probably remove all ifdef FreeBSD's

sys/compat/linuxkpi/common/src/linux_dma-buf.c
90

Move this definition where it belongs!

152

Or if offset is not page aligned ?

191

Poll doesn't return EXXXX error codes?? I think POLLNVAL is the right here. Please check existing kernel code.

257

I think you can remove these two lines.

260

Double newline.

sys/compat/linuxkpi/common/src/linux_dma-fence.c
366

count is uint32_t so should "i" be.

537

Technically this should be:

(int64_t)(f1 - f2) > 0

Else there is an assumption about 64-bit not wrapping around!

sys/compat/linuxkpi/common/src/linux_dma-resv.c
146

Ditto.

175

Ditto.

manu marked 8 inline comments as done.Aug 22 2022, 7:53 AM
manu added inline comments.
sys/compat/linuxkpi/common/include/linux/dma-resv.h
84

No, this helps syncing the file as it's imported from Linux.

Include sys/poll.h for POLLNVAL