From: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
To: Srinivas Kandagatla <srini@kernel.org>,
Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Bharath Kumar <bkumar@qti.qualcomm.com>,
Chenna Kesava Raju <chennak@qti.qualcomm.com>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
Subject: [PATCH v2 3/4] misc: fastrpc: add extended context bank support
Date: Wed, 07 Oct 2026 17:07:50 +0530 [thread overview]
Message-ID: <20261007-extended-mapping-v2-3-5dca3aa2c2d3@oss.qualcomm.com> (raw)
In-Reply-To: <20261007-extended-mapping-v2-0-5dca3aa2c2d3@oss.qualcomm.com>
Detect extended context banks by the presence of iommu-ranges on the
context bank node. Register them in a separate ext_cb array so the
mapping layer can direct large allocations into the wider IOVA window.
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 5c7bb56cf46d..d40cdcd5dec3 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -307,6 +307,8 @@ struct fastrpc_channel_ctx {
struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS];
struct rpmsg_device *rpdev;
struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS];
+ struct fastrpc_session_ctx **ext_cb;
+ int ext_cb_count;
spinlock_t lock;
struct idr ctx_idr;
struct list_head users;
@@ -538,9 +540,13 @@ static int fastrpc_remote_heap_alloc(struct fastrpc_user *fl, struct device *dev
static void fastrpc_channel_ctx_free(struct kref *ref)
{
struct fastrpc_channel_ctx *cctx;
+ int i;
cctx = container_of(ref, struct fastrpc_channel_ctx, refcount);
+ for (i = 0; i < cctx->ext_cb_count; i++)
+ kfree(cctx->ext_cb[i]);
+ kfree(cctx->ext_cb);
idr_destroy(&cctx->ctx_idr);
kfree(cctx);
}
@@ -2343,6 +2349,7 @@ static int fastrpc_cb_init(struct platform_device *pdev)
u32 dma_bits;
u32 sid = 0;
int rc;
+ bool is_extended_cb = false;
cctx = dev_get_drvdata(dev->parent);
if (!cctx)
@@ -2352,6 +2359,43 @@ static int fastrpc_cb_init(struct platform_device *pdev)
of_n_addr_cells(dev->of_node) - 1, &sid))
dev_info(dev, "FastRPC Session ID not specified in DT\n");
+ if (of_property_present(dev->of_node, "iommu-ranges"))
+ is_extended_cb = true;
+
+ if (is_extended_cb) {
+ struct fastrpc_session_ctx **new_ext;
+
+ sess = kzalloc_obj(*sess);
+ if (!sess)
+ return -ENOMEM;
+
+ rc = dma_set_mask(dev, DMA_BIT_MASK(40));
+ if (rc) {
+ dev_err(dev, "40-bit DMA enable failed\n");
+ kfree(sess);
+ return rc;
+ }
+
+ new_ext = krealloc(cctx->ext_cb,
+ (cctx->ext_cb_count + 1) * sizeof(*cctx->ext_cb),
+ GFP_KERNEL);
+ if (!new_ext) {
+ kfree(sess);
+ return -ENOMEM;
+ }
+
+ spin_lock_irqsave(&cctx->lock, flags);
+ cctx->ext_cb = new_ext;
+ sess->valid = true;
+ sess->dev = dev;
+ sess->sid = sid;
+ dev_set_drvdata(dev, sess);
+ cctx->ext_cb[cctx->ext_cb_count++] = sess;
+ spin_unlock_irqrestore(&cctx->lock, flags);
+
+ return 0;
+ }
+
spin_lock_irqsave(&cctx->lock, flags);
if (cctx->sesscount >= FASTRPC_MAX_SESSIONS) {
spin_unlock_irqrestore(&cctx->lock, flags);
@@ -2391,6 +2435,8 @@ static void fastrpc_cb_devices_destroy(struct rpmsg_device *rpdev)
spin_lock_irqsave(&cctx->lock, flags);
for (i = 0; i < cctx->sesscount; i++)
cctx->session[i].valid = false;
+ for (i = 0; i < cctx->ext_cb_count; i++)
+ cctx->ext_cb[i]->valid = false;
spin_unlock_irqrestore(&cctx->lock, flags);
for_each_available_child_of_node(rdev->of_node, np) {
--
2.34.1
next prev parent reply other threads:[~2026-10-07 11:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 11:37 [PATCH v2 0/4] misc: fastrpc: add extended IOVA mapping support Vinayak Katoch
2026-10-07 11:37 ` [PATCH v2 1/4] dt-bindings: misc: qcom,fastrpc: add iommu-ranges support for context bank Vinayak Katoch
2026-10-09 9:56 ` Krzysztof Kozlowski
2026-10-07 11:37 ` [PATCH v2 2/4] misc: fastrpc: handle multi-cell reg in context bank probe Vinayak Katoch
2026-10-07 11:37 ` Vinayak Katoch [this message]
2026-10-07 11:37 ` [PATCH v2 4/4] misc: fastrpc: add UAPI flags for extended IOVA mapping Vinayak Katoch
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=20261007-extended-mapping-v2-3-5dca3aa2c2d3@oss.qualcomm.com \
--to=vinayak.katoch@oss.qualcomm.com \
--cc=arnd@arndb.de \
--cc=bkumar@qti.qualcomm.com \
--cc=chennak@qti.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ekansh.gupta@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=srini@kernel.org \
/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
all inboxes | Powered by JetHome®