<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/compat/linuxkpi/common/include/linux, branch main</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>linuxkpi: Handle bin attributes in sysfs attribute groups</title>
<updated>2026-04-01T15:10:12+00:00</updated>
<author>
<name>Jean-Sébastien Pédron</name>
<email>dumbbell@FreeBSD.org</email>
</author>
<published>2026-02-08T10:11:39+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=5bb0f63020669bd3675c651ba7745fc4356edc1a'/>
<id>5bb0f63020669bd3675c651ba7745fc4356edc1a</id>
<content type='text'>
For instance, this is used by DRM drivers to declare the EDID property
of an GPU output connector:

    sysctl -b sys.device.drmn1.card0.card0-DP-1.edid | edid-decode

    ...
    Block 0, Base EDID:
      EDID Structure Version &amp; Revision: 1.4
      Vendor &amp; Product Identification:
        Manufacturer: SAM
        Model: 29814
        Serial Number: 810635354 (0x3051505a)
        Made in: week 15 of 2025
    ...

Reviewed by:	bz, emaste, wulf
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55176
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For instance, this is used by DRM drivers to declare the EDID property
of an GPU output connector:

    sysctl -b sys.device.drmn1.card0.card0-DP-1.edid | edid-decode

    ...
    Block 0, Base EDID:
      EDID Structure Version &amp; Revision: 1.4
      Vendor &amp; Product Identification:
        Manufacturer: SAM
        Model: 29814
        Serial Number: 810635354 (0x3051505a)
        Made in: week 15 of 2025
    ...

Reviewed by:	bz, emaste, wulf
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55176
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: add supporting #includes</title>
<updated>2026-03-21T21:16:43+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-03-19T20:29:29+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=1d18872c2519d7ca726ddc49735180ab1d8916e0'/>
<id>1d18872c2519d7ca726ddc49735180ab1d8916e0</id>
<content type='text'>
Compiling drm-kmod on !X86 does not include asm/smp.h which includes
preempt.h on FreeBSD.  In order to compile drm-kmod on other
architectures add the secondary #includes for preempt.h to
spinlock.h and hardirq.h (which now also gets included from highmem.h)
to connect the #include chain.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
PR:		279864
Reviewed by:	jhibbits, emaste
Differential Revision: https://reviews.freebsd.org/D55974
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Compiling drm-kmod on !X86 does not include asm/smp.h which includes
preempt.h on FreeBSD.  In order to compile drm-kmod on other
architectures add the secondary #includes for preempt.h to
spinlock.h and hardirq.h (which now also gets included from highmem.h)
to connect the #include chain.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
PR:		279864
Reviewed by:	jhibbits, emaste
Differential Revision: https://reviews.freebsd.org/D55974
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: Fix simple_read_from_buffer for zero-size and off-the-end reads</title>
<updated>2026-03-17T19:49:01+00:00</updated>
<author>
<name>John Baldwin</name>
<email>jhb@FreeBSD.org</email>
</author>
<published>2026-03-17T19:49:01+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=2353fa1aca553883141a7b5d0aa54312a4610412'/>
<id>2353fa1aca553883141a7b5d0aa54312a4610412</id>
<content type='text'>
I noticed that the buf_size &lt; 0 check can never be true (it's a
size_t) and decided to check for this condition by an alternate
expression, and I also noticed that a read_size of 0 would incorrectly
return -EFAULT.  Instead, return success for both of these cases as
reading beyond the EOF of a normal file also returns EOF, not EINVAL.

Reviewed by:	bz
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D55845
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I noticed that the buf_size &lt; 0 check can never be true (it's a
size_t) and decided to check for this condition by an alternate
expression, and I also noticed that a read_size of 0 would incorrectly
return -EFAULT.  Instead, return success for both of these cases as
reading beyond the EOF of a normal file also returns EOF, not EINVAL.

Reviewed by:	bz
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D55845
</pre>
</div>
</content>
</entry>
<entry>
<title>lindebugfs: Pass user buffer pointers to the read/write file operations</title>
<updated>2026-03-17T19:45:34+00:00</updated>
<author>
<name>John Baldwin</name>
<email>jhb@FreeBSD.org</email>
</author>
<published>2026-03-17T19:45:34+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=2cf15144daf7ec44cdcd9bf3ef007939b79c361e'/>
<id>2cf15144daf7ec44cdcd9bf3ef007939b79c361e</id>
<content type='text'>
The Linux file_operations API expects the read and write operations
to take a single user buffer pointer (along with the length and the
file offset as an in/out parameter).

However, the debugfs_fill function was violating this part of the
contract as it was passing down kernel pointers instead.  An earlier
commit (5668c22a13c6befa9b8486387d38457c40ce7af4) hacked around this
by modifying simple_read_from_buffer() to treat its user pointer
argument as a kernel pointer instead.  However, other commits keep
tripping over this same API mismatch
(e.g. 78e25e65bf381303c8bdac9a713ab7b26a854b8c passes a kernel pointer
to copy_from_user in fops_str_write).

Instead, change debugfs_fill to use the "raw" pseudofs mode where the
uio is passed down to directly to the fill callback rather than an
sbuf.  debufs_fill now iterates over the iovec in the uio similar to
the implementation of uiomove invoking the read or write operation on
each user pointer.

This also fixes a tiny bug where the initial file offset from
uio_offset was ignored.  Instead, the operations were always invoked
with a file offset of 0.

As part of this, revert the the changes to simple_read_from_buffer()
from commit 5668c22a13c6befa9b8486387d38457c40ce7af4.

Also as part of this, the simple_attr_read/write methods and seq_read
now also need to accept and handle user pointers (also matching the
API in Linux).

For simple_attr_write*(), copy the user buffer into a kernel buffer
before parsing.  Also, do not permit writes at an offset as it's
unclear what the semantics for those would even be (perhaps you would
write out the formatted value into a buffer first and then allow the
copy_from_user to overwrite/extend that buffer and then re-parse the
integer value?).  The old handling of *ppos for writes was definitely
wrong before and only worked for an offset of 0 anyway.

Reviewed by:	bz
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D55833
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The Linux file_operations API expects the read and write operations
to take a single user buffer pointer (along with the length and the
file offset as an in/out parameter).

However, the debugfs_fill function was violating this part of the
contract as it was passing down kernel pointers instead.  An earlier
commit (5668c22a13c6befa9b8486387d38457c40ce7af4) hacked around this
by modifying simple_read_from_buffer() to treat its user pointer
argument as a kernel pointer instead.  However, other commits keep
tripping over this same API mismatch
(e.g. 78e25e65bf381303c8bdac9a713ab7b26a854b8c passes a kernel pointer
to copy_from_user in fops_str_write).

Instead, change debugfs_fill to use the "raw" pseudofs mode where the
uio is passed down to directly to the fill callback rather than an
sbuf.  debufs_fill now iterates over the iovec in the uio similar to
the implementation of uiomove invoking the read or write operation on
each user pointer.

This also fixes a tiny bug where the initial file offset from
uio_offset was ignored.  Instead, the operations were always invoked
with a file offset of 0.

As part of this, revert the the changes to simple_read_from_buffer()
from commit 5668c22a13c6befa9b8486387d38457c40ce7af4.

Also as part of this, the simple_attr_read/write methods and seq_read
now also need to accept and handle user pointers (also matching the
API in Linux).

For simple_attr_write*(), copy the user buffer into a kernel buffer
before parsing.  Also, do not permit writes at an offset as it's
unclear what the semantics for those would even be (perhaps you would
write out the formatted value into a buffer first and then allow the
copy_from_user to overwrite/extend that buffer and then re-parse the
integer value?).  The old handling of *ppos for writes was definitely
wrong before and only worked for an offset of 0 anyway.

Reviewed by:	bz
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D55833
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: pass attrs in more places in dma-mapping.h</title>
<updated>2026-03-04T08:23:22+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-02-19T23:17:47+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=31c3cba807839a1a16e6f4bca91d530d9342b61a'/>
<id>31c3cba807839a1a16e6f4bca91d530d9342b61a</id>
<content type='text'>
Various macros (dma_map_sg_attrs, dma_unmap_sg_attrs,
dma_map_single_attrs, and dma_unmap_single_attrs) currently supress
passing on the attrs argument.  Their implementation (even though at
times still marked the argument __unused; we remove that) have long
gained support for handling the argument.
With ofed fixed (5edf24aac1d09), pass the argument through so that
other drivers using these functions may hopefully work just a bit
better as well.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D55391
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Various macros (dma_map_sg_attrs, dma_unmap_sg_attrs,
dma_map_single_attrs, and dma_unmap_single_attrs) currently supress
passing on the attrs argument.  Their implementation (even though at
times still marked the argument __unused; we remove that) have long
gained support for handling the argument.
With ofed fixed (5edf24aac1d09), pass the argument through so that
other drivers using these functions may hopefully work just a bit
better as well.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D55391
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: avoid -Werror=unused-value in sort() from BUILD_BUG_ON_ZERO()</title>
<updated>2026-03-03T19:19:32+00:00</updated>
<author>
<name>Siva Mahadevan</name>
<email>siva@FreeBSD.org</email>
</author>
<published>2026-03-03T19:09:35+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=f26cb4757eb74ceace39144933ae198ebf1b4f28'/>
<id>f26cb4757eb74ceace39144933ae198ebf1b4f28</id>
<content type='text'>
The BUILD_BUG_ON_ZERO() macro returns an (int)0 if it does not fail
at build time. LinuxKPI sort() has it as a guard for an unsupported
argument but ignores the return value.

This leads to gcc complaining:

/usr/src/sys/compat/linuxkpi/common/include/linux/build_bug.h:60:33: error: statement with no effect [-Werror=unused-value]
   60 | #define BUILD_BUG_ON_ZERO(x)    ((int)sizeof(struct { int:-((x) != 0); }))
      |                                 ^
/usr/src/sys/compat/linuxkpi/common/include/linux/sort.h:37:9: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
   37 |         BUILD_BUG_ON_ZERO(swap);                        \
      |         ^~~~~~~~~~~~~~~~~
/usr/src/sys/contrib/dev/rtw89/core.c:2575:9: note: in expansion of macro 'sort'
 2575 |         sort(drift, RTW89_BCN_TRACK_STAT_NR, sizeof(*drift), cmp_u16, NULL);

Change to BUILD_BUG_ON() for the statement version.

Reported by:	CI
Co-authored-by:	bz
Approved by:	emaste (mentor)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D55634
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The BUILD_BUG_ON_ZERO() macro returns an (int)0 if it does not fail
at build time. LinuxKPI sort() has it as a guard for an unsupported
argument but ignores the return value.

This leads to gcc complaining:

/usr/src/sys/compat/linuxkpi/common/include/linux/build_bug.h:60:33: error: statement with no effect [-Werror=unused-value]
   60 | #define BUILD_BUG_ON_ZERO(x)    ((int)sizeof(struct { int:-((x) != 0); }))
      |                                 ^
/usr/src/sys/compat/linuxkpi/common/include/linux/sort.h:37:9: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
   37 |         BUILD_BUG_ON_ZERO(swap);                        \
      |         ^~~~~~~~~~~~~~~~~
/usr/src/sys/contrib/dev/rtw89/core.c:2575:9: note: in expansion of macro 'sort'
 2575 |         sort(drift, RTW89_BCN_TRACK_STAT_NR, sizeof(*drift), cmp_u16, NULL);

Change to BUILD_BUG_ON() for the statement version.

Reported by:	CI
Co-authored-by:	bz
Approved by:	emaste (mentor)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D55634
</pre>
</div>
</content>
</entry>
<entry>
<title>brcm80211: add LinuxKPI files and module Makefiles</title>
<updated>2026-02-10T21:36:29+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-02-10T21:33:09+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=902136e0fe112383ec64d2ef43a446063b5e6417'/>
<id>902136e0fe112383ec64d2ef43a446063b5e6417</id>
<content type='text'>
sys/compat/linuxkpi/common/include/linux/platform_data/brcmfmac.h
is based on
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
e5f0a698b34ed76002dc5cff3804a61c80233a7a ( tag: v6.17 ).

Currently only PCIe is made to compile.
It does load firmware (if needed, e.g., on arm64 with an alignment
issue fixed), and starts to come up.

To make it work there is a cfg80211 layer and netdevice integration
to do, so do not hold your breath just yet.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
sys/compat/linuxkpi/common/include/linux/platform_data/brcmfmac.h
is based on
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
e5f0a698b34ed76002dc5cff3804a61c80233a7a ( tag: v6.17 ).

Currently only PCIe is made to compile.
It does load firmware (if needed, e.g., on arm64 with an alignment
issue fixed), and starts to come up.

To make it work there is a cfg80211 layer and netdevice integration
to do, so do not hold your breath just yet.
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: add scoped_guard(), spinlock guard support</title>
<updated>2026-02-09T21:49:45+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-01-20T22:54:30+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=31393810a168b74cf13ace0e1d35dae6b4a12bf5'/>
<id>31393810a168b74cf13ace0e1d35dae6b4a12bf5</id>
<content type='text'>
The "cleanup.h" implementation got a bit more complicated.

For one we now use a macro to concatenate a prefix, the name, and a
suffix for variable and function declarations.  This was triggered
by the fact that the "guard_" prefix we used was confusing.  We now
use a generic "cleanup_" which is only encoded in the single place
rather than all over the file.

As already indicated by the comment the DEFINE_LOCK_GUARD_0()
macro got split up and a _1 version which also takes a type got
implemented and is used for a spinlock variant used by rtw89(4)
via the new scoped_guard() bits.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54808
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The "cleanup.h" implementation got a bit more complicated.

For one we now use a macro to concatenate a prefix, the name, and a
suffix for variable and function declarations.  This was triggered
by the fact that the "guard_" prefix we used was confusing.  We now
use a generic "cleanup_" which is only encoded in the single place
rather than all over the file.

As already indicated by the comment the DEFINE_LOCK_GUARD_0()
macro got split up and a _1 version which also takes a type got
implemented and is used for a spinlock variant used by rtw89(4)
via the new scoped_guard() bits.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54808
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: mod_devicetable, add comment about [future] LinuxKPI USB</title>
<updated>2026-02-09T21:49:44+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-01-26T21:00:24+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=020ff5e29431f5b55f2e3876c0e4828205e17cd5'/>
<id>020ff5e29431f5b55f2e3876c0e4828205e17cd5</id>
<content type='text'>
USB structures are defined with the native USB implementation.
Just leave a comment why they are not here.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D54991
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
USB structures are defined with the native USB implementation.
Just leave a comment why they are not here.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D54991
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: move MODULE_DEVICE_TABLE from pci.h to module.h</title>
<updated>2026-02-09T21:49:44+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-01-26T20:31:24+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=1f4fbcf342f41fecc8dff4e0d9a1f9bdb1cdf784'/>
<id>1f4fbcf342f41fecc8dff4e0d9a1f9bdb1cdf784</id>
<content type='text'>
Move the MODULE_DEVICE_TABLE macro to module.h where it belongs
in preparation for different bus (e.g., USB, SDIO) support.
The various struct &lt;bus&gt;_device_id, if not elsewhere, should be
defined in mod_devicetable.h.

This is the next step after 2f5666c1727c.

No functional changes.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D54900
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move the MODULE_DEVICE_TABLE macro to module.h where it belongs
in preparation for different bus (e.g., USB, SDIO) support.
The various struct &lt;bus&gt;_device_id, if not elsewhere, should be
defined in mod_devicetable.h.

This is the next step after 2f5666c1727c.

No functional changes.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D54900
</pre>
</div>
</content>
</entry>
</feed>
