Re: [RFC PATCH 02/28] media: mali-vpu: add Mali VPU platform driver

From: Charvi Mehta

Date: Tue Nov 24 2026 - 04:56:54 EST



On 11/19/26 20:04, Nicolas Dufresne wrote:
+
+/* VPU register access helpers */
+static u32 mali_vpu_read_reg(void __iomem *regs_base, u32 off)
+{
+ return readl(regs_base + off);
That wrapper does nothing other then increasing the code length. Why not take a
vpu_dev as parameter?
Passing the MMIO base keeps the helpers independent of the device structure,
but taking `struct mali_vpu_dev *` would simplify the callers.
I’ll make that change in v2.


You're chosen namespace is also very long, worth considering, but not strictly a
problem.

I'd prefer to keep the `mali_vpu_` prefix for consistency with the driver name and
rest of the series.


+static int mali_vpu_get_clocks(struct mali_vpu_dev *vpu_dev)
+{
+ int ret;
+
+ ret = devm_clk_bulk_get_all(vpu_dev->dev, &vpu_dev->clk_list);
+ if (ret < 0)
+ return dev_err_probe(vpu_dev->dev, ret, "failed to get clocks\n");
+ if (!ret)
+ return dev_err_probe(vpu_dev->dev, -EINVAL, "no clocks found\n");
I don't think the second check is required, that would mean you have zero clock
in your DT, which is invalid according to your binding.
The VPU requires a core clock, but `devm_clk_bulk_get_all()` returns zero
when none are found. Although this violates the binding, schema validation
is not enabled by default or performed at runtime, and the bootloader can
supply a separate DTB. I’d prefer to retain the check so probe reports the
missing clock before attempting register access.


+static int mali_vpu_enable_clk(struct mali_vpu_dev *vpu_dev)
+{
+ return clk_bulk_prepare_enable(vpu_dev->clk_count, vpu_dev->clk_list);
+}
+
+static void mali_vpu_disable_clk(struct mali_vpu_dev *vpu_dev)
+{
+ clk_bulk_disable_unprepare(vpu_dev->clk_count, vpu_dev->clk_list);
+}
The two wrapper above do nothing.
Fair point. I’ll remove them and call the bulk clock APIs directly.


+ ret = mali_vpu_get_resources(vpu_dev);
+ if (ret)
+ return ret;
+
+ ret = mali_vpu_enable_clk(vpu_dev);
+ if (ret) {
+ dev_err(vpu_dev->dev, "failed to enable core clock\n");
+ return ret;
+ }
+
+ ret = mali_vpu_deassert_reset(vpu_dev);
+ if (ret) {
+ dev_err(vpu_dev->dev, "failed to deassert reset\n");
+ goto err_clk;
+ }
In practice the two above should be inside your PM runtime ops, not sure if
that's coming after, in which case just ignore. It best to do this early, PM as
after thought would be bad.
Thanks, runtime PM support will follow in subsequent patches.


+ mali_vpu_read_version(vpu_dev, &pid, &rev, &patch);
+ dev_info(&pdev->dev, "Mali VPU device product ID: %#x, revision: %#x, patch: %#x\n",
+ pid, rev, patch);
+
+ if (pid != vpu_dev->variant->expected_hw_pid) {
+ dev_err(vpu_dev->dev, "unexpected hardware product ID: %#x (expected %#x)\n",
+ pid, vpu_dev->variant->expected_hw_pid);
+ ret = -ENODEV;
+ goto err_rst_clk;
+ }
Both ways work, but you could also pick the variant based on the version
instead, and only depend on DT for the "families" (e.g. the version register
layout have changed but you still want this under the same driver).
Thanks for the suggestion. For V76, I prefer to retain the DT-selected
variant and use the product ID as a sanity check.
I'll revisit product-ID-based variant selection when another variant is added.


Regards,
Charvi