linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* consistent_alloc() on PPC
@ 2005-01-19 11:53 Sachin P
  2005-01-19 14:04 ` Matt Porter
  2005-01-19 14:10 ` Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: Sachin P @ 2005-01-19 11:53 UTC (permalink / raw)
  To: Linuxppc-dev

Hi , 
I am facing some problems porting my drivers to the PPC platform . Am
currently using consistent_alloc() and consistent_free() to
allocate/free (non-cached) DMA ble memory.
Is there any function/patch/macro, equivalent to
phy_to_virt()/virt_to_phy() for memory returned by consistent_alloc()?

Regards
sachin

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

* consistent_alloc() on PPC
@ 2005-01-19 11:53 Sachin P
  2005-01-19 15:14 ` Jörn Engel
  0 siblings, 1 reply; 8+ messages in thread
From: Sachin P @ 2005-01-19 11:53 UTC (permalink / raw)
  To: Linuxppc-embedded

Hi , 
I am facing some problems porting my drivers to the PPC platform . Am
currently using consistent_alloc() and consistent_free() to
allocate/free (non-cached) DMA ble memory.
Is there any function/patch/macro, equivalent to
phy_to_virt()/virt_to_phy() for memory returned by consistent_alloc()?

Regards
sachin

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

* Re: consistent_alloc() on PPC
  2005-01-19 11:53 consistent_alloc() on PPC Sachin P
@ 2005-01-19 14:04 ` Matt Porter
  2005-01-19 14:10 ` Christoph Hellwig
  1 sibling, 0 replies; 8+ messages in thread
From: Matt Porter @ 2005-01-19 14:04 UTC (permalink / raw)
  To: Sachin P; +Cc: Linuxppc-dev

On Wed, Jan 19, 2005 at 05:23:17PM +0530, Sachin P wrote:
> Hi , 
> I am facing some problems porting my drivers to the PPC platform . Am
> currently using consistent_alloc() and consistent_free() to
> allocate/free (non-cached) DMA ble memory.
> Is there any function/patch/macro, equivalent to
> phy_to_virt()/virt_to_phy() for memory returned by consistent_alloc()?

iopa()

-Matt

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

* Re: consistent_alloc() on PPC
  2005-01-19 11:53 consistent_alloc() on PPC Sachin P
  2005-01-19 14:04 ` Matt Porter
@ 2005-01-19 14:10 ` Christoph Hellwig
  2005-01-19 14:56   ` Matt Porter
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2005-01-19 14:10 UTC (permalink / raw)
  To: Sachin P; +Cc: Linuxppc-dev

On Wed, Jan 19, 2005 at 05:23:17PM +0530, Sachin P wrote:
> Hi , 
> I am facing some problems porting my drivers to the PPC platform . Am
> currently using consistent_alloc() and consistent_free() to
> allocate/free (non-cached) DMA ble memory.
> Is there any function/patch/macro, equivalent to
> phy_to_virt()/virt_to_phy() for memory returned by consistent_alloc()?

Don't ever use concistant_alloc directly.  Always use
dma_alloc_coherent() which will give you both virtual and bus address.

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

* Re: consistent_alloc() on PPC
  2005-01-19 14:10 ` Christoph Hellwig
@ 2005-01-19 14:56   ` Matt Porter
  2005-01-20 16:30     ` Sachin P
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Porter @ 2005-01-19 14:56 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Linuxppc-dev, Sachin P

On Wed, Jan 19, 2005 at 03:10:48PM +0100, Christoph Hellwig wrote:
> On Wed, Jan 19, 2005 at 05:23:17PM +0530, Sachin P wrote:
> > Hi , 
> > I am facing some problems porting my drivers to the PPC platform . Am
> > currently using consistent_alloc() and consistent_free() to
> > allocate/free (non-cached) DMA ble memory.
> > Is there any function/patch/macro, equivalent to
> > phy_to_virt()/virt_to_phy() for memory returned by consistent_alloc()?
> 
> Don't ever use concistant_alloc directly.  Always use
> dma_alloc_coherent() which will give you both virtual and bus address.

He's obviously not talking about 2.6 since he's mentioning
consistent_alloc().  I removed those PPC-specific APIs when I
updated our DMA API implementation in 2.6.

-Matt

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

* Re: consistent_alloc() on PPC
  2005-01-19 11:53 Sachin P
@ 2005-01-19 15:14 ` Jörn Engel
  0 siblings, 0 replies; 8+ messages in thread
From: Jörn Engel @ 2005-01-19 15:14 UTC (permalink / raw)
  To: Sachin P; +Cc: Linuxppc-embedded

