linux-next: build failure after merge of the rust tree
Hi all,
After merging the rust tree, today's linux-next build (x86_64 allmodconfig) failed like this:
error[E0277]: the trait bound u32: From<DmaTrfCmdSize> is not satisfied
--> drivers/gpu/nova-core/regs/macros.rs:310:26
|
310 | let value = (u32::from(value) << SHIFT) & MASK;
| ^^^ the trait `From<DmaTrfCmdSize>` is not implemented for `u32`
|
::: drivers/gpu/nova-core/regs.rs:240:1
|
240 | / register!(NV_PFALCON_FALCON_DMATRFCMD @ +0x00000118 {
241 | | 0:0 full as bool;
242 | | 1:1 idle as bool;
243 | | 3:2 sec as u8;
... |
248 | | 16:16 set_dmtag as u8;
249 | | });
| |__- in this macro invocation
|
= help: the following other types implement trait `From<T>`:
`u32` implements `From<Char>`
`u32` implements `From<CpuId>`
`u32` implements `From<Ipv4Addr>`
`u32` implements `From<NV_FUSE_OPT_FPF_GSP_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_NVDEC_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_SEC2_UCODE1_VERSION>`
`u32` implements `From<NV_PBUS_SW_SCRATCH_0E>`
`u32` implements `From<NV_PDISP_VGA_WORKSPACE_BASE>`
and 41 others
= note: this error originates in the macro `register` (in Nightly builds, run with -Z macro-backtrace for more info)error[E0277]: the trait bound u32: From<FalconCoreRev> is not satisfied
--> drivers/gpu/nova-core/regs/macros.rs:310:26
|
310 | let value = (u32::from(value) << SHIFT) & MASK;
| ^^^ the trait `From<FalconCoreRev>` is not implemented for `u32`
|
::: drivers/gpu/nova-core/regs.rs:259:1
|
259 | / register!(NV_PFALCON_FALCON_HWCFG1 @ +0x0000012c {
260 | | 3:0 core_rev as u8 ?=> FalconCoreRev, "Core revision";
261 | | 5:4 security_model as u8 ?=> FalconSecurityModel, "Security model";
262 | | 7:6 core_rev_subversion as u8 ?=> FalconCoreRevSubversion, "Core revision subversion";
263 | | });
| |__- in this macro invocation
|
= help: the following other types implement trait `From<T>`:
`u32` implements `From<Char>`
`u32` implements `From<CpuId>`
`u32` implements `From<Ipv4Addr>`
`u32` implements `From<NV_FUSE_OPT_FPF_GSP_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_NVDEC_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_SEC2_UCODE1_VERSION>`
`u32` implements `From<NV_PBUS_SW_SCRATCH_0E>`
`u32` implements `From<NV_PDISP_VGA_WORKSPACE_BASE>`
and 41 others
= note: this error originates in the macro `register` (in Nightly builds, run with -Z macro-backtrace for more info)error[E0277]: the trait bound u32: From<FalconSecurityModel> is not satisfied
--> drivers/gpu/nova-core/regs/macros.rs:310:26
|
310 | let value = (u32::from(value) << SHIFT) & MASK;
| ^^^ the trait `From<FalconSecurityModel>` is not implemented for `u32`
|
::: drivers/gpu/nova-core/regs.rs:259:1
|
259 | / register!(NV_PFALCON_FALCON_HWCFG1 @ +0x0000012c {
260 | | 3:0 core_rev as u8 ?=> FalconCoreRev, "Core revision";
261 | | 5:4 security_model as u8 ?=> FalconSecurityModel, "Security model";
262 | | 7:6 core_rev_subversion as u8 ?=> FalconCoreRevSubversion, "Core revision subversion";
263 | | });
| |__- in this macro invocation
|
= help: the following other types implement trait `From<T>`:
`u32` implements `From<Char>`
`u32` implements `From<CpuId>`
`u32` implements `From<Ipv4Addr>`
`u32` implements `From<NV_FUSE_OPT_FPF_GSP_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_NVDEC_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_SEC2_UCODE1_VERSION>`
`u32` implements `From<NV_PBUS_SW_SCRATCH_0E>`
`u32` implements `From<NV_PDISP_VGA_WORKSPACE_BASE>`
and 41 others
= note: this error originates in the macro `register` (in Nightly builds, run with -Z macro-backtrace for more info)error[E0277]: the trait bound u32: From<FalconCoreRevSubversion> is not satisfied
--> drivers/gpu/nova-core/regs/macros.rs:310:26
|
310 | let value = (u32::from(value) << SHIFT) & MASK;
| ^^^ the trait `From<FalconCoreRevSubversion>` is not implemented for `u32`
|
::: drivers/gpu/nova-core/regs.rs:259:1
|
259 | / register!(NV_PFALCON_FALCON_HWCFG1 @ +0x0000012c {
260 | | 3:0 core_rev as u8 ?=> FalconCoreRev, "Core revision";
261 | | 5:4 security_model as u8 ?=> FalconSecurityModel, "Security model";
262 | | 7:6 core_rev_subversion as u8 ?=> FalconCoreRevSubversion, "Core revision subversion";
263 | | });
| |__- in this macro invocation
|
= help: the following other types implement trait `From<T>`:
`u32` implements `From<Char>`
`u32` implements `From<CpuId>`
`u32` implements `From<Ipv4Addr>`
`u32` implements `From<NV_FUSE_OPT_FPF_GSP_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_NVDEC_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_SEC2_UCODE1_VERSION>`
`u32` implements `From<NV_PBUS_SW_SCRATCH_0E>`
`u32` implements `From<NV_PDISP_VGA_WORKSPACE_BASE>`
and 41 others
= note: this error originates in the macro `register` (in Nightly builds, run with -Z macro-backtrace for more info)error[E0277]: the trait bound u32: From<FalconFbifTarget> is not satisfied
--> drivers/gpu/nova-core/regs/macros.rs:310:26
|
310 | let value = (u32::from(value) << SHIFT) & MASK;
| ^^^ the trait `From<FalconFbifTarget>` is not implemented for `u32`
|
::: drivers/gpu/nova-core/regs.rs:276:1
|
276 | / register!(NV_PFALCON_FBIF_TRANSCFG @ +0x00000600 {
277 | | 1:0 target as u8 ?=> FalconFbifTarget;
278 | | 2:2 mem_type as bool => FalconFbifMemType;
279 | | });
| |__- in this macro invocation
|
= help: the following other types implement trait `From<T>`:
`u32` implements `From<Char>`
`u32` implements `From<CpuId>`
`u32` implements `From<Ipv4Addr>`
`u32` implements `From<NV_FUSE_OPT_FPF_GSP_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_NVDEC_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_SEC2_UCODE1_VERSION>`
`u32` implements `From<NV_PBUS_SW_SCRATCH_0E>`
`u32` implements `From<NV_PDISP_VGA_WORKSPACE_BASE>`
and 41 others
= note: this error originates in the macro `register` (in Nightly builds, run with -Z macro-backtrace for more info)error[E0277]: the trait bound u32: From<FalconFbifMemType> is not satisfied
--> drivers/gpu/nova-core/regs/macros.rs:310:26
|
310 | let value = (u32::from(value) << SHIFT) & MASK;
| ^^^ the trait `From<FalconFbifMemType>` is not implemented for `u32`
|
::: drivers/gpu/nova-core/regs.rs:276:1
|
276 | / register!(NV_PFALCON_FBIF_TRANSCFG @ +0x00000600 {
277 | | 1:0 target as u8 ?=> FalconFbifTarget;
278 | | 2:2 mem_type as bool => FalconFbifMemType;
279 | | });
| |__- in this macro invocation
|
= help: the following other types implement trait `From<T>`:
`u32` implements `From<Char>`
`u32` implements `From<CpuId>`
`u32` implements `From<Ipv4Addr>`
`u32` implements `From<NV_FUSE_OPT_FPF_GSP_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_NVDEC_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_SEC2_UCODE1_VERSION>`
`u32` implements `From<NV_PBUS_SW_SCRATCH_0E>`
`u32` implements `From<NV_PDISP_VGA_WORKSPACE_BASE>`
and 41 others
= note: this error originates in the macro `register` (in Nightly builds, run with -Z macro-backtrace for more info)error[E0277]: the trait bound u32: From<FalconModSelAlgo> is not satisfied
--> drivers/gpu/nova-core/regs/macros.rs:310:26
|
310 | let value = (u32::from(value) << SHIFT) & MASK;
| ^^^ the trait `From<FalconModSelAlgo>` is not implemented for `u32`
|
::: drivers/gpu/nova-core/regs.rs:285:1
|
285 | / register!(NV_PFALCON2_FALCON_MOD_SEL @ +0x00001180 {
286 | | 7:0 algo as u8 ?=> FalconModSelAlgo;
287 | | });
| |__- in this macro invocation
|
= help: the following other types implement trait `From<T>`:
`u32` implements `From<Char>`
`u32` implements `From<CpuId>`
`u32` implements `From<Ipv4Addr>`
`u32` implements `From<NV_FUSE_OPT_FPF_GSP_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_NVDEC_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_SEC2_UCODE1_VERSION>`
`u32` implements `From<NV_PBUS_SW_SCRATCH_0E>`
`u32` implements `From<NV_PDISP_VGA_WORKSPACE_BASE>`
and 41 others
= note: this error originates in the macro `register` (in Nightly builds, run with -Z macro-backtrace for more info)error[E0277]: the trait bound u32: From<PeregrineCoreSelect> is not satisfied
--> drivers/gpu/nova-core/regs/macros.rs:310:26
|
310 | let value = (u32::from(value) << SHIFT) & MASK;
| ^^^ the trait `From<PeregrineCoreSelect>` is not implemented for `u32`
|
::: drivers/gpu/nova-core/regs.rs:304:1
|
304 | / register!(NV_PRISCV_RISCV_BCR_CTRL @ +0x00001668 {
305 | | 0:0 valid as bool;
306 | | 4:4 core_select as bool => PeregrineCoreSelect;
307 | | 8:8 br_fetch as bool;
308 | | });
| |__- in this macro invocation
|
= help: the following other types implement trait `From<T>`:
`u32` implements `From<Char>`
`u32` implements `From<CpuId>`
`u32` implements `From<Ipv4Addr>`
`u32` implements `From<NV_FUSE_OPT_FPF_GSP_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_NVDEC_UCODE1_VERSION>`
`u32` implements `From<NV_FUSE_OPT_FPF_SEC2_UCODE1_VERSION>`
`u32` implements `From<NV_PBUS_SW_SCRATCH_0E>`
`u32` implements `From<NV_PDISP_VGA_WORKSPACE_BASE>`
and 41 others
= note: this error originates in the macro `register` (in Nightly builds, run with -Z macro-backtrace for more info)error[E0599]: no method named as_nanos found for struct Delta in the current scope
--> drivers/gpu/nova-core/util.rs:45:33
|
45 | if start_time.elapsed().as_nanos() > timeout.as_nanos() as i64 {
| ^^^^^^^^ method not found in `Delta`error: aborting due to 9 previous errors
Some errors have detailed explanations: E0277, E0599. For more information about an error, try rustc --explain E0277.
Presumably caused by commit
b7c8d7a8d251 ("rust: enable clippy::cast_lossless lint")
interacting with some changes in the drm-nova tree
(https://gitlab.freedesktop.org/drm/nova.git#nova-next).
A suggested merge resolution would be appreciated.
I have used the rust tree from next-20250620 for today.
Signature · 2 lines
Cheers, Stephen Rothwell
Quoted 8 lines · Stephen Rothwell
error[E0277]: the trait bound
u32: From<DmaTrfCmdSize>is not satisfiederror[E0599]: no method named
as_nanosfound for structDeltain the current scopePresumably caused by commit
b7c8d7a8d251("rust: enableclippy::cast_losslesslint")
The first error, yes -- the register! macro was changed to use u32::from() to avoid an as cast in that commit, and while the cast is OK converting the new enums like FalconCoreRev, from() isn't, so we would need to implement From` explicitly -- Cc'ing Danilo, Alexandre, Lyude.
The second error is due to 2ed94606a0fe ("rust: time: Rename Delta's methods from as_* to into_*"). However, I am not sure why that patch was applied since we were discussing the naming of those methods elsewhere -- Cc'ing Andreas and Tomonori.
Nevertheless, even if 2ed94606a0fe is dropped (or the conflict solved by a trivial rename), there will be another nearby conflict after that one, due the addition of the ClockSource generic parameter, so that needs a change too, e.g. using Monotonic explicitly if that is correct or allowing the caller to pass a ClockSource.
By the way, I also noticed a Clippy warning in nova-next (on its own, i.e. without merging anything) -- please see below [1].
I hope this helps.
Cheers,
Miguel
[1]
error: mutable borrow from immutable input(s)
--> rust/kernel/dma.rs:297:78
|
297 | pub unsafe fn as_slice_mut(&self, offset: usize, count:
usize) -> Result<&mut [T]> {
|
^^^^^^^^
|
note: immutable borrow here
--> rust/kernel/dma.rs:297:32
|
297 | pub unsafe fn as_slice_mut(&self, offset: usize, count:usize) -> Result<&mut [T]> {
| ^^^^^
= help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#mut_from_ref
= note: -D clippy::mut-from-ref implied by -D warnings = help: to override -D warnings add #[allow(clippy::mut_from_ref)]
Quoted 2 lines · Miguel Ojeda
By the way, I also noticed a Clippy warning in
nova-next(on its own, i.e. without merging anything) -- please see below [1].
How do I get this warning to trigger? I did run my usual tests with rustc 1.78 and 1.87.
Quoted 7 lines
[1]
error: mutable borrow from immutable input(s)
-->rust/kernel/dma.rs:297:78
|
297 | pub unsafe fn as_slice_mut(&self, offset: usize, count:
usize) -> Result<&mut [T]> {
I think the method isn't wrong, it is unsafe and the safety requirement explicitly covers this part.
However, we should consider changing it anyways.
Quoted 13 lines
| ^^^^^^^^ | note: immutable borrow here --> rust/kernel/dma.rs:297:32 | 297 | pub unsafe fn as_slice_mut(&self, offset: usize, count:usize) -> Result<&mut [T]> {
| ^^^^^
= help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#mut_from_ref
= note:-D clippy::mut-from-refimplied by-D warnings= help: to override-D warningsadd#[allow(clippy::mut_from_ref)]
Quoted 3 lines · Danilo Krummrich
How do I get this warning to trigger? I did run my usual tests with rustc 1.78 and 1.87.
Ah, sorry, my bad -- it is in the upcoming 1.88, which I was using for something else.
You can test it with:
RUSTUP_DIST_SERVER=https://dev-static.rust-lang.org rustup update stable
Cheers,
Miguel
Quoted 8 lines · Miguel Ojeda
Quoted 7 lines · Stephen Rothwell
error[E0277]: the trait bound
u32: From<DmaTrfCmdSize>is not satisfiederror[E0599]: no method named
as_nanosfound for structDeltain the current scopePresumably caused by commit
Quoted 7 lines
Quoted 1 line
b7c8d7a8d251("rust: enableclippy::cast_losslesslint")The first error, yes -- the
register!macro was changed to useu32::from()to avoid anascast in that commit, and while the cast is OK converting the newenums likeFalconCoreRev,from()isn't, so we would need to implementFrom` explicitly -- Cc'ing Danilo, Alexandre, Lyude.
It's a bit annoying to implement From explicitly for all of them, but it seems to be the correct thing to do.
nova-next also contains a couple of cases where the introduction of cast_lossless causes warnings.
I can implement the From traits and fix up the warnings caused by enabling cast_lossless in my tree with subsequent patches, such that we do not have to carry all this as merge resolution.
- Danilo
Quoted 11 lines · Danilo Krummrich
Quoted 10 lines · Miguel Ojeda
Quoted 8 lines · Stephen Rothwell
error[E0277]: the trait bound
u32: From<DmaTrfCmdSize>is not satisfiederror[E0599]: no method named
as_nanosfound for structDeltain the current scopePresumably caused by commit
b7c8d7a8d251("rust: enableclippy::cast_losslesslint")
Quoted 8 lines
Quoted 5 lines
The first error, yes -- the
register!macro was changed to useu32::from()to avoid anascast in that commit, and while the cast is OK converting the newenums likeFalconCoreRev,from()isn't, so we would need to implementFrom` explicitly -- Cc'ing Danilo, Alexandre, Lyude.It's a bit annoying to implement From explicitly for all of them, but it seems to be the correct thing to do.
This might be something FromPrimitive will help with eventually, but in the meantime I agree having explicit implementations is a bit cumbersome.
What I don't understand is why these as are problematic - a type like FalconCoreRev is repr(u8), so the cast cannot be lossy. I think this is the case for all such instances using the register!() macro.
Quoted 7 lines
nova-next also contains a couple of cases where the introduction of
cast_losslesscauses warnings.I can implement the From traits and fix up the warnings caused by enabling
cast_losslessin my tree with subsequent patches, such that we do not have to carry all this as merge resolution.
Let me know if you want me to take care of that.
Quoted 22 lines · Alexandre Courbot
Quoted 11 lines · Danilo Krummrich
Quoted 10 lines · Miguel Ojeda
Quoted 8 lines · Stephen Rothwell
error[E0277]: the trait bound
u32: From<DmaTrfCmdSize>is not satisfiederror[E0599]: no method named
as_nanosfound for structDeltain the current scopePresumably caused by commit
b7c8d7a8d251("rust: enableclippy::cast_losslesslint")Quoted 8 lines
Quoted 5 lines
The first error, yes -- the
register!macro was changed to useu32::from()to avoid anascast in that commit, and while the cast is OK converting the newenums likeFalconCoreRev,from()isn't, so we would need to implementFrom` explicitly -- Cc'ing Danilo, Alexandre, Lyude.It's a bit annoying to implement From explicitly for all of them, but it seems to be the correct thing to do.
Quoted 7 lines
This might be something
FromPrimitivewill help with eventually, but in the meantime I agree having explicit implementations is a bit cumbersome.What I don't understand is why these
asare problematic - a type likeFalconCoreRevisrepr(u8), so the cast cannot be lossy. I think this is the case for all such instances using the register!() macro.
The use of as is problematic because it disempowers the compiler from checking that the cast is not lossy. In other words, it is of course fine in the case of a repr(u8) enum, but if the type changes in a way that causes a lossy conversion, the compiler will not warn you.
Quoted 10 lines
Quoted 8 lines
nova-next also contains a couple of cases where the introduction of
cast_losslesscauses warnings.I can implement the From traits and fix up the warnings caused by enabling
cast_losslessin my tree with subsequent patches, such that we do not have to carry all this as merge resolution.Let me know if you want me to take care of that.
Quoted 31 lines · Tamir Duberstein
Quoted 22 lines · Alexandre Courbot
Quoted 11 lines · Danilo Krummrich
Quoted 10 lines · Miguel Ojeda
Quoted 8 lines · Stephen Rothwell
error[E0277]: the trait bound
u32: From<DmaTrfCmdSize>is not satisfiederror[E0599]: no method named
as_nanosfound for structDeltain the current scopePresumably caused by commit
b7c8d7a8d251("rust: enableclippy::cast_losslesslint")Quoted 8 lines
Quoted 5 lines
The first error, yes -- the
register!macro was changed to useu32::from()to avoid anascast in that commit, and while the cast is OK converting the newenums likeFalconCoreRev,from()isn't, so we would need to implementFrom` explicitly -- Cc'ing Danilo, Alexandre, Lyude.It's a bit annoying to implement From explicitly for all of them, but it seems to be the correct thing to do.
Quoted 7 lines
This might be something
FromPrimitivewill help with eventually, but in the meantime I agree having explicit implementations is a bit cumbersome.What I don't understand is why these
asare problematic - a type likeFalconCoreRevisrepr(u8), so the cast cannot be lossy. I think this is the case for all such instances using the register!() macro.
Quoted 5 lines
The use of
asis problematic because it disempowers the compiler from checking that the cast is not lossy. In other words, it is of course fine in the case of arepr(u8)enum, but if the type changes in a way that causes a lossy conversion, the compiler will not warn you.
I understand and agree with this, but why doesn't the linter limit itself to such lossy cases (e.g. u64 as u32) and let the harmless ones be?
Quoted 39 lines · Alexandre Courbot
Quoted 31 lines · Tamir Duberstein
Quoted 22 lines · Alexandre Courbot
Quoted 11 lines · Danilo Krummrich
Quoted 10 lines · Miguel Ojeda
Quoted 8 lines · Stephen Rothwell
error[E0277]: the trait bound
u32: From<DmaTrfCmdSize>is not satisfiederror[E0599]: no method named
as_nanosfound for structDeltain the current scopePresumably caused by commit
b7c8d7a8d251("rust: enableclippy::cast_losslesslint")Quoted 8 lines
Quoted 5 lines
The first error, yes -- the
register!macro was changed to useu32::from()to avoid anascast in that commit, and while the cast is OK converting the newenums likeFalconCoreRev,from()isn't, so we would need to implementFrom` explicitly -- Cc'ing Danilo, Alexandre, Lyude.It's a bit annoying to implement From explicitly for all of them, but it seems to be the correct thing to do.
Quoted 7 lines
This might be something
FromPrimitivewill help with eventually, but in the meantime I agree having explicit implementations is a bit cumbersome.What I don't understand is why these
asare problematic - a type likeFalconCoreRevisrepr(u8), so the cast cannot be lossy. I think this is the case for all such instances using the register!() macro.Quoted 5 lines
The use of
asis problematic because it disempowers the compiler from checking that the cast is not lossy. In other words, it is of course fine in the case of arepr(u8)enum, but if the type changes in a way that causes a lossy conversion, the compiler will not warn you.
Quoted 3 lines
I understand and agree with this, but why doesn't the linter limit itself to such lossy cases (e.g.
u64 as u32) and let the harmless ones be?
Ah, that's a different lint. They are all explained in the docs probably better than I can:
https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation
https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_wrap
https://rust-lang.github.io/rust-clippy/master/index.html#cast_sign_loss
They are all allow-by-default though, because it is expected that *sometimes* you do want to do the lossy thing and there's no other way to express that.
Quoted 3 lines · Danilo Krummrich
It's a bit annoying to implement From explicitly for all of them, but it seems to be the correct thing to do.
Yeah, agreed.
Quoted 3 lines
I can implement the From traits and fix up the warnings caused by enabling
cast_losslessin my tree with subsequent patches, such that we do not have to carry all this as merge resolution.
That would be great, thanks.
Cheers,
Miguel