Messages in this thread Patch in this message | | | Date | Sat, 11 Oct 2003 16:03:46 -0700 | From | David Brownell <> | Subject | Re: USB and DMA on Alpha with 2.6.0-test7 |
| |
> Ivan Kokshaysky wrote: >> >> This doesn't work. You will always return success if mask = ~0ULL.
Whoops. I didn't copy what I thought I was copying:
(mask & *dev->dma_mask) == mask /* not "== dma_mask" */
Updated code is appended ... which also provides a BUG()-free version of dma_set_mask(). I think the only arch/platform hook needed would be for dma_supported().
- Dave
--- 1.4/include/asm-generic/dma-mapping.h Mon Jan 13 14:37:47 2003 +++ edited/include/asm-generic/dma-mapping.h Sat Oct 11 15:33:56 2003 @@ -13,20 +13,22 @@ /* need struct page definitions */ #include <linux/mm.h> +/* FIXME use this everywhere there's no platform_dma_supported() */ static inline int dma_supported(struct device *dev, u64 mask) { - BUG_ON(dev->bus != &pci_bus_type); - - return pci_dma_supported(to_pci_dev(dev), mask); + /* device can dma, using those address bits */ + return dev->dma_mask + && (mask & *dev->dma_mask) == mask; } static inline int -dma_set_mask(struct device *dev, u64 dma_mask) +dma_set_mask(struct device *dev, u64 mask) { - BUG_ON(dev->bus != &pci_bus_type); - - return pci_set_dma_mask(to_pci_dev(dev), dma_mask); + if (!dma_supported(dev, mask)) + return 0; + *dev->dma_mask = mask; + return 1; } static inline void * | |