Re: [PATCH 04/11] media: iris: Add helper to create a context bank device on iris vpu bus
From: Vishnu Reddy
Date: Mon Apr 20 2026 - 12:40:17 EST
On 4/17/2026 11:53 PM, Dmitry Baryshkov wrote:
> On Fri, Apr 17, 2026 at 08:49:44PM +0530, Vishnu Reddy wrote:
>> On 4/14/2026 8:48 PM, Dmitry Baryshkov wrote:
>>> On Tue, Apr 14, 2026 at 10:30:00AM +0530, Vishnu Reddy wrote:
>>>> From: Vikash Garodia<vikash.garodia@xxxxxxxxxxxxxxxx>
>>>>
>>>> Add a helper function to allocate and register context bank (CB) device
>>>> on the iris vpu bus. The function ID associated with the CB is specified
>>>> from the platform data, allowing the bus dma_configure callback to apply
>>>> correct stream ID mapping when device is registered.
>>>>
>>>> Signed-off-by: Vikash Garodia<vikash.garodia@xxxxxxxxxxxxxxxx>
>>>> Signed-off-by: Vishnu Reddy<busanna.reddy@xxxxxxxxxxxxxxxx>
>>>> ---
>>>> drivers/media/platform/qcom/iris/iris_resources.c | 33 +++++++++++++++++++++++
>>>> drivers/media/platform/qcom/iris/iris_resources.h | 1 +
>>>> 2 files changed, 34 insertions(+)
>>>>
>>>> diff --git a/drivers/media/platform/qcom/iris/iris_resources.c b/drivers/media/platform/qcom/iris/iris_resources.c
>>>> index 773f6548370a..a25e0f2e9d26 100644
>>>> --- a/drivers/media/platform/qcom/iris/iris_resources.c
>>>> +++ b/drivers/media/platform/qcom/iris/iris_resources.c
>>>> @@ -6,6 +6,7 @@
>>>> #include <linux/clk.h>
>>>> #include <linux/devfreq.h>
>>>> #include <linux/interconnect.h>
>>>> +#include <linux/iris_vpu_bus.h>
>>>> #include <linux/pm_domain.h>
>>>> #include <linux/pm_opp.h>
>>>> #include <linux/pm_runtime.h>
>>>> @@ -141,3 +142,35 @@ int iris_disable_unprepare_clock(struct iris_core *core, enum platform_clk_type
>>>> return 0;
>>>> }
>>>> +
>>>> +static void iris_release_cb_dev(struct device *dev)
>>>> +{
>>>> + kfree(dev);
>>>> +}
>>>> +
>>>> +struct device *iris_create_cb_dev(struct iris_core *core, const char *name, const u32 *f_id)
>>> Please move into the bus code and make it generic enough.
>> Do you suggest to add a wrapper to pass the varying inputs to the generic
>> bus, something like this
>> struct device* create_and_register_device(dma_mask, parent_dev, *release,
>> dev_name,...)
> Definitely not the release function. The devname is also not that
> important. The rest, yes, you are correct.
>
>>>> +{
>>>> + struct device *dev;
>>>> + int ret;
>>>> +
>>>> + dev = kzalloc_obj(*dev);
>>>> + if (!dev)
>>>> + return ERR_PTR(-ENOMEM);
>>>> +
>>>> + dev->release = iris_release_cb_dev;
>>>> + dev->bus = &iris_vpu_bus_type;
>>>> + dev->parent = core->dev;
>>>> + dev->coherent_dma_mask = core->iris_platform_data->dma_mask;
>>>> + dev->dma_mask = &dev->coherent_dma_mask;
>>> Would you also need to set the of_node? See
>>> device_set_of_node_from_dev()
>> It might be needed for FastRPC as they are following sub node approach, Iris
>> does not need.
> Wouldn't it save you from passing it to of_dma_configure_id()?
Iris will pass parent device of_node, setting parent device is enough.
>>>> +
>>>> + dev_set_name(dev, "%s", name);
>>>> + dev_set_drvdata(dev, (void *)f_id);
>>>> +
>>>> + ret = device_register(dev);
>>>> + if (ret) {
>>>> + put_device(dev);
>>>> + return ERR_PTR(ret);
>>>> + }
>>>> +
>>>> + return dev;
>>>> +}
>>>> diff --git a/drivers/media/platform/qcom/iris/iris_resources.h b/drivers/media/platform/qcom/iris/iris_resources.h
>>>> index 6bfbd2dc6db0..4a494627ff23 100644
>>>> --- a/drivers/media/platform/qcom/iris/iris_resources.h
>>>> +++ b/drivers/media/platform/qcom/iris/iris_resources.h
>>>> @@ -15,5 +15,6 @@ int iris_unset_icc_bw(struct iris_core *core);
>>>> int iris_set_icc_bw(struct iris_core *core, unsigned long icc_bw);
>>>> int iris_disable_unprepare_clock(struct iris_core *core, enum platform_clk_type clk_type);
>>>> int iris_prepare_enable_clock(struct iris_core *core, enum platform_clk_type clk_type);
>>>> +struct device *iris_create_cb_dev(struct iris_core *core, const char *name, const u32 *f_id);
>>>> #endif
>>>>
>>>> --
>>>> 2.34.1
>>>>