public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
To: Dmitry Baryshkov <dmitry.baryshkov@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 v2 5/7] media: iris: add helper to select context bank device
Date: Wed, 4 Mar 2026 20:59:24 +0530	[thread overview]
Message-ID: <22b3e2e9-b855-487e-868f-e72fcbbb22cd@oss.qualcomm.com> (raw)
In-Reply-To: <jgygscmwovezkytizhh54cmmu5etgv23bgopfqrql3qj7zlhxh@adxo2b7izlrc>


On 3/4/2026 3:57 AM, Dmitry Baryshkov wrote:
> On Wed, Mar 04, 2026 at 12:46:27AM +0530, Vikash Garodia wrote:
>>
>>
>> On 2/28/2026 1:57 AM, Dmitry Baryshkov wrote:
>>> On Fri, Feb 27, 2026 at 07:41:21PM +0530, Vikash Garodia wrote:
>>>> Depending on the buffer type (input, output, internal and interface
>>>> queues), associated context bank is selected, if available. Fallback to
>>>> parent device for backward compatibility.
>>>>
>>>> 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_buffer.c    |  7 +--
>>>>    drivers/media/platform/qcom/iris/iris_buffer.h    |  2 +
>>>>    drivers/media/platform/qcom/iris/iris_hfi_queue.c | 16 +++---
>>>>    drivers/media/platform/qcom/iris/iris_resources.c | 60 +++++++++++++++++++++++
>>>>    drivers/media/platform/qcom/iris/iris_resources.h |  2 +
>>>>    drivers/media/platform/qcom/iris/iris_vidc.c      |  4 +-
>>>>    6 files changed, 79 insertions(+), 12 deletions(-)
>>>>
>>>> @@ -177,3 +178,62 @@ int iris_create_child_device_and_map(struct iris_core *core, struct iris_context
>>>>    	return 0;
>>>>    }
>>>> +
>>>> +static enum iris_buffer_region iris_get_region(struct iris_inst *inst,
>>>> +					       enum iris_buffer_type buffer_type)
>>>> +{
>>>> +	switch (buffer_type) {
>>>> +	case BUF_INPUT:
>>>> +		if (inst && inst->domain == ENCODER)
>>>
>>> Can inst be NULL here?
>>
>> during queues init/deinit, instances are not created.
> 
> Is this function being called during queues init?

yes, via iris_get_cb_dev()

> 
>>
>>>
>>>> +			return IRIS_PIXEL_REGION;
>>>> +		else if (inst && inst->domain == DECODER)
>>>> +			return IRIS_BITSTREAM_REGION;
>>>
>>> Are there any other possibilities than encoder and decoder?
>>
>> will simplify it as
>>
>> if (inst) {
>>      if (inst->domain == ENCODER)
>>          return IRIS_PIXEL_REGION;
>>      else
>>          return IRIS_BITSTREAM_REGION;
>> }
>>>
>>>> +		break;
>>>> +	case BUF_OUTPUT:
>>>> +		if (inst && inst->domain == ENCODER)
>>>> +			return IRIS_BITSTREAM_REGION;
>>>> +		else if (inst && inst->domain == DECODER)
>>>> +			return IRIS_PIXEL_REGION;
>>>> +		break;
>>>> +	case BUF_BIN:
>>>> +		return IRIS_BITSTREAM_REGION;
>>>> +	case BUF_DPB:
>>>> +	case BUF_PARTIAL:
>>>> +	case BUF_SCRATCH_2:
>>>> +	case BUF_VPSS:
>>>> +		return IRIS_PIXEL_REGION;
>>>> +	case BUF_ARP:
>>>> +	case BUF_COMV:
>>>> +	case BUF_HFI_QUEUE:
>>>> +	case BUF_LINE:
>>>> +	case BUF_NON_COMV:
>>>> +	case BUF_PERSIST:
>>>> +		return IRIS_NON_PIXEL_REGION;
>>>> +	default:
>>>> +		return 0;
>>>
>>> dev_err(dev, "unsupported buffer type %x\n", buffer_type)
>>> return -EINVAL;
>>
>> these are bit fields, returning -EINVAL would still match some bits and can
>> make the logic as true. 0 can be defined as IRIS_UNKNOWN_REGION
> 
> Yes, sounds good.
> 
>>
>>>
>>>> +	}
>>>> +
>>>> +	return 0;
>>>
>>> Drop
>>>
>>
>> Ack
>>
>>>> +}
>>>> +
>>>> +struct device *iris_get_cb_dev(struct iris_core *core, struct iris_inst *inst,
>>>> +			       enum iris_buffer_type buffer_type)
>>>> +{
>>>> +	enum iris_buffer_region region;
>>>> +	struct device *dev = NULL;
>>>> +	int i;
>>>> +
>>>> +	region = iris_get_region(inst, buffer_type);
>>>> +
>>>> +	for (i = 0; i < core->iris_platform_data->cb_data_size; i++) {
>>>> +		if (core->iris_platform_data->cb_data[i].region & region) {
>>>> +			dev = core->iris_platform_data->cb_data[i].dev;
>>>> +			break;
>>>> +		}
>>>
>>> You really seem to overcomplicate things. Replace array search with the
>>> indexed array access. Much easier and much better.
>>>
>>> enum iris_buffer_region {
>>> 	IRIS_PIXEL_REGION,
>>> 	IRIS_BITSTREAM_REGION,
>>> 	IRIS_NON_PIXEL_REGION,
>>> 	// add more when necessary
>>> 	IRIS_NUM_REGIONS,
>>> };
>>>
>>> struct iris_core {
>>> 	struct iris_cb_device cb_devices[IRIS_NUM_REGIONS];
>>> };
>>>
>>> region = iris_get_region(inst, buffer_type);
>>> dev = core->cb_devices[region];
>>
>> all the regions may/may not be present in all SOC
> 
> You can check for dev != NULL afterwards.

with one CB to multiple region mapping, this logic would not work.

Regards,
Vikash

> 
> 


  reply	other threads:[~2026-03-04 15:29 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27 14:11 [PATCH v2 0/7] media: iris: add support for kaanapali platform Vikash Garodia
2026-02-27 14:11 ` [PATCH v2 1/7] media: dt-bindings: qcom-kaanapali-iris: Add kaanapali video codec binding Vikash Garodia
2026-02-27 15:42   ` Rob Herring (Arm)
2026-02-27 15:50   ` Krzysztof Kozlowski
2026-02-27 15:55     ` Krzysztof Kozlowski
2026-03-03 18:10     ` Vikash Garodia
2026-03-04 15:07       ` Krzysztof Kozlowski
2026-03-05 12:23         ` Vikash Garodia
2026-02-27 19:52   ` Dmitry Baryshkov
2026-03-03 18:13     ` Vikash Garodia
2026-03-03 23:53       ` Dmitry Baryshkov
2026-03-04 15:02         ` Vikash Garodia
2026-03-05  3:33           ` Dmitry Baryshkov
2026-02-27 14:11 ` [PATCH v2 2/7] media: iris: switch to hardware mode after firmware boot Vikash Garodia
2026-02-27 16:49   ` Konrad Dybcio
2026-03-03 18:15     ` Vikash Garodia
2026-03-04  8:57       ` Konrad Dybcio
2026-02-27 14:11 ` [PATCH v2 3/7] media: iris: add iris vpu bus support and register it with iommu_buses Vikash Garodia
2026-02-27 15:49   ` Krzysztof Kozlowski
2026-03-03 18:26     ` Vikash Garodia
2026-02-27 20:14   ` Dmitry Baryshkov
2026-02-27 14:11 ` [PATCH v2 4/7] media: iris: add context bank devices using iommu-map Vikash Garodia
2026-02-27 20:20   ` Dmitry Baryshkov
2026-03-03 18:46     ` Vikash Garodia
2026-03-03 22:25       ` Dmitry Baryshkov
2026-03-05 12:49         ` Vikash Garodia
2026-03-05 14:21           ` Dmitry Baryshkov
2026-03-05 17:26             ` Vikash Garodia
2026-03-05 18:32               ` Dmitry Baryshkov
2026-03-05 21:34                 ` Vikash Garodia
2026-03-13 19:26                   ` Dmitry Baryshkov
2026-02-27 14:11 ` [PATCH v2 5/7] media: iris: add helper to select context bank device Vikash Garodia
2026-02-27 20:27   ` Dmitry Baryshkov
2026-03-03 19:16     ` Vikash Garodia
2026-03-03 22:27       ` Dmitry Baryshkov
2026-03-04 15:29         ` Vikash Garodia [this message]
2026-03-05  3:40           ` Dmitry Baryshkov
2026-02-27 14:11 ` [PATCH v2 6/7] media: iris: add iris4 specific H265 line buffer calculation Vikash Garodia
2026-02-27 20:28   ` Dmitry Baryshkov
2026-03-03 18:48     ` Vikash Garodia
2026-03-03 22:28       ` Dmitry Baryshkov
2026-03-04 15:40         ` Vikash Garodia
2026-03-05  3:41           ` Dmitry Baryshkov
2026-02-27 14:11 ` [PATCH v2 7/7] media: iris: add platform data for kaanapali Vikash Garodia
2026-02-27 15:48   ` Krzysztof Kozlowski
2026-02-28  7:31     ` Dmitry Baryshkov
2026-02-27 15:42 ` [PATCH v2 0/7] media: iris: add support for kaanapali platform Bryan O'Donoghue

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=22b3e2e9-b855-487e-868f-e72fcbbb22cd@oss.qualcomm.com \
    --to=vikash.garodia@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=dmitry.baryshkov@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=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