Bug 282479 - LinuxKPI: drm-kmod 5.10-lts doesn't build on main after 5c92f84bb607 lockdep.h changes
Summary: LinuxKPI: drm-kmod 5.10-lts doesn't build on main after 5c92f84bb607 lockdep....
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Bjoern A. Zeeb
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-01 20:21 UTC by Evgenii Khramtsov
Modified: 2024-11-19 00:40 UTC (History)
2 users (show)

See Also:
bz: mfc-stable14+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Evgenii Khramtsov 2024-11-01 20:21:49 UTC
drm-kmod 5.10-lts branch on -CURRENT:

[...]
--- intel_context_param.o ---
In file included from /tmp/drm-kmod/drivers/gpu/drm/i915/gt/intel_context_param.c:6:
In file included from /tmp/drm-kmod/drivers/gpu/drm/i915/i915_active.h:10:
/usr/src/sys/compat/linuxkpi/common/include/linux/lockdep.h:86:27: error: expected ')'
   86 | lockdep_is_held(void *__m __diagused)
      |                           ^
/usr/src/sys/compat/linuxkpi/common/include/linux/lockdep.h:86:16: note: to match this '('
   86 | lockdep_is_held(void *__m __diagused)
      |                ^
--- intel_engine_heartbeat.o ---
[...]

I've built drm-kmod {5.10,5.15,6.1}-lts and master, GENERIC, GENERIC-NODEBUG kernels with:

diff --git a/sys/compat/linuxkpi/common/include/linux/lockdep.h b/sys/compat/linuxkpi/common/include/linux/lockdep.h
index 70a4e45867f..85878d4100c 100644
--- a/sys/compat/linuxkpi/common/include/linux/lockdep.h
+++ b/sys/compat/linuxkpi/common/include/linux/lockdep.h
@@ -83,7 +83,7 @@ struct pin_cookie {
 #endif
 
 static __inline bool
-lockdep_is_held(void *__m __diagused)
+lockdep_is_held(void *__m)
 {
 #ifdef INVARIANTS
        struct lock_object *__lock;
Comment 1 Evgenii Khramtsov 2024-11-01 20:22:10 UTC
__diagused was added to lockdep_is_held() parameters in base 5c92f84bb607, CC bz@
Comment 2 Evgenii Khramtsov 2024-11-01 20:22:28 UTC
__diagused was added to lockdep_is_held() parameters after base 5c92f84bb607
Comment 3 Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-11-01 21:59:21 UTC
(In reply to Evgenii Khramtsov from comment #2)

Sorry but 5.10 is not for current.  Assuming amd64 please use 6.1-lts or simply ports they'll do the right thing and 6.1-lts compiles (and wulf tried master he said; see review of the commit).

Also if you have no DEBUG kernel (or no INVARIANTS) *__m may not be used in a function but only declared, which leads to an error.  Memory serving me right this can happen in iwlwifi.

There were other compile-time fixes for drm-kmod committed a few days ago.

It is not clear where your sources are from and whether you are building the modules with the same options as your kernel or with the kernel (given your sources seem to be in /tmp).

Please provide better information on how to reproduce this.
Comment 4 Evgenii Khramtsov 2024-11-01 23:13:58 UTC
(In reply to Bjoern A. Zeeb from comment #3)

> Also if you have no DEBUG kernel (or no INVARIANTS) *__m may not be used in a function but only declared, which leads to an error.  Memory serving me right this can happen in iwlwifi.

Comment #1 says that -CURRENT with both GENERIC and GENERIC-NODEBUG kernels (that include iwlwifi) build fine after removing the __diagused macro (which expands to the __unused attribute) from the parameter list. I didn't investigate further.

> It is not clear where your sources are from and whether you are building the modules with the same options as your kernel or with the kernel (given your sources seem to be in /tmp).

Comment #1 says -CURRENT and drm-kmod 5.10-lts branch:

base 8d6feaaaa26f (/usr/src) and https://github.com/freebsd/drm-kmod/commit/17498c322eea (/tmp/drm-kmod)

cd /tmp/drm-kmod && make -j$(nproc)

> There were other compile-time fixes for drm-kmod committed a few days ago.

"path does not exist" types of warning fixes do not apply to 5.10-lts

> Sorry but 5.10 is not for current.  Assuming amd64 please use 6.1-lts or simply ports they'll do the right thing and 6.1-lts compiles (and wulf tried master he said; see review of the commit).

drm-kmod >=5.11 with the new ttmv3 allocator is unusable on amdgpu as it lacks bus_dma(9) for DMA allocations, and instead requests 4 MB phys contig allocations without a scatter gather which become a burden after enough free phys mem fragmentation (prolonged uptime or poudriere building) see https://github.com/freebsd/drm-kmod/issues/302#issuecomment-2318230263 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277476#c0

"The right thing" is subjective, please don't give unsolicited advice.
Comment 5 Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-11-02 00:02:16 UTC
(In reply to Evgenii Khramtsov from comment #4)

I would highly assume that this has nothing to do with the clang19 import but is a simple #include problem which only surfaces in 5.10.

I think the fix likely (which we should probably do anyway) is to
#include <sys/systm.h> in sys/compat/linuxkpi/common/include/linux/lockdep.h .

I am running a tinderbox build with drm-kmod checked out in LOCAL_MODULES_DIR using the 5.10-lts branch to see if it breaks and if the above fixes it.  That way drm-kmod is built along with the kernel and the same build and kernel options.
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-11-02 01:26:25 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9b2705121ba230bf71a1509cc928f0481dfbf31c

commit 9b2705121ba230bf71a1509cc928f0481dfbf31c
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-11-02 01:21:52 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-11-02 01:24:42 +0000

    LinuxKPI:  lockdep fix #includes

    Add sys/sytm.h for __diagused which unbreaks compilation of
    drm-kmod 5.10-lts on main.

    Sponsored by:   The FreeBSD Foundation
    Reported by:    Evgenii Khramtsov
    PR:             282479
    Fixes:          5c92f84bb607
    MFC after:      3 days

 sys/compat/linuxkpi/common/include/linux/lockdep.h | 1 +
 1 file changed, 1 insertion(+)
Comment 7 Evgenii Khramtsov 2024-11-02 07:57:42 UTC
I confirm, 5.10-lts builds fine after base 9b2705121ba2

(In reply to Bjoern A. Zeeb from comment #5)

> I would highly assume that this has nothing to do with the clang19 import but is a simple #include problem which only surfaces in 5.10.

You are likely right. I didn't bisect src with git this time but instead did a less precise bisect with pkgbase. 5c92f84bb607~...f3dbef108212 distance is small and I wrongly attributed this to subtle Clang lexer behavior change. I should have put more effort into reporting this PR by doing a git bisect.

Thank you for the fix.

> LOCAL_MODULES_DIR
> [...] That way drm-kmod is built along with the kernel and the same build and kernel options. [...]

Thank you for mentioning this as well.

I think this PR should be closed after MFC to stable/14? No preference here.
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-11-14 01:54:28 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=06733ceca677b2d8ea2ae738bbb624d510fc9df8

commit 06733ceca677b2d8ea2ae738bbb624d510fc9df8
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-11-02 01:21:52 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-11-14 01:52:01 +0000

    LinuxKPI:  lockdep fix #includes

    Add sys/sytm.h for __diagused which unbreaks compilation of
    drm-kmod 5.10-lts on main.

    Sponsored by:   The FreeBSD Foundation
    Reported by:    Evgenii Khramtsov
    PR:             282479
    Fixes:          5c92f84bb607

    (cherry picked from commit 9b2705121ba230bf71a1509cc928f0481dfbf31c)

 sys/compat/linuxkpi/common/include/linux/lockdep.h | 1 +
 1 file changed, 1 insertion(+)
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-11-19 00:39:02 UTC
A commit in branch releng/14.2 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=de5496958c8651fd62e9d65722ad36d322a59574

commit de5496958c8651fd62e9d65722ad36d322a59574
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-11-02 01:21:52 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-11-19 00:36:04 +0000

    LinuxKPI:  lockdep fix #includes

    Add sys/sytm.h for __diagused which unbreaks compilation of
    drm-kmod 5.10-lts on main.

    Sponsored by:   The FreeBSD Foundation
    Reported by:    Evgenii Khramtsov
    PR:             282479
    Fixes:          5c92f84bb607
    Approved by:    re (cperciva)

    (cherry picked from commit 9b2705121ba230bf71a1509cc928f0481dfbf31c)
    (cherry picked from commit 06733ceca677b2d8ea2ae738bbb624d510fc9df8)

 sys/compat/linuxkpi/common/include/linux/lockdep.h | 1 +
 1 file changed, 1 insertion(+)