About PHYS_TO_DMAP

Dmitry Salychev <[email protected]>
Newsgroups gmane.os.freebsd.devel.arm
Message-ID <[email protected]>
Hi,

I'm struggling to understand which KVA will be returned by PHYS_TO_DMAP
on arm64. For example, if I'll create a DMA tag this way:

	bus_dma_tag_create(
	    bus_get_dma_tag(dev),
	    sc->buf_align, 0,		/* alignment, boundary */
	    DMAP_MAX_PHYSADDR,		/* low restricted addr */
	    DMAP_MIN_PHYSADDR,		/* high restricted addr */
	    NULL, NULL,			/* filter, filterarg */
	    BUF_SIZE, 1,		/* maxsize, nsegments */
	    BUF_SIZE, 0,		/* maxsegsize, flags */
	    NULL, NULL,			/* lockfunc, lockarg */
	    &dmat);

in order to restrict any physical addresses but a window defined by
DMAP_MIN_PHYSADDR and DMAP_MAX_PHYSADDR. Later on when I'll be
mapping my mbuf (BUF_SIZE) with

	bus_dmamap_load_mbuf_sg(dmat, dmap,
	    m, &segs, &nsegs, BUS_DMA_NOWAIT);

I expect that

	m->m_data == PHYS_TO_DMAP(segs[0].ds_addr)

but it isn't true. Could somebody explain what exactly is returned by
PHYS_TO_DMAP in this case and whether it's possible to translate
physical address to KVA as fast as possible (O(1) ideally).

Regards,
Dmitry

--
Open source software/hardware enthusiast
hackaday.io/dsl | github.com/mcusim | patreon.com/salychev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.