linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Jeff Garzik <jgarzik@pobox.com>,
	Linux/m68k <linux-m68k@vger.kernel.org>,
	Linux/m68k on Mac <linux-mac68k@mac.linux-m68k.org>,
	Linux MIPS <linux-mips@vger.kernel.org>,
	Linux kernel <linux-kernel@vger.kernel.org>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Subject: Re: [PATCH] Jazzsonic driver updates
Date: Thu, 16 Jun 2005 02:53:22 +1000 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.61.0506160218310.24328@loopy.telegraphics.com.au> (raw)
In-Reply-To: <20050615142717.GD9411@linux-mips.org>



On Wed, 15 Jun 2005, Ralf Baechle wrote:

> On Thu, Jun 16, 2005 at 12:02:33AM +1000, Finn Thain wrote:
> 
> > > The Jazz DMA hardware is an MMU that translates virtual DMA to 
> > > physical addresses.  It's virtual DMA address space is 16MB in size, 
> > > it's page size is 4kB.  That's a set of capabilities that nicely 
> > > translates into the DMA API.
> > 
> > I gather that someone has already put this hardware under the control 
> > of the generic DMA API?
> 
> That's being worked on.

OK, I guess I should code for it then. It is difficult to avoid converting 
the sonic core to the DMA API if I'm going to adopt it for macsonic. It 
just means that my changes to jazzsonic can't be tested yet, and so my 
work will remain out-of-tree.

> > > > Would I be right to say that vdma_{alloc,free}() can be changed to 
> > > > dma_{,un}map_single? The other Jazz specific routine that sonic 
> > > > uses is vdma_log2phys, and I don't know if that has a better 
> > > > alternative.
> > > 
> > > The use of that call should simply be eleminated entirely.  DMA API 
> > > functions such as dma_alloc_coherent or dma_map_single will return a 
> > > dma_handle which along with the virtual address returned is 
> > > everything ever needed to program a DMA engine.
> > 
> > The sonic chip stores packets inside a "receive resource area" at a 
> > physical address that depends on the packets it previously stored 
> > there.
> > 
> > So the chip determines that address and the driver has to convert it 
> > from a physical to a virtual address with KSEG1ADDR(vdma_log2phys(x)), 
> > in order to memcpy the received packet.
> 
> Wrong.  The Sonic only does DMA to DMA addresses which will be 
> translated to physical addresses by the IOMMU.  That is it never ever 
> deals with physical addresses directly.

OK.

> When transmitting or receiving a buffer it has to be mapped into the DMA 
> controller's address space first, for example through dma_map_single.
> 
> As the result you will obtain a DMA address which you will feed to the 
> Sonic or put into a rx or tx ring, whatever.  And you need to remember 
> it in the driver private data, just like the virtual address of the 
> buffer or the struct sk_buff pointer.  So all you need is to look at 
> your private data to find that virtual address you need for memcpy.

Not quite. The virtual address you are talking about is the beginning of 
the receive resource area, which is mapped as you describe. But, the chip 
then decides where in that area the recieved packet gets buffered, and the 
chip reports the address of that packet as a pointer. And this is why 
vdma_log2phys is used to convert the location of the packet (in IOMMU 
virtual address space) into CPU virtual address where the packet can be 
found by memcpy. And that is why I was asking for an alternative to 
vdma_log2phys. But I think calculating the offset of the packet with some 
IOMMU virtual pointer arithmetic will suffice in this case, since the 
initial mapping is probably going to be linear.

-f

> tg3 is a reasonable example of a driver - albeit not a simple one.
> 
> > >From what code I've looked at, and from what you've told me, I'm guessing 
> > that bus_to_virt() won't cut it here (?)
> 
> bus_to_virt and virt_to_bus are shooting offences these days, no less.
> 
>   Ralf
> -
> To unsubscribe from this list: send the line "unsubscribe linux-mips" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2005-06-15 16:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200503070210.j272ARii023023@hera.kernel.org>
2005-03-22 17:13 ` [PATCH] Jazzsonic driver updates Geert Uytterhoeven
2005-03-23  2:30   ` [PATCH] " Finn Thain
2005-03-23 10:01   ` Ralf Baechle
2005-03-23 10:47     ` Finn Thain
2005-06-12  6:05     ` Finn Thain
2005-06-15 11:41       ` Ralf Baechle
2005-06-15 14:02         ` Finn Thain
2005-06-15 14:27           ` Ralf Baechle
2005-06-15 16:53             ` Finn Thain [this message]
2005-06-15 17:45               ` Finn Thain
2005-06-16  9:22                 ` Ralf Baechle
2005-06-16 12:14                   ` Finn Thain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0506160218310.24328@loopy.telegraphics.com.au \
    --to=fthain@telegraphics.com.au \
    --cc=geert@linux-m68k.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=linux-mac68k@mac.linux-m68k.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=ralf@linux-mips.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).