On Wed, 19 January 2005 17:23:42 +0530, Sachin P wrote:
> 
> I am facing some problems porting my drivers to the PPC platform . Am
> currently using consistent_alloc() and consistent_free() to
> allocate/free (non-cached) DMA ble memory.
> Is there any function/patch/macro, equivalent to
> phy_to_virt()/virt_to_phy() for memory returned by consistent_alloc()?

Imo not.  I ended up writing a private version of it, along these
lines:

static inline unsigned long private_io_to_bus(void *addr)
{
        return iopa((unsigned long)addr) + offset;
}

Wouldn't hurt if you could generalize it somehow.

Jörn

-- 
Everything should be made as simple as possible, but not simpler.
-- Albert Einstein

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

* Re: consistent_alloc() on PPC
  2005-01-19 14:56   ` Matt Porter
@ 2005-01-20 16:30     ` Sachin P
  2005-01-20 18:16       ` Matt Porter
  0 siblings, 1 reply; 8+ messages in thread
From: Sachin P @ 2005-01-20 16:30 UTC (permalink / raw)
  To: Linuxppc-dev

Hi,
Thanks a lot to all of you for the help . 
The following is a more clearer version of the problem I am facing :

1.I am porting drivers from X86 (running Linux 2.4-20) to 
  PPC platform running (Montevista Linux-2.4.20).
2.In  wrapper function for DMA allocation, I am using 
  consistent_alloc() to allocate the memory. This function gives me
  both the virtual-address as well as the dma-address.
  I pass both these values to the upper-level drivers.
3. However , once the upper-level drivers are done with the memory
   they call the wrapper function for free dma and pass only the dma
   address and not the virtual-address. However consistent_free() 
   accepts only virtual-address. 
   Hence I need a way to convert the dma address to the
   virtual-address.  

Regards
sachin


On Wed, 19 Jan 2005 07:56:03 -0700, Matt Porter
<mporter@kernel.crashing.org> wrote:
> On Wed, Jan 19, 2005 at 03:10:48PM +0100, Christoph Hellwig wrote:
> > On Wed, Jan 19, 2005 at 05:23:17PM +0530, Sachin P wrote:
> > > Hi ,
> > > I am facing some problems porting my drivers to the PPC platform . Am
> > > currently using consistent_alloc() and consistent_free() to
> > > allocate/free (non-cached) DMA ble memory.
> > > Is there any function/patch/macro, equivalent to
> > > phy_to_virt()/virt_to_phy() for memory returned by consistent_alloc()?
> >
> > Don't ever use concistant_alloc directly.  Always use
> > dma_alloc_coherent() which will give you both virtual and bus address.
> 
> He's obviously not talking about 2.6 since he's mentioning
> consistent_alloc().  I removed those PPC-specific APIs when I
> updated our DMA API implementation in 2.6.
> 
> -Matt
>

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

* Re: consistent_alloc() on PPC
  2005-01-20 16:30     ` Sachin P
@ 2005-01-20 18:16       ` Matt Porter
  0 siblings, 0 replies; 8+ messages in thread
From: Matt Porter @ 2005-01-20 18:16 UTC (permalink / raw)
  To: Sachin P; +Cc: Linuxppc-dev

On Thu, Jan 20, 2005 at 10:00:47PM +0530, Sachin P wrote:
> Hi,
> Thanks a lot to all of you for the help . 
> The following is a more clearer version of the problem I am facing :
> 
> 1.I am porting drivers from X86 (running Linux 2.4-20) to 
>   PPC platform running (Montevista Linux-2.4.20).
> 2.In  wrapper function for DMA allocation, I am using 
>   consistent_alloc() to allocate the memory. This function gives me
>   both the virtual-address as well as the dma-address.
>   I pass both these values to the upper-level drivers.
> 3. However , once the upper-level drivers are done with the memory
>    they call the wrapper function for free dma and pass only the dma
>    address and not the virtual-address. However consistent_free() 
>    accepts only virtual-address. 
>    Hence I need a way to convert the dma address to the
>    virtual-address.  

All you need to do is cache the virtual address and the dma/phys
address for later use when calling consistent_free(). converting
random DMA/phys to virtual is a bad idea since you are going to
find multiple mappings. Cache the results in your driver...it's
trivial.

-Matt

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

end of thread, other threads:[~2005-01-20 18:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-19 11:53 consistent_alloc() on PPC Sachin P
2005-01-19 14:04 ` Matt Porter
2005-01-19 14:10 ` Christoph Hellwig
2005-01-19 14:56   ` Matt Porter
2005-01-20 16:30     ` Sachin P
2005-01-20 18:16       ` Matt Porter
  -- strict thread matches above, loose matches on Subject: below --
2005-01-19 11:53 Sachin P
2005-01-19 15:14 ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).