[Bug 274592] bus_dmamem_alloc()/bus_dmamap_load returns physical address outside the tag low/high bounds

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 19 Oct 2023 11:07:33 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274592

            Bug ID: 274592
           Summary: bus_dmamem_alloc()/bus_dmamap_load returns physical
                    address outside the tag low/high bounds
           Product: Base System
           Version: 15.0-CURRENT
          Hardware: arm64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: arm
          Assignee: freebsd-arm@FreeBSD.org
          Reporter: shafaisal.us@gmail.com

Hello Team, 
We are using the below 3 routines to alloc DMA memory for one of our devices
connected through PCIe interface.
Out of 10 rebooted 4-5 times we get the address outside greated 32G range of
addresses, due to which our device functionality is effected and there is a
crash seen.

error = bus_dma_tag_create(bus_get_dma_tag(dev),
                               PAGE_SIZE,
                               0,
                               BUS_SPACE_MAXADDR_32BIT,
                               BUS_SPACE_MAXADDR,
                               NULL,
                               NULL,
                               128*1024*1024, 1,
                               128*1024*1024, BUS_DMA_COHERENT,
                               NULL, NULL,
                               &dma_tag);

error = bus_dmamem_alloc(dma_tag, &vaddr,
                             BUS_DMA_WAITOK | BUS_DMA_ZERO | BUS_DMA_COHERENT,
                             &dma_map);


error = bus_dmamap_load(dma_tag, dma_map, vaddr,
                            128*1024*1024, dma_mem_callback, 
                            &dma_paddr, BUS_DMA_NOWAIT);                      


Below are the addresses we get for Working and non-working case

Working case vaddr and dma_paddr:
DMA phys addr with arm64_address_translate is 0xff000000cf000b80 for vaddr
0xffff00007ec00000
DMA phys addr with vtophys is 0xcf000000 for vaddr 0xffff00007ec00000

Non-Working case vaddr and dma_paddr:
DMA phys addr with arm64_address_translate is 0xff00000163000b80 for vaddr
0xffff00007ec00000
DMA phys addr with vtophys is 0x163000000 for vaddr 0xffff00007ec00000

-- 
You are receiving this mail because:
You are the assignee for the bug.