mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:24:47 +01:00
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Cross-merge networking fixes after downstream PR (net-6.19-rc9). No adjacent changes, conflicts: drivers/net/ethernet/spacemit/k1_emac.c3125fc1701("net: spacemit: k1-emac: fix jumbo frame support")f66086798f("net: spacemit: Remove broken flow control support") https://lore.kernel.org/aYIysFIE9ooavWia@sirena.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
a182a62ff7
187 changed files with 1545 additions and 815 deletions
|
|
@ -383,6 +383,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
|
|||
-fno-inline-functions-called-once -fsanitize=bounds-strict \
|
||||
-fstrict-flex-arrays=% -fmin-function-alignment=% \
|
||||
-fzero-init-padding-bits=% -mno-fdpic \
|
||||
-fdiagnostics-show-context -fdiagnostics-show-context=% \
|
||||
--param=% --param asan-% -fno-isolate-erroneous-paths-dereference
|
||||
|
||||
# Derived from `scripts/Makefile.clang`.
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ macro_rules! impl_bit_fn {
|
|||
///
|
||||
/// This version is the default and should be used if `n` is known at
|
||||
/// compile time.
|
||||
#[inline]
|
||||
// Always inline to optimize out error path of `build_assert`.
|
||||
#[inline(always)]
|
||||
pub const fn [<bit_ $ty>](n: u32) -> $ty {
|
||||
build_assert!(n < <$ty>::BITS);
|
||||
(1 as $ty) << n
|
||||
|
|
@ -75,7 +76,8 @@ macro_rules! impl_genmask_fn {
|
|||
/// This version is the default and should be used if the range is known
|
||||
/// at compile time.
|
||||
$(#[$genmask_ex])*
|
||||
#[inline]
|
||||
// Always inline to optimize out error path of `build_assert`.
|
||||
#[inline(always)]
|
||||
pub const fn [<genmask_ $ty>](range: RangeInclusive<u32>) -> $ty {
|
||||
let start = *range.start();
|
||||
let end = *range.end();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
pub use core::fmt::{Arguments, Debug, Error, Formatter, Result, Write};
|
||||
|
||||
/// Internal adapter used to route allow implementations of formatting traits for foreign types.
|
||||
/// Internal adapter used to route and allow implementations of formatting traits for foreign types.
|
||||
///
|
||||
/// It is inserted automatically by the [`fmt!`] macro and is not meant to be used directly.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ fn fits_within<T: Integer>(value: T, num_bits: u32) -> bool {
|
|||
fits_within!(value, T, num_bits)
|
||||
}
|
||||
|
||||
/// An integer value that requires only the `N` less significant bits of the wrapped type to be
|
||||
/// An integer value that requires only the `N` least significant bits of the wrapped type to be
|
||||
/// encoded.
|
||||
///
|
||||
/// This limits the number of usable bits in the wrapped integer type, and thus the stored value to
|
||||
/// a narrower range, which provides guarantees that can be useful when working with in e.g.
|
||||
/// a narrower range, which provides guarantees that can be useful when working within e.g.
|
||||
/// bitfields.
|
||||
///
|
||||
/// # Invariants
|
||||
|
|
@ -56,7 +56,7 @@ fn fits_within<T: Integer>(value: T, num_bits: u32) -> bool {
|
|||
/// # Examples
|
||||
///
|
||||
/// The preferred way to create values is through constants and the [`Bounded::new`] family of
|
||||
/// constructors, as they trigger a build error if the type invariants cannot be withheld.
|
||||
/// constructors, as they trigger a build error if the type invariants cannot be upheld.
|
||||
///
|
||||
/// ```
|
||||
/// use kernel::num::Bounded;
|
||||
|
|
@ -82,7 +82,7 @@ fn fits_within<T: Integer>(value: T, num_bits: u32) -> bool {
|
|||
/// ```
|
||||
/// use kernel::num::Bounded;
|
||||
///
|
||||
/// // This succeeds because `15` can be represented with 4 unsigned bits.
|
||||
/// // This succeeds because `15` can be represented with 4 unsigned bits.
|
||||
/// assert!(Bounded::<u8, 4>::try_new(15).is_some());
|
||||
///
|
||||
/// // This fails because `16` cannot be represented with 4 unsigned bits.
|
||||
|
|
@ -221,7 +221,7 @@ fn fits_within<T: Integer>(value: T, num_bits: u32) -> bool {
|
|||
/// let v: Option<Bounded<u16, 8>> = 128u32.try_into_bounded();
|
||||
/// assert_eq!(v.as_deref().copied(), Some(128));
|
||||
///
|
||||
/// // Fails because `128` doesn't fits into 6 bits.
|
||||
/// // Fails because `128` doesn't fit into 6 bits.
|
||||
/// let v: Option<Bounded<u16, 6>> = 128u32.try_into_bounded();
|
||||
/// assert_eq!(v, None);
|
||||
/// ```
|
||||
|
|
@ -259,9 +259,9 @@ macro_rules! impl_const_new {
|
|||
assert!(fits_within!(VALUE, $type, N));
|
||||
}
|
||||
|
||||
// INVARIANT: `fits_within` confirmed that `VALUE` can be represented within
|
||||
// SAFETY: `fits_within` confirmed that `VALUE` can be represented within
|
||||
// `N` bits.
|
||||
Self::__new(VALUE)
|
||||
unsafe { Self::__new(VALUE) }
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
|
@ -282,9 +282,10 @@ where
|
|||
/// All instances of [`Bounded`] must be created through this method as it enforces most of the
|
||||
/// type invariants.
|
||||
///
|
||||
/// The caller remains responsible for checking, either statically or dynamically, that `value`
|
||||
/// can be represented as a `T` using at most `N` bits.
|
||||
const fn __new(value: T) -> Self {
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must ensure that `value` can be represented within `N` bits.
|
||||
const unsafe fn __new(value: T) -> Self {
|
||||
// Enforce the type invariants.
|
||||
const {
|
||||
// `N` cannot be zero.
|
||||
|
|
@ -293,6 +294,7 @@ where
|
|||
assert!(N <= T::BITS);
|
||||
}
|
||||
|
||||
// INVARIANT: The caller ensures `value` fits within `N` bits.
|
||||
Self(value)
|
||||
}
|
||||
|
||||
|
|
@ -328,8 +330,8 @@ where
|
|||
/// ```
|
||||
pub fn try_new(value: T) -> Option<Self> {
|
||||
fits_within(value, N).then(|| {
|
||||
// INVARIANT: `fits_within` confirmed that `value` can be represented within `N` bits.
|
||||
Self::__new(value)
|
||||
// SAFETY: `fits_within` confirmed that `value` can be represented within `N` bits.
|
||||
unsafe { Self::__new(value) }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -363,6 +365,7 @@ where
|
|||
/// assert_eq!(Bounded::<u8, 1>::from_expr(1).get(), 1);
|
||||
/// assert_eq!(Bounded::<u16, 8>::from_expr(0xff).get(), 0xff);
|
||||
/// ```
|
||||
// Always inline to optimize out error path of `build_assert`.
|
||||
#[inline(always)]
|
||||
pub fn from_expr(expr: T) -> Self {
|
||||
crate::build_assert!(
|
||||
|
|
@ -370,8 +373,8 @@ where
|
|||
"Requested value larger than maximal representable value."
|
||||
);
|
||||
|
||||
// INVARIANT: `fits_within` confirmed that `expr` can be represented within `N` bits.
|
||||
Self::__new(expr)
|
||||
// SAFETY: `fits_within` confirmed that `expr` can be represented within `N` bits.
|
||||
unsafe { Self::__new(expr) }
|
||||
}
|
||||
|
||||
/// Returns the wrapped value as the backing type.
|
||||
|
|
@ -410,9 +413,9 @@ where
|
|||
);
|
||||
}
|
||||
|
||||
// INVARIANT: The value did fit within `N` bits, so it will all the more fit within
|
||||
// SAFETY: The value did fit within `N` bits, so it will all the more fit within
|
||||
// the larger `M` bits.
|
||||
Bounded::__new(self.0)
|
||||
unsafe { Bounded::__new(self.0) }
|
||||
}
|
||||
|
||||
/// Attempts to shrink the number of bits usable for `self`.
|
||||
|
|
@ -466,9 +469,9 @@ where
|
|||
// `U` and `T` have the same sign, hence this conversion cannot fail.
|
||||
let value = unsafe { U::try_from(self.get()).unwrap_unchecked() };
|
||||
|
||||
// INVARIANT: Although the backing type has changed, the value is still represented within
|
||||
// SAFETY: Although the backing type has changed, the value is still represented within
|
||||
// `N` bits, and with the same signedness.
|
||||
Bounded::__new(value)
|
||||
unsafe { Bounded::__new(value) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -501,7 +504,7 @@ where
|
|||
/// let v: Option<Bounded<u16, 8>> = 128u32.try_into_bounded();
|
||||
/// assert_eq!(v.as_deref().copied(), Some(128));
|
||||
///
|
||||
/// // Fails because `128` doesn't fits into 6 bits.
|
||||
/// // Fails because `128` doesn't fit into 6 bits.
|
||||
/// let v: Option<Bounded<u16, 6>> = 128u32.try_into_bounded();
|
||||
/// assert_eq!(v, None);
|
||||
/// ```
|
||||
|
|
@ -944,9 +947,9 @@ macro_rules! impl_from_primitive {
|
|||
Self: AtLeastXBits<{ <$type as Integer>::BITS as usize }>,
|
||||
{
|
||||
fn from(value: $type) -> Self {
|
||||
// INVARIANT: The trait bound on `Self` guarantees that `N` bits is
|
||||
// SAFETY: The trait bound on `Self` guarantees that `N` bits is
|
||||
// enough to hold any value of the source type.
|
||||
Self::__new(T::from(value))
|
||||
unsafe { Self::__new(T::from(value)) }
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
|
@ -1051,8 +1054,8 @@ where
|
|||
T: Integer + From<bool>,
|
||||
{
|
||||
fn from(value: bool) -> Self {
|
||||
// INVARIANT: A boolean can be represented using a single bit, and thus fits within any
|
||||
// SAFETY: A boolean can be represented using a single bit, and thus fits within any
|
||||
// integer type for any `N` > 0.
|
||||
Self::__new(T::from(value))
|
||||
unsafe { Self::__new(T::from(value)) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -985,7 +985,7 @@ impl<'a, K, V> CursorMut<'a, K, V> {
|
|||
self.peek(Direction::Prev)
|
||||
}
|
||||
|
||||
/// Access the previous node without moving the cursor.
|
||||
/// Access the next node without moving the cursor.
|
||||
pub fn peek_next(&self) -> Option<(&K, &V)> {
|
||||
self.peek(Direction::Next)
|
||||
}
|
||||
|
|
@ -1130,7 +1130,7 @@ pub struct IterMut<'a, K, V> {
|
|||
}
|
||||
|
||||
// SAFETY: The [`IterMut`] has exclusive access to both `K` and `V`, so it is sufficient to require them to be `Send`.
|
||||
// The iterator only gives out immutable references to the keys, but since the iterator has excusive access to those same
|
||||
// The iterator only gives out immutable references to the keys, but since the iterator has exclusive access to those same
|
||||
// keys, `Send` is sufficient. `Sync` would be okay, but it is more restrictive to the user.
|
||||
unsafe impl<'a, K: Send, V: Send> Send for IterMut<'a, K, V> {}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,12 +35,23 @@ unsafe impl super::AtomicAdd<i64> for i64 {
|
|||
// as `isize` and `usize`, and `isize` and `usize` are always bi-directional transmutable to
|
||||
// `isize_atomic_repr`, which also always implements `AtomicImpl`.
|
||||
#[allow(non_camel_case_types)]
|
||||
#[cfg(not(testlib))]
|
||||
#[cfg(not(CONFIG_64BIT))]
|
||||
type isize_atomic_repr = i32;
|
||||
#[allow(non_camel_case_types)]
|
||||
#[cfg(not(testlib))]
|
||||
#[cfg(CONFIG_64BIT)]
|
||||
type isize_atomic_repr = i64;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[cfg(testlib)]
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
type isize_atomic_repr = i32;
|
||||
#[allow(non_camel_case_types)]
|
||||
#[cfg(testlib)]
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
type isize_atomic_repr = i64;
|
||||
|
||||
// Ensure size and alignment requirements are checked.
|
||||
static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>());
|
||||
static_assert!(align_of::<isize>() == align_of::<isize_atomic_repr>());
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ impl Refcount {
|
|||
/// Construct a new [`Refcount`] from an initial value.
|
||||
///
|
||||
/// The initial value should be non-saturated.
|
||||
#[inline]
|
||||
// Always inline to optimize out error path of `build_assert`.
|
||||
#[inline(always)]
|
||||
pub fn new(value: i32) -> Self {
|
||||
build_assert!(value >= 0, "initial value saturated");
|
||||
// SAFETY: There are no safety requirements for this FFI call.
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ pub(crate) fn fmt(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
(None, acc)
|
||||
})();
|
||||
args.extend(quote_spanned!(first_span => #lhs #adapter(&#rhs)));
|
||||
args.extend(quote_spanned!(first_span => #lhs #adapter(&(#rhs))));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ use proc_macro::TokenStream;
|
|||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// ```ignore
|
||||
/// use kernel::prelude::*;
|
||||
///
|
||||
/// module!{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
// When fixdep scans this, it will find this string `CONFIG_RUSTC_VERSION_TEXT`
|
||||
// and thus add a dependency on `include/config/RUSTC_VERSION_TEXT`, which is
|
||||
// touched by Kconfig when the version string from the compiler changes.
|
||||
|
||||
//! [![github]](https://github.com/dtolnay/proc-macro2) [![crates-io]](https://crates.io/crates/proc-macro2) [![docs-rs]](crate)
|
||||
//!
|
||||
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue