Skip to content

Commit 9ff7a2d

Browse files
committed
Minor changes done to harmonize with Linux kernel v6.11
1 parent 8a15dce commit 9ff7a2d

File tree

9 files changed

+157
-46
lines changed

9 files changed

+157
-46
lines changed

config/HARMONIZED_LINUX_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.10
1+
6.11

config/PROGRAM_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.0
1+
1.5.0

src/include/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ extern unsigned int external_clk; // "
139139
#define __must_check
140140
#define __attribute_const__
141141
#define __force
142+
#define compiletime_assert static_assert
142143

143144
struct netlink_ext_ack {}; // Unused null declaration
144145

src/kernel/drivers/net/can/sja1000/plx_pci.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ struct plx_pci_card {
145145
#define TEWS_PCI_VENDOR_ID 0x1498
146146
#define TEWS_PCI_DEVICE_ID_TMPC810 0x032A
147147

148-
#define CTI_PCI_VENDOR_ID 0x12c4
149148
#define CTI_PCI_DEVICE_ID_CRG001 0x0900
150149

151150
#define MOXA_PCI_VENDOR_ID 0x1393
@@ -381,7 +380,7 @@ static const struct pci_device_id plx_pci_tbl[] = {
381380
{
382381
/* Connect Tech Inc. CANpro/104-Plus Opto (CRG001) card */
383382
PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030,
384-
CTI_PCI_VENDOR_ID, CTI_PCI_DEVICE_ID_CRG001,
383+
PCI_SUBVENDOR_ID_CONNECT_TECH, CTI_PCI_DEVICE_ID_CRG001,
385384
0, 0,
386385
(kernel_ulong_t)&plx_pci_card_info_cti
387386
},

src/kernel/include/linux/compiler.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,22 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
220220
* This data_race() macro is useful for situations in which data races
221221
* should be forgiven. One example is diagnostic code that accesses
222222
* shared variables but is not a part of the core synchronization design.
223+
* For example, if accesses to a given variable are protected by a lock,
224+
* except for diagnostic code, then the accesses under the lock should
225+
* be plain C-language accesses and those in the diagnostic code should
226+
* use data_race(). This way, KCSAN will complain if buggy lockless
227+
* accesses to that variable are introduced, even if the buggy accesses
228+
* are protected by READ_ONCE() or WRITE_ONCE().
223229
*
224230
* This macro *does not* affect normal code generation, but is a hint
225-
* to tooling that data races here are to be ignored.
231+
* to tooling that data races here are to be ignored. If the access must
232+
* be atomic *and* KCSAN should ignore the access, use both data_race()
233+
* and READ_ONCE(), for example, data_race(READ_ONCE(x)).
226234
*/
227235
#define data_race(expr) \
228236
({ \
229-
__unqual_scalar_typeof(({ expr; })) __v = ({ \
230-
__kcsan_disable_current(); \
231-
expr; \
232-
}); \
237+
__kcsan_disable_current(); \
238+
__auto_type __v = (expr); \
233239
__kcsan_enable_current(); \
234240
__v; \
235241
})
@@ -316,6 +322,15 @@ static inline void *offset_to_ptr(const int *off)
316322
#define is_signed_type(type) (((type)(-1)) < (__force type)1)
317323
#define is_unsigned_type(type) (!is_signed_type(type))
318324

325+
/*
326+
* Useful shorthand for "is this condition known at compile-time?"
327+
*
328+
* Note that the condition may involve non-constant values,
329+
* but the compiler may know enough about the details of the
330+
* values to determine that the condition is statically true.
331+
*/
332+
#define statically_true(x) (__builtin_constant_p(x) && (x))
333+
319334
/*
320335
* This is needed in functions which generate the stack canary, see
321336
* arch/x86/kernel/smpboot.c::start_secondary() for an example.

src/kernel/include/linux/math.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ struct type##_fract { \
138138
__##type numerator; \
139139
__##type denominator; \
140140
};
141+
__STRUCT_FRACT(s8)
142+
__STRUCT_FRACT(u8)
141143
__STRUCT_FRACT(s16)
142144
__STRUCT_FRACT(u16)
143145
__STRUCT_FRACT(s32)

src/kernel/include/linux/math64.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,19 @@ u64 mul_u64_u64_div_u64(u64 a, u64 mul, u64 div);
321321
#define DIV64_U64_ROUND_UP(ll, d) \
322322
({ u64 _tmp = (d); div64_u64((ll) + _tmp - 1, _tmp); })
323323

324+
/**
325+
* DIV_U64_ROUND_UP - unsigned 64bit divide with 32bit divisor rounded up
326+
* @ll: unsigned 64bit dividend
327+
* @d: unsigned 32bit divisor
328+
*
329+
* Divide unsigned 64bit dividend by unsigned 32bit divisor
330+
* and round up.
331+
*
332+
* Return: dividend / divisor rounded up
333+
*/
334+
#define DIV_U64_ROUND_UP(ll, d) \
335+
({ u32 _tmp = (d); div_u64((ll) + _tmp - 1, _tmp); })
336+
324337
/**
325338
* DIV64_U64_ROUND_CLOSEST - unsigned 64bit divide with 64bit divisor rounded to nearest integer
326339
* @dividend: unsigned 64bit dividend
@@ -366,4 +379,19 @@ u64 mul_u64_u64_div_u64(u64 a, u64 mul, u64 div);
366379
div_s64((__x - (__d / 2)), __d); \
367380
} \
368381
)
382+
383+
/**
384+
* roundup_u64 - Round up a 64bit value to the next specified 32bit multiple
385+
* @x: the value to up
386+
* @y: 32bit multiple to round up to
387+
*
388+
* Rounds @x to the next multiple of @y. For 32bit @x values, see roundup and
389+
* the faster round_up() for powers of 2.
390+
*
391+
* Return: rounded up value.
392+
*/
393+
static inline u64 roundup_u64(u64 x, u32 y)
394+
{
395+
return DIV_U64_ROUND_UP(x, y) * y;
396+
}
369397
#endif /* _LINUX_MATH64_H */

src/kernel/include/linux/minmax.h

Lines changed: 98 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -48,56 +48,100 @@
4848
#define __typecheck(x, y) \
4949
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
5050

51-
/* is_signed_type() isn't a constexpr for pointer types */
52-
#define __is_signed(x) \
53-
__builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
54-
is_signed_type(typeof(x)), 0)
51+
/*
52+
* __sign_use for integer expressions:
53+
* bit #0 set if ok for unsigned comparisons
54+
* bit #1 set if ok for signed comparisons
55+
*
56+
* In particular, statically non-negative signed integer
57+
* expressions are ok for both.
58+
*
59+
* NOTE! Unsigned types smaller than 'int' are implicitly
60+
* converted to 'int' in expressions, and are accepted for
61+
* signed conversions for now. This is debatable.
62+
*
63+
* Note that 'x' is the original expression, and 'ux' is
64+
* the unique variable that contains the value.
65+
*
66+
* We use 'ux' for pure type checking, and 'x' for when
67+
* we need to look at the value (but without evaluating
68+
* it for side effects! Careful to only ever evaluate it
69+
* with sizeof() or __builtin_constant_p() etc).
70+
*
71+
* Pointers end up being checked by the normal C type
72+
* rules at the actual comparison, and these expressions
73+
* only need to be careful to not cause warnings for
74+
* pointer use.
75+
*/
76+
#define __signed_type_use(x,ux) (2+__is_nonneg(x,ux))
77+
#define __unsigned_type_use(x,ux) (1+2*(sizeof(ux)<4))
78+
#define __sign_use(x,ux) (is_signed_type(typeof(ux))? \
79+
__signed_type_use(x,ux):__unsigned_type_use(x,ux))
80+
81+
/*
82+
* To avoid warnings about casting pointers to integers
83+
* of different sizes, we need that special sign type.
84+
*
85+
* On 64-bit we can just always use 'long', since any
86+
* integer or pointer type can just be cast to that.
87+
*
88+
* This does not work for 128-bit signed integers since
89+
* the cast would truncate them, but we do not use s128
90+
* types in the kernel (we do use 'u128', but they will
91+
* be handled by the !is_signed_type() case).
92+
*
93+
* NOTE! The cast is there only to avoid any warnings
94+
* from when values that aren't signed integer types.
95+
*/
96+
#ifdef CONFIG_64BIT
97+
#define __signed_type(ux) long
98+
#else
99+
#define __signed_type(ux) typeof(__builtin_choose_expr(sizeof(ux)>4,1LL,1L))
100+
#endif
101+
#define __is_nonneg(x,ux) statically_true((__signed_type(ux))(x)>=0)
55102

56-
/* True for a non-negative signed int constant */
57-
#define __is_noneg_int(x) \
58-
(__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
103+
#define __types_ok(x,y,ux,uy) \
104+
(__sign_use(x,ux) & __sign_use(y,uy))
59105

60-
#define __types_ok(x, y) \
61-
(__is_signed(x) == __is_signed(y) || \
62-
__is_signed((x) + 0) == __is_signed((y) + 0) || \
63-
__is_noneg_int(x) || __is_noneg_int(y))
106+
#define __types_ok3(x,y,z,ux,uy,uz) \
107+
(__sign_use(x,ux) & __sign_use(y,uy) & __sign_use(z,uz))
64108

65109
#define __cmp_op_min <
66110
#define __cmp_op_max >
67111

68112
#define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
69113

70-
#define __cmp_once(op, x, y, unique_x, unique_y) ({ \
71-
typeof(x) unique_x = (x); \
72-
typeof(y) unique_y = (y); \
73-
static_assert(__types_ok(x, y), \
74-
#op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \
75-
__cmp(op, unique_x, unique_y); })
114+
#define __cmp_once_unique(op, type, x, y, ux, uy) \
115+
({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
116+
117+
#define __cmp_once(op, type, x, y) \
118+
__cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
76119

77-
#define __careful_cmp(op, x, y) \
78-
__builtin_choose_expr(__is_constexpr((x) - (y)), \
79-
__cmp(op, x, y), \
80-
__cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
120+
#define __careful_cmp_once(op, x, y, ux, uy) ({ \
121+
__auto_type ux = (x); __auto_type uy = (y); \
122+
BUILD_BUG_ON_MSG(!__types_ok(x,y,ux,uy), \
123+
#op"("#x", "#y") signedness error"); \
124+
__cmp(op, ux, uy); })
125+
126+
#define __careful_cmp(op, x, y) \
127+
__careful_cmp_once(op, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
81128

82129
#define __clamp(val, lo, hi) \
83130
((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
84131

85-
#define __clamp_once(val, lo, hi, unique_val, unique_lo, unique_hi) ({ \
86-
typeof(val) unique_val = (val); \
87-
typeof(lo) unique_lo = (lo); \
88-
typeof(hi) unique_hi = (hi); \
132+
#define __clamp_once(val, lo, hi, uval, ulo, uhi) ({ \
133+
__auto_type uval = (val); \
134+
__auto_type ulo = (lo); \
135+
__auto_type uhi = (hi); \
89136
static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \
90137
(lo) <= (hi), true), \
91138
"clamp() low limit " #lo " greater than high limit " #hi); \
92-
static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error"); \
93-
static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error"); \
94-
__clamp(unique_val, unique_lo, unique_hi); })
139+
BUILD_BUG_ON_MSG(!__types_ok3(val,lo,hi,uval,ulo,uhi), \
140+
"clamp("#val", "#lo", "#hi") signedness error"); \
141+
__clamp(uval, ulo, uhi); })
95142

96-
#define __careful_clamp(val, lo, hi) ({ \
97-
__builtin_choose_expr(__is_constexpr((val) - (lo) + (hi)), \
98-
__clamp(val, lo, hi), \
99-
__clamp_once(val, lo, hi, __UNIQUE_ID(__val), \
100-
__UNIQUE_ID(__lo), __UNIQUE_ID(__hi))); })
143+
#define __careful_clamp(val, lo, hi) \
144+
__clamp_once(val, lo, hi, __UNIQUE_ID(v_), __UNIQUE_ID(l_), __UNIQUE_ID(h_))
101145

102146
#ifndef __QNX__
103147
/**
@@ -132,21 +176,29 @@
132176
#define umax(x, y) \
133177
__careful_cmp(max, (x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull)
134178

179+
#define __careful_op3(op, x, y, z, ux, uy, uz) ({ \
180+
__auto_type ux = (x); __auto_type uy = (y);__auto_type uz = (z);\
181+
BUILD_BUG_ON_MSG(!__types_ok3(x,y,z,ux,uy,uz), \
182+
#op"3("#x", "#y", "#z") signedness error"); \
183+
__cmp(op, ux, __cmp(op, uy, uz)); })
184+
135185
/**
136186
* min3 - return minimum of three values
137187
* @x: first value
138188
* @y: second value
139189
* @z: third value
140190
*/
141-
#define min3(x, y, z) min((typeof(x))min(x, y), z)
191+
#define min3(x, y, z) \
192+
__careful_op3(min, x, y, z, __UNIQUE_ID(x_), __UNIQUE_ID(y_), __UNIQUE_ID(z_))
142193

143194
/**
144195
* max3 - return maximum of three values
145196
* @x: first value
146197
* @y: second value
147198
* @z: third value
148199
*/
149-
#define max3(x, y, z) max((typeof(x))max(x, y), z)
200+
#define max3(x, y, z) \
201+
__careful_op3(max, x, y, z, __UNIQUE_ID(x_), __UNIQUE_ID(y_), __UNIQUE_ID(z_))
150202

151203
/**
152204
* min_not_zero - return the minimum that is _not_ zero, unless both are zero
@@ -182,15 +234,15 @@
182234
* @x: first value
183235
* @y: second value
184236
*/
185-
#define min_t(type, x, y) __careful_cmp(min, (type)(x), (type)(y))
237+
#define min_t(type, x, y) __cmp_once(min, type, x, y)
186238

187239
/**
188240
* max_t - return maximum of two values, using the specified type
189241
* @type: data type to use
190242
* @x: first value
191243
* @y: second value
192244
*/
193-
#define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
245+
#define max_t(type, x, y) __cmp_once(max, type, x, y)
194246

195247
/*
196248
* Do not check the array parameter using __must_be_array().
@@ -294,4 +346,13 @@ static inline bool in_range32(u32 val, u32 start, u32 len)
294346
#define swap(a, b) \
295347
do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
296348

349+
/*
350+
* Use these carefully: no type checking, and uses the arguments
351+
* multiple times. Use for obvious constants only.
352+
*/
353+
#define MIN(a,b) __cmp(min,a,b)
354+
#define MAX(a,b) __cmp(max,a,b)
355+
#define MIN_T(type,a,b) __cmp(min,(type)(a),(type)(b))
356+
#define MAX_T(type,a,b) __cmp(max,(type)(a),(type)(b))
357+
297358
#endif /* _LINUX_MINMAX_H */

src/kernel/include/linux/pci_ids.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,8 @@
21502150

21512151
#define PCI_VENDOR_ID_CHELSIO 0x1425
21522152

2153+
#define PCI_VENDOR_ID_EDIMAX 0x1432
2154+
21532155
#define PCI_VENDOR_ID_ADLINK 0x144a
21542156

21552157
#define PCI_VENDOR_ID_SAMSUNG 0x144d
@@ -2623,6 +2625,8 @@
26232625

26242626
#define PCI_VENDOR_ID_HYGON 0x1d94
26252627

2628+
#define PCI_VENDOR_ID_META 0x1d9b
2629+
26262630
#define PCI_VENDOR_ID_FUNGIBLE 0x1dad
26272631

26282632
#define PCI_VENDOR_ID_HXT 0x1dbf
@@ -3136,6 +3140,7 @@
31363140
#define PCI_DEVICE_ID_INTEL_HDA_LNL_P 0xa828
31373141
#define PCI_DEVICE_ID_INTEL_S21152BB 0xb152
31383142
#define PCI_DEVICE_ID_INTEL_HDA_BMG 0xe2f7
3143+
#define PCI_DEVICE_ID_INTEL_HDA_PTL 0xe428
31393144
#define PCI_DEVICE_ID_INTEL_HDA_CML_R 0xf0c8
31403145
#define PCI_DEVICE_ID_INTEL_HDA_RKL_S 0xf1c8
31413146

0 commit comments

Comments
 (0)