Hi Geert,

On Thu, Mar 1, 2018 at 11:05 PM, Geert Uytterhoeven
<ge...@linux-m68k.org> wrote:
> Hi Michael,
>
> On Thu, Mar 1, 2018 at 3:55 AM, Michael Schmitz <schmitz...@gmail.com> wrote:
>> The generic DMA API uses dev->dma_mask to check the DMA addressable
>> memory bitmask, and warns if no mask is set or even allocated.
>>
>> Allocate z->dev.dma_mask on Zorro bus scan so device drivers can use
>> dma_set_mask_and_coherent() to set their DMA bit mask.
>>
>> Signed-off-by: Michael Schmitz <schmitz...@gmail.com>
>> ---
>>  drivers/zorro/zorro.c |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c
>> index cc1b1ac..e2d0344 100644
>> --- a/drivers/zorro/zorro.c
>> +++ b/drivers/zorro/zorro.c
>> @@ -185,6 +185,8 @@ static int __init amiga_zorro_probe(struct 
>> platform_device *pdev)
>>                 z->dev.parent = &bus->dev;
>>                 z->dev.bus = &zorro_bus_type;
>>                 z->dev.id = i;
>> +               z->dev.dma_mask =
>> +                       kmalloc(sizeof(*z->dev.dma_mask), GFP_KERNEL);
>
> Now *dma_mask will contain random garbage.

True - I was relying on the driver code to set the mask correctly.
Should have zeroed it here though.

>
> Possible alternatives:
> 1. PCI has pci_dev.dma_mask, and sets dev.dma_mask to &pci_dev.dma_mask.

We don't have such a bus-wide mask - adding one for the Zorro bus
might be another option.
Can we rely on all devices on the Zorro bus supporting DMA, with the
same mask? Can we find out which devices do, at bus scan time?
(My knowledge of Zorro internals is severely limited ...)

> 2. drivers/of/device.c does
>
>         /*
>          * Set default coherent_dma_mask to 32 bit.  Drivers are expected to
>          * setup the correct supported mask.
>          */
>         if (!dev->coherent_dma_mask)
>                 dev->coherent_dma_mask = DMA_BIT_MASK(32);
>         /*
>          * Set it to coherent_dma_mask by default if the architecture
>          * code has not set it.
>          */
>         if (!dev->dma_mask)
>                 dev->dma_mask = &dev->coherent_dma_mask;
>
> So
>
>      dev->coherent_dma_mask = DMA_BIT_MASK(32);
>      dev->dma_mask = &dev->coherent_dma_mask;
>
> may be the simplest solution.

That would be the most elegant fix, true. Do you want to provide that
for all devices in the Zorro code, or on a case by case basis  in the
driver code?

Cheers,

  Michael

>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
>                                 -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to