From: Kel Modderman <kelvmod@gmail.com>
To: Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Bryan O'Donoghue <bod@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Kel Modderman <kelvmod@gmail.com>,
Vishnu Reddy <busanna.reddy@oss.qualcomm.com>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 2/2] media: venus: Skip the IOVA reservation when the range is already reserved
Date: Sat, 5 Dec 2026 09:51:39 +1000 [thread overview]
Message-ID: <20261204235141.1264368-3-kelvmod@gmail.com> (raw)
In-Reply-To: <20261204235141.1264368-1-kelvmod@gmail.com>
venus_reserve_iova_region() has the same problem as Iris: when the
device tree already reserves IOVA 0 to 0x25800000 for the video codec
with an "iommu-addresses" reserved-memory node, dma_iova_try_alloc()
can't get the range and the probe fails with -ENOMEM.
Skip the reservation when an IOMMU_RESV_RESERVED region already covers
it, as for Iris.
Claude Code (Claude Opus 5.5) wrote this change and its changelog
together with the Iris one. It is compile-tested only.
Fixes: 953439251b59 ("media: venus: Fix iova allocation from restrict region")
Cc: stable@vger.kernel.org
Signed-off-by: Kel Modderman <kelvmod@gmail.com>
---
drivers/media/platform/qcom/venus/core.c | 26 ++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 7087af32060..07d216e8c05 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -7,6 +7,7 @@
#include <linux/interconnect.h>
#include <linux/io.h>
#include <linux/ioctl.h>
+#include <linux/iommu.h>
#include <linux/delay.h>
#include <linux/devcoredump.h>
#include <linux/list.h>
@@ -385,6 +386,26 @@ static void venus_unreserve_iova_region(struct device *dev, struct dma_iova_stat
dma_iova_free(dev, &state[i]);
}
+static bool venus_iova_region_reserved(struct device *dev, unsigned long start,
+ unsigned long size)
+{
+ struct iommu_resv_region *region;
+ LIST_HEAD(resv_regions);
+ bool reserved = false;
+
+ iommu_get_resv_regions(dev, &resv_regions);
+ list_for_each_entry(region, &resv_regions, list) {
+ if (region->type == IOMMU_RESV_RESERVED && region->start <= start &&
+ region->start + region->length >= start + size) {
+ reserved = true;
+ break;
+ }
+ }
+ iommu_put_resv_regions(dev, &resv_regions);
+
+ return reserved;
+}
+
static int venus_reserve_iova_region(struct device *dev, struct dma_iova_state **iova_state,
unsigned long start, unsigned long size)
{
@@ -398,6 +419,11 @@ static int venus_reserve_iova_region(struct device *dev, struct dma_iova_state *
if (!state)
return ret;
+ if (venus_iova_region_reserved(dev, start, size)) {
+ *iova_state = state;
+ return 0;
+ }
+
end = start + size;
rem = end - max(start, PAGE_SIZE);
dev->bus_dma_limit = end - 1;
--
2.55.0
prev parent reply other threads:[~2026-12-04 23:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 23:51 [PATCH 0/2] media: qcom: Don't fail probe when the IOVA range is already reserved Kel Modderman
2026-12-04 23:51 ` [PATCH 1/2] media: iris: Skip the IOVA reservation when the " Kel Modderman
2026-12-04 23:51 ` Kel Modderman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204235141.1264368-3-kelvmod@gmail.com \
--to=kelvmod@gmail.com \
--cc=abhinav.kumar@linux.dev \
--cc=bod@kernel.org \
--cc=busanna.reddy@oss.qualcomm.com \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=vikash.garodia@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox