Skip to contentSkip to conversation

media: iris: Add support for glymur platform

PATCH Superseded Vishnu Reddy 4 participants 33 messages Apr 23 – Apr 26

Subsystems (12)

v2 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v2 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]: It's a generic fix, media maintainer can pick this independently.

Patch[2-3]: Generalizes existing host1x context bus. Not sure on who applies these patches in drivers/base and drivers/gpu/host1x, kindly suggest.

Patch[4-10] glymur enablement patches, media maintainer can pick these independently.

Patch[11-12] depend on patch[2] and patch[3].

Patch[13] is dependent on the below patch.
https://lore.kernel.org/all/20260410-glymur_mmcc_dt_config_v2-v3-1-acce9d106e72@oss.qualcomm.com/

Note: Patch[3] compile tested. I would kindly request the host1x maintainers to validate their end or to share the validation steps.

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.0.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.0.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 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]

---
Ekansh Gupta (2):
drivers: base: Add generic dma context bus
gpu: host1x: Migrate to generic dma context bus

Mukesh Ojha (1):
media: iris: Enable Secure PAS support with IOMMU managed by Linux

Vishnu Reddy (10):
media: iris: Fix VM count passed to firmware
dt-bindings: media: qcom,glymur-iris: Add glymur video codec
media: iris: Add context bank hooks for platform specific initialization
media: iris: Rename clock and power domain macros to use vcodec prefix
media: iris: Use power domain type to look up pd_devs index
media: iris: Add power sequence for Glymur
media: iris: Add support to select core for dual core platforms
media: iris: Select DMA_CONTEXT_BUS to create firmware device
media: iris: Add platform data for glymur
arm64: dts: qcom: glymur: Add iris video node

 .../bindings/media/qcom,glymur-iris.yaml           | 220 +++++++++++++++++++++
 arch/arm64/boot/dts/qcom/glymur-crd.dts            |   4 +
 arch/arm64/boot/dts/qcom/glymur.dtsi               | 118 +++++++++++
 drivers/base/Kconfig                               |   3 +
 drivers/base/Makefile                              |   1 +
 drivers/base/dma_context_bus.c                     |  77 ++++++++
 drivers/gpu/drm/tegra/uapi.c                       |   2 +-
 drivers/gpu/host1x/Kconfig                         |   5 +-
 drivers/gpu/host1x/Makefile                        |   1 -
 drivers/gpu/host1x/context.c                       |  47 ++---
 drivers/gpu/host1x/context.h                       |   3 +-
 drivers/gpu/host1x/context_bus.c                   |  26 ---
 drivers/iommu/iommu.c                              |   6 +-
 drivers/media/platform/qcom/iris/Kconfig           |   1 +
 drivers/media/platform/qcom/iris/Makefile          |   1 +
 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       |   9 +
 drivers/media/platform/qcom/iris/iris_firmware.c   |  72 ++++++-
 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      |  33 +++-
 .../media/platform/qcom/iris/iris_platform_gen1.c  |  24 ++-
 .../media/platform/qcom/iris/iris_platform_gen2.c  | 129 ++++++++++--
 .../platform/qcom/iris/iris_platform_glymur.c      |  97 +++++++++
 .../platform/qcom/iris/iris_platform_glymur.h      |  17 ++
 .../platform/qcom/iris/iris_platform_sc7280.h      |  10 +-
 .../platform/qcom/iris/iris_platform_sm8750.h      |  12 +-
 drivers/media/platform/qcom/iris/iris_power.c      |  11 +-
 drivers/media/platform/qcom/iris/iris_probe.c      |  31 ++-
 drivers/media/platform/qcom/iris/iris_resources.c  |  44 ++++-
 drivers/media/platform/qcom/iris/iris_resources.h  |   6 +-
 drivers/media/platform/qcom/iris/iris_utils.c      |  87 ++++++--
 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      | 148 ++++++++++++--
 drivers/media/platform/qcom/iris/iris_vpu4x.c      |  68 +++----
 drivers/media/platform/qcom/iris/iris_vpu_common.c |  47 +++--
 drivers/media/platform/qcom/iris/iris_vpu_common.h |   1 +
 .../platform/qcom/iris/iris_vpu_register_defines.h |   7 +
 include/dt-bindings/media/qcom,glymur-iris.h       |  11 ++
 include/linux/dma_context_bus.h                    |  26 +++
 include/linux/host1x.h                             |   2 +-
 include/linux/host1x_context_bus.h                 |  15 --
 46 files changed, 1222 insertions(+), 244 deletions(-)

---
base-commit: 70c8a7ec6715b5fb14e501731b5b9210a16684f7
change-id: 20260409-glymur-140ab7ca0910

Best regards,

Signature · 1 line
Vishnu Reddy <[email protected]>
#1 lore raw

PATCH v2 1/13 media: iris: Fix VM count passed to firmware

On Glymur, firmware interprets the value written to CPU_CS_SCIACMDARG3 as the number of virtual machines (VMs) and internally adds 1 to it. Writing 1 causes firmware to treat it as 2 VMs. Since only one VM is required, remove this write to leave the register at its reset value of 0. This does not affect other platforms as only Glymur firmware uses this register, earlier platform firmwares ignore it.

Fixes abf5bac63f68a ("media: iris: implement the boot sequence of the firmware")
---
 drivers/media/platform/qcom/iris/iris_vpu_common.c | 1 -
 1 file changed, 1 deletion(-)
drivers/media/platform/qcom/iris/iris_vpu_common.c +0 -1
index 548e5f1727fd..bfd1e762c38e 100644
@@ -78,7 +78,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);
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/13 drivers: base: Add generic dma context bus

In reply to Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
drivers/base/Kconfig +3 -0
index f7d385cbd3ba..499ea92dd88f 100644
@@ -4,6 +4,9 @@ menu "Generic Driver Options"
 config AUXILIARY_BUS
 	bool
 
+config DMA_CONTEXT_BUS
+	bool
+
 config UEVENT_HELPER
 	bool "Support for uevent helper"
 	help
drivers/base/Makefile +1 -0
index 8074a10183dc..348e69695e55 100644
@@ -8,6 +8,7 @@ obj-y			:= component.o core.o bus.o dd.o syscore.o \
 			   topology.o container.o property.o cacheinfo.o \
 			   swnode.o faux.o
 obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o
+obj-$(CONFIG_DMA_CONTEXT_BUS) += dma_context_bus.o
 obj-$(CONFIG_DEVTMPFS)	+= devtmpfs.o
 obj-y			+= power/
 obj-$(CONFIG_ISA_BUS_API)	+= isa.o
drivers/base/dma_context_bus.c new file +77 -0

77 lines not on this page · raw message

include/linux/dma_context_bus.h new file +26 -0
new file mode 100644
index 000000000000..3d89594fbce4
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef _LINUX_DMA_CONTEXT_BUS_H
+#define _LINUX_DMA_CONTEXT_BUS_H
+
+#include <linux/device.h>
+
+#ifdef CONFIG_DMA_CONTEXT_BUS
+extern const struct bus_type dma_context_bus_type;
+
+struct device *create_dma_context_bus_device(struct device *parent_device,
+					     struct device_node *of_node,
+					     u64 dma_mask, const u32 *iommu_f_id);
+#else
+static inline struct device *create_dma_context_bus_device(struct device *parent_device,
+							   struct device_node *of_node,
+							   u64 dma_mask, const u32 *iommu_f_id)
+{
+	return NULL;
+}
+#endif
+
+#endif /* _LINUX_DMA_CONTEXT_BUS_H */
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

thanks,

greg k-h

#4 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

https://lore.kernel.org/all/[email protected]/

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

Thanks,
Vishnu Reddy.

Quoted 3 lines

thanks,

greg k-h

#5 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 43 lines · Vishnu Reddy
Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

Quoted 4 lines

https://lore.kernel.org/all/[email protected]/

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Why not make a irus_vpu_bus where you can do what you want?

Quoted 10 lines

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

As there is only one user, just make this your own bus please and do all of the needed bus operations for your devices there (i.e. don't hang an "empty" device off of it.)

thanks,

greg k-h

#6 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 42 lines · Greg Kroah-Hartman
Quoted 41 lines · Vishnu Reddy
Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

Quoted 5 lines
Quoted 4 lines

https://lore.kernel.org/all/[email protected]/

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Why not make a irus_vpu_bus where you can do what you want?

Initially iris_vpu_bus was introduced, and it was made generic based on the discussion,

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 7 lines

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

Quoted 6 lines
Quoted 3 lines

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

As there is only one user, just make this your own bus please and do all of the needed bus operations for your devices there (i.e. don't hang an "empty" device off of it.)

The reasoning behind to make it generic was to have more users - host1x, Iris VPU, QDA on the generic context bus, instead of each of them having their own. Let me know if you suggest to have the iris_vpu_bus.

QDA -
https://lore.kernel.org/all/[email protected]/
Iris VPU -
https://lore.kernel.org/all/[email protected]/

Quoted 3 lines

thanks,

greg k-h

#7 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 46 lines · Vishnu Reddy
Quoted 44 lines · Greg Kroah-Hartman
Quoted 43 lines · Vishnu Reddy
Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Why not make a irus_vpu_bus where you can do what you want?

Initially iris_vpu_bus was introduced, and it was made generic based on the discussion,

https://lore.kernel.org/all/[email protected]/

I don't really see that request here, I see a "make this better and more generic for other busses" but that does not mean "dump it into drivers/bus/ for someone else to maintain" :)

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

Quoted 6 lines
Quoted 3 lines

As there is only one user, just make this your own bus please and do all of the needed bus operations for your devices there (i.e. don't hang an "empty" device off of it.)

The reasoning behind to make it generic was to have more users - host1x, Iris VPU, QDA on the generic context bus, instead of each of them having their own. Let me know if you suggest to have the iris_vpu_bus.

But you did not add such users here, so how would we know this?

And still, I have no idea what this bus really is doing. Is it dynamic? Is it self-describing? Why not just use aux-bus? What is it supposed to be doing and used for?

still totally confused,

greg k-h

#8 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 70 lines · Greg Kroah-Hartman
Quoted 45 lines · Vishnu Reddy
Quoted 44 lines · Greg Kroah-Hartman
Quoted 43 lines · Vishnu Reddy
Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Why not make a irus_vpu_bus where you can do what you want?

Initially iris_vpu_bus was introduced, and it was made generic based on the discussion,

https://lore.kernel.org/all/[email protected]/

I don't really see that request here, I see a "make this better and more generic for other busses" but that does not mean "dump it into drivers/bus/ for someone else to maintain" :)

Quoted 13 lines
Quoted 13 lines
Quoted 10 lines

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

As there is only one user, just make this your own bus please and do all of the needed bus operations for your devices there (i.e. don't hang an "empty" device off of it.)

Quoted 8 lines
Quoted 3 lines

The reasoning behind to make it generic was to have more users - host1x, Iris VPU, QDA on the generic context bus, instead of each of them having their own. Let me know if you suggest to have the iris_vpu_bus.

But you did not add such users here, so how would we know this?

And still, I have no idea what this bus really is doing. Is it dynamic? Is it self-describing? Why not just use aux-bus? What is it supposed to be doing and used for?

This bus will allow users to create a dynamic device and map to IOMMU stream ID via .dma_configure callback which calls the of_dma_confgure_id() based on the user inputs. This bus is under the iommu_buses list to register for bus notifier callbacks for iommu_probe_device() and iommu_release_device() during add and remove.

auxilary bus don't have the .dma_callback and bus notifier callbacks where it can do iommu_probe_device() and iommu_release_device(). iommu_release_device(), being a static api, need to be called from bus notifier callbacks which should be under the list of iommu_buses.

Quoted 4 lines

still totally confused,

greg k-h

#9 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 81 lines · Vishnu Reddy
Quoted 70 lines · Greg Kroah-Hartman
Quoted 45 lines · Vishnu Reddy
Quoted 44 lines · Greg Kroah-Hartman
Quoted 43 lines · Vishnu Reddy
Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Why not make a irus_vpu_bus where you can do what you want?

Initially iris_vpu_bus was introduced, and it was made generic based on the discussion,

https://lore.kernel.org/all/[email protected]/

I don't really see that request here, I see a "make this better and more generic for other busses" but that does not mean "dump it into drivers/bus/ for someone else to maintain" :)

Quoted 13 lines
Quoted 13 lines
Quoted 10 lines

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

As there is only one user, just make this your own bus please and do all of the needed bus operations for your devices there (i.e. don't hang an "empty" device off of it.)

Quoted 8 lines
Quoted 3 lines

The reasoning behind to make it generic was to have more users - host1x, Iris VPU, QDA on the generic context bus, instead of each of them having their own. Let me know if you suggest to have the iris_vpu_bus.

But you did not add such users here, so how would we know this?

And still, I have no idea what this bus really is doing. Is it dynamic? Is it self-describing? Why not just use aux-bus? What is it supposed to be doing and used for?

Quoted 5 lines

This bus will allow users to create a dynamic device and map to IOMMU stream ID via .dma_configure callback which calls the of_dma_confgure_id() based on the user inputs. This bus is under the iommu_buses list to register for bus notifier callbacks for iommu_probe_device() and iommu_release_device() during add and remove.

But a device is nothing on its own. You can not just have a random 'struct device' hanging out there that does nothing but iommu, right? It should be doing something else that is very "bus" specific.

Again, why not create a bus for your hardware type and have that control the bindings of drivers to the devices, like it should be done. You better not be creating platform devices for these things :)

Quoted 4 lines

auxilary bus don't have the .dma_callback and bus notifier callbacks where it can do iommu_probe_device() and iommu_release_device(). iommu_release_device(), being a static api, need to be called from bus notifier callbacks which should be under the list of iommu_buses.

True, because aux bus devices don't do that directly, they are "sharing" resources with their parent device and something has to mediate for it. So yes, you are right, that is not a good idea. Make a custom bus type instead please.

thanks,

greg k-h

#10 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 88 lines · Greg Kroah-Hartman
Quoted 81 lines · Vishnu Reddy
Quoted 70 lines · Greg Kroah-Hartman
Quoted 45 lines · Vishnu Reddy
Quoted 44 lines · Greg Kroah-Hartman
Quoted 43 lines · Vishnu Reddy
Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Why not make a irus_vpu_bus where you can do what you want?

Initially iris_vpu_bus was introduced, and it was made generic based on the discussion,

https://lore.kernel.org/all/[email protected]/

I don't really see that request here, I see a "make this better and more generic for other busses" but that does not mean "dump it into drivers/bus/ for someone else to maintain" :)

Quoted 13 lines
Quoted 13 lines
Quoted 10 lines

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

As there is only one user, just make this your own bus please and do all of the needed bus operations for your devices there (i.e. don't hang an "empty" device off of it.)

Quoted 8 lines
Quoted 3 lines

The reasoning behind to make it generic was to have more users - host1x, Iris VPU, QDA on the generic context bus, instead of each of them having their own. Let me know if you suggest to have the iris_vpu_bus.

But you did not add such users here, so how would we know this?

And still, I have no idea what this bus really is doing. Is it dynamic? Is it self-describing? Why not just use aux-bus? What is it supposed to be doing and used for?

Quoted 5 lines

This bus will allow users to create a dynamic device and map to IOMMU stream ID via .dma_configure callback which calls the of_dma_confgure_id() based on the user inputs. This bus is under the iommu_buses list to register for bus notifier callbacks for iommu_probe_device() and iommu_release_device() during add and remove.

Quoted 3 lines

But a device is nothing on its own. You can not just have a random 'struct device' hanging out there that does nothing but iommu, right? It should be doing something else that is very "bus" specific.

Unfortunately, it is a pattern of IOMMU-only devices. All the actual programmig is done through IO region associated with the main device, while subdevices are mostly used for DMA buffer allocation.

Quoted 5 lines

Again, why not create a bus for your hardware type and have that control the bindings of drivers to the devices, like it should be done. You better not be creating platform devices for these things :)

Signature · 2 lines
With best wishes
Dmitry
#11 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 89 lines · Dmitry Baryshkov
Quoted 88 lines · Greg Kroah-Hartman
Quoted 86 lines · Vishnu Reddy
Quoted 70 lines · Greg Kroah-Hartman
Quoted 45 lines · Vishnu Reddy
Quoted 44 lines · Greg Kroah-Hartman
Quoted 43 lines · Vishnu Reddy
Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Why not make a irus_vpu_bus where you can do what you want?

Initially iris_vpu_bus was introduced, and it was made generic based on the discussion,

https://lore.kernel.org/all/[email protected]/

I don't really see that request here, I see a "make this better and more generic for other busses" but that does not mean "dump it into drivers/bus/ for someone else to maintain" :)

Quoted 13 lines
Quoted 13 lines
Quoted 10 lines

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

As there is only one user, just make this your own bus please and do all of the needed bus operations for your devices there (i.e. don't hang an "empty" device off of it.)

Quoted 8 lines
Quoted 3 lines

The reasoning behind to make it generic was to have more users - host1x, Iris VPU, QDA on the generic context bus, instead of each of them having their own. Let me know if you suggest to have the iris_vpu_bus.

But you did not add such users here, so how would we know this?

And still, I have no idea what this bus really is doing. Is it dynamic? Is it self-describing? Why not just use aux-bus? What is it supposed to be doing and used for?

This bus will allow users to create a dynamic device and map to IOMMU stream ID via .dma_configure callback which calls the of_dma_confgure_id() based on the user inputs. This bus is under the iommu_buses list to register for bus notifier callbacks for iommu_probe_device() and iommu_release_device() during add and remove.

Quoted 7 lines
Quoted 3 lines

But a device is nothing on its own. You can not just have a random 'struct device' hanging out there that does nothing but iommu, right? It should be doing something else that is very "bus" specific.

Unfortunately, it is a pattern of IOMMU-only devices. All the actual programmig is done through IO region associated with the main device, while subdevices are mostly used for DMA buffer allocation.

Great, then you have a "host controller" for the devices, and children devices on that bus, with proper drivers binding to them. Like all other normal busses.

Yes, writing a new bus is a bit more pain than it should be, one of these days someone will get around to making that simpler...

Along those lines, why aren't these new drivers in rust? :)

thanks,

greg k-h

#12 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

Quoted 95 lines · Greg Kroah-Hartman
Quoted 93 lines · Dmitry Baryshkov
Quoted 91 lines · Greg Kroah-Hartman
Quoted 81 lines · Vishnu Reddy
Quoted 70 lines · Greg Kroah-Hartman
Quoted 45 lines · Vishnu Reddy
Quoted 44 lines · Greg Kroah-Hartman
Quoted 43 lines · Vishnu Reddy
Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Why not make a irus_vpu_bus where you can do what you want?

Initially iris_vpu_bus was introduced, and it was made generic based on the discussion,

https://lore.kernel.org/all/[email protected]/

I don't really see that request here, I see a "make this better and more generic for other busses" but that does not mean "dump it into drivers/bus/ for someone else to maintain" :)

Quoted 13 lines
Quoted 13 lines
Quoted 10 lines

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

As there is only one user, just make this your own bus please and do all of the needed bus operations for your devices there (i.e. don't hang an "empty" device off of it.)

Quoted 8 lines
Quoted 3 lines

The reasoning behind to make it generic was to have more users - host1x, Iris VPU, QDA on the generic context bus, instead of each of them having their own. Let me know if you suggest to have the iris_vpu_bus.

But you did not add such users here, so how would we know this?

And still, I have no idea what this bus really is doing. Is it dynamic? Is it self-describing? Why not just use aux-bus? What is it supposed to be doing and used for?

Quoted 5 lines

This bus will allow users to create a dynamic device and map to IOMMU stream ID via .dma_configure callback which calls the of_dma_confgure_id() based on the user inputs. This bus is under the iommu_buses list to register for bus notifier callbacks for iommu_probe_device() and iommu_release_device() during add and remove.

But a device is nothing on its own. You can not just have a random 'struct device' hanging out there that does nothing but iommu, right? It should be doing something else that is very "bus" specific.

Quoted 7 lines
Quoted 3 lines

Unfortunately, it is a pattern of IOMMU-only devices. All the actual programmig is done through IO region associated with the main device, while subdevices are mostly used for DMA buffer allocation.

Great, then you have a "host controller" for the devices, and children devices on that bus, with proper drivers binding to them. Like all other normal busses.

I see your point.

Quoted 5 lines

Yes, writing a new bus is a bit more pain than it should be, one of these days someone will get around to making that simpler...

Along those lines, why aren't these new drivers in rust? :)

:-D

Signature · 2 lines
With best wishes
Dmitry
#13 lore raw

Re: [PATCH v2 02/13] drivers: base: Add generic dma context bus

In reply to Greg Kroah-Hartman
Quoted 85 lines · Greg Kroah-Hartman
Quoted 76 lines · Vishnu Reddy
Quoted 75 lines · Greg Kroah-Hartman
Quoted 45 lines · Vishnu Reddy
Quoted 44 lines · Greg Kroah-Hartman
Quoted 43 lines · Vishnu Reddy
Quoted 27 lines · Greg Kroah-Hartman
Quoted 20 lines · Vishnu Reddy

From: Ekansh Gupta <[email protected]>

When a driver needs to create virtual device at runtime and map it to an IOMMU context for memory isolation, there is no common bus available for this purpose. Each driver ends up implementing its own bus type, leading to duplicated logic across multiple drivers.

host1x driver implemented its own bus type to attach an IOMMU context to a dynamically created device. The Iris VPU driver now has the same requirement. Rather than duplicating the same bus logic again, a shared bus type is introduced under drivers/base that multiple drivers can use directly.

The bus takes care of creating a device and attaching the IOMMU context to it based on the client inputs.

Quoted 6 lines
---
 drivers/base/Kconfig            |  3 ++
 drivers/base/Makefile           |  1 +
 drivers/base/dma_context_bus.c  | 77 +++++++++++++++++++++++++++++++++++++++++
 include/linux/dma_context_bus.h | 26 ++++++++++++++
 4 files changed, 107 insertions(+)
Quoted 8 lines

as you can not have a device on multiple busses at the same time, this makes no sense to me at all. "dma context" is a bus-specific thing, so please add it to the bus that you are wanting it for. It can't be a generic bus as that just doesn't work.

Or what am I missing here?

And why is DMA somehow "special" here from any other hardware attribute?

Let me give brief information which was discussed, in the initial series, the iris VPU used platform bus for dynamically created devices and we got the comment/suggestion from Robin to implement a proper bus_type with a .dma_configure callback.

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

based on the discussion, implemented the dma_context_bus and used for iris VPU devices instead of platform bus.

Why not make a irus_vpu_bus where you can do what you want?

Initially iris_vpu_bus was introduced, and it was made generic based on the discussion,

https://lore.kernel.org/all/[email protected]/

I don't really see that request here, I see a "make this better and more generic for other busses" but that does not mean "dump it into drivers/bus/ for someone else to maintain" :)

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Here, the device have only one bus (dma_context_bus), not multiple buses.

Regarding the "DMA" naming, the core operation of this bus is its .dma_configure callback, which calls of_dma_configure_id() to map the device to a corresponding IOMMU stream ID. The name "dma_context" reflects this purpose.

I am open to suggestions from you or Robin or anyone else, if there is a better or preferred way to achieve this, I am happy to consider it and rework the implementation accordingly.

Quoted 6 lines
Quoted 3 lines

As there is only one user, just make this your own bus please and do all of the needed bus operations for your devices there (i.e. don't hang an "empty" device off of it.)

The reasoning behind to make it generic was to have more users - host1x, Iris VPU, QDA on the generic context bus, instead of each of them having their own. Let me know if you suggest to have the iris_vpu_bus.

But you did not add such users here, so how would we know this?

Quoted 8 lines
Quoted 3 lines

And still, I have no idea what this bus really is doing. Is it dynamic? Is it self-describing? Why not just use aux-bus? What is it supposed to be doing and used for?

This bus will allow users to create a dynamic device and map to IOMMU stream ID via .dma_configure callback which calls the of_dma_confgure_id() based on the user inputs. This bus is under the iommu_buses list to register for bus notifier callbacks for iommu_probe_device() and iommu_release_device() during add and remove.

Quoted 7 lines

But a device is nothing on its own. You can not just have a random 'struct device' hanging out there that does nothing but iommu, right? It should be doing something else that is very "bus" specific.

Again, why not create a bus for your hardware type and have that control the bindings of drivers to the devices, like it should be done. You better not be creating platform devices for these things :)

Creating a dedicated bus for iris_vpu is indeed possible, and we had actually explored this direction in a one of the series. A patch implementing an iris_vpu bus was posted earlier here,
https://lore.kernel.org/all/[email protected]/

I'll bring back that approach. Before that, I'll wait a few days to gather any further opinions or suggestions from anyone else. Then, I'll proceed with posting the next revision with the iris_vpu bus in place.

Quoted 12 lines
Quoted 4 lines

auxilary bus don't have the .dma_callback and bus notifier callbacks where it can do iommu_probe_device() and iommu_release_device(). iommu_release_device(), being a static api, need to be called from bus notifier callbacks which should be under the list of iommu_buses.

True, because aux bus devices don't do that directly, they are "sharing" resources with their parent device and something has to mediate for it. So yes, you are right, that is not a good idea. Make a custom bus type instead please.

thanks,

greg k-h

#14 lore raw

PATCH v2 3/13 gpu: host1x: Migrate to generic dma context bus

In reply to Vishnu Reddy

From: Ekansh Gupta <[email protected]>

The host1x driver creates context bank devices to map IOMMU contexts for memory isolation. Previously, this required a host1x-specific bus type with its own device setup and IOMMU configuration logic.

A generic "dma-context-bus" is now available in the driver core that handles this for any driver. Replace the host1x-specific bus with this shared generic bus. This removes the private bus registration, device setup, and of_dma_configure_id() from host1x, as the generic bus handles all of this internally.

The IOMMU subsystem is also updated to reference the generic bus instead of the host1x-specific one.

---
 drivers/gpu/drm/tegra/uapi.c       |  2 +-
 drivers/gpu/host1x/Kconfig         |  5 +---
 drivers/gpu/host1x/Makefile        |  1 -
 drivers/gpu/host1x/context.c       | 47 ++++++++++++--------------------------
 drivers/gpu/host1x/context.h       |  3 +--
 drivers/gpu/host1x/context_bus.c   | 26 ---------------------
 drivers/iommu/iommu.c              |  6 ++---
 include/linux/host1x.h             |  2 +-
 include/linux/host1x_context_bus.h | 15 ------------
 9 files changed, 21 insertions(+), 86 deletions(-)
drivers/gpu/drm/tegra/uapi.c +1 -1
index c0ac6b45f2d7..9547725a6c3c 100644
@@ -215,7 +215,7 @@ int tegra_drm_ioctl_channel_map(struct drm_device *drm, void *data, struct drm_f
 	kref_init(&mapping->ref);
 
 	if (context->memory_context)
-		mapping_dev = &context->memory_context->dev;
+		mapping_dev = context->memory_context->dev;
 	else
 		mapping_dev = context->client->base.dev;
 
drivers/gpu/host1x/Kconfig +1 -4
index e6c78ae2003a..0539ff057a51 100644
@@ -1,13 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-config TEGRA_HOST1X_CONTEXT_BUS
-	bool
-
 config TEGRA_HOST1X
 	tristate "NVIDIA Tegra host1x driver"
 	depends on ARCH_TEGRA || COMPILE_TEST
 	select DMA_SHARED_BUFFER
-	select TEGRA_HOST1X_CONTEXT_BUS
+	select DMA_CONTEXT_BUS
 	select IOMMU_IOVA
 	help
 	  Driver for the NVIDIA Tegra host1x hardware.
drivers/gpu/host1x/Makefile +0 -1
index fead483af0b4..2ccd9a5f1c65 100644
@@ -23,4 +23,3 @@ host1x-$(CONFIG_IOMMU_API) += \
 	context.o
 
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
-obj-$(CONFIG_TEGRA_HOST1X_CONTEXT_BUS) += context_bus.o
drivers/gpu/host1x/context.c +14 -33

93 lines not on this page · raw message

drivers/gpu/host1x/context.h +1 -2
index 3e03bc1d3bac..558638c457d6 100644
@@ -8,13 +8,12 @@
 #ifndef __HOST1X_CONTEXT_H
 #define __HOST1X_CONTEXT_H
 
+#include <linux/dma_context_bus.h>
 #include <linux/mutex.h>
 #include <linux/refcount.h>
 
 struct host1x;
 
-extern struct bus_type host1x_context_device_bus_type;
-
 struct host1x_memory_context_list {
 	struct mutex lock;
 	struct host1x_memory_context *devs;
drivers/gpu/host1x/context_bus.c deleted +0 -26
deleted file mode 100644
index 7cd0e1a5edd1..000000000000
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (c) 2021, NVIDIA Corporation.
- */
-
-#include <linux/device.h>
-#include <linux/of.h>
-
-const struct bus_type host1x_context_device_bus_type = {
-	.name = "host1x-context",
-};
-EXPORT_SYMBOL_GPL(host1x_context_device_bus_type);
-
-static int __init host1x_context_device_bus_init(void)
-{
-	int err;
-
-	err = bus_register(&host1x_context_device_bus_type);
-	if (err < 0) {
-		pr_err("bus type registration failed: %d\n", err);
-		return err;
-	}
-
-	return 0;
-}
-postcore_initcall(host1x_context_device_bus_init);
drivers/iommu/iommu.c +3 -3
index 61c12ba78206..5d0fad1402eb 100644
@@ -16,7 +16,7 @@
 #include <linux/export.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
-#include <linux/host1x_context_bus.h>
+#include <linux/dma_context_bus.h>
 #include <linux/iommu.h>
 #include <linux/iommufd.h>
 #include <linux/idr.h>
@@ -173,8 +173,8 @@ static const struct bus_type * const iommu_buses[] = {
 #ifdef CONFIG_FSL_MC_BUS
 	&fsl_mc_bus_type,
 #endif
-#ifdef CONFIG_TEGRA_HOST1X_CONTEXT_BUS
-	&host1x_context_device_bus_type,
+#ifdef CONFIG_DMA_CONTEXT_BUS
+	&dma_context_bus_type,
 #endif
 #ifdef CONFIG_CDX_BUS
 	&cdx_bus_type,
include/linux/host1x.h +1 -1
index 1f5f55917d1c..30dbb3a71828 100644
@@ -462,7 +462,7 @@ struct host1x_memory_context {
 	struct pid *owner;
 
 	struct device_dma_parameters dma_parms;
-	struct device dev;
+	struct device *dev;
 	u64 dma_mask;
 	u32 stream_id;
 };
include/linux/host1x_context_bus.h deleted +0 -15
deleted file mode 100644
index c928cb432680..000000000000
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (c) 2021, NVIDIA Corporation. All rights reserved.
- */
-
-#ifndef __LINUX_HOST1X_CONTEXT_BUS_H
-#define __LINUX_HOST1X_CONTEXT_BUS_H
-
-#include <linux/device.h>
-
-#ifdef CONFIG_TEGRA_HOST1X_CONTEXT_BUS
-extern const struct bus_type host1x_context_device_bus_type;
-#endif
-
-#endif
Signature · 1 line
2.34.1
#15 lore raw

Re: [PATCH v2 03/13] gpu: host1x: Migrate to generic dma context bus

include/linux/host1x.h struct host1x_memory_context { · line 465

Quoted 8 lines · Vishnu Reddy
include/linux/host1x.h +1 -1
@@ -462,7 +462,7 @@ struct host1x_memory_context {
 	struct pid *owner;
 
 	struct device_dma_parameters dma_parms;
-	struct device dev;
+	struct device *dev;

Ah, nice try, but no. You can't use a "generic" device for this type of thing (i.e. your dma context bus device), as that's not what this device really is. Add the needed logic to the bus this real device lives on, don't try to work around it.

thanks,

greg k-h

#16 lore raw

PATCH v2 4/13 dt-bindings: media: qcom,glymur-iris: Add glymur video codec

In reply to Vishnu Reddy

Add 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.

---
 .../bindings/media/qcom,glymur-iris.yaml           | 220 +++++++++++++++++++++
 include/dt-bindings/media/qcom,glymur-iris.h       |  11 ++
 2 files changed, 231 insertions(+)
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +220 -0
new file mode 100644
index 000000000000..0fd8a8db01af
@@ -0,0 +1,220 @@
+# 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
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 9
+
+  clock-names:
+    items:
+      - const: iface
+      - const: core
+      - const: vcodec0_core
+      - const: iface1
+      - const: core_freerun
+      - const: vcodec0_core_freerun
+      - const: iface2
+      - const: vcodec1_core
+      - const: vcodec1_core_freerun
+
+  dma-coherent: true
+
+  firmware-name:
+    maxItems: 1
+
+  interconnects:
+    maxItems: 2
+
+  interconnect-names:
+    items:
+      - const: cpu-cfg
+      - const: video-mem
+
+  interrupts:
+    maxItems: 1
+
+  iommus:
+    maxItems: 4
+
+  iommu-map:
+    maxItems: 1
+
+  memory-region:
+    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: bus0
+      - const: bus1
+      - const: core
+      - const: vcodec0_core
+      - const: bus2
+      - const: vcodec1_core
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - dma-coherent
+  - interconnects
+  - interconnect-names
+  - interrupts
+  - iommus
+  - memory-region
+  - power-domains
+  - power-domain-names
+  - resets
+  - reset-names
+
+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_axi0_clk>,
+                 <&videocc_mvs0c_clk>,
+                 <&videocc_mvs0_clk>,
+                 <&gcc_video_axi0c_clk>,
+                 <&videocc_mvs0c_freerun_clk>,
+                 <&videocc_mvs0_freerun_clk>,
+                 <&gcc_video_axi1_clk>,
+                 <&videocc_mvs1_clk>,
+                 <&videocc_mvs1_freerun_clk>;
+        clock-names = "iface",
+                      "core",
+                      "vcodec0_core",
+                      "iface1",
+                      "core_freerun",
+                      "vcodec0_core_freerun",
+                      "iface2",
+                      "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_axi0_clk_ares>,
+                 <&gcc_video_axi0c_clk_ares>,
+                 <&videocc_mvs0c_freerun_clk_ares>,
+                 <&videocc_mvs0_freerun_clk_ares>,
+                 <&gcc_video_axi1_clk_ares>,
+                 <&videocc_mvs1_freerun_clk_ares>;
+        reset-names = "bus0",
+                      "bus1",
+                      "core",
+                      "vcodec0_core",
+                      "bus2",
+                      "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>;
+            };
+        };
+    };
include/dt-bindings/media/qcom,glymur-iris.h new file +11 -0
new file mode 100644
index 000000000000..dcaa2bc21db5
@@ -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
#17 lore raw

Re: [PATCH v2 04/13] dt-bindings: media: qcom,glymur-iris: Add glymur video codec

Quoted 8 lines · Vishnu Reddy
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +8 -0
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - dma-coherent
+  - interconnects
+  - interconnect-names

Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml line 107

Quoted 10 lines
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +10 -0
+  - interrupts
+  - iommus
+  - memory-region
+  - power-domains
+  - power-domain-names
+  - resets
+  - reset-names
+
+unevaluatedProperties: false
+

I think I commented around here but probably not specific enough. You miss here either reference to venus or usage of additionalProperties instead of unevaluatedProperties.

If you intend not to use qcom,venus-common.yaml, then explain WHY in commit msg and switch to additionalProperties: false.

Otherwise, you miss $ref.

Rest looked good.

Best regards,
Krzysztof

#18 lore raw

Re: [PATCH v2 04/13] dt-bindings: media: qcom,glymur-iris: Add glymur video codec

Quoted 23 lines · Krzysztof Kozlowski
Quoted 8 lines · Vishnu Reddy
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +8 -0
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - dma-coherent
+  - interconnects
+  - interconnect-names

Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml line 107

Quoted 10 lines
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +10 -0
+  - interrupts
+  - iommus
+  - memory-region
+  - power-domains
+  - power-domain-names
+  - resets
+  - reset-names
+
+unevaluatedProperties: false
+

I think I commented around here but probably not specific enough. You miss here either reference to venus or usage of additionalProperties instead of unevaluatedProperties.

Quoted 6 lines

If you intend not to use qcom,venus-common.yaml, then explain WHY in commit msg and switch to additionalProperties: false.

Otherwise, you miss $ref.

Rest looked good.

Iris glymur platform have more clocks and power domains, which exceed the maxItems limits defined in qcom,venus-common.yaml. Inheriting from it would cause dt-schema validation failures, so I have chosen not to reference it.

I will add this information in the commit message explaining this, and switch from unevaluatedProperties: false to additionalProperties: false as you suggested. Will address in the next version.

Thanks,
Vishnu Reddy.

Quoted 3 lines

Best regards,
Krzysztof

#19 lore raw

Re: [PATCH v2 04/13] dt-bindings: media: qcom,glymur-iris: Add glymur video codec

Quoted 28 lines · Vishnu Reddy
Quoted 26 lines · Krzysztof Kozlowski
Quoted 8 lines · Vishnu Reddy
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +8 -0
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - dma-coherent
+  - interconnects
+  - interconnect-names

Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml line 107

Quoted 10 lines
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +10 -0
+  - interrupts
+  - iommus
+  - memory-region
+  - power-domains
+  - power-domain-names
+  - resets
+  - reset-names
+
+unevaluatedProperties: false
+

I think I commented around here but probably not specific enough. You miss here either reference to venus or usage of additionalProperties instead of unevaluatedProperties.

If you intend not to use qcom,venus-common.yaml, then explain WHY in commit msg and switch to additionalProperties: false.

Quoted 8 lines
Quoted 3 lines

Otherwise, you miss $ref.

Rest looked good.

Iris glymur platform have more clocks and power domains, which exceed the maxItems limits defined in qcom,venus-common.yaml. Inheriting from it would cause dt-schema validation failures, so I have chosen not to reference it.

Instead, you should extend the common schema. It's already flexible, so what is the problem here?

You then need to duplicate all of the common properties...

Best regards,
Krzysztof

#20 lore raw

Re: [PATCH v2 04/13] dt-bindings: media: qcom,glymur-iris: Add glymur video codec

Quoted 31 lines · Krzysztof Kozlowski
Quoted 30 lines · Vishnu Reddy
Quoted 29 lines · Krzysztof Kozlowski
Quoted 8 lines · Vishnu Reddy
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +8 -0
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - dma-coherent
+  - interconnects
+  - interconnect-names

Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml line 107

Quoted 10 lines
Documentation/devicetree/bindings/media/qcom,glymur-iris.yaml new file +10 -0
+  - interrupts
+  - iommus
+  - memory-region
+  - power-domains
+  - power-domain-names
+  - resets
+  - reset-names
+
+unevaluatedProperties: false
+

I think I commented around here but probably not specific enough. You miss here either reference to venus or usage of additionalProperties instead of unevaluatedProperties.

If you intend not to use qcom,venus-common.yaml, then explain WHY in commit msg and switch to additionalProperties: false.

Otherwise, you miss $ref.

Rest looked good.

Quoted 8 lines
Quoted 4 lines

Iris glymur platform have more clocks and power domains, which exceed the maxItems limits defined in qcom,venus-common.yaml. Inheriting from it would cause dt-schema validation failures, so I have chosen not to reference it.

Instead, you should extend the common schema. It's already flexible, so what is the problem here?

You then need to duplicate all of the common properties...

Ack, I'm fine to update qcom,venus-common.yaml to relax the maxItems constraints for clocks and power domains, so that the Glymur Iris binding can properly inherit from it.

Quoted 3 lines

Best regards,
Krzysztof

#21 lore raw

PATCH v2 5/13 media: iris: Add context bank hooks for platform specific initialization

In reply to Vishnu Reddy

The Glymur platform requires a dedicated firmware context bank device which is mapped to the firmware stream ID to load the firmware.

Add init and deinit hooks in the platform data for context bank setup. These hooks allow platform specific code to initialize and tear down context banks.

---
 .../platform/qcom/iris/iris_platform_common.h      |  2 ++
 drivers/media/platform/qcom/iris/iris_probe.c      | 23 +++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_platform_common.h +2 -0
index 5a489917580e..55ff6137d9a9 100644
@@ -219,6 +219,8 @@ struct iris_platform_data {
 	u32 (*get_vpu_buffer_size)(struct iris_inst *inst, enum iris_buffer_type buffer_type);
 	const struct vpu_ops *vpu_ops;
 	void (*set_preset_registers)(struct iris_core *core);
+	int (*init_cb_devs)(struct iris_core *core);
+	void (*deinit_cb_devs)(struct iris_core *core);
 	const struct icc_info *icc_tbl;
 	unsigned int icc_tbl_size;
 	const struct bw_info *bw_tbl_dec;
drivers/media/platform/qcom/iris/iris_probe.c +22 -1
index ddaacda523ec..34751912f871 100644
@@ -142,6 +142,20 @@ static int iris_init_resources(struct iris_core *core)
 	return iris_init_resets(core);
 }
 
+static int iris_init_cb_devs(struct iris_core *core)
+{
+	if (core->iris_platform_data->init_cb_devs)
+		return core->iris_platform_data->init_cb_devs(core);
+
+	return 0;
+}
+
+static void iris_deinit_cb_devs(struct iris_core *core)
+{
+	if (core->iris_platform_data->deinit_cb_devs)
+		core->iris_platform_data->deinit_cb_devs(core);
+}
+
 static int iris_register_video_device(struct iris_core *core, enum domain_type type)
 {
 	struct video_device *vdev;
@@ -193,6 +207,7 @@ static void iris_remove(struct platform_device *pdev)
 		return;
 
 	iris_core_deinit(core);
+	iris_deinit_cb_devs(core);
 
 	video_unregister_device(core->vdev_dec);
 	video_unregister_device(core->vdev_enc);
@@ -259,11 +274,15 @@ static int iris_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ret = iris_init_cb_devs(core);
+	if (ret)
+		return ret;
+
 	iris_session_init_caps(core);
 
 	ret = v4l2_device_register(dev, &core->v4l2_dev);
 	if (ret)
-		return ret;
+		goto err_deinit_cb;
 
 	ret = iris_register_video_device(core, DECODER);
 	if (ret)
@@ -298,6 +317,8 @@ static int iris_probe(struct platform_device *pdev)
 	video_unregister_device(core->vdev_dec);
 err_v4l2_unreg:
 	v4l2_device_unregister(&core->v4l2_dev);
+err_deinit_cb:
+	iris_deinit_cb_devs(core);
 
 	return ret;
 }
Signature · 1 line
2.34.1
#22 lore raw

PATCH v2 6/13 media: iris: Enable Secure PAS support with IOMMU managed by Linux

In reply to Vishnu Reddy

From: Mukesh Ojha <[email protected]>

Most Qualcomm platforms feature a proprietary hypervisor (such as Gunyah or QHEE), which typically handles IOMMU configuration. This includes mapping memory regions and device memory resources for remote processors by intercepting qcom_scm_pas_auth_and_reset() calls. These mappings are later removed during teardown. Additionally, SHM bridge setup is required to enable memory protection for both remoteproc metadata and its memory regions.

When the hypervisor is absent, the operating system must perform these configurations instead.

Support for handling IOMMU and SHM setup in the absence of a hypervisor is now in place. Extend the Iris driver to enable this functionality on platforms where IOMMU is managed by Linux (i.e., non-Gunyah, non-QHEE).

Additionally, the Iris driver must map the firmware and its required resources to the firmware SID, which is now specified via iommu-map in the device tree.

---
 drivers/media/platform/qcom/iris/iris_core.h     |  4 ++
 drivers/media/platform/qcom/iris/iris_firmware.c | 72 ++++++++++++++++++++----
 2 files changed, 66 insertions(+), 10 deletions(-)
drivers/media/platform/qcom/iris/iris_core.h +4 -0
index fb194c967ad4..b396c8cf595e 100644
@@ -34,6 +34,8 @@ enum domain_type {
  * 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
@@ -77,6 +79,8 @@ enum domain_type {
 
 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 +62 -10

136 lines not on this page · raw message

Signature · 1 line
2.34.1
#23 lore raw

PATCH v2 7/13 media: iris: Rename clock and power domain macros to use vcodec prefix

In reply to Vishnu Reddy

The current clock and power domain enum names are too generic. Rename them with a vcodec prefix to make the names more meaningful and to easily accommodate vcodec1 enums for the secondary core for glymur platform.

No functional changes intended.

---
 .../platform/qcom/iris/iris_platform_common.h      | 12 ++++----
 .../media/platform/qcom/iris/iris_platform_gen1.c  |  6 ++--
 .../media/platform/qcom/iris/iris_platform_gen2.c  |  6 ++--
 .../platform/qcom/iris/iris_platform_sc7280.h      | 10 +++----
 .../platform/qcom/iris/iris_platform_sm8750.h      | 12 ++++----
 drivers/media/platform/qcom/iris/iris_vpu3x.c      | 25 ++++++++--------
 drivers/media/platform/qcom/iris/iris_vpu4x.c      | 30 ++++++++++---------
 drivers/media/platform/qcom/iris/iris_vpu_common.c | 35 +++++++++++-----------
 8 files changed, 70 insertions(+), 66 deletions(-)
drivers/media/platform/qcom/iris/iris_platform_common.h +6 -6
index 55ff6137d9a9..30e9d4d288c6 100644
@@ -49,14 +49,14 @@ extern const struct iris_platform_data sm8650_data;
 extern const struct iris_platform_data sm8750_data;
 
 enum platform_clk_type {
-	IRIS_AXI_CLK, /* AXI0 in case of platforms with multiple AXI clocks */
+	IRIS_AXI_VCODEC_CLK,
 	IRIS_CTRL_CLK,
 	IRIS_AHB_CLK,
-	IRIS_HW_CLK,
-	IRIS_HW_AHB_CLK,
-	IRIS_AXI1_CLK,
+	IRIS_VCODEC_CLK,
+	IRIS_VCODEC_AHB_CLK,
+	IRIS_AXI_CTRL_CLK,
 	IRIS_CTRL_FREERUN_CLK,
-	IRIS_HW_FREERUN_CLK,
+	IRIS_VCODEC_FREERUN_CLK,
 	IRIS_BSE_HW_CLK,
 	IRIS_VPP0_HW_CLK,
 	IRIS_VPP1_HW_CLK,
@@ -206,7 +206,7 @@ struct icc_vote_data {
 
 enum platform_pm_domain_type {
 	IRIS_CTRL_POWER_DOMAIN,
-	IRIS_HW_POWER_DOMAIN,
+	IRIS_VCODEC_POWER_DOMAIN,
 	IRIS_VPP0_HW_POWER_DOMAIN,
 	IRIS_VPP1_HW_POWER_DOMAIN,
 	IRIS_APV_HW_POWER_DOMAIN,
drivers/media/platform/qcom/iris/iris_platform_gen1.c +3 -3
index df8e6bf9430e..be6a631f8ede 100644
@@ -284,9 +284,9 @@ static const char * const sm8250_pmdomain_table[] = { "venus", "vcodec0" };
 static const char * const sm8250_opp_pd_table[] = { "mx" };
 
 static const struct platform_clk_data sm8250_clk_table[] = {
-	{IRIS_AXI_CLK,  "iface"        },
-	{IRIS_CTRL_CLK, "core"         },
-	{IRIS_HW_CLK,   "vcodec0_core" },
+	{IRIS_AXI_VCODEC_CLK,	"iface"		},
+	{IRIS_CTRL_CLK,		"core"		},
+	{IRIS_VCODEC_CLK,	"vcodec0_core"	},
 };
 
 static const char * const sm8250_opp_clk_table[] = {
drivers/media/platform/qcom/iris/iris_platform_gen2.c +3 -3
index 5da90d47f9c6..47c6b650f0b4 100644
@@ -780,9 +780,9 @@ static const char * const sm8550_pmdomain_table[] = { "venus", "vcodec0" };
 static const char * const sm8550_opp_pd_table[] = { "mxc", "mmcx" };
 
 static const struct platform_clk_data sm8550_clk_table[] = {
-	{IRIS_AXI_CLK,  "iface"        },
-	{IRIS_CTRL_CLK, "core"         },
-	{IRIS_HW_CLK,   "vcodec0_core" },
+	{IRIS_AXI_VCODEC_CLK,	"iface"		},
+	{IRIS_CTRL_CLK,		"core"		},
+	{IRIS_VCODEC_CLK,	"vcodec0_core"	},
 };
 
 static const char * const sm8550_opp_clk_table[] = {
drivers/media/platform/qcom/iris/iris_platform_sc7280.h +5 -5
index 0ec8f334df67..6b783e524b81 100644
@@ -16,11 +16,11 @@ 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"   },
+	{IRIS_CTRL_CLK,		"core"		},
+	{IRIS_AXI_VCODEC_CLK,	"iface"		},
+	{IRIS_AHB_CLK,		"bus"		},
+	{IRIS_VCODEC_CLK,	"vcodec_core"	},
+	{IRIS_VCODEC_AHB_CLK,	"vcodec_bus"	},
 };
 
 static const char * const sc7280_opp_clk_table[] = {
drivers/media/platform/qcom/iris/iris_platform_sm8750.h +6 -6
index 719056656a5b..f843f13251c5 100644
@@ -11,12 +11,12 @@ static const char * const sm8750_clk_reset_table[] = {
 };
 
 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"	},
+	{IRIS_AXI_VCODEC_CLK,		"iface"			},
+	{IRIS_CTRL_CLK,			"core"			},
+	{IRIS_VCODEC_CLK,		"vcodec0_core"		},
+	{IRIS_AXI_CTRL_CLK,		"iface1"		},
+	{IRIS_CTRL_FREERUN_CLK,		"core_freerun"		},
+	{IRIS_VCODEC_FREERUN_CLK,	"vcodec0_core_freerun"	},
 };
 
 #endif
drivers/media/platform/qcom/iris/iris_vpu3x.c +13 -12
index fe4423b951b1..1f0a3a47d87f 100644
@@ -209,7 +209,7 @@ static int iris_vpu33_power_off_controller(struct iris_core *core)
 
 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_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 
 	return 0;
 }
@@ -218,36 +218,37 @@ 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]);
+	ret = iris_enable_power_domains(core,
+					core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
 	if (ret)
 		return ret;
 
-	ret = iris_prepare_enable_clock(core, IRIS_AXI_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_AXI_VCODEC_CLK);
 	if (ret)
 		goto err_disable_power;
 
-	ret = iris_prepare_enable_clock(core, IRIS_HW_FREERUN_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_VCODEC_FREERUN_CLK);
 	if (ret)
 		goto err_disable_axi_clk;
 
-	ret = iris_prepare_enable_clock(core, IRIS_HW_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_VCODEC_CLK);
 	if (ret)
 		goto err_disable_hw_free_clk;
 
-	ret = dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN], true);
+	ret = dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN], true);
 	if (ret)
 		goto err_disable_hw_clk;
 
 	return 0;
 
 err_disable_hw_clk:
-	iris_disable_unprepare_clock(core, IRIS_HW_CLK);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_CLK);
 err_disable_hw_free_clk:
-	iris_disable_unprepare_clock(core, IRIS_HW_FREERUN_CLK);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_FREERUN_CLK);
 err_disable_axi_clk:
-	iris_disable_unprepare_clock(core, IRIS_AXI_CLK);
+	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 err_disable_power:
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN]);
+	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
 
 	return ret;
 }
@@ -256,8 +257,8 @@ 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);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_FREERUN_CLK);
+	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 }
 
 const struct vpu_ops iris_vpu3_ops = {
drivers/media/platform/qcom/iris/iris_vpu4x.c +16 -14
index a8db02ce5c5e..4082d331d2f3 100644
@@ -27,7 +27,8 @@ static int iris_vpu4x_genpd_set_hwmode(struct iris_core *core, bool hw_mode, u32
 {
 	int ret;
 
-	ret = dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN], hw_mode);
+	ret = dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN],
+				      hw_mode);
 	if (ret)
 		return ret;
 
@@ -63,7 +64,7 @@ static int iris_vpu4x_genpd_set_hwmode(struct iris_core *core, bool hw_mode, u32
 		dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_VPP0_HW_POWER_DOMAIN],
 					!hw_mode);
 restore_hw_domain_mode:
-	dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN], !hw_mode);
+	dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN], !hw_mode);
 
 	return ret;
 }
@@ -162,15 +163,15 @@ static int iris_vpu4x_enable_hardware_clocks(struct iris_core *core, u32 efuse_v
 {
 	int ret;
 
-	ret = iris_prepare_enable_clock(core, IRIS_AXI_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_AXI_VCODEC_CLK);
 	if (ret)
 		return ret;
 
-	ret = iris_prepare_enable_clock(core, IRIS_HW_FREERUN_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_VCODEC_FREERUN_CLK);
 	if (ret)
 		goto disable_axi_clock;
 
-	ret = iris_prepare_enable_clock(core, IRIS_HW_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_VCODEC_CLK);
 	if (ret)
 		goto disable_hw_free_run_clock;
 
@@ -198,11 +199,11 @@ static int iris_vpu4x_enable_hardware_clocks(struct iris_core *core, u32 efuse_v
 disable_bse_hw_clock:
 	iris_disable_unprepare_clock(core, IRIS_BSE_HW_CLK);
 disable_hw_clock:
-	iris_disable_unprepare_clock(core, IRIS_HW_CLK);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_CLK);
 disable_hw_free_run_clock:
-	iris_disable_unprepare_clock(core, IRIS_HW_FREERUN_CLK);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_FREERUN_CLK);
 disable_axi_clock:
-	iris_disable_unprepare_clock(core, IRIS_AXI_CLK);
+	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 
 	return ret;
 }
@@ -216,9 +217,9 @@ static void iris_vpu4x_disable_hardware_clocks(struct iris_core *core, u32 efuse
 		iris_disable_unprepare_clock(core, IRIS_VPP0_HW_CLK);
 
 	iris_disable_unprepare_clock(core, IRIS_BSE_HW_CLK);
-	iris_disable_unprepare_clock(core, IRIS_HW_CLK);
-	iris_disable_unprepare_clock(core, IRIS_HW_FREERUN_CLK);
-	iris_disable_unprepare_clock(core, IRIS_AXI_CLK);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_CLK);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_FREERUN_CLK);
+	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 }
 
 static int iris_vpu4x_power_on_hardware(struct iris_core *core)
@@ -226,7 +227,8 @@ static int iris_vpu4x_power_on_hardware(struct iris_core *core)
 	u32 efuse_value = readl(core->reg_base + WRAPPER_EFUSE_MONITOR);
 	int ret;
 
-	ret = iris_enable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN]);
+	ret = iris_enable_power_domains(core,
+					core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
 	if (ret)
 		return ret;
 
@@ -278,7 +280,7 @@ static int iris_vpu4x_power_on_hardware(struct iris_core *core)
 		iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs
 						[IRIS_VPP0_HW_POWER_DOMAIN]);
 disable_hw_power_domain:
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN]);
+	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
 
 	return ret;
 }
@@ -356,7 +358,7 @@ static void iris_vpu4x_power_off_hardware(struct iris_core *core)
 		iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs
 					   [IRIS_VPP0_HW_POWER_DOMAIN]);
 
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN]);
+	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
 }
 
 const struct vpu_ops iris_vpu4x_ops = {
drivers/media/platform/qcom/iris/iris_vpu_common.c +18 -17
index bfd1e762c38e..006fd3ffc752 100644
@@ -213,7 +213,7 @@ int iris_vpu_power_off_controller(struct iris_core *core)
 disable_power:
 	iris_disable_unprepare_clock(core, IRIS_AHB_CLK);
 	iris_disable_unprepare_clock(core, IRIS_CTRL_CLK);
-	iris_disable_unprepare_clock(core, IRIS_AXI_CLK);
+	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
 
 	return 0;
@@ -221,10 +221,10 @@ int iris_vpu_power_off_controller(struct iris_core *core)
 
 void iris_vpu_power_off_hw(struct iris_core *core)
 {
-	dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN], false);
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN]);
-	iris_disable_unprepare_clock(core, IRIS_HW_AHB_CLK);
-	iris_disable_unprepare_clock(core, IRIS_HW_CLK);
+	dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN], false);
+	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_AHB_CLK);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_CLK);
 }
 
 void iris_vpu_power_off(struct iris_core *core)
@@ -251,7 +251,7 @@ int iris_vpu_power_on_controller(struct iris_core *core)
 	if (ret)
 		goto err_disable_power;
 
-	ret = iris_prepare_enable_clock(core, IRIS_AXI_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_AXI_VCODEC_CLK);
 	if (ret)
 		goto err_disable_power;
 
@@ -268,7 +268,7 @@ int iris_vpu_power_on_controller(struct iris_core *core)
 err_disable_ctrl_clock:
 	iris_disable_unprepare_clock(core, IRIS_CTRL_CLK);
 err_disable_axi_clock:
-	iris_disable_unprepare_clock(core, IRIS_AXI_CLK);
+	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 err_disable_power:
 	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
 
@@ -279,30 +279,31 @@ int iris_vpu_power_on_hw(struct iris_core *core)
 {
 	int ret;
 
-	ret = iris_enable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN]);
+	ret = iris_enable_power_domains(core,
+					core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
 	if (ret)
 		return ret;
 
-	ret = iris_prepare_enable_clock(core, IRIS_HW_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_VCODEC_CLK);
 	if (ret)
 		goto err_disable_power;
 
-	ret = iris_prepare_enable_clock(core, IRIS_HW_AHB_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_VCODEC_AHB_CLK);
 	if (ret && ret != -ENOENT)
 		goto err_disable_hw_clock;
 
-	ret = dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN], true);
+	ret = dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN], true);
 	if (ret)
 		goto err_disable_hw_ahb_clock;
 
 	return 0;
 
 err_disable_hw_ahb_clock:
-	iris_disable_unprepare_clock(core, IRIS_HW_AHB_CLK);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_AHB_CLK);
 err_disable_hw_clock:
-	iris_disable_unprepare_clock(core, IRIS_HW_CLK);
+	iris_disable_unprepare_clock(core, IRIS_VCODEC_CLK);
 err_disable_power:
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN]);
+	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
 
 	return ret;
 }
@@ -362,7 +363,7 @@ int iris_vpu35_vpu4x_power_off_controller(struct iris_core *core)
 disable_power:
 	iris_disable_unprepare_clock(core, IRIS_CTRL_CLK);
 	iris_disable_unprepare_clock(core, IRIS_CTRL_FREERUN_CLK);
-	iris_disable_unprepare_clock(core, IRIS_AXI1_CLK);
+	iris_disable_unprepare_clock(core, IRIS_AXI_CTRL_CLK);
 
 	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
 
@@ -379,7 +380,7 @@ int iris_vpu35_vpu4x_power_on_controller(struct iris_core *core)
 	if (ret)
 		return ret;
 
-	ret = iris_prepare_enable_clock(core, IRIS_AXI1_CLK);
+	ret = iris_prepare_enable_clock(core, IRIS_AXI_CTRL_CLK);
 	if (ret)
 		goto err_disable_power;
 
@@ -396,7 +397,7 @@ int iris_vpu35_vpu4x_power_on_controller(struct iris_core *core)
 err_disable_ctrl_free_clk:
 	iris_disable_unprepare_clock(core, IRIS_CTRL_FREERUN_CLK);
 err_disable_axi1_clk:
-	iris_disable_unprepare_clock(core, IRIS_AXI1_CLK);
+	iris_disable_unprepare_clock(core, IRIS_AXI_CTRL_CLK);
 err_disable_power:
 	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
 
Signature · 1 line
2.34.1
#24 lore raw

PATCH v2 8/13 media: iris: Use power domain type to look up pd_devs index

In reply to Vishnu Reddy

The pmdomain_tbl was a array of strings holding only the power domain names. Callers had to pass a pd_devs[] pointer indexed directly by the platform_pm_domain_type enum value to iris_enable_power_domains() and iris_disable_power_domains().

A future platform may need to introduce a new enum value that aliases an existing one (e.g. IRIS_VCODEC1_POWER_DOMAIN aliasing the IRIS_VPP0_HW_POWER_DOMAIN on Glymur), which would break the assumption that enum values map 1:1 to pd_devs[] indices.

To fix this, replace the string array with a new struct platform_pd_data that pairs each power domain name with its platform_pm_domain_type. Add a helper iris_get_pd_index_by_type() that walks this table and returns the correct pd_devs[] index for a given type.

Update iris_enable_power_domains() and iris_disable_power_domains() to accept a platform_pm_domain_type instead of a struct device pointer. They now call the helper internally to resolve the index, removing the need for callers to do the index lookup themselves.

This prepares the driver for adding new platforms where power domain enum values cannot be used directly as pd_devs[] indices.

---
 .../platform/qcom/iris/iris_platform_common.h      |  9 +++-
 .../media/platform/qcom/iris/iris_platform_gen1.c  | 18 +++++---
 .../media/platform/qcom/iris/iris_platform_gen2.c  | 24 ++++++----
 drivers/media/platform/qcom/iris/iris_probe.c      |  4 +-
 drivers/media/platform/qcom/iris/iris_resources.c  | 44 +++++++++++++++++-
 drivers/media/platform/qcom/iris/iris_resources.h  |  6 ++-
 drivers/media/platform/qcom/iris/iris_vpu3x.c      |  9 ++--
 drivers/media/platform/qcom/iris/iris_vpu4x.c      | 52 ++++++++--------------
 drivers/media/platform/qcom/iris/iris_vpu_common.c | 23 +++++-----
 9 files changed, 117 insertions(+), 72 deletions(-)
drivers/media/platform/qcom/iris/iris_platform_common.h +7 -2
index 30e9d4d288c6..7d59e6364e9d 100644
@@ -212,6 +212,12 @@ enum platform_pm_domain_type {
 	IRIS_APV_HW_POWER_DOMAIN,
 };
 
+struct platform_pd_data {
+	enum platform_pm_domain_type *pd_types;
+	const char **pd_names;
+	u32 pd_count;
+};
+
 struct iris_platform_data {
 	void (*init_hfi_command_ops)(struct iris_core *core);
 	void (*init_hfi_response_ops)(struct iris_core *core);
@@ -225,8 +231,7 @@ struct iris_platform_data {
 	unsigned int icc_tbl_size;
 	const struct bw_info *bw_tbl_dec;
 	unsigned int bw_tbl_dec_size;
-	const char * const *pmdomain_tbl;
-	unsigned int pmdomain_tbl_size;
+	const struct platform_pd_data *pmdomain_tbl;
 	const char * const *opp_pd_tbl;
 	unsigned int opp_pd_tbl_size;
 	const struct platform_clk_data *clk_tbl;
drivers/media/platform/qcom/iris/iris_platform_gen1.c +13 -5
index be6a631f8ede..0ec73783bc10 100644
@@ -279,7 +279,17 @@ static const struct bw_info sm8250_bw_table_dec[] = {
 	{ ((1920 * 1080) / 256) * 30,  416000 },
 };
 
-static const char * const sm8250_pmdomain_table[] = { "venus", "vcodec0" };
+static const struct platform_pd_data sm8250_pmdomain_table = {
+	.pd_types = (enum platform_pm_domain_type []) {
+		IRIS_CTRL_POWER_DOMAIN,
+		IRIS_VCODEC_POWER_DOMAIN,
+	},
+	.pd_names = (const char *[]) {
+		"venus",
+		"vcodec0",
+	},
+	.pd_count = 2,
+};
 
 static const char * const sm8250_opp_pd_table[] = { "mx" };
 
@@ -350,8 +360,7 @@ const struct iris_platform_data sm8250_data = {
 	.clk_rst_tbl_size = ARRAY_SIZE(sm8250_clk_reset_table),
 	.bw_tbl_dec = sm8250_bw_table_dec,
 	.bw_tbl_dec_size = ARRAY_SIZE(sm8250_bw_table_dec),
-	.pmdomain_tbl = sm8250_pmdomain_table,
-	.pmdomain_tbl_size = ARRAY_SIZE(sm8250_pmdomain_table),
+	.pmdomain_tbl = &sm8250_pmdomain_table,
 	.opp_pd_tbl = sm8250_opp_pd_table,
 	.opp_pd_tbl_size = ARRAY_SIZE(sm8250_opp_pd_table),
 	.clk_tbl = sm8250_clk_table,
@@ -403,8 +412,7 @@ const struct iris_platform_data sc7280_data = {
 	.icc_tbl_size = ARRAY_SIZE(sm8250_icc_table),
 	.bw_tbl_dec = sc7280_bw_table_dec,
 	.bw_tbl_dec_size = ARRAY_SIZE(sc7280_bw_table_dec),
-	.pmdomain_tbl = sm8250_pmdomain_table,
-	.pmdomain_tbl_size = ARRAY_SIZE(sm8250_pmdomain_table),
+	.pmdomain_tbl = &sm8250_pmdomain_table,
 	.opp_pd_tbl = sc7280_opp_pd_table,
 	.opp_pd_tbl_size = ARRAY_SIZE(sc7280_opp_pd_table),
 	.clk_tbl = sc7280_clk_table,
drivers/media/platform/qcom/iris/iris_platform_gen2.c +15 -9
index 47c6b650f0b4..5862c89a4971 100644
@@ -775,7 +775,17 @@ static const struct bw_info sm8550_bw_table_dec[] = {
 	{ ((1920 * 1080) / 256) * 30,  294000 },
 };
 
-static const char * const sm8550_pmdomain_table[] = { "venus", "vcodec0" };
+static const struct platform_pd_data sm8550_pmdomain_table = {
+	.pd_types = (enum platform_pm_domain_type []) {
+		IRIS_CTRL_POWER_DOMAIN,
+		IRIS_VCODEC_POWER_DOMAIN,
+	},
+	.pd_names = (const char *[]) {
+		"venus",
+		"vcodec0",
+	},
+	.pd_count = 2,
+};
 
 static const char * const sm8550_opp_pd_table[] = { "mxc", "mmcx" };
 
@@ -934,8 +944,7 @@ const struct iris_platform_data sm8550_data = {
 	.clk_rst_tbl_size = ARRAY_SIZE(sm8550_clk_reset_table),
 	.bw_tbl_dec = sm8550_bw_table_dec,
 	.bw_tbl_dec_size = ARRAY_SIZE(sm8550_bw_table_dec),
-	.pmdomain_tbl = sm8550_pmdomain_table,
-	.pmdomain_tbl_size = ARRAY_SIZE(sm8550_pmdomain_table),
+	.pmdomain_tbl = &sm8550_pmdomain_table,
 	.opp_pd_tbl = sm8550_opp_pd_table,
 	.opp_pd_tbl_size = ARRAY_SIZE(sm8550_opp_pd_table),
 	.clk_tbl = sm8550_clk_table,
@@ -1039,8 +1048,7 @@ const struct iris_platform_data sm8650_data = {
 	.controller_rst_tbl_size = ARRAY_SIZE(sm8650_controller_reset_table),
 	.bw_tbl_dec = sm8550_bw_table_dec,
 	.bw_tbl_dec_size = ARRAY_SIZE(sm8550_bw_table_dec),
-	.pmdomain_tbl = sm8550_pmdomain_table,
-	.pmdomain_tbl_size = ARRAY_SIZE(sm8550_pmdomain_table),
+	.pmdomain_tbl = &sm8550_pmdomain_table,
 	.opp_pd_tbl = sm8550_opp_pd_table,
 	.opp_pd_tbl_size = ARRAY_SIZE(sm8550_opp_pd_table),
 	.clk_tbl = sm8550_clk_table,
@@ -1135,8 +1143,7 @@ const struct iris_platform_data sm8750_data = {
 	.clk_rst_tbl_size = ARRAY_SIZE(sm8750_clk_reset_table),
 	.bw_tbl_dec = sm8550_bw_table_dec,
 	.bw_tbl_dec_size = ARRAY_SIZE(sm8550_bw_table_dec),
-	.pmdomain_tbl = sm8550_pmdomain_table,
-	.pmdomain_tbl_size = ARRAY_SIZE(sm8550_pmdomain_table),
+	.pmdomain_tbl = &sm8550_pmdomain_table,
 	.opp_pd_tbl = sm8550_opp_pd_table,
 	.opp_pd_tbl_size = ARRAY_SIZE(sm8550_opp_pd_table),
 	.clk_tbl = sm8750_clk_table,
@@ -1235,8 +1242,7 @@ const struct iris_platform_data qcs8300_data = {
 	.clk_rst_tbl_size = ARRAY_SIZE(sm8550_clk_reset_table),
 	.bw_tbl_dec = sm8550_bw_table_dec,
 	.bw_tbl_dec_size = ARRAY_SIZE(sm8550_bw_table_dec),
-	.pmdomain_tbl = sm8550_pmdomain_table,
-	.pmdomain_tbl_size = ARRAY_SIZE(sm8550_pmdomain_table),
+	.pmdomain_tbl = &sm8550_pmdomain_table,
 	.opp_pd_tbl = sm8550_opp_pd_table,
 	.opp_pd_tbl_size = ARRAY_SIZE(sm8550_opp_pd_table),
 	.clk_tbl = sm8550_clk_table,
drivers/media/platform/qcom/iris/iris_probe.c +2 -2
index 34751912f871..34c981be9bc1 100644
@@ -43,8 +43,8 @@ static int iris_init_power_domains(struct iris_core *core)
 	int ret;
 
 	struct dev_pm_domain_attach_data iris_pd_data = {
-		.pd_names = core->iris_platform_data->pmdomain_tbl,
-		.num_pd_names = core->iris_platform_data->pmdomain_tbl_size,
+		.pd_names = core->iris_platform_data->pmdomain_tbl->pd_names,
+		.num_pd_names = core->iris_platform_data->pmdomain_tbl->pd_count,
 		.pd_flags = PD_FLAG_NO_DEV_LINK,
 	};
 
drivers/media/platform/qcom/iris/iris_resources.c +42 -2

62 lines not on this page · raw message

drivers/media/platform/qcom/iris/iris_resources.h +4 -2
index 6bfbd2dc6db0..d5692e4694b1 100644
@@ -9,11 +9,13 @@
 struct iris_core;
 
 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_enable_power_domains(struct iris_core *core, enum platform_pm_domain_type pd_type);
+int iris_disable_power_domains(struct iris_core *core, enum platform_pm_domain_type pd_type);
 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_genpd_set_hwmode(struct iris_core *core, enum platform_pm_domain_type pd_type,
+			  bool hwmode);
 
 #endif
drivers/media/platform/qcom/iris/iris_vpu3x.c +4 -5
index 1f0a3a47d87f..a9f43dbfc695 100644
@@ -208,7 +208,7 @@ static int iris_vpu33_power_off_controller(struct iris_core *core)
 	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_power_domains(core, IRIS_CTRL_POWER_DOMAIN);
 	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 
 	return 0;
@@ -218,8 +218,7 @@ 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_VCODEC_POWER_DOMAIN]);
+	ret = iris_enable_power_domains(core, IRIS_VCODEC_POWER_DOMAIN);
 	if (ret)
 		return ret;
 
@@ -235,7 +234,7 @@ static int iris_vpu35_power_on_hw(struct iris_core *core)
 	if (ret)
 		goto err_disable_hw_free_clk;
 
-	ret = dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN], true);
+	ret = iris_genpd_set_hwmode(core, IRIS_VCODEC_POWER_DOMAIN, true);
 	if (ret)
 		goto err_disable_hw_clk;
 
@@ -248,7 +247,7 @@ static int iris_vpu35_power_on_hw(struct iris_core *core)
 err_disable_axi_clk:
 	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 err_disable_power:
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
+	iris_disable_power_domains(core, IRIS_VCODEC_POWER_DOMAIN);
 
 	return ret;
 }
drivers/media/platform/qcom/iris/iris_vpu4x.c +19 -33

132 lines not on this page · raw message

drivers/media/platform/qcom/iris/iris_vpu_common.c +11 -12
index 006fd3ffc752..74b4dccd6a66 100644
@@ -214,15 +214,15 @@ int iris_vpu_power_off_controller(struct iris_core *core)
 	iris_disable_unprepare_clock(core, IRIS_AHB_CLK);
 	iris_disable_unprepare_clock(core, IRIS_CTRL_CLK);
 	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
+	iris_disable_power_domains(core, IRIS_CTRL_POWER_DOMAIN);
 
 	return 0;
 }
 
 void iris_vpu_power_off_hw(struct iris_core *core)
 {
-	dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN], false);
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
+	iris_genpd_set_hwmode(core, IRIS_VCODEC_POWER_DOMAIN, false);
+	iris_disable_power_domains(core, IRIS_VCODEC_POWER_DOMAIN);
 	iris_disable_unprepare_clock(core, IRIS_VCODEC_AHB_CLK);
 	iris_disable_unprepare_clock(core, IRIS_VCODEC_CLK);
 }
