public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Michael Schmitz <schmitzmic@gmail.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Linux/m68k <linux-m68k@vger.kernel.org>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH v1 0/3] Converting m68k WD33C93 drivers to DMA API
Date: Thu, 30 Jun 2022 08:28:44 +1200	[thread overview]
Message-ID: <ccdf0461-5d4a-0e6b-030f-f2578e02fd93@gmail.com> (raw)
In-Reply-To: <CAK8P3a3uTpSmzaRbeWp3Y9FZYx8js5pvgjNpLj79wAFFGp4Vhg@mail.gmail.com>

Hi Arnd,

On 29/06/22 20:20, Arnd Bergmann wrote:
>
>>> To clarify, the dma-mapping API has two ways of dealing with this:
>>>
>>> - the streaming API (dma_map/unmap_...) uses explicit cache flushes
>>>
>>> - the coherent API (dma_alloc_coherent etc) uses page protections
>>>    to prevent caching.
>>>
>>> These three drivers use the streaming API because they operate on
>>> data passed in from the outside, so the non-cacheable protection bits
>>> are not used here.
>> I had feared you'd say something along these lines ...
>>
>> Now that throws up a possible problem for the gvp11 driver: due to the
>> need to first map an allocated chunk, then possibly discard that and try
>> another allocation strategy, copying of data to the bounce buffer is
>> deferred until after the final mapping has been successful. This means
>> for writes, we have done the cache flushing before we have actually
>> written any data to the buffer.
>>
>> I don't think it is safe to omit the explicit cache flush for writes in
>> this case.
> I think it's fine as long as you do things in the correct order: the
> copy into the bounce buffer has to be done before the
> dma_map_single() here, and conversely, the copy out of the
> bounce buffer must happen after the dma_unmap_single().

Ah - I had missed the latter (due to dma_setup previously doing all 
cache management, and I had expected dma_map_single to do the same, i.e. 
invalidate the affected cache lines at time of mapping). Will fix.

The former is possible to do, but may incur an extra memcpy on gvp11 
(filling a bounce buffer that we may then discard because 
dma_map_single() returns a DMA handle outside our DMA range). The driver 
does switch to only allocating bounce buffers from chip RAM once a 
kmalloc allocation failed to yield DMA-able RAM, so the performance 
impact ought to be minimal.

> Regarding the amiga_chip_alloc(), I don't know what this means
> for caching. If chip memory is cache-coherent (either uncached
> or by snooping), then there should not be any
> dma_map()/dma_unmap() for that case, but instead the
> amiga_chip_alloc() function should return both the pointer
> and the dma_addr_t token.

amiga_chip_alloc() is used in many places around the kernel, I'd rather 
not change all that (or more precisely. I'd rather Geert does change 
amiga_chip_alloc() if need be).

I'll drop use of dma_map_single() on chip RAM and will rely on that 
having been mapped non-cacheable.

Cheers,

     Michael

>
>           Arnd

      parent reply	other threads:[~2022-06-29 20:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29  1:16 [PATCH v1 0/3] Converting m68k WD33C93 drivers to DMA API Michael Schmitz
2022-06-29  1:16 ` [PATCH v1 1/3] scsi - a3000.c: convert " Michael Schmitz
2022-06-29  6:07   ` Arnd Bergmann
2022-06-29  1:16 ` [PATCH v1 2/3] scsi - a2091.c: " Michael Schmitz
2022-06-29  6:06   ` Arnd Bergmann
2022-06-29  7:26     ` Michael Schmitz
2022-06-29 15:55       ` Geert Uytterhoeven
2022-06-29 20:48         ` Michael Schmitz
2022-06-30  9:27           ` Geert Uytterhoeven
2022-06-30 19:42             ` Michael Schmitz
2022-06-29  1:16 ` [PATCH v1 3/3] scsi - gvp11.c: " Michael Schmitz
2022-06-29  6:02   ` Arnd Bergmann
2022-06-29  6:19 ` [PATCH v1 0/3] Converting " Arnd Bergmann
2022-06-29  7:36   ` Michael Schmitz
2022-06-29  8:20     ` Arnd Bergmann
2022-06-29 15:48       ` Geert Uytterhoeven
2022-06-29 16:44         ` Arnd Bergmann
2022-06-30  2:45           ` Michael Schmitz
2022-06-29 20:28       ` Michael Schmitz [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=ccdf0461-5d4a-0e6b-030f-f2578e02fd93@gmail.com \
    --to=schmitzmic@gmail.com \
    --cc=arnd@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=linux-scsi@vger.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