* [PATCH 0/2] media: qcom: Fix iova allocation from restrict region
@ 2026-08-12 10:55 Vishnu Reddy
2026-08-12 10:55 ` [PATCH 1/2] media: iris: " Vishnu Reddy
2026-08-12 10:55 ` [PATCH 2/2] media: venus: " Vishnu Reddy
0 siblings, 2 replies; 10+ messages in thread
From: Vishnu Reddy @ 2026-08-12 10:55 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil,
Stefan Schmidt, Stanimir Varbanov
Cc: linux-media, linux-arm-msm, linux-kernel, Vishnu Reddy, stable
The VPU issues DMA through several SMMU streams, and the hardware does
not give every stream the same addressable range. The non-pixel stream
cannot address the low 600MB of IOVA space, while the pixel stream can
address the full range:
+-----------------------------------------------------------+
| non-pixel stream addressable range (600 MB - 3.5 GB) |
| 0x25800000 - 0xe0000000 |
+-----------------------------------------------------------+
| pixel stream addressable range (0 - 3.5 GB) |
| 0x00000000 - 0xe0000000 |
+-----------------------------------------------------------+
A single "iommus" property on the video-codec node puts every stream
in one IOMMU domain sharing one IOVA allocator, so nothing restricts a
non-pixel buffer to avoid 0 to 600MB. Once an allocation lands below that
boundary the hardware faults, which shows up as unhandled SMMU page
faults and spontaneous reboots.
https://gitlab.freedesktop.org/drm/msm/-/work_items/100
A series to reserve the 0-600MB IOVA range via "iommu-addresses" was
already posted here:
https://lore.kernel.org/all/20260807-iris_iova_600mb_fix-v1-0-3996f67e33f9@oss.qualcomm.com
Those changes involve DT binding and DT node changes, and discussion is
still ongoing on how to handle those for stable and for the upcoming
sub-node design, with no conclusion reached yet. Thereby a critical reset
issue is still open.
This is an alternate solution to fix the unhandled SMMU page fault
by restricting the IOVA range in the video driver, which also makes it
easier and faster to land on mainline and stable kernels.
Currently sub-nodes are not yet present, and only a single device is
available, so the restriction is applied to both non-pixel and pixel
stream IDs. This makes the solution unoptimal while fixing the issue
considering all scenarios.
Once sub-nodes for non-pixel, pixel, and secure streams become available,
the restriction can be made stream specific.
Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
---
Vishnu Reddy (2):
media: iris: Fix iova allocation from restrict region
media: venus: Fix iova allocation from restrict region
drivers/media/platform/qcom/iris/iris_core.h | 6 +++
drivers/media/platform/qcom/iris/iris_probe.c | 69 +++++++++++++++++++++++++-
drivers/media/platform/qcom/venus/core.c | 71 ++++++++++++++++++++++++++-
drivers/media/platform/qcom/venus/core.h | 5 ++
4 files changed, 148 insertions(+), 3 deletions(-)
---
base-commit: 5e6de6a2b522f659defacb1551d0465ba6ce13cf
change-id: 20260812-reserve_iova_in_driver-855b388cbb29
Best regards,
--
Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 1/2] media: iris: Fix iova allocation from restrict region 2026-08-12 10:55 [PATCH 0/2] media: qcom: Fix iova allocation from restrict region Vishnu Reddy @ 2026-08-12 10:55 ` Vishnu Reddy 2026-08-14 14:41 ` Vikash Garodia ` (2 more replies) 2026-08-12 10:55 ` [PATCH 2/2] media: venus: " Vishnu Reddy 1 sibling, 3 replies; 10+ messages in thread From: Vishnu Reddy @ 2026-08-12 10:55 UTC (permalink / raw) To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil, Stefan Schmidt, Stanimir Varbanov Cc: linux-media, linux-arm-msm, linux-kernel, Vishnu Reddy, stable The VPU issues DMA through several SMMU streams, and the hardware does not give every stream the same addressable range. The non-pixel stream cannot address the low 600MB of IOVA space, while the pixel stream can address the full range: +-----------------------------------------------------------+ | non-pixel stream addressable range (600 MB - 3.5 GB) | | 0x25800000 - 0xe0000000 | +-----------------------------------------------------------+ | pixel stream addressable range (0 - 3.5 GB) | | 0x00000000 - 0xe0000000 | +-----------------------------------------------------------+ A single "iommus" property on the video-codec node puts every stream in one IOMMU domain sharing one IOVA allocator, so nothing restricts a non-pixel buffer to avoid 0 to 600MB. Once an allocation lands below that boundary the hardware faults, which shows up as unhandled SMMU page faults and spontaneous reboots. https://gitlab.freedesktop.org/drm/msm/-/work_items/100 A series to reserve the 0-600MB IOVA range via "iommu-addresses" was already posted here: https://lore.kernel.org/all/20260807-iris_iova_600mb_fix-v1-0-3996f67e33f9@oss.qualcomm.com Those changes involve DT binding and DT node changes, and discussion is still ongoing on how to handle those for stable and for the upcoming sub-node design, with no conclusion reached yet. Thereby a critical reset issue is still open. This is an alternate solution to fix the unhandled SMMU page fault by restricting the IOVA range in the video driver, which also makes it easier and faster to land on mainline and stable kernels. At the same time the patch only reserves in the IOVA space without allocating any physical memory. Currently sub-nodes are not yet present, and only a single device is available, so the restriction is applied to both non-pixel and pixel stream IDs. This makes the solution unoptimal while fixing the issue considering all scenarios. Once sub-nodes for non-pixel, pixel, and secure streams become available, the restriction can be made stream specific. Fixes: d7378f84e94e ("media: iris: introduce iris core state management with shared queues") Cc: stable@vger.kernel.org Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com> --- drivers/media/platform/qcom/iris/iris_core.h | 6 +++ drivers/media/platform/qcom/iris/iris_probe.c | 69 ++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/platform/qcom/iris/iris_core.h index 24da60448cf2..79bc342a25a2 100644 --- a/drivers/media/platform/qcom/iris/iris_core.h +++ b/drivers/media/platform/qcom/iris/iris_core.h @@ -7,6 +7,7 @@ #define __IRIS_CORE_H__ #include <linux/types.h> +#include <linux/dma-mapping.h> #include <linux/pm_domain.h> #include <media/v4l2-device.h> @@ -25,6 +26,9 @@ struct icc_info { #define IRIS_FW_VERSION_LENGTH 128 #define IFACEQ_CORE_PKT_SIZE (1024 * 4) +#define IRIS_NP_RESERVE_IOVA_START 0x0 +#define IRIS_NP_RESERVE_IOVA_SIZE 0x25800000 + enum domain_type { ENCODER = BIT(0), DECODER = BIT(1), @@ -77,6 +81,7 @@ struct qcom_ubwc_cfg_data; * @instances: a list_head of all instances * @inst_fw_caps_dec: an array of supported instance capabilities by decoder * @inst_fw_caps_enc: an array of supported instance capabilities by encoder + * @iova_state: an array of dma_iova_state entries reserved for the restricted IOVA region */ struct iris_core { @@ -123,6 +128,7 @@ struct iris_core { /* encoder and decoder have overlapping caps, so two different arrays are required */ struct platform_inst_fw_cap inst_fw_caps_dec[INST_FW_CAP_MAX]; struct platform_inst_fw_cap inst_fw_caps_enc[INST_FW_CAP_MAX]; + struct dma_iova_state *iova_state; }; int iris_core_init(struct iris_core *core); diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/platform/qcom/iris/iris_probe.c index e4acf4a74f94..f44305ee81b6 100644 --- a/drivers/media/platform/qcom/iris/iris_probe.c +++ b/drivers/media/platform/qcom/iris/iris_probe.c @@ -150,6 +150,64 @@ static int iris_init_resources(struct iris_core *core) return iris_init_resets(core); } +static int iris_reserve_iova_region(struct device *dev, struct dma_iova_state **iova_state, + unsigned long start, unsigned long size) +{ + unsigned long mask = dma_get_mask(dev); + unsigned long end, rem, chunk; + struct dma_iova_state *state; + unsigned int count = 0; + int ret; + + state = kcalloc(BITS_PER_TYPE(dma_addr_t) + 1, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + end = start + size; + rem = end - max(start, PAGE_SIZE); + + ret = dma_set_mask_and_coherent(dev, end - 1); + if (ret) + goto err_free_mem; + + while (rem) { + chunk = min(end & -end, (u64)1 << (fls64(rem) - 1)); + + if (!dma_iova_try_alloc(dev, &state[count], 0, chunk)) { + ret = -ENOMEM; + goto err_free_iova; + } + + rem -= chunk; + end -= chunk; + count++; + } + + *iova_state = state; + dma_set_mask_and_coherent(dev, mask); + + return 0; + +err_free_iova: + while (count--) + dma_iova_free(dev, &state[count]); + dma_set_mask_and_coherent(dev, mask); +err_free_mem: + kfree(state); + + return ret; +} + +static void iris_unreserve_iova_region(struct device *dev, struct dma_iova_state *iova_state) +{ + unsigned int i; + + for (i = 0; dma_iova_size(&iova_state[i]); i++) + dma_iova_free(dev, &iova_state[i]); + + kfree(iova_state); +} + static int iris_register_video_device(struct iris_core *core, enum domain_type type) { struct video_device *vdev; @@ -207,6 +265,8 @@ static void iris_remove(struct platform_device *pdev) v4l2_device_unregister(&core->v4l2_dev); + iris_unreserve_iova_region(core->dev, core->iova_state); + mutex_destroy(&core->lock); } @@ -292,14 +352,21 @@ static int iris_probe(struct platform_device *pdev) dma_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); dma_set_seg_boundary(&pdev->dev, DMA_BIT_MASK(32)); + ret = iris_reserve_iova_region(dev, &core->iova_state, IRIS_NP_RESERVE_IOVA_START, + IRIS_NP_RESERVE_IOVA_SIZE); + if (ret) + goto err_vdev_unreg_enc; + pm_runtime_set_autosuspend_delay(core->dev, AUTOSUSPEND_DELAY_VALUE); pm_runtime_use_autosuspend(core->dev); ret = devm_pm_runtime_enable(core->dev); if (ret) - goto err_vdev_unreg_enc; + goto err_unresv_iova_region; return 0; +err_unresv_iova_region: + iris_unreserve_iova_region(dev, core->iova_state); err_vdev_unreg_enc: video_unregister_device(core->vdev_enc); err_vdev_unreg_dec: -- 2.34.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] media: iris: Fix iova allocation from restrict region 2026-08-12 10:55 ` [PATCH 1/2] media: iris: " Vishnu Reddy @ 2026-08-14 14:41 ` Vikash Garodia 2026-08-18 6:49 ` Dmitry Baryshkov 2026-08-18 10:19 ` Bryan O'Donoghue 2 siblings, 0 replies; 10+ messages in thread From: Vikash Garodia @ 2026-08-14 14:41 UTC (permalink / raw) To: Vishnu Reddy, Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil, Stefan Schmidt, Stanimir Varbanov Cc: linux-media, linux-arm-msm, linux-kernel, stable On 8/12/2026 4:25 PM, Vishnu Reddy wrote: > The VPU issues DMA through several SMMU streams, and the hardware does > not give every stream the same addressable range. The non-pixel stream > cannot address the low 600MB of IOVA space, while the pixel stream can > address the full range: > +-----------------------------------------------------------+ > | non-pixel stream addressable range (600 MB - 3.5 GB) | > | 0x25800000 - 0xe0000000 | > +-----------------------------------------------------------+ > | pixel stream addressable range (0 - 3.5 GB) | > | 0x00000000 - 0xe0000000 | > +-----------------------------------------------------------+ > A single "iommus" property on the video-codec node puts every stream > in one IOMMU domain sharing one IOVA allocator, so nothing restricts a > non-pixel buffer to avoid 0 to 600MB. Once an allocation lands below that > boundary the hardware faults, which shows up as unhandled SMMU page > faults and spontaneous reboots. > https://gitlab.freedesktop.org/drm/msm/-/work_items/100 > > A series to reserve the 0-600MB IOVA range via "iommu-addresses" was > already posted here: > https://lore.kernel.org/all/20260807-iris_iova_600mb_fix- > v1-0-3996f67e33f9@oss.qualcomm.com > > Those changes involve DT binding and DT node changes, and discussion is > still ongoing on how to handle those for stable and for the upcoming > sub-node design, with no conclusion reached yet. Thereby a critical reset > issue is still open. > > This is an alternate solution to fix the unhandled SMMU page fault > by restricting the IOVA range in the video driver, which also makes it > easier and faster to land on mainline and stable kernels. At the same > time the patch only reserves in the IOVA space without allocating > any physical memory. > > Currently sub-nodes are not yet present, and only a single device is > available, so the restriction is applied to both non-pixel and pixel > stream IDs. This makes the solution unoptimal while fixing the issue > considering all scenarios. > Once sub-nodes for non-pixel, pixel, and secure streams become available, > the restriction can be made stream specific. > > Fixes: d7378f84e94e ("media: iris: introduce iris core state management with shared queues") > Cc:stable@vger.kernel.org > Signed-off-by: Vishnu Reddy<busanna.reddy@oss.qualcomm.com> > --- > drivers/media/platform/qcom/iris/iris_core.h | 6 +++ > drivers/media/platform/qcom/iris/iris_probe.c | 69 ++++++++++++++++++++++++++- > 2 files changed, 74 insertions(+), 1 deletion(-) Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] media: iris: Fix iova allocation from restrict region 2026-08-12 10:55 ` [PATCH 1/2] media: iris: " Vishnu Reddy 2026-08-14 14:41 ` Vikash Garodia @ 2026-08-18 6:49 ` Dmitry Baryshkov 2026-08-18 10:19 ` Bryan O'Donoghue 2 siblings, 0 replies; 10+ messages in thread From: Dmitry Baryshkov @ 2026-08-18 6:49 UTC (permalink / raw) To: Vishnu Reddy Cc: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil, Stefan Schmidt, Stanimir Varbanov, linux-media, linux-arm-msm, linux-kernel, stable On Wed, Aug 12, 2026 at 04:25:58PM +0530, Vishnu Reddy wrote: > The VPU issues DMA through several SMMU streams, and the hardware does > not give every stream the same addressable range. The non-pixel stream > cannot address the low 600MB of IOVA space, while the pixel stream can > address the full range: > +-----------------------------------------------------------+ > | non-pixel stream addressable range (600 MB - 3.5 GB) | > | 0x25800000 - 0xe0000000 | > +-----------------------------------------------------------+ > | pixel stream addressable range (0 - 3.5 GB) | > | 0x00000000 - 0xe0000000 | > +-----------------------------------------------------------+ > A single "iommus" property on the video-codec node puts every stream > in one IOMMU domain sharing one IOVA allocator, so nothing restricts a > non-pixel buffer to avoid 0 to 600MB. Once an allocation lands below that > boundary the hardware faults, which shows up as unhandled SMMU page > faults and spontaneous reboots. > https://gitlab.freedesktop.org/drm/msm/-/work_items/100 > > A series to reserve the 0-600MB IOVA range via "iommu-addresses" was > already posted here: > https://lore.kernel.org/all/20260807-iris_iova_600mb_fix-v1-0-3996f67e33f9@oss.qualcomm.com > > Those changes involve DT binding and DT node changes, and discussion is > still ongoing on how to handle those for stable and for the upcoming > sub-node design, with no conclusion reached yet. Thereby a critical reset > issue is still open. > > This is an alternate solution to fix the unhandled SMMU page fault > by restricting the IOVA range in the video driver, which also makes it > easier and faster to land on mainline and stable kernels. At the same > time the patch only reserves in the IOVA space without allocating > any physical memory. > > Currently sub-nodes are not yet present, and only a single device is > available, so the restriction is applied to both non-pixel and pixel > stream IDs. This makes the solution unoptimal while fixing the issue > considering all scenarios. > Once sub-nodes for non-pixel, pixel, and secure streams become available, > the restriction can be made stream specific. > > Fixes: d7378f84e94e ("media: iris: introduce iris core state management with shared queues") > Cc: stable@vger.kernel.org > Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com> > --- > drivers/media/platform/qcom/iris/iris_core.h | 6 +++ > drivers/media/platform/qcom/iris/iris_probe.c | 69 ++++++++++++++++++++++++++- > 2 files changed, 74 insertions(+), 1 deletion(-) > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] media: iris: Fix iova allocation from restrict region 2026-08-12 10:55 ` [PATCH 1/2] media: iris: " Vishnu Reddy 2026-08-14 14:41 ` Vikash Garodia 2026-08-18 6:49 ` Dmitry Baryshkov @ 2026-08-18 10:19 ` Bryan O'Donoghue 2 siblings, 0 replies; 10+ messages in thread From: Bryan O'Donoghue @ 2026-08-18 10:19 UTC (permalink / raw) To: Vishnu Reddy, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar, Mauro Carvalho Chehab, Hans Verkuil, Stefan Schmidt, Stanimir Varbanov Cc: linux-media, linux-arm-msm, linux-kernel, stable On 12/08/2026 11:55, Vishnu Reddy wrote: > The VPU issues DMA through several SMMU streams, and the hardware does > not give every stream the same addressable range. The non-pixel stream > cannot address the low 600MB of IOVA space, while the pixel stream can > address the full range: > +-----------------------------------------------------------+ > | non-pixel stream addressable range (600 MB - 3.5 GB) | > | 0x25800000 - 0xe0000000 | > +-----------------------------------------------------------+ > | pixel stream addressable range (0 - 3.5 GB) | > | 0x00000000 - 0xe0000000 | > +-----------------------------------------------------------+ > A single "iommus" property on the video-codec node puts every stream > in one IOMMU domain sharing one IOVA allocator, so nothing restricts a > non-pixel buffer to avoid 0 to 600MB. Once an allocation lands below that > boundary the hardware faults, which shows up as unhandled SMMU page > faults and spontaneous reboots. > https://gitlab.freedesktop.org/drm/msm/-/work_items/100 > > A series to reserve the 0-600MB IOVA range via "iommu-addresses" was > already posted here: > https://lore.kernel.org/all/20260807-iris_iova_600mb_fix-v1-0-3996f67e33f9@oss.qualcomm.com Something for a cover letter not a commit log - ongoing debates about how to change the behaviour will be irrelevant in 15 years after this stuff has landed. The commit log should - State the problem - State the fix Additional narrative about other series is for the series overview not the commit log. > Those changes involve DT binding and DT node changes, and discussion is > still ongoing on how to handle those for stable and for the upcoming > sub-node design, with no conclusion reached yet. Thereby a critical reset > issue is still open. Drop. > This is an alternate solution to fix the unhandled SMMU page fault Kill this "alternative solution" stuff - if this lands in mainline then this _is_ the solution unless/until it is superseded. > by restricting the IOVA range in the video driver, which also makes it > easier and faster to land on mainline and stable kernels. At the same > time the patch only reserves in the IOVA space without allocating > any physical memory. You should specify how you are making that restriction in the commit log. Reading code... OK you reserve below the boundary. Please add that to the commit log, its the salient piece of information. > > Currently sub-nodes are not yet present, and only a single device is > available, so the restriction is applied to both non-pixel and pixel > stream IDs. This makes the solution unoptimal while fixing the issue > considering all scenarios. > Once sub-nodes for non-pixel, pixel, and secure streams become available, > the restriction can be made stream specific. Yeah all good information for the overview but if someone lands from Trantor in 10,000 years to pick through the detritus of our civilisation finding an old computer with kernel version 55.20 running on it and no sign of venus sub-nodes they might march off to the next planet to try to find them. Drop the sub-nodes discussion from your commit log. Clearly state the problem and its remediation in your log, no need to reference ongoing bikeshedding elsewhere. > > Fixes: d7378f84e94e ("media: iris: introduce iris core state management with shared queues") > Cc: stable@vger.kernel.org > Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com> > --- > drivers/media/platform/qcom/iris/iris_core.h | 6 +++ > drivers/media/platform/qcom/iris/iris_probe.c | 69 ++++++++++++++++++++++++++- > 2 files changed, 74 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/platform/qcom/iris/iris_core.h > index 24da60448cf2..79bc342a25a2 100644 > --- a/drivers/media/platform/qcom/iris/iris_core.h > +++ b/drivers/media/platform/qcom/iris/iris_core.h > @@ -7,6 +7,7 @@ > #define __IRIS_CORE_H__ > > #include <linux/types.h> > +#include <linux/dma-mapping.h> > #include <linux/pm_domain.h> > #include <media/v4l2-device.h> > > @@ -25,6 +26,9 @@ struct icc_info { > #define IRIS_FW_VERSION_LENGTH 128 > #define IFACEQ_CORE_PKT_SIZE (1024 * 4) > > +#define IRIS_NP_RESERVE_IOVA_START 0x0 > +#define IRIS_NP_RESERVE_IOVA_SIZE 0x25800000 > + > enum domain_type { > ENCODER = BIT(0), > DECODER = BIT(1), > @@ -77,6 +81,7 @@ struct qcom_ubwc_cfg_data; > * @instances: a list_head of all instances > * @inst_fw_caps_dec: an array of supported instance capabilities by decoder > * @inst_fw_caps_enc: an array of supported instance capabilities by encoder > + * @iova_state: an array of dma_iova_state entries reserved for the restricted IOVA region > */ > > struct iris_core { > @@ -123,6 +128,7 @@ struct iris_core { > /* encoder and decoder have overlapping caps, so two different arrays are required */ > struct platform_inst_fw_cap inst_fw_caps_dec[INST_FW_CAP_MAX]; > struct platform_inst_fw_cap inst_fw_caps_enc[INST_FW_CAP_MAX]; > + struct dma_iova_state *iova_state; > }; > > int iris_core_init(struct iris_core *core); > diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/platform/qcom/iris/iris_probe.c > index e4acf4a74f94..f44305ee81b6 100644 > --- a/drivers/media/platform/qcom/iris/iris_probe.c > +++ b/drivers/media/platform/qcom/iris/iris_probe.c > @@ -150,6 +150,64 @@ static int iris_init_resources(struct iris_core *core) > return iris_init_resets(core); > } > > +static int iris_reserve_iova_region(struct device *dev, struct dma_iova_state **iova_state, > + unsigned long start, unsigned long size) > +{ > + unsigned long mask = dma_get_mask(dev); > + unsigned long end, rem, chunk; > + struct dma_iova_state *state; > + unsigned int count = 0; > + int ret; > + > + state = kcalloc(BITS_PER_TYPE(dma_addr_t) + 1, sizeof(*state), GFP_KERNEL); > + if (!state) > + return -ENOMEM; devm_kcalloc() is less work. > + > + end = start + size; > + rem = end - max(start, PAGE_SIZE); > + > + ret = dma_set_mask_and_coherent(dev, end - 1); > + if (ret) > + goto err_free_mem; I believe you should set dev->bus_dma_limit instead so drop this mask operation. drivers/ata/ahci.c: * bogus, platform code should use dev->bus_dma_limit instead.. => dev->bus_dma_limit = IRIS_NP_RESERVE_IOVA_SIZE -1; > + > + while (rem) { > + chunk = min(end & -end, (u64)1 << (fls64(rem) - 1)); > + if (!dma_iova_try_alloc(dev, &state[count], 0, chunk)) { > + ret = -ENOMEM; > + goto err_free_iova; > + } > + check that state[count].addr == end - chunk error out if it does not. > + rem -= chunk; > + end -= chunk; > + count++; > + } > + > + *iova_state = state; > + dma_set_mask_and_coherent(dev, mask); > + > + return 0; > + > +err_free_iova: > + while (count--) > + dma_iova_free(dev, &state[count]); > + dma_set_mask_and_coherent(dev, mask); \n> +err_free_mem: > + kfree(state); > + > + return ret; > +} > + > +static void iris_unreserve_iova_region(struct device *dev, struct dma_iova_state *iova_state) > +{ > + unsigned int i; > + > + for (i = 0; dma_iova_size(&iova_state[i]); i++) > + dma_iova_free(dev, &iova_state[i]); > + > + kfree(iova_state); > +} > + > static int iris_register_video_device(struct iris_core *core, enum domain_type type) > { > struct video_device *vdev; > @@ -207,6 +265,8 @@ static void iris_remove(struct platform_device *pdev) > > v4l2_device_unregister(&core->v4l2_dev); > > + iris_unreserve_iova_region(core->dev, core->iova_state); > + > mutex_destroy(&core->lock); > } > > @@ -292,14 +352,21 @@ static int iris_probe(struct platform_device *pdev) > dma_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); > dma_set_seg_boundary(&pdev->dev, DMA_BIT_MASK(32)); > > + ret = iris_reserve_iova_region(dev, &core->iova_state, IRIS_NP_RESERVE_IOVA_START, > + IRIS_NP_RESERVE_IOVA_SIZE); > + if (ret) > + goto err_vdev_unreg_enc; > + This reservation should come before video_register_device() since its possible for user-space to race this otherwise. Should come pretty much up the top > pm_runtime_set_autosuspend_delay(core->dev, AUTOSUSPEND_DELAY_VALUE); > pm_runtime_use_autosuspend(core->dev); > ret = devm_pm_runtime_enable(core->dev); > if (ret) > - goto err_vdev_unreg_enc; > + goto err_unresv_iova_region; > > return 0; > > +err_unresv_iova_region: > + iris_unreserve_iova_region(dev, core->iova_state); > err_vdev_unreg_enc: > video_unregister_device(core->vdev_enc); > err_vdev_unreg_dec: > > -- > 2.34.1 > --- bod ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] media: venus: Fix iova allocation from restrict region 2026-08-12 10:55 [PATCH 0/2] media: qcom: Fix iova allocation from restrict region Vishnu Reddy 2026-08-12 10:55 ` [PATCH 1/2] media: iris: " Vishnu Reddy @ 2026-08-12 10:55 ` Vishnu Reddy 2026-08-14 14:41 ` Vikash Garodia 2026-08-18 7:04 ` Dmitry Baryshkov 1 sibling, 2 replies; 10+ messages in thread From: Vishnu Reddy @ 2026-08-12 10:55 UTC (permalink / raw) To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil, Stefan Schmidt, Stanimir Varbanov Cc: linux-media, linux-arm-msm, linux-kernel, Vishnu Reddy, stable The VPU issues DMA through several SMMU streams, and the hardware does not give every stream the same addressable range. The non-pixel stream cannot address the low 600MB of IOVA space, while the pixel stream can address the full range: +-----------------------------------------------------------+ | non-pixel stream addressable range (600 MB - 3.5 GB) | | 0x25800000 - 0xe0000000 | +-----------------------------------------------------------+ | pixel stream addressable range (0 - 3.5 GB) | | 0x00000000 - 0xe0000000 | +-----------------------------------------------------------+ A single "iommus" property on the video-codec node puts every stream in one IOMMU domain sharing one IOVA allocator, so nothing restricts a non-pixel buffer to avoid 0 to 600MB. Once an allocation lands below that boundary the hardware faults, which shows up as unhandled SMMU page faults and spontaneous reboots. https://gitlab.freedesktop.org/drm/msm/-/work_items/100 A series to reserve the 0-600MB IOVA range via "iommu-addresses" was already posted here: https://lore.kernel.org/all/20260807-iris_iova_600mb_fix-v1-0-3996f67e33f9@oss.qualcomm.com Those changes involve DT binding and DT node changes, and discussion is still ongoing on how to handle those for stable and for the upcoming sub-node design, with no conclusion reached yet. Thereby a critical reset issue is still open. This is an alternate solution to fix the unhandled SMMU page fault by restricting the IOVA range in the video driver, which also makes it easier and faster to land on mainline and stable kernels. At the same time the patch only reserves in the IOVA space without allocating any physical memory. Currently sub-nodes are not yet present, and only a single device is available, so the restriction is applied to both non-pixel and pixel stream IDs. This makes the solution unoptimal while fixing the issue considering all scenarios. Once sub-nodes for non-pixel, pixel, and secure streams become available, the restriction can be made stream specific. Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions") Cc: stable@vger.kernel.org Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com> --- drivers/media/platform/qcom/venus/core.c | 71 +++++++++++++++++++++++++++++++- drivers/media/platform/qcom/venus/core.h | 5 +++ 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 243e342b0ae7..d70f7c3325b4 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -377,6 +377,64 @@ static int venus_add_dynamic_nodes(struct venus_core *core) static void venus_remove_dynamic_nodes(struct venus_core *core) {} #endif +static int venus_reserve_iova_region(struct device *dev, struct dma_iova_state **iova_state, + unsigned long start, unsigned long size) +{ + struct dma_iova_state *state; + unsigned long mask = dma_get_mask(dev); + unsigned long end, rem, chunk; + unsigned int count = 0; + int ret; + + state = kcalloc(BITS_PER_TYPE(dma_addr_t) + 1, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + end = start + size; + rem = end - max(start, PAGE_SIZE); + + ret = dma_set_mask_and_coherent(dev, end - 1); + if (ret) + goto err_free_mem; + + while (rem) { + chunk = min(end & -end, (u64)1 << (fls64(rem) - 1)); + + if (!dma_iova_try_alloc(dev, &state[count], 0, chunk)) { + ret = -ENOMEM; + goto err_free_iova; + } + + rem -= chunk; + end -= chunk; + count++; + } + + *iova_state = state; + dma_set_mask_and_coherent(dev, mask); + + return 0; + +err_free_iova: + while (count--) + dma_iova_free(dev, &state[count]); + dma_set_mask_and_coherent(dev, mask); +err_free_mem: + kfree(state); + + return ret; +} + +static void venus_unreserve_iova_region(struct device *dev, struct dma_iova_state *state) +{ + unsigned int i; + + for (i = 0; dma_iova_size(&state[i]); i++) + dma_iova_free(dev, &state[i]); + + kfree(state); +} + static int venus_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -427,6 +485,11 @@ static int venus_probe(struct platform_device *pdev) dma_set_max_seg_size(dev, UINT_MAX); + ret = venus_reserve_iova_region(dev, &core->iova_state, VENUS_NP_RESERVE_IOVA_START, + VENUS_NP_RESERVE_IOVA_SIZE); + if (ret) + goto err_core_put; + INIT_LIST_HEAD(&core->instances); mutex_init(&core->lock); INIT_DELAYED_WORK(&core->work, venus_sys_error_handler); @@ -434,13 +497,13 @@ static int venus_probe(struct platform_device *pdev) ret = hfi_create(core, &venus_core_ops); if (ret) - goto err_core_put; + goto err_unresv_iova_region; ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "venus", core); if (ret) - goto err_core_put; + goto err_unresv_iova_region; venus_assign_register_offsets(core); @@ -525,6 +588,8 @@ static int venus_probe(struct platform_device *pdev) v4l2_device_unregister(&core->v4l2_dev); err_hfi_destroy: hfi_destroy(core); +err_unresv_iova_region: + venus_unreserve_iova_region(dev, core->iova_state); err_core_put: if (core->pm_ops->core_put) core->pm_ops->core_put(core); @@ -562,6 +627,8 @@ static void venus_remove(struct platform_device *pdev) hfi_destroy(core); + venus_unreserve_iova_region(dev, core->iova_state); + mutex_destroy(&core->pm_lock); mutex_destroy(&core->lock); venus_dbgfs_deinit(core); diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 46705a666776..30b8cababe86 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -8,6 +8,7 @@ #define __VENUS_CORE_H_ #include <linux/bitops.h> +#include <linux/dma-mapping.h> #include <linux/list.h> #include <media/videobuf2-v4l2.h> #include <media/v4l2-ctrls.h> @@ -30,6 +31,9 @@ #define VENUS_MAX_FPS 240 +#define VENUS_NP_RESERVE_IOVA_START 0x0 +#define VENUS_NP_RESERVE_IOVA_SIZE 0x25800000 + extern int venus_fw_debug; struct freq_tbl { @@ -250,6 +254,7 @@ struct venus_core { unsigned long dump_core; struct of_changeset *ocs; bool hwmode_dev; + struct dma_iova_state *iova_state; }; struct vdec_controls { -- 2.34.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] media: venus: Fix iova allocation from restrict region 2026-08-12 10:55 ` [PATCH 2/2] media: venus: " Vishnu Reddy @ 2026-08-14 14:41 ` Vikash Garodia 2026-08-18 7:04 ` Dmitry Baryshkov 1 sibling, 0 replies; 10+ messages in thread From: Vikash Garodia @ 2026-08-14 14:41 UTC (permalink / raw) To: Vishnu Reddy, Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil, Stefan Schmidt, Stanimir Varbanov Cc: linux-media, linux-arm-msm, linux-kernel, stable On 8/12/2026 4:25 PM, Vishnu Reddy wrote: > The VPU issues DMA through several SMMU streams, and the hardware does > not give every stream the same addressable range. The non-pixel stream > cannot address the low 600MB of IOVA space, while the pixel stream can > address the full range: > +-----------------------------------------------------------+ > | non-pixel stream addressable range (600 MB - 3.5 GB) | > | 0x25800000 - 0xe0000000 | > +-----------------------------------------------------------+ > | pixel stream addressable range (0 - 3.5 GB) | > | 0x00000000 - 0xe0000000 | > +-----------------------------------------------------------+ > A single "iommus" property on the video-codec node puts every stream > in one IOMMU domain sharing one IOVA allocator, so nothing restricts a > non-pixel buffer to avoid 0 to 600MB. Once an allocation lands below that > boundary the hardware faults, which shows up as unhandled SMMU page > faults and spontaneous reboots. > https://gitlab.freedesktop.org/drm/msm/-/work_items/100 > > A series to reserve the 0-600MB IOVA range via "iommu-addresses" was > already posted here: > https://lore.kernel.org/all/20260807-iris_iova_600mb_fix- > v1-0-3996f67e33f9@oss.qualcomm.com > > Those changes involve DT binding and DT node changes, and discussion is > still ongoing on how to handle those for stable and for the upcoming > sub-node design, with no conclusion reached yet. Thereby a critical reset > issue is still open. > > This is an alternate solution to fix the unhandled SMMU page fault > by restricting the IOVA range in the video driver, which also makes it > easier and faster to land on mainline and stable kernels. At the same > time the patch only reserves in the IOVA space without allocating > any physical memory. > > Currently sub-nodes are not yet present, and only a single device is > available, so the restriction is applied to both non-pixel and pixel > stream IDs. This makes the solution unoptimal while fixing the issue > considering all scenarios. > Once sub-nodes for non-pixel, pixel, and secure streams become available, > the restriction can be made stream specific. > > Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions") > Cc:stable@vger.kernel.org > Signed-off-by: Vishnu Reddy<busanna.reddy@oss.qualcomm.com> > --- > drivers/media/platform/qcom/venus/core.c | 71 +++++++++++++++++++++++++++++++- > drivers/media/platform/qcom/venus/core.h | 5 +++ > 2 files changed, 74 insertions(+), 2 deletions(-) Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] media: venus: Fix iova allocation from restrict region 2026-08-12 10:55 ` [PATCH 2/2] media: venus: " Vishnu Reddy 2026-08-14 14:41 ` Vikash Garodia @ 2026-08-18 7:04 ` Dmitry Baryshkov 2026-08-18 7:55 ` Vikash Garodia 1 sibling, 1 reply; 10+ messages in thread From: Dmitry Baryshkov @ 2026-08-18 7:04 UTC (permalink / raw) To: Vishnu Reddy Cc: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil, Stefan Schmidt, Stanimir Varbanov, linux-media, linux-arm-msm, linux-kernel, stable On Wed, Aug 12, 2026 at 04:25:59PM +0530, Vishnu Reddy wrote: > The VPU issues DMA through several SMMU streams, and the hardware does > not give every stream the same addressable range. The non-pixel stream > cannot address the low 600MB of IOVA space, while the pixel stream can > address the full range: > +-----------------------------------------------------------+ > | non-pixel stream addressable range (600 MB - 3.5 GB) | > | 0x25800000 - 0xe0000000 | > +-----------------------------------------------------------+ > | pixel stream addressable range (0 - 3.5 GB) | > | 0x00000000 - 0xe0000000 | > +-----------------------------------------------------------+ Does this split apply to all generations of Venus? We support MSM8916, for example. There has been work to enable MSM8974. -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] media: venus: Fix iova allocation from restrict region 2026-08-18 7:04 ` Dmitry Baryshkov @ 2026-08-18 7:55 ` Vikash Garodia 2026-08-18 8:20 ` Dmitry Baryshkov 0 siblings, 1 reply; 10+ messages in thread From: Vikash Garodia @ 2026-08-18 7:55 UTC (permalink / raw) To: Dmitry Baryshkov, Vishnu Reddy Cc: Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil, Stefan Schmidt, Stanimir Varbanov, linux-media, linux-arm-msm, linux-kernel, stable On 8/18/2026 12:34 PM, Dmitry Baryshkov wrote: > On Wed, Aug 12, 2026 at 04:25:59PM +0530, Vishnu Reddy wrote: >> The VPU issues DMA through several SMMU streams, and the hardware does >> not give every stream the same addressable range. The non-pixel stream >> cannot address the low 600MB of IOVA space, while the pixel stream can >> address the full range: >> +-----------------------------------------------------------+ >> | non-pixel stream addressable range (600 MB - 3.5 GB) | >> | 0x25800000 - 0xe0000000 | >> +-----------------------------------------------------------+ >> | pixel stream addressable range (0 - 3.5 GB) | >> | 0x00000000 - 0xe0000000 | >> +-----------------------------------------------------------+ > Does this split apply to all generations of Venus? We support MSM8916, > for example. There has been work to enable MSM8974. Yes, applicable for all VPUs Regards, Vikash ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] media: venus: Fix iova allocation from restrict region 2026-08-18 7:55 ` Vikash Garodia @ 2026-08-18 8:20 ` Dmitry Baryshkov 0 siblings, 0 replies; 10+ messages in thread From: Dmitry Baryshkov @ 2026-08-18 8:20 UTC (permalink / raw) To: Vikash Garodia Cc: Vishnu Reddy, Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil, Stefan Schmidt, Stanimir Varbanov, linux-media, linux-arm-msm, linux-kernel, stable On Tue, Aug 18, 2026 at 01:25:58PM +0530, Vikash Garodia wrote: > > On 8/18/2026 12:34 PM, Dmitry Baryshkov wrote: > > On Wed, Aug 12, 2026 at 04:25:59PM +0530, Vishnu Reddy wrote: > > > The VPU issues DMA through several SMMU streams, and the hardware does > > > not give every stream the same addressable range. The non-pixel stream > > > cannot address the low 600MB of IOVA space, while the pixel stream can > > > address the full range: > > > +-----------------------------------------------------------+ > > > | non-pixel stream addressable range (600 MB - 3.5 GB) | > > > | 0x25800000 - 0xe0000000 | > > > +-----------------------------------------------------------+ > > > | pixel stream addressable range (0 - 3.5 GB) | > > > | 0x00000000 - 0xe0000000 | > > > +-----------------------------------------------------------+ > > Does this split apply to all generations of Venus? We support MSM8916, > > for example. There has been work to enable MSM8974. > > Yes, applicable for all VPUs Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-08-18 10:20 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-12 10:55 [PATCH 0/2] media: qcom: Fix iova allocation from restrict region Vishnu Reddy 2026-08-12 10:55 ` [PATCH 1/2] media: iris: " Vishnu Reddy 2026-08-14 14:41 ` Vikash Garodia 2026-08-18 6:49 ` Dmitry Baryshkov 2026-08-18 10:19 ` Bryan O'Donoghue 2026-08-12 10:55 ` [PATCH 2/2] media: venus: " Vishnu Reddy 2026-08-14 14:41 ` Vikash Garodia 2026-08-18 7:04 ` Dmitry Baryshkov 2026-08-18 7:55 ` Vikash Garodia 2026-08-18 8:20 ` Dmitry Baryshkov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox