mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Abhinav Parihar" <abhinav.parihar@oss.qualcomm.com>,
	"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: Tue, 24 Nov 2026 13:29:09 +0100	[thread overview]
Message-ID: <6db57a38-ddf9-4345-996b-82db8a790b7a@app.fastmail.com> (raw)
In-Reply-To: <20261124120604.2640046-1-abhinav.parihar@oss.qualcomm.com>

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?

> @@ -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

      reply	other threads:[~2026-11-24 12:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 12:06 Abhinav Parihar
2026-11-24 12:29 ` Arnd Bergmann [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=6db57a38-ddf9-4345-996b-82db8a790b7a@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=abhinav.parihar@oss.qualcomm.com \
    --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®