Commit Graph

1245 Commits (master)

Author SHA1 Message Date
Linus Torvalds 0923fd0419 Locking updates for v6.20:
Lock debugging:
 
  - Implement compiler-driven static analysis locking context
    checking, using the upcoming Clang 22 compiler's context
    analysis features. (Marco Elver)
 
    We removed Sparse context analysis support, because prior to
    removal even a defconfig kernel produced 1,700+ context
    tracking Sparse warnings, the overwhelming majority of which
    are false positives. On an allmodconfig kernel the number of
    false positive context tracking Sparse warnings grows to
    over 5,200... On the plus side of the balance actual locking
    bugs found by Sparse context analysis is also rather ... sparse:
    I found only 3 such commits in the last 3 years. So the
    rate of false positives and the maintenance overhead is
    rather high and there appears to be no active policy in
    place to achieve a zero-warnings baseline to move the
    annotations & fixers to developers who introduce new code.
 
    Clang context analysis is more complete and more aggressive
    in trying to find bugs, at least in principle. Plus it has
    a different model to enabling it: it's enabled subsystem by
    subsystem, which results in zero warnings on all relevant
    kernel builds (as far as our testing managed to cover it).
    Which allowed us to enable it by default, similar to other
    compiler warnings, with the expectation that there are no
    warnings going forward. This enforces a zero-warnings baseline
    on clang-22+ builds. (Which are still limited in distribution,
    admittedly.)
 
    Hopefully the Clang approach can lead to a more maintainable
    zero-warnings status quo and policy, with more and more
    subsystems and drivers enabling the feature. Context tracking
    can be enabled for all kernel code via WARN_CONTEXT_ANALYSIS_ALL=y
    (default disabled), but this will generate a lot of false positives.
 
    ( Having said that, Sparse support could still be added back,
      if anyone is interested - the removal patch is still
      relatively straightforward to revert at this stage. )
 
 Rust integration updates: (Alice Ryhl, Fujita Tomonori, Boqun Feng)
 
   - Add support for Atomic<i8/i16/bool> and replace most Rust native
     AtomicBool usages with Atomic<bool>
 
   - Clean up LockClassKey and improve its documentation
 
   - Add missing Send and Sync trait implementation for SetOnce
 
   - Make ARef Unpin as it is supposed to be
 
   - Add __rust_helper to a few Rust helpers as a preparation for
     helper LTO
 
   - Inline various lock related functions to avoid additional
     function calls.
 
 WW mutexes:
 
   - Extend ww_mutex tests and other test-ww_mutex updates (John Stultz)
 
 Misc fixes and cleanups:
 
   - rcu: Mark lockdep_assert_rcu_helper() __always_inline
     (Arnd Bergmann)
 
   - locking/local_lock: Include more missing headers (Peter Zijlstra)
 
   - seqlock: fix scoped_seqlock_read kernel-doc (Randy Dunlap)
 
   - rust: sync: Replace `kernel::c_str!` with C-Strings
     (Tamir Duberstein)
 
 Signed-off-by: Ingo Molnar <mingo@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAmmIXiURHG1pbmdvQGtl
 cm5lbC5vcmcACgkQEnMQ0APhK1gH+A/9GX5UmU6+HuDfDrCtXm9GDve6wkwahvcW
 jLDxOYjs764I2BhyjZnjKjyF5zw60hbykem7Wcf5EV2YH30nM4XRgEWVJfkr1UAI
 Pra415X4DdOzZ6qYQIpO8Udt1LtR7BMSaXITVLJaLicxEoOVtq3SKxjqyhCFs7UW
 MfJdqleB+RMLqq3LlzgB4l43eKk1xyeHh+oQwI0RSxuIpVZme3p4TObnCKjIWnK7
 Ihd+dkgC852WBjANgNL7F/sd5UsF5QX3wjtOrLhMKvkIgTPdXln0g398pivjN/G/
 Kpnw18SFeb159JfJu8eMotsYvVnQ0D5aOcTBfL4qvOHCImhpcu2s6ik9BcXqt2yT
 8IiuWk9xEM3Ok+I/I4ClT5cf5GYpyigV2QsXxn+IjDX5Na8v4zlHh0r8SElP8fOt
 7dpQx7iw8UghAib3AzA3suN78Oh39m8l5BNobj7LAjnqOQcVvoPo4o7/48ntuH7A
 38EucFrXfxQBMfGbMwvxEmgYuX7MyVfQLaPE06MHy1BkZkffT8Um38TB0iNtZmtf
 WUx01yLKWYspehlwFi319uVI4/Zp7FnTfqa5uKv1oSXVdL9vZojSXUzrgDV7FVqT
 Z4xAAw/kwNHpUG7y0zNOqd6PukovG1t+CjbLvK+eHPwc5c0vEGG2oTRAfEvvP1z/
 kesYDmCyJnk=
 =N1gA
 -----END PGP SIGNATURE-----

Merge tag 'locking-core-2026-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking updates from Ingo Molnar:
 "Lock debugging:

   - Implement compiler-driven static analysis locking context checking,
     using the upcoming Clang 22 compiler's context analysis features
     (Marco Elver)

     We removed Sparse context analysis support, because prior to
     removal even a defconfig kernel produced 1,700+ context tracking
     Sparse warnings, the overwhelming majority of which are false
     positives. On an allmodconfig kernel the number of false positive
     context tracking Sparse warnings grows to over 5,200... On the plus
     side of the balance actual locking bugs found by Sparse context
     analysis is also rather ... sparse: I found only 3 such commits in
     the last 3 years. So the rate of false positives and the
     maintenance overhead is rather high and there appears to be no
     active policy in place to achieve a zero-warnings baseline to move
     the annotations & fixers to developers who introduce new code.

     Clang context analysis is more complete and more aggressive in
     trying to find bugs, at least in principle. Plus it has a different
     model to enabling it: it's enabled subsystem by subsystem, which
     results in zero warnings on all relevant kernel builds (as far as
     our testing managed to cover it). Which allowed us to enable it by
     default, similar to other compiler warnings, with the expectation
     that there are no warnings going forward. This enforces a
     zero-warnings baseline on clang-22+ builds (Which are still limited
     in distribution, admittedly)

     Hopefully the Clang approach can lead to a more maintainable
     zero-warnings status quo and policy, with more and more subsystems
     and drivers enabling the feature. Context tracking can be enabled
     for all kernel code via WARN_CONTEXT_ANALYSIS_ALL=y (default
     disabled), but this will generate a lot of false positives.

     ( Having said that, Sparse support could still be added back,
       if anyone is interested - the removal patch is still
       relatively straightforward to revert at this stage. )

  Rust integration updates: (Alice Ryhl, Fujita Tomonori, Boqun Feng)

    - Add support for Atomic<i8/i16/bool> and replace most Rust native
      AtomicBool usages with Atomic<bool>

    - Clean up LockClassKey and improve its documentation

    - Add missing Send and Sync trait implementation for SetOnce

    - Make ARef Unpin as it is supposed to be

    - Add __rust_helper to a few Rust helpers as a preparation for
      helper LTO

    - Inline various lock related functions to avoid additional function
      calls

  WW mutexes:

    - Extend ww_mutex tests and other test-ww_mutex updates (John
      Stultz)

  Misc fixes and cleanups:

    - rcu: Mark lockdep_assert_rcu_helper() __always_inline (Arnd
      Bergmann)

    - locking/local_lock: Include more missing headers (Peter Zijlstra)

    - seqlock: fix scoped_seqlock_read kernel-doc (Randy Dunlap)

    - rust: sync: Replace `kernel::c_str!` with C-Strings (Tamir
      Duberstein)"

* tag 'locking-core-2026-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (90 commits)
  locking/rwlock: Fix write_trylock_irqsave() with CONFIG_INLINE_WRITE_TRYLOCK
  rcu: Mark lockdep_assert_rcu_helper() __always_inline
  compiler-context-analysis: Remove __assume_ctx_lock from initializers
  tomoyo: Use scoped init guard
  crypto: Use scoped init guard
  kcov: Use scoped init guard
  compiler-context-analysis: Introduce scoped init guards
  cleanup: Make __DEFINE_LOCK_GUARD handle commas in initializers
  seqlock: fix scoped_seqlock_read kernel-doc
  tools: Update context analysis macros in compiler_types.h
  rust: sync: Replace `kernel::c_str!` with C-Strings
  rust: sync: Inline various lock related methods
  rust: helpers: Move #define __rust_helper out of atomic.c
  rust: wait: Add __rust_helper to helpers
  rust: time: Add __rust_helper to helpers
  rust: task: Add __rust_helper to helpers
  rust: sync: Add __rust_helper to helpers
  rust: refcount: Add __rust_helper to helpers
  rust: rcu: Add __rust_helper to helpers
  rust: processor: Add __rust_helper to helpers
  ...
