Re: [PATCH 1/2] rust: Add initial interconnect framework abstractions

From: Konrad Dybcio
Date: Wed Jul 23 2025 - 07:32:58 EST


On 7/23/25 12:42 PM, Miguel Ojeda wrote:
> Hi Konrad,
>
> Some quick mostly doc-related comments...

[...]

>> + /// Create a new instance from gigabytes (GB) per second
>> + pub const fn from_gigabytes_per_sec(gbps: u32) -> Self {
>> + Self(gbps * 1000 * 1000)
>> + }
>
> I guess this means callers must call this with reasonable numbers and
> otherwise it is considered a bug, right? i.e. this could overflow, and
> thus panic under `CONFIG_RUST_OVERFLOW_CHECKS=y`.

The C framework makes no effort to check for that, so panicking is at
least something.. That said, what would you suggest to do here?

[...]

>> +#[cfg(CONFIG_INTERCONNECT)]
>> +mod icc_path {
>
> Maybe a different file?

I was debating that. icc_path represents the interconnect consumer part
(i.e. used in device drivers that just need to toggle a bus endpoint),
whereas the corresponding provider part (which manages said bus) is not
yet abstracted.

It would make logical sense to split these two.. with the latter going
to icc_provider.rs, perhaps?

[...]

>> +// SAFETY: An `IccPath` is always reference-counted and can be released from any thread.
>> +unsafe impl Send for IccPath {}
>
> This gives an error, right? Was it meant to be inside the other Rust module?

No, it compiles fine here.. Strangely, I didn't get any warnings or
errors with this patch. Maybe because the struct is pub and within the
same file?

Should I move it into the module scope for sanity?

>
> Also, please also run `make .... rustfmt`.
>
> Finally, the examples in the docs are converted automatically into
> KUnit tests (under `CONFIG_RUST_KERNEL_DOCTESTS=y`) -- the examples
> currently have build errors.

I was missing this config, yeah..

>
> We have some extra notes at:
>
> https://rust-for-linux.com/contributing#submit-checklist-addendum
>
> on things that are useful to test/check.

I almost wanna say `make rustfmt` produced slightly different results
(one or two lines of difference) than make rust-analyzer + vscode
extension.. hmm.. Perhaps PEBKAC..

Konrad