linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree
@ 2025-06-24  9:51 ` Stephen Rothwell
  2025-06-24 11:48   ` Andreas Hindborg
  2025-08-01  7:18   ` Stephen Rothwell
  0 siblings, 2 replies; 8+ messages in thread
From: Stephen Rothwell @ 2025-06-24  9:51 UTC (permalink / raw)
  To: Andreas Hindborg, Danilo Krummrich
  Cc: Alexandre Courbot, FUJITA Tomonori, Linux Kernel Mailing List,
	Linux Next Mailing List

[-- Attachment #1: Type: text/plain, Size: 1046 bytes --]

Hi all,

After merging the rust-timekeeping tree, today's linux-next build
(x86_64 allmodconfig) failed like this:

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 1 previous error

For more information about this error, try `rustc --explain E0599`.

Caused by commits

  2ed94606a0fe ("rust: time: Rename Delta's methods from as_* to into_*")
  768dfbfc98e2 ("rust: time: Make Instant generic over ClockSource")

interacting with commit

  a03c9bd953c2 ("gpu: nova-core: add helper function to wait on condition")

from the drm-nova tree.

I tried to fix it up, but this lead down a rabbit hole and my rust
skills are poor, so I just dropped the rust-timekeeping tree for today.
A merge resolution would be appreciated.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree
  2025-06-24  9:51 ` linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree Stephen Rothwell
@ 2025-06-24 11:48   ` Andreas Hindborg
  2025-06-24 12:03     ` Alexandre Courbot
  2025-08-01  7:18   ` Stephen Rothwell
  1 sibling, 1 reply; 8+ messages in thread
From: Andreas Hindborg @ 2025-06-24 11:48 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Danilo Krummrich, Alexandre Courbot, FUJITA Tomonori,
	Linux Kernel Mailing List, Linux Next Mailing List

"Stephen Rothwell" <sfr@canb.auug.org.au> writes:

> Hi all,
>
> After merging the rust-timekeeping tree, today's linux-next build
> (x86_64 allmodconfig) failed like this:
>
> 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 1 previous error
>
> For more information about this error, try `rustc --explain E0599`.
>
> Caused by commits
>
>   2ed94606a0fe ("rust: time: Rename Delta's methods from as_* to into_*")
>   768dfbfc98e2 ("rust: time: Make Instant generic over ClockSource")
>
> interacting with commit
>
>   a03c9bd953c2 ("gpu: nova-core: add helper function to wait on condition")
>
> from the drm-nova tree.
>
> I tried to fix it up, but this lead down a rabbit hole and my rust
> skills are poor, so I just dropped the rust-timekeeping tree for today.
> A merge resolution would be appreciated.

I would suggest the following:

diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs
index 5cafe0797cd6..24cbf3f4cc39 100644
--- a/drivers/gpu/nova-core/util.rs
+++ b/drivers/gpu/nova-core/util.rs
@@ -3,7 +3,7 @@
 use core::time::Duration;
 
 use kernel::prelude::*;
-use kernel::time::Instant;
+use kernel::time::{Instant, Monotonic};
 
 pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] {
     let src = s.as_bytes();
@@ -35,14 +35,14 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str {
 /// TODO[DLAY]: replace with `read_poll_timeout` once it is available.
 /// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/)
 pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Duration, cond: F) -> Result<R> {
-    let start_time = Instant::now();
+    let start_time = Instant::<Monotonic>::now();
 
     loop {
         if let Some(ret) = cond() {
             return Ok(ret);
         }
 
-        if start_time.elapsed().as_nanos() > timeout.as_nanos() as i64 {
+        if start_time.elapsed().into_nanos() > timeout.as_nanos() as i64 {
             return Err(ETIMEDOUT);
         }
     }

For the Nova people: You might consider if it makes sense to take a
`kernel::time::Delta<C>` for the timeout.

Best regards,
Andreas Hindborg



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree
  2025-06-24 11:48   ` Andreas Hindborg
@ 2025-06-24 12:03     ` Alexandre Courbot
  2025-06-24 12:16       ` Danilo Krummrich
  0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Courbot @ 2025-06-24 12:03 UTC (permalink / raw)
  To: Andreas Hindborg, Stephen Rothwell
  Cc: Danilo Krummrich, FUJITA Tomonori, Linux Kernel Mailing List,
	Linux Next Mailing List

On Tue Jun 24, 2025 at 8:48 PM JST, Andreas Hindborg wrote:
> "Stephen Rothwell" <sfr@canb.auug.org.au> writes:
>
>> Hi all,
>>
>> After merging the rust-timekeeping tree, today's linux-next build
>> (x86_64 allmodconfig) failed like this:
>>
>> 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 1 previous error
>>
>> For more information about this error, try `rustc --explain E0599`.
>>
>> Caused by commits
>>
>>   2ed94606a0fe ("rust: time: Rename Delta's methods from as_* to into_*")
>>   768dfbfc98e2 ("rust: time: Make Instant generic over ClockSource")
>>
>> interacting with commit
>>
>>   a03c9bd953c2 ("gpu: nova-core: add helper function to wait on condition")
>>
>> from the drm-nova tree.
>>
>> I tried to fix it up, but this lead down a rabbit hole and my rust
>> skills are poor, so I just dropped the rust-timekeeping tree for today.
>> A merge resolution would be appreciated.
>
> I would suggest the following:
>
> diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs
> index 5cafe0797cd6..24cbf3f4cc39 100644
> --- a/drivers/gpu/nova-core/util.rs
> +++ b/drivers/gpu/nova-core/util.rs
> @@ -3,7 +3,7 @@
>  use core::time::Duration;
>  
>  use kernel::prelude::*;
> -use kernel::time::Instant;
> +use kernel::time::{Instant, Monotonic};
>  
>  pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] {
>      let src = s.as_bytes();
> @@ -35,14 +35,14 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str {
>  /// TODO[DLAY]: replace with `read_poll_timeout` once it is available.
>  /// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/)
>  pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Duration, cond: F) -> Result<R> {
> -    let start_time = Instant::now();
> +    let start_time = Instant::<Monotonic>::now();
>  
>      loop {
>          if let Some(ret) = cond() {
>              return Ok(ret);
>          }
>  
> -        if start_time.elapsed().as_nanos() > timeout.as_nanos() as i64 {
> +        if start_time.elapsed().into_nanos() > timeout.as_nanos() as i64 {
>              return Err(ETIMEDOUT);
>          }
>      }
>
> For the Nova people: You might consider if it makes sense to take a
> `kernel::time::Delta<C>` for the timeout.

It probably does now that it is available. I'm willing to do it this
cycle if we can find a way to not break the build. Should we have a tag
to merge into nova-next or something?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree
  2025-06-24 12:03     ` Alexandre Courbot
@ 2025-06-24 12:16       ` Danilo Krummrich
  2025-06-24 19:02         ` Andreas Hindborg
  0 siblings, 1 reply; 8+ messages in thread
From: Danilo Krummrich @ 2025-06-24 12:16 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: Andreas Hindborg, Stephen Rothwell, FUJITA Tomonori,
	Linux Kernel Mailing List, Linux Next Mailing List

On Tue, Jun 24, 2025 at 09:03:48PM +0900, Alexandre Courbot wrote:
> On Tue Jun 24, 2025 at 8:48 PM JST, Andreas Hindborg wrote:
> > For the Nova people: You might consider if it makes sense to take a
> > `kernel::time::Delta<C>` for the timeout.
> 
> It probably does now that it is available. I'm willing to do it this
> cycle if we can find a way to not break the build. Should we have a tag
> to merge into nova-next or something?

I'm not sure about the generic in Delta mentioned by Andreas above, but the
Detla type did land in the last merge window, so it's available in the nova
tree already.

In case it would not have been, I wouldn't recommend doing signed tags for such
a minor thing. We should only do that when things are really getting into the
way.

- Danilo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree
  2025-06-24 12:16       ` Danilo Krummrich
@ 2025-06-24 19:02         ` Andreas Hindborg
  2025-06-25  6:13           ` Stephen Rothwell
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Hindborg @ 2025-06-24 19:02 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: Alexandre Courbot, Stephen Rothwell, FUJITA Tomonori,
	Linux Kernel Mailing List, Linux Next Mailing List

"Danilo Krummrich" <dakr@kernel.org> writes:

> On Tue, Jun 24, 2025 at 09:03:48PM +0900, Alexandre Courbot wrote:
>> On Tue Jun 24, 2025 at 8:48 PM JST, Andreas Hindborg wrote:
>> > For the Nova people: You might consider if it makes sense to take a
>> > `kernel::time::Delta<C>` for the timeout.
>>
>> It probably does now that it is available. I'm willing to do it this
>> cycle if we can find a way to not break the build. Should we have a tag
>> to merge into nova-next or something?
>
> I'm not sure about the generic in Delta mentioned by Andreas above, but the
> Detla type did land in the last merge window, so it's available in the nova
> tree already.

Sorry, that is my mistake. `Delta` does not take any generics, I was
thinking of `Instant`, it takes the clock.

Anyway, I dropped the patch renaming `as_*` [1], so now the resolution would
be:

diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs
index 5cafe0797cd6..01a920085438 100644
--- a/drivers/gpu/nova-core/util.rs
+++ b/drivers/gpu/nova-core/util.rs
@@ -3,7 +3,7 @@
 use core::time::Duration;
 
 use kernel::prelude::*;
-use kernel::time::Instant;
+use kernel::time::{Instant, Monotonic};
 
 pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] {
     let src = s.as_bytes();
@@ -35,7 +35,7 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str {
 /// TODO[DLAY]: replace with `read_poll_timeout` once it is available.
 /// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/)
 pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Duration, cond: F) -> Result<R> {
-    let start_time = Instant::now();
+    let start_time = Instant::<Monotonic>::now();
 
     loop {
         if let Some(ret) = cond() {


Best regards,
Andreas Hindborg


[1] https://lore.kernel.org/all/87wm912sjg.fsf@kernel.org


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree
  2025-06-24 19:02         ` Andreas Hindborg
@ 2025-06-25  6:13           ` Stephen Rothwell
  2025-06-26  7:05             ` Stephen Rothwell
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Rothwell @ 2025-06-25  6:13 UTC (permalink / raw)
  To: Andreas Hindborg
  Cc: Danilo Krummrich, Alexandre Courbot, FUJITA Tomonori,
	Linux Kernel Mailing List, Linux Next Mailing List

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

Hi Andreas,

On Tue, 24 Jun 2025 21:02:43 +0200 Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
> diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs
> index 5cafe0797cd6..01a920085438 100644
> --- a/drivers/gpu/nova-core/util.rs
> +++ b/drivers/gpu/nova-core/util.rs
> @@ -3,7 +3,7 @@
>  use core::time::Duration;
>  
>  use kernel::prelude::*;
> -use kernel::time::Instant;
> +use kernel::time::{Instant, Monotonic};
>  
>  pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] {
>      let src = s.as_bytes();
> @@ -35,7 +35,7 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str {
>  /// TODO[DLAY]: replace with `read_poll_timeout` once it is available.
>  /// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/)
>  pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Duration, cond: F) -> Result<R> {
> -    let start_time = Instant::now();
> +    let start_time = Instant::<Monotonic>::now();
>  
>      loop {
>          if let Some(ret) = cond() {

I have applied that to the merge of the rust-timekeeping tree today,
thanks.
-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree
  2025-06-25  6:13           ` Stephen Rothwell
@ 2025-06-26  7:05             ` Stephen Rothwell
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Rothwell @ 2025-06-26  7:05 UTC (permalink / raw)
  To: Andreas Hindborg
  Cc: Danilo Krummrich, Alexandre Courbot, FUJITA Tomonori,
	Linux Kernel Mailing List, Linux Next Mailing List

[-- Attachment #1: Type: text/plain, Size: 2325 bytes --]

Hi all,

On Wed, 25 Jun 2025 16:13:01 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> On Tue, 24 Jun 2025 21:02:43 +0200 Andreas Hindborg <a.hindborg@kernel.org> wrote:
> >
> > diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs
> > index 5cafe0797cd6..01a920085438 100644
> > --- a/drivers/gpu/nova-core/util.rs
> > +++ b/drivers/gpu/nova-core/util.rs
> > @@ -3,7 +3,7 @@
> >  use core::time::Duration;
> >  
> >  use kernel::prelude::*;
> > -use kernel::time::Instant;
> > +use kernel::time::{Instant, Monotonic};
> >  
> >  pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] {
> >      let src = s.as_bytes();
> > @@ -35,7 +35,7 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str {
> >  /// TODO[DLAY]: replace with `read_poll_timeout` once it is available.
> >  /// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/)
> >  pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Duration, cond: F) -> Result<R> {
> > -    let start_time = Instant::now();
> > +    let start_time = Instant::<Monotonic>::now();
> >  
> >      loop {
> >          if let Some(ret) = cond() {  
> 
> I have applied that to the merge of the rust-timekeeping tree today,
> thanks.

The merge resolution now looks like this:

diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs
index 64fb13760764..76cedf3710d7 100644
--- a/drivers/gpu/nova-core/util.rs
+++ b/drivers/gpu/nova-core/util.rs
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 
 use kernel::prelude::*;
-use kernel::time::{Delta, Instant};
+use kernel::time::{Delta, Instant, Monotonic};
 
 pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] {
     let src = s.as_bytes();
@@ -33,7 +33,7 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str {
 /// TODO[DLAY]: replace with `read_poll_timeout` once it is available.
 /// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/)
 pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Delta, cond: F) -> Result<R> {
-    let start_time = Instant::now();
+    let start_time = Instant::<Monotonic>::now();
 
     loop {
         if let Some(ret) = cond() {

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree
  2025-06-24  9:51 ` linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree Stephen Rothwell
  2025-06-24 11:48   ` Andreas Hindborg
@ 2025-08-01  7:18   ` Stephen Rothwell
  1 sibling, 0 replies; 8+ messages in thread
From: Stephen Rothwell @ 2025-08-01  7:18 UTC (permalink / raw)
  To: Danilo Krummrich, Miguel Ojeda
  Cc: Andreas Hindborg, Alexandre Courbot, FUJITA Tomonori,
	Linux Kernel Mailing List, Linux Next Mailing List

[-- Attachment #1: Type: text/plain, Size: 2665 bytes --]

Hi all,

On Tue, 24 Jun 2025 19:51:42 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> After merging the rust-timekeeping tree, today's linux-next build
> (x86_64 allmodconfig) failed like this:
> 
> 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 1 previous error
> 
> For more information about this error, try `rustc --explain E0599`.
> 
> Caused by commits
> 
>   2ed94606a0fe ("rust: time: Rename Delta's methods from as_* to into_*")
>   768dfbfc98e2 ("rust: time: Make Instant generic over ClockSource")
> 
> interacting with commit
> 
>   a03c9bd953c2 ("gpu: nova-core: add helper function to wait on condition")
> 
> from the drm-nova tree.
> 
> I tried to fix it up, but this lead down a rabbit hole and my rust
> skills are poor, so I just dropped the rust-timekeeping tree for today.
> A merge resolution would be appreciated.

This is now a conflict between the rust tree and Linus' tree.

The resolution being used is:

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Wed, 25 Jun 2025 16:00:14 +1000
Subject: [PATCH] fix up for "rust: time: Make Instant generic over ClockSource"

interacting with "gpu: nova-core: add helper function to wait on
condition" from the drm-nova tree

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 drivers/gpu/nova-core/util.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs
index 64fb13760764..76cedf3710d7 100644
--- a/drivers/gpu/nova-core/util.rs
+++ b/drivers/gpu/nova-core/util.rs
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 
 use kernel::prelude::*;
-use kernel::time::{Delta, Instant};
+use kernel::time::{Delta, Instant, Monotonic};
 
 pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] {
     let src = s.as_bytes();
@@ -33,7 +33,7 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str {
 /// TODO[DLAY]: replace with `read_poll_timeout` once it is available.
 /// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/)
 pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Delta, cond: F) -> Result<R> {
-    let start_time = Instant::now();
+    let start_time = Instant::<Monotonic>::now();
 
     loop {
         if let Some(ret) = cond() {

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-08-01  7:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <iuo4BpdTglZkpW9Xyy1ehjFspmj3ay0q7iejyeOShBG0HLZmIrhzIpi0eG_wBv71ZPPCgh2lcn2BOsrFHOegfg==@protonmail.internalid>
2025-06-24  9:51 ` linux-next: manual merge of the rust-timekeeping tree with the drm-nova tree Stephen Rothwell
2025-06-24 11:48   ` Andreas Hindborg
2025-06-24 12:03     ` Alexandre Courbot
2025-06-24 12:16       ` Danilo Krummrich
2025-06-24 19:02         ` Andreas Hindborg
2025-06-25  6:13           ` Stephen Rothwell
2025-06-26  7:05             ` Stephen Rothwell
2025-08-01  7:18   ` Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).