From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
Cc: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Bryan O'Donoghue <bod@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Saravana Kannan <saravanak@kernel.org>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Stefan Schmidt <stefan.schmidt@linaro.org>,
Hans Verkuil <hverkuil@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Vishnu Reddy <busanna.reddy@oss.qualcomm.com>,
Hans Verkuil <hverkuil+cisco@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
iommu@lists.linux.dev,
Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Subject: Re: [PATCH v3 4/7] media: iris: add context bank devices using iommu-map
Date: Fri, 13 Mar 2026 17:33:29 +0200 [thread overview]
Message-ID: <2l4izvnne7mgzoepn2ckctqxpz4tbi6pgeoobon32cecyf64mz@mhx5bicwp5na> (raw)
In-Reply-To: <20260313-kaanapali-iris-v3-4-9c0d1a67af4b@oss.qualcomm.com>
On Fri, Mar 13, 2026 at 06:49:38PM +0530, Vikash Garodia wrote:
> Introduce different context banks(CB) and the associated buffer region.
> Different stream IDs from VPU would be associated to one of these CB.
> Multiple CBs are needed to increase the IOVA for the video usecases like
> higher concurrent sessions.
>
> Co-developed-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
> Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
> Signed-off-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
> ---
> drivers/media/platform/qcom/iris/iris_core.h | 2 +
> .../platform/qcom/iris/iris_platform_common.h | 14 +++++
> drivers/media/platform/qcom/iris/iris_probe.c | 66 ++++++++++++++++++++--
> drivers/media/platform/qcom/iris/iris_resources.c | 46 +++++++++++++++
> drivers/media/platform/qcom/iris/iris_resources.h | 1 +
> 5 files changed, 125 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/platform/qcom/iris/iris_core.h
> index fb194c967ad4f9b5e00cd74f0d41e0b827ef14db..62364bd6909e9a03d223bac86962dc9094a40243 100644
> --- a/drivers/media/platform/qcom/iris/iris_core.h
> +++ b/drivers/media/platform/qcom/iris/iris_core.h
> @@ -34,6 +34,7 @@ enum domain_type {
> * struct iris_core - holds core parameters valid for all instances
> *
> * @dev: reference to device structure
> + * @cb_devs: array of context bank devices (eg: bitstream, non-pixel, pixel, etc)
> * @reg_base: IO memory base address
> * @irq: iris irq
> * @v4l2_dev: a holder for v4l2 device structure
> @@ -77,6 +78,7 @@ enum domain_type {
>
> struct iris_core {
> struct device *dev;
> + struct device *cb_devs[IRIS_MAX_REGION];
> void __iomem *reg_base;
> int irq;
> struct v4l2_device v4l2_dev;
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
> index 2273243d1a80446233dd82dcd77444aa043ad064..df63a06b8401cd367c69ab8909af227f04bf69bf 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_common.h
> +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
> @@ -204,6 +204,18 @@ struct icc_vote_data {
> u32 fps;
> };
>
> +enum iris_buffer_region {
> + IRIS_UNKNOWN_REGION,
> + IRIS_BITSTREAM_REGION,
> + IRIS_NON_PIXEL_REGION,
> + IRIS_PIXEL_REGION,
> + IRIS_SECURE_BITSTREAM_REGION,
> + IRIS_SECURE_NON_PIXEL_REGION,
> + IRIS_SECURE_PIXEL_REGION,
> + IRIS_FIRMWARE_REGION,
> + IRIS_MAX_REGION,
Why do you need this enum in addition to the DT bindings? Where are the
bindings being used?
> +};
> +
> struct iris_context_bank {
> char *name;
> u32 f_id;
> @@ -252,6 +264,8 @@ struct iris_platform_data {
> u32 inst_fw_caps_enc_size;
> const struct tz_cp_config *tz_cp_config_data;
> u32 tz_cp_config_data_size;
> + const struct iris_context_bank *cb_data;
> + const u32 cb_data_size;
> u32 core_arch;
> u32 hw_response_timeout;
> struct ubwc_config_data *ubwc_config;
> diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/platform/qcom/iris/iris_probe.c
> index ddaacda523ecb9990af0dd0640196223fbcc2cab..439e6e0fe8adf8287f81d26257ef2a7e9f21e53d 100644
> --- a/drivers/media/platform/qcom/iris/iris_probe.c
> +++ b/drivers/media/platform/qcom/iris/iris_probe.c
> @@ -123,6 +123,55 @@ static int iris_init_resets(struct iris_core *core)
> core->iris_platform_data->controller_rst_tbl_size);
> }
>
> +static void iris_destroy_child_device(struct iris_core *core, const struct iris_context_bank *cb)
> +{
> + u32 index, region_mask = cb->region_mask;
> + struct device *dev = NULL;
> +
> + while (region_mask) {
> + index = __ffs(region_mask);
> + dev = core->cb_devs[index];
> + core->cb_devs[index] = NULL;
> + region_mask &= ~BIT(index);
> + }
> +
> + if (dev)
> + device_unregister(dev);
Which devices will be unregistered? You are setting dev in a loop, which
means that only the last one will be unregistered (and only if it is not
NULL).
> +}
> +
> +static void iris_deinit_context_bank_devices(struct iris_core *core)
> +{
> + const struct iris_context_bank *cb;
> + int i;
> +
> + for (i = 0; i < core->iris_platform_data->cb_data_size; i++) {
> + cb = &core->iris_platform_data->cb_data[i];
> + iris_destroy_child_device(core, cb);
> + }
> +}
> +
> +static int iris_init_context_bank_devices(struct iris_core *core)
> +{
> + const struct iris_context_bank *cb;
> + int ret, i;
> +
> + for (i = 0; i < core->iris_platform_data->cb_data_size; i++) {
> + cb = &core->iris_platform_data->cb_data[i];
> +
> + ret = iris_create_child_device_and_map(core, cb);
> + if (ret)
> + goto err_deinit_cb;
> + }
> +
> + return 0;
> +
> +err_deinit_cb:
> + while (i-- > 0)
> + iris_destroy_child_device(core, &core->iris_platform_data->cb_data[i]);
> +
> + return ret;
> +}
> +
> static int iris_init_resources(struct iris_core *core)
> {
> int ret;
> @@ -193,6 +242,7 @@ static void iris_remove(struct platform_device *pdev)
> return;
>
> iris_core_deinit(core);
> + iris_deinit_context_bank_devices(core);
>
> video_unregister_device(core->vdev_dec);
> video_unregister_device(core->vdev_enc);
> @@ -275,12 +325,18 @@ static int iris_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, core);
>
> - dma_mask = core->iris_platform_data->dma_mask;
> -
> - ret = dma_set_mask_and_coherent(dev, dma_mask);
> + ret = iris_init_context_bank_devices(core);
> if (ret)
> goto err_vdev_unreg_enc;
>
> + dma_mask = core->iris_platform_data->dma_mask;
> +
> + if (device_iommu_mapped(core->dev)) {
> + ret = dma_set_mask_and_coherent(core->dev, dma_mask);
> + if (ret)
> + goto err_deinit_cb;
> + }
> +
> dma_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
> dma_set_seg_boundary(&pdev->dev, DMA_BIT_MASK(32));
>
> @@ -288,10 +344,12 @@ static int iris_probe(struct platform_device *pdev)
> pm_runtime_use_autosuspend(core->dev);
> ret = devm_pm_runtime_enable(core->dev);
> if (ret)
> - goto err_vdev_unreg_enc;
> + goto err_deinit_cb;
>
> return 0;
>
> +err_deinit_cb:
> + iris_deinit_context_bank_devices(core);
> err_vdev_unreg_enc:
> video_unregister_device(core->vdev_enc);
> err_vdev_unreg_dec:
> diff --git a/drivers/media/platform/qcom/iris/iris_resources.c b/drivers/media/platform/qcom/iris/iris_resources.c
> index 773f6548370a257b8ae7332242544266cbbd61a9..a2e648f4cdb8c63db89396d49f32bbc06d870ea5 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,48 @@ int iris_disable_unprepare_clock(struct iris_core *core, enum platform_clk_type
>
> return 0;
> }
> +
> +static void iris_device_release(struct device *dev)
> +{
> + dev_set_drvdata(dev, NULL);
There is no need to clean this pointer.
> + kfree(dev);
> +}
> +
> +int iris_create_child_device_and_map(struct iris_core *core, const struct iris_context_bank *cb)
> +{
> + u32 index, region_mask = cb->region_mask;
> + struct device *dev;
> + int ret;
> +
> + dev = kzalloc_obj(*dev);
> + if (!dev)
> + return -ENOMEM;
> +
> + dev->release = iris_device_release;
> + 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;
> +
> + dev_set_name(dev, "%s", cb->name);
> + dev_set_drvdata(dev, (void *)cb);
> +
> + ret = device_register(dev);
> + if (ret) {
> + put_device(dev);
> + return ret;
> + }
> +
> + if (!device_iommu_mapped(dev)) {
> + device_unregister(dev);
> + return 0;
> + }
> +
> + while (region_mask) {
> + index = __ffs(region_mask);
> + core->cb_devs[index] = dev;
This needs to have some explanation how region masks work with the
device types.
> + region_mask &= ~BIT(index);
> + }
> +
> + return 0;
> +}
> diff --git a/drivers/media/platform/qcom/iris/iris_resources.h b/drivers/media/platform/qcom/iris/iris_resources.h
> index 6bfbd2dc6db095ec05e53c894e048285f82446c6..c573016535b87d4fd140cad967d926cc1de63382 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);
> +int iris_create_child_device_and_map(struct iris_core *core, const struct iris_context_bank *cb);
>
> #endif
>
> --
> 2.34.1
>
--
With best wishes
Dmitry
next prev parent reply other threads:[~2026-03-13 15:33 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 13:19 [PATCH v3 0/7] media: iris: add support for kaanapali platform Vikash Garodia
2026-03-13 13:19 ` [PATCH v3 1/7] media: dt-bindings: qcom-kaanapali-iris: Add kaanapali video codec binding Vikash Garodia
2026-03-13 15:02 ` Dmitry Baryshkov
2026-03-13 15:16 ` Vikash Garodia
2026-03-13 15:40 ` Dmitry Baryshkov
2026-03-25 15:10 ` Vikash Garodia
2026-03-13 15:34 ` Rob Herring (Arm)
2026-03-13 15:43 ` Krzysztof Kozlowski
2026-03-25 15:10 ` Vikash Garodia
2026-03-13 13:19 ` [PATCH v3 2/7] media: iris: switch to hardware mode after firmware boot Vikash Garodia
2026-03-13 15:38 ` Dmitry Baryshkov
2026-03-24 5:15 ` Dikshita Agarwal
2026-03-25 15:14 ` Vikash Garodia
2026-03-25 15:16 ` Bryan O'Donoghue
2026-03-13 13:19 ` [PATCH v3 3/7] media: iris: add iris vpu bus support and register it with iommu_buses Vikash Garodia
2026-03-13 15:35 ` Dmitry Baryshkov
2026-03-13 13:19 ` [PATCH v3 4/7] media: iris: add context bank devices using iommu-map Vikash Garodia
2026-03-13 15:33 ` Dmitry Baryshkov [this message]
2026-03-13 13:19 ` [PATCH v3 5/7] media: iris: add helper to select context bank device Vikash Garodia
2026-03-13 15:41 ` Dmitry Baryshkov
2026-03-13 13:19 ` [PATCH v3 6/7] media: iris: add iris4 specific H265 line buffer calculation Vikash Garodia
2026-03-13 13:19 ` [PATCH v3 7/7] media: iris: add platform data for kaanapali Vikash Garodia
2026-03-13 15:46 ` Dmitry Baryshkov
2026-03-13 15:55 ` Krzysztof Kozlowski
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=2l4izvnne7mgzoepn2ckctqxpz4tbi6pgeoobon32cecyf64mz@mhx5bicwp5na \
--to=dmitry.baryshkov@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=bod@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=busanna.reddy@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=hverkuil+cisco@kernel.org \
--cc=hverkuil@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=saravanak@kernel.org \
--cc=stefan.schmidt@linaro.org \
--cc=vikash.garodia@oss.qualcomm.com \
--cc=will@kernel.org \
/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