2026-02-10 12:28:44 -08:00
Linus Torvalds a9aabb3b83 Rust changes for v6.20 / v7.0
Toolchain and infrastructure:
 
  - Add '__rust_helper' annotation to the C helpers.
 
    This is needed to inline these helpers into Rust code.
 
  - Remove imports available via the prelude, treewide.
 
    This was possible thanks to a new lint in Klint that Gary has
    implemented -- more Klint-related changes, including initial upstream
    support, are coming.
 
  - Deduplicate pin-init flags.
 
 'kernel' crate:
 
  - Add support for calling a function exactly once with the new
    'do_once_lite!' macro (and 'OnceLite' type).
 
    Based on this, add 'pr_*_once!' macros to print only once.
 
  - Add 'impl_flags!' macro for defining common bitflags operations:
 
        impl_flags!(
            /// Represents multiple permissions.
            #[derive(Debug, Clone, Default, Copy, PartialEq, Eq)]
            pub struct Permissions(u32);
 
            /// Represents a single permission.
            #[derive(Debug, Clone, Copy, PartialEq, Eq)]
            pub enum Permission {
                /// Read permission.
                Read = 1 << 0,
 
                /// Write permission.
                Write = 1 << 1,
 
                /// Execute permission.
                Execute = 1 << 2,
            }
        );
 
        let mut f: Permissions = Permission::Read | Permission::Write;
        assert!(f.contains(Permission::Read));
        assert!(!f.contains(Permission::Execute));
 
        f |= Permission::Execute;
        assert!(f.contains(Permission::Execute));
 
        let f2: Permissions = Permission::Write | Permission::Execute;
        assert!((f ^ f2).contains(Permission::Read));
        assert!(!(f ^ f2).contains(Permission::Write));
 
  - 'bug' module: support 'CONFIG_DEBUG_BUGVERBOSE_DETAILED' in the
    'warn_on!' macro in order to show the evaluated condition alongside
    the file path:
 
         ------------[ cut here ]------------
         WARNING: [val == 1] linux/samples/rust/rust_minimal.rs:27 at ...
         Modules linked in: rust_minimal(+)
 
  - Add safety module with 'unsafe_precondition_assert!' macro, currently
    a wrapper for 'debug_assert!', intended to mark the validation of
    safety preconditions where possible:
 
        /// # Safety
        ///
        /// The caller must ensure that `index` is less than `N`.
        unsafe fn set_unchecked(&mut self, index: usize, value: T) {
            unsafe_precondition_assert!(
                index < N,
                "set_unchecked() requires index ({index}) < N ({N})"
            );
 
            ...
        }
 
  - Add instructions to 'build_assert!' documentation requesting to
    always inline functions when used with function arguments.
 
  - 'ptr' module: replace 'build_assert!' with a 'const' one.
 
  - 'rbtree' module: reduce unsafe blocks on pointer derefs.
 
  - 'transmute' module: implement 'FromBytes' and 'AsBytes' for
    inhabited ZSTs, and use it in Nova.
 
  - More treewide replacements of 'c_str!' with C string literals.
 
 'macros' crate:
 
  - Rewrite most procedural macros ('module!', 'concat_idents!',
    '#[export]', '#[vtable]', '#[kunit_tests]') to use the 'syn' parsing
    library which we introduced last cycle, with better diagnostics.
 
    This also allows to support '#[cfg]' properly in the '#[vtable]'
    macro, to support arbitrary types in 'module!' macro (not just an
    identifier) and to remove several custom parsing helpers we had.
 
  - Use 'quote!' from the recently vendored 'quote' library and remove
    our custom one.
 
    The vendored one also allows us to avoid quoting '"' and '{}' inside
    the template anymore and editors can now highlight it. In addition,
    it improves robustness as it eliminates the need for string quoting
    and escaping.
 
  - Use 'pin_init::zeroed()' to simplify KUnit code.
 
 'pin-init' crate:
 
  - Rewrite all procedural macros ('[pin_]init!', '#[pin_data]',
    '#[pinned_drop]', 'derive([Maybe]Zeroable)') to use the 'syn' parsing
    library which we introduced last cycle, with better diagnostics.
 
  - Implement 'InPlaceWrite' for '&'static mut MaybeUninit<T>'. This
    enables users to use external allocation mechanisms such as
    'static_cell'.
 
  - Support tuple structs in 'derive([Maybe]Zeroable)'.
 
  - Support attributes on fields in '[pin_]init!' (such as
    '#[cfg(...)]').
 
  - Add a '#[default_error(<type>)]' attribute to '[pin_]init!' to
    override the default error (when no '? Error' is specified).
 
  - Support packed structs in '[pin_]init!' with
    '#[disable_initialized_field_access]'.
 
  - Remove 'try_[pin_]init!' in favor of merging their feature
    with '[pin_]init!'. Update the kernel's own 'try_[pin_]init!'
    macros to use the 'default_error' attribute.
 
  - Correct 'T: Sized' bounds to 'T: ?Sized' in the generated
    'PinnedDrop' check by '#[pin_data]'.
 
 Documentation:
 
  - Conclude the Rust experiment.
 
 MAINTAINERS:
 
  - Add "RUST [RUST-ANALYZER]" entry for the rust-analyzer support. Tamir
    and Jesung will take care of it. They have both been active around it
    for a while. The new tree will flow through the Rust one.
 
  - Add Gary as maintainer for "RUST [PIN-INIT]".
 
  - Update Boqun and Tamir emails to their kernel.org accounts.
 
 And a few other cleanups and improvements.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPjU5OPd5QIZ9jqqOGXyLc2htIW0FAmmIeIwACgkQGXyLc2ht
 IW13gg//ZW9kgIILHRbyLtLA9luNukD75pYigg0sigeKfZq5SIbDVepOtDGIsXId
 fJwYme297u81nf+TWySGPKEwCPFX9NNwrN6JiIKTxxkpfIYNd+cA57QN141xm2y4
 4+cG0Zw7yj2PitTKl5nzjRr4dfdfG+t63zLa29O4D5XqMtKs+yeawMLmYpNJLcfJ
 /RDRt+p/GX84xgP7fFRPi6zG4sD48ZktmLOe2H7st/mQKxjtqXdMVSqKENhdriGm
 h6IdKPs38fxA953+xHE1jO+XygbevnBmWD/E+/7ns5nNajoHU8KKkKMUUyzGqcQK
 0tgnOW5Pn5zdZ2Tf+CYGEjo04aA1rDtAUTtjr74uGiUtJR63E3TcGaRr1sY9Hye2
 tqKC1MVnj+UFzaZw57OJI9s8At6HBz7NXx4ZZ/MrkKp3jaV5BFhz11rWPAF9SM2E
 DqMyIXSrKLCeLr1LocizvrTvNQFGQSdmlbnywnJ2PP679JbJsZz714igxTOvdQBt
 M4AGRl/BnC6ZUJV3+/cdpRfqUAi0TPYxouphQ5ynm0zuIG0VjCYhSWM/w9k3LiZD
 pamQYOVdBCUrIcPyXMyEt6DszZM5qlt+4syCygcYfdr3PklFrTxeqF9mhetEuJRR
 UcOEXAdknHFcPFUnMakAYrL9PBnVyb2INsdsRpOj2GTb/neJKPg=
 =en99
 -----END PGP SIGNATURE-----

Merge tag 'rust-6.20-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux

Pull rust updates from Miguel Ojeda:
 "Toolchain and infrastructure:

   - Add '__rust_helper' annotation to the C helpers

     This is needed to inline these helpers into Rust code

   - Remove imports available via the prelude, treewide

     This was possible thanks to a new lint in Klint that Gary has
     implemented -- more Klint-related changes, including initial
     upstream support, are coming

   - Deduplicate pin-init flags

  'kernel' crate:

   - Add support for calling a function exactly once with the new
     'do_once_lite!' macro (and 'OnceLite' type)

     Based on this, add 'pr_*_once!' macros to print only once

   - Add 'impl_flags!' macro for defining common bitflags operations:

         impl_flags!(
             /// Represents multiple permissions.
             #[derive(Debug, Clone, Default, Copy, PartialEq, Eq)]
             pub struct Permissions(u32);

             /// Represents a single permission.
             #[derive(Debug, Clone, Copy, PartialEq, Eq)]
             pub enum Permission {
                 /// Read permission.
                 Read = 1 << 0,

                 /// Write permission.
                 Write = 1 << 1,

                 /// Execute permission.
                 Execute = 1 << 2,
             }
         );

         let mut f: Permissions = Permission::Read | Permission::Write;
         assert!(f.contains(Permission::Read));
         assert!(!f.contains(Permission::Execute));

         f |= Permission::Execute;
         assert!(f.contains(Permission::Execute));

         let f2: Permissions = Permission::Write | Permission::Execute;
         assert!((f ^ f2).contains(Permission::Read));
         assert!(!(f ^ f2).contains(Permission::Write));

   - 'bug' module: support 'CONFIG_DEBUG_BUGVERBOSE_DETAILED' in the
     'warn_on!' macro in order to show the evaluated condition alongside
     the file path:

          ------------[ cut here ]------------
          WARNING: [val == 1] linux/samples/rust/rust_minimal.rs:27 at ...
          Modules linked in: rust_minimal(+)

   - Add safety module with 'unsafe_precondition_assert!' macro,
     currently a wrapper for 'debug_assert!', intended to mark the
     validation of safety preconditions where possible:

         /// # Safety
         ///
         /// The caller must ensure that `index` is less than `N`.
         unsafe fn set_unchecked(&mut self, index: usize, value: T) {
             unsafe_precondition_assert!(
                 index < N,
                 "set_unchecked() requires index ({index}) < N ({N})"
             );

             ...
         }

   - Add instructions to 'build_assert!' documentation requesting to
     always inline functions when used with function arguments

   - 'ptr' module: replace 'build_assert!' with a 'const' one

   - 'rbtree' module: reduce unsafe blocks on pointer derefs

   - 'transmute' module: implement 'FromBytes' and 'AsBytes' for
     inhabited ZSTs, and use it in Nova

   - More treewide replacements of 'c_str!' with C string literals

  'macros' crate:

   - Rewrite most procedural macros ('module!', 'concat_idents!',
     '#[export]', '#[vtable]', '#[kunit_tests]') to use the 'syn'
     parsing library which we introduced last cycle, with better
     diagnostics

     This also allows to support '#[cfg]' properly in the '#[vtable]'
     macro, to support arbitrary types in 'module!' macro (not just an
     identifier) and to remove several custom parsing helpers we had

   - Use 'quote!' from the recently vendored 'quote' library and remove
     our custom one

     The vendored one also allows us to avoid quoting '"' and '{}'
     inside the template anymore and editors can now highlight it. In
     addition, it improves robustness as it eliminates the need for
     string quoting and escaping

   - Use 'pin_init::zeroed()' to simplify KUnit code

  'pin-init' crate:

   - Rewrite all procedural macros ('[pin_]init!', '#[pin_data]',
     '#[pinned_drop]', 'derive([Maybe]Zeroable)') to use the 'syn'
     parsing library which we introduced last cycle, with better
     diagnostics

   - Implement 'InPlaceWrite' for '&'static mut MaybeUninit<T>'. This
     enables users to use external allocation mechanisms such as
     'static_cell'

   - Support tuple structs in 'derive([Maybe]Zeroable)'

   - Support attributes on fields in '[pin_]init!' (such as
     '#[cfg(...)]')

   - Add a '#[default_error(<type>)]' attribute to '[pin_]init!' to
     override the default error (when no '? Error' is specified)

   - Support packed structs in '[pin_]init!' with
     '#[disable_initialized_field_access]'

   - Remove 'try_[pin_]init!' in favor of merging their feature with
     '[pin_]init!'. Update the kernel's own 'try_[pin_]init!' macros to
     use the 'default_error' attribute

   - Correct 'T: Sized' bounds to 'T: ?Sized' in the generated
     'PinnedDrop' check by '#[pin_data]'

  Documentation:

   - Conclude the Rust experiment

  MAINTAINERS:

   - Add "RUST [RUST-ANALYZER]" entry for the rust-analyzer support.
     Tamir and Jesung will take care of it. They have both been active
     around it for a while. The new tree will flow through the Rust one

   - Add Gary as maintainer for "RUST [PIN-INIT]"

   - Update Boqun and Tamir emails to their kernel.org accounts

  And a few other cleanups and improvements"

* tag 'rust-6.20-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (59 commits)
  rust: safety: introduce `unsafe_precondition_assert!` macro
  rust: add `impl_flags!` macro for defining common bitflag operations
  rust: print: Add pr_*_once macros
  rust: bug: Support DEBUG_BUGVERBOSE_DETAILED option
  rust: print: Add support for calling a function exactly once
  rust: kbuild: deduplicate pin-init flags
  gpu: nova-core: remove imports available via prelude
  rust: clk: replace `kernel::c_str!` with C-Strings
  MAINTAINERS: Update my email address to @kernel.org
  rust: macros: support `#[cfg]` properly in `#[vtable]` macro.
  rust: kunit: use `pin_init::zeroed` instead of custom null value
  rust: macros: rearrange `#[doc(hidden)]` in `module!` macro
  rust: macros: allow arbitrary types to be used in `module!` macro
  rust: macros: convert `#[kunit_tests]` macro to use `syn`
  rust: macros: convert `concat_idents!` to use `syn`
  rust: macros: convert `#[export]` to use `syn`
  rust: macros: use `quote!` for `module!` macro
  rust: macros: use `syn` to parse `module!` macro
  rust: macros: convert `#[vtable]` macro to use `syn`
  rust: macros: use `quote!` from vendored crate
  ...
2026-02-10 11:53:01 -08:00
Linus Torvalds 9b1b3dcd28 Power management updates for 6.20-rc1/7.0-rc1
- Remove the unused omap-cpufreq driver (Andreas Kemnade)
 
  - Optimize error handling code in cpufreq_boost_trigger_state() and
    make cpufreq_boost_trigger_state() return -EOPNOTSUPP if no policy
    supports boost (Lifeng Zheng)
 
  - Update cpufreq-dt-platdev list for tegra, qcom, TI (Aaron Kling,
    Dhruva Gole, and Konrad Dybcio)
 
  - Minor improvements to the cpufreq and cpumask rust implementation
    (Alexandre Courbot, Alice Ryhl, Tamir Duberstein, and Yilin Chen)
 
  - Add support for AM62L3 SoC to the ti-cpufreq driver (Dhruva Gole)
 
  - Update arch_freq_scale in the CPPC cpufreq driver's frequency
    invariance engine (FIE) in scheduler ticks if the related CPPC
    registers are not in PCC (Jie Zhan)
 
  - Assorted minor cleanups and improvements in ARM cpufreq drivers (Juan
    Martinez, Felix Gu, Luca Weiss, and Sergey Shtylyov)
 
  - Add generic helpers for sysfs show/store to cppc_cpufreq (Sumit
    Gupta)
 
  - Make the scaling_setspeed cpufreq sysfs attribute return the actual
    requested frequency to avoid confusion (Pengjie Zhang)
 
  - Simplify the idle CPU time granularity test in the ondemand cpufreq
    governor (Frederic Weisbecker)
 
  - Enable asym capacity in intel_pstate only when CPU SMT is not
    possible (Yaxiong Tian)
 
  - Update the description of rate_limit_us default value in cpufreq
    documentation (Yaxiong Tian)
 
  - Add a command line option to adjust the C-states table in the
    intel_idle driver, remove the 'preferred_cstates' module parameter
    from it, add C-states validation to it and clean it up (Artem
    Bityutskiy)
 
  - Make the menu cpuidle governor always check the time till the closest
    timer event when the scheduler tick has been stopped to prevent it
    from mistakenly selecting the deepest available idle state (Rafael
    Wysocki)
 
  - Update the teo cpuidle governor to avoid making suboptimal decisions
    in certain corner cases and generally improve idle state selection
    accuracy (Rafael Wysocki)
 
  - Remove an unlikely() annotation on the early-return condition in
    menu_select() that leads to branch misprediction 100% of the time
    on systems with only 1 idle state enabled, like ARM64 servers (Breno
    Leitao)
 
  - Add Christian Loehle to MAINTAINERS as a cpuidle reviewer (Christian
    Loehle)
 
  - Stop flagging the PM runtime workqueue as freezable to avoid system
    suspend and resume deadlocks in subsystems that assume asynchronous
    runtime PM to work during system-wide PM transitions (Rafael Wysocki)
 
  - Drop redundant NULL pointer checks before acomp_request_free() from
    the hibernation code handling image saving (Rafael Wysocki)
 
  - Update wakeup_sources_walk_start() to handle empty lists of wakeup
    sources as appropriate (Samuel Wu)
 
  - Make dev_pm_clear_wake_irq() check the power.wakeirq value under
    power.lock to avoid race conditions (Gui-Dong Han)
 
  - Avoid bit field races related to power.work_in_progress in the core
    device suspend code (Xuewen Yan)
 
  - Make several drivers discard pm_runtime_put() return value in
    preparation for converting that function to a void one (Rafael
    Wysocki)
 
  - Add PL4 support for Ice Lake to the Intel RAPL power capping
    driver (Daniel Tang)
 
  - Replace sprintf() with sysfs_emit() in power capping sysfs show
    functions (Sumeet Pawnikar)
 
  - Make dev_pm_opp_get_level() return value match the documentation
    after a previous update of the latter (Aleks Todorov)
 
  - Use scoped for each OF child loop in the OPP code (Krzysztof
    Kozlowski)
 
  - Fix a bug in an example code snippet and correct typos in the energy
    model management documentation (Patrick Little)
 
  - Fix miscellaneous problems in cpupower (Kaushlendra Kumar):
 
    * idle_monitor: Fix incorrect value logged after stop
    * Fix inverted APERF capability check
    * Use strcspn() to strip trailing newline
    * Reset errno before strtoull()
    * Show C0 in idle-info dump
 
  - Improve cpupower installation procedure by making the systemd step
    optional and allowing users to disable the installation of systemd's
    unit file (João Marcos Costa)
 -----BEGIN PGP SIGNATURE-----
 
 iQFGBAABCAAwFiEEcM8Aw/RY0dgsiRUR7l+9nS/U47UFAmmDr5ASHHJqd0Byand5
 c29ja2kubmV0AAoJEO5fvZ0v1OO1Q8oH/0KRqdidHzesIQl6gd5WSS/sWdxODRUt
 R9dEGQQ6LXCY0z05RAq29HZQf618fYuRFX4PSrtyCvrcRJK7MJKuzK55MRq0MC3c
 c/2pL1PdpHexjLXUP9pcoxrYjetsr7SnD6Y0M3JfOPg1E/bG8sp1DlnE8cdqrL0W
 lrdB2cEGewT2SVkNhCIQ2n6bwfQwmLlfQl1vXTM8BA7xCjoslePUJlRphAFVAt/J
 5fQxSOH0eSxK5PYQFUDM2D2J3uMAN0pFb6eIjwVYYqjABqV//BPl99Rv2W3ElJq7
 K/SICRWlvzyINCgF15QAUtQHWdINxSb0GzovECVxODHOv0N4mKHdpNU=
 =QlVe
 -----END PGP SIGNATURE-----

Merge tag 'pm-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management updates from Rafael Wysocki:
 "By the number of commits, cpufreq is the leading party (again) and the
  most visible change there is the removal of the omap-cpufreq driver
  that has not been used for a long time (good riddance). There are also
  quite a few changes in the cppc_cpufreq driver, mostly related to
  fixing its frequency invariance engine in the case when the CPPC
  registers used by it are not in PCC. In addition to that, support for
  AM62L3 is added to the ti-cpufreq driver and the cpufreq-dt-platdev
  list is updated for some platforms. The remaining cpufreq changes are
  assorted fixes and cleanups.

  Next up is cpuidle and the changes there are dominated by intel_idle
  driver updates, mostly related to the new command line facility
  allowing users to adjust the list of C-states used by the driver.
  There are also a few updates of cpuidle governors, including two menu
  governor fixes and some refinements of the teo governor, and a
  MAINTAINERS update adding Christian Loehle as a cpuidle reviewer.
  [Thanks for stepping up Christian!]

  The most significant update related to system suspend and hibernation
  is the one to stop freezing the PM runtime workqueue during system PM
  transitions which allows some deadlocks to be avoided. There is also a
  fix for possible concurrent bit field updates in the core device
  suspend code and a few other minor fixes.

  Apart from the above, several drivers are updated to discard the
  return value of pm_runtime_put() which is going to be converted to a
  void function as soon as everybody stops using its return value, PL4
  support for Ice Lake is added to the Intel RAPL power capping driver,
  and there are assorted cleanups, documentation fixes, and some
  cpupower utility improvements.

  Specifics:

   - Remove the unused omap-cpufreq driver (Andreas Kemnade)

   - Optimize error handling code in cpufreq_boost_trigger_state() and
     make cpufreq_boost_trigger_state() return -EOPNOTSUPP if no policy
     supports boost (Lifeng Zheng)

   - Update cpufreq-dt-platdev list for tegra, qcom, TI (Aaron Kling,
     Dhruva Gole, and Konrad Dybcio)

   - Minor improvements to the cpufreq and cpumask rust implementation
     (Alexandre Courbot, Alice Ryhl, Tamir Duberstein, and Yilin Chen)

   - Add support for AM62L3 SoC to the ti-cpufreq driver (Dhruva Gole)

   - Update arch_freq_scale in the CPPC cpufreq driver's frequency
     invariance engine (FIE) in scheduler ticks if the related CPPC
     registers are not in PCC (Jie Zhan)

   - Assorted minor cleanups and improvements in ARM cpufreq drivers
     (Juan Martinez, Felix Gu, Luca Weiss, and Sergey Shtylyov)

   - Add generic helpers for sysfs show/store to cppc_cpufreq (Sumit
     Gupta)

   - Make the scaling_setspeed cpufreq sysfs attribute return the actual
     requested frequency to avoid confusion (Pengjie Zhang)

   - Simplify the idle CPU time granularity test in the ondemand cpufreq
     governor (Frederic Weisbecker)

   - Enable asym capacity in intel_pstate only when CPU SMT is not
     possible (Yaxiong Tian)

   - Update the description of rate_limit_us default value in cpufreq
     documentation (Yaxiong Tian)

   - Add a command line option to adjust the C-states table in the
     intel_idle driver, remove the 'preferred_cstates' module parameter
     from it, add C-states validation to it and clean it up (Artem
     Bityutskiy)

   - Make the menu cpuidle governor always check the time till the
     closest timer event when the scheduler tick has been stopped to
     prevent it from mistakenly selecting the deepest available idle
     state (Rafael Wysocki)

   - Update the teo cpuidle governor to avoid making suboptimal
     decisions in certain corner cases and generally improve idle state
     selection accuracy (Rafael Wysocki)

   - Remove an unlikely() annotation on the early-return condition in
     menu_select() that leads to branch misprediction 100% of the time
     on systems with only 1 idle state enabled, like ARM64 servers
     (Breno Leitao)

   - Add Christian Loehle to MAINTAINERS as a cpuidle reviewer
     (Christian Loehle)

   - Stop flagging the PM runtime workqueue as freezable to avoid system
     suspend and resume deadlocks in subsystems that assume asynchronous
     runtime PM to work during system-wide PM transitions (Rafael
     Wysocki)

   - Drop redundant NULL pointer checks before acomp_request_free() from
     the hibernation code handling image saving (Rafael Wysocki)

   - Update wakeup_sources_walk_start() to handle empty lists of wakeup
     sources as appropriate (Samuel Wu)

   - Make dev_pm_clear_wake_irq() check the power.wakeirq value under
     power.lock to avoid race conditions (Gui-Dong Han)

   - Avoid bit field races related to power.work_in_progress in the core
     device suspend code (Xuewen Yan)

   - Make several drivers discard pm_runtime_put() return value in
     preparation for converting that function to a void one (Rafael
     Wysocki)

   - Add PL4 support for Ice Lake to the Intel RAPL power capping driver
     (Daniel Tang)

   - Replace sprintf() with sysfs_emit() in power capping sysfs show
     functions (Sumeet Pawnikar)

   - Make dev_pm_opp_get_level() return value match the documentation
     after a previous update of the latter (Aleks Todorov)

   - Use scoped for each OF child loop in the OPP code (Krzysztof
     Kozlowski)

   - Fix a bug in an example code snippet and correct typos in the
     energy model management documentation (Patrick Little)

   - Fix miscellaneous problems in cpupower (Kaushlendra Kumar):
      * idle_monitor: Fix incorrect value logged after stop
      * Fix inverted APERF capability check
      * Use strcspn() to strip trailing newline
      * Reset errno before strtoull()
      * Show C0 in idle-info dump

   - Improve cpupower installation procedure by making the systemd step
     optional and allowing users to disable the installation of
     systemd's unit file (João Marcos Costa)"

