All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vishnu Reddy" <busanna.reddy@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v7 04/12] media: iris: Add context bank hooks for platform specific initialization
Date: Wed, 03 Jun 2026 14:36:00 +0000	[thread overview]
Message-ID: <20260603143600.87F901F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260603-glymur-v7-4-afaa55d11fe0@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Concurrent calls to `iris_core_init` can bypass hardware initialization and use uninitialized hardware.
- [High] Failure during `iris_wait_for_system_response` leaves hardware initialized and memory allocated without cleanup, leading to permanent DMA memory leaks on subsequent opens.
--

commit 378c8a359d3ed3242ace4eba3b25ac54fcc682b5
Author: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>

    media: iris: Add context bank hooks for platform specific initialization

This patch adds initialization and de-initialization hooks for platform-specific
context bank devices. These hooks are required for the glymur platform where
Linux runs as the hypervisor and the driver must manually manage the firmware
IOMMU mapping.

> diff --git a/drivers/media/platform/qcom/iris/iris_core.c b/drivers/media/platform/qcom/iris/iris_core.c
> index 52bf56e517f91..89dbe9bbf6b0a 100644
> --- a/drivers/media/platform/qcom/iris/iris_core.c
> +++ b/drivers/media/platform/qcom/iris/iris_core.c
[ ... ]
> @@ -58,10 +59,14 @@ int iris_core_init(struct iris_core *core)
>  
>  	core->state = IRIS_CORE_INIT;

[Severity: High]
This is a pre-existing issue, but does setting the state to IRIS_CORE_INIT
here before initialization completes create a concurrency flaw?

If a second thread calls iris_core_init() while the first thread unlocks
core->lock and waits for the system response:

drivers/media/platform/qcom/iris/iris_core.c:iris_core_init() {
    ...
	mutex_unlock(&core->lock);

	return iris_wait_for_system_response(core);
}

The second thread would see core->state == IRIS_CORE_INIT and return 0
immediately, bypassing hardware initialization and allowing user-space to
issue ioctls before the hardware finishes booting.

Can this cause firmware crashes or unhandled hardware states?

>  
> -	ret = iris_hfi_queues_init(core);
> +	ret = iris_init_cb_devs(core);
>  	if (ret)
>  		goto error;
>  
> +	ret = iris_hfi_queues_init(core);
> +	if (ret)
> +		goto error_deinit_cb_devs;
> +
>  	ret = iris_vpu_power_on(core);
>  	if (ret)
>  		goto error_queue_deinit;
[ ... ]
> @@ -94,6 +99,8 @@ int iris_core_init(struct iris_core *core)
>  	iris_vpu_power_off(core);
>  error_queue_deinit:
>  	iris_hfi_queues_deinit(core);
> +error_deinit_cb_devs:
> +	iris_deinit_cb_devs(core);
>  error:
>  	core->state = IRIS_CORE_DEINIT;

[Severity: High]
This isn't a bug introduced by this patch, but if
iris_wait_for_system_response() times out, it sets
core->state = IRIS_CORE_ERROR and returns -ETIMEDOUT. Since the VFS release
is never called on an open failure, the queues and the newly added context
bank devices remain allocated.

When a second open() attempt calls iris_core_init(), it sees the ERROR state
and jumps to the error label:

drivers/media/platform/qcom/iris/iris_core.c:iris_core_init() {
    ...
	} else if (core->state == IRIS_CORE_ERROR) {
		ret = -EINVAL;
		goto error;
	}
    ...
}

At the error label, the state is simply reset to DEINIT without freeing any
previously allocated resources like queues or cb_devs. A third open() attempt
will see the DEINIT state and proceed with a full initialization, allocating
new DMA memory and overwriting the old pointers.

Does this permanently leak the previously allocated resources?

>  exit:

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260603-glymur-v7-0-afaa55d11fe0@oss.qualcomm.com?part=4

  reply	other threads:[~2026-06-03 14:36 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 14:18 [PATCH v7 00/12] media: iris: Add support for glymur platform Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 01/12] media: iris: Add iris vpu bus support Vishnu Reddy
2026-06-03 14:45   ` sashiko-bot
2026-06-08  5:35     ` Vishnu Reddy
2026-06-03 23:14   ` Dmitry Baryshkov
2026-06-03 14:18 ` [PATCH v7 02/12] iommu: Add iris-vpu-bus to iommu_buses Vishnu Reddy
2026-06-03 14:34   ` sashiko-bot
2026-06-08  5:37     ` Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 03/12] dt-bindings: media: qcom,glymur-iris: Add glymur video codec Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 04/12] media: iris: Add context bank hooks for platform specific initialization Vishnu Reddy
2026-06-03 14:36   ` sashiko-bot [this message]
2026-06-08  5:38     ` Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 05/12] media: iris: Enable Secure PAS support with IOMMU managed by Linux Vishnu Reddy
2026-06-03 14:39   ` sashiko-bot
2026-06-07 21:39     ` Dmitry Baryshkov
2026-06-08  5:38       ` Vishnu Reddy
2026-06-08  5:38     ` Vishnu Reddy
2026-06-08  5:55       ` Dmitry Baryshkov
2026-06-08  6:15         ` Vishnu Reddy
2026-06-07 21:38   ` Dmitry Baryshkov
2026-06-03 14:18 ` [PATCH v7 06/12] media: iris: Replace enum-indexed clock and power domain tables with per-block structures Vishnu Reddy
2026-06-03 14:37   ` sashiko-bot
2026-06-07 21:44     ` Dmitry Baryshkov
2026-06-08  5:38       ` Vishnu Reddy
2026-06-08  5:39     ` Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 07/12] media: iris: Add power sequence for glymur Vishnu Reddy
2026-06-07 21:47   ` Dmitry Baryshkov
2026-06-08  5:39     ` Vishnu Reddy
2026-06-08 12:08       ` Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 08/12] media: iris: Handle CPU_CS_SCIACMDARG3 register write via program bootup registers hook Vishnu Reddy
2026-06-07 21:48   ` Dmitry Baryshkov
2026-06-03 14:18 ` [PATCH v7 09/12] media: iris: Add support to select core for dual core platforms Vishnu Reddy
2026-06-03 14:44   ` sashiko-bot
2026-06-07 21:49     ` Dmitry Baryshkov
2026-06-08  5:39     ` Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 10/12] media: iris: Add platform data for glymur Vishnu Reddy
2026-06-03 14:46   ` sashiko-bot
2026-06-08  5:41     ` Vishnu Reddy
2026-06-07 21:50   ` Dmitry Baryshkov
2026-06-03 14:18 ` [PATCH v7 11/12] arm64: dts: qcom: glymur: Add iris video node Vishnu Reddy
2026-06-07 21:51   ` Dmitry Baryshkov
2026-06-03 14:18 ` [PATCH v7 12/12] arm64: dts: qcom: glymur-crd: Enable iris video codec node Vishnu Reddy
2026-06-07 21:51   ` Dmitry Baryshkov
2026-06-08  5:30 ` [PATCH v7 00/12] media: iris: Add support for glymur platform Vikash Garodia

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=20260603143600.87F901F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=busanna.reddy@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.