From: Abhinav Parihar <abhinav.parihar@oss.qualcomm.com>
To: Arnd Bergmann <arnd@arndb.de>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
linux-arm-msm@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
quic_bkumar@quicinc.com,
Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>,
linux-kernel@vger.kernel.org, quic_chennak@quicinc.com,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3] misc: fastrpc: Add cache maintenance for non-coherent platforms
Date: Mon, 30 Nov 2026 14:41:19 +0530 [thread overview]
Message-ID: <2c58c159-3062-4afd-8b28-0c7afc996345@oss.qualcomm.com> (raw)
In-Reply-To: <6db57a38-ddf9-4345-996b-82db8a790b7a@app.fastmail.com>
On 11/24/2026 5:59 PM, Arnd Bergmann wrote:
> On Tue, Nov 24, 2026, at 13:06, Abhinav Parihar wrote:
>> Some platforms using fastrpc do not support DMA coherency on
>> HLOS. On such systems, explicit cache maintenance is
>> required to ensure data consistency for RPC argument buffers.
>>
>> Add cache maintenance for argument buffers when operating on
>> non-coherent platforms:
>> - Flush input buffers before invoking RPC to ensure CPU writes are
>> visible to the DSP
>> - Invalidate output buffers after RPC completion to ensure DSP
>> writes are visible to the CPU
>>
>> Introduce helper functions fastrpc_flush_args() and
>> fastrpc_inv_args() to perform the required dma-buf cache
>> operations. These are invoked only when the device is not marked
>> as DMA coherent.
>>
>> The coherency capability is determined using the "dma-coherent"
>> device tree property and stored per session context.
> The dma-mapping abstraction is meant to hide this from drivers,
> why does this driver need to know?
I added that check because I thought coherency varied across targets and
wanted to avoid unnecessary operations
for IO coherent targets.
The data flow is that userspace allocates the dma-buf (system heap),
FastRPC driver attaches and maps it for the HLOS SMMU,
and the resulting IOVA is passed to the DSP, which maps and accesses the
buffer in its own address space. Goal is that inbufs
are updated in DDR before DSP reads them and outbufs cache lines are
invalidated before HLOS reads the DSP results.
>> @@ -1078,6 +1086,54 @@ static int fastrpc_create_maps(struct
>> fastrpc_invoke_ctx *ctx)
>> return 0;
>> }
>>
>> +static void fastrpc_flush_args(struct fastrpc_invoke_ctx *ctx)
>> +{
>> + union fastrpc_remote_arg *rpra = ctx->rpra;
>> + int i, inbufs;
>> +
>> + inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
>> +
>> + for (i = 0; i < ctx->nbufs; ++i) {
>> + int raix = ctx->olaps[i].raix;
>> + struct fastrpc_map *map = ctx->maps[raix];
>> +
>> + if (raix + 1 > inbufs)
>> + continue;
>> + if (!map || !map->buf)
>> + continue;
>> +
>> + if (rpra[raix].buf.len && (ctx->olaps[i].mstart ||
>> ctx->olaps[i].do_cmo)) {
>> + dma_buf_begin_cpu_access(map->buf, DMA_TO_DEVICE);
>> + dma_buf_end_cpu_access(map->buf, DMA_TO_DEVICE);
>> + }
>> + }
>> +}
> This does not look like an appropriate interface: the driver
> should not have to worry about platform specific details
> of 'flush' or 'invalidate' and only access the data between
> 'begin' and 'end' here. E.g. if there is an iommu or swiotlb,
> the buffer may become inaccessible again after 'end'.
>
> Can you change this to have separate loops to manage
> ownership before and after the access?
>
> Arnd
I was calling dma_buf_begin_cpu_access() and dma_buf_end_cpu_access()
back-to-back to trigger cache maintenance.
Currently we are treating these calls as flush/invalidate primitives.
Since FastRPC passes the mapping to the DSP rather than accessing the
buffer contents in the kernel, could you advise which
interface is appropriate for this case?
next prev parent reply other threads:[~2026-11-30 9:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 12:06 Abhinav Parihar
2026-11-24 12:29 ` Arnd Bergmann
2026-11-30 9:11 ` Abhinav Parihar [this message]
2026-11-30 9:38 ` Arnd Bergmann
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=2c58c159-3062-4afd-8b28-0c7afc996345@oss.qualcomm.com \
--to=abhinav.parihar@oss.qualcomm.com \
--cc=arnd@arndb.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=ekansh.gupta@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_bkumar@quicinc.com \
--cc=quic_chennak@quicinc.com \
--cc=srinivas.kandagatla@linaro.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®