* tag 'pm-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (65 commits)
  PM: sleep: core: Avoid bit field races related to work_in_progress
  PM: sleep: wakeirq: harden dev_pm_clear_wake_irq() against races
  cpufreq: Documentation: Update description of rate_limit_us default value
  cpufreq: intel_pstate: Enable asym capacity only when CPU SMT is not possible
  PM: wakeup: Handle empty list in wakeup_sources_walk_start()
  PM: EM: Documentation: Fix bug in example code snippet
  Documentation: Fix typos in energy model documentation
  cpuidle: governors: teo: Refine intercepts-based idle state lookup
  cpuidle: governors: teo: Adjust the classification of wakeup events
  cpufreq: ondemand: Simplify idle cputime granularity test
  cpufreq: userspace: make scaling_setspeed return the actual requested frequency
  PM: hibernate: Drop NULL pointer checks before acomp_request_free()
  cpufreq: CPPC: Add generic helpers for sysfs show/store
  cpufreq: scmi: Fix device_node reference leak in scmi_cpu_domain_id()
  cpufreq: ti-cpufreq: add support for AM62L3 SoC
  cpufreq: dt-platdev: Add ti,am62l3 to blocklist
  cpufreq/amd-pstate: Add comment explaining nominal_perf usage for performance policy
  cpufreq: scmi: correct SCMI explanation
  cpufreq: dt-platdev: Block the driver from probing on more QC platforms
  rust: cpumask: rename methods of Cpumask for clarity and consistency
  ...
2026-02-09 19:00:42 -08:00
Linus Torvalds 0c00ed308d for-7.0/block-20260206
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCAAuFiEEwPw5LcreJtl1+l5K99NY+ylx4KYFAmmGLwcQHGF4Ym9lQGtl
 cm5lbC5kawAKCRD301j7KXHgpv+TD/48S2HTnMhmW6AtFYWErQ+sEKXpHrxbYe7S
 +qR8/g/T+QSfhfqPwZEuagndFKtIP3LJfaXGSP1Lk1RfP9NLQy91v33Ibe4DjHkp
 etWSfnMHA9MUAoWKmg8EvncB2G+ZQFiYCpjazj5tKHD9S2+psGMuL8kq6qzMJE83
 uhpb8WutUl4aSIXbMSfyGlwBhI1MjjRbbWlIBmg4yC8BWt1sH8Qn2L2GNVylEIcX
 U8At3KLgPGn0axSg4yGMAwTqtGhL/jwdDyeczbmRlXuAr4iVL9UX/yADCYkazt6U
 ttQ2/H+cxCwfES84COx9EteAatlbZxo6wjGvZ3xOMiMJVTjYe1x6Gkcckq+LrZX6
 tjofi2KK78qkrMXk1mZMkZjpyUWgRtCswhDllbQyqFs0SwzQtno2//Rk8HU9dhbt
 pkpryDbGFki9X3upcNyEYp5TYflpW6YhAzShYgmE6KXim2fV8SeFLviy0erKOAl+
 fwjTE6KQ5QoQv0s3WxkWa4lREm34O6IHrCUmbiPm5CruJnQDhqAN2QZIDgYC4WAf
 0gu9cR/O4Vxu7TQXrumPs5q+gCyDU0u0B8C3mG2s+rIo+PI5cVZKs2OIZ8HiPo0F
 x73kR/pX3DMe35ZQkQX22ymMuowV+aQouDLY9DTwakP5acdcg7h7GZKABk6VLB06
 gUIsnxURiQ==
 =jNzW
 -----END PGP SIGNATURE-----

Merge tag 'for-7.0/block-20260206' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux

Pull block updates from Jens Axboe:

 - Support for batch request processing for ublk, improving the
   efficiency of the kernel/ublk server communication. This can yield
   nice 7-12% performance improvements

 - Support for integrity data for ublk

 - Various other ublk improvements and additions, including a ton of
   selftests additions and updated

 - Move the handling of blk-crypto software fallback from below the
   block layer to above it. This reduces the complexity of dealing with
   bio splitting

 - Series fixing a number of potential deadlocks in blk-mq related to
   the queue usage counter and writeback throttling and rq-qos debugfs
   handling

 - Add an async_depth queue attribute, to resolve a performance
   regression that's been around for a qhilw related to the scheduler
   depth handling

 - Only use task_work for IOPOLL completions on NVMe, if it is necessary
   to do so. An earlier fix for an issue resulted in all these
   completions being punted to task_work, to guarantee that completions
   were only run for a given io_uring ring when it was local to that
   ring. With the new changes, we can detect if it's necessary to use
   task_work or not, and avoid it if possible.

 - rnbd fixes:
      - Fix refcount underflow in device unmap path
      - Handle PREFLUSH and NOUNMAP flags properly in protocol
      - Fix server-side bi_size for special IOs
      - Zero response buffer before use
      - Fix trace format for flags
      - Add .release to rnbd_dev_ktype

 - MD pull requests via Yu Kuai
      - Fix raid5_run() to return error when log_init() fails
      - Fix IO hang with degraded array with llbitmap
      - Fix percpu_ref not resurrected on suspend timeout in llbitmap
      - Fix GPF in write_page caused by resize race
      - Fix NULL pointer dereference in process_metadata_update
      - Fix hang when stopping arrays with metadata through dm-raid
      - Fix any_working flag handling in raid10_sync_request
      - Refactor sync/recovery code path, improve error handling for
        badblocks, and remove unused recovery_disabled field
      - Consolidate mddev boolean fields into mddev_flags
      - Use mempool to allocate stripe_request_ctx and make sure
        max_sectors is not less than io_opt in raid5
      - Fix return value of mddev_trylock
      - Fix memory leak in raid1_run()
      - Add Li Nan as mdraid reviewer

 - Move phys_vec definitions to the kernel types, mostly in preparation
   for some VFIO and RDMA changes

 - Improve the speed for secure erase for some devices

 - Various little rust updates

 - Various other minor fixes, improvements, and cleanups

* tag 'for-7.0/block-20260206' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux: (162 commits)
  blk-mq: ABI/sysfs-block: fix docs build warnings
  selftests: ublk: organize test directories by test ID
  block: decouple secure erase size limit from discard size limit
  block: remove redundant kill_bdev() call in set_blocksize()
  blk-mq: add documentation for new queue attribute async_dpeth
  block, bfq: convert to use request_queue->async_depth
  mq-deadline: covert to use request_queue->async_depth
  kyber: covert to use request_queue->async_depth
  blk-mq: add a new queue sysfs attribute async_depth
  blk-mq: factor out a helper blk_mq_limit_depth()
  blk-mq-sched: unify elevators checking for async requests
  block: convert nr_requests to unsigned int
  block: don't use strcpy to copy blockdev name
  blk-mq-debugfs: warn about possible deadlock
  blk-mq-debugfs: add missing debugfs_mutex in blk_mq_debugfs_register_hctxs()
  blk-mq-debugfs: remove blk_mq_debugfs_unregister_rqos()
  blk-mq-debugfs: make blk_mq_debugfs_register_rqos() static
  blk-rq-qos: fix possible debugfs_mutex deadlock
  blk-mq-debugfs: factor out a helper to register debugfs for all rq_qos
  blk-wbt: fix possible deadlock to nest pcpu_alloc_mutex under q_usage_counter
  ...
2026-02-09 17:57:21 -08:00
Ritvik Gupta b8d687c7ee rust: safety: introduce `unsafe_precondition_assert!` macro
Introduce a new `safety` module containing `unsafe_precondition_assert!`
macro. It is a wrapper around `debug_assert!`, intended for validating
preconditions of unsafe function.

When `CONFIG_RUST_DEBUG_ASSERTIONS` flag is enabled, this macro performs
runtime checks to ensure that the preconditions for unsafe function hold.
Otherwise, the macro is a no-op.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-Linux/linux/issues/1162
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/291566-Library/topic/.60unsafe_precondition_assert.60.20macro/with/528457452
Signed-off-by: Ritvik Gupta <ritvikfoss@gmail.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20251007215034.213779-1-ritvikfoss@gmail.com
[ Added trailing periods, intra-doc link, "a" in "is a no-op" and `()`
  to function reference. Removed plural in assertion message and title
  of macro. Reworded slightly. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-02-02 08:10:48 +01:00
Filipe Xavier 0e62e4f3e5 rust: add `impl_flags!` macro for defining common bitflag operations
We have seen a proliferation of `mod_whatever::foo::Flags` being
defined with essentially the same implementation for `BitAnd`, `BitOr`,
`.contains()` etc.

This macro aims to bring a solution for this, allowing to generate these
methods for user-defined structs.  With some use cases in KMS and upcoming
GPU drivers.

Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/We.20really.20need.20a.20common.20.60Flags.60.20type
Suggested-by: Daniel Almeida <daniel.almeida@collabora.com>
Suggested-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Signed-off-by: Filipe Xavier <felipeaggger@gmail.com>
Link: https://patch.msgid.link/20260117-feat-add-bitmask-macro-v9-1-45ea1f00f846@gmail.com
[ Implemented missing `BitXorAssign<$flag> for $flags`. Sorted
  `impl`s. Removed prelude addition for now -- I asked the team and they
  also felt it wasn't needed. We can always add it later on if needed.
  Fixed intra-doc link (by removing the sentence since it was superfluous
  anyway). Simplified `empty()` title. Reworded commit slightly. Added
  docs to enum variants in example to avoid 'missing_docs' lint when used
  in actual code. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-02-02 08:09:11 +01:00
Linus Torvalds 367b81ef01 Rust fixes for v6.19
Toolchain and infrastructure:
 
   - Trigger rebuilds of the newly added 'proc-macro2' crate (and its
     dependencies) when the Rust compiler version changes.
 
   - Fix error in '.rsi' targets (macro expanding single targets) under
     'O=' pointing to an external (not subdir) folder.
 
   - Fix off-by-one line number in 'rustdoc' KUnit tests.
 
   - Add '-fdiagnostics-show-context' to GCC flags skipped by 'bindgen'.
 
   - Clean objtool warning by adding one more 'noreturn' function.
 
   - Clean 'libpin_init_internal.{so,dylib}' in 'mrproper'.
 
 'kernel' crate:
 
   - Fix build error when using expressions in formatting arguments.
 
   - Mark 'num::Bounded::__new()' as unsafe and clean documentation
     accordingly.
 
   - Always inline functions using 'build_assert' with arguments.
 
   - Fix 'rusttest' build error providing the right 'isize_atomic_repr'
     type for the host.
 
 'macros' crate:
 
   - Fix 'rusttest' build error by ignoring example.
 
 rust-analyzer:
 
   - Remove assertion that was not true for distributions like NixOS.
 
   - Add missing dependency edges and fix editions for 'quote' and
     sysroot crates to provide correct IDE support.
 
 DRM Tyr:
 
   - Fix build error by adding missing dependency on 'CONFIG_COMMON_CLK'.
 
 Plus clean a few typos in docs and comments.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPjU5OPd5QIZ9jqqOGXyLc2htIW0FAml9K+8ACgkQGXyLc2ht
 IW2N0xAAyYZgbZIYsnSkHUHkCNsnHGOxAfm7D7LzCnCoPQlLGuN+wDZ8a2NABuoH
 nKYnBim685xv3Lwlr2WVMPoSezTRCdeNNN6xjkfkv8XOpPpgyB4xDR2LyubcWSsE
 LE0fx3SEkfY1Itc3tKdmWauaGXSGk6xzrzlZ5yCB37UC6Ml5vfbr/Pz3BDNpG2D1
 whHMatP31DlNGaxGENG0Ze+PGt9qEgkfvbkWj0nXKqB6uh2jXvYq+G0t7yHx3Evq
 TwsiyQM3SpmzmZ1T0smPdflbWSqBCtGyH9TCVAAf5SSQCpZzmVt3O3AxMZNbaT9w
 OeH6OpOnOhKcGat3DKfEO7VmUDfbo7jaCoruQRVH7FRgFafeYXsGbmmvbHS8HQi8
 iXavmmbQuQ4WSDPSePxfQuX6KV+ooVg8NH2pO7MpqSZnHDkMPjufw60Bd4qntPvi
 N+QwmrRp34/k2kfAArM63xtfA1o2xNh4w1hRZeaTwot7FnKSe6tr1v1cg3JbtoPT
 DwMbTCwy4EskwRNbBSV4Ie5gtRcWHhB3uuu4edfluFsI5GIxuQka+Td3ABHWv7jG
 //HVoE+4QWGH7992nSYGMA2zpLbgy5FfJZnraqFoHvcNDtWiipNXAwh4CEG0oQ5m
 OxwLf8GcX2ZTbm3XePdzNebwmowedO69IY9juFSiP380AsrCpjw=
 =C6JY
 -----END PGP SIGNATURE-----

Merge tag 'rust-fixes-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux

Pull Rust fixes from Miguel Ojeda:
 "Toolchain and infrastructure:

   - Trigger rebuilds of the newly added 'proc-macro2' crate (and its
     dependencies) when the Rust compiler version changes

   - Fix error in '.rsi' targets (macro expanding single targets) under
     'O=' pointing to an external (not subdir) folder

   - Fix off-by-one line number in 'rustdoc' KUnit tests

   - Add '-fdiagnostics-show-context' to GCC flags skipped by 'bindgen'

   - Clean objtool warning by adding one more 'noreturn' function

   - Clean 'libpin_init_internal.{so,dylib}' in 'mrproper'

  'kernel' crate:

   - Fix build error when using expressions in formatting arguments

   - Mark 'num::Bounded::__new()' as unsafe and clean documentation
     accordingly

   - Always inline functions using 'build_assert' with arguments

   - Fix 'rusttest' build error providing the right 'isize_atomic_repr'
     type for the host

  'macros' crate:

   - Fix 'rusttest' build error by ignoring example

  rust-analyzer:

   - Remove assertion that was not true for distributions like NixOS

   - Add missing dependency edges and fix editions for 'quote' and
     sysroot crates to provide correct IDE support

  DRM Tyr:

   - Fix build error by adding missing dependency on 'CONFIG_COMMON_CLK'

  Plus clean a few typos in docs and comments"

* tag 'rust-fixes-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (28 commits)
  rust: num: bounded: clean __new documentation and comments
  scripts: generate_rust_analyzer: fix resolution of #[pin_data] macros
  drm/tyr: depend on `COMMON_CLK` to fix build error
  rust: sync: atomic: Provide stub for `rusttest` 32-bit hosts
  kbuild: rust: clean libpin_init_internal in mrproper
  rust: proc-macro2: rebuild if the version text changes
  rust: num: bounded: add missing comment for always inlined function
  rust: sync: refcount: always inline functions using build_assert with arguments
  rust: bits: always inline functions using build_assert with arguments
  scripts: generate_rust_analyzer: compile sysroot with correct edition
  scripts: generate_rust_analyzer: compile quote with correct edition
  scripts: generate_rust_analyzer: quote: treat `core` and `std` as dependencies
  scripts: generate_rust_analyzer: syn: treat `std` as a dependency
  scripts: generate_rust_analyzer: remove sysroot assertion
  rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target
  scripts: generate_rust_analyzer: Add pin_init_internal deps
  scripts: generate_rust_analyzer: Add pin_init -> compiler_builtins dep
  scripts: generate_rust_analyzer: Add compiler_builtins -> core dep
  rust: macros: ignore example with module parameters
  rust: num: bounded: mark __new as unsafe
  ...
2026-01-30 16:15:59 -08:00
FUJITA Tomonori 46c40f938f rust: print: Add pr_*_once macros
Add Rust version of pr_[emerg|alert|crit|err|warn|notice|info]_once
macros, which print a message only once.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Link: https://patch.msgid.link/20251117002452.4068692-3-fujita.tomonori@gmail.com
[ Added prefix to title. Fixed typo. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-30 05:47:05 +01:00
FUJITA Tomonori e600425708 rust: print: Add support for calling a function exactly once
Add the Rust equivalent of the kernel's `DO_ONCE_LITE` macro. While it
would be possible to implement the feature entirely as a Rust macro,
the functionality that can be implemented as regular functions has
been extracted and implemented as the `OnceLite` struct for better
code maintainability.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20251117002452.4068692-2-fujita.tomonori@gmail.com
[ Added prefix to title. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-30 05:18:17 +01:00
FUJITA Tomonori 966f79ce6f rust: bug: Support DEBUG_BUGVERBOSE_DETAILED option
Make warn_on() support DEBUG_BUGVERBOSE_DETAILED option, which was
introduced by the commit aec58b4851 ("bugs/core: Extend
__WARN_FLAGS() with the 'cond_str' parameter").

When the option is enabled, WARN splats now show the evaluated
warn_on() condition alongside the file path, e.g.:

------------[ cut here ]------------
WARNING: [val == 1] linux/samples/rust/rust_minimal.rs:27 at _RNvXCsk7t4azzUqHP_12rust_minimalNtB2_11RustMinimalNtCs8pcx3n4
Modules linked in: rust_minimal(+)

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260108013350.2880613-1-fujita.tomonori@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-30 05:18:17 +01:00
Tamir Duberstein 844590b439 rust: clk: replace `kernel::c_str!` with C-Strings
C-String literals were added in Rust 1.77. Replace instances of
`kernel::c_str!` with C-String literals where possible.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://patch.msgid.link/20251222-cstr-clk-v1-1-ef0687717aa1@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-30 01:08:24 +01:00
Gary Guo be97f3c820 rust: kunit: use `pin_init::zeroed` instead of custom null value
The last null element can be created (constly) using `pin_init::zeroed`,
so prefer to use it instead of adding a custom way of building it.

Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Gary Guo <gary@garyguo.net>
Reviewed-by: David Gow <davidgow@google.com>
Link: https://patch.msgid.link/20260112170919.1888584-12-gary@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-28 13:44:17 +01:00
Tamir Duberstein e6de07249e rust: sync: Replace `kernel::c_str!` with C-Strings
C-String literals were added in Rust 1.77. Replace instances of
`kernel::c_str!` with C-String literals where possible.

Signed-off-by: Tamir Duberstein <tamird@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260120-cstr-sync-again-v1-1-2a775a2a36fd@kernel.org
Link: https://patch.msgid.link/20260123054624.8226-2-boqun.feng@gmail.com
2026-01-28 09:25:44 +01:00
Miguel Ojeda 99ba0fa10d pin-init changes for v7.0
Added:
 
 - '&'static mut MaybeUninit<T>' now implements 'InPlaceWrite'. This
   enables users to use external allocation mechanisms such as
   'static_cell'.
 
 - Gary Guo as a Maintainer.
 
 Changed:
 
 - Rewrote all proc-macros ('[pin_]init!', '#[pin_data]',
   '#[pinned_drop]', 'derive([Maybe]Zeroable)'),  using 'syn' with better
   diagnostics.
 
 - 'derive([Maybe]Zeroable)' now support tuple structs.
 
 - '[pin_]init!' now supports attributes on fields (such as
   '#[cfg(...)]').
 
 - Add a '#[default_error(<type>)]' attribute to '[pin_]init!' to
   override the default error (when no '? Error' is specified).
 
 - Support packed struct in '[pin_]init!' with
   '#[disable_initialized_field_access]'.
 
 Removed:
 
 - 'try_[pin_]init!' have been removed in favor of merging their feature
   with '[pin_]init!'. The kernel's own 'try_[pin_]init!' macros have
   been updated to use the 'default_error' attribute.
 
 Fixed:
 
 - Corrected 'T: Sized' bounds to 'T: ?Sized' in the generated
   'PinnedDrop' check by '#[pin_data]'.
 -----BEGIN PGP SIGNATURE-----
 
 iIgEABYKADAWIQQjEG/HT3UeYLJybLTomd21rZaLygUCaXHz9BIcbG9zc2luQGtl
 cm5lbC5vcmcACgkQ6Jndta2Wi8q1AQD+IAf84ueKJ8vEfiSRP0IgteZakHxFHCyZ
 Uqsn0MQRUTgA/238IG65zYkrT8jaT3FY+LSoaNRY4rNS8/l9bxFWqqwA
 =dBj9
 -----END PGP SIGNATURE-----

Merge tag 'pin-init-v7.0' of https://github.com/Rust-for-Linux/linux into rust-next

Pull pin-init updates from Benno Lossin:
 "Added:

   - Implement 'InPlaceWrite' for '&'static mut MaybeUninit<T>'. This
     enables users to use external allocation mechanisms such as
     'static_cell'.

   - Add Gary Guo as a Maintainer.

  Changed:

   - Rewrote all proc-macros ('[pin_]init!', '#[pin_data]',
     '#[pinned_drop]', 'derive([Maybe]Zeroable)'), using 'syn' with
     better diagnostics.

   - Support tuple structs in 'derive([Maybe]Zeroable)'.

   - Support attributes on fields in '[pin_]init!' (such as
     '#[cfg(...)]').

   - Add a '#[default_error(<type>)]' attribute to '[pin_]init!' to
     override the default error (when no '? Error' is specified).

   - Support packed structs in '[pin_]init!' with
     '#[disable_initialized_field_access]'.

  Removed:

   - Remove 'try_[pin_]init!' in favor of merging their feature
     with '[pin_]init!'. Update the kernel's own 'try_[pin_]init!'
     macros to use the 'default_error' attribute.

  Fixed:

   - Correct 'T: Sized' bounds to 'T: ?Sized' in the generated
     'PinnedDrop' check by '#[pin_data]'."

* tag 'pin-init-v7.0' of https://github.com/Rust-for-Linux/linux:
  rust: pin-init: Implement `InPlaceWrite<T>` for `&'static mut MaybeUninit<T>`
  MAINTAINERS: add Gary Guo to pin-init
  rust: pin-init: internal: init: simplify Zeroable safety check
  rust: pin-init: internal: init: add escape hatch for referencing initialized fields
  rust: pin-init: internal: init: add support for attributes on initializer fields
  rust: init: use `#[default_error(err)]` for the initializer macros
  rust: pin-init: add `#[default_error(<type>)]` attribute to initializer macros
  rust: pin-init: rewrite the initializer macros using `syn`
  rust: pin-init: add `?Sized` bounds to traits in `#[pin_data]` macro
  rust: pin-init: rewrite `#[pin_data]` using `syn`
  rust: pin-init: rewrite the `#[pinned_drop]` attribute macro using `syn`
  rust: pin-init: rewrite `derive(Zeroable)` and `derive(MaybeZeroable)` using `syn`
  rust: pin-init: internal: add utility API for syn error handling
  rust: pin-init: add `syn` dependency and remove `proc-macro[2]` and `quote` workarounds
  rust: pin-init: allow the crate to refer to itself as `pin-init` in doc tests
  rust: pin-init: remove `try_` versions of the initializer macros
2026-01-28 00:19:32 +01:00
Rafael J. Wysocki b753c3204d CPUFreq arm updates for 7.0
- Update cpufreq-dt-platdev list for tegra, qcom, TI (Aaron Kling,
   Dhruva Gole, and Konrad Dybcio).
 
 - Minor improvements to the cpufreq / cpumask rust implementation
   (Alexandre Courbot, Alice Ryhl, Tamir Duberstein, and Yilin Chen).
 
 - Add support for AM62L3 SoC to ti-cpufreq driver (Dhruva Gole).
 
 - Update FIE arch_freq_scale in ticks for non-PCC regs (Jie Zhan).
 
 - Other minor cleanups / improvements (Felix Gu, Juan Martinez, Luca
   Weiss, and Sergey Shtylyov).
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEx73Crsp7f6M6scA70rkcPK6BEhwFAml4YIcACgkQ0rkcPK6B
 Ehx6hQ//Y8GoICqNQe6IrVQ6b9eJLB/YOP7vPyZuwc0iqT9YWXrMou5xlnmNW/IY
 zj0Wo3l3fidp6eDOo7f21mXALF9yt8kElKq411Oqcg4WVWyAXc9p6ODpWZp/G2/h
 JcmusAkwFPul0XE0QJmlJ54KqtsyjoSWQHtrPzOO54mJEhOL4dWQwqhWP046ed7T
 FVkNRLb7ysY3+weNuAg45SbVJ3FT/a7f8XbdGd5DAz96efbqTyFt+znhfsd3Xti+
 sF75Mq1AEN0Vnfb8ZP4MZUCe7zeVdOVfLFqXXiW/qJOdbRgoD6k2uAOIt2NAcYU/
 sbv6UjaW0NE0oTvKbJ8CLE4IIJudjRgVNjyyGlKHdjBVgMQQk9vr7DIedGLghink
 VABcyerIqhPFGkBkY0IXkLSmhNtKWoLN9w7sMeCwhE34l63Bnie3Sg9JLikRxaXK
 6BAm3+8BiG30tg4WL1LX8UyssnMlUGvvOD9TCP4jOfLQeAk8wWgQ1D+CwWCB5o5j
 jtDwPTOCIN9UQT46lYS+kkqzwf4YTFVdA4c23Tod70gjrtm7Z1a7UzYNxoTGcGS3
 VtrgVnlgPh3/I/95Qpsgoy5D1oeIz9znFoVv6ETPBINy4A4rAsYMA4DEASfM7tIY
 pNhbSTcbtDbp6Eo79hkh5J2ZGoJyTSthrX+irqOz+IQFp8fP9s4=
 =Zz3B
 -----END PGP SIGNATURE-----

Merge tag 'cpufreq-arm-updates-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm

Pull CPUFreq Arm updates for 7.0 from Viresh Kumar:

"- Update cpufreq-dt-platdev list for tegra, qcom, TI (Aaron Kling,
   Dhruva Gole, and Konrad Dybcio).

 - Minor improvements to the cpufreq / cpumask rust implementation
   (Alexandre Courbot, Alice Ryhl, Tamir Duberstein, and Yilin Chen).

 - Add support for AM62L3 SoC to ti-cpufreq driver (Dhruva Gole).

 - Update FIE arch_freq_scale in ticks for non-PCC regs (Jie Zhan).

 - Other minor cleanups / improvements (Felix Gu, Juan Martinez, Luca
   Weiss, and Sergey Shtylyov)."

* tag 'cpufreq-arm-updates-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
  cpufreq: scmi: Fix device_node reference leak in scmi_cpu_domain_id()
  cpufreq: ti-cpufreq: add support for AM62L3 SoC
  cpufreq: dt-platdev: Add ti,am62l3 to blocklist
  cpufreq/amd-pstate: Add comment explaining nominal_perf usage for performance policy
  cpufreq: scmi: correct SCMI explanation
  cpufreq: dt-platdev: Block the driver from probing on more QC platforms
  rust: cpumask: rename methods of Cpumask for clarity and consistency
  cpufreq: CPPC: Update FIE arch_freq_scale in ticks for non-PCC regs
  cpufreq: CPPC: Factor out cppc_fie_kworker_init()
  ACPI: CPPC: Factor out and export per-cpu cppc_perf_ctrs_in_pcc_cpu()
  rust: cpufreq: replace `kernel::c_str!` with C-Strings
  cpufreq: Add Tegra186 and Tegra194 to cpufreq-dt-platdev blocklist
  dt-bindings: cpufreq: qcom-hw: document Milos CPUFREQ Hardware
  rust: cpufreq: add __rust_helper to helpers
  rust: cpufreq: always inline functions using build_assert with arguments
2026-01-27 14:46:28 +01:00
Yilin Chen 11af6e102d rust: cpumask: rename methods of Cpumask for clarity and consistency
Rename `as_ref` and `as_mut_ref` to `from_raw` and `from_raw_mut` to
align with the established naming convention for constructing types
from raw pointers in the kernel's Rust codebase.

Signed-off-by: Yilin Chen <1479826151@qq.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2026-01-27 11:21:23 +05:30
Tamir Duberstein e05d9e5c8b rust: cpufreq: replace `kernel::c_str!` with C-Strings
C-String literals were added in Rust 1.77. Replace instances of
`kernel::c_str!` with C-String literals where possible.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2026-01-27 11:21:22 +05:30
Alexandre Courbot 8c8b12a556 rust: cpufreq: always inline functions using build_assert with arguments
`build_assert` relies on the compiler to optimize out its error path.
Functions using it with its arguments must thus always be inlined,
otherwise the error path of `build_assert` might not be optimized out,
triggering a build error.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2026-01-27 11:21:22 +05:30
Alexandre Courbot 209c70953a rust: transmute: implement FromBytes and AsBytes for inhabited ZSTs
This is useful when using types that may or may not be empty in generic
code relying on these traits. It is also safe because technically a
no-op.

Reviewed-by: Alistair Popple <apopple@nvidia.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20251215-transmute_unit-v4-1-477d71ec7c23@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-26 03:16:31 +01:00
Peter Novak 7f87c7a003 rust: use consistent backtick formatting for NULL in docs
Some doc comments use `NULL` while others use plain NULL.  Make it
consistent by adding backticks everywhere, matching the majority of
existing usage.

Signed-off-by: Peter Novak <seimun018r@gmail.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Acked-by: David Gow <davidgow@google.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20251130211233.367946-1-seimun018r@gmail.com
[ Reworded slightly. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-26 03:13:27 +01:00
Shivam Kalra 5016cae970 rust: num: bounded: clean __new documentation and comments
Following commit 3a1ec424dd ("rust: num: bounded: mark __new as
unsafe"), remove the redundant paragraph in the documentation of __new now
that the Safety section explicitly covers the requirement.

Additionally, add an INVARIANT comment inside the function body where
the Bounded instance is actually constructed to document that the type
invariant is upheld.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/rust-for-linux/CANiq72mUCUh72BWP4eD1PTDpwdb1ML+Xgfom-Ys6thJooqQPwQ@mail.gmail.com/
Signed-off-by: Shivam Kalra <shivamklr@cock.li>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260123132132.53854-1-shivamklr@cock.li
[ Reworded slightly. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-26 02:53:16 +01:00
Miguel Ojeda bd36f6e2ab rust: sync: atomic: Provide stub for `rusttest` 32-bit hosts
For arm32, on a x86_64 builder, running the `rusttest` target yields:

    error[E0080]: evaluation of constant value failed
      --> rust/kernel/static_assert.rs:37:23
       |
    37 |         const _: () = ::core::assert!($condition $(,$arg)?);
       |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: size_of::<isize>() == size_of::<isize_atomic_repr>()', rust/kernel/sync/atomic/predefine.rs:68:1
       |
      ::: rust/kernel/sync/atomic/predefine.rs:68:1
       |
    68 | static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>());
       | -------------------------------------------------------------------- in this macro invocation
       |
       = note: this error originates in the macro `::core::assert` which comes from the expansion of the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)

The reason is that `rusttest` runs on the host, so for e.g. a x86_64
builder `isize` is 64 bits but it is not a `CONFIG_64BIT` build.

Fix it by providing a stub for `rusttest` as usual.

Fixes: 84c6d36bca ("rust: sync: atomic: Add Atomic<{usize,isize}>")
Cc: stable@vger.kernel.org
Reviewed-by: Onur Özkan <work@onurozkan.dev>
Acked-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20260123233432.22703-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-26 02:18:58 +01:00
Ke Sun 880528eaa6 rust: block: mq: use pin_init::zeroed() for tag_set
Replace unsafe core::mem::zeroed() with pin_init::zeroed() for
blk_mq_tag_set initialization.

Signed-off-by: Ke Sun <sunke@kylinos.cn>
Acked-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/r/20260120083824.477339-4-sunke@kylinos.cn
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2026-01-21 07:37:15 -07:00
Ke Sun d7a4693a25 rust: block: mq: use pin_init::zeroed() for queue_limits
Replace unsafe core::mem::zeroed() with pin_init::zeroed() for
queue_limits initialization.

Signed-off-by: Ke Sun <sunke@kylinos.cn>
Acked-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/r/20260120083824.477339-3-sunke@kylinos.cn
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2026-01-21 07:37:15 -07:00
Onur Özkan 2ad6c5cdc8 rust: rbtree: reduce unsafe blocks on pointer derefs
Refactors parts of the get() and find_best_match()
traversal logic to minimize the scope of unsafe blocks
and avoid duplicating same safety comments.

One of the removed comments was also misleading:

    // SAFETY: `node` is a non-null node...
    Ordering::Equal => return Some(unsafe { &(*this).value }),

as `node` should have been `this`.

No functional changes intended; this is purely a safety
improvement that reduces the amount of unsafe blocks
while keeping all invariants intact.

[ Alice writes:

    "One consequence of creating a &_ to the bindings::rb_node struct means
    that we assert immutability for the entire struct and not just the
    rb_left/rb_right fields, but I have verified that this is ok."

      - Miguel ]

Signed-off-by: Onur Özkan <work@onurozkan.dev>
Reviewed-by: Charalampos Mitrodimas <charmitro@posteo.net>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20251113144547.502-1-work@onurozkan.dev
[ Reworded title and replaced `cursor_lower_bound()` with
  `find_best_match()` in message. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-19 09:38:10 +01:00
Tamir Duberstein 6c37b6841a rust: kunit: replace `kernel::c_str!` with C-Strings
C-String literals were added in Rust 1.77. Replace instances of
`kernel::c_str!` with C-String literals where possible.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Reviewed-by: David Gow <davidgow@google.com>
Link: https://patch.msgid.link/20251222-cstr-kunit-v1-1-39d999672f35@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-19 01:13:23 +01:00
Tamir Duberstein eeaad2f021 rust: i2c: replace `kernel::c_str!` with C-Strings
C-String literals were added in Rust 1.77. Replace instances of
`kernel::c_str!` with C-String literals where possible.

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Acked-by: Igor Korotin <igor.korotin.linux@gmail.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://patch.msgid.link/20251222-cstr-i2c-v1-1-df1c258d4615@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-19 01:13:22 +01:00
Alexandre Courbot 84b1b49ecc rust: ptr: replace unneeded use of `build_assert`
Since `ALIGN` is a const parameter, this assertion can be done in const
context using the `assert!` macro.

Suggested-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20251216-ptr_assert-v1-1-d8b2d5c5741d@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-19 01:13:22 +01:00
Alexandre Courbot 1b18b37a2c rust: build_assert: add instructions for use with function arguments
`build_assert` relies on the compiler to optimize out its error path,
lest build fails with the dreaded error:

    ERROR: modpost: "rust_build_error" [path/to/module.ko] undefined!

It has been observed that very trivial code performing I/O accesses
(sometimes even using an immediate value) would seemingly randomly fail
with this error whenever `CLIPPY=1` was set. The same behavior was also
observed until different, very similar conditions [1][2].

The cause appears to be that the failing function is eventually using
`build_assert` with its argument, but is only annotated with
`#[inline]`. This gives the compiler freedom to not inline the function,
which it notably did when Clippy was active, triggering the error.

The fix is to annotate functions passing their argument to
`build_assert` with `#[inline(always)]`, telling the compiler to be as
aggressive as possible with their inlining. This is also the correct
behavior as inlining is mandatory for correct behavior in these cases.

Add a paragraph instructing to annotate such functions with
`#[inline(always)]` in `build_assert`'s documentation, and split its
example to illustrate.

Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20251208-io-build-assert-v3-1-98aded02c1ea@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-19 01:13:22 +01:00
Alexandre Courbot 2af6ad09fc rust: num: bounded: add missing comment for always inlined function
This code is always inlined to avoid a build error if the error path of
`build_assert` cannot be optimized out. Add a comment justifying the
`#[inline(always)]` property to avoid it being taken away by mistake.

Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20251208-io-build-assert-v3-7-98aded02c1ea@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-18 20:40:12 +01:00
Alexandre Courbot d6ff6e8700 rust: sync: refcount: always inline functions using build_assert with arguments
`build_assert` relies on the compiler to optimize out its error path.
Functions using it with its arguments must thus always be inlined,
otherwise the error path of `build_assert` might not be optimized out,
triggering a build error.

Cc: stable@vger.kernel.org
Fixes: bb38f35b35 ("rust: implement `kernel::sync::Refcount`")
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251208-io-build-assert-v3-5-98aded02c1ea@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-18 20:40:12 +01:00
Alexandre Courbot 09c3c9112d rust: bits: always inline functions using build_assert with arguments
`build_assert` relies on the compiler to optimize out its error path.
Functions using it with its arguments must thus always be inlined,
otherwise the error path of `build_assert` might not be optimized out,
triggering a build error.

Cc: stable@vger.kernel.org
Fixes: cc84ef3b88 ("rust: bits: add support for bits/genmask macros")
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20251208-io-build-assert-v3-4-98aded02c1ea@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-18 20:40:11 +01:00
Benno Lossin d083a6214c rust: init: use `#[default_error(err)]` for the initializer macros
Initializer macros should use this attribute instead of manually parsing
the macro's input. This is because the syntax is now parsed using `syn`,
which permits more complex constructs to be parsed. In addition, this
ensures that the kernel's initializer marcos will have the exact same
syntax as the ones from pin-init.

Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Benno Lossin <lossin@kernel.org>
2026-01-17 10:51:42 +01:00
Benno Lossin 61d62ab08f rust: pin-init: remove `try_` versions of the initializer macros
The `try_[pin_]init!` versions of the initializer macros are
superfluous. Instead of forcing the user to always write an error in
`try_[pin_]init!` and not allowing one in `[pin_]init!`, combine them
into `[pin_]init!` that defaults the error to
`core::convert::Infallible`, but also allows to specify a custom one.

Projects using pin-init still can provide their own defaulting
initializers using the `try_` prefix by using the `#[default_error]`
attribute added in a future patch.

[ Adjust the definition of the kernel's version of the `try_`
  initializer macros - Benno]

Reviewed-by: Gary Guo <gary@garyguo.net>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Signed-off-by: Benno Lossin <lossin@kernel.org>
2026-01-17 10:49:31 +01:00
Danilo Krummrich a995fe1a3a rust: driver: drop device private data post unbind
Currently, the driver's device private data is allocated and initialized
from driver core code called from bus abstractions after the driver's
probe() callback returned the corresponding initializer.

Similarly, the driver's device private data is dropped within the
remove() callback of bus abstractions after calling the remove()
callback of the corresponding driver.

However, commit 6f61a2637a ("rust: device: introduce
Device::drvdata()") introduced an accessor for the driver's device
private data for a Device<Bound>, i.e. a device that is currently bound
to a driver.

Obviously, this is in conflict with dropping the driver's device private
data in remove(), since a device can not be considered to be fully
unbound after remove() has finished:

We also have to consider registrations guarded by devres - such as IRQ
or class device registrations - which are torn down after remove() in
devres_release_all().

Thus, it can happen that, for instance, a class device or IRQ callback
still calls Device::drvdata(), which then runs concurrently to remove()
(which sets dev->driver_data to NULL and drops the driver's device
private data), before devres_release_all() started to tear down the
corresponding registration. This is because devres guarded registrations
can, as expected, access the corresponding Device<Bound> that defines
their scope.

In C it simply is the driver's responsibility to ensure that its device
private data is freed after e.g. an IRQ registration is unregistered.

Typically, C drivers achieve this by allocating their device private data
with e.g. devm_kzalloc() before doing anything else, i.e. before e.g.
registering an IRQ with devm_request_threaded_irq(), relying on the
reverse order cleanup of devres.

Technically, we could do something similar in Rust. However, the
resulting code would be pretty messy:

In Rust we have to differentiate between allocated but uninitialized
memory and initialized memory in the type system. Thus, we would need to
somehow keep track of whether the driver's device private data object
has been initialized (i.e. probe() was successful and returned a valid
initializer for this memory) and conditionally call the destructor of
the corresponding object when it is freed.

This is because we'd need to allocate and register the memory of the
driver's device private data *before* it is initialized by the
initializer returned by the driver's probe() callback, because the
driver could already register devres guarded registrations within
probe() outside of the driver's device private data initializer.

Luckily there is a much simpler solution: Instead of dropping the
driver's device private data at the end of remove(), we just drop it
after the device has been fully unbound, i.e. after all devres callbacks
have been processed.

For this, we introduce a new post_unbind() callback private to the
driver-core, i.e. the callback is neither exposed to drivers, nor to bus
abstractions.

This way, the driver-core code can simply continue to conditionally
allocate the memory for the driver's device private data when the
driver's initializer is returned from probe() - no change needed - and
drop it when the driver-core code receives the post_unbind() callback.

Closes: https://lore.kernel.org/all/DEZMS6Y4A7XE.XE7EUBT5SJFJ@kernel.org/
Fixes: 6f61a2637a ("rust: device: introduce Device::drvdata()")
Acked-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Igor Korotin <igor.korotin.linux@gmail.com>
Link: https://patch.msgid.link/20260107103511.570525-7-dakr@kernel.org
[ Remove #ifdef CONFIG_RUST, rename post_unbind() to post_unbind_rust().
 - Danilo]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-01-16 01:17:29 +01:00
Danilo Krummrich 2ad0f490c2 rust: driver: add DriverData type to the DriverLayout trait
Add an associated type DriverData to the DriverLayout trait indicating
the type of the driver's device private data.

Acked-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Igor Korotin <igor.korotin.linux@gmail.com>
Link: https://patch.msgid.link/20260107103511.570525-6-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-01-16 01:17:29 +01:00
Danilo Krummrich c1d4519e1c rust: driver: add DEVICE_DRIVER_OFFSET to the DriverLayout trait
Add an associated const DEVICE_DRIVER_OFFSET to the DriverLayout trait
indicating the offset of the embedded struct device_driver within
Self::DriverType, i.e. the specific driver structs, such as struct
pci_driver or struct platform_driver.

Acked-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Igor Korotin <igor.korotin.linux@gmail.com>
Link: https://patch.msgid.link/20260107103511.570525-5-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-01-16 01:17:29 +01:00
Danilo Krummrich 0af1a9e462 rust: driver: introduce a DriverLayout trait
The DriverLayout trait describes the layout of a specific driver
structure, such as `struct pci_driver` or `struct platform_driver`.

In a first step, this replaces the associated type RegType of the
RegistrationOps with the DriverLayout::DriverType associated type.

Acked-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Igor Korotin <igor.korotin.linux@gmail.com>
Link: https://patch.msgid.link/20260107103511.570525-4-dakr@kernel.org
[ Rename driver::Driver to driver::DriverLayout, as it represents the
  layout of a driver structure rather than the driver structure itself.
  - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-01-16 01:16:44 +01:00
Danilo Krummrich 5f4476e983 rust: auxiliary: add Driver::unbind() callback
Add missing unbind() callback to auxiliary::Driver, since it will be
needed by drivers eventually (e.g. the Nova DRM driver).

Acked-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260107103511.570525-3-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-01-15 01:19:18 +01:00
Danilo Krummrich 4181aceb4a rust: i2c: do not drop device private data on shutdown()
We must not drop the device private data on shutdown(); none of the
registrations attached to devres that might access the device private
data are released before shutdown() is called.

Hence, freeing the device private data on shutdown() can cause UAF bugs.

Fixes: 57c5bd9aee ("rust: i2c: add basic I2C device and driver abstractions")
Acked-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Igor Korotin <igor.korotin.linux@gmail.com>
Link: https://patch.msgid.link/20260107103511.570525-2-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-01-15 01:18:34 +01:00
Alexandre Courbot 5d9c4c272b rust: irq: always inline functions using build_assert with arguments
`build_assert` relies on the compiler to optimize out its error path.
Functions using it with its arguments must thus always be inlined,
otherwise the error path of `build_assert` might not be optimized out,
triggering a build error.

Cc: stable@vger.kernel.org
Fixes: 746680ec66 ("rust: irq: add flags module")
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20251208-io-build-assert-v3-6-98aded02c1ea@nvidia.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-01-14 20:32:28 +01:00
Alexandre Courbot 33d19f6216 rust: io: always inline functions using build_assert with arguments
`build_assert` relies on the compiler to optimize out its error path.
Functions using it with its arguments must thus always be inlined,
otherwise the error path of `build_assert` might not be optimized out,
triggering a build error.

Cc: stable@vger.kernel.org
Fixes: ce30d94e68 ("rust: add `io::{Io, IoRaw}` base types")
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Timur Tabi <ttabi@nvidia.com>
Link: https://patch.msgid.link/20251208-io-build-assert-v3-2-98aded02c1ea@nvidia.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-01-14 20:30:26 +01:00
Linus Torvalds 0fa27899e0 Driver core fixes for 6.19-rc5
- Fix swapped example values for the `family` and `machine` attributes
   in the sysfs SoC bus ABI documentation.
 
 - Fix Rust build and intra-doc issues when optional subsystems
   (CONFIG_PCI, CONFIG_AUXILIARY_BUS, CONFIG_PRINTK) are disabled.
 
 - Fix typos and incorrect safety comments in Rust PCI, DMA, and device
   ID documentation.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQS2q/xV6QjXAdC7k+1FlHeO1qrKLgUCaWK1TwAKCRBFlHeO1qrK
 LlNtAP9a2C6HtdumNpYec5bbEIEAHuWIqH8DoypF0jlIP11E6QD+ONnmiWnlRyb+
 iJzTXy7EZfV+/zbszWLpQ6qiuX38vgo=
 =MZle
 -----END PGP SIGNATURE-----

Merge tag 'driver-core-6.19-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core

Pull driver core fixes from Danilo Krummrich:

 - Fix swapped example values for the `family` and `machine` attributes
   in the sysfs SoC bus ABI documentation

 - Fix Rust build and intra-doc issues when optional subsystems
   (CONFIG_PCI, CONFIG_AUXILIARY_BUS, CONFIG_PRINTK) are disabled

 - Fix typos and incorrect safety comments in Rust PCI, DMA, and
   device ID documentation

* tag 'driver-core-6.19-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core:
  rust: device: Remove explicit import of CStrExt
  rust: pci: fix typos in Bar struct's comments
  rust: device: fix broken intra-doc links
  rust: dma: fix broken intra-doc links
  rust: driver: fix broken intra-doc links to example driver types
  rust: device_id: replace incorrect word in safety documentation
  rust: dma: remove incorrect safety documentation
  docs: ABI: sysfs-devices-soc: Fix swapped sample values
2026-01-10 15:04:04 -10:00
Alice Ryhl ccf9e07011 rust: sync: Inline various lock related methods
While debugging a different issue [1], the following relocation was
noticed in the rust_binder.ko file:

	R_AARCH64_CALL26	_RNvXNtNtNtCsdfZWD8DztAw_6kernel4sync4lock8spinlockNtB2_15SpinLockBackendNtB4_7Backend6unlock

This relocation (and a similar one for lock) occurred many times
throughout the module. That is not really useful because all this
function does is call spin_unlock(), so what we actually want here is
that a call to spin_unlock() dirctly is generated in favor of this
wrapper method.

Thus, mark these methods inline.

[boqun: Reword the commit message a bit]

Link: https://lore.kernel.org/p/20251111-binder-fix-list-remove-v1-0-8ed14a0da63d@google.com
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251218-inline-lock-unlock-v2-1-fbadac8bd61b@google.com
2026-01-10 10:53:46 +08:00
FUJITA Tomonori 323e4bfcbe rust: list: Switch to kernel::sync atomic primitives
Convert uses of `AtomicBool` to `Atomic<bool>`.

Note that the compare_exchange migration simplifies to
`try_cmpxchg()`, since `try_cmpxchg()` provides relaxed ordering on
failure, making the explicit failure ordering unnecessary.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251230093718.1852322-3-fujita.tomonori@gmail.com
2026-01-09 19:01:41 +08:00
FUJITA Tomonori 4bac28727a rust: sync: atomic: Add atomic bool tests
Add tests for Atomic<bool> operations.

Atomic<bool> does not fit into the existing u8/16/32/64 tests so
introduce a dedicated test for it.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20260101034922.2020334-3-fujita.tomonori@gmail.com
2026-01-09 19:01:41 +08:00
FUJITA Tomonori 06bd0e52bf rust: sync: atomic: Add atomic bool support via i8 representation
Add `bool` support, `Atomic<bool>` by using `i8` as its underlying
representation.

Rust specifies that `bool` has size 1 and alignment 1 [1], so it
matches `i8` on layout; keep `static_assert!()` checks to enforce this
assumption at build time.

[boqun: Remove the unnecessary impl AtomicImpl for bool]

Link: https://doc.rust-lang.org/reference/types/boolean.html [1]
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20260101034922.2020334-2-fujita.tomonori@gmail.com
2026-01-09 19:01:41 +08:00
FUJITA Tomonori 584f286f82 rust: sync: atomic: Add i8/i16 xchg and cmpxchg support
Add atomic xchg and cmpxchg operation support for i8 and i16 types
with tests.

Note that since the current implementation of
Atomic::<{i8,i16}>::{load,store}() is READ_ONCE()/WRITE_ONCE()-based.
The atomicity between load/store and xchg/cmpxchg is only guaranteed if
the architecture has native RmW support, hence i8/i16 is currently
AtomicImpl only when CONFIG_ARCH_SUPPORTS_ATOMIC_RWM=y.

[boqun: Make i8/i16 AtomicImpl only when
CONFIG_ARCH_SUPPORTS_ATOMIC_RWM=y]

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251228120546.1602275-4-fujita.tomonori@gmail.com
2026-01-09 19:01:41 +08:00
FUJITA Tomonori 7b001c97d9 rust: sync: atomic: Add store_release/load_acquire tests
Add minimum store_release/load_acquire tests.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251211113826.1299077-5-fujita.tomonori@gmail.com
2026-01-09 19:01:41 +08:00
FUJITA Tomonori b33796d554 rust: sync: atomic: Add i8/i16 load and store support
Add atomic operation support for i8 and i16 types using volatile
read/write and smp_load_acquire/smp_store_release helpers.

[boqun: Adjust [1] to avoid introduction of
impl_atomic_only_load_and_store_ops!() in the middle]

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Link: https://lore.kernel.org/all/20251228120546.1602275-1-fujita.tomonori@gmail.com/ [1]
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251211113826.1299077-4-fujita.tomonori@gmail.com
2026-01-09 19:01:41 +08:00