From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Do not merge, this is for illustration / CI purposes only.
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
drivers/interconnect/Makefile | 1 +
drivers/interconnect/test.rs | 47 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile
index b0a9a6753b9dc30083781163ccc01dafcfcd0485..913b92080cc0b79846b74c239e14959b45b5450c 100644
--- a/drivers/interconnect/Makefile
+++ b/drivers/interconnect/Makefile
@@ -2,6 +2,7 @@
CFLAGS_core.o := -I$(src)
icc-core-objs := core.o bulk.o debugfs-client.o
+icc-core-$(CONFIG_RUST) += test.o
obj-$(CONFIG_INTERCONNECT) += icc-core.o
obj-$(CONFIG_INTERCONNECT_IMX) += imx/
diff --git a/drivers/interconnect/test.rs b/drivers/interconnect/test.rs
new file mode 100644
index 0000000000000000000000000000000000000000..f4ba2000d0f1fd2d91aedf8aace0b0b54bfd48f2
--- /dev/null
+++ b/drivers/interconnect/test.rs
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+
+//! Test interconnect consumer driver
+use kernel::{
+ c_str, device::Core, icc::*, module_platform_driver, of, of::DeviceId, platform, prelude::*,
+};
+
+#[pin_data]
+struct IccTestConsumerDriver {
+ #[pin]
+ path: IccPath,
+}
+
+kernel::of_device_table!(
+ OF_TABLE,
+ MODULE_OF_TABLE,
+ <IccTestConsumerDriver as platform::Driver>::IdInfo,
+ [(DeviceId::new(c_str!("linux,icc-consumer-test")), ())]
+);
+
+impl platform::Driver for IccTestConsumerDriver {
+ type IdInfo = ();
+ const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
+
+ fn probe(
+ pdev: &platform::Device<Core>,
+ _id_info: Option<&Self::IdInfo>,
+ ) -> Result<Pin<KBox<Self>>> {
+ let path = IccPath::of_get(pdev.as_ref(), None)?;
+
+ path.set_bw(
+ IccBwUnit::from_megabits_per_sec(400),
+ IccBwUnit::from_megabits_per_sec(800),
+ )?;
+
+ Ok(KBox::pin_init(Self { path }, GFP_KERNEL)?.into())
+ }
+}
+
+module_platform_driver! {
+ type: IccTestConsumerDriver,
+ name: "icc-test-consumer",
+ authors: ["Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>"],
+ description: "Test interconnect consumer driver",
+ license: "GPL",
+}
--
2.50.1
Hi Konrad, commenting in case this driver goes forward.
> On 22 Jul 2025, at 18:14, Konrad Dybcio <konradybcio@kernel.org> wrote:
>
> From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>
> Do not merge, this is for illustration / CI purposes only.
>
> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> drivers/interconnect/Makefile | 1 +
> drivers/interconnect/test.rs | 47 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 48 insertions(+)
>
> diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile
> index b0a9a6753b9dc30083781163ccc01dafcfcd0485..913b92080cc0b79846b74c239e14959b45b5450c 100644
> --- a/drivers/interconnect/Makefile
> +++ b/drivers/interconnect/Makefile
> @@ -2,6 +2,7 @@
>
> CFLAGS_core.o := -I$(src)
> icc-core-objs := core.o bulk.o debugfs-client.o
> +icc-core-$(CONFIG_RUST) += test.o
>
> obj-$(CONFIG_INTERCONNECT) += icc-core.o
> obj-$(CONFIG_INTERCONNECT_IMX) += imx/
> diff --git a/drivers/interconnect/test.rs b/drivers/interconnect/test.rs
> new file mode 100644
> index 0000000000000000000000000000000000000000..f4ba2000d0f1fd2d91aedf8aace0b0b54bfd48f2
> --- /dev/null
> +++ b/drivers/interconnect/test.rs
> @@ -0,0 +1,47 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> +
> +//! Test interconnect consumer driver
> +use kernel::{
> + c_str, device::Core, icc::*, module_platform_driver, of, of::DeviceId, platform, prelude::*,
> +};
> +
> +#[pin_data]
> +struct IccTestConsumerDriver {
> + #[pin]
> + path: IccPath,
> +}
I don’t think this does anything useful without PhantomPinned, but Benno is
the right person to chime in here.
More importantly though, why do you have #[pin] on IccPath?
> +
> +kernel::of_device_table!(
> + OF_TABLE,
> + MODULE_OF_TABLE,
> + <IccTestConsumerDriver as platform::Driver>::IdInfo,
> + [(DeviceId::new(c_str!("linux,icc-consumer-test")), ())]
> +);
> +
> +impl platform::Driver for IccTestConsumerDriver {
> + type IdInfo = ();
> + const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
> +
> + fn probe(
> + pdev: &platform::Device<Core>,
> + _id_info: Option<&Self::IdInfo>,
> + ) -> Result<Pin<KBox<Self>>> {
> + let path = IccPath::of_get(pdev.as_ref(), None)?;
> +
> + path.set_bw(
> + IccBwUnit::from_megabits_per_sec(400),
> + IccBwUnit::from_megabits_per_sec(800),
> + )?;
> +
> + Ok(KBox::pin_init(Self { path }, GFP_KERNEL)?.into())
> + }
> +}
> +
> +module_platform_driver! {
> + type: IccTestConsumerDriver,
> + name: "icc-test-consumer",
> + authors: ["Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>"],
> + description: "Test interconnect consumer driver",
> + license: "GPL",
> +}
>
> --
> 2.50.1
>
>
— Daniel
On Wed Jul 23, 2025 at 3:10 PM CEST, Daniel Almeida wrote:
> On 22 Jul 2025, at 18:14, Konrad Dybcio <konradybcio@kernel.org> wrote:
>> +#[pin_data]
>> +struct IccTestConsumerDriver {
>> + #[pin]
>> + path: IccPath,
>> +}
>
> I don’t think this does anything useful without PhantomPinned, but Benno is
> the right person to chime in here.
It does do something useful, there just has to be one type marked with
`#[pin]` that is `!Unpin` (so for example `PhantomPinned`, `Opaque<T>`
etc.).
In this case however, `IccPath` is a newtype of `*mut bindings::icc_path`
which isn't `PhantomPinned`, so this doesn't ensure that the
`IccTestConsumerDriver` will stay pinned after initializing.
> More importantly though, why do you have #[pin] on IccPath?
Another question is: why is `IccPath` not a newtype of
`Opaque<bindings::icc_path>`? And then one can use `&IccPath`.
---
Cheers,
Benno
On 7/23/25 3:22 PM, Benno Lossin wrote:
> On Wed Jul 23, 2025 at 3:10 PM CEST, Daniel Almeida wrote:
>> On 22 Jul 2025, at 18:14, Konrad Dybcio <konradybcio@kernel.org> wrote:
>>> +#[pin_data]
>>> +struct IccTestConsumerDriver {
>>> + #[pin]
>>> + path: IccPath,
>>> +}
>>
>> I don’t think this does anything useful without PhantomPinned, but Benno is
>> the right person to chime in here.
>
> It does do something useful, there just has to be one type marked with
> `#[pin]` that is `!Unpin` (so for example `PhantomPinned`, `Opaque<T>`
> etc.).
>
> In this case however, `IccPath` is a newtype of `*mut bindings::icc_path`
> which isn't `PhantomPinned`, so this doesn't ensure that the
> `IccTestConsumerDriver` will stay pinned after initializing.
>
>> More importantly though, why do you have #[pin] on IccPath?
>
> Another question is: why is `IccPath` not a newtype of
> `Opaque<bindings::icc_path>`? And then one can use `&IccPath`.
The short answer to all of your questions happens to be the simple
"the code compiled".. :) I didn't know about Opaque<T>, thanks
Konrad
© 2016 - 2026 Red Hat, Inc.