Page MenuHomeFreeBSD

LinuxKPI: Use macro for implementation of some dma_map_* functions
ClosedPublic

Authored by wulf on Jun 28 2021, 8:51 PM.

Details

Summary

This allows to remove unimplemented attrs parameter which type differs
between Linux kernel versions and to compile both drm-kmod and ofed
callers unmodified.
Also convert it to 'unsigned long' type to match modern Linuxes.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

wulf requested review of this revision.Jun 28 2021, 8:51 PM

Did you test-build:

make buildkernel WITH_OFED=YES ?

Did you test-build:

make buildkernel WITH_OFED=YES ?

Just tried, and it succeeded.

If I understand build process correctly, OFED builds even if WITH_OFED is not included. It goes through sys/modules hierarchy

The one thing which scares me is to use unsigned long for pointers, which I think is not a good idea (and a bad Linuxism).
Would uintptr_t work between 32/64bit archs?

All of the LinuxKPI builds on that sizeof(long) == sizeof(void *) --- yeah bad Linux :-)

We even have an compile time assert for that.

In D30932#696344, @bz wrote:

The one thing which scares me is to use unsigned long for pointers, which I think is not a good idea (and a bad Linuxism).
Would uintptr_t work between 32/64bit archs?

Linux does not use unsigned long for pointers here. Initially they stored attrs as array of unsigned longs and passed it by reference. But after attrs stabilized, it is appeared that they fit in one byte and array of unsigned longs was replaced with single unsigned long passed directly.

In D30932#696380, @wulf wrote:
In D30932#696344, @bz wrote:

The one thing which scares me is to use unsigned long for pointers, which I think is not a good idea (and a bad Linuxism).
Would uintptr_t work between 32/64bit archs?

Linux does not use unsigned long for pointers here. Initially they stored attrs as array of unsigned longs and passed it by reference. But after attrs stabilized, it is appeared that they fit in one byte and array of unsigned longs was replaced with single unsigned long passed directly.

Ok. Thanks for the explanation. I guess we can also mark some of them __unused but I am good.

Add __unused keyword to unused parameters

Just make sure a kernel build WITH_OFED=YES builds.

This revision is now accepted and ready to land.Jul 3 2021, 8:09 AM