Ejemplo n.º 1
0
int
dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
	   enum dma_data_direction direction)
{
	int i, rc;

	if (direction == DMA_NONE)
		BUG();
	WARN_ON(nents == 0 || sg[0].length == 0);

	if (swiotlb) {
		rc = swiotlb_map_sg(hwdev, sg, nents, direction);
	} else {
		for (i = 0; i < nents; i++ ) {
			sg[i].dma_address =
				page_to_bus(sg[i].page) + sg[i].offset;
			sg[i].dma_length  = sg[i].length;
			BUG_ON(!sg[i].page);
			IOMMU_BUG_ON(address_needs_mapping(
				hwdev, sg[i].dma_address));
		}
		rc = nents;
	}

	flush_write_buffers();
	return rc;
}
Ejemplo n.º 2
0
dma_addr_t
dma_map_page(struct device *dev, struct page *page, unsigned long offset,
	     size_t size, enum dma_data_direction direction)
{
	dma_addr_t dma_addr;

	BUG_ON(direction == DMA_NONE);

	if (swiotlb) {
		dma_addr = swiotlb_map_page(
			dev, page, offset, size, direction);
	} else {
		dma_addr = page_to_bus(page) + offset;
		IOMMU_BUG_ON(address_needs_mapping(dev, dma_addr));
	}

	return dma_addr;
}
Ejemplo n.º 3
0
static int xen_map_sg(struct device *hwdev, struct scatterlist *sg,
		      int nents,
		      enum dma_data_direction direction,
		      struct dma_attrs *attrs)
{
	struct scatterlist *s;
	struct page *page;
	int i, rc;

	BUG_ON(direction == DMA_NONE);
	WARN_ON(nents == 0 || sg[0].length == 0);

	for_each_sg(sg, s, nents, i) {
		BUG_ON(!sg_page(s));
		page = sg_page(s);
		s->dma_address = xen_dma_map_page(page) + s->offset;
		s->dma_length = s->length;
		IOMMU_BUG_ON(range_straddles_page_boundary(
				page_to_phys(page), s->length));
	}