public inbox for linux-scsi@vger.kernel.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: Wed, 29 Jun 2022 19:36:52 +1200	[thread overview]
Message-ID: <5e57e1e1-2b06-e58c-9081-3b2cce11b5ce@gmail.com> (raw)
In-Reply-To: <CAK8P3a2hQWF8vY7HPF=6QMW+Ts8fpcwcwmBskbrMLGNgK08hSw@mail.gmail.com>

Hi Arnd,

Am 29.06.2022 um 18:19 schrieb Arnd Bergmann:
> On Wed, Jun 29, 2022 at 3:16 AM Michael Schmitz <schmitzmic@gmail.com> wrote:
>>
>> V1 of a patch series to convert m68k Amiga WD33C93 drivers to the
>> DMA API.
>>
>> This series was precipitated by Arnd removing CONFIG_VIRT_TO_BUS. The
>> m68k WD33C93 still used virt_to_bus to convert virtual addresses to
>> physical addresses suitable for the DMA engines (note m68k does not
>> have an IOMMU and uses a direct mapping for DMA addresses).
>>
>> Arnd suggested to use dma_map_single() to set up dma mappings instead
>> of open-coding much the same in every driver dma_setup() function.
>>
>> It appears that m68k (MMU, except for coldfire) will set up pages for
>> DMA transfers as non-cacheable, thus obviating the need for explicit
>> cache management.
>
> 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.

>> DMA setup on a3000 host adapters can be simplified to skip bounce
>> buffer use (assuming SCSI buffers passed to the driver are cache> Thanks, and Cheers,
>>
>>    Michael
>>
>
>> line aligned; a safe bet except for maybe sg.c input).
>>
>> On gvp11 and a2091 host adapters, only the lowest 16 MB of physical
>> memory can be directy addressed by DMA, and bounce buffers from that
>> space must still be used (possibly allocated from chip RAM using the
>> custom allocator) if buffers are located in the higher memory regions.
>>
>> The m68k VME mvme147 driver has no DMA addressing or alignment
>> restrictions and can be converted in the same way as the Amiga a3000
>> one, but will require conversion to a platform device driver first.
>
> Right, it seems that the old hack of passing a NULL device pointer
> no longer works, and that is probably for the better.
>
> If you want an easy way out, the driver can just call
> platform_device_register_full() to create its own device with a
> dma_mask set up, and use that device for the DMA API, but
> not actually match the device to a driver.

I'll leave it to Geert to decide whether he prefers setting up a 
platform device in arch/m68k/mvme147/config.c or use the shortcut. I've 
used platform_device_register_simple() in a few other drivers so don't 
mind that much.

Cheers,

	Michael

>
>> Only compile tested so far, and hardware testing might be hard to do.
>> I'd appreciate someone giving this a thorough review.
>
> Looks all good to me.
>
>         Arnd
>

  reply	other threads:[~2022-06-29  7:37 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 [this message]
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

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=5e57e1e1-2b06-e58c-9081-3b2cce11b5ce@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