public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [HOWTO] accessing the DMA mapped data
@ 2007-05-10  7:58 Mahesh
  2007-05-10  8:47 ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Mahesh @ 2007-05-10  7:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernelnewbies

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.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [HOWTO] accessing the DMA mapped data
  2007-05-10  7:58 [HOWTO] accessing the DMA mapped data Mahesh
@ 2007-05-10  8:47 ` David Miller
  2007-05-10 11:19   ` Mahesh
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2007-05-10  8:47 UTC (permalink / raw)
  To: maheshk; +Cc: linux-kernel, kernelnewbies

From: Mahesh <maheshk@cdac.in>
Date: Thu, 10 May 2007 13:28:13 +0530

> 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???

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [HOWTO] accessing the DMA mapped data
  2007-05-10  8:47 ` David Miller
@ 2007-05-10 11:19   ` Mahesh
  2007-05-10 11:32     ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Mahesh @ 2007-05-10 11:19 UTC (permalink / raw)
  To: David Miller; +Cc: linux-kernel, kernelnewbies

Hi Miller,

Thanks for replying.
> 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [HOWTO] accessing the DMA mapped data
  2007-05-10 11:19   ` Mahesh
@ 2007-05-10 11:32     ` David Miller
  2007-05-10 11:41       ` Mahesh
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2007-05-10 11:32 UTC (permalink / raw)
  To: maheshk; +Cc: linux-kernel, kernelnewbies

From: Mahesh <maheshk@cdac.in>
Date: Thu, 10 May 2007 16:49:03 +0530

> 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 ??

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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [HOWTO] accessing the DMA mapped data
  2007-05-10 11:32     ` David Miller
@ 2007-05-10 11:41       ` Mahesh
  2007-05-10 11:47         ` David Miller
  2007-05-10 18:27         ` Roland Dreier
  0 siblings, 2 replies; 8+ messages in thread
From: Mahesh @ 2007-05-10 11:41 UTC (permalink / raw)
  To: David Miller; +Cc: linux-kernel, kernelnewbies

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?
>   
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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [HOWTO] accessing the DMA mapped data
  2007-05-10 11:41       ` Mahesh
@ 2007-05-10 11:47         ` David Miller
  2007-05-11 15:42           ` Muli Ben-Yehuda
  2007-05-10 18:27         ` Roland Dreier
  1 sibling, 1 reply; 8+ messages in thread
From: David Miller @ 2007-05-10 11:47 UTC (permalink / raw)
  To: maheshk; +Cc: linux-kernel, kernelnewbies

From: Mahesh <maheshk@cdac.in>
Date: Thu, 10 May 2007 17:11:17 +0530

> 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?
> > 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [HOWTO] accessing the DMA mapped data
  2007-05-10 11:41       ` Mahesh
  2007-05-10 11:47         ` David Miller
@ 2007-05-10 18:27         ` Roland Dreier
  1 sibling, 0 replies; 8+ messages in thread
From: Roland Dreier @ 2007-05-10 18:27 UTC (permalink / raw)
  To: Mahesh; +Cc: David Miller, linux-kernel, kernelnewbies, general

 > 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
<general@lists.openfabrics.org> to get the best info.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [HOWTO] accessing the DMA mapped data
  2007-05-10 11:47         ` David Miller
@ 2007-05-11 15:42           ` Muli Ben-Yehuda
  0 siblings, 0 replies; 8+ messages in thread
From: Muli Ben-Yehuda @ 2007-05-11 15:42 UTC (permalink / raw)
  To: David Miller; +Cc: maheshk, linux-kernel, kernelnewbies

On Thu, May 10, 2007 at 04:47:32AM -0700, David Miller wrote:
> From: Mahesh <maheshk@cdac.in>
> Date: Thu, 10 May 2007 17:11:17 +0530
> 
> > 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?
> > > 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.

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-05-11 15:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-10  7:58 [HOWTO] accessing the DMA mapped data Mahesh
2007-05-10  8:47 ` David Miller
2007-05-10 11:19   ` Mahesh
2007-05-10 11:32     ` David Miller
2007-05-10 11:41       ` Mahesh
2007-05-10 11:47         ` David Miller
2007-05-11 15:42           ` Muli Ben-Yehuda
2007-05-10 18:27         ` Roland Dreier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox