From: "Maíra Canal" <mcanal@igalia.com>
To: "Daniel Almeida" <daniel.almeida@collabora.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Stone" <daniels@collabora.com>,
"Rob Herring" <robh@kernel.org>,
"Alice Ryhl" <alice.ryhl@google.com>,
"Beata Michalska" <beata.michalska@arm.com>,
"Carsten Haitzler" <carsten.haitzler@foss.arm.com>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
"Ashley Smith" <ashley.smith@collabora.com>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org, kernel@collabora.com
Subject: Re: [PATCH] Introduce Tyr
Date: Sat, 28 Jun 2025 16:55:44 -0300 [thread overview]
Message-ID: <f0ad78da-d4ba-44ec-beda-4f8c616053f8@igalia.com> (raw)
In-Reply-To: <20250627-tyr-v1-1-cb5f4c6ced46@collabora.com>
Hi Daniel,
On 27/06/25 19:34, Daniel Almeida wrote:
[...]
> diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
> new file mode 100644
> index 0000000000000000000000000000000000000000..2443620e10620585eae3d57978e64d2169a1b2d1
> --- /dev/null
> +++ b/drivers/gpu/drm/tyr/driver.rs
> @@ -0,0 +1,188 @@
> +// SPDX-License-Identifier: GPL-2.0 or MIT
> +
> +use core::pin::Pin;
> +
> +use kernel::bits::bit_u32;
> +use kernel::c_str;
> +use kernel::clk::Clk;
> +use kernel::device::Core;
> +use kernel::devres::Devres;
> +use kernel::drm;
> +use kernel::drm::ioctl;
> +use kernel::io;
> +use kernel::io::mem::IoMem;
> +use kernel::new_mutex;
> +use kernel::of;
> +use kernel::platform;
> +use kernel::prelude::*;
> +use kernel::regulator;
> +use kernel::regulator::Regulator;
> +use kernel::sync::Arc;
> +use kernel::sync::Mutex;
> +use kernel::time;
> +use kernel::types::ARef;
> +
> +use crate::file::File;
> +use crate::gem::TyrObject;
> +use crate::gpu;
> +use crate::gpu::GpuInfo;
> +use crate::regs;
> +
> +/// Convienence type alias for the DRM device type for this driver
> +pub(crate) type TyrDevice = drm::device::Device<TyrDriver>;
> +
> +#[pin_data(PinnedDrop)]
> +pub(crate) struct TyrDriver {
> + device: ARef<TyrDevice>,
> +}
> +
> +#[pin_data]
> +pub(crate) struct TyrData {
> + pub(crate) pdev: ARef<platform::Device>,
> +
> + #[pin]
> + clks: Mutex<Clocks>,
> +
> + #[pin]
> + regulators: Mutex<Regulators>,
> +
> + // Some inforation on the GPU. This is mainly queried by userspace (mesa).
s/inforation/information
> + pub(crate) gpu_info: GpuInfo,
> +}
> +
> +unsafe impl Send for TyrData {}
> +unsafe impl Sync for TyrData {}
> +
> +fn issue_soft_reset(iomem: &Devres<IoMem<0>>) -> Result<()> {
> + let irq_enable_cmd = 1 | bit_u32(8);
To enhance readability, consider using a regmap similar to
panthor_regs.h. This would help avoid 'magic numbers' and make the
code's intent much clearer.
> + regs::GPU_CMD.write(iomem, irq_enable_cmd)?;
> +
> + let op = || regs::GPU_INT_RAWSTAT.read(iomem);
> + let cond = |raw_stat: &u32| -> bool { (*raw_stat >> 8) & 1 == 1 };
> + let res = io::poll::read_poll_timeout(
> + op,
> + cond,
> + time::Delta::from_millis(100),
> + Some(time::Delta::from_micros(20000)),
> + );
> +
> + if let Err(e) = res {
> + pr_err!("GPU reset failed with errno {}\n", e.to_errno());
> + pr_err!(
> + "GPU_INT_RAWSTAT is {}\n",
> + regs::GPU_INT_RAWSTAT.read(iomem)?
> + );
> + }
> +
> + Ok(())
> +}
> +
> +kernel::of_device_table!(
> + OF_TABLE,
> + MODULE_OF_TABLE,
> + <TyrDriver as platform::Driver>::IdInfo,
> + [
> + (of::DeviceId::new(c_str!("rockchip,rk3588-mali")), ()),
> + (of::DeviceId::new(c_str!("arm,mali-valhall-csf")), ())
> + ]
> +);
> +
> +impl platform::Driver for TyrDriver {
> + type IdInfo = ();
> + const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
> +
> + fn probe(
> + pdev: &platform::Device<Core>,
> + _info: Option<&Self::IdInfo>,
> + ) -> Result<Pin<KBox<Self>>> {
> + dev_dbg!(pdev.as_ref(), "Probed Tyr\n");
> +
> + let core_clk = Clk::get(pdev.as_ref(), Some(c_str!("core")))?;
> + let stacks_clk = Clk::get(pdev.as_ref(), Some(c_str!("stacks")))?;
Shouldn't it be OptionalClk::get? From the DT schema for "arm,mali-
valhall-csf", I see that "stacks" and "coregroups" are optional.
> + let coregroup_clk = Clk::get(pdev.as_ref(), Some(c_str!("coregroup")))?;
Same.
Best Regards,
- Maíra
next prev parent reply other threads:[~2025-06-28 19:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 22:34 Daniel Almeida
2025-06-27 22:36 ` Daniel Almeida
2025-06-27 22:39 ` Boqun Feng
2025-06-27 22:56 ` Boqun Feng
2025-06-27 23:12 ` Danilo Krummrich
2025-06-28 0:12 ` Daniel Almeida
2025-06-28 9:31 ` Miguel Ojeda
2025-06-30 13:52 ` Rob Herring
2025-06-30 14:01 ` Daniel Almeida
2025-06-30 17:29 ` Miguel Ojeda
2025-06-30 16:06 ` Boris Brezillon
2025-06-30 16:12 ` Danilo Krummrich
2025-07-01 9:11 ` Boris Brezillon
2025-06-28 9:44 ` Miguel Ojeda
2025-06-28 13:05 ` Daniel Almeida
2025-06-28 13:49 ` FUJITA Tomonori
2025-06-28 14:29 ` Miguel Ojeda
2025-06-30 15:22 ` Daniel Almeida
2025-06-30 17:29 ` Miguel Ojeda
2025-06-28 19:55 ` Maíra Canal [this message]
2025-06-30 13:53 ` Daniel Almeida
2025-07-03 10:45 ` Maíra Canal
2025-06-30 10:11 ` Steven Price
2025-06-30 14:56 ` Daniel Almeida
2025-06-30 15:31 ` Steven Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0ad78da-d4ba-44ec-beda-4f8c616053f8@igalia.com \
--to=mcanal@igalia.com \
--cc=a.hindborg@kernel.org \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=alice.ryhl@google.com \
--cc=aliceryhl@google.com \
--cc=ashley.smith@collabora.com \
--cc=beata.michalska@arm.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=carsten.haitzler@foss.arm.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=ojeda@kernel.org \
--cc=robh@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®