[PATCH v3 2/4] i3c: mipi-i3c-hci: Use core helpers for DMA mapping and bounce buffering

Frank Li Frank.li at nxp.com
Thu Aug 21 11:53:56 PDT 2025


On Thu, Aug 21, 2025 at 08:51:37AM +0300, Jarkko Nikula wrote:
> On 8/20/25 7:11 PM, Frank Li wrote:
> > On Wed, Aug 20, 2025 at 02:34:45PM +0300, Jarkko Nikula wrote:
> > >
> > > For now, require bounce buffer only when the buffer is in the
> > > vmalloc() area to avoid unnecessary copying with CCC commands and
> > > DMA-safe I2C transfers.
> >
> > I see below you pass 'false' to i3c_master_dma_map_single(). where
> > check buffer in the vmaloc() area?
> >
> Yes it's intended in this patch. Driver doesn't especially require a bounce
> here (in the next patch yes) but if buffer is in vmalloc area the
> i3c_master_dma_map_single() does allocate it internally.

After check your i3c_master_dma_map_single() implmenet again,

i3c_master_dma_map_single(..., need_bounce,...)
	if (is_vmalloc_addr(buf))
		need_bounce = true;

You overwrite need_bounce in i3c_master_dma_map_single(), it will cause
confuse.

Can you change 'need_bounce' to 'force_bounce'?

force_bounce: true,  means force to use bounce bounce.
force_bounce: false, means system auto check base on buf

Frank

>
> > >
> > > Signed-off-by: Jarkko Nikula <jarkko.nikula at linux.intel.com>
> > > ---
> > >   drivers/i3c/master/mipi-i3c-hci/core.c | 34 --------------------------
> > >   drivers/i3c/master/mipi-i3c-hci/dma.c  | 27 +++++++++-----------
> > >   drivers/i3c/master/mipi-i3c-hci/hci.h  |  3 +--
> > >   3 files changed, 12 insertions(+), 52 deletions(-)
> > >
> > [...]
> > > @@ -391,21 +390,17 @@ static int hci_dma_queue_xfer(struct i3c_hci *hci,
> > >
> > >   		/* 2nd and 3rd words of Data Buffer Descriptor Structure */
> > >   		if (xfer->data) {
> > > -			buf = xfer->bounce_buf ? xfer->bounce_buf : xfer->data;
> > > -			xfer->data_dma =
> > > -				dma_map_single(&hci->master.dev,
> > > -					       buf,
> > > -					       xfer->data_len,
> > > -					       xfer->rnw ?
> > > -						  DMA_FROM_DEVICE :
> > > -						  DMA_TO_DEVICE);
> > > -			if (dma_mapping_error(&hci->master.dev,
> > > -					      xfer->data_dma)) {
> > > +			xfer->dma = i3c_master_dma_map_single(&hci->master.dev,
> > > +							      xfer->data,
> > > +							      xfer->data_len,
> > > +							      false,
> > > +
> >
> > you pass false here.
> >
>
> --
> linux-i3c mailing list
> linux-i3c at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c



More information about the linux-i3c mailing list