/* * Dom0 is mapped 1:1, and while the Linux page can span across multiple Xen * pages, it is not possible for it to contain a mix of local and foreign Xen * pages. Calling pfn_valid on a foreign mfn will always return false, so if * pfn_valid returns true the pages is local and we can use the native * dma-direct functions, otherwise we call the Xen specific version.
*/ void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir)
{ if (dir != DMA_TO_DEVICE)
dma_cache_maint(dev, handle, size, GNTTAB_CACHE_INVAL);
}
/* * The swiotlb buffer should be used if * - Xen doesn't have the cache flush hypercall * - The Linux page refers to foreign memory * - The device doesn't support coherent DMA request * * The Linux page may be spanned acrros multiple Xen page, although * it's not possible to have a mix of local and foreign Xen page. * Furthermore, range_straddles_page_boundary is already checking * if buffer is physically contiguous in the host RAM. * * Therefore we only need to check the first Xen page to know if we * require a bounce buffer because the device doesn't support coherent * memory and we are not able to flush the cache.
*/ return (!hypercall_cflush && (xen_pfn != bfn) &&
!dev_is_dma_coherent(dev));
}
staticint __init xen_mm_init(void)
{ struct gnttab_cache_flush cflush; int rc;
if (!xen_swiotlb_detect()) return 0;
/* we can work with the default swiotlb */
rc = swiotlb_init_late(swiotlb_size_or_default(),
xen_swiotlb_gfp(), NULL); if (rc < 0) return rc;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.