On Sat, Sep 28, 2019 at 11:33:16AM +0800, Nicolas Boichat wrote: > > +static gfp_t uvc_alloc_gfp_flags(struct device *dev) > > +{ > > + u64 mask = dma_get_mask(dev); > > + > > + if (dev->bus_dma_mask) > > + mask &= dev->bus_dma_mask; > > + > > + if (mask < DMA_BIT_MASK(32) && IS_ENABLED(CONFIG_ZONE_DMA)) > > + return GFP_DMA; > > + > > + if (mask < DMA_BIT_MASK(64)) { > > + if (IS_ENABLED(CONFIG_ZONE_DMA32)) > > + return GFP_DMA32; > > We're hitting issues with this on 64-bit ARM platform, where > ZONE_DMA32 is enabled (default), the kmalloc allocation with GFP_DMA32 > fails. > > There is no slab cache for GFP_DMA32, so those calls are expected to > fail, AFAICT there are no other (working) kmalloc(..., .. | GFP_DMA32) > users in the kernel, so I don't think we want to add a cache. If this > helps, some discussion here why the cache wasn't added: > https://lore.kernel.org/patchwork/patch/1009563/#1198622 And drivers really have no business looking at the dma mask. I have a plan for dma_alloc_pages API that could replace that cruft, but until then please use GFP_KERNEL and let the dma subsystem bounce buffer if needed.