On Wed, Sep 16, 2020 at 02:21:00PM -0300, Jason Gunthorpe wrote: > + dma_addr = dma & ODP_DMA_ADDR_MASK; > + if (dma_addr) { > > > But more importantly except for (dma_addr_t)-1 (DMA_MAPPING_ERROR) > > all dma_addr_t values are valid, so taking more than a single bit > > from a dma_addr_t is not strictly speaking correct. > > This is the result of dma_map_page(). The HW requires that > dma_map_page(page_size) returns a DMA address that is page_size > aligned, even for huge pages. > > So at least the last 12 bits of the DMA address are always 0, they can > be used for flags. This is also the HW representation in the page > table. > > Last time you pointed at this code you agreed this alignment was met, > is it still OK? True, the alignment actually makes this work. I'd still suggest to throw in a comment about the actual usage.