Re: [PATCH] m68k/amiga - zorro.c: allocate z->dev.dma_mask so the DMA API can work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michael,

On Thu, Mar 1, 2018 at 3:55 AM, Michael Schmitz <schmitzmic@xxxxxxxxx> 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 <schmitzmic@xxxxxxxxx>
---
 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.

Possible alternatives:
1. PCI has pci_dev.dma_mask, and sets dev.dma_mask to &pci_dev.dma_mask.
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.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Video for Linux]     [Yosemite News]     [Linux S/390]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux