accessing the DMA mapped data
Hi list,
I have a small question regarding the accessing the data in the DMA mapped region (in the driver). In my driver I only have the 'dma_addr_t addr' variable which is result after the 'dma_map_single'. I don't have access to the virtual address of the data region.
Is there helper routine which we will give me the virtual address back from the DMA mapped address???
After some searching in the net about it found 'dma_sync_single' which will help to synchronize it after 'modifying' the contents of the DMA mapped region. But to 'modify' the contents of DMA mapped region I require the virtual address, which is not available in my case.
Regards,
Mahesh.
From: Mahesh <[email protected]>
Date: Thu, 10 May 2007 13:28:13 +0530
Quoted 7 lines
I have a small question regarding the accessing the data in the DMA mapped region (in the driver). In my driver I only have the '
dma_addr_taddr' variable which is result after the 'dma_map_single'. I don't have access to the virtual address of the data region.Is there helper routine which we will give me the virtual address back from the DMA mapped address???
You can eithe keep track of this yourself, or (depending upon your usage) you might be able to use DMA pools, see dma_pool_create() and friends.
Hi Miller,
Thanks for replying.
Quoted 4 lines
You can eithe keep track of this yourself, or (depending upon your usage) you might be able to use DMA pools, see
dma_pool_create()and friends.
I think you have not understood my question properly. My problem is, the layer above the driver will do dma_map_single on a kmalloc'ed buffer and passes the result (bus address) to the device driver. Now the driver has to modify the contents of the the original buffer.
Is it possible to do that ??
-regards,
Mahesh
From: Mahesh <[email protected]>
Date: Thu, 10 May 2007 16:49:03 +0530
Quoted 6 lines
I think you have not understood my question properly. My problem is, the layer above the driver will do
dma_map_singleon a kmalloc'ed buffer and passes the result (bus address) to the device driver. Now
the driver has to modify the contents of the the original buffer. Is it possible to do that ??
You haven't given an example of where this might actually happen.
The driver is where the DMA mappings almost always occur because that is the layer that knows the bus technology and therefore the correct DMA interfaces to call.
What kind of driver do you have and what is this upper layer doing the mappings for you but not giving you a pointer to the kernel buffer as well?
Hi,
Quoted 10 lines
You haven't given an example of where this might actually happen.
The driver is where the DMA mappings almost always occur because that is the layer that knows the bus technology and therefore the correct DMA interfaces to call.
What kind of driver do you have and what is this upper layer doing the mappings for you but not giving you a pointer to the kernel buffer as well?
Here I am dealing with a infiniband (see www.openfabrics.org) network device driver. The layer above the driver is the standard infiniband core interface. Now I have a situation where I need to peek into the packets and do some modifications(some hacking). So I just want know whether I can access the original data region using the bus address generated by the dma_map_single.
FYI, architecture I am working on is x86_64.
-Mahesh
From: Mahesh <[email protected]>
Date: Thu, 10 May 2007 17:11:17 +0530
Quoted 6 lines
Hi, > You haven't given an example of where this might actually happen. > > The driver is where the DMA mappings almost always occur because > that is the layer that knows the bus technology and therefore > the correct DMA interfaces to call. > > What kind of driver do you have and what is this upper layer > doing the mappings for you but not giving you a pointer to > the kernel buffer as well?
Quoted 6 lines
Quoted 1 line
Here I am dealing with a infiniband (see www.openfabrics.org)
network device driver. The layer above the driver is the standard infiniband core interface. Now I have a situation where I need to peek into the packets and do some modifications(some hacking). So I just want know whether I can access the original data region using the bus address generated by the
dma_map_single.
You can't, therefore you need to ask the Inifiniband guys to perhaps tweak the infiniband driver interfaces so that you can get at the buffer or provide some other mechanism by which you can accomplish what you're trying to do.
Quoted 16 lines · David Miller
From: Mahesh <[email protected]>
Date: Thu, 10 May 2007 17:11:17 +0530Quoted 6 lines
Hi, > You haven't given an example of where this might actually happen. > > The driver is where the DMA mappings almost always occur because > that is the layer that knows the bus technology and therefore > the correct DMA interfaces to call. > > What kind of driver do you have and what is this upper layer > doing the mappings for you but not giving you a pointer to > the kernel buffer as well?
Quoted 6 lines
Quoted 1 line
Here I am dealing with a infiniband (see www.openfabrics.org)
network device driver. The layer above the driver is the standard infiniband core interface. Now I have a situation where I need to peek into the packets and do some modifications(some hacking). So I just want know whether I can access the original data region using the bus address generated by the
dma_map_single.
Quoted 4 lines
You can't, therefore you need to ask the Inifiniband guys to perhaps tweak the infiniband driver interfaces so that you can get at the buffer or provide some other mechanism by which you can accomplish what you're trying to do.
AFAICR the ipath driver had the same problem, which resulted in the addition of ib specific DMA-API wrappers. See usage of struct ipath_dma_mapping_ops in ipath_dma.c.
Cheers,
Muli
Quoted 6 lines
Here I am dealing with a infiniband (see www.openfabrics.org) network device driver. The layer above the driver is the standard infiniband core interface. Now I have a situation where I need to peek into the packets and do some modifications(some hacking). So I just want know whether I can access the original data region using the bus address generated by the
dma_map_single.
If you give more details about what you're trying to do, maybe I can suggest a good way to accomplish it.
Also for IB-related stuff you may want to at least CC <[email protected]> to get the best info.