Re: [PATCH] sh: use declared coherent memory for dreamcast pci ethernet adapter

Magnus Damm
2008-01-25T04:16:21Z

[-- Attachment #1: Type: text/plain, Size: 2179 bytes --]

On Jan 25, 2008 7:53 AM, Adrian McMenamin
<adrian@newgolddream.dyndns.info> wrote:
> On Thu, 2008-01-24 at 22:33 +0000, Adrian McMenamin wrote:
> > On Thu, 2008-01-24 at 18:40 +0900, Magnus Damm wrote:
> > > sh: use declared coherent memory for dreamcast pci ethernet adapter
> > >
> > > This patch makes the dreamcast use the recently added declared coherent
> > > memory functions to point out the memory window suitable for dma.
> > >
> > > Apart from cleaning up, this gives the dreamcast a proper memory allocator
> > > for pci dma memory.
> > >
> > > Signed-off-by: Magnus Damm <damm@igel.co.jp>
> >
> >
> > I get this now:
> >
> > [ 2.894858] IP-Config: Failed to open eth0
> > [ 2.898395] IP-Config: No network devices available.
> >
> > So it appears, on first blush, that the patch breaks the driver. I'll
> > test further to confirm.
> >
>
> I can confirm that the patches:
>
> f838a96ef5cdc261cb458b154e79b259688008b8
> b82c3460d4a2d86cdac80e178a76f3833f1aecba
> 1b0a4750bf70d0e6f1b4ef573b1231530b9891be
>
> all need to be reverted as they break the Dreamcast network driver

Hi Adrian,

Thanks for testing and sorry about breaking the dreamcast ethernet
driver. We do need declared coherent memory support for the sm501 chip
and there shouldn't be any problems with using that interface for the
dreamcast. At least in theory. =)

I did unfortunately introduce a generic bug with the declared coherent
memory V2 patch yesterday, but I've posted a fix for that earlier
today. I don't however think that fix will help you. What you're
seeing seems to be that IP-config doesn't work which hints that packet
data isn't transferred as it should. And in your case it's most likely
because some virtual address or dma handle isn't setup properly.

The main thing here is that dma_alloc_coherent() should return the
same virtual address and dma handle regardless if my coherent patches
are applied. Or the values should at least be sane.

Can you please apply the attached patch and test both with and without
the 3 declared coherent patches? I'd like to see the values printed
out by printk() both with and without the declared coherent patches.

Thank you.

/ magnus

[-- Attachment #2: linux-2.6.25-pre-sh-8139too-dma-printk-20080125.patch --]
[-- Type: application/octet-stream, Size: 710 bytes --]

--- 0001/drivers/net/8139too.c
+++ work/drivers/net/8139too.c 2008-01-25 13:08:46.000000000 +0900
@@ -1311,6 +1311,15 @@ static int rtl8139_open (struct net_devi
&tp->tx_bufs_dma, GFP_KERNEL);
tp->rx_ring = dma_alloc_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN,
&tp->rx_ring_dma, GFP_KERNEL);
+
+ printk("zzzzzzzz:"
+ "tx_bufs = 0x%08lx/0x%08lx, "
+ "rx_ring = 0x%08lx/0x%08lx, "
+ "(0x%08lx)\n",
+ (unsigned long)tp->tx_bufs, (unsigned long)tp->tx_bufs_dma,
+ (unsigned long)tp->rx_ring, (unsigned long)tp->rx_ring_dma,
+ (unsigned long)tp->pci_dev->dev.dma_mem);
+
if (tp->tx_bufs == NULL || tp->rx_ring == NULL) {
free_irq(dev->irq, dev);