@@ -243,7 +243,7 @@ int iris_vpu_power_on_controller(struct iris_core *core)
 	u32 rst_tbl_size = core->iris_platform_data->clk_rst_tbl_size;
 	int ret;
 
-	ret = iris_enable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
+	ret = iris_enable_power_domains(core, IRIS_CTRL_POWER_DOMAIN);
 	if (ret)
 		return ret;
 
@@ -270,7 +270,7 @@ int iris_vpu_power_on_controller(struct iris_core *core)
 err_disable_axi_clock:
 	iris_disable_unprepare_clock(core, IRIS_AXI_VCODEC_CLK);
 err_disable_power:
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
+	iris_disable_power_domains(core, IRIS_CTRL_POWER_DOMAIN);
 
 	return ret;
 }
@@ -279,8 +279,7 @@ int iris_vpu_power_on_hw(struct iris_core *core)
 {
 	int ret;
 
-	ret = iris_enable_power_domains(core,
-					core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
+	ret = iris_enable_power_domains(core, IRIS_VCODEC_POWER_DOMAIN);
 	if (ret)
 		return ret;
 
@@ -292,7 +291,7 @@ int iris_vpu_power_on_hw(struct iris_core *core)
 	if (ret && ret != -ENOENT)
 		goto err_disable_hw_clock;
 
-	ret = dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN], true);
+	ret = iris_genpd_set_hwmode(core, IRIS_VCODEC_POWER_DOMAIN, true);
 	if (ret)
 		goto err_disable_hw_ahb_clock;
 
@@ -303,7 +302,7 @@ int iris_vpu_power_on_hw(struct iris_core *core)
 err_disable_hw_clock:
 	iris_disable_unprepare_clock(core, IRIS_VCODEC_CLK);
 err_disable_power:
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_VCODEC_POWER_DOMAIN]);
+	iris_disable_power_domains(core, IRIS_VCODEC_POWER_DOMAIN);
 
 	return ret;
 }
@@ -365,7 +364,7 @@ int iris_vpu35_vpu4x_power_off_controller(struct iris_core *core)
 	iris_disable_unprepare_clock(core, IRIS_CTRL_FREERUN_CLK);
 	iris_disable_unprepare_clock(core, IRIS_AXI_CTRL_CLK);
 
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
+	iris_disable_power_domains(core, IRIS_CTRL_POWER_DOMAIN);
 
 	reset_control_bulk_reset(clk_rst_tbl_size, core->resets);
 
@@ -376,7 +375,7 @@ int iris_vpu35_vpu4x_power_on_controller(struct iris_core *core)
 {
 	int ret;
 
-	ret = iris_enable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
+	ret = iris_enable_power_domains(core, IRIS_CTRL_POWER_DOMAIN);
 	if (ret)
 		return ret;
 
@@ -399,7 +398,7 @@ int iris_vpu35_vpu4x_power_on_controller(struct iris_core *core)
 err_disable_axi1_clk:
 	iris_disable_unprepare_clock(core, IRIS_AXI_CTRL_CLK);
 err_disable_power:
-	iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]);
+	iris_disable_power_domains(core, IRIS_CTRL_POWER_DOMAIN);
 
 	return ret;
 }
Signature · 1 line
2.34.1
#25 lore raw

PATCH v2 9/13 media: iris: Add power sequence for Glymur

In reply to Vishnu Reddy

Glymur has a secondary video codec core (vcodec1), equivalent to the primary core (vcodec0), but with independent power domains, clocks, and reset lines. Reuse the existing code wherever possible and add power sequence for vcodec1.

---
 .../platform/qcom/iris/iris_platform_common.h      |   4 +
 drivers/media/platform/qcom/iris/iris_vpu3x.c      | 122 +++++++++++++++++++++
 drivers/media/platform/qcom/iris/iris_vpu_common.h |   1 +
 .../platform/qcom/iris/iris_vpu_register_defines.h |   7 ++
 4 files changed, 134 insertions(+)
drivers/media/platform/qcom/iris/iris_platform_common.h +4 -0
index 7d59e6364e9d..8995136ad29e 100644
@@ -61,6 +61,9 @@ enum platform_clk_type {
 	IRIS_VPP0_HW_CLK,
 	IRIS_VPP1_HW_CLK,
 	IRIS_APV_HW_CLK,
+	IRIS_AXI_VCODEC1_CLK,
+	IRIS_VCODEC1_CLK,
+	IRIS_VCODEC1_FREERUN_CLK,
 };
 
 struct platform_clk_data {
@@ -210,6 +213,7 @@ enum platform_pm_domain_type {
 	IRIS_VPP0_HW_POWER_DOMAIN,
 	IRIS_VPP1_HW_POWER_DOMAIN,
 	IRIS_APV_HW_POWER_DOMAIN,
+	IRIS_VCODEC1_POWER_DOMAIN,
 };
 
 struct platform_pd_data {
drivers/media/platform/qcom/iris/iris_vpu3x.c +122 -0

137 lines not on this page · raw message

drivers/media/platform/qcom/iris/iris_vpu_common.h +1 -0
index f6dffc613b82..99e75fb4b10d 100644
@@ -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 +7 -0
index 72168b9ffa73..37f234484f1b 100644
@@ -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,11 +57,13 @@
 #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)
Signature · 1 line
2.34.1
#26 lore raw

PATCH v2 10/13 media: iris: Add support to select core for dual core platforms

In reply to Vishnu Reddy

On platforms with dual vcodec cores, select the hardware core for a session based on current load. Assign the session to vcodec0 if its MBPF/MBPS capacity allows it, otherwise assign to vcodec1. Communicate the selected core to firmware using the new HFI_PROP_CORE_ID property.

---
 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 +
 .../platform/qcom/iris/iris_platform_common.h      |  1 +
 drivers/media/platform/qcom/iris/iris_power.c      | 11 ++-
 drivers/media/platform/qcom/iris/iris_utils.c      | 87 +++++++++++++++++-----
 drivers/media/platform/qcom/iris/iris_vb2.c        |  4 +
 drivers/media/platform/qcom/iris/iris_vidc.c       |  6 +-
 12 files changed, 123 insertions(+), 25 deletions(-)
drivers/media/platform/qcom/iris/iris_common.c +10 -0
index 7f1c7fe144f7..3b3fc482e194 100644
@@ -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_command_ops *hfi_ops = inst->core->hfi_ops;
+
+	if (!inst->core->iris_platform_data->dual_core)
+		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_command_ops *hfi_ops = inst->core->hfi_ops;
drivers/media/platform/qcom/iris/iris_common.h +1 -0
index b2a27b781c9a..34e32c60f768 100644
@@ -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
index b396c8cf595e..54a8649841e4 100644
@@ -30,6 +30,11 @@ enum domain_type {
 	DECODER	= BIT(1),
 };
 
+enum iris_vcodec_core_id {
+	IRIS_VCODEC0 = 1,
+	IRIS_VCODEC1,
+};
+
 /**
  * struct iris_core - holds core parameters valid for all instances
  *
drivers/media/platform/qcom/iris/iris_hfi_common.h +1 -0
index 3edb5ae582b4..fbaf852a6b99 100644
@@ -124,6 +124,7 @@ struct iris_hfi_command_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 iris_hfi_response_ops {
drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +19 -0
index 30bfd90d423b..9d9fae587297 100644
@@ -1300,6 +1300,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_command_ops iris_hfi_gen2_command_ops = {
 	.sys_init = iris_hfi_gen2_sys_init,
 	.sys_image_version = iris_hfi_gen2_sys_image_version,
@@ -1317,6 +1335,7 @@ static const struct iris_hfi_command_ops iris_hfi_gen2_command_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,
 };
 
 void iris_hfi_gen2_command_ops_init(struct iris_core *core)
drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +1 -0
index cecf771c55dd..600e9dc07669 100644
@@ -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			0x030001a9
 
 enum hfi_rate_control {
 	HFI_RC_VBR_CFR		= 0x00000000,
drivers/media/platform/qcom/iris/iris_instance.h +2 -0
index 16965150f427..dd341ca5be57 100644
@@ -37,6 +37,7 @@ struct iris_fmt {
  *
  * @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
  * @ctx_q_lock: lock to serialize queues related ioctls
  * @lock: lock to seralise forward and reverse threads
@@ -79,6 +80,7 @@ struct iris_fmt {
 struct iris_inst {
 	struct list_head		list;
 	struct iris_core		*core;
+	u32				core_id;
 	u32				session_id;
 	struct mutex			ctx_q_lock;/* lock to serialize queues related ioctls */
 	struct mutex			lock; /* lock to serialize forward and reverse threads */
drivers/media/platform/qcom/iris/iris_platform_common.h +1 -0
index 8995136ad29e..502d7099085c 100644
@@ -258,6 +258,7 @@ struct iris_platform_data {
 	const struct tz_cp_config *tz_cp_config_data;
 	u32 tz_cp_config_data_size;
 	u32 core_arch;
+	bool dual_core;
 	u32 hw_response_timeout;
 	struct ubwc_config_data *ubwc_config;
 	u32 num_vpp_pipe;
drivers/media/platform/qcom/iris/iris_power.c +7 -4
index 91aa21d4070e..0e116c63f529 100644
@@ -77,9 +77,9 @@ static int iris_vote_interconnects(struct iris_inst *inst)
 
 static int iris_set_clocks(struct iris_inst *inst)
 {
+	u64 vcodec0_freq = 0, vcodec1_freq = 0;
 	struct iris_core *core = inst->core;
 	struct iris_inst *instance;
-	u64 freq = 0;
 	int ret;
 
 	mutex_lock(&core->lock);
@@ -87,11 +87,14 @@ static int iris_set_clocks(struct iris_inst *inst)
 		if (!instance->max_input_data_size)
 			continue;
 
-		freq += instance->power.min_freq;
+		if (instance->core_id == IRIS_VCODEC0)
+			vcodec0_freq += instance->power.min_freq;
+		else if (instance->core_id == IRIS_VCODEC1)
+			vcodec1_freq += instance->power.min_freq;
 	}
 
-	core->power.clk_freq = freq;
-	ret = iris_opp_set_rate(core->dev, freq);
+	core->power.clk_freq = vcodec0_freq > vcodec1_freq ? vcodec0_freq : vcodec1_freq;
+	ret = iris_opp_set_rate(core->dev, core->power.clk_freq);
 	mutex_unlock(&core->lock);
 
 	return ret;
drivers/media/platform/qcom/iris/iris_utils.c +67 -20

107 lines not on this page · raw message

drivers/media/platform/qcom/iris/iris_vb2.c +4 -0
index bf0b8400996e..5a05f7d65501 100644
@@ -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
index bd38d84c9cc7..eb167cede4c0 100644
@@ -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)
 {
+	u32 max_session_count = inst->core->iris_platform_data->max_session_count;
 	struct iris_core *core = inst->core;
 	struct iris_inst *iter;
 	u32 count = 0;
 
+	if (inst->core->iris_platform_data->dual_core)
+		max_session_count *= 2;
+
 	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);
Signature · 1 line
2.34.1
#27 lore raw

PATCH v2 11/13 media: iris: Select DMA_CONTEXT_BUS to create firmware device

In reply to Vishnu Reddy

Iris need a firmware device to enable secure PAS (peripheral authentication service) support in case of non-Gunyah. This device requires its own IOMMU context for memory isolation. The generic dma-context-bus provides the infrastructure to create the device and configure its firmware stream ID.

Select DMA_CONTEXT_BUS to ensure this bus is available when VIDEO_QCOM_IRIS is enabled.

---
 drivers/media/platform/qcom/iris/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/qcom/iris/Kconfig +1 -0
index 3c803a05305a..de1fc4b07ff8 100644
@@ -6,6 +6,7 @@ config VIDEO_QCOM_IRIS
         select QCOM_MDT_LOADER if ARCH_QCOM
         select QCOM_SCM
         select VIDEOBUF2_DMA_CONTIG
+        select DMA_CONTEXT_BUS
         help
           This is a V4L2 driver for Qualcomm iris video accelerator
           hardware. It accelerates decoding operations on various
Signature · 1 line
2.34.1
#28 lore raw

Re: [PATCH v2 11/13] media: iris: Select DMA_CONTEXT_BUS to create firmware device

Quoted 2 lines · Vishnu Reddy

Iris need a firmware device to enable secure PAS (peripheral authentication service) support in case of non-Gunyah.

As gunyah isn't ever going upstream, why is this an issue here for us at all?

confused,

greg k-h

#29 lore raw

Re: [PATCH v2 11/13] media: iris: Select DMA_CONTEXT_BUS to create firmware device

Quoted 6 lines · Greg Kroah-Hartman
Quoted 2 lines · Vishnu Reddy

Iris need a firmware device to enable secure PAS (peripheral authentication service) support in case of non-Gunyah.

As gunyah isn't ever going upstream, why is this an issue here for us at all?

Vishnu, this is a nice example of why we are always asking for the complete commit message, describing the problem that you are solving. You gave zero context for people outside of your group who don't have a knowledge of your issue.

Please start thinking from the reviewers point of view. Or consider yourself being an engineer in 5 years wishing to change that code and trying to understand, would you break something if you do this or that. You need to explain, explain and explain things.

For example (please correct it, it is based on my incomplete understanding):

If Linux is run under the Gunyah control, the hypervisor will set up the SMMU SID for loading the firware (and protect it from being touched by te OS). If Linux is running in EL2 without Gunyah in play, it needs to take care of that setup. Since loading the firmware requires separate address mapping, corresponding SID is describing in DT as one of the functions inside the iommu-map property. Create the child device that will be used for allocating DMA buffers for the firmware and mapping them to the correct SID.

Please review all your commit messages from this position and adjust / rewrite them as necessary.

Signature · 2 lines
With best wishes
Dmitry
#30 lore raw

PATCH v2 12/13 media: iris: Add platform data for glymur

In reply to Vishnu Reddy

Add glymur platform data by reusing most of the SM8550 definitions. Move configuration that differs in a per-SoC platform specific data.

---
 drivers/media/platform/qcom/iris/Makefile          |  1 +
 .../platform/qcom/iris/iris_platform_common.h      |  5 ++
 .../media/platform/qcom/iris/iris_platform_gen2.c  | 99 ++++++++++++++++++++++
 .../platform/qcom/iris/iris_platform_glymur.c      | 97 +++++++++++++++++++++
 .../platform/qcom/iris/iris_platform_glymur.h      | 17 ++++
 drivers/media/platform/qcom/iris/iris_probe.c      |  4 +
 6 files changed, 223 insertions(+)
drivers/media/platform/qcom/iris/Makefile +1 -0
index 2abbd3aeb4af..2a50f3cafc38 100644
@@ -11,6 +11,7 @@ qcom-iris-objs += iris_buffer.o \
              iris_hfi_gen2_response.o \
              iris_hfi_queue.o \
              iris_platform_gen2.o \
+             iris_platform_glymur.o \
              iris_power.o \
              iris_probe.o \
              iris_resources.o \
drivers/media/platform/qcom/iris/iris_platform_common.h +5 -0
index 502d7099085c..2003b7186480 100644
@@ -30,6 +30,10 @@ struct iris_inst;
 #define DEFAULT_QP				20
 #define BITRATE_DEFAULT			20000000
 
+#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,
@@ -41,6 +45,7 @@ enum pipe_type {
 	PIPE_4 = 4,
 };
 
+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_gen2.c +99 -0

111 lines not on this page · raw message

drivers/media/platform/qcom/iris/iris_platform_glymur.c new file +97 -0

97 lines not on this page · raw message

drivers/media/platform/qcom/iris/iris_platform_glymur.h new file +17 -0
new file mode 100644
index 000000000000..e0d07ccf658c
@@ -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 platform_clk_data iris_glymur_clk_table[9];
+extern const char * const iris_glymur_clk_reset_table[6];
+extern const char * const iris_glymur_opp_clk_table[4];
+extern const struct platform_pd_data iris_glymur_pmdomain_table;
+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_probe.c +4 -0
index 34c981be9bc1..78e3627557e9 100644
@@ -369,6 +369,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,
Signature · 1 line
2.34.1
#31 lore raw

Re: [PATCH v2 12/13] media: iris: Add platform data for glymur

Quoted 2 lines · Vishnu Reddy

Add glymur platform data by reusing most of the SM8550 definitions. Move configuration that differs in a per-SoC platform specific data.

As a continuation to the previous patch. Compare your commit message to:

On the Glymur platform Iris core shares most of the properties with the Iris core on the SM8550 platform. The major differences come from Glymur using two cores, wile SM8550 had only one codec core inside Iris. Add glymur-specific platform data, reusing SM8550 definitions where it makes sense.

Even for such small change it is much easier to first describe why you are going to perform your changes in a certain way.

Quoted 2 lines
Signature · 2 lines
With best wishes
Dmitry
#32 lore raw

PATCH v2 13/13 arm64: dts: qcom: glymur: Add iris video node

In reply to 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.

---
 arch/arm64/boot/dts/qcom/glymur-crd.dts |   4 ++
 arch/arm64/boot/dts/qcom/glymur.dtsi    | 118 ++++++++++++++++++++++++++++++++
 2 files changed, 122 insertions(+)
arch/arm64/boot/dts/qcom/glymur-crd.dts +4 -0
index 35aaf09e4e2b..cbc9856956ff 100644
@@ -255,6 +255,10 @@ &mdss_dp3_phy {
 	status = "okay";
 };
 
+&iris {
+	status = "okay";
+};
+
 &pmh0110_f_e0_gpios {
 	misc_3p3_reg_en: misc-3p3-reg-en-state {
 		pins = "gpio6";
arch/arm64/boot/dts/qcom/glymur.dtsi +118 -0

130 lines not on this page · raw message

Signature · 1 line
2.34.1