[openib-general] IB/ipath - Implement new verbs DMA mapping functions

Or Gerlitz ogerlitz at voltaire.com
Sat Nov 11 23:25:11 PST 2006


Ralph Campbell wrote:
> IB/ipath - Implement new verbs DMA mapping functions
> 
> This patch implements the interposing DMA mapping functions to allow
> support for IOMMUs and remove the dependence on phys_to_virt().

> diff -r f37bd0e41fec drivers/infiniband/hw/ipath/ipath_dma.c
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/drivers/infiniband/hw/ipath/ipath_dma.c	Fri Oct 27 10:40:03 2006 -0800
> +/**
> + * ipath_dma_map_single - Map a kernel virtual address to DMA address
> + * @device: The device for which the dma_addr is to be created
> + * @cpu_addr: The kernel virtual address
> + * @size: The size of the region in bytes
> + * @direction: The direction of the DMA
> + */
> +static dma_addr_t ipath_dma_map_single(struct ib_device *dev,
> +				       void *cpu_addr, size_t size,
> +				       enum dma_data_direction direction)
> +{
> +	BUG_ON(direction == DMA_NONE);
> +	return (dma_addr_t) cpu_addr;
> +}

This is a bug since there are architectures eg PPC64 where the native 
address size is u64 but dma_addr_t is u32. You are somehow in a problem 
here, since returning an unchopped cpu_addr to the consumer might cause 
a memory corruption as they are expecting 32 bit value.

Or.





More information about the general mailing list