Skip to content

linuxkm: Fix spinlock initialization on Tegra kernels for __SPIN_LOCK…#9478

Merged
douzzer merged 1 commit intowolfSSL:masterfrom
sameehj:fix-tegra
Dec 2, 2025
Merged

linuxkm: Fix spinlock initialization on Tegra kernels for __SPIN_LOCK…#9478
douzzer merged 1 commit intowolfSSL:masterfrom
sameehj:fix-tegra

Conversation

@sameehj
Copy link
Copy Markdown
Contributor

@sameehj sameehj commented Nov 26, 2025

Description

linuxkm: Fix spinlock initialization on Tegra kernels for __SPIN_LOCK_UNLOCKED macro incompatibility

Tegra vendor kernels (L4T / NVIDIA Yocto BSP) fail to compile the wolfSSL Linux kernel module due to the use of the legacy assignment form of the spinlock initializer:

m->lock = __SPIN_LOCK_UNLOCKED(m);

On Tegra, __SPIN_LOCK_UNLOCKED() expands to a braced-struct initializer that is not valid as an assignment expression, causing:

error: expected expression before '{' token

This patch applies a Tegra-specific workaround by replacing the assignment with the stable kernel API:

spin_lock_init(&m->lock);

This is guarded behind CONFIG_ARCH_TEGRA so that non-Tegra platforms retain the current initialization behavior until further validation is completed.

This fix restores successful kernel module builds on NVIDIA Tegra-based Yocto images without modifying behavior on other architectures.

Testing

Compiled with tegra Kernel

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@sameehj sameehj requested a review from douzzer November 26, 2025 06:22
Comment thread linuxkm/linuxkm_wc_port.h Outdated
Copy link
Copy Markdown
Contributor

@douzzer douzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a couple more tweaks.

Comment thread linuxkm/linuxkm_wc_port.h Outdated
…_UNLOCKED macro incompatibility

Tegra vendor kernels (L4T / NVIDIA Yocto BSP) fail to compile the
wolfSSL Linux kernel module due to the use of the legacy assignment form
of the spinlock initializer:

    m->lock = __SPIN_LOCK_UNLOCKED(m);

On Tegra, __SPIN_LOCK_UNLOCKED() expands to a braced-struct initializer
that is *not* valid as an assignment expression, causing:

    error: expected expression before '{' token

This patch applies a Tegra-specific workaround by replacing the
assignment with the stable kernel API:

    spin_lock_init(&m->lock);

This is guarded behind CONFIG_ARCH_TEGRA so that non-Tegra platforms
retain the current initialization behavior until further validation is
completed.

This fix restores successful kernel module builds on NVIDIA Tegra-based
Yocto images without modifying behavior on other architectures.

Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
@sameehj
Copy link
Copy Markdown
Contributor Author

sameehj commented Nov 27, 2025

@douzzer Thanks for the comments, fixed all of them now.

@douzzer
Copy link
Copy Markdown
Contributor

douzzer commented Dec 2, 2025

retest this please
(test results were flushed)

Copy link
Copy Markdown
Contributor

@douzzer douzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

hostap tests are unrelated failures believed fixed by #9486

@douzzer douzzer merged commit bc615a2 into wolfSSL:master Dec 2, 2025
273 of 308 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants