media: iris: Add support for glymur platform
Subsystems (8)
v7 cover media: iris: Add support for glymur platform
Glymur is a new generation video codec that supports dual hardware cores along with additional power domains and clocks.
This series adds platform specific support in the iris driver to handle the extra cores, power domains, and clock requirements introduced by glymur. Add support for firmware loading through context bank firmware device.
Dependencies and merge strategy:
Patch[1-2]: IOMMU maintainer need to apply and provide an immutable tag which can merged into media tree.
Patch[3-9]: Media maintainer can pick them independently.
Patch[10]: Media maintainer can apply this once tag for patch[1-2] is available.
Patch[11-12]: Glymur iris DT node, depends on patch[3].
v4l2-compliance report for decoder including streaming tests:
v4l2-compliance 1.33.0-5441, 64 bits, 64-bit time_t v4l2-compliance SHA: 4310f15610f4 2026-01-18 22:09:17
Compliance test for iris_driver device /dev/video0:
Driver Info:
Driver name : iris_driver
Card type : Iris Decoder
Bus info : platform:aa00000.video-codec
Driver version : 7.1.0
Capabilities : 0x84204000 Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Detected Stateful Decoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 12 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported) test blocking wait: OK
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported)
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers test MMAP (select, REQBUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers test MMAP (epoll, REQBUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers test MMAP (select, CREATE_BUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers test MMAP (epoll, CREATE_BUFS): OK
test USERPTR (select): OK (Not Supported) test DMABUF: Cannot test, specify --expbuf-device
Total for iris_driver device /dev/video0: 54, Succeeded: 54, Failed: 0, Warnings: 0
v4l2-compliance report for encoder including streaming tests:
v4l2-compliance 1.33.0-5441, 64 bits, 64-bit time_t v4l2-compliance SHA: 4310f15610f4 2026-01-18 22:09:17
Compliance test for iris_driver device /dev/video1:
Driver Info:
Driver name : iris_driver
Card type : Iris Encoder
Bus info : platform:aa00000.video-codec
Driver version : 7.1.0
Capabilities : 0x84204000 Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Detected Stateful Encoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video1 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 43 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK
test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported) test blocking wait: OK
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported) Video Capture Multiplanar: Captured 61 buffers test MMAP (select, REQBUFS): OK
Video Capture Multiplanar: Captured 61 buffers test MMAP (epoll, REQBUFS): OK
Video Capture Multiplanar: Captured 61 buffers test MMAP (select, CREATE_BUFS): OK Video Capture Multiplanar: Captured 61 buffers test MMAP (epoll, CREATE_BUFS): OK
test USERPTR (select): OK (Not Supported) test DMABUF: Cannot test, specify --expbuf-device
Total for iris_driver device /dev/video1: 54, Succeeded: 54, Failed: 0, Warnings: 0
Fluster test report:
77/135 while testing JVT-AVC_V1 with
GStreamer-H.264-V4L2-Gst1.0.JVT-AVC_V1
The failing tests are:
- 52 test vectors failed due to interlaced clips: Interlaced decoding is not supported.
- cabac_mot_fld0_full
- cabac_mot_mbaff0_full
- cabac_mot_picaff0_full
- CABREF3_Sand_D
- CAFI1_SVA_C
- CAMA1_Sony_C
- CAMA1_TOSHIBA_B
- cama1_vtc_c
- cama2_vtc_b
- CAMA3_Sand_E
- cama3_vtc_b
- CAMACI3_Sony_C
- CAMANL1_TOSHIBA_B
- CAMANL2_TOSHIBA_B
- CAMANL3_Sand_E
- CAMASL3_Sony_B
- CAMP_MOT_MBAFF_L30
- CAMP_MOT_MBAFF_L31
- CANLMA2_Sony_C
- CANLMA3_Sony_C
- CAPA1_TOSHIBA_B
- CAPAMA3_Sand_F
- cavlc_mot_fld0_full_B
- cavlc_mot_mbaff0_full_B
- cavlc_mot_picaff0_full_B
- CVCANLMA2_Sony_C
- CVFI1_Sony_D
- CVFI1_SVA_C
- CVFI2_Sony_H
- CVFI2_SVA_C
- CVMA1_Sony_D
- CVMA1_TOSHIBA_B
- CVMANL1_TOSHIBA_B
- CVMANL2_TOSHIBA_B
- CVMAPAQP3_Sony_E
- CVMAQP2_Sony_G
- CVMAQP3_Sony_D
- CVMP_MOT_FLD_L30_B
- CVNLFI1_Sony_C
- CVNLFI2_Sony_H
- CVPA1_TOSHIBA_B
- FI1_Sony_E
- MR6_BT_B
- MR7_BT_B
- MR8_BT_B
- MR9_BT_B
- Sharp_MP_Field_1_B
- Sharp_MP_Field_2_B
- Sharp_MP_Field_3_B
- Sharp_MP_PAFF_1r2
- Sharp_MP_PAFF_2r
- CVMP_MOT_FRM_L31_B
3 test case failed due to unsupported bitstream. num_slice_groups_minus1 greater than zero is not supported.
- FM1_BT_B
- FM1_FT_E
- FM2_SVA_C
2 test case failed because SP_SLICE type is not supported.
- SP1_BT_A
- sp2_bt_b
1 test case failed due to unsupported profile.
- BA3_SVA_C
131/147 testcases passed while testing JCT-VC-HEVC_V1 with GStreamer-H.265-V4L2-Gst1.0
10 testcases failed due to unsupported 10 bit format.
- DBLK_A_MAIN10_VIXS_4
- INITQP_B_Main10_Sony_1
- TSUNEQBD_A_MAIN10_Technicolor_2
- WP_A_MAIN10_Toshiba_3
- WP_MAIN10_B_Toshiba_3
- WPP_A_ericsson_MAIN10_2
- WPP_B_ericsson_MAIN10_2
- WPP_C_ericsson_MAIN10_2
- WPP_E_ericsson_MAIN10_2
- WPP_F_ericsson_MAIN10_2
4 testcase failed due to unsupported resolution.
- PICSIZE_A_Bossen_1
- PICSIZE_B_Bossen_1
- WPP_D_ericsson_MAIN10_2
- WPP_D_ericsson_MAIN_2
2 testcase failed due to CRC mismatch.
- VPSSPSPPS_A_MainConcept_1
This fails with software decoder as well. Refer the below link for the discussion happened for earlier platform.
https://lore.kernel.org/all/[email protected]/
- RAP_A_docomo_6
This was discussed on bug report
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4392
Based on above discussion, the initial error frames need to be dropped in the firmware or driver. Discussion ongoing with video firmware team on a way to handle such case. This issue is not specific to this platform, and its there on other platforms also.
235/305 testcases passed while testing VP9-TEST-VECTORS with GStreamer-VP9-V4L2-Gst1.0 64 testcases failed due to unsupported resolution
- vp90-2-02-size-08x08.webm
- vp90-2-02-size-08x10.webm
- vp90-2-02-size-08x16.webm
- vp90-2-02-size-08x18.webm
- vp90-2-02-size-08x32.webm
- vp90-2-02-size-08x34.webm
- vp90-2-02-size-08x64.webm
- vp90-2-02-size-08x66.webm
- vp90-2-02-size-10x08.webm
- vp90-2-02-size-10x10.webm
- vp90-2-02-size-10x16.webm
- vp90-2-02-size-10x18.webm
- vp90-2-02-size-10x32.webm
- vp90-2-02-size-10x34.webm
- vp90-2-02-size-10x64.webm
- vp90-2-02-size-10x66.webm
- vp90-2-02-size-16x08.webm
- vp90-2-02-size-16x10.webm
- vp90-2-02-size-16x16.webm
- vp90-2-02-size-16x18.webm
- vp90-2-02-size-16x32.webm
- vp90-2-02-size-16x34.webm
- vp90-2-02-size-16x64.webm
- vp90-2-02-size-16x66.webm
- vp90-2-02-size-18x08.webm
- vp90-2-02-size-18x10.webm
- vp90-2-02-size-18x16.webm
- vp90-2-02-size-18x18.webm
- vp90-2-02-size-18x32.webm
- vp90-2-02-size-18x34.webm
- vp90-2-02-size-18x64.webm
- vp90-2-02-size-18x66.webm
- vp90-2-02-size-32x08.webm
- vp90-2-02-size-32x10.webm
- vp90-2-02-size-32x16.webm
- vp90-2-02-size-32x18.webm
- vp90-2-02-size-32x32.webm
- vp90-2-02-size-32x34.webm
- vp90-2-02-size-32x64.webm
- vp90-2-02-size-32x66.webm
- vp90-2-02-size-34x08.webm
- vp90-2-02-size-34x10.webm
- vp90-2-02-size-34x16.webm
- vp90-2-02-size-34x18.webm
- vp90-2-02-size-34x32.webm
- vp90-2-02-size-34x34.webm
- vp90-2-02-size-34x64.webm
- vp90-2-02-size-34x66.webm
- vp90-2-02-size-64x08.webm
- vp90-2-02-size-64x10.webm
- vp90-2-02-size-64x16.webm
- vp90-2-02-size-64x18.webm
- vp90-2-02-size-64x32.webm
- vp90-2-02-size-64x34.webm
- vp90-2-02-size-64x64.webm
- vp90-2-02-size-64x66.webm
- vp90-2-02-size-66x08.webm
- vp90-2-02-size-66x10.webm
- vp90-2-02-size-66x16.webm
- vp90-2-02-size-66x18.webm
- vp90-2-02-size-66x32.webm
- vp90-2-02-size-66x34.webm
- vp90-2-02-size-66x64.webm
- vp90-2-02-size-66x66.webm
2 testcases failed due to unsupported format.
- vp91-2-04-yuv422.webm
- vp91-2-04-yuv444.webm
2 testcase failed due to unsupported resolution after DRC.
- vp90-2-21-resize_inter_320x180_5_1-2.webm
- vp90-2-21-resize_inter_320x180_7_1-2.webm
1 testcase failed with CRC mismatch.
- vp90-2-22-svc_1280x720_3.ivf
This VP9 bitstream contains 20 superframes, and each superframe consists of three subframes in the following order:
• 180p subframe
• 360p subframe
• 720p subframe
Each superframe is submitted to the driver and firmware as a single input buffer, with one common timestamp attached to it. For every such input buffer, the hardware decoder produces three corresponding output buffers, one for each resolution (180p, 360p, and 720p), and all three output buffers carry the same timestamp. When these output buffers are returned to the client (GStreamer, in this case), the first buffer returned is displayed, while the remaining two buffers are dropped due to having identical timestamps. As a result, only one frame per superframe is rendered. Here the expectation of the test result is with 720p, last decoded frame in each super frame.
Discussion ongoing with firmware team and gst maintainer on how to handle this case. This is not specific to glymur, and its there for the other platforms also.
1 testcase failed due to unsupported stream.
- vp90-2-16-intra-only.webm
---
Changes in v7:
- Replaced enum-indexed clock and power domain tables with per-block structures (Dmitry)
- Combined venus common schema update patch and glymur video binding patch (Krzysztof)
- Updated CPU_CS_SCIACMDARG3 write value as zero specific to glymur platform (Dmitry)
- Updated the clock and reset names (Dmitry)
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- Rename function names in iris_vpu_bus (Dmitry)
- Update the venus-common schema (Dmitry, Krzysztof)
- Add dual core related functions into platform specific vpu ops (Dmitry)
- Update power domain enum names (Vikash)
- Remove unused macro
- Link to v5: https://lore.kernel.org/r/[email protected]/
Changes in v5:
- Remove clocks, clock-names, power-domains from the required list in venus-common schema (Krzysztof)
- Update core selection logic (Vikash)
- Add macros for power status bits instead of magical values (Vikash)
- Add new config for iris vpu bus instead of using the iris driver
config.
- Re-arrage the patches (Krzysztof)
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Update existing venus common binding.
- Update glymur DT binding required properties.
- Patches are rebased and resolved merge conflicts.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Drop generic dma context bus and moved to iris vpu bus (Greg)
- Update commit message for platform data patch (Dmitry)
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Update the clock and reset names in DT binding (Krzysztof)
- Update firmware device names (Mukesh, Konrad)
- Update the selection of core for dual core platforms
- Add new generic dma context bus instead of own iris vpu bus (Dmitry)
- Add patch to get power domain type to look up pd_devs index
- Update glymur platform data (Dmitry)
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Mukesh Ojha (1):
media: iris: Enable Secure PAS support with IOMMU managed by Linux
Vikash Garodia (2):
media: iris: Add iris vpu bus support
iommu: Add iris-vpu-bus to iommu_buses
Vishnu Reddy (9):
dt-bindings: media: qcom,glymur-iris: Add glymur video codec
media: iris: Add context bank hooks for platform specific initialization
media: iris: Replace enum-indexed clock and power domain tables with per-block structures
media: iris: Add power sequence for glymur
media: iris: Handle CPU_CS_SCIACMDARG3 register write via program bootup registers hook
media: iris: Add support to select core for dual core platforms
media: iris: Add platform data for glymur
arm64: dts: qcom: glymur: Add iris video node
arm64: dts: qcom: glymur-crd: Enable iris video codec node
.../bindings/media/qcom,glymur-iris.yaml | 208 +++++++++++++++++++++ .../bindings/media/qcom,venus-common.yaml | 8 +- MAINTAINERS | 1 + arch/arm64/boot/dts/qcom/glymur-crd.dts | 6 + arch/arm64/boot/dts/qcom/glymur.dtsi | 118 ++++++++++++ drivers/iommu/iommu.c | 4 + drivers/media/platform/qcom/iris/Kconfig | 4 + drivers/media/platform/qcom/iris/Makefile | 2 + drivers/media/platform/qcom/iris/iris_common.c | 10 + drivers/media/platform/qcom/iris/iris_common.h | 1 + drivers/media/platform/qcom/iris/iris_core.c | 9 +- drivers/media/platform/qcom/iris/iris_core.h | 31 ++- drivers/media/platform/qcom/iris/iris_firmware.c | 73 +++++++- drivers/media/platform/qcom/iris/iris_hfi_common.h | 1 + .../platform/qcom/iris/iris_hfi_gen2_command.c | 19 ++ .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + drivers/media/platform/qcom/iris/iris_instance.h | 2 + .../platform/qcom/iris/iris_platform_common.h | 46 ++--- .../platform/qcom/iris/iris_platform_glymur.c | 106 +++++++++++ .../platform/qcom/iris/iris_platform_glymur.h | 17 ++ .../platform/qcom/iris/iris_platform_sc7280.h | 28 ++- .../platform/qcom/iris/iris_platform_sm8250.h | 26 ++- .../platform/qcom/iris/iris_platform_sm8550.h | 26 ++- .../platform/qcom/iris/iris_platform_sm8750.h | 29 ++- .../media/platform/qcom/iris/iris_platform_vpu2.c | 14 +- .../media/platform/qcom/iris/iris_platform_vpu3x.c | 67 ++++--- .../platform/qcom/iris/iris_platform_x1p42100.h | 27 ++- drivers/media/platform/qcom/iris/iris_power.c | 20 +- drivers/media/platform/qcom/iris/iris_probe.c | 126 +++++++++++-- drivers/media/platform/qcom/iris/iris_resources.c | 65 +------ drivers/media/platform/qcom/iris/iris_resources.h | 7 +- drivers/media/platform/qcom/iris/iris_utils.c | 58 ++++-- drivers/media/platform/qcom/iris/iris_utils.h | 3 +- drivers/media/platform/qcom/iris/iris_vb2.c | 4 + drivers/media/platform/qcom/iris/iris_vidc.c | 6 +- drivers/media/platform/qcom/iris/iris_vpu3x.c | 200 +++++++++++++++++--- drivers/media/platform/qcom/iris/iris_vpu4x.c | 137 ++------------ drivers/media/platform/qcom/iris/iris_vpu_bus.c | 61 ++++++ drivers/media/platform/qcom/iris/iris_vpu_common.c | 116 +++--------- drivers/media/platform/qcom/iris/iris_vpu_common.h | 7 + .../platform/qcom/iris/iris_vpu_register_defines.h | 11 ++ include/dt-bindings/media/qcom,glymur-iris.h | 11 ++ include/linux/iris_vpu_bus.h | 25 +++ 43 files changed, 1297 insertions(+), 444 deletions(-)
---
base-commit: b7bee4ca5688e30ca50fbc87b1b8f7eed7006c17
change-id: 20260601-glymur-4fcd4d832ecc
Best regards,
Signature · 1 line
Vishnu Reddy <[email protected]>
PATCH v7 1/12 media: iris: Add iris vpu bus support
From: Vikash Garodia <[email protected]>
On glymur platform, firmware loading needs a separate IOMMU mapping with its own stream ID. This stream ID is defined in the device tree with the associated firmware function ID in the iommu-map property. To create this mapping, a separate child device is needed so the firmware memory can be isolated in its own IOMMU context.
Introduce a new bus called iris-vpu-bus. This creates a dynamic device, and its dma_configure() callback calls of_dma_configure_id() with the function ID provided by the client to map the corresponding stream ID. This sets up a dedicated IOMMU context for the child device.
--- MAINTAINERS | 1 + drivers/media/platform/qcom/iris/Kconfig | 4 ++ drivers/media/platform/qcom/iris/Makefile | 1 + drivers/media/platform/qcom/iris/iris_vpu_bus.c | 61 +++++++++++++++++++++++++ include/linux/iris_vpu_bus.h | 25 ++++++++++ 5 files changed, 92 insertions(+)
MAINTAINERS +1 -0
@@ -22230,6 +22230,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/media/qcom,*-iris.yaml F: drivers/media/platform/qcom/iris/ +F: include/linux/iris_vpu_bus.h QUALCOMM NAND CONTROLLER DRIVER M: Manivannan Sadhasivam <[email protected]>
drivers/media/platform/qcom/iris/Kconfig +4 -0
@@ -1,3 +1,6 @@ +config QCOM_IRIS_VPU_BUS + bool + config VIDEO_QCOM_IRIS tristate "Qualcomm iris V4L2 decoder driver" depends on VIDEO_DEV
@@ -5,6 +8,7 @@ config VIDEO_QCOM_IRIS select V4L2_MEM2MEM_DEV select QCOM_MDT_LOADER select QCOM_SCM + select QCOM_IRIS_VPU_BUS select QCOM_UBWC_CONFIG select VIDEOBUF2_DMA_CONTIG help
drivers/media/platform/qcom/iris/Makefile +1 -0
@@ -30,3 +30,4 @@ qcom-iris-objs += iris_buffer.o \ iris_vpu_common.o \ obj-$(CONFIG_VIDEO_QCOM_IRIS) += qcom-iris.o +obj-$(CONFIG_QCOM_IRIS_VPU_BUS) += iris_vpu_bus.o
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +61 -0
61 lines not on this page · raw message
include/linux/iris_vpu_bus.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) Qualcomm Innovation Center, Inc. All rights reserved. +*/ + +#ifndef _LINUX_IRIS_VPU_BUS_H +#define _LINUX_IRIS_VPU_BUS_H + +#include <linux/device.h> + +#ifdef CONFIG_QCOM_IRIS_VPU_BUS +extern const struct bus_type iris_vpu_bus_type; + +struct device *iris_vpu_bus_create_device (struct device *parent_device,const char *name, +u64 dma_mask,const u32 *iommu_fid); +#else +static inline struct device *iris_vpu_bus_create_device (struct device *parent_device, +const char *name,u64 dma_mask, +const u32 *iommu_fid) +{ +return ERR_PTR (-ENODEV ); +} +#endif + +#endif /* _LINUX_IRIS_VPU_BUS_H */
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v7 01/12] media: iris: Add iris vpu bus support
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The dynamic device's `platform_data` is initialized with a pointer to a short-lived stack…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The dynamic device's platform_data is initialized with a pointer to a short-lived stack variable, creating a persistent dangling pointer vulnerability.
- [High] A devm allocation tied to the persistent core device causes a memory leak on every firmware reload.
--
commit 5c9139b17fe941a07d06bbded6b06a8c47d21867
Author: Vikash Garodia <[email protected]>
media: iris: Add iris vpu bus support
On glymur platform, firmware loading needs a separate IOMMU mapping with its own stream ID. This stream ID is defined in the device tree with the associated firmware function ID in the iommu-map property. To create this mapping, a separate child device is needed so the firmware memory can be isolated in its own IOMMU context.
Introduce a new bus called iris-vpu-bus. This creates a dynamic device, and its dma_configure() callback calls of_dma_configure_id() with the function ID provided by the client to map the corresponding stream ID. This sets up a dedicated IOMMU context for the child device.
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +3
-0@@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) Qualcomm Innovation Center, Inc. All rights reserved.
drivers/media/platform/qcom/iris/iris_vpu_bus.c line 13
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +10
-0+*/ + +#include <linux/device.h> +#include <linux/iris_vpu_bus.h> +#include <linux/of_device.h> +#include <linux/slab.h> + +static int iris_vpu_bus_dma_configure (struct device *dev) +{ +const u32 *iommu_fid = (const u32 *)dev_get_platdata (dev);
[Severity: High]
Can this dereference a dangling pointer if the dma_configure callback executes asynchronously?
The iommu_fid pointer is populated in iris_vpu_bus_create_device() directly from the caller's argument, which in iris_glymur_init_cb_devs() points to a local stack variable. If this callback runs later (e.g., deferred probing), it will read invalid stack memory.
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +3
-0+ +return of_dma_configure_id (dev, dev->parent->of_node, true, iommu_fid); +}
[ ... ]
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +6
-0+struct device *iris_vpu_bus_create_device (struct device *parent_device,const char *name, +u64 dma_mask,const u32 *iommu_fid) +{ +struct device *dev; +int ret; +
drivers/media/platform/qcom/iris/iris_vpu_bus.c line 44
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +10
-0+ dev =kzalloc_obj (*dev); +if (!dev) +return ERR_PTR (-ENOMEM ); + + dev->release = iris_vpu_bus_release_device; + dev->bus = &iris_vpu_bus_type; + dev->parent = parent_device; + dev->coherent_dma_mask = dma_mask; + dev->dma_mask = &dev->coherent_dma_mask; + dev->platform_data = (void *)iommu_fid;
[Severity: High]
Does this code store a dangling pointer if the caller passes a stack variable?
The caller iris_glymur_init_cb_devs() passes the address of a local stack variable (fw_fid) for iommu_fid:
iris_glymur_init_cb_devs() {
...
const u32 fw_fid = IOMMU_FID_IRIS_FIRMWARE;
...
dev = iris_vpu_bus_create_device(core->dev, "iris-firmware", dma_mask, &fw_fid);
...
}Because the device structure outlives the caller's stack frame, dev->platform_data becomes a dangling pointer immediately after iris_glymur_init_cb_devs() returns. Should the value be copied into the device structure instead of storing the pointer?
drivers/media/platform/qcom/iris/iris_vpu_bus.c line 54
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +10
-0+dev_set_name (dev,"%s" , name); + + ret =device_register (dev); +if (ret) { +put_device (dev); +return ERR_PTR (ret); + } + +return dev; +}
Also, regarding an issue newly introduced in this series by commit 85711dbb43a8 ("media: iris: Enable Secure PAS support with IOMMU managed by Linux"):
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0
[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0@@ -30,14 +34,18 @@ static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)if (strlen (fw_name) >=MAX_FIRMWARE_NAME_SIZE -4 )return -EINVAL ;
drivers/media/platform/qcom/iris/iris_firmware.c static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name) · line 44
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +2
-2- ret =of_reserved_mem_region_to_resource (dev->of_node,0 , &res); + ret =of_reserved_mem_region_to_resource (core->dev->of_node,0 , &res);if (ret)return ret; mem_phys = res.start; res_size =resource_size (&res); - ret =request_firmware (&firmware, fw_name, dev); + pas_ctx =devm_qcom_scm_pas_context_alloc (fw_dev,IRIS_PAS_ID , mem_phys, res_size);
[Severity: High]
Does this devm_ allocation cause a memory leak on every firmware reload?
On platforms that do not use a dedicated firmware context bank device (where core->fw_dev is NULL), fw_dev falls back to the long-lived core->dev.
Because firmware loading can be repeatedly triggered upon firmware crashes (via iris_sys_error_handler()), these devm_ allocations accumulate indefinitely on core->dev's devres list without being explicitly freed in iris_fw_unload() or iris_core_deinit().
Will repeated firmware reloads eventually exhaust system memory?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v7 01/12] media: iris: Add iris vpu bus support
Quoted 44 lines · On 6/3/2026 8:15 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The dynamic device'splatform_datais initialized with a pointer to a short-lived stack variable, creating a persistent dangling pointer vulnerability.
- [High] A devm allocation tied to the persistent core device causes a memory leak on every firmware reload.
--commit
5c9139b17fe941a07d06bbded6b06a8c47d21867
Author: Vikash Garodia <[email protected]>media: iris: Add iris vpu bus support
On glymur platform, firmware loading needs a separate IOMMU mapping with its own stream ID. This stream ID is defined in the device tree with the associated firmware function ID in the iommu-map property. To create this mapping, a separate child device is needed so the firmware memory can be isolated in its own IOMMU context.
Introduce a new bus called iris-vpu-bus. This creates a dynamic device, and its
dma_configure()callback callsof_dma_configure_id()with the function ID provided by the client to map the corresponding stream ID. This sets up a dedicated IOMMU context for the child device.Quoted 9 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +3
-0@@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) Qualcomm Innovation Center, Inc. All rights reserved. drivers/media/platform/qcom/iris/iris_vpu_bus.c line 13
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +10
-0+*/ + +#include <linux/device.h> +#include <linux/iris_vpu_bus.h> +#include <linux/of_device.h> +#include <linux/slab.h> + +static int iris_vpu_bus_dma_configure (struct device *dev) +{ +const u32 *iommu_fid = (const u32 *)dev_get_platdata (dev);[Severity: High]
Can this dereference a dangling pointer if thedma_configurecallback executes asynchronously?
Quoted 4 lines
The
iommu_fidpointer is populated iniris_vpu_bus_create_device()directly from the caller's argument, which iniris_glymur_init_cb_devs()points to a local stack variable. If this callback runs later (e.g., deferred probing), it will read invalid stack memory.
These are sync calls, It won' t create dangling pointer de-reference.
Quoted 34 lines
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +3
-0+ +return of_dma_configure_id (dev, dev->parent->of_node, true, iommu_fid); +}[ ... ]
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +6
-0+struct device *iris_vpu_bus_create_device (struct device *parent_device,const char *name, +u64 dma_mask,const u32 *iommu_fid) +{ +struct device *dev; +int ret; +drivers/media/platform/qcom/iris/iris_vpu_bus.c line 44
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +10
-0+ dev =kzalloc_obj (*dev); +if (!dev) +return ERR_PTR (-ENOMEM ); + + dev->release = iris_vpu_bus_release_device; + dev->bus = &iris_vpu_bus_type; + dev->parent = parent_device; + dev->coherent_dma_mask = dma_mask; + dev->dma_mask = &dev->coherent_dma_mask; + dev->platform_data = (void *)iommu_fid;[Severity: High]
Does this code store a dangling pointer if the caller passes a stack variable?The caller
iris_glymur_init_cb_devs()passes the address of a local stack variable (fw_fid) foriommu_fid:iris_glymur_init_cb_devs() { ... const u32 fw_fid = IOMMU_FID_IRIS_FIRMWARE; ... dev = iris_vpu_bus_create_device(core->dev, "iris-firmware", dma_mask, &fw_fid); ... }
Quoted 4 lines
Because the device structure outlives the caller's stack frame,
dev->platform_databecomes a dangling pointer immediately afteriris_glymur_init_cb_devs()returns. Should the value be copied into the device structure instead of storing the pointer?
These are sync calls, It won' t create dangling pointer de-reference. After iris_glymur_init_cb_devs call, driver is not using the dev->platform_data anywhere else. Making it to global variable is not required because of one time usage.
Quoted 38 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c line 54
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu_bus.c new file +10
-0+dev_set_name (dev,"%s" , name); + + ret =device_register (dev); +if (ret) { +put_device (dev); +return ERR_PTR (ret); + } + +return dev; +}Also, regarding an issue newly introduced in this series by commit
85711dbb43a8("media: iris: Enable Secure PAS support with IOMMU managed by Linux"):Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0@@ -30,14 +34,18 @@ static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)if (strlen (fw_name) >=MAX_FIRMWARE_NAME_SIZE -4 )return -EINVAL ;drivers/media/platform/qcom/iris/iris_firmware.c static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name) · line 44
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +2
-2- ret =of_reserved_mem_region_to_resource (dev->of_node,0 , &res); + ret =of_reserved_mem_region_to_resource (core->dev->of_node,0 , &res);if (ret)return ret; mem_phys = res.start; res_size =resource_size (&res); - ret =request_firmware (&firmware, fw_name, dev); + pas_ctx =devm_qcom_scm_pas_context_alloc (fw_dev,IRIS_PAS_ID , mem_phys, res_size);[Severity: High]
Does thisdevm_allocation cause a memory leak on every firmware reload?On platforms that do not use a dedicated firmware context bank device (where
core->fw_devis NULL),fw_devfalls back to the long-livedcore->dev.
Quoted 6 lines
Because firmware loading can be repeatedly triggered upon firmware crashes (via
iris_sys_error_handler()), thesedevm_allocations accumulate indefinitely on core->dev's devres list without being explicitly freed iniris_fw_unload()oriris_core_deinit().Will repeated firmware reloads eventually exhaust system memory?
If the dedicated firmware device is not there, will check and skip the repeated allocations.
Re: [PATCH v7 01/12] media: iris: Add iris vpu bus support
In reply to Vishnu ReddyQuoted 16 lines · Vishnu Reddy
From: Vikash Garodia <[email protected]>
On glymur platform, firmware loading needs a separate IOMMU mapping with its own stream ID. This stream ID is defined in the device tree with the associated firmware function ID in the iommu-map property. To create this mapping, a separate child device is needed so the firmware memory can be isolated in its own IOMMU context.
Introduce a new bus called iris-vpu-bus. This creates a dynamic device, and its
dma_configure()callback callsof_dma_configure_id()with the function ID provided by the client to map the corresponding stream ID. This sets up a dedicated IOMMU context for the child device.Reviewed-by Vishnu Reddy <[email protected]>Signed-off-by Vikash Garodia <[email protected]>Signed-off-by Vishnu Reddy <[email protected]>
Quoted 8 lines
--- MAINTAINERS | 1 + drivers/media/platform/qcom/iris/Kconfig | 4 ++ drivers/media/platform/qcom/iris/Makefile | 1 + drivers/media/platform/qcom/iris/iris_vpu_bus.c | 61 +++++++++++++++++++++++++ include/linux/iris_vpu_bus.h | 25 ++++++++++ 5 files changed, 92 insertions(+)
Signature · 2 lines
With best wishes Dmitry
PATCH v7 2/12 iommu: Add iris-vpu-bus to iommu_buses
In reply to Vishnu ReddyFrom: Vikash Garodia <[email protected]>
Add iris_vpu_bus_type to the iommu_buses array in the core IOMMU subsystem so that the bus notifier callbacks are registered for device addition and removal events.
--- drivers/iommu/iommu.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/iommu/iommu.c +4 -0
@@ -13,6 +13,7 @@#include <linux/bug.h> #include <linux/types.h> #include <linux/init.h> +#include <linux/iris_vpu_bus.h> #include <linux/export.h> #include <linux/slab.h> #include <linux/errno.h>
@@ -200,6 +201,9 @@ static const struct bus_type * const iommu_buses[] = {#ifdef CONFIG_CDX_BUS &cdx_bus_type,#endif +#ifdef CONFIG_QCOM_IRIS_VPU_BUS + &iris_vpu_bus_type, +#endif };/*
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v7 02/12] iommu: Add iris-vpu-bus to iommu_buses
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Adding a vendor-specific media driver virtual bus (`iris_vpu_bus_type`) to the core `iommu_buses`…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Adding a vendor-specific media driver virtual bus (iris_vpu_bus_type) to the core iommu_buses array is an architectural layering violation and abuses the device model. --
commit 237441c1b5f7b6f9432bcd95591b1105966e57b0
Author: Vikash Garodia <[email protected]>
iommu: Add iris-vpu-bus to iommu_buses
Add iris_vpu_bus_type to the iommu_buses array in the core IOMMU subsystem so that the bus notifier callbacks are registered for device addition and removal events.
drivers/iommu/iommu.c line 16
Quoted 9 lines
drivers/iommu/iommu.c +1
-0@@ -13,6 +13,7 @@#include <linux/bug.h> #include <linux/types.h> #include <linux/init.h> +#include <linux/iris_vpu_bus.h>
[Severity: High]
Does this introduce a layering violation by pulling a vendor-specific media driver header directly into the core IOMMU framework?
Quoted 3 lines
drivers/iommu/iommu.c +0
-0#include <linux/export.h> #include <linux/slab.h> #include <linux/errno.h>
[ ... ]
drivers/iommu/iommu.c static const struct bus_type * const iommu_buses[] = { · line 207
Quoted 8 lines
drivers/iommu/iommu.c +3
-0@@ -200,6 +201,9 @@ static const struct bus_type * const iommu_buses[] = {#ifdef CONFIG_CDX_BUS &cdx_bus_type,#endif +#ifdef CONFIG_QCOM_IRIS_VPU_BUS + &iris_vpu_bus_type, +#endif };
[Severity: High]
Is it appropriate to add an artificial software bus created inside a single media driver to the system-level hardware interconnects list here?
The iommu_buses array is generally intended for system-level hardware interconnects like PCI or Platform buses. Modifying the core framework to accommodate a vendor driver's private bus seems to couple subsystems together incorrectly.
Additionally, because CONFIG_QCOM_IRIS_VPU_BUS is defined as a bool in the driver's Kconfig and registers its bus using a postcore_initcall, this forces the custom bus code into the core kernel binary even when the media driver is built as a loadable module, leading to kernel bloat and abusing core initialization levels.
Can generic solutions be used instead, such as using standard platform_device child nodes or creating a standardized context bus?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v7 02/12] iommu: Add iris-vpu-bus to iommu_buses
Quoted 48 lines · On 6/3/2026 8:04 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Adding a vendor-specific media driver virtual bus (iris_vpu_bus_type) to the coreiommu_busesarray is an architectural layering violation and abuses the device model. --commit
237441c1b5f7b6f9432bcd95591b1105966e57b0
Author: Vikash Garodia <[email protected]>iommu: Add iris-vpu-bus to
iommu_busesAdd
iris_vpu_bus_typeto theiommu_busesarray in the core IOMMU subsystem so that the bus notifier callbacks are registered for device addition and removal events.drivers/iommu/iommu.c line 16
Quoted 9 lines
drivers/iommu/iommu.c +1
-0@@ -13,6 +13,7 @@#include <linux/bug.h> #include <linux/types.h> #include <linux/init.h> +#include <linux/iris_vpu_bus.h> [Severity: High]
Does this introduce a layering violation by pulling a vendor-specific media driver header directly into the core IOMMU framework?Quoted 3 lines
drivers/iommu/iommu.c +0
-0#include <linux/export.h> #include <linux/slab.h> #include <linux/errno.h> [ ... ]
drivers/iommu/iommu.c static const struct bus_type * const iommu_buses[] = { · line 207
Quoted 8 lines
drivers/iommu/iommu.c +3
-0@@ -200,6 +201,9 @@ static const struct bus_type * const iommu_buses[] = {#ifdef CONFIG_CDX_BUS &cdx_bus_type,#endif +#ifdef CONFIG_QCOM_IRIS_VPU_BUS + &iris_vpu_bus_type, +#endif };[Severity: High]
Is it appropriate to add an artificial software bus created inside a single media driver to the system-level hardware interconnects list here?The
iommu_busesarray is generally intended for system-level hardware interconnects like PCI or Platform buses. Modifying the core framework to accommodate a vendor driver's private bus seems to couple subsystems together incorrectly.
Quoted 5 lines
Additionally, because
CONFIG_QCOM_IRIS_VPU_BUSis defined as a bool in the driver'sKconfigand registers its bus using apostcore_initcall, this forces the custom bus code into the core kernel binary even when the media driver is built as a loadable module, leading to kernel bloat and abusing core initialization levels.
iris-vpu-bus will be compiled along with kernel. This bus is used the external loadable modules. So here bus is not an external module.
Quoted 2 lines
Can generic solutions be used instead, such as using standard
platform_devicechild nodes or creating a standardized context bus?
platform_device child nodes method is not accepted and got suggestion to create a custom bus.
PATCH v7 3/12 dt-bindings: media: qcom,glymur-iris: Add glymur video codec
In reply to Vishnu ReddyAdd device tree binding for the Qualcomm Glymur Iris video codec. Glymur is a new generation of video IP that introduces a dual-core architecture. The second core brings its own power domain, clocks, and reset lines, requiring additional power domains and clocks in the power sequence.
The current maxItems constraints for clocks and power-domains in the common venus schema were sized for platforms available at the time of authoring. The glymur platform introduces a dual core architecture that requires more clocks and power domains, exceeding these limits.
Raise maxItems for clocks, clock-names, power-domains and power-domain-names to accommodate the glymur platform.
The glymur platform-specific schema have fixed constraints for these properties, so the common schema only acts as an upper bound.
--- .../bindings/media/qcom,glymur-iris.yaml | 208 +++++++++++++++++++++ .../bindings/media/qcom,venus-common.yaml | 8 +- include/dt-bindings/media/qcom,glymur-iris.h | 11 ++ 3 files changed, 223 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +208 -0
@@ -0,0 +1,208 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/qcom,glymur-iris.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Glymur SoC Iris video encoder and decoder + +maintainers: + - Vishnu Reddy <[email protected]> + +description: + The Iris video processing unit on Qualcomm Glymur SoC is a video encode and + decode accelerator. + +properties: + compatible: + const: qcom,glymur-iris + + clocks: + maxItems: 9 + + clock-names: + items: + - const: core_iface + - const: core + - const: vcodec0_core + - const: vcodec0_iface + - const: core_freerun + - const: vcodec0_core_freerun + - const: vcodec1_iface + - const: vcodec1_core + - const: vcodec1_core_freerun + + dma-coherent: true + + interconnects: + maxItems: 2 + + interconnect-names: + items: + - const: cpu-cfg + - const: video-mem + + iommus: + maxItems: 4 + + iommu-map: + maxItems: 1 + + operating-points-v2: true + opp-table: + type: object + + power-domains: + maxItems: 5 + + power-domain-names: + items: + - const: venus + - const: vcodec0 + - const: mxc + - const: mmcx + - const: vcodec1 + + resets: + maxItems: 6 + + reset-names: + items: + - const: core_bus + - const: vcodec0_bus + - const: core + - const: vcodec0_core + - const: vcodec1_bus + - const: vcodec1_core + +required: + - clocks + - clock-names + - compatible + - dma-coherent + - interconnects + - interconnect-names + - iommus + - power-domains + - power-domain-names + - resets + - reset-names + +allOf: + - $ref: qcom,venus-common.yaml# + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/media/qcom,glymur-iris.h> + #include <dt-bindings/power/qcom,rpmhpd.h> + + video-codec@aa00000 { + compatible = "qcom,glymur-iris"; + reg = <0x0aa00000 0xf0000>; + + clocks = <&gcc_video_axi0c_clk>, + <&videocc_mvs0c_clk>, + <&videocc_mvs0_clk>, + <&gcc_video_axi0_clk>, + <&videocc_mvs0c_freerun_clk>, + <&videocc_mvs0_freerun_clk>, + <&gcc_video_axi1_clk>, + <&videocc_mvs1_clk>, + <&videocc_mvs1_freerun_clk>; + clock-names = "core_iface", + "core", + "vcodec0_core", + "vcodec0_iface", + "core_freerun", + "vcodec0_core_freerun", + "vcodec1_iface", + "vcodec1_core", + "vcodec1_core_freerun"; + + dma-coherent; + + interconnects = <&hsc_noc_master_appss_proc &config_noc_slave_venus_cfg>, + <&mmss_noc_master_video &mc_virt_slave_ebi1>; + interconnect-names = "cpu-cfg", + "video-mem"; + + interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>; + + iommus = <&apps_smmu 0x1940 0x0>, + <&apps_smmu 0x1943 0x0>, + <&apps_smmu 0x1944 0x0>, + <&apps_smmu 0x19e0 0x0>; + + iommu-map = <IOMMU_FID_IRIS_FIRMWARE &apps_smmu 0x19e2 0x1>; + + memory-region = <&video_mem>; + + operating-points-v2 = <&iris_opp_table>; + + power-domains = <&videocc_mvs0c_gdsc>, + <&videocc_mvs0_gdsc>, + <&rpmhpd RPMHPD_MXC>, + <&rpmhpd RPMHPD_MMCX>, + <&videocc_mvs1_gdsc>; + power-domain-names = "venus", + "vcodec0", + "mxc", + "mmcx", + "vcodec1"; + + resets = <&gcc_video_axi0c_clk_ares>, + <&gcc_video_axi0_clk_ares>, + <&videocc_mvs0c_freerun_clk_ares>, + <&videocc_mvs0_freerun_clk_ares>, + <&gcc_video_axi1_clk_ares>, + <&videocc_mvs1_freerun_clk_ares>; + reset-names = "core_bus", + "vcodec0_bus", + "core", + "vcodec0_core", + "vcodec1_bus", + "vcodec1_core"; + + iris_opp_table: opp-table { + compatible = "operating-points-v2"; + + opp-240000000 { + opp-hz = /bits/ 64 <240000000 240000000 360000000>; + required-opps = <&rpmhpd_opp_svs>, + <&rpmhpd_opp_low_svs>; + }; + + opp-338000000 { + opp-hz = /bits/ 64 <338000000 338000000 507000000>; + required-opps = <&rpmhpd_opp_svs>, + <&rpmhpd_opp_svs>; + }; + + opp-366000000 { + opp-hz = /bits/ 64 <366000000 366000000 549000000>; + required-opps = <&rpmhpd_opp_svs_l1>, + <&rpmhpd_opp_svs_l1>; + }; + + opp-444000000 { + opp-hz = /bits/ 64 <444000000 444000000 666000000>; + required-opps = <&rpmhpd_opp_svs_l1>, + <&rpmhpd_opp_nom>; + }; + + opp-533333334 { + opp-hz = /bits/ 64 <533333334 533333334 800000000>; + required-opps = <&rpmhpd_opp_svs_l1>, + <&rpmhpd_opp_turbo>; + }; + + opp-655000000 { + opp-hz = /bits/ 64 <655000000 655000000 982000000>; + required-opps = <&rpmhpd_opp_nom>, + <&rpmhpd_opp_turbo_l1>; + }; + }; + };
Documentation/devicetree/bindings/media/qcom,venus-common.yaml +4 -4
@@ -20,11 +20,11 @@ properties: clocks: minItems: 3 - maxItems: 7 + maxItems: 9 clock-names: minItems: 3 - maxItems: 7 + maxItems: 9 firmware-name: maxItems: 1
@@ -41,11 +41,11 @@ properties: power-domains: minItems: 1 - maxItems: 4 + maxItems: 5 power-domain-names: minItems: 1 - maxItems: 4 + maxItems: 5 required: - reg
include/dt-bindings/media/qcom,glymur-iris.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +*/ + +#ifndef _DT_BINDINGS_MEDIA_QCOM_GLYMUR_IRIS_H_ +#define _DT_BINDINGS_MEDIA_QCOM_GLYMUR_IRIS_H_ + +#define IOMMU_FID_IRIS_FIRMWARE 0 + +#endif
Signature · 1 line
2.34.1
PATCH v7 4/12 media: iris: Add context bank hooks for platform specific initialization
In reply to Vishnu ReddyThe glymur platform requires a dedicated firmware context bank device to boot firmware where linux runs as the hypervisor and driver needs to manually manage the firmware IOMMU mapping.
Add init and deinit hooks in the vpu ops for context bank setup. These hooks allow platform specific code to initialize and tear down context banks.
--- drivers/media/platform/qcom/iris/iris_core.c | 9 ++++++++- drivers/media/platform/qcom/iris/iris_vpu_common.c | 14 ++++++++++++++ drivers/media/platform/qcom/iris/iris_vpu_common.h | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_core.c +8 -1
@@ -19,6 +19,7 @@ void iris_core_deinit(struct iris_core *core)iris_fw_unload (core);iris_vpu_power_off (core);iris_hfi_queues_deinit (core); +iris_deinit_cb_devs (core); core->state =IRIS_CORE_DEINIT ; }mutex_unlock (&core->lock);
@@ -58,10 +59,14 @@ int iris_core_init(struct iris_core *core) core->state =IRIS_CORE_INIT ; - 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 ; exit:
drivers/media/platform/qcom/iris/iris_vpu_common.c +14 -0
@@ -319,6 +319,20 @@ int iris_vpu_switch_to_hwmode(struct iris_core *core)return core->iris_platform_data->vpu_ops->set_hwmode (core); } +int iris_init_cb_devs (struct iris_core *core) +{ +if (core->iris_platform_data->vpu_ops->init_cb_devs) +return core->iris_platform_data->vpu_ops->init_cb_devs (core); + +return 0 ; +} + +void iris_deinit_cb_devs (struct iris_core *core) +{ +if (core->iris_platform_data->vpu_ops->deinit_cb_devs) + core->iris_platform_data->vpu_ops->deinit_cb_devs (core); +} +int iris_vpu35_vpu4x_power_off_controller (struct iris_core *core) {u32 clk_rst_tbl_size = core->iris_platform_data->clk_rst_tbl_size;
drivers/media/platform/qcom/iris/iris_vpu_common.h +4 -0
@@ -22,6 +22,8 @@ struct vpu_ops {void (*program_bootup_registers)(struct iris_core *core);u64 (*calc_freq)(struct iris_inst *inst,size_t data_size);int (*set_hwmode)(struct iris_core *core); +int (*init_cb_devs)(struct iris_core *core); +void (*deinit_cb_devs)(struct iris_core *core); };int iris_vpu_boot_firmware (struct iris_core *core);
@@ -33,6 +35,8 @@ int iris_vpu_power_on_controller(struct iris_core *core);int iris_vpu_power_on_hw (struct iris_core *core);int iris_vpu_set_hwmode (struct iris_core *core);int iris_vpu_switch_to_hwmode (struct iris_core *core); +int iris_init_cb_devs (struct iris_core *core); +void iris_deinit_cb_devs (struct iris_core *core);int iris_vpu_power_on (struct iris_core *core);int iris_vpu_power_off_controller (struct iris_core *core);void iris_vpu_power_off_hw (struct iris_core *core);
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v7 04/12] media: iris: Add context bank hooks for platform specific initialization
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
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 <[email protected]>
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.
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_core.c +0
-0
[ ... ]
drivers/media/platform/qcom/iris/iris_core.c int iris_core_init(struct iris_core *core) · line 60
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_core.c +0
-0@@ -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?
Quoted 13 lines
drivers/media/platform/qcom/iris/iris_core.c +5
-1- 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;
[ ... ]
drivers/media/platform/qcom/iris/iris_core.c int iris_core_init(struct iris_core *core) · line 105
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_core.c +2
-0@@ -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 setscore->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?
Quoted 1 line
drivers/media/platform/qcom/iris/iris_core.c +0
-0exit:
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v7 04/12] media: iris: Add context bank hooks for platform specific initialization
Quoted 39 lines · On 6/3/2026 8:06 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrent calls toiris_core_initcan bypass hardware initialization and use uninitialized hardware.
- [High] Failure duringiris_wait_for_system_responseleaves hardware initialized and memory allocated without cleanup, leading to permanent DMA memory leaks on subsequent opens. --commit
378c8a359d3ed3242ace4eba3b25ac54fcc682b5
Author: Vishnu Reddy <[email protected]>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.
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_core.c +0
-0[ ... ]
drivers/media/platform/qcom/iris/iris_core.c int iris_core_init(struct iris_core *core) · line 60
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_core.c +0
-0@@ -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 toIRIS_CORE_INIThere before initialization completes create a concurrency flaw?If a second thread calls
iris_core_init()while the first thread unlockscore->lockand 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); }
Quoted 5 lines
The second thread would see
core->state==IRIS_CORE_INITand 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?
It's not introduced in this patch and it's pre-existing issue. Will taken up as a separate post.
Quoted 41 lines
Quoted 13 lines
drivers/media/platform/qcom/iris/iris_core.c +5
-1- 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;[ ... ]
drivers/media/platform/qcom/iris/iris_core.c int iris_core_init(struct iris_core *core) · line 105
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_core.c +2
-0@@ -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 ifiris_wait_for_system_response()times out, it setscore->state=IRIS_CORE_ERRORand 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 callsiris_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; } ... }
Quoted 6 lines
At the error label, the state is simply reset to DEINIT without freeing any previously allocated resources like queues or
cb_devs. A thirdopen()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?
It's not introduced in this patch and it's pre-existing issue. Will taken up as a separate post.
Quoted 1 line
Quoted 1 line
drivers/media/platform/qcom/iris/iris_core.c +0
-0exit:
PATCH v7 5/12 media: iris: Enable Secure PAS support with IOMMU managed by Linux
In reply to Vishnu ReddyFrom: Mukesh Ojha <[email protected]>
On platforms where a hypervisor is present, all Secure Monitor Calls (SMC) are intercepted. For qcom_scm_pas_auth_and_reset(), the hypervisor registers a Shared Memory (SHM) bridge over the Peripheral Image Loader (PIL) memory region so that TrustZone (TZ) can access it, forwards the authentication SMC to TZ, and upon return maps the PIL region and triggers the co-processor bring-up sequence:
HLOS -> Hypervisor(SHM setup) -> TZ(auth) -> Hypervisor(map+reset) -> IRIS
On platforms without a hypervisor, Linux drives these steps directly. The SHM bridge infrastructure required for this is already upstream [1].
To isolate firmware memory in its own Input-Output Memory Management Unit (IOMMU) context, a dedicated stream ID (SID) is required, tied to the firmware function ID. This SID is specified via the iommu-map property in the device tree using the firmware function ID as the lookup key. A firmware device is created and mapped to this SID.
The presence of a SID mapped to the firmware device via iommu-map is used to detect whether a hypervisor is absent: when the firmware device has a SID mapped, Linux manages the IOMMU directly; when no SID is mapped, a hypervisor is assumed to be present and these steps are skipped.
Extend the Iris driver to support Secure Peripheral Authentication Service (PAS) on platforms where Linux manages the IOMMU, by creating the firmware context device and performing the necessary IOMMU mapping when the firmware device SID is present.
[1] https://lore.kernel.org/lkml/20260105-kvmrprocv10-v10-0-022e96815380
@oss.qualcomm.com/
--- drivers/media/platform/qcom/iris/iris_core.h | 4 ++ drivers/media/platform/qcom/iris/iris_firmware.c | 73 ++++++++++++++++++++---- 2 files changed, 67 insertions(+), 10 deletions(-)
drivers/media/platform/qcom/iris/iris_core.h +4 -0
@@ -36,6 +36,8 @@ struct qcom_ubwc_cfg_data;* struct iris_core - holds core parameters valid for all instances * * @dev: reference to device structure +* @fw_dev: reference to the context bank device used for firmware load +* @pas_ctx: SCM PAS context for authenticated firmware load and shutdown * @reg_base: IO memory base address * @irq: iris irq * @v4l2_dev: a holder for v4l2 device structure
@@ -81,6 +83,8 @@ struct qcom_ubwc_cfg_data;struct iris_core {struct device *dev; +struct device *fw_dev; +struct qcom_scm_pas_context *pas_ctx;void __iomem *reg_base;int irq;struct v4l2_device v4l2_dev;
drivers/media/platform/qcom/iris/iris_firmware.c +63 -10
138 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v7 05/12] media: iris: Enable Secure PAS support with IOMMU managed by Linux
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] Unconditional devm_qcom_scm_pas_context_alloc of pas_ctx causes a memory leak during repeated iris_core_init failures.
- [High] Double invocation of qcom_scm_pas_shutdown in the qcom_scm_mem_protect_video_var error path.
- [High] PAS metadata memory is permanently leaked upon every firmware load.
- [Medium] iris_fw_unload() skips iris_fw_iommu_unmap() if qcom_scm_pas_shutdown() fails, leaking the IOMMU mapping.
Pre-existing issues:
- [High] The sys_error_handler delayed work is never canceled during driver removal, risking use-after-free and locking crashes. --
commit 85711dbb43a8f02c3f39064784fe37381f80c2c5
Author: Mukesh Ojha <[email protected]>
media: iris: Enable Secure PAS support with IOMMU managed by Linux
On platforms without a hypervisor, Linux drives the firmware loading and authentication steps directly. This commit extends the Iris driver to support Secure Peripheral Authentication Service (PAS) on such platforms by creating the firmware context device and mapping the IOMMU when the firmware device SID is present.
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0
[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0@@ -30,14 +34,18 @@ static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)if (strlen (fw_name) >=MAX_FIRMWARE_NAME_SIZE -4 )return -EINVAL ;
drivers/media/platform/qcom/iris/iris_firmware.c static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name) · line 44
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +2
-2- ret =of_reserved_mem_region_to_resource (dev->of_node,0 , &res); + ret =of_reserved_mem_region_to_resource (core->dev->of_node,0 , &res);if (ret)return ret; mem_phys = res.start; res_size =resource_size (&res); - ret =request_firmware (&firmware, fw_name, dev); + pas_ctx =devm_qcom_scm_pas_context_alloc (fw_dev,IRIS_PAS_ID , mem_phys, res_size);
[Severity: High]
Does this unconditional devm_qcom_scm_pas_context_alloc() cause a memory leak during repeated iris_core_init() failures?
If a subsequent step in the firmware load fails (e.g., request_firmware() returning an error), iris_core_init() returns an error, but the device remains bound.
Because iris_core_init() is called upon opening the V4L2 device, userspace could repeatedly open the device, failing each time and allocating a new pas_ctx without freeing the previous one.
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_firmware.c +4
-0+if (IS_ERR (pas_ctx)) +return PTR_ERR (pas_ctx); + + ret =request_firmware (&firmware, fw_name, fw_dev);if (ret)return ret;
[ ... ]
drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 121
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +2
-2@@ -77,13 +115,13 @@ int iris_fw_load(struct iris_core *core) ret =iris_load_fw_to_memory (core, fwpath);if (ret) {dev_err (core->dev,"firmware download failed\n" ); -return -ENOMEM ; +return ret; } - ret =qcom_scm_pas_auth_and_reset (IRIS_PAS_ID ); + ret =qcom_scm_pas_prepare_and_auth_reset (core->pas_ctx);
[Severity: High]
Does this permanently leak the PAS metadata memory upon every successful firmware load?
qcom_mdt_pas_load() delegates to qcom_scm_pas_init_image(), which allocates DMA or TZ memory for the firmware metadata (ELF header and hashes).
The SCM API requires the caller to free this memory using qcom_scm_pas_metadata_release() once authentication is complete.
It appears the iris driver never invokes this release function.
Quoted 7 lines
drivers/media/platform/qcom/iris/iris_firmware.c +1
-1if (ret) {dev_err (core->dev,"auth and reset failed: %d\n" , ret); -return ret; + goto err_unmap; }for (i =0 ; i < core->iris_platform_data->tz_cp_config_data_size; i++) {
[ ... ]
drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 143
Quoted 13 lines
drivers/media/platform/qcom/iris/iris_firmware.c +5
-1@@ -95,16 +133,31 @@ int iris_fw_load(struct iris_core *core)if (ret) {dev_err (core->dev,"qcom_scm_mem_protect_video_var failed: %d\n" , ret);qcom_scm_pas_shutdown (IRIS_PAS_ID ); -return ret; + goto err_pas_shutdown; } } +return 0 ; + +err_pas_shutdown: +qcom_scm_pas_shutdown (core->pas_ctx->pas_id);
[Severity: High]
Does this result in a double invocation of qcom_scm_pas_shutdown() on the qcom_scm_mem_protect_video_var() error path?
The code calls qcom_scm_pas_shutdown(IRIS_PAS_ID) explicitly before jumping to the err_pas_shutdown label, which calls qcom_scm_pas_shutdown() again.
Since core->pas_ctx->pas_id is initialized to IRIS_PAS_ID, this results in the shutdown function being called twice consecutively for the same PAS ID, which could trigger TrustZone errors or corrupt Secure Monitor state.
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +3
-0+err_unmap: +iris_fw_iommu_unmap (core); +return ret;
drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 156
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +5
-1}int iris_fw_unload (struct iris_core *core) { -return qcom_scm_pas_shutdown (IRIS_PAS_ID ); +int ret; + + ret =qcom_scm_pas_shutdown (core->pas_ctx->pas_id); +if (ret) +return ret;
[Severity: Medium]
Will this early return skip the required IOMMU unmap logic if qcom_scm_pas_shutdown() fails?
Since the caller (iris_core_deinit()) ignores the return value of iris_fw_unload(), the driver proceeds with teardown while permanently leaking the firmware's IOMMU IOVA mapping.
Software resource cleanup should likely continue even if a hardware/SCM command fails.
drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 161
Quoted 5 lines
drivers/media/platform/qcom/iris/iris_firmware.c +4
-0+ +iris_fw_iommu_unmap (core); + +return ret; }
[Severity: High]
This is a pre-existing issue, but I noticed that the sys_error_handler delayed work is never canceled during driver removal.
Looking at iris_remove() in drivers/media/platform/qcom/iris/iris_probe.c:
static void iris_remove(struct platform_device *pdev)
{
...The driver initializes core->sys_error_handler on a delayed workqueue in iris_probe(), but iris_remove() unregisters devices and destroys core->lock without calling cancel_delayed_work_sync(&core->sys_error_handler).
If the delayed work executes concurrently with or after iris_remove(), will it access freed driver state and attempt to acquire the destroyed mutex, leading to a use-after-free?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v7 05/12] media: iris: Enable Secure PAS support with IOMMU managed by Linux
Quoted 7 lines · On Wed, Jun 03, 2026 at 02:39:22PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] Unconditionaldevm_qcom_scm_pas_context_allocofpas_ctxcauses a memory leak during repeatediris_core_initfailures.
- [High] Double invocation ofqcom_scm_pas_shutdownin theqcom_scm_mem_protect_video_varerror path.
- [High] PAS metadata memory is permanently leaked upon every firmware load.
- [Medium]iris_fw_unload()skipsiris_fw_iommu_unmap()ifqcom_scm_pas_shutdown()fails, leaking the IOMMU mapping.
Hmm, please check Sashiko comments.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v7 05/12] media: iris: Enable Secure PAS support with IOMMU managed by Linux
Quoted 10 lines · Dmitry Baryshkov
Quoted 7 lines · On Wed, Jun 03, 2026 at 02:39:22PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] Unconditionaldevm_qcom_scm_pas_context_allocofpas_ctxcauses a memory leak during repeatediris_core_initfailures.
- [High] Double invocation ofqcom_scm_pas_shutdownin theqcom_scm_mem_protect_video_varerror path.
- [High] PAS metadata memory is permanently leaked upon every firmware load.
- [Medium]iris_fw_unload()skipsiris_fw_iommu_unmap()ifqcom_scm_pas_shutdown()fails, leaking the IOMMU mapping.Hmm, please check Sashiko comments.
Ack
Re: [PATCH v7 05/12] media: iris: Enable Secure PAS support with IOMMU managed by Linux
In reply to [email protected]Quoted 49 lines · On 6/3/2026 8:09 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] Unconditionaldevm_qcom_scm_pas_context_allocofpas_ctxcauses a memory leak during repeatediris_core_initfailures.
- [High] Double invocation ofqcom_scm_pas_shutdownin theqcom_scm_mem_protect_video_varerror path.
- [High] PAS metadata memory is permanently leaked upon every firmware load.
- [Medium]iris_fw_unload()skipsiris_fw_iommu_unmap()ifqcom_scm_pas_shutdown()fails, leaking the IOMMU mapping.Pre-existing issues:
- [High] Thesys_error_handlerdelayed work is never canceled during driver removal, risking use-after-free and locking crashes. --commit
85711dbb43a8f02c3f39064784fe37381f80c2c5
Author: Mukesh Ojha <[email protected]>media: iris: Enable Secure PAS support with IOMMU managed by Linux
On platforms without a hypervisor, Linux drives the firmware loading and authentication steps directly. This commit extends the Iris driver to support Secure Peripheral Authentication Service (PAS) on such platforms by creating the firmware context device and mapping the IOMMU when the firmware device SID is present.
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0@@ -30,14 +34,18 @@ static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)if (strlen (fw_name) >=MAX_FIRMWARE_NAME_SIZE -4 )return -EINVAL ;drivers/media/platform/qcom/iris/iris_firmware.c static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name) · line 44
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +2
-2- ret =of_reserved_mem_region_to_resource (dev->of_node,0 , &res); + ret =of_reserved_mem_region_to_resource (core->dev->of_node,0 , &res);if (ret)return ret; mem_phys = res.start; res_size =resource_size (&res); - ret =request_firmware (&firmware, fw_name, dev); + pas_ctx =devm_qcom_scm_pas_context_alloc (fw_dev,IRIS_PAS_ID , mem_phys, res_size);[Severity: High]
Does this unconditionaldevm_qcom_scm_pas_context_alloc()cause a memory leak during repeatediris_core_init()failures?
Quoted 7 lines
If a subsequent step in the firmware load fails (e.g.,
request_firmware()returning an error),iris_core_init()returns an error, but the device remains bound.Because
iris_core_init()is called upon opening the V4L2 device, userspace could repeatedly open the device, failing each time and allocating a newpas_ctxwithout freeing the previous one.
If the dedicated firmware device is not there, will check and skip the repeated allocations.
Quoted 22 lines
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_firmware.c +4
-0+if (IS_ERR (pas_ctx)) +return PTR_ERR (pas_ctx); + + ret =request_firmware (&firmware, fw_name, fw_dev);if (ret)return ret;[ ... ]
drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 121
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +2
-2@@ -77,13 +115,13 @@ int iris_fw_load(struct iris_core *core) ret =iris_load_fw_to_memory (core, fwpath);if (ret) {dev_err (core->dev,"firmware download failed\n" ); -return -ENOMEM ; +return ret; } - ret =qcom_scm_pas_auth_and_reset (IRIS_PAS_ID ); + ret =qcom_scm_pas_prepare_and_auth_reset (core->pas_ctx);[Severity: High]
Does this permanently leak the PAS metadata memory upon every successful firmware load?
Quoted 7 lines
qcom_mdt_pas_load()delegates toqcom_scm_pas_init_image(), which allocates DMA or TZ memory for the firmware metadata (ELF header and hashes).The SCM API requires the caller to free this memory using
qcom_scm_pas_metadata_release()once authentication is complete.It appears the iris driver never invokes this release function.
This is discussed here [1] and finalized that no changes needed in this patch.
[1]
https://lore.kernel.org/all/[email protected]/
Quoted 26 lines
Quoted 7 lines
drivers/media/platform/qcom/iris/iris_firmware.c +1
-1if (ret) {dev_err (core->dev,"auth and reset failed: %d\n" , ret); -return ret; + goto err_unmap; }for (i =0 ; i < core->iris_platform_data->tz_cp_config_data_size; i++) {[ ... ]
drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 143
Quoted 13 lines
drivers/media/platform/qcom/iris/iris_firmware.c +5
-1@@ -95,16 +133,31 @@ int iris_fw_load(struct iris_core *core)if (ret) {dev_err (core->dev,"qcom_scm_mem_protect_video_var failed: %d\n" , ret);qcom_scm_pas_shutdown (IRIS_PAS_ID ); -return ret; + goto err_pas_shutdown; } } +return 0 ; + +err_pas_shutdown: +qcom_scm_pas_shutdown (core->pas_ctx->pas_id);[Severity: High]
Does this result in a double invocation ofqcom_scm_pas_shutdown()on theqcom_scm_mem_protect_video_var()error path?
Quoted 6 lines
The code calls
qcom_scm_pas_shutdown(IRIS_PAS_ID)explicitly before jumping to theerr_pas_shutdownlabel, which callsqcom_scm_pas_shutdown()again.Since
core->pas_ctx->pas_idis initialized toIRIS_PAS_ID, this results in the shutdown function being called twice consecutively for the same PAS ID, which could trigger TrustZone errors or corrupt Secure Monitor state.
It was missed during rebase and resolving merge conflicts in the previous series. Will fix in next revision.
Quoted 40 lines
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +3
-0+err_unmap: +iris_fw_iommu_unmap (core); +return ret;drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 156
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +5
-1}int iris_fw_unload (struct iris_core *core) { -return qcom_scm_pas_shutdown (IRIS_PAS_ID ); +int ret; + + ret =qcom_scm_pas_shutdown (core->pas_ctx->pas_id); +if (ret) +return ret;[Severity: Medium]
Will this early return skip the required IOMMU unmap logic ifqcom_scm_pas_shutdown()fails?Since the caller (
iris_core_deinit()) ignores the return value ofiris_fw_unload(), the driver proceeds with teardown while permanently leaking the firmware's IOMMU IOVA mapping.Software resource cleanup should likely continue even if a hardware/SCM command fails.
drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 161
Quoted 5 lines
drivers/media/platform/qcom/iris/iris_firmware.c +4
-0+ +iris_fw_iommu_unmap (core); + +return ret; }[Severity: High]
This is a pre-existing issue, but I noticed that thesys_error_handlerdelayed work is never canceled during driver removal.Looking at
iris_remove()indrivers/media/platform/qcom/iris/iris_probe.c:static void
iris_remove(struct platform_device *pdev){ ...
Quoted 7 lines
The driver initializes
core->sys_error_handleron a delayed workqueue iniris_probe(), butiris_remove()unregisters devices and destroyscore->lockwithout callingcancel_delayed_work_sync(&core->sys_error_handler).If the delayed work executes concurrently with or after
iris_remove(), will it access freed driver state and attempt to acquire the destroyed mutex, leading to a use-after-free?
This is not introduced with this patch.
Will check this pre-existing issue and will post another series for this fixes if required.
Re: [PATCH v7 05/12] media: iris: Enable Secure PAS support with IOMMU managed by Linux
Quoted 55 lines · Vishnu Reddy
Quoted 53 lines · On 6/3/2026 8:09 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] Unconditionaldevm_qcom_scm_pas_context_allocofpas_ctxcauses a memory leak during repeatediris_core_initfailures.
- [High] Double invocation ofqcom_scm_pas_shutdownin theqcom_scm_mem_protect_video_varerror path.
- [High] PAS metadata memory is permanently leaked upon every firmware load.
- [Medium]iris_fw_unload()skipsiris_fw_iommu_unmap()ifqcom_scm_pas_shutdown()fails, leaking the IOMMU mapping.Pre-existing issues:
- [High] Thesys_error_handlerdelayed work is never canceled during driver removal, risking use-after-free and locking crashes. --commit
85711dbb43a8f02c3f39064784fe37381f80c2c5
Author: Mukesh Ojha <[email protected]>media: iris: Enable Secure PAS support with IOMMU managed by Linux
On platforms without a hypervisor, Linux drives the firmware loading and authentication steps directly. This commit extends the Iris driver to support Secure Peripheral Authentication Service (PAS) on such platforms by creating the firmware context device and mapping the IOMMU when the firmware device SID is present.
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0@@ -30,14 +34,18 @@ static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)if (strlen (fw_name) >=MAX_FIRMWARE_NAME_SIZE -4 )return -EINVAL ;drivers/media/platform/qcom/iris/iris_firmware.c static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name) · line 44
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +2
-2- ret =of_reserved_mem_region_to_resource (dev->of_node,0 , &res); + ret =of_reserved_mem_region_to_resource (core->dev->of_node,0 , &res);if (ret)return ret; mem_phys = res.start; res_size =resource_size (&res); - ret =request_firmware (&firmware, fw_name, dev); + pas_ctx =devm_qcom_scm_pas_context_alloc (fw_dev,IRIS_PAS_ID , mem_phys, res_size);[Severity: High]
Does this unconditionaldevm_qcom_scm_pas_context_alloc()cause a memory leak during repeatediris_core_init()failures?If a subsequent step in the firmware load fails (e.g.,
request_firmware()returning an error),iris_core_init()returns an error, but the device remains bound.
Quoted 6 lines
Quoted 3 lines
Because
iris_core_init()is called upon opening the V4L2 device, userspace could repeatedly open the device, failing each time and allocating a newpas_ctxwithout freeing the previous one.If the dedicated firmware device is not there, will check and skip the repeated allocations.
No, the path is the following:
iris_load_fw_to_memory():
devm_qcom_scm_pas_context_alloc() -> succeeds
request_firmware() -> returns an error
return
Now you have a dangling PAS context. It will be freed only when the driver is unbound. If user is persistent, the driver can eat memory and possibly other resources.
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
drivers/media/platform/qcom/iris/iris_firmware.c +4
-0+if (IS_ERR (pas_ctx)) +return PTR_ERR (pas_ctx); + + ret =request_firmware (&firmware, fw_name, fw_dev);if (ret)return ret;[ ... ]
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v7 05/12] media: iris: Enable Secure PAS support with IOMMU managed by Linux
Quoted 62 lines · Dmitry Baryshkov
Quoted 54 lines · Vishnu Reddy
Quoted 53 lines · On 6/3/2026 8:09 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] Unconditionaldevm_qcom_scm_pas_context_allocofpas_ctxcauses a memory leak during repeatediris_core_initfailures.
- [High] Double invocation ofqcom_scm_pas_shutdownin theqcom_scm_mem_protect_video_varerror path.
- [High] PAS metadata memory is permanently leaked upon every firmware load.
- [Medium]iris_fw_unload()skipsiris_fw_iommu_unmap()ifqcom_scm_pas_shutdown()fails, leaking the IOMMU mapping.Pre-existing issues:
- [High] Thesys_error_handlerdelayed work is never canceled during driver removal, risking use-after-free and locking crashes. --commit
85711dbb43a8f02c3f39064784fe37381f80c2c5
Author: Mukesh Ojha <[email protected]>media: iris: Enable Secure PAS support with IOMMU managed by Linux
On platforms without a hypervisor, Linux drives the firmware loading and authentication steps directly. This commit extends the Iris driver to support Secure Peripheral Authentication Service (PAS) on such platforms by creating the firmware context device and mapping the IOMMU when the firmware device SID is present.
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0@@ -30,14 +34,18 @@ static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)if (strlen (fw_name) >=MAX_FIRMWARE_NAME_SIZE -4 )return -EINVAL ;drivers/media/platform/qcom/iris/iris_firmware.c static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name) · line 44
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_firmware.c +2
-2- ret =of_reserved_mem_region_to_resource (dev->of_node,0 , &res); + ret =of_reserved_mem_region_to_resource (core->dev->of_node,0 , &res);if (ret)return ret; mem_phys = res.start; res_size =resource_size (&res); - ret =request_firmware (&firmware, fw_name, dev); + pas_ctx =devm_qcom_scm_pas_context_alloc (fw_dev,IRIS_PAS_ID , mem_phys, res_size);[Severity: High]
Does this unconditionaldevm_qcom_scm_pas_context_alloc()cause a memory leak during repeatediris_core_init()failures?If a subsequent step in the firmware load fails (e.g.,
request_firmware()returning an error),iris_core_init()returns an error, but the device remains bound.Quoted 5 lines
Quoted 3 lines
Because
iris_core_init()is called upon opening the V4L2 device, userspace could repeatedly open the device, failing each time and allocating a newpas_ctxwithout freeing the previous one.If the dedicated firmware device is not there, will check and skip the repeated allocations.
No, the path is the following:
Quoted 8 lines
iris_load_fw_to_memory():devm_qcom_scm_pas_context_alloc() -> succeeds request_firmware() -> returns an error returnNow you have a dangling PAS context. It will be freed only when the driver is unbound. If user is persistent, the driver can eat memory and possibly other resources.
Agree, Will store the allocated address directly into core->pas_ctx and used for next time instead of allocating again.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_firmware.c +4
-0+if (IS_ERR (pas_ctx)) +return PTR_ERR (pas_ctx); + + ret =request_firmware (&firmware, fw_name, fw_dev);if (ret)return ret;[ ... ]
Re: [PATCH v7 05/12] media: iris: Enable Secure PAS support with IOMMU managed by Linux
In reply to Vishnu ReddyQuoted 39 lines · Vishnu Reddy
From: Mukesh Ojha <[email protected]>
On platforms where a hypervisor is present, all Secure Monitor Calls (SMC) are intercepted. For
qcom_scm_pas_auth_and_reset(), the hypervisor registers a Shared Memory (SHM) bridge over the Peripheral Image Loader (PIL) memory region so that TrustZone (TZ) can access it, forwards the authentication SMC to TZ, and upon return maps the PIL region and triggers the co-processor bring-up sequence:HLOS -> Hypervisor(SHM setup) -> TZ(auth) -> Hypervisor(map+reset) -> IRIS
On platforms without a hypervisor, Linux drives these steps directly. The SHM bridge infrastructure required for this is already upstream [1].
To isolate firmware memory in its own Input-Output Memory Management Unit (IOMMU) context, a dedicated stream ID (SID) is required, tied to the firmware function ID. This SID is specified via the iommu-map property in the device tree using the firmware function ID as the lookup key. A firmware device is created and mapped to this SID.
The presence of a SID mapped to the firmware device via iommu-map is used to detect whether a hypervisor is absent: when the firmware device has a SID mapped, Linux manages the IOMMU directly; when no SID is mapped, a hypervisor is assumed to be present and these steps are skipped.
Extend the Iris driver to support Secure Peripheral Authentication Service (PAS) on platforms where Linux manages the IOMMU, by creating the firmware context device and performing the necessary IOMMU mapping when the firmware device SID is present.
[1] https://lore.kernel.org/lkml/20260105-kvmrprocv10-v10-0-022e96815380
@oss.qualcomm.com/Reviewed-by Vishnu Reddy <[email protected]>Co-developed-by Vikash Garodia <[email protected]>Signed-off-by Vikash Garodia <[email protected]>Signed-off-by Mukesh Ojha <[email protected]>Signed-off-by Vishnu Reddy <[email protected]>
Quoted 5 lines
--- drivers/media/platform/qcom/iris/iris_core.h | 4 ++ drivers/media/platform/qcom/iris/iris_firmware.c | 73 ++++++++++++++++++++---- 2 files changed, 67 insertions(+), 10 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH v7 6/12 media: iris: Replace enum-indexed clock and power domain tables with per-block structures
In reply to Vishnu ReddyAs new platforms are added, the platform_clk_type and platform_pm_domain_type enums keep growing. Every new clock or power domain requires a new enum entry, and every enable/disable path has to loop through the clock table to find the right clock by enum value, adding overhead and boilerplate on each path.
The enum index space is also shared across all hardware blocks. On the Glymur platform, the VPP0 index for VPU4x and the VCODEC1 index clash, making it error-prone to extend support without breaking existing platforms.
Replace the flat tables and enum-based lookups with iris_power_domain, which bundles a power domain device and its associated clocks together per hardware block. Platform data describes each block via iris_power_domain_data, and the enable and disable helpers operate directly on an iris_power_domain instance, removing the need for any index lookup at runtime.
--- drivers/media/platform/qcom/iris/iris_core.h | 22 +++- .../platform/qcom/iris/iris_platform_common.h | 41 ++---- .../platform/qcom/iris/iris_platform_sc7280.h | 28 ++++- .../platform/qcom/iris/iris_platform_sm8250.h | 26 +++- .../platform/qcom/iris/iris_platform_sm8550.h | 26 +++- .../platform/qcom/iris/iris_platform_sm8750.h | 29 +++-- .../media/platform/qcom/iris/iris_platform_vpu2.c | 14 +-- .../media/platform/qcom/iris/iris_platform_vpu3x.c | 32 ++--- .../platform/qcom/iris/iris_platform_x1p42100.h | 27 +++- drivers/media/platform/qcom/iris/iris_probe.c | 122 ++++++++++++++++-- drivers/media/platform/qcom/iris/iris_resources.c | 65 ++-------- drivers/media/platform/qcom/iris/iris_resources.h | 7 +- drivers/media/platform/qcom/iris/iris_vpu3x.c | 37 +----- drivers/media/platform/qcom/iris/iris_vpu4x.c | 137 +++------------------ drivers/media/platform/qcom/iris/iris_vpu_common.c | 98 ++------------- 15 files changed, 303 insertions(+), 408 deletions(-)
drivers/media/platform/qcom/iris/iris_core.h +16 -6
@@ -16,6 +16,12 @@#include "iris_resources.h" #include "iris_state.h" +struct iris_power_domain { +struct device *dev; +struct clk_bulk_data *clocks; +unsigned int clk_cnt; +}; +struct icc_info {const char *name;u32 bw_min_kbps;
@@ -49,10 +55,12 @@ struct qcom_ubwc_cfg_data;* @iris_vb2_ops: iris vb2 ops * @icc_tbl: table of iris interconnects * @icc_count: count of iris interconnects -* @pmdomain_tbl: table of iris power domains +* @ctrl: power domain and clocks for the controller +* @vcodec: power domain and clocks for the vcodec +* @vcodec_vpp0: power domain and clocks for the vcodec VPP0 +* @vcodec_vpp1: power domain and clocks for the vcodec VPP1 +* @apv: power domain and clocks for the APV hardware block * @opp_pmdomain_tbl: table of opp power domains -* @clock_tbl: table of iris clocks -* @clk_count: count of iris clocks * @resets: table of iris reset clocks * @controller_resets: table of controller reset clocks * @iris_platform_data: a structure for platform data
@@ -96,10 +104,12 @@ struct iris_core {const struct vb2_ops *iris_vb2_ops;struct icc_bulk_data *icc_tbl;u32 icc_count; -struct dev_pm_domain_list *pmdomain_tbl; +struct iris_power_domain *ctrl; +struct iris_power_domain *vcodec; +struct iris_power_domain *vcodec_vpp0; +struct iris_power_domain *vcodec_vpp1; +struct iris_power_domain *apv;struct dev_pm_domain_list *opp_pmdomain_tbl; -struct clk_bulk_data *clock_tbl; -u32 clk_count;struct reset_control_bulk_data *resets;struct reset_control_bulk_data *controller_resets;const struct iris_platform_data *iris_platform_data;
drivers/media/platform/qcom/iris/iris_platform_common.h +11 -30
68 lines not on this page · raw message
drivers/media/platform/qcom/iris/iris_platform_sc7280.h +22 -6
@@ -15,12 +15,28 @@ static const struct bw_info sc7280_bw_table_dec[] = {static const char *const sc7280_opp_pd_table[] = {"cx" }; -static const struct platform_clk_data sc7280_clk_table[] = { - {IRIS_CTRL_CLK ,"core" }, - {IRIS_AXI_CLK ,"iface" }, - {IRIS_AHB_CLK ,"bus" }, - {IRIS_HW_CLK ,"vcodec_core" }, - {IRIS_HW_AHB_CLK ,"vcodec_bus" }, +static const struct iris_power_domain_data sc7280_ctrl_data = { + .pd_names = (const char *[]) { +"venus" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"iface" ,"core" ,"bus" , + }, + .clk_cnt =3 , +}; + +static const struct iris_power_domain_data sc7280_vcodec_data[] = { + { + .pd_names = (const char *[]) { +"vcodec0" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"vcodec_core" ,"vcodec_bus" , + }, + .clk_cnt =2 , + }, };static const char *const sc7280_opp_clk_table[] = {
drivers/media/platform/qcom/iris/iris_platform_sm8250.h +22 -4
@@ -15,10 +15,28 @@ static const struct bw_info sm8250_bw_table_dec[] = {static const char *const sm8250_opp_pd_table[] = {"mx" ,"mmcx" }; -static const struct platform_clk_data sm8250_clk_table[] = { - {IRIS_AXI_CLK ,"iface" }, - {IRIS_CTRL_CLK ,"core" }, - {IRIS_HW_CLK ,"vcodec0_core" }, +static const struct iris_power_domain_data sm8250_ctrl_data = { + .pd_names = (const char *[]) { +"venus" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"iface" ,"core" , + }, + .clk_cnt =2 , +}; + +static const struct iris_power_domain_data sm8250_vcodec_data[] = { + { + .pd_names = (const char *[]) { +"vcodec0" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"vcodec0_core" , + }, + .clk_cnt =1 , + }, };static const char *const sm8250_opp_clk_table[] = {
drivers/media/platform/qcom/iris/iris_platform_sm8550.h +22 -4
@@ -8,10 +8,28 @@static const char *const sm8550_clk_reset_table[] = {"bus" }; -static const struct platform_clk_data sm8550_clk_table[] = { - {IRIS_AXI_CLK ,"iface" }, - {IRIS_CTRL_CLK ,"core" }, - {IRIS_HW_CLK ,"vcodec0_core" }, +static const struct iris_power_domain_data sm8550_ctrl_data = { + .pd_names = (const char *[]) { +"venus" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"iface" ,"core" , + }, + .clk_cnt =2 , +}; + +static const struct iris_power_domain_data sm8550_vcodec_data[] = { + { + .pd_names = (const char *[]) { +"vcodec0" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"vcodec0_core" , + }, + .clk_cnt =1 , + }, };static struct platform_inst_caps platform_inst_cap_sm8550 = {
drivers/media/platform/qcom/iris/iris_platform_sm8750.h +22 -7
@@ -10,13 +10,28 @@ static const char * const sm8750_clk_reset_table[] = {"bus0" ,"bus1" ,"core" ,"vcodec0_core" }; -static const struct platform_clk_data sm8750_clk_table[] = { - {IRIS_AXI_CLK ,"iface" }, - {IRIS_CTRL_CLK ,"core" }, - {IRIS_HW_CLK ,"vcodec0_core" }, - {IRIS_AXI1_CLK ,"iface1" }, - {IRIS_CTRL_FREERUN_CLK ,"core_freerun" }, - {IRIS_HW_FREERUN_CLK ,"vcodec0_core_freerun" }, +static const struct iris_power_domain_data sm8750_ctrl_data = { + .pd_names = (const char *[]) { +"venus" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"iface1" ,"core_freerun" ,"core" , + }, + .clk_cnt =3 , +}; + +static const struct iris_power_domain_data sm8750_vcodec_data[] = { + { + .pd_names = (const char *[]) { +"vcodec0" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"iface" ,"vcodec0_core_freerun" ,"vcodec0_core" , + }, + .clk_cnt =3 , + }, };#endif
drivers/media/platform/qcom/iris/iris_platform_vpu2.c +4 -10
@@ -53,8 +53,6 @@ static const struct icc_info iris_icc_info_vpu2[] = {static const char *const iris_clk_reset_table_vpu2[] = {"bus" ,"core" }; -static const char *const iris_pmdomain_table_vpu2[] = {"venus" ,"vcodec0" }; -static const struct tz_cp_config tz_cp_config_vpu2[] = { { .cp_start =0 ,
@@ -71,12 +69,10 @@ const struct iris_platform_data sc7280_data = { .icc_tbl_size = ARRAY_SIZE(iris_icc_info_vpu2), .bw_tbl_dec = sc7280_bw_table_dec, .bw_tbl_dec_size = ARRAY_SIZE(sc7280_bw_table_dec), - .pmdomain_tbl = iris_pmdomain_table_vpu2, - .pmdomain_tbl_size = ARRAY_SIZE(iris_pmdomain_table_vpu2), + .ctrl_data = &sc7280_ctrl_data, + .vcodec_data = sc7280_vcodec_data, .opp_pd_tbl = sc7280_opp_pd_table, .opp_pd_tbl_size = ARRAY_SIZE(sc7280_opp_pd_table), - .clk_tbl = sc7280_clk_table, - .clk_tbl_size = ARRAY_SIZE(sc7280_clk_table), .opp_clk_tbl = sc7280_opp_clk_table,/* Upper bound of DMA address range */ .dma_mask = 0xe0000000 - 1,
@@ -102,12 +98,10 @@ const struct iris_platform_data sm8250_data = { .clk_rst_tbl_size = ARRAY_SIZE(iris_clk_reset_table_vpu2), .bw_tbl_dec = sm8250_bw_table_dec, .bw_tbl_dec_size = ARRAY_SIZE(sm8250_bw_table_dec), - .pmdomain_tbl = iris_pmdomain_table_vpu2, - .pmdomain_tbl_size = ARRAY_SIZE(iris_pmdomain_table_vpu2), + .ctrl_data = &sm8250_ctrl_data, + .vcodec_data = sm8250_vcodec_data, .opp_pd_tbl = sm8250_opp_pd_table, .opp_pd_tbl_size = ARRAY_SIZE(sm8250_opp_pd_table), - .clk_tbl = sm8250_clk_table, - .clk_tbl_size = ARRAY_SIZE(sm8250_clk_table), .opp_clk_tbl = sm8250_opp_clk_table,/* Upper bound of DMA address range */ .dma_mask = 0xe0000000 - 1,
drivers/media/platform/qcom/iris/iris_platform_vpu3x.c +10 -22
@@ -67,8 +67,6 @@ static const struct bw_info iris_bw_table_dec_vpu3x[] = { { ((1920 * 1080) / 256) * 30, 294000 }, }; -static const char *const iris_pmdomain_table_vpu3x[] = {"venus" ,"vcodec0" }; -static const char *const iris_opp_pd_table_vpu3x[] = {"mxc" ,"mmcx" }; static const char * const iris_opp_clk_table_vpu3x[] = {
@@ -98,12 +96,10 @@ const struct iris_platform_data qcs8300_data = { .clk_rst_tbl_size = ARRAY_SIZE(sm8550_clk_reset_table), .bw_tbl_dec = iris_bw_table_dec_vpu3x, .bw_tbl_dec_size = ARRAY_SIZE(iris_bw_table_dec_vpu3x), - .pmdomain_tbl = iris_pmdomain_table_vpu3x, - .pmdomain_tbl_size = ARRAY_SIZE(iris_pmdomain_table_vpu3x), + .ctrl_data = &sm8550_ctrl_data, + .vcodec_data = sm8550_vcodec_data, .opp_pd_tbl = iris_opp_pd_table_vpu3x, .opp_pd_tbl_size = ARRAY_SIZE(iris_opp_pd_table_vpu3x), - .clk_tbl = sm8550_clk_table, - .clk_tbl_size = ARRAY_SIZE(sm8550_clk_table), .opp_clk_tbl = iris_opp_clk_table_vpu3x,/* Upper bound of DMA address range */ .dma_mask = 0xe0000000 - 1,
@@ -127,12 +123,10 @@ const struct iris_platform_data sm8550_data = { .clk_rst_tbl_size = ARRAY_SIZE(sm8550_clk_reset_table), .bw_tbl_dec = iris_bw_table_dec_vpu3x, .bw_tbl_dec_size = ARRAY_SIZE(iris_bw_table_dec_vpu3x), - .pmdomain_tbl = iris_pmdomain_table_vpu3x, - .pmdomain_tbl_size = ARRAY_SIZE(iris_pmdomain_table_vpu3x), + .ctrl_data = &sm8550_ctrl_data, + .vcodec_data = sm8550_vcodec_data, .opp_pd_tbl = iris_opp_pd_table_vpu3x, .opp_pd_tbl_size = ARRAY_SIZE(iris_opp_pd_table_vpu3x), - .clk_tbl = sm8550_clk_table, - .clk_tbl_size = ARRAY_SIZE(sm8550_clk_table), .opp_clk_tbl = iris_opp_clk_table_vpu3x,/* Upper bound of DMA address range */ .dma_mask = 0xe0000000 - 1,
@@ -164,12 +158,10 @@ const struct iris_platform_data sm8650_data = { .controller_rst_tbl_size = ARRAY_SIZE(sm8650_controller_reset_table), .bw_tbl_dec = iris_bw_table_dec_vpu3x, .bw_tbl_dec_size = ARRAY_SIZE(iris_bw_table_dec_vpu3x), - .pmdomain_tbl = iris_pmdomain_table_vpu3x, - .pmdomain_tbl_size = ARRAY_SIZE(iris_pmdomain_table_vpu3x), + .ctrl_data = &sm8550_ctrl_data, + .vcodec_data = sm8550_vcodec_data, .opp_pd_tbl = iris_opp_pd_table_vpu3x, .opp_pd_tbl_size = ARRAY_SIZE(iris_opp_pd_table_vpu3x), - .clk_tbl = sm8550_clk_table, - .clk_tbl_size = ARRAY_SIZE(sm8550_clk_table), .opp_clk_tbl = iris_opp_clk_table_vpu3x,/* Upper bound of DMA address range */ .dma_mask = 0xe0000000 - 1,
@@ -193,12 +185,10 @@ const struct iris_platform_data sm8750_data = { .clk_rst_tbl_size = ARRAY_SIZE(sm8750_clk_reset_table), .bw_tbl_dec = iris_bw_table_dec_vpu3x, .bw_tbl_dec_size = ARRAY_SIZE(iris_bw_table_dec_vpu3x), - .pmdomain_tbl = iris_pmdomain_table_vpu3x, - .pmdomain_tbl_size = ARRAY_SIZE(iris_pmdomain_table_vpu3x), + .ctrl_data = &sm8750_ctrl_data, + .vcodec_data = sm8750_vcodec_data, .opp_pd_tbl = iris_opp_pd_table_vpu3x, .opp_pd_tbl_size = ARRAY_SIZE(iris_opp_pd_table_vpu3x), - .clk_tbl = sm8750_clk_table, - .clk_tbl_size = ARRAY_SIZE(sm8750_clk_table), .opp_clk_tbl = iris_opp_clk_table_vpu3x,/* Upper bound of DMA address range */ .dma_mask = 0xe0000000 - 1,
@@ -228,12 +218,10 @@ const struct iris_platform_data x1p42100_data = { .clk_rst_tbl_size = ARRAY_SIZE(sm8550_clk_reset_table), .bw_tbl_dec = iris_bw_table_dec_vpu3x, .bw_tbl_dec_size = ARRAY_SIZE(iris_bw_table_dec_vpu3x), - .pmdomain_tbl = iris_pmdomain_table_vpu3x, - .pmdomain_tbl_size = ARRAY_SIZE(iris_pmdomain_table_vpu3x), + .ctrl_data = &x1p42100_ctrl_data, + .vcodec_data = x1p42100_vcodec_data, .opp_pd_tbl = iris_opp_pd_table_vpu3x, .opp_pd_tbl_size = ARRAY_SIZE(iris_opp_pd_table_vpu3x), - .clk_tbl = x1p42100_clk_table, - .clk_tbl_size = ARRAY_SIZE(x1p42100_clk_table), .opp_clk_tbl = x1p42100_opp_clk_table,/* Upper bound of DMA address range */ .dma_mask = 0xe0000000 - 1,
drivers/media/platform/qcom/iris/iris_platform_x1p42100.h +22 -5
@@ -6,11 +6,28 @@#ifndef __IRIS_PLATFORM_X1P42100_H__#define __IRIS_PLATFORM_X1P42100_H__ -static const struct platform_clk_data x1p42100_clk_table[] = { - {IRIS_AXI_CLK ,"iface" }, - {IRIS_CTRL_CLK ,"core" }, - {IRIS_HW_CLK ,"vcodec0_core" }, - {IRIS_BSE_HW_CLK ,"vcodec0_bse" }, +static const struct iris_power_domain_data x1p42100_ctrl_data = { + .pd_names = (const char *[]) { +"venus" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"iface" ,"core" , + }, + .clk_cnt =2 , +}; + +static const struct iris_power_domain_data x1p42100_vcodec_data[] = { + { + .pd_names = (const char *[]) { +"vcodec0" , + }, + .pd_cnt =1 , + .clk_names = (const char *[]) { +"vcodec0_core" ,"vcodec0_bse" , + }, + .clk_cnt =2 , + }, }; static const char *const x1p42100_opp_clk_table[] = {
drivers/media/platform/qcom/iris/iris_probe.c +110 -12
152 lines not on this page · raw message
drivers/media/platform/qcom/iris/iris_resources.c +9 -56
89 lines not on this page · raw message
drivers/media/platform/qcom/iris/iris_resources.h +3 -4
@@ -7,13 +7,12 @@#define __IRIS_RESOURCES_H__struct iris_core ; +struct iris_power_domain ;int iris_opp_set_rate (struct device *dev,unsigned long freq); -int iris_enable_power_domains (struct iris_core *core,struct device *pd_dev); -int iris_disable_power_domains (struct iris_core *core,struct device *pd_dev);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_enable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd); +void iris_disable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd);#endif
drivers/media/platform/qcom/iris/iris_vpu3x.c +2 -35
@@ -205,53 +205,20 @@ static int iris_vpu33_power_off_controller(struct iris_core *core) val &= ~NOC_HALT ;writel (val, core->reg_base +AON_WRAPPER_MVP_NOC_CORE_CLK_CONTROL ); -iris_disable_unprepare_clock (core,IRIS_CTRL_CLK ); - disable_power: -iris_disable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN ]); -iris_disable_unprepare_clock (core,IRIS_AXI_CLK ); +iris_disable_power_domain_and_clocks (core, core->ctrl);return 0 ; }static int iris_vpu35_power_on_hw (struct iris_core *core) { -int ret; - - ret =iris_enable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); -if (ret) -return ret; - - ret =iris_prepare_enable_clock (core,IRIS_AXI_CLK ); -if (ret) - goto err_disable_power; - - ret =iris_prepare_enable_clock (core,IRIS_HW_FREERUN_CLK ); -if (ret) - goto err_disable_axi_clk; - - ret =iris_prepare_enable_clock (core,IRIS_HW_CLK ); -if (ret) - goto err_disable_hw_free_clk; - -return 0 ; - -err_disable_hw_free_clk: -iris_disable_unprepare_clock (core,IRIS_HW_FREERUN_CLK ); -err_disable_axi_clk: -iris_disable_unprepare_clock (core,IRIS_AXI_CLK ); -err_disable_power: -iris_disable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); - -return ret; +return iris_enable_power_domain_and_clocks (core, core->vcodec); }static void iris_vpu35_power_off_hw (struct iris_core *core) {iris_vpu33_power_off_hardware (core); - -iris_disable_unprepare_clock (core,IRIS_HW_FREERUN_CLK ); -iris_disable_unprepare_clock (core,IRIS_AXI_CLK ); }const struct vpu_ops iris_vpu3_ops = {
drivers/media/platform/qcom/iris/iris_vpu4x.c +19 -118
224 lines not on this page · raw message
drivers/media/platform/qcom/iris/iris_vpu_common.c +9 -89
147 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v7 06/12] media: iris: Replace enum-indexed clock and power domain tables with per-block structures
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
New issues:
- [High] Uninitialized stack pointer dereference when a hardware block has 0 power domains.
- [High] Secondary hardware cores are left unpowered due to missing iteration over num_cores.
- [High] NULL pointer dereference when optional hardware blocks are enabled in hardware but missing from platform data.
- [High] Premature OPP voltage drop causes DVFS sequence violation.
- [High] Uninitialized fields in struct dev_pm_domain_attach_data result in arbitrary behavior.
- [Medium] API mismatch silently discards additional power domains if pd_cnt > 1.
Pre-existing issues:
- [High] Resource leak of Runtime PM usage counter and OPP rate on error path. --
commit 569dbace99d0eb806398e44f1f3dd0f46e77e155
Author: Vishnu Reddy <[email protected]>
media: iris: Replace enum-indexed clock and power domain tables with per-block structures
This patch replaces flat, enum-indexed tables for clocks and power domains with per-hardware block structures in the iris driver. It groups devices, power domains, and clocks together logically in the iris_power_domain struct, and removes index lookups at runtime.
Quoted 5 lines
drivers/media/platform/qcom/iris/iris_probe.c +0
-0
drivers/media/platform/qcom/iris/iris_probe.c static int iris_init_icc(struct iris_core *core) · line 46
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_probe.c +4
-1@@ -39,15 +39,32 @@ static int iris_init_icc(struct iris_core *core)return devm_of_icc_bulk_get (core->dev, core->icc_count, core->icc_tbl); } -static int iris_init_power_domains (struct iris_core *core) +static int iris_init_power_domains_per_block (struct iris_core *core, +struct iris_power_domain *pd, +const struct iris_power_domain_data *pd_data) { +struct dev_pm_domain_attach_data iris_pd_data;
[Severity: High]
Does this leave fields in iris_pd_data uninitialized? Since it's allocated on the stack without zero-initialization, any fields added to struct dev_pm_domain_attach_data (like link_flags) could contain stack garbage when passed to devm_pm_domain_attach_list().
drivers/media/platform/qcom/iris/iris_probe.c static int iris_init_icc(struct iris_core *core) · line 58
Quoted 12 lines
drivers/media/platform/qcom/iris/iris_probe.c +10
-0+struct dev_pm_domain_list *pmdomain_tbl;int ret; + iris_pd_data.pd_names = pd_data->pd_names; + iris_pd_data.num_pd_names = pd_data->pd_cnt; + iris_pd_data.pd_flags =PD_FLAG_NO_DEV_LINK ; + + ret =devm_pm_domain_attach_list (core->dev, &iris_pd_data, &pmdomain_tbl); +if (ret <0 ) +return ret; + + pd->dev = pmdomain_tbl->pd_devs[0 ];
[Severity: High]
If pd_data->pd_cnt is 0, devm_pm_domain_attach_list() returns 0 but does not modify pmdomain_tbl. Does this result in an uninitialized pointer dereference when accessing pmdomain_tbl->pd_devs[0]?
[Severity: Medium]
Also, if the platform data specifies multiple power domains (pd_cnt > 1), does this logic silently discard all but the first power domain? Since PD_FLAG_NO_DEV_LINK is used, the driver has to power them on manually, which means secondary domains might never be powered on.
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_probe.c +3
-0+ +return 0 ; +}
[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_resources.c +0
-0
[ ... ]
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1@@ -70,7 +69,7 @@ int iris_opp_set_rate(struct device *dev, unsigned long freq)return dev_pm_opp_set_opp (dev, opp); } -int iris_enable_power_domains (struct iris_core *core,struct device *pd_dev) +int iris_enable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd) {int ret;
drivers/media/platform/qcom/iris/iris_resources.c int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev) · line 83
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1@@ -78,66 +77,20 @@ int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev)if (ret)return ret; - ret =pm_runtime_get_sync (pd_dev); + ret =pm_runtime_get_sync (pd->dev);if (ret <0 )return ret;
[Severity: High]
This is a pre-existing issue, but does this error path permanently leak the runtime PM usage counter and leave the global core device forced to its highest performance state? If pm_runtime_get_sync() fails, there is no pm_runtime_put_noidle() or iris_opp_set_rate(core->dev, 0) called before returning.
Quoted 20 lines
drivers/media/platform/qcom/iris/iris_resources.c +2
-16-return ret; -} - -int iris_disable_power_domains (struct iris_core *core,struct device *pd_dev) -{ -int ret; - - ret =iris_opp_set_rate (core->dev,0 ); + ret =clk_bulk_prepare_enable (pd->clk_cnt, pd->clocks);if (ret) -return ret; - -pm_runtime_put_sync (pd_dev); - -return 0 ; -} +pm_runtime_put_sync (pd->dev); -static struct clk *iris_get_clk_by_type (struct iris_core *core,enum platform_clk_type clk_type) -{
[ ... ]
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_resources.c +2
-4+return ret; } -int iris_disable_unprepare_clock (struct iris_core *core,enum platform_clk_type clk_type) +void iris_disable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd) { -struct clk *clock; - - clock =iris_get_clk_by_type (core, clk_type);
drivers/media/platform/qcom/iris/iris_resources.c int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev) · line 96
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_resources.c +3
-6-if (!clock) -return -EINVAL ; - -clk_disable_unprepare (clock); - -return 0 ; +clk_bulk_disable_unprepare (pd->clk_cnt, pd->clocks); +iris_opp_set_rate (core->dev,0 ); +pm_runtime_put_sync (pd->dev); }
[Severity: High]
Could dropping the OPP rate to 0 inside a block-specific helper cause issues? If multiple blocks are being torn down (for example, in iris_vpu4x_power_off_hardware() which shuts down VPP1, VPP0, then VCODEC), this would instantly drop the global controller OPP to 0 when the first block is disabled, while other blocks' clocks are still running. Does this violate DVFS constraints?
[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +0
-0
[ ... ]
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +0
-2@@ -158,116 +136,43 @@ static void iris_vpu4x_ahb_sync_reset_hardware(struct iris_core *core)writel (0x0 , core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); } -static int iris_vpu4x_enable_hardware_clocks (struct iris_core *core,u32 efuse_value) -{
[ ... ]
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +0
-2-} -static int iris_vpu4x_power_on_hardware (struct iris_core *core) {u32 efuse_value =readl (core->reg_base +WRAPPER_EFUSE_MONITOR );int ret;
drivers/media/platform/qcom/iris/iris_vpu4x.c static void iris_vpu4x_ahb_sync_reset_hardware(struct iris_core *core) · line 149
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +2
-3- ret =iris_enable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); + ret =iris_enable_power_domain_and_clocks (core, core->vcodec);if (ret)return ret;if (!(efuse_value &DISABLE_VIDEO_VPP0_BIT )) { - ret =iris_enable_power_domains (core, core->pmdomain_tbl->pd_devs - [IRIS_VPP0_HW_POWER_DOMAIN ]); + ret =iris_enable_power_domain_and_clocks (core, core->vcodec_vpp0);
[Severity: High]
If the hardware efuse indicates VPP0 is present, but the platform data omits vcodec_vpp0_data, core->vcodec_vpp0 will not be allocated during probe. Does this result in a NULL pointer dereference here since iris_enable_power_domain_and_clocks() accesses pd->dev?
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +0
-0if (ret) goto disable_hw_power_domain; }
[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_vpu_common.c +0
-0
[ ... ]
Quoted 22 lines
int
iris_vpu_power_on_hw(struct iris_core *core)
{drivers/media/platform/qcom/iris/iris_vpu_common.c +0
-20-int ret; - - ret =iris_enable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); -if (ret) -return ret; - - ret =iris_prepare_enable_clock (core,IRIS_HW_CLK ); -if (ret) - goto err_disable_power; - - ret =iris_prepare_enable_clock (core,IRIS_HW_AHB_CLK ); -if (ret && ret != -ENOENT ) - goto err_disable_hw_clock; - - ret =iris_prepare_enable_clock (core,IRIS_BSE_HW_CLK ); -if (ret && ret != -ENOENT ) - goto err_disable_hw_ahb_clock; - -return 0 ; -
drivers/media/platform/qcom/iris/iris_vpu_common.c int iris_vpu_power_on_controller(struct iris_core *core) · line 261
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu_common.c +1
-8-err_disable_hw_ahb_clock: -iris_disable_unprepare_clock (core,IRIS_HW_AHB_CLK ); -err_disable_hw_clock: -iris_disable_unprepare_clock (core,IRIS_HW_CLK ); -err_disable_power: -iris_disable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); - -return ret; +return iris_enable_power_domain_and_clocks (core, core->vcodec); }
[Severity: High]
Does this fail to power on any secondary hardware cores? The probe function dynamically allocates core->vcodec as an array based on num_cores, but this only passes the pointer to the first element to iris_enable_power_domain_and_clocks(), without iterating over the remaining cores.
Quoted 6 lines
int
iris_vpu_set_hwmode(struct iris_core *core)
{drivers/media/platform/qcom/iris/iris_vpu_common.c +1
-1-return dev_pm_genpd_set_hwmode (core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ], true); +return dev_pm_genpd_set_hwmode (core->vcodec->dev, true); }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Re: [PATCH v7 06/12] media: iris: Replace enum-indexed clock and power domain tables with per-block structures
Quoted 32 lines · On Wed, Jun 03, 2026 at 02:37:18PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
New issues:
- [High] Uninitialized stack pointer dereference when a hardware block has 0 power domains.
- [High] Secondary hardware cores are left unpowered due to missing iteration overnum_cores.
- [High] NULL pointer dereference when optional hardware blocks are enabled in hardware but missing from platform data.
- [High] Premature OPP voltage drop causes DVFS sequence violation.
- [High] Uninitialized fields instruct dev_pm_domain_attach_dataresult in arbitrary behavior.
- [Medium] API mismatch silently discards additional power domains ifpd_cnt > 1.Pre-existing issues:
- [High] Resource leak of Runtime PM usage counter and OPP rate on error path. --commit
569dbace99d0eb806398e44f1f3dd0f46e77e155
Author: Vishnu Reddy <[email protected]>media: iris: Replace enum-indexed clock and power domain tables with per-block structures
This patch replaces flat, enum-indexed tables for clocks and power domains with per-hardware block structures in the iris driver. It groups devices, power domains, and clocks together logically in the
iris_power_domainstruct, and removes index lookups at runtime.Quoted 8 lines
drivers/media/platform/qcom/iris/iris_probe.c +0
-0@@ -39,15 +39,32 @@ static int iris_init_icc(struct iris_core *core)return devm_of_icc_bulk_get (core->dev, core->icc_count, core->icc_tbl); }
Quoted 12 lines
drivers/media/platform/qcom/iris/iris_probe.c static int iris_init_icc(struct iris_core *core) · line 46
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_probe.c +4
-1-static int iris_init_power_domains (struct iris_core *core) +static int iris_init_power_domains_per_block (struct iris_core *core, +struct iris_power_domain *pd, +const struct iris_power_domain_data *pd_data) { +struct dev_pm_domain_attach_data iris_pd_data;[Severity: High]
Does this leave fields iniris_pd_datauninitialized? Since it's allocated on the stack without zero-initialization, any fields added to structdev_pm_domain_attach_data(likelink_flags) could contain stack garbage when passed todevm_pm_domain_attach_list().
A simple '= {};' would have saved you.
Quoted 19 lines
drivers/media/platform/qcom/iris/iris_probe.c static int iris_init_icc(struct iris_core *core) · line 58
Quoted 13 lines
drivers/media/platform/qcom/iris/iris_probe.c +10
-0+struct dev_pm_domain_list *pmdomain_tbl;int ret; + iris_pd_data.pd_names = pd_data->pd_names; + iris_pd_data.num_pd_names = pd_data->pd_cnt; + iris_pd_data.pd_flags =PD_FLAG_NO_DEV_LINK ; + + ret =devm_pm_domain_attach_list (core->dev, &iris_pd_data, &pmdomain_tbl); +if (ret <0 ) +return ret; + + pd->dev = pmdomain_tbl->pd_devs[0 ];[Severity: High]
Ifpd_data->pd_cntis 0,devm_pm_domain_attach_list()returns 0 but does not modifypmdomain_tbl. Does this result in an uninitialized pointer dereference when accessing pmdomain_tbl->pd_devs[0]?
Quoted 5 lines
[Severity: Medium]
Also, if the platform data specifies multiple power domains (pd_cnt> 1), does this logic silently discard all but the first power domain? SincePD_FLAG_NO_DEV_LINKis used, the driver has to power them on manually, which means secondary domains might never be powered on.
Indeed, both seem to be correct.
Quoted 23 lines
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_probe.c +3
-0+ +return 0 ; +}[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_resources.c +0
-0[ ... ]
Quoted 13 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1@@ -70,7 +69,7 @@ int iris_opp_set_rate(struct device *dev, unsigned long freq)return dev_pm_opp_set_opp (dev, opp); } -int iris_enable_power_domains (struct iris_core *core,struct device *pd_dev) +int iris_enable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd) {int ret;@@ -78,66 +77,20 @@ int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev)if (ret)return ret;
Quoted 12 lines
drivers/media/platform/qcom/iris/iris_resources.c int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev) · line 83
Quoted 5 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1- ret =pm_runtime_get_sync (pd_dev); + ret =pm_runtime_get_sync (pd->dev);if (ret <0 )return ret;[Severity: High]
This is a pre-existing issue, but does this error path permanently leak the runtime PM usage counter and leave the global core device forced to its highest performance state? Ifpm_runtime_get_sync()fails, there is nopm_runtime_put_noidle()oriris_opp_set_rate(core->dev, 0)called before returning.
I think I saw patches fixing this.
Quoted 42 lines
Quoted 21 lines
drivers/media/platform/qcom/iris/iris_resources.c +2
-16-return ret; -} - -int iris_disable_power_domains (struct iris_core *core,struct device *pd_dev) -{ -int ret; - - ret =iris_opp_set_rate (core->dev,0 ); + ret =clk_bulk_prepare_enable (pd->clk_cnt, pd->clocks);if (ret) -return ret; - -pm_runtime_put_sync (pd_dev); - -return 0 ; -} +pm_runtime_put_sync (pd->dev); -static struct clk *iris_get_clk_by_type (struct iris_core *core,enum platform_clk_type clk_type) -{[ ... ]
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_resources.c +2
-4+return ret; } -int iris_disable_unprepare_clock (struct iris_core *core,enum platform_clk_type clk_type) +void iris_disable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd) { -struct clk *clock; - - clock =iris_get_clk_by_type (core, clk_type);drivers/media/platform/qcom/iris/iris_resources.c int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev) · line 96
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_resources.c +3
-6-if (!clock) -return -EINVAL ; - -clk_disable_unprepare (clock); - -return 0 ; +clk_bulk_disable_unprepare (pd->clk_cnt, pd->clocks); +iris_opp_set_rate (core->dev,0 ); +pm_runtime_put_sync (pd->dev); }
Quoted 7 lines
[Severity: High]
Could dropping the OPP rate to 0 inside a block-specific helper cause issues? If multiple blocks are being torn down (for example, iniris_vpu4x_power_off_hardware()which shuts down VPP1, VPP0, then VCODEC), this would instantly drop the global controller OPP to 0 when the first block is disabled, while other blocks' clocks are still running. Does this violate DVFS constraints?
Yes. iris_opp_set_rate() should not be called from a per-domain functions.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v7 06/12] media: iris: Replace enum-indexed clock and power domain tables with per-block structures
Quoted 44 lines · Dmitry Baryshkov
Quoted 32 lines · On Wed, Jun 03, 2026 at 02:37:18PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
New issues:
- [High] Uninitialized stack pointer dereference when a hardware block has 0 power domains.
- [High] Secondary hardware cores are left unpowered due to missing iteration overnum_cores.
- [High] NULL pointer dereference when optional hardware blocks are enabled in hardware but missing from platform data.
- [High] Premature OPP voltage drop causes DVFS sequence violation.
- [High] Uninitialized fields instruct dev_pm_domain_attach_dataresult in arbitrary behavior.
- [Medium] API mismatch silently discards additional power domains ifpd_cnt > 1.Pre-existing issues:
- [High] Resource leak of Runtime PM usage counter and OPP rate on error path. --commit
569dbace99d0eb806398e44f1f3dd0f46e77e155
Author: Vishnu Reddy <[email protected]>media: iris: Replace enum-indexed clock and power domain tables with per-block structures
This patch replaces flat, enum-indexed tables for clocks and power domains with per-hardware block structures in the iris driver. It groups devices, power domains, and clocks together logically in the
iris_power_domainstruct, and removes index lookups at runtime.Quoted 8 lines
drivers/media/platform/qcom/iris/iris_probe.c +0
-0@@ -39,15 +39,32 @@ static int iris_init_icc(struct iris_core *core)return devm_of_icc_bulk_get (core->dev, core->icc_count, core->icc_tbl); }Quoted 11 lines
drivers/media/platform/qcom/iris/iris_probe.c static int iris_init_icc(struct iris_core *core) · line 46
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_probe.c +4
-1-static int iris_init_power_domains (struct iris_core *core) +static int iris_init_power_domains_per_block (struct iris_core *core, +struct iris_power_domain *pd, +const struct iris_power_domain_data *pd_data) { +struct dev_pm_domain_attach_data iris_pd_data;[Severity: High]
Does this leave fields iniris_pd_datauninitialized? Since it's allocated on the stack without zero-initialization, any fields added to structdev_pm_domain_attach_data(likelink_flags) could contain stack garbage when passed todevm_pm_domain_attach_list().
Quoted 1 line
A simple '= {};' would have saved you.
Thanks, will use this.
Quoted 17 lines
Quoted 17 lines
drivers/media/platform/qcom/iris/iris_probe.c static int iris_init_icc(struct iris_core *core) · line 58
Quoted 12 lines
drivers/media/platform/qcom/iris/iris_probe.c +10
-0+struct dev_pm_domain_list *pmdomain_tbl;int ret; + iris_pd_data.pd_names = pd_data->pd_names; + iris_pd_data.num_pd_names = pd_data->pd_cnt; + iris_pd_data.pd_flags =PD_FLAG_NO_DEV_LINK ; + + ret =devm_pm_domain_attach_list (core->dev, &iris_pd_data, &pmdomain_tbl); +if (ret <0 ) +return ret; + + pd->dev = pmdomain_tbl->pd_devs[0 ];[Severity: High]
Ifpd_data->pd_cntis 0,devm_pm_domain_attach_list()returns 0 but does not modifypmdomain_tbl. Does this result in an uninitialized pointer dereference when accessing pmdomain_tbl->pd_devs[0]?
Quoted 6 lines
Quoted 5 lines
[Severity: Medium]
Also, if the platform data specifies multiple power domains (pd_cnt> 1), does this logic silently discard all but the first power domain? SincePD_FLAG_NO_DEV_LINKis used, the driver has to power them on manually, which means secondary domains might never be powered on.Indeed, both seem to be correct.
For pd_cnt = 0: Will add a guard to return early before accessing pmdomain_tbl.
For pd_cnt > 1: All current platforms will 1 pd_cnt only. Support for multiple managed domains will be added when needed.
Quoted 33 lines
Quoted 22 lines
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_probe.c +3
-0+ +return 0 ; +}[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_resources.c +0
-0[ ... ]
Quoted 13 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1@@ -70,7 +69,7 @@ int iris_opp_set_rate(struct device *dev, unsigned long freq)return dev_pm_opp_set_opp (dev, opp); } -int iris_enable_power_domains (struct iris_core *core,struct device *pd_dev) +int iris_enable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd) {int ret;@@ -78,66 +77,20 @@ int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev)if (ret)return ret;Quoted 11 lines
drivers/media/platform/qcom/iris/iris_resources.c int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev) · line 83
Quoted 5 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1- ret =pm_runtime_get_sync (pd_dev); + ret =pm_runtime_get_sync (pd->dev);if (ret <0 )return ret;[Severity: High]
This is a pre-existing issue, but does this error path permanently leak the runtime PM usage counter and leave the global core device forced to its highest performance state? Ifpm_runtime_get_sync()fails, there is nopm_runtime_put_noidle()oriris_opp_set_rate(core->dev, 0)called before returning.
Quoted 1 line
I think I saw patches fixing this.
Yes, You are correct.
Quoted 47 lines
Quoted 39 lines
Quoted 20 lines
drivers/media/platform/qcom/iris/iris_resources.c +2
-16-return ret; -} - -int iris_disable_power_domains (struct iris_core *core,struct device *pd_dev) -{ -int ret; - - ret =iris_opp_set_rate (core->dev,0 ); + ret =clk_bulk_prepare_enable (pd->clk_cnt, pd->clocks);if (ret) -return ret; - -pm_runtime_put_sync (pd_dev); - -return 0 ; -} +pm_runtime_put_sync (pd->dev); -static struct clk *iris_get_clk_by_type (struct iris_core *core,enum platform_clk_type clk_type) -{[ ... ]
Quoted 18 lines
drivers/media/platform/qcom/iris/iris_resources.c +5
-10+return ret; } -int iris_disable_unprepare_clock (struct iris_core *core,enum platform_clk_type clk_type) +void iris_disable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd) { -struct clk *clock; - - clock =iris_get_clk_by_type (core, clk_type); -if (!clock) -return -EINVAL ; - -clk_disable_unprepare (clock); - -return 0 ; +clk_bulk_disable_unprepare (pd->clk_cnt, pd->clocks); +iris_opp_set_rate (core->dev,0 ); +pm_runtime_put_sync (pd->dev);Quoted 8 lines
Quoted 1 line
}
[Severity: High]
Could dropping the OPP rate to 0 inside a block-specific helper cause issues? If multiple blocks are being torn down (for example, iniris_vpu4x_power_off_hardware()which shuts down VPP1, VPP0, then VCODEC), this would instantly drop the global controller OPP to 0 when the first block is disabled, while other blocks' clocks are still running. Does this violate DVFS constraints?
Quoted 3 lines
Yes.
iris_opp_set_rate()should not be called from a per-domain functions.
iris_opp_set_rate(0) sets all associated clocks to their lowest rate and drops the RPMHPD level to low simultaneously. By the time the first block's helper calls it, no clocks remain at a higher rate.
Re: [PATCH v7 06/12] media: iris: Replace enum-indexed clock and power domain tables with per-block structures
In reply to [email protected]Quoted 224 lines · On 6/3/2026 8:07 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
New issues:
- [High] Uninitialized stack pointer dereference when a hardware block has 0 power domains.
- [High] Secondary hardware cores are left unpowered due to missing iteration overnum_cores.
- [High] NULL pointer dereference when optional hardware blocks are enabled in hardware but missing from platform data.
- [High] Premature OPP voltage drop causes DVFS sequence violation.
- [High] Uninitialized fields instruct dev_pm_domain_attach_dataresult in arbitrary behavior.
- [Medium] API mismatch silently discards additional power domains ifpd_cnt > 1.Pre-existing issues:
- [High] Resource leak of Runtime PM usage counter and OPP rate on error path. --commit
569dbace99d0eb806398e44f1f3dd0f46e77e155
Author: Vishnu Reddy <[email protected]>media: iris: Replace enum-indexed clock and power domain tables with per-block structures
This patch replaces flat, enum-indexed tables for clocks and power domains with per-hardware block structures in the iris driver. It groups devices, power domains, and clocks together logically in the
iris_power_domainstruct, and removes index lookups at runtime.Quoted 5 lines
drivers/media/platform/qcom/iris/iris_probe.c +0
-0drivers/media/platform/qcom/iris/iris_probe.c static int iris_init_icc(struct iris_core *core) · line 46
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_probe.c +4
-1@@ -39,15 +39,32 @@ static int iris_init_icc(struct iris_core *core)return devm_of_icc_bulk_get (core->dev, core->icc_count, core->icc_tbl); } -static int iris_init_power_domains (struct iris_core *core) +static int iris_init_power_domains_per_block (struct iris_core *core, +struct iris_power_domain *pd, +const struct iris_power_domain_data *pd_data) { +struct dev_pm_domain_attach_data iris_pd_data;[Severity: High]
Does this leave fields iniris_pd_datauninitialized? Since it's allocated on the stack without zero-initialization, any fields added to structdev_pm_domain_attach_data(likelink_flags) could contain stack garbage when passed todevm_pm_domain_attach_list().drivers/media/platform/qcom/iris/iris_probe.c static int iris_init_icc(struct iris_core *core) · line 58
Quoted 12 lines
drivers/media/platform/qcom/iris/iris_probe.c +10
-0+struct dev_pm_domain_list *pmdomain_tbl;int ret; + iris_pd_data.pd_names = pd_data->pd_names; + iris_pd_data.num_pd_names = pd_data->pd_cnt; + iris_pd_data.pd_flags =PD_FLAG_NO_DEV_LINK ; + + ret =devm_pm_domain_attach_list (core->dev, &iris_pd_data, &pmdomain_tbl); +if (ret <0 ) +return ret; + + pd->dev = pmdomain_tbl->pd_devs[0 ];[Severity: High]
Ifpd_data->pd_cntis 0,devm_pm_domain_attach_list()returns 0 but does not modifypmdomain_tbl. Does this result in an uninitialized pointer dereference when accessing pmdomain_tbl->pd_devs[0]?[Severity: Medium]
Also, if the platform data specifies multiple power domains (pd_cnt> 1), does this logic silently discard all but the first power domain? SincePD_FLAG_NO_DEV_LINKis used, the driver has to power them on manually, which means secondary domains might never be powered on.Quoted 3 lines
drivers/media/platform/qcom/iris/iris_probe.c +3
-0+ +return 0 ; +}[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_resources.c +0
-0[ ... ]
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1@@ -70,7 +69,7 @@ int iris_opp_set_rate(struct device *dev, unsigned long freq)return dev_pm_opp_set_opp (dev, opp); } -int iris_enable_power_domains (struct iris_core *core,struct device *pd_dev) +int iris_enable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd) {int ret;drivers/media/platform/qcom/iris/iris_resources.c int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev) · line 83
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1@@ -78,66 +77,20 @@ int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev)if (ret)return ret; - ret =pm_runtime_get_sync (pd_dev); + ret =pm_runtime_get_sync (pd->dev);if (ret <0 )return ret;[Severity: High]
This is a pre-existing issue, but does this error path permanently leak the runtime PM usage counter and leave the global core device forced to its highest performance state? Ifpm_runtime_get_sync()fails, there is nopm_runtime_put_noidle()oriris_opp_set_rate(core->dev, 0)called before returning.Quoted 20 lines
drivers/media/platform/qcom/iris/iris_resources.c +2
-16-return ret; -} - -int iris_disable_power_domains (struct iris_core *core,struct device *pd_dev) -{ -int ret; - - ret =iris_opp_set_rate (core->dev,0 ); + ret =clk_bulk_prepare_enable (pd->clk_cnt, pd->clocks);if (ret) -return ret; - -pm_runtime_put_sync (pd_dev); - -return 0 ; -} +pm_runtime_put_sync (pd->dev); -static struct clk *iris_get_clk_by_type (struct iris_core *core,enum platform_clk_type clk_type) -{[ ... ]
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_resources.c +2
-4+return ret; } -int iris_disable_unprepare_clock (struct iris_core *core,enum platform_clk_type clk_type) +void iris_disable_power_domain_and_clocks (struct iris_core *core,struct iris_power_domain *pd) { -struct clk *clock; - - clock =iris_get_clk_by_type (core, clk_type);drivers/media/platform/qcom/iris/iris_resources.c int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev) · line 96
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_resources.c +3
-6-if (!clock) -return -EINVAL ; - -clk_disable_unprepare (clock); - -return 0 ; +clk_bulk_disable_unprepare (pd->clk_cnt, pd->clocks); +iris_opp_set_rate (core->dev,0 ); +pm_runtime_put_sync (pd->dev); }[Severity: High]
Could dropping the OPP rate to 0 inside a block-specific helper cause issues? If multiple blocks are being torn down (for example, iniris_vpu4x_power_off_hardware()which shuts down VPP1, VPP0, then VCODEC), this would instantly drop the global controller OPP to 0 when the first block is disabled, while other blocks' clocks are still running. Does this violate DVFS constraints?[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +0
-0[ ... ]
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +0
-2@@ -158,116 +136,43 @@ static void iris_vpu4x_ahb_sync_reset_hardware(struct iris_core *core)writel (0x0 , core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); } -static int iris_vpu4x_enable_hardware_clocks (struct iris_core *core,u32 efuse_value) -{[ ... ]
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +0
-2-} -static int iris_vpu4x_power_on_hardware (struct iris_core *core) {u32 efuse_value =readl (core->reg_base +WRAPPER_EFUSE_MONITOR );int ret;drivers/media/platform/qcom/iris/iris_vpu4x.c static void iris_vpu4x_ahb_sync_reset_hardware(struct iris_core *core) · line 149
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +2
-3- ret =iris_enable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); + ret =iris_enable_power_domain_and_clocks (core, core->vcodec);if (ret)return ret;if (!(efuse_value &DISABLE_VIDEO_VPP0_BIT )) { - ret =iris_enable_power_domains (core, core->pmdomain_tbl->pd_devs - [IRIS_VPP0_HW_POWER_DOMAIN ]); + ret =iris_enable_power_domain_and_clocks (core, core->vcodec_vpp0);[Severity: High]
If the hardware efuse indicates VPP0 is present, but the platform data omitsvcodec_vpp0_data,core->vcodec_vpp0will not be allocated during probe. Does this result in a NULL pointer dereference here sinceiris_enable_power_domain_and_clocks()accessespd->dev?Quoted 4 lines
drivers/media/platform/qcom/iris/iris_vpu4x.c +0
-0if (ret) goto disable_hw_power_domain; }[ ... ]
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_vpu_common.c +0
-0[ ... ]
Quoted 30 lines
int
iris_vpu_power_on_hw(struct iris_core *core)
{drivers/media/platform/qcom/iris/iris_vpu_common.c +0
-28-int ret; - - ret =iris_enable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); -if (ret) -return ret; - - ret =iris_prepare_enable_clock (core,IRIS_HW_CLK ); -if (ret) - goto err_disable_power; - - ret =iris_prepare_enable_clock (core,IRIS_HW_AHB_CLK ); -if (ret && ret != -ENOENT ) - goto err_disable_hw_clock; - - ret =iris_prepare_enable_clock (core,IRIS_BSE_HW_CLK ); -if (ret && ret != -ENOENT ) - goto err_disable_hw_ahb_clock; - -return 0 ; - -err_disable_hw_ahb_clock: -iris_disable_unprepare_clock (core,IRIS_HW_AHB_CLK ); -err_disable_hw_clock: -iris_disable_unprepare_clock (core,IRIS_HW_CLK ); -err_disable_power: -iris_disable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); - -return ret;
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_vpu_common.c
Quoted 2 lines
drivers/media/platform/qcom/iris/iris_vpu_common.c +1
-0+return iris_enable_power_domain_and_clocks (core, core->vcodec); }[Severity: High]
Does this fail to power on any secondary hardware cores? The probe function dynamically allocatescore->vcodecas an array based onnum_cores, but this only passes the pointer to the first element toiris_enable_power_domain_and_clocks(), without iterating over the remaining cores.
These functions will be applicable only for single core platforms.
Quoted 6 lines
Quoted 6 lines
int
iris_vpu_set_hwmode(struct iris_core *core)
{drivers/media/platform/qcom/iris/iris_vpu_common.c +1
-1-return dev_pm_genpd_set_hwmode (core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ], true); +return dev_pm_genpd_set_hwmode (core->vcodec->dev, true); }
PATCH v7 7/12 media: iris: Add power sequence for glymur
In reply to Vishnu ReddyGlymur platform has two video codec cores: vcodec0 and vcodec1.
Both cores share a common clock source (video_cc_mvs0_clk_src) and the same power rails. The clock dividers between the source and the branch clocks are fixed. So when both cores are running, the source clock always runs at the highest frequency requested by either core.
Since both cores share the same power rails, the power corner cannot be voted independently. Scaling one core's power corner up or down would directly affect the other, leading to under or over-voting.
For these reasons, both cores should voted the clock and power rail must be based on the workload of both cores.
--- drivers/media/platform/qcom/iris/iris_vpu3x.c | 111 ++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_vpu_common.h | 1 + .../platform/qcom/iris/iris_vpu_register_defines.h | 10 ++ 3 files changed, 117 insertions(+), 5 deletions(-)
drivers/media/platform/qcom/iris/iris_vpu3x.c +106 -5
@@ -17,14 +17,14 @@#define NOC_HALT BIT(0)#define AON_WRAPPER_SPARE (AON_BASE_OFFS + 0x28) -static bool iris_vpu3x_hw_power_collapsed (struct iris_core *core) +static bool iris_vpu3x_hw_power_collapsed (struct iris_core *core,u32 pwr_status_bit) {u32 value, pwr_status; value =readl (core->reg_base +WRAPPER_CORE_POWER_STATUS ); - pwr_status = value &BIT (1 ); + pwr_status = value & pwr_status_bit; -return pwr_status ? false : true; +return !pwr_status; }static void iris_vpu3_power_off_hardware (struct iris_core *core)
@@ -32,7 +32,7 @@ static void iris_vpu3_power_off_hardware(struct iris_core *core)u32 reg_val =0 , value, i;int ret; -if (iris_vpu3x_hw_power_collapsed (core)) +if (iris_vpu3x_hw_power_collapsed (core,VCODEC0_POWER_STATUS )) goto disable_power;dev_err (core->dev,"video hw is power on\n" );
@@ -78,7 +78,7 @@ static void iris_vpu33_power_off_hardware(struct iris_core *core)u32 count =0 ;int ret; -if (iris_vpu3x_hw_power_collapsed (core)) +if (iris_vpu3x_hw_power_collapsed (core,VCODEC0_POWER_STATUS )) goto disable_power;dev_err (core->dev,"video hw is power on\n" );
@@ -221,6 +221,98 @@ static void iris_vpu35_power_off_hw(struct iris_core *core)iris_vpu33_power_off_hardware (core); } +static void iris_vpu36_power_off_vcodec (struct iris_core *core,u32 core_id) +{ +u32 value, i; +int ret; + +if (iris_vpu3x_hw_power_collapsed (core, + core_id ?VCODEC1_POWER_STATUS :VCODEC0_POWER_STATUS )) + goto disable_power; + + value =readl (core->reg_base +WRAPPER_CORE_CLOCK_CONFIG ); +if (value) +writel (CORE_CLK_RUN , core->reg_base +WRAPPER_CORE_CLOCK_CONFIG ); + +for (i =0 ; i < core->iris_platform_data->num_vpp_pipe; i++) { + ret =readl_poll_timeout (core->reg_base + (core_id ?VCODEC1_SS_IDLE_STATUSN : +VCODEC_SS_IDLE_STATUSN ) +4 * i, value, + value &DMA_NOC_IDLE ,2000 ,20000 ); +if (ret) + goto disable_power; + } + +writel (core_id ?REQ_VCODEC1_POWER_DOWN_PREP :REQ_POWER_DOWN_PREP , + core->reg_base +AON_WRAPPER_MVP_NOC_LPI_CONTROL ); + ret =readl_poll_timeout (core->reg_base +AON_WRAPPER_MVP_NOC_LPI_STATUS , value, + value & (core_id ?NOC_LPI_VCODEC1_STATUS_DONE : +NOC_LPI_STATUS_DONE ),2000 ,20000 ); +if (ret) + goto disable_power; + +writel (0 , core->reg_base +AON_WRAPPER_MVP_NOC_LPI_CONTROL ); + +writel ((core_id ?VCODEC1_BRIDGE_SW_RESET |VCODEC1_BRIDGE_HW_RESET_DISABLE : +CORE_BRIDGE_SW_RESET |CORE_BRIDGE_HW_RESET_DISABLE ), + core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +writel (core_id ?VCODEC1_BRIDGE_HW_RESET_DISABLE :CORE_BRIDGE_HW_RESET_DISABLE , + core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +writel (0x0 , core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); + +disable_power: +dev_pm_genpd_set_hwmode (core->vcodec[core_id].dev, false); +iris_disable_power_domain_and_clocks (core, &core->vcodec[core_id]); +} + +static void iris_vpu36_power_off_hw (struct iris_core *core) +{ +u32 num_cores =max (core->iris_platform_data->num_cores,1 ); +int i; + +for (i =0 ; i < num_cores; i++) +iris_vpu36_power_off_vcodec (core, i); +} + +static int iris_vpu36_power_on_hw (struct iris_core *core) +{ +u32 num_cores =max (core->iris_platform_data->num_cores,1 ); +int i, ret; + +for (i =0 ; i < num_cores; i++) { + ret =iris_enable_power_domain_and_clocks (core, &core->vcodec[i]); +if (ret) + goto error; + } + +return 0 ; + +error: +while (--i >=0 ) +iris_vpu36_power_off_vcodec (core, i); + +return ret; +} + +static int iris_vpu36_set_hwmode (struct iris_core *core) +{ +u32 num_cores =max (core->iris_platform_data->num_cores,1 ); +int i, ret; + +for (i =0 ; i < num_cores; i++) { + ret =dev_pm_genpd_set_hwmode (core->vcodec[i].dev, true); +if (ret) + goto error; + } + +return 0 ; + +error: +while (--i >=0 ) +dev_pm_genpd_set_hwmode (core->vcodec[i].dev, false); + +return ret; +} +const struct vpu_ops iris_vpu3_ops = { .power_off_hw = iris_vpu3_power_off_hardware, .power_on_hw = iris_vpu_power_on_hw,
@@ -248,3 +340,12 @@ const struct vpu_ops iris_vpu35_ops = { .calc_freq = iris_vpu3x_vpu4x_calculate_frequency, .set_hwmode = iris_vpu_set_hwmode, }; + +const struct vpu_ops iris_vpu36_ops = { + .power_off_hw = iris_vpu36_power_off_hw, + .power_on_hw = iris_vpu36_power_on_hw, + .power_off_controller = iris_vpu35_vpu4x_power_off_controller, + .power_on_controller = iris_vpu35_vpu4x_power_on_controller, + .calc_freq = iris_vpu3x_vpu4x_calculate_frequency, + .set_hwmode = iris_vpu36_set_hwmode, +};
drivers/media/platform/qcom/iris/iris_vpu_common.h +1 -0
@@ -12,6 +12,7 @@ extern const struct vpu_ops iris_vpu2_ops;extern const struct vpu_ops iris_vpu3_ops;extern const struct vpu_ops iris_vpu33_ops;extern const struct vpu_ops iris_vpu35_ops; +extern const struct vpu_ops iris_vpu36_ops;extern const struct vpu_ops iris_vpu4x_ops;struct vpu_ops {
drivers/media/platform/qcom/iris/iris_vpu_register_defines.h +10 -0
@@ -7,6 +7,7 @@#define __IRIS_VPU_REGISTER_DEFINES_H__#define VCODEC_BASE_OFFS 0x00000000 +#define VCODEC1_BASE_OFFS 0x00040000#define AON_MVP_NOC_RESET 0x0001F000#define CPU_BASE_OFFS 0x000A0000#define WRAPPER_BASE_OFFS 0x000B0000
@@ -14,6 +15,8 @@#define AON_BASE_OFFS 0x000E0000#define VCODEC_SS_IDLE_STATUSN (VCODEC_BASE_OFFS + 0x70) +#define VCODEC1_SS_IDLE_STATUSN (VCODEC1_BASE_OFFS + 0x70) +#define DMA_NOC_IDLE BIT(22)#define AON_WRAPPER_MVP_NOC_RESET_REQ (AON_MVP_NOC_RESET + 0x000)#define VIDEO_NOC_RESET_REQ (BIT(0) | BIT(1))
@@ -35,6 +38,8 @@#define CPU_CS_AHB_BRIDGE_SYNC_RESET (CPU_CS_BASE_OFFS + 0x160)#define CORE_BRIDGE_SW_RESET BIT(0)#define CORE_BRIDGE_HW_RESET_DISABLE BIT(1) +#define VCODEC1_BRIDGE_SW_RESET BIT(2) +#define VCODEC1_BRIDGE_HW_RESET_DISABLE BIT(3)#define CPU_CS_X2RPMH (CPU_CS_BASE_OFFS + 0x168)#define MSK_SIGNAL_FROM_TENSILICA BIT(0)
@@ -52,14 +57,19 @@#define WRAPPER_DEBUG_BRIDGE_LPI_STATUS (WRAPPER_BASE_OFFS + 0x58)#define WRAPPER_IRIS_CPU_NOC_LPI_CONTROL (WRAPPER_BASE_OFFS + 0x5C)#define REQ_POWER_DOWN_PREP BIT(0) +#define REQ_VCODEC1_POWER_DOWN_PREP BIT(1)#define WRAPPER_IRIS_CPU_NOC_LPI_STATUS (WRAPPER_BASE_OFFS + 0x60)#define NOC_LPI_STATUS_DONE BIT(0)/* Indicates the NOC handshake is complete */ #define NOC_LPI_STATUS_DENY BIT(1)/* Indicates the NOC handshake is denied */ #define NOC_LPI_STATUS_ACTIVE BIT(2)/* Indicates the NOC is active */ +#define NOC_LPI_VCODEC1_STATUS_DONE BIT(8)#define WRAPPER_IRIS_VCODEC_VPU_WRAPPER_SPARE_0 (WRAPPER_BASE_OFFS + 0x78)#define WRAPPER_CORE_POWER_STATUS (WRAPPER_BASE_OFFS + 0x80) +#define VCODEC0_POWER_STATUS BIT(1) +#define VCODEC1_POWER_STATUS BIT(4) +#define WRAPPER_CORE_CLOCK_CONFIG (WRAPPER_BASE_OFFS + 0x88)#define CORE_CLK_RUN 0x0
Signature · 1 line
2.34.1
Re: [PATCH v7 07/12] media: iris: Add power sequence for glymur
Quoted 73 lines · Vishnu Reddy
Glymur platform has two video codec cores: vcodec0 and vcodec1.
Both cores share a common clock source (
video_cc_mvs0_clk_src) and the same power rails. The clock dividers between the source and the branch clocks are fixed. So when both cores are running, the source clock always runs at the highest frequency requested by either core.Since both cores share the same power rails, the power corner cannot be voted independently. Scaling one core's power corner up or down would directly affect the other, leading to under or over-voting.
For these reasons, both cores should voted the clock and power rail must be based on the workload of both cores.
Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Vishnu Reddy <[email protected]>--- drivers/media/platform/qcom/iris/iris_vpu3x.c | 111 ++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_vpu_common.h | 1 + .../platform/qcom/iris/iris_vpu_register_defines.h | 10 ++ 3 files changed, 117 insertions(+), 5 deletions(-)drivers/media/platform/qcom/iris/iris_vpu3x.c +12
-5@@ -17,14 +17,14 @@#define NOC_HALT BIT(0)#define AON_WRAPPER_SPARE (AON_BASE_OFFS + 0x28) -static bool iris_vpu3x_hw_power_collapsed (struct iris_core *core) +static bool iris_vpu3x_hw_power_collapsed (struct iris_core *core,u32 pwr_status_bit) {u32 value, pwr_status; value =readl (core->reg_base +WRAPPER_CORE_POWER_STATUS ); - pwr_status = value &BIT (1 ); + pwr_status = value & pwr_status_bit; -return pwr_status ? false : true; +return !pwr_status; }static void iris_vpu3_power_off_hardware (struct iris_core *core)@@ -32,7 +32,7 @@ static void iris_vpu3_power_off_hardware(struct iris_core *core)u32 reg_val =0 , value, i;int ret; -if (iris_vpu3x_hw_power_collapsed (core)) +if (iris_vpu3x_hw_power_collapsed (core,VCODEC0_POWER_STATUS )) goto disable_power;dev_err (core->dev,"video hw is power on\n" );@@ -78,7 +78,7 @@ static void iris_vpu33_power_off_hardware(struct iris_core *core)u32 count =0 ;int ret; -if (iris_vpu3x_hw_power_collapsed (core)) +if (iris_vpu3x_hw_power_collapsed (core,VCODEC0_POWER_STATUS )) goto disable_power;dev_err (core->dev,"video hw is power on\n" );@@ -221,6 +221,98 @@ static void iris_vpu35_power_off_hw(struct iris_core *core)iris_vpu33_power_off_hardware (core); } +static void iris_vpu36_power_off_vcodec (struct iris_core *core,u32 core_id) +{ +u32 value, i; +int ret; + +if (iris_vpu3x_hw_power_collapsed (core, + core_id ?VCODEC1_POWER_STATUS :VCODEC0_POWER_STATUS ))
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu35_power_off_hw(struct iris_core *core) · line 240
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +10
-0+ goto disable_power; + + value =readl (core->reg_base +WRAPPER_CORE_CLOCK_CONFIG ); +if (value) +writel (CORE_CLK_RUN , core->reg_base +WRAPPER_CORE_CLOCK_CONFIG ); + +for (i =0 ; i < core->iris_platform_data->num_vpp_pipe; i++) { + ret =readl_poll_timeout (core->reg_base + (core_id ?VCODEC1_SS_IDLE_STATUSN : +VCODEC_SS_IDLE_STATUSN ) +4 * i, value, + value &DMA_NOC_IDLE ,2000 ,20000 );
Unreadable. Extract register addresses to separate variables.
Quoted 19 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +19
-0+if (ret) + goto disable_power; + } + +writel (core_id ?REQ_VCODEC1_POWER_DOWN_PREP :REQ_POWER_DOWN_PREP , + core->reg_base +AON_WRAPPER_MVP_NOC_LPI_CONTROL ); + ret =readl_poll_timeout (core->reg_base +AON_WRAPPER_MVP_NOC_LPI_STATUS , value, + value & (core_id ?NOC_LPI_VCODEC1_STATUS_DONE : +NOC_LPI_STATUS_DONE ),2000 ,20000 ); +if (ret) + goto disable_power; + +writel (0 , core->reg_base +AON_WRAPPER_MVP_NOC_LPI_CONTROL ); + +writel ((core_id ?VCODEC1_BRIDGE_SW_RESET |VCODEC1_BRIDGE_HW_RESET_DISABLE : +CORE_BRIDGE_SW_RESET |CORE_BRIDGE_HW_RESET_DISABLE ), + core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +writel (core_id ?VCODEC1_BRIDGE_HW_RESET_DISABLE :CORE_BRIDGE_HW_RESET_DISABLE , + core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET );
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu35_power_off_hw(struct iris_core *core) · line 269
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +10
-0+writel (0x0 , core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); + +disable_power: +dev_pm_genpd_set_hwmode (core->vcodec[core_id].dev, false); +iris_disable_power_domain_and_clocks (core, &core->vcodec[core_id]); +} + +static void iris_vpu36_power_off_hw (struct iris_core *core) +{ +u32 num_cores =max (core->iris_platform_data->num_cores,1 );
Can we trust the patch authors that VPU3.6 hardware data will have at least 1 core?
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu35_power_off_hw(struct iris_core *core)
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +6
-0+int i; + +for (i =0 ; i < num_cores; i++) +iris_vpu36_power_off_vcodec (core, i); +} +#define WRAPPER_DEBUG_BRIDGE_LPI_STATUS (WRAPPER_BASE_OFFS + 0x58)#define WRAPPER_IRIS_CPU_NOC_LPI_CONTROL (WRAPPER_BASE_OFFS + 0x5C)
Lowercase hex.
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +1
-0#define REQ_POWER_DOWN_PREP BIT(0) +#define REQ_VCODEC1_POWER_DOWN_PREP BIT(1)
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v7 07/12] media: iris: Add power sequence for glymur
Quoted 77 lines · Dmitry Baryshkov
Quoted 76 lines · Vishnu Reddy
Glymur platform has two video codec cores: vcodec0 and vcodec1.
Both cores share a common clock source (
video_cc_mvs0_clk_src) and the same power rails. The clock dividers between the source and the branch clocks are fixed. So when both cores are running, the source clock always runs at the highest frequency requested by either core.Since both cores share the same power rails, the power corner cannot be voted independently. Scaling one core's power corner up or down would directly affect the other, leading to under or over-voting.
For these reasons, both cores should voted the clock and power rail must be based on the workload of both cores.
Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Vishnu Reddy <[email protected]>--- drivers/media/platform/qcom/iris/iris_vpu3x.c | 111 ++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_vpu_common.h | 1 + .../platform/qcom/iris/iris_vpu_register_defines.h | 10 ++ 3 files changed, 117 insertions(+), 5 deletions(-)drivers/media/platform/qcom/iris/iris_vpu3x.c +15
-5@@ -17,14 +17,14 @@#define NOC_HALT BIT(0)#define AON_WRAPPER_SPARE (AON_BASE_OFFS + 0x28) -static bool iris_vpu3x_hw_power_collapsed (struct iris_core *core) +static bool iris_vpu3x_hw_power_collapsed (struct iris_core *core,u32 pwr_status_bit) {u32 value, pwr_status; value =readl (core->reg_base +WRAPPER_CORE_POWER_STATUS ); - pwr_status = value &BIT (1 ); + pwr_status = value & pwr_status_bit; -return pwr_status ? false : true; +return !pwr_status; }static void iris_vpu3_power_off_hardware (struct iris_core *core)@@ -32,7 +32,7 @@ static void iris_vpu3_power_off_hardware(struct iris_core *core)u32 reg_val =0 , value, i;int ret; -if (iris_vpu3x_hw_power_collapsed (core)) +if (iris_vpu3x_hw_power_collapsed (core,VCODEC0_POWER_STATUS )) goto disable_power;dev_err (core->dev,"video hw is power on\n" );@@ -78,7 +78,7 @@ static void iris_vpu33_power_off_hardware(struct iris_core *core)u32 count =0 ;int ret; -if (iris_vpu3x_hw_power_collapsed (core)) +if (iris_vpu3x_hw_power_collapsed (core,VCODEC0_POWER_STATUS )) goto disable_power;dev_err (core->dev,"video hw is power on\n" );@@ -221,6 +221,98 @@ static void iris_vpu35_power_off_hw(struct iris_core *core)iris_vpu33_power_off_hardware (core); } +static void iris_vpu36_power_off_vcodec (struct iris_core *core,u32 core_id) +{ +u32 value, i; +int ret; + +if (iris_vpu3x_hw_power_collapsed (core, + core_id ?VCODEC1_POWER_STATUS :VCODEC0_POWER_STATUS )) + goto disable_power; + + value =readl (core->reg_base +WRAPPER_CORE_CLOCK_CONFIG );
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu35_power_off_hw(struct iris_core *core) · line 240
Quoted 7 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +7
-0+if (value) +writel (CORE_CLK_RUN , core->reg_base +WRAPPER_CORE_CLOCK_CONFIG ); + +for (i =0 ; i < core->iris_platform_data->num_vpp_pipe; i++) { + ret =readl_poll_timeout (core->reg_base + (core_id ?VCODEC1_SS_IDLE_STATUSN : +VCODEC_SS_IDLE_STATUSN ) +4 * i, value, + value &DMA_NOC_IDLE ,2000 ,20000 );Unreadable. Extract register addresses to separate variables.
Ack
Quoted 23 lines
Quoted 23 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +23
-0+if (ret) + goto disable_power; + } + +writel (core_id ?REQ_VCODEC1_POWER_DOWN_PREP :REQ_POWER_DOWN_PREP , + core->reg_base +AON_WRAPPER_MVP_NOC_LPI_CONTROL ); + ret =readl_poll_timeout (core->reg_base +AON_WRAPPER_MVP_NOC_LPI_STATUS , value, + value & (core_id ?NOC_LPI_VCODEC1_STATUS_DONE : +NOC_LPI_STATUS_DONE ),2000 ,20000 ); +if (ret) + goto disable_power; + +writel (0 , core->reg_base +AON_WRAPPER_MVP_NOC_LPI_CONTROL ); + +writel ((core_id ?VCODEC1_BRIDGE_SW_RESET |VCODEC1_BRIDGE_HW_RESET_DISABLE : +CORE_BRIDGE_SW_RESET |CORE_BRIDGE_HW_RESET_DISABLE ), + core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +writel (core_id ?VCODEC1_BRIDGE_HW_RESET_DISABLE :CORE_BRIDGE_HW_RESET_DISABLE , + core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +writel (0x0 , core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); + +disable_power: +dev_pm_genpd_set_hwmode (core->vcodec[core_id].dev, false);
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu35_power_off_hw(struct iris_core *core) · line 269
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +6
-0+iris_disable_power_domain_and_clocks (core, &core->vcodec[core_id]); +} + +static void iris_vpu36_power_off_hw (struct iris_core *core) +{ +u32 num_cores =max (core->iris_platform_data->num_cores,1 );Can we trust the patch authors that VPU3.6 hardware data will have at least 1 core?
On Glymur (VPU3.6), num_cores is 2. The max() guard is unnecessary. Will access num_cores directly.
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu35_power_off_hw(struct iris_core *core)
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +6
-0+int i; + +for (i =0 ; i < num_cores; i++) +iris_vpu36_power_off_vcodec (core, i); +} +#define WRAPPER_DEBUG_BRIDGE_LPI_STATUS (WRAPPER_BASE_OFFS + 0x58)#define WRAPPER_IRIS_CPU_NOC_LPI_CONTROL (WRAPPER_BASE_OFFS + 0x5C)Lowercase hex.
Ack
Quoted 3 lines
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +1
-0#define REQ_POWER_DOWN_PREP BIT(0) +#define REQ_VCODEC1_POWER_DOWN_PREP BIT(1)
Re: [PATCH v7 07/12] media: iris: Add power sequence for glymur
Quoted 131 lines · Vishnu Reddy
Quoted 77 lines · Dmitry Baryshkov
Quoted 76 lines · Vishnu Reddy
Glymur platform has two video codec cores: vcodec0 and vcodec1.
Both cores share a common clock source (
video_cc_mvs0_clk_src) and the same power rails. The clock dividers between the source and the branch clocks are fixed. So when both cores are running, the source clock always runs at the highest frequency requested by either core.Since both cores share the same power rails, the power corner cannot be voted independently. Scaling one core's power corner up or down would directly affect the other, leading to under or over-voting.
For these reasons, both cores should voted the clock and power rail must be based on the workload of both cores.
Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Vishnu Reddy <[email protected]>--- drivers/media/platform/qcom/iris/iris_vpu3x.c | 111 ++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_vpu_common.h | 1 + .../platform/qcom/iris/iris_vpu_register_defines.h | 10 ++ 3 files changed, 117 insertions(+), 5 deletions(-)drivers/media/platform/qcom/iris/iris_vpu3x.c +15
-5@@ -17,14 +17,14 @@#define NOC_HALT BIT(0)#define AON_WRAPPER_SPARE (AON_BASE_OFFS + 0x28) -static bool iris_vpu3x_hw_power_collapsed (struct iris_core *core) +static bool iris_vpu3x_hw_power_collapsed (struct iris_core *core,u32 pwr_status_bit) {u32 value, pwr_status; value =readl (core->reg_base +WRAPPER_CORE_POWER_STATUS ); - pwr_status = value &BIT (1 ); + pwr_status = value & pwr_status_bit; -return pwr_status ? false : true; +return !pwr_status; }static void iris_vpu3_power_off_hardware (struct iris_core *core)@@ -32,7 +32,7 @@ static void iris_vpu3_power_off_hardware(struct iris_core *core)u32 reg_val =0 , value, i;int ret; -if (iris_vpu3x_hw_power_collapsed (core)) +if (iris_vpu3x_hw_power_collapsed (core,VCODEC0_POWER_STATUS )) goto disable_power;dev_err (core->dev,"video hw is power on\n" );@@ -78,7 +78,7 @@ static void iris_vpu33_power_off_hardware(struct iris_core *core)u32 count =0 ;int ret; -if (iris_vpu3x_hw_power_collapsed (core)) +if (iris_vpu3x_hw_power_collapsed (core,VCODEC0_POWER_STATUS )) goto disable_power;dev_err (core->dev,"video hw is power on\n" );@@ -221,6 +221,98 @@ static void iris_vpu35_power_off_hw(struct iris_core *core)iris_vpu33_power_off_hardware (core); } +static void iris_vpu36_power_off_vcodec (struct iris_core *core,u32 core_id) +{ +u32 value, i; +int ret; + +if (iris_vpu3x_hw_power_collapsed (core, + core_id ?VCODEC1_POWER_STATUS :VCODEC0_POWER_STATUS )) + goto disable_power; + + value =readl (core->reg_base +WRAPPER_CORE_CLOCK_CONFIG );Quoted 8 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu35_power_off_hw(struct iris_core *core) · line 240
Quoted 7 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +7
-0+if (value) +writel (CORE_CLK_RUN , core->reg_base +WRAPPER_CORE_CLOCK_CONFIG ); + +for (i =0 ; i < core->iris_platform_data->num_vpp_pipe; i++) { + ret =readl_poll_timeout (core->reg_base + (core_id ?VCODEC1_SS_IDLE_STATUSN : +VCODEC_SS_IDLE_STATUSN ) +4 * i, value, + value &DMA_NOC_IDLE ,2000 ,20000 );Unreadable. Extract register addresses to separate variables.
Ack
Quoted 23 lines
Quoted 23 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +23
-0+if (ret) + goto disable_power; + } + +writel (core_id ?REQ_VCODEC1_POWER_DOWN_PREP :REQ_POWER_DOWN_PREP , + core->reg_base +AON_WRAPPER_MVP_NOC_LPI_CONTROL ); + ret =readl_poll_timeout (core->reg_base +AON_WRAPPER_MVP_NOC_LPI_STATUS , value, + value & (core_id ?NOC_LPI_VCODEC1_STATUS_DONE : +NOC_LPI_STATUS_DONE ),2000 ,20000 ); +if (ret) + goto disable_power; + +writel (0 , core->reg_base +AON_WRAPPER_MVP_NOC_LPI_CONTROL ); + +writel ((core_id ?VCODEC1_BRIDGE_SW_RESET |VCODEC1_BRIDGE_HW_RESET_DISABLE : +CORE_BRIDGE_SW_RESET |CORE_BRIDGE_HW_RESET_DISABLE ), + core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +writel (core_id ?VCODEC1_BRIDGE_HW_RESET_DISABLE :CORE_BRIDGE_HW_RESET_DISABLE , + core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +writel (0x0 , core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); + +disable_power: +dev_pm_genpd_set_hwmode (core->vcodec[core_id].dev, false);Quoted 8 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu35_power_off_hw(struct iris_core *core) · line 269
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +6
-0+iris_disable_power_domain_and_clocks (core, &core->vcodec[core_id]); +} + +static void iris_vpu36_power_off_hw (struct iris_core *core) +{ +u32 num_cores =max (core->iris_platform_data->num_cores,1 );Can we trust the patch authors that VPU3.6 hardware data will have at least 1 core?
On Glymur (VPU3.6),
num_coresis 2. Themax()guard is unnecessary. Will accessnum_coresdirectly.Quoted 9 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu35_power_off_hw(struct iris_core *core)
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +6
-0+int i; + +for (i =0 ; i < num_cores; i++) +iris_vpu36_power_off_vcodec (core, i); +} +#define WRAPPER_DEBUG_BRIDGE_LPI_STATUS (WRAPPER_BASE_OFFS + 0x58)#define WRAPPER_IRIS_CPU_NOC_LPI_CONTROL (WRAPPER_BASE_OFFS + 0x5C)Lowercase hex.
Quoted 1 line
Ack
Just now I found that this change is not part of this series. Can I take this into separate post?
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +1
-0#define REQ_POWER_DOWN_PREP BIT(0) +#define REQ_VCODEC1_POWER_DOWN_PREP BIT(1)
PATCH v7 8/12 media: iris: Handle CPU_CS_SCIACMDARG3 register write via program bootup registers hook
In reply to Vishnu ReddyOn the Glymur platform, the firmware reads CPU_CS_SCIACMDARG3 during boot to determine the VM count and increments it by 1. Writing the default 0x1 causes the firmware to treat the VM count as 2. To avoid that write 0x0 to CPU_CS_SCIACMDARG3 as a Glymur platform specific.
--- drivers/media/platform/qcom/iris/iris_vpu3x.c | 6 ++++++ drivers/media/platform/qcom/iris/iris_vpu_common.c | 4 ++-- drivers/media/platform/qcom/iris/iris_vpu_register_defines.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_vpu3x.c +6 -0
@@ -313,6 +313,11 @@ static int iris_vpu36_set_hwmode(struct iris_core *core)return ret; } +static void iris_vpu36_program_bootup_registers (struct iris_core *core) +{ +writel (0x0 , core->reg_base +CPU_CS_SCIACMDARG3 ); +} +const struct vpu_ops iris_vpu3_ops = { .power_off_hw = iris_vpu3_power_off_hardware, .power_on_hw = iris_vpu_power_on_hw,
@@ -346,6 +351,7 @@ const struct vpu_ops iris_vpu36_ops = { .power_on_hw = iris_vpu36_power_on_hw, .power_off_controller = iris_vpu35_vpu4x_power_off_controller, .power_on_controller = iris_vpu35_vpu4x_power_on_controller, + .program_bootup_registers = iris_vpu36_program_bootup_registers, .calc_freq = iris_vpu3x_vpu4x_calculate_frequency, .set_hwmode = iris_vpu36_set_hwmode, };
drivers/media/platform/qcom/iris/iris_vpu_common.c +2 -2
@@ -26,7 +26,6 @@#define QTBL_ENABLE BIT(0)#define QTBL_ADDR (CPU_CS_BASE_OFFS + 0x54) -#define CPU_CS_SCIACMDARG3 (CPU_CS_BASE_OFFS + 0x58)#define SFR_ADDR (CPU_CS_BASE_OFFS + 0x5C)#define UC_REGION_ADDR (CPU_CS_BASE_OFFS + 0x64)#define UC_REGION_SIZE (CPU_CS_BASE_OFFS + 0x68)
@@ -67,6 +66,8 @@ static void iris_vpu_setup_ucregion_memory_map(struct iris_core *core)writel (value, core->reg_base +SFR_ADDR ); } +writel (0x1 , core->reg_base +CPU_CS_SCIACMDARG3 ); +if (vpu_ops->program_bootup_registers) vpu_ops->program_bootup_registers (core); }
@@ -78,7 +79,6 @@ int iris_vpu_boot_firmware(struct iris_core *core)iris_vpu_setup_ucregion_memory_map (core);writel (ctrl_init, core->reg_base +CTRL_INIT ); -writel (0x1 , core->reg_base +CPU_CS_SCIACMDARG3 );while (!ctrl_status && count < max_tries) { ctrl_status =readl (core->reg_base +CTRL_STATUS );
drivers/media/platform/qcom/iris/iris_vpu_register_defines.h +1 -0
@@ -29,6 +29,7 @@#define CPU_CS_A2HSOFTINTCLR (CPU_CS_BASE_OFFS + 0x1C)#define CLEAR_XTENSA2HOST_INTR BIT(0) +#define CPU_CS_SCIACMDARG3 (CPU_CS_BASE_OFFS + 0x58)#define CPU_CS_H2XSOFTINTEN (CPU_CS_BASE_OFFS + 0x148)#define HOST2XTENSA_INTR_ENABLE BIT(0)
Signature · 1 line
2.34.1
Re: [PATCH v7 08/12] media: iris: Handle CPU_CS_SCIACMDARG3 register write via program bootup registers hook
Quoted 5 lines · Vishnu Reddy
On the Glymur platform, the firmware reads
CPU_CS_SCIACMDARG3during boot to determine the VM count and increments it by 1. Writing the default0x1causes the firmware to treat the VM count as 2. To avoid that write0x0toCPU_CS_SCIACMDARG3as a Glymur platform specific.
Quoted 7 lines
Signed-off-by Vishnu Reddy <[email protected]>--- drivers/media/platform/qcom/iris/iris_vpu3x.c | 6 ++++++ drivers/media/platform/qcom/iris/iris_vpu_common.c | 4 ++-- drivers/media/platform/qcom/iris/iris_vpu_register_defines.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH v7 9/12 media: iris: Add support to select core for dual core platforms
In reply to Vishnu ReddyOn platforms with two video codec cores, select the hardware core for a new session based on the current Macroblocks Per Frame (MBPF) and Macroblocks Per Second (MBPS) load on each core. The selected core is communicated to the firmware via the HFI_PROP_CORE_ID property at stream-on time.
Since both cores share the same clock source, the required clock frequency is the maximum of the aggregated frequencies across both cores.
The total session count limit is scaled by the number of cores, since each core independently supports sessions up to its own limit.
--- drivers/media/platform/qcom/iris/iris_common.c | 10 ++++ drivers/media/platform/qcom/iris/iris_common.h | 1 + drivers/media/platform/qcom/iris/iris_core.h | 5 ++ drivers/media/platform/qcom/iris/iris_hfi_common.h | 1 + .../platform/qcom/iris/iris_hfi_gen2_command.c | 19 +++++++ .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + drivers/media/platform/qcom/iris/iris_instance.h | 2 + drivers/media/platform/qcom/iris/iris_power.c | 20 +++++-- drivers/media/platform/qcom/iris/iris_utils.c | 58 +++++++++++++------- drivers/media/platform/qcom/iris/iris_utils.h | 3 +- drivers/media/platform/qcom/iris/iris_vb2.c | 4 ++ drivers/media/platform/qcom/iris/iris_vidc.c | 6 ++- drivers/media/platform/qcom/iris/iris_vpu3x.c | 63 ++++++++++++++++++++++ drivers/media/platform/qcom/iris/iris_vpu_common.h | 2 + 14 files changed, 171 insertions(+), 24 deletions(-)
drivers/media/platform/qcom/iris/iris_common.c +10 -0
@@ -46,6 +46,16 @@ void iris_set_ts_metadata(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf) inst->metadata_idx++; } +int iris_set_core_id (struct iris_inst *inst) +{ +const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops; + +if (!inst->core_id) +return 0 ; + +return hfi_ops->session_set_core_id (inst, inst->core_id); +} +int iris_process_streamon_input (struct iris_inst *inst) {const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops;
drivers/media/platform/qcom/iris/iris_common.h +1 -0
@@ -11,6 +11,7 @@ struct iris_buffer;int iris_vb2_buffer_to_driver (struct vb2_buffer *vb2,struct iris_buffer *buf);void iris_set_ts_metadata (struct iris_inst *inst,struct vb2_v4l2_buffer *vbuf); +int iris_set_core_id (struct iris_inst *inst);int iris_process_streamon_input (struct iris_inst *inst);int iris_process_streamon_output (struct iris_inst *inst);int iris_session_streamoff (struct iris_inst *inst,u32 plane);
drivers/media/platform/qcom/iris/iris_core.h +5 -0
@@ -36,6 +36,11 @@ enum domain_type { DECODER = BIT(1), }; +enum iris_vcodec_core_id { +IRIS_VCODEC0 =1 , +IRIS_VCODEC1 , +}; +struct qcom_ubwc_cfg_data ;/**
drivers/media/platform/qcom/iris/iris_hfi_common.h +1 -0
@@ -131,6 +131,7 @@ struct iris_hfi_session_ops {int (*session_drain)(struct iris_inst *inst,u32 plane);int (*session_resume_drain)(struct iris_inst *inst,u32 plane);int (*session_close)(struct iris_inst *inst); +int (*session_set_core_id)(struct iris_inst *inst,u32 core_id); };struct hfi_subscription_params {
drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +19 -0
@@ -1291,6 +1291,24 @@ static int iris_hfi_gen2_session_release_buffer(struct iris_inst *inst, struct i inst_hfi_gen2->packet->size); } +static int iris_hfi_gen2_set_core_id (struct iris_inst *inst,u32 core_id) +{ +struct iris_inst_hfi_gen2 *inst_hfi_gen2 =to_iris_inst_hfi_gen2 (inst); +u32 payload = core_id; + +iris_hfi_gen2_packet_session_command (inst, +HFI_PROP_CORE_ID , +HFI_HOST_FLAGS_NONE , +HFI_PORT_NONE , + inst->session_id, +HFI_PAYLOAD_U32 , + &payload, +sizeof (u32)); + +return iris_hfi_queue_cmd_write (inst->core, inst_hfi_gen2->packet, + inst_hfi_gen2->packet->size); +} +static const struct iris_hfi_session_ops iris_hfi_gen2_session_ops = { .session_open = iris_hfi_gen2_session_open, .session_set_config_params = iris_hfi_gen2_session_set_config_params,
@@ -1304,6 +1322,7 @@ static const struct iris_hfi_session_ops iris_hfi_gen2_session_ops = { .session_drain = iris_hfi_gen2_session_drain, .session_resume_drain = iris_hfi_gen2_session_resume_drain, .session_close = iris_hfi_gen2_session_close, + .session_set_core_id = iris_hfi_gen2_set_core_id, };static struct iris_inst *iris_hfi_gen2_get_instance (void )
drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +1 -0
@@ -56,6 +56,7 @@#define HFI_PROP_BUFFER_HOST_MAX_COUNT 0x03000123#define HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT 0x03000124#define HFI_PROP_PIC_ORDER_CNT_TYPE 0x03000128 +#define HFI_PROP_CORE_ID 0x030001a9enum hfi_rate_control {HFI_RC_VBR_CFR =0x00000000 ,
drivers/media/platform/qcom/iris/iris_instance.h +2 -0
@@ -34,6 +34,7 @@ enum iris_fmt_type_cap {* * @list: used for attach an instance to the core * @core: pointer to core structure +* @core_id: specifies the hardware core on which the session runs * @session_id: id of current video session * @hfi_session_ops: iris HFI session ops * @ctx_q_lock: lock to serialize queues related ioctls
@@ -81,6 +82,7 @@ enum iris_fmt_type_cap {struct iris_inst {struct list_head list;struct iris_core *core; +u32 core_id;u32 session_id;const struct iris_hfi_session_ops *hfi_session_ops;struct mutex ctx_q_lock;/* lock to serialize queues related ioctls */
drivers/media/platform/qcom/iris/iris_power.c +17 -3
@@ -75,14 +75,12 @@ static int iris_vote_interconnects(struct iris_inst *inst)return iris_set_interconnects (inst); } -static int iris_set_clocks (struct iris_inst *inst) +static u64 iris_get_required_freq (struct iris_inst *inst) {struct iris_core *core = inst->core;struct iris_inst *instance;u64 freq =0 ; -int ret; -mutex_lock (&core->lock);list_for_each_entry (instance, &core->instances, list) {if (!instance->max_input_data_size)continue ;
@@ -90,6 +88,22 @@ static int iris_set_clocks(struct iris_inst *inst) freq += instance->power.min_freq; } +return freq; +} + +static int iris_set_clocks (struct iris_inst *inst) +{ +const struct vpu_ops *vpu_ops = inst->core->iris_platform_data->vpu_ops; +struct iris_core *core = inst->core; +u64 freq; +int ret; + +mutex_lock (&core->lock); +if (vpu_ops->get_required_freq) + freq = vpu_ops->get_required_freq (inst); +else + freq =iris_get_required_freq (inst); + core->power.clk_freq = freq; ret =iris_opp_set_rate (core->dev, freq);mutex_unlock (&core->lock);
drivers/media/platform/qcom/iris/iris_utils.c +39 -19
98 lines not on this page · raw message
drivers/media/platform/qcom/iris/iris_utils.h +2 -1
@@ -43,7 +43,8 @@ static inline enum iris_buffer_type iris_v4l2_type_to_driver(u32 type)bool iris_res_is_less_than (u32 width,u32 height,u32 ref_width,u32 ref_height); -int iris_get_mbpf (struct iris_inst *inst); +u32 iris_get_mbpf (struct iris_inst *inst); +u32 iris_get_mbps (struct iris_inst *inst);bool iris_split_mode_enabled (struct iris_inst *inst);struct iris_inst *iris_get_instance (struct iris_core *core,u32 session_id); void iris_helper_buffers_done(struct iris_inst *inst, unsigned int type,
drivers/media/platform/qcom/iris/iris_vb2.c +4 -0
@@ -176,6 +176,10 @@ int iris_vb2_start_streaming(struct vb2_queue *q, unsigned int count)if (ret) goto error; + ret =iris_set_core_id (inst); +if (ret) + goto error; +if (V4L2_TYPE_IS_OUTPUT (q->type)) {if (inst->domain ==DECODER ) ret =iris_vdec_streamon_input (inst);
drivers/media/platform/qcom/iris/iris_vidc.c +5 -1
@@ -41,16 +41,20 @@ static void iris_v4l2_fh_deinit(struct iris_inst *inst, struct file *filp)static void iris_add_session (struct iris_inst *inst) { +const struct iris_platform_data *plat = inst->core->iris_platform_data; +u32 max_session_count = plat->max_session_count;struct iris_core *core = inst->core;struct iris_inst *iter;u32 count =0 ; + max_session_count *=max (plat->num_cores,1 ); +mutex_lock (&core->lock);list_for_each_entry (iter, &core->instances, list) count++; -if (count < core->iris_platform_data->max_session_count) +if (count < max_session_count)list_add_tail (&inst->list, &core->instances);mutex_unlock (&core->lock);
drivers/media/platform/qcom/iris/iris_vpu3x.c +63 -0
73 lines not on this page · raw message
drivers/media/platform/qcom/iris/iris_vpu_common.h +2 -0
@@ -25,6 +25,8 @@ struct vpu_ops {int (*set_hwmode)(struct iris_core *core);int (*init_cb_devs)(struct iris_core *core);void (*deinit_cb_devs)(struct iris_core *core); +int (*check_core_load)(struct iris_inst *inst,bool mbpf); +u64 (*get_required_freq)(struct iris_inst *inst); };int iris_vpu_boot_firmware (struct iris_core *core);
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v7 09/12] media: iris: Add support to select core for dual core platforms
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Dynamic core assignment logic mutates `inst->core_id` during streaming without firmware…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Dynamic core assignment logic mutates inst->core_id during streaming without firmware notification and without holding inst->lock.
- [Medium] Initial core assignment bypasses MBPS constraints.
--
commit 2b81abf719d22ec30cd3764b2bba16be2af15168
Author: Vishnu Reddy <[email protected]>
media: iris: Add support to select core for dual core platforms
On platforms with two video codec cores, select the hardware core for a new session based on the current Macroblocks Per Frame (MBPF) and Macroblocks Per Second (MBPS) load on each core. The selected core is communicated to the firmware via the HFI_PROP_CORE_ID property at stream-on time.
drivers/media/platform/qcom/iris/iris_vb2.c int iris_vb2_start_streaming(struct vb2_queue *q, unsigned int count) · line 179
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_vb2.c +1
-0@@ -176,6 +176,10 @@ int iris_vb2_start_streaming(struct vb2_queue *q, unsigned int count)if (ret) goto error; + ret =iris_set_core_id (inst);
[Severity: Medium]
Since this initial core assignment is driven by iris_check_session_supported() called just before this, does that function need to check both MBPF and MBPS limits?
Currently, iris_check_session_supported() only calls iris_check_core_mbpf() to verify Macroblocks Per Frame limits. The complementary MBPS constraint check via iris_check_core_mbps() appears to be entirely omitted.
Could this allow a session to be successfully assigned to a core that meets the MBPF limit but vastly exceeds its maximum processing capability (MBPS)?
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vb2.c +3
-0+if (ret) + goto error; +if (V4L2_TYPE_IS_OUTPUT (q->type)) {if (inst->domain ==DECODER ) ret =iris_vdec_streamon_input (inst);
[ ... ]
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +2
-0@@ -318,6 +318,67 @@ static void iris_vpu36_program_bootup_registers(struct iris_core *core)writel (0x0 , core->reg_base +CPU_CS_SCIACMDARG3 ); } +static int iris_vpu36_check_core_load (struct iris_inst *inst,bool mbpf) +{
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu36_program_bootup_registers(struct iris_core *core) · line 332
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +10
-0+const struct iris_platform_data *platform_data = inst->core->iris_platform_data; +u32 max_load = mbpf ? platform_data->max_core_mbpf : platform_data->max_core_mbps; +u32 max_session_cnt = platform_data->max_session_count; +u32 core0_session_cnt =0 , core1_session_cnt =0 ; +u32 core0_load =0 , core1_load =0 ; +bool select_core0, select_core1; +struct iris_inst *instance; +u32 load, new_load; + + inst->core_id =0 ;
[Severity: High]
Is it safe to mutate inst->core_id here during active streaming without holding inst->lock?
This function can be reached mid-stream if a concurrent s_parm call triggers iris_venc_s_param() -> iris_check_core_mbpf(). Since iris_venc_s_param() executes without holding inst->lock, a concurrent call can clear inst->core_id to 0 right before iris_set_core_id() reads it during iris_vb2_start_streaming().
Additionally, altering inst->core_id mid-stream without notifying the firmware (which only receives HFI_PROP_CORE_ID at stream-on) permanently desynchronizes the driver from the firmware.
This could cause iris_vpu36_get_required_freq() to incorrectly shift the session's power votes to the new core while the firmware continues executing on the old core, potentially leading to hardware underclocking and system hangs.
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +3
-0+ +list_for_each_entry (instance, &inst->core->instances, list) { + load = mbpf ?iris_get_mbpf (instance) :iris_get_mbps (instance);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
Re: [PATCH v7 09/12] media: iris: Add support to select core for dual core platforms
Quoted 4 lines · On Wed, Jun 03, 2026 at 02:44:34PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Dynamic core assignment logic mutatesinst->core_idduring streaming without firmware notification and without holdinginst->lock.
- [Medium] Initial core assignment bypasses MBPS constraints.
--
Vishnu, I'd expect at least some reaction to the reviews. It doesn't matter if it was performed by the person or by the AI.
Quoted 12 lines
commit
2b81abf719d22ec30cd3764b2bba16be2af15168
Author: Vishnu Reddy <[email protected]>media: iris: Add support to select core for dual core platforms
On platforms with two video codec cores, select the hardware core for a new session based on the current Macroblocks Per Frame (MBPF) and Macroblocks Per Second (MBPS) load on each core. The selected core is communicated to the firmware via the
HFI_PROP_CORE_IDproperty at stream-on time.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v7 09/12] media: iris: Add support to select core for dual core platforms
In reply to [email protected]Quoted 30 lines · On 6/3/2026 8:14 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Dynamic core assignment logic mutatesinst->core_idduring streaming without firmware notification and without holdinginst->lock.
- [Medium] Initial core assignment bypasses MBPS constraints.
--commit
2b81abf719d22ec30cd3764b2bba16be2af15168
Author: Vishnu Reddy <[email protected]>media: iris: Add support to select core for dual core platforms
On platforms with two video codec cores, select the hardware core for a new session based on the current Macroblocks Per Frame (MBPF) and Macroblocks Per Second (MBPS) load on each core. The selected core is communicated to the firmware via the
HFI_PROP_CORE_IDproperty at stream-on time.drivers/media/platform/qcom/iris/iris_vb2.c int iris_vb2_start_streaming(struct vb2_queue *q, unsigned int count) · line 179
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_vb2.c +1
-0@@ -176,6 +176,10 @@ int iris_vb2_start_streaming(struct vb2_queue *q, unsigned int count)if (ret) goto error; + ret =iris_set_core_id (inst);[Severity: Medium]
Since this initial core assignment is driven byiris_check_session_supported()called just before this, does that function need to check both MBPF and MBPS limits?
Quoted 6 lines
Currently,
iris_check_session_supported()only callsiris_check_core_mbpf()to verify Macroblocks Per Frame limits. The complementary MBPS constraint check viairis_check_core_mbps()appears to be entirely omitted.Could this allow a session to be successfully assigned to a core that meets the MBPF limit but vastly exceeds its maximum processing capability (MBPS)?
Decoder doesn't know the FPS at this stage to validate MBPS.
Quoted 16 lines
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_vb2.c +3
-0+if (ret) + goto error; +if (V4L2_TYPE_IS_OUTPUT (q->type)) {if (inst->domain ==DECODER ) ret =iris_vdec_streamon_input (inst);[ ... ]
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +0
-0@@ -318,6 +318,67 @@ static void iris_vpu36_program_bootup_registers(struct iris_core *core)writel (0x0 , core->reg_base +CPU_CS_SCIACMDARG3 ); }
Quoted 15 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c static void iris_vpu36_program_bootup_registers(struct iris_core *core) · line 332
Quoted 12 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +12
-0+static int iris_vpu36_check_core_load (struct iris_inst *inst,bool mbpf) +{ +const struct iris_platform_data *platform_data = inst->core->iris_platform_data; +u32 max_load = mbpf ? platform_data->max_core_mbpf : platform_data->max_core_mbps; +u32 max_session_cnt = platform_data->max_session_count; +u32 core0_session_cnt =0 , core1_session_cnt =0 ; +u32 core0_load =0 , core1_load =0 ; +bool select_core0, select_core1; +struct iris_inst *instance; +u32 load, new_load; + + inst->core_id =0 ;[Severity: High]
Is it safe to mutateinst->core_idhere during active streaming without holdinginst->lock?
core->lock is already acquired before control reaching here, so additional inst->lock not required.
Quoted 17 lines
This function can be reached mid-stream if a concurrent
s_parmcall triggersiris_venc_s_param()->iris_check_core_mbpf(). Sinceiris_venc_s_param()executes without holdinginst->lock, a concurrent call can clearinst->core_idto 0 right beforeiris_set_core_id()reads it duringiris_vb2_start_streaming().Additionally, altering
inst->core_idmid-stream without notifying the firmware (which only receivesHFI_PROP_CORE_IDat stream-on) permanently desynchronizes the driver from the firmware.This could cause
iris_vpu36_get_required_freq()to incorrectly shift the session's power votes to the new core while the firmware continues executing on the old core, potentially leading to hardware underclocking and system hangs.Quoted 3 lines
drivers/media/platform/qcom/iris/iris_vpu3x.c +3
-0+ +list_for_each_entry (instance, &inst->core->instances, list) { + load = mbpf ?iris_get_mbpf (instance) :iris_get_mbps (instance);
PATCH v7 10/12 media: iris: Add platform data for glymur
In reply to Vishnu ReddyOn glymur platform, the iris core shares most properties with the iris core on the SM8550 platform. The major difference is that glymur integrates two codec cores (vcodec0 and vcodec1), while SM8550 has only one. Add glymur specific platform data, reusing SM8550 definitions wherever applicable.
--- drivers/media/platform/qcom/iris/Makefile | 1 + .../platform/qcom/iris/iris_platform_common.h | 5 + .../platform/qcom/iris/iris_platform_glymur.c | 106 +++++++++++++++++++++ .../platform/qcom/iris/iris_platform_glymur.h | 17 ++++ .../media/platform/qcom/iris/iris_platform_vpu3x.c | 35 +++++++ drivers/media/platform/qcom/iris/iris_probe.c | 4 + drivers/media/platform/qcom/iris/iris_vpu3x.c | 3 + 7 files changed, 171 insertions(+)
drivers/media/platform/qcom/iris/Makefile +1 -0
@@ -12,6 +12,7 @@ qcom-iris-objs += iris_buffer.o \ iris_hfi_gen2_packet.o \ iris_hfi_gen2_response.o \ iris_hfi_queue.o \ + iris_platform_glymur.o \ iris_platform_vpu2.o \ iris_platform_vpu3x.o \ iris_power.o \
drivers/media/platform/qcom/iris/iris_platform_common.h +5 -0
@@ -38,6 +38,10 @@ struct iris_inst;#define MAX_HEVC_VBR_LAYER_HP_SLIDING_WINDOW 5#define MAX_HIER_CODING_LAYER_GEN1 6 +#define VIDEO_REGION_SECURE_FW_REGION_ID 0 +#define VIDEO_REGION_VM0_SECURE_NP_ID 1 +#define VIDEO_REGION_VM0_NONSECURE_NP_ID 5 +enum stage_type {STAGE_1 =1 ,STAGE_2 =2 ,
@@ -52,6 +56,7 @@ enum pipe_type {extern const struct iris_firmware_data iris_hfi_gen1_data;extern const struct iris_firmware_data iris_hfi_gen2_data; +extern const struct iris_platform_data glymur_data;extern const struct iris_platform_data qcs8300_data;extern const struct iris_platform_data sc7280_data;extern const struct iris_platform_data sm8250_data;
drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +106 -0
106 lines not on this page · raw message
drivers/media/platform/qcom/iris/iris_platform_glymur.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) Qualcomm Innovation Center, Inc. All rights reserved. +*/ + +#ifndef __IRIS_PLATFORM_GLYMUR_H__ +#define __IRIS_PLATFORM_GLYMUR_H__ + +extern const struct iris_power_domain_data iris_glymur_ctrl_data; +extern const struct iris_power_domain_data iris_glymur_vcodec_data[2 ]; +extern const char *const iris_glymur_clk_reset_table[6 ]; +extern const char *const iris_glymur_opp_clk_table[4 ]; +extern const struct tz_cp_config iris_glymur_tz_cp_config[3 ]; +int iris_glymur_init_cb_devs (struct iris_core *core); +void iris_glymur_deinit_cb_devs (struct iris_core *core); + +#endif /* __IRIS_PLATFORM_GLYMUR_H__ */
drivers/media/platform/qcom/iris/iris_platform_vpu3x.c +35 -0
@@ -12,6 +12,7 @@#include "iris_vpu_buffer.h" #include "iris_vpu_common.h" +#include "iris_platform_glymur.h" #include "iris_platform_qcs8300.h" #include "iris_platform_sm8550.h" #include "iris_platform_sm8650.h"
@@ -48,6 +49,12 @@ static const struct iris_firmware_desc iris_vpu35_p4_gen2_desc = { .fwname = "qcom/vpu/vpu35_p4.mbn", }; +static const struct iris_firmware_desc iris_vpu36_p4_s7_gen2_desc = { + .firmware_data = &iris_hfi_gen2_data, + .get_vpu_buffer_size = iris_vpu_buf_size, + .fwname ="qcom/vpu/vpu36_p4_s7.mbn" , +}; +static const u32 iris_fmts_vpu3x_dec[] = { [IRIS_FMT_H264 ] =V4L2_PIX_FMT_H264 , [IRIS_FMT_HEVC ] =V4L2_PIX_FMT_HEVC ,
@@ -83,6 +90,34 @@ static const struct tz_cp_config tz_cp_config_vpu3[] = { }, }; +const struct iris_platform_data glymur_data = { + .firmware_desc = &iris_vpu36_p4_s7_gen2_desc, + .vpu_ops = &iris_vpu36_ops, + .icc_tbl = iris_icc_info_vpu3x, + .icc_tbl_size =ARRAY_SIZE (iris_icc_info_vpu3x), + .clk_rst_tbl = iris_glymur_clk_reset_table, + .clk_rst_tbl_size =ARRAY_SIZE (iris_glymur_clk_reset_table), + .bw_tbl_dec = iris_bw_table_dec_vpu3x, + .bw_tbl_dec_size =ARRAY_SIZE (iris_bw_table_dec_vpu3x), + .ctrl_data = &iris_glymur_ctrl_data, + .vcodec_data = iris_glymur_vcodec_data, + .opp_pd_tbl = iris_opp_pd_table_vpu3x, + .opp_pd_tbl_size =ARRAY_SIZE (iris_opp_pd_table_vpu3x), + .opp_clk_tbl = iris_glymur_opp_clk_table, +/* Upper bound of DMA address range */ + .dma_mask =0xffe00000 -1 , + .inst_iris_fmts = iris_fmts_vpu3x_dec, + .inst_iris_fmts_size =ARRAY_SIZE (iris_fmts_vpu3x_dec), + .inst_caps = &platform_inst_cap_sm8550, + .tz_cp_config_data = iris_glymur_tz_cp_config, + .tz_cp_config_data_size =ARRAY_SIZE (iris_glymur_tz_cp_config), + .num_vpp_pipe =4 , + .max_session_count =16 , + .num_cores =2 , + .max_core_mbpf =NUM_MBS_8K *2 , + .max_core_mbps = ((8192 *4320 ) /256 ) *60 , +}; +/* * Shares most of SM8550 data except: * - inst_caps to platform_inst_cap_qcs8300
drivers/media/platform/qcom/iris/iris_probe.c +4 -0
@@ -458,6 +458,10 @@ static const struct dev_pm_ops iris_pm_ops = { };static const struct of_device_id iris_dt_match[] = { + { + .compatible ="qcom,glymur-iris" , + .data = &glymur_data, + }, { .compatible ="qcom,qcs8300-iris" , .data = &qcs8300_data,
drivers/media/platform/qcom/iris/iris_vpu3x.c +3 -0
@@ -8,6 +8,7 @@#include <linux/reset.h> #include "iris_instance.h" +#include "iris_platform_glymur.h" #include "iris_vpu_common.h" #include "iris_vpu_register_defines.h"
@@ -415,6 +416,8 @@ const struct vpu_ops iris_vpu36_ops = { .program_bootup_registers = iris_vpu36_program_bootup_registers, .calc_freq = iris_vpu3x_vpu4x_calculate_frequency, .set_hwmode = iris_vpu36_set_hwmode, + .init_cb_devs = iris_glymur_init_cb_devs, + .deinit_cb_devs = iris_glymur_deinit_cb_devs, .check_core_load = iris_vpu36_check_core_load, .get_required_freq = iris_vpu36_get_required_freq, };
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v7 10/12] media: iris: Add platform data for glymur
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Critical] `iris_glymur_deinit_cb_devs()` unregisters and frees `core->fw_dev` but fails to set the…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Critical] iris_glymur_deinit_cb_devs() unregisters and frees core->fw_dev but fails to set the pointer to NULL, leaving a dangling pointer in the core structure.
- [High] The address of a local stack variable (fw_fid) is stored in a permanent device structure field (dev->platform_data), leading to a dangling pointer and Use-After-Free once the initialization function returns.
- [High] Silent cancellation of IOMMU deferred probe leading to improper fallback.
--
commit 22223f505726fa5c0ee432b64a8712aa1e89468b
Author: Vishnu Reddy <[email protected]>
media: iris: Add platform data for glymur
On glymur platform, the iris core shares most properties with the iris core on the SM8550 platform. The major difference is that glymur integrates two codec cores (vcodec0 and vcodec1), while SM8550 has only one. Add glymur specific platform data, reusing SM8550 definitions wherever applicable.
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +0
-0@@ -0,0 +1,106 @@
[ ... ]
drivers/media/platform/qcom/iris/iris_platform_glymur.c line 90
Quoted 7 lines
drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +7
-0+int iris_glymur_init_cb_devs (struct iris_core *core) +{ +u64 dma_mask = core->iris_platform_data->dma_mask; +const u32 fw_fid =IOMMU_FID_IRIS_FIRMWARE ; +struct device *dev; + + dev =iris_vpu_bus_create_device (core->dev,"iris-firmware" , dma_mask, &fw_fid);
[Severity: High]
Is it safe to pass the address of a local stack variable to device creation?
Looking at iris_vpu_bus_create_device(), it assigns the passed pointer directly to dev->platform_data:
iris_vpu_bus_create_device()
...
dev->platform_data = (void *)iommu_fid;Since fw_fid is allocated on the stack in iris_glymur_init_cb_devs(), accessing dev->platform_data after this function returns might lead to a use-after-free.
drivers/media/platform/qcom/iris/iris_platform_glymur.c line 99
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +9
-0+if (IS_ERR (dev)) +return PTR_ERR (dev); + +if (device_iommu_mapped (dev)) + core->fw_dev = dev; +else +device_unregister (dev); + +return 0 ;
[Severity: High]
Is it intentional to return success (0) here when the IOMMU mapping fails?
If device_iommu_mapped(dev) is false, the device is unregistered but the function still returns 0. Without an error being propagated, the firmware loading logic might incorrectly fall back to using core->dev instead of the required secure firmware domain. Could this lead to TrustZone load failures or IOMMU translation faults?
drivers/media/platform/qcom/iris/iris_platform_glymur.c line 105
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +6
-0+} + +void iris_glymur_deinit_cb_devs (struct iris_core *core) +{ +if (core->fw_dev) +device_unregister (core->fw_dev);
[Severity: Critical]
Could this unregistration leave a dangling pointer in core->fw_dev?
Since core->fw_dev is not set to NULL after calling device_unregister(), subsequent initialization attempts might dereference the stale pointer. For example, if a later call to iris_glymur_init_cb_devs() fails to map the IOMMU and returns 0, core->fw_dev would remain unchanged. The core might then proceed to iris_fw_load() and pass the stale pointer to devm_qcom_scm_pas_context_alloc(), causing a use-after-free.
Quoted 1 line
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Re: [PATCH v7 10/12] media: iris: Add platform data for glymur
Quoted 38 lines · On 6/3/2026 8:16 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Critical]iris_glymur_deinit_cb_devs()unregisters and freescore->fw_devbut fails to set the pointer toNULL, leaving a dangling pointer in thecorestructure.
- [High] The address of a local stack variable (fw_fid) is stored in a permanent device structure field (dev->platform_data), leading to a dangling pointer and Use-After-Free once the initialization function returns.
- [High] Silent cancellation of IOMMU deferred probe leading to improper fallback.
--commit
22223f505726fa5c0ee432b64a8712aa1e89468b
Author: Vishnu Reddy <[email protected]>media: iris: Add platform data for glymur
On glymur platform, the iris core shares most properties with the iris core on the SM8550 platform. The major difference is that glymur integrates two codec cores (vcodec0 and vcodec1), while SM8550 has only one. Add glymur specific platform data, reusing SM8550 definitions wherever applicable.
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +0
-0@@ -0,0 +1,106 @@[ ... ]
drivers/media/platform/qcom/iris/iris_platform_glymur.c line 90
Quoted 7 lines
drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +7
-0+int iris_glymur_init_cb_devs (struct iris_core *core) +{ +u64 dma_mask = core->iris_platform_data->dma_mask; +const u32 fw_fid =IOMMU_FID_IRIS_FIRMWARE ; +struct device *dev; + + dev =iris_vpu_bus_create_device (core->dev,"iris-firmware" , dma_mask, &fw_fid);[Severity: High]
Is it safe to pass the address of a local stack variable to device creation?Looking at
iris_vpu_bus_create_device(), it assigns the passed pointer directly todev->platform_data:
Quoted 7 lines
iris_vpu_bus_create_device()... dev->platform_data = (void *)iommu_fid;Since
fw_fidis allocated on the stack iniris_glymur_init_cb_devs(), accessingdev->platform_dataafter this function returns might lead to a use-after-free.
These are sync calls, It won' t create dangling pointer de-reference. Making it to global variable is not required because of one time usage.
Quoted 11 lines
drivers/media/platform/qcom/iris/iris_platform_glymur.c line 99
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +9
-0+if (IS_ERR (dev)) +return PTR_ERR (dev); + +if (device_iommu_mapped (dev)) + core->fw_dev = dev; +else +device_unregister (dev); + +return 0 ;[Severity: High]
Is it intentional to return success (0) here when the IOMMU mapping fails?
Yes, intentional. When Linux runs as KVM managed, the firmware device has a stream ID mapped via the iommu-map property and the IOMMU mapping is handled here. When a hypervisor (Gunyah/QHEE) is present, the iommu-map property is absent and the IOMMU mapping is delegated to the hypervisor. So returning 0 in that case is also a success path, not an error.
Quoted 15 lines
If
device_iommu_mapped(dev)is false, the device is unregistered but the function still returns 0. Without an error being propagated, the firmware loading logic might incorrectly fall back to usingcore->devinstead of the required secure firmware domain. Could this lead to TrustZone load failures or IOMMU translation faults?drivers/media/platform/qcom/iris/iris_platform_glymur.c line 105
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +6
-0+} + +void iris_glymur_deinit_cb_devs (struct iris_core *core) +{ +if (core->fw_dev) +device_unregister (core->fw_dev);[Severity: Critical]
Could this unregistration leave a dangling pointer incore->fw_dev?
Quoted 6 lines
Since
core->fw_devis not set to NULL after callingdevice_unregister(), subsequent initialization attempts might dereference the stale pointer. For example, if a later call toiris_glymur_init_cb_devs()fails to map the IOMMU and returns 0,core->fw_devwould remain unchanged. The core might then proceed toiris_fw_load()and pass the stale pointer todevm_qcom_scm_pas_context_alloc(), causing a use-after-free.
If context bank device creation fails, It will end up into error path and won't reach the iris_fw_load(). And I don't think so that first time iommu SID is mapped success and next time on-wards iommu SID failure case.
Quoted 1 line
Quoted 1 line
+}
Re: [PATCH v7 10/12] media: iris: Add platform data for glymur
In reply to Vishnu ReddyQuoted 8 lines · Vishnu Reddy
On glymur platform, the iris core shares most properties with the iris core on the SM8550 platform. The major difference is that glymur integrates two codec cores (vcodec0 and vcodec1), while SM8550 has only one. Add glymur specific platform data, reusing SM8550 definitions wherever applicable.
Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Vishnu Reddy <[email protected]>
Quoted 10 lines
--- drivers/media/platform/qcom/iris/Makefile | 1 + .../platform/qcom/iris/iris_platform_common.h | 5 + .../platform/qcom/iris/iris_platform_glymur.c | 106 +++++++++++++++++++++ .../platform/qcom/iris/iris_platform_glymur.h | 17 ++++ .../media/platform/qcom/iris/iris_platform_vpu3x.c | 35 +++++++ drivers/media/platform/qcom/iris/iris_probe.c | 4 + drivers/media/platform/qcom/iris/iris_vpu3x.c | 3 + 7 files changed, 171 insertions(+)
Signature · 2 lines
With best wishes Dmitry
PATCH v7 11/12 arm64: dts: qcom: glymur: Add iris video node
In reply to Vishnu ReddyAdd iris video codec to glymur SoC, which comes with significantly different powering up sequence than previous platforms, thus different clocks and resets.
--- arch/arm64/boot/dts/qcom/glymur.dtsi | 118 +++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+)
arch/arm64/boot/dts/qcom/glymur.dtsi +118 -0
@@ -16,6 +16,7 @@ #include <dt-bindings/interconnect/qcom,glymur-rpmh.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/mailbox/qcom-ipcc.h> +#include <dt-bindings/media/qcom,glymur-iris.h> #include <dt-bindings/phy/phy-qcom-qmp.h> #include <dt-bindings/power/qcom,rpmhpd.h> #include <dt-bindings/power/qcom-rpmpd.h>
@@ -4788,6 +4789,123 @@ mdss_dp3_out: endpoint { }; }; + iris: video-codec@aa00000 { + compatible = "qcom,glymur-iris"; + reg = <0x0 0xaa00000 0x0 0xf0000>; + + clocks = <&gcc GCC_VIDEO_AXI0C_CLK>, + <&videocc VIDEO_CC_MVS0C_CLK>, + <&videocc VIDEO_CC_MVS0_CLK>, + <&gcc GCC_VIDEO_AXI0_CLK>, + <&videocc VIDEO_CC_MVS0C_FREERUN_CLK>, + <&videocc VIDEO_CC_MVS0_FREERUN_CLK>, + <&gcc GCC_VIDEO_AXI1_CLK>, + <&videocc VIDEO_CC_MVS1_CLK>, + <&videocc VIDEO_CC_MVS1_FREERUN_CLK>; + clock-names = "core_iface", + "core", + "vcodec0_core", + "vcodec0_iface", + "core_freerun", + "vcodec0_core_freerun", + "vcodec1_iface", + "vcodec1_core", + "vcodec1_core_freerun"; + + dma-coherent; + + interconnects = <&hsc_noc MASTER_APPSS_PROC QCOM_ICC_TAG_ACTIVE_ONLY + &config_noc SLAVE_VENUS_CFG QCOM_ICC_TAG_ACTIVE_ONLY>, + <&mmss_noc MASTER_VIDEO QCOM_ICC_TAG_ALWAYS + &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>; + interconnect-names = "cpu-cfg", + "video-mem"; + + interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>; + + iommus = <&apps_smmu 0x1940 0x0>, + <&apps_smmu 0x1943 0x0>, + <&apps_smmu 0x1944 0x0>, + <&apps_smmu 0x19e0 0x0>; + + iommu-map = <IOMMU_FID_IRIS_FIRMWARE &apps_smmu 0x19e2 0x1>; + + memory-region = <&video_mem>; + + operating-points-v2 = <&iris_opp_table>; + + power-domains = <&videocc VIDEO_CC_MVS0C_GDSC>, + <&videocc VIDEO_CC_MVS0_GDSC>, + <&rpmhpd RPMHPD_MXC>, + <&rpmhpd RPMHPD_MMCX>, + <&videocc VIDEO_CC_MVS1_GDSC>; + power-domain-names = "venus", + "vcodec0", + "mxc", + "mmcx", + "vcodec1"; + + resets = <&gcc GCC_VIDEO_AXI0C_CLK_ARES>, + <&gcc GCC_VIDEO_AXI0_CLK_ARES>, + <&videocc VIDEO_CC_MVS0C_FREERUN_CLK_ARES>, + <&videocc VIDEO_CC_MVS0_FREERUN_CLK_ARES>, + <&gcc GCC_VIDEO_AXI1_CLK_ARES>, + <&videocc VIDEO_CC_MVS1_FREERUN_CLK_ARES>; + reset-names = "core_bus", + "vcodec0_bus", + "core", + "vcodec0_core", + "vcodec1_bus", + "vcodec1_core"; + + /* + * IRIS firmware is signed by vendors, only + * enable on boards where the proper signed firmware + * is available. + */ + status = "disabled"; + + iris_opp_table: opp-table { + compatible = "operating-points-v2"; + + opp-240000000 { + opp-hz = /bits/ 64 <240000000 240000000 360000000>; + required-opps = <&rpmhpd_opp_svs>, + <&rpmhpd_opp_low_svs>; + }; + + opp-338000000 { + opp-hz = /bits/ 64 <338000000 338000000 507000000>; + required-opps = <&rpmhpd_opp_svs>, + <&rpmhpd_opp_svs>; + }; + + opp-366000000 { + opp-hz = /bits/ 64 <366000000 366000000 549000000>; + required-opps = <&rpmhpd_opp_svs_l1>, + <&rpmhpd_opp_svs_l1>; + }; + + opp-444000000 { + opp-hz = /bits/ 64 <444000000 444000000 666000000>; + required-opps = <&rpmhpd_opp_svs_l1>, + <&rpmhpd_opp_nom>; + }; + + opp-533333334 { + opp-hz = /bits/ 64 <533333334 533333334 800000000>; + required-opps = <&rpmhpd_opp_svs_l1>, + <&rpmhpd_opp_turbo>; + }; + + opp-655000000 { + opp-hz = /bits/ 64 <655000000 655000000 982000000>; + required-opps = <&rpmhpd_opp_nom>, + <&rpmhpd_opp_turbo_l1>; + }; + }; + }; + videocc: clock-controller@aaf0000 { compatible = "qcom,glymur-videocc"; reg = <0x0 0x0aaf0000 0x0 0x10000>;
Signature · 1 line
2.34.1
Re: [PATCH v7 11/12] arm64: dts: qcom: glymur: Add iris video node
Quoted 10 lines · Vishnu Reddy
Add iris video codec to glymur SoC, which comes with significantly different powering up sequence than previous platforms, thus different clocks and resets.
Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Vishnu Reddy <[email protected]>--- arch/arm64/boot/dts/qcom/glymur.dtsi | 118 +++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+)
Signature · 2 lines
With best wishes Dmitry
PATCH v7 12/12 arm64: dts: qcom: glymur-crd: Enable iris video codec node
In reply to Vishnu ReddyThe iris hardware block is described in the glymur SoC DTSI, and enabling it here allows the media iris driver to probe and use the video codec functionality.
--- arch/arm64/boot/dts/qcom/glymur-crd.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/qcom/glymur-crd.dts +6 -0
@@ -198,6 +198,12 @@ ptn3222_1: redriver@47 { }; }; +&iris { + firmware-name = "qcom/vpu/vpu36_p4_s7.mbn"; + + status = "okay"; +}; + &mdss { status = "okay"; };
Signature · 1 line
2.34.1
Re: [PATCH v7 12/12] arm64: dts: qcom: glymur-crd: Enable iris video codec node
Quoted 11 lines · Vishnu Reddy
The iris hardware block is described in the glymur SoC DTSI, and enabling it here allows the media iris driver to probe and use the video codec functionality.
Reviewed-by Vikash Garodia <[email protected]>Reviewed-by Dmitry Baryshkov <[email protected]>Signed-off-by Vishnu Reddy <[email protected]>--- arch/arm64/boot/dts/qcom/glymur-crd.dts | 6 ++++++ 1 file changed, 6 insertions(+)
Signature · 2 lines
With best wishes Dmitry
Vikash Garodia
maintainerQuoted 8 lines · Vishnu Reddy
Glymur is a new generation video codec that supports dual hardware cores along with additional power domains and clocks.
This series adds platform specific support in the iris driver to handle the extra cores, power domains, and clock requirements introduced by glymur. Add support for firmware loading through context bank firmware device.
<snip>
Quoted 5 lines
Vikash Garodia (2):
media: iris: Add iris vpu bus support
iommu: Add iris-vpu-bus toiommu_buses
Bryan,
AFAIU, if media maintainer can review and ack these patches, then we can check with iommu maintainers to pick these ?
Regards,
Vikash