All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
To: Programmingkid <programmingkidx@gmail.com>
Cc: jasowang@redhat.com, qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] Make rtl8139 network interface card compatible with Mac OS 10.4
Date: Thu, 31 Dec 2015 13:23:52 +0000	[thread overview]
Message-ID: <56852C68.9050509@ilande.co.uk> (raw)
In-Reply-To: <251F828B-25A7-41D1-B536-4CEC57A02EDE@gmail.com>

On 30/12/15 17:50, Programmingkid wrote:

>> Okay. I've just posted a revised patchset to the OpenBIOS list which may
>> (or may not) help, so please test with that aswell to see if it makes a
>> difference.
> 
> I have test your patch set. First I disabled my change to the pci_dma_read() function. Then I activated my change to the rtl8139.c file. The nic didn't work. The driver detected the nic, but DHCP did not set it up. Disabling my change to the rtl8139.c file causes a timeout message to be printed by the driver. 
> 
> When I was doing my research, I did a test where I changed the call to memory_region_set_enabled() in do_pci_register_device() to set everything to true instead of false. The MemoryRegion's enabled property was false by the time the RTL8139 tried using the pci_dma_read() function. I think something might be setting the enabled variable to false for some reason.

I've managed to get something reasonably similar here with my Darwin
image, and with the new OpenBIOS patchset then I get chip reset errors
similar to you - but if I then just apply the BAR swap part of your
patch then the error seemingly goes away. So this seems to confirm that
the OpenBIOS patchset is doing the right thing and the call to
memory_region_set_enabled() isn't required.

>>>> It looks like we have to face up to the reality that Apple's OF
>>>> implementation likes to enable bus mastering for some cards and emulate
>>>> this behaviour in OpenBIOS, since because of this some drivers don't
>>>> explicitly enable bus mastering and so fail under emulation.
>>>>
>>>> I'll go back and revisit Zoltan's patches to see if we can come up with
>>>> something that works better for OpenBIOS upstream. In the meantime I
>>>> still can't quite work out why you still need to swap the BARs around as
>>>> AFAICT both the mmio and io BARs are mapped onto the chip registers -
>>>> any chance you could add some debugging to QEMU in order to figure out
>>>> what is going wrong without your patch?
>>>
>>> I have done a lot of debugging. With only the pci_dma_read() change applied to QEMU, nothing the Mac OS X driver does ever accesses any of the functions from the rtl8139.c file (as far as I can tell). I will add that when this code "if ( csrRead8( RTL_CM ) & R_CM_RST )" is executed by the driver, the value is 16. It appeared to be pretty consistent. The value returned by just "csrRead8( RTL_CM )" is 24. 
>>
>> Right, so then the question to ask is what is the difference in
>> behaviours both before and after the BAR swap? It seems that you're
>> getting a value back but presumably it must be a different value with
>> your patch applied.
> 
> The difference is I see activity in the RTL8139.c file when I made the swap. Without the change, none of the I/O functions in the RTL8139.c file are called.
> 
> This is what I did. I added this code "printf("RTL8139: %s() called\n", __FUNCTION__);" to these functions in the rtl8139.c file: 
> rtl8139_mmio_writeb()
> rtl8139_mmio_writew()
> rtl8139_mmio_writel()
> rtl8139_mmio_readb()
> rtl8139_mmio_readw()
> rtl8139_mmio_readl()
> rtl8139_ioport_write()
> rtl8139_ioport_read()
> 
> If a register read and write from the driver doesn't access one of these functions, what else could it be accessing? 

Yeah, I see that too. Given that you have the source to the Apple
RTL8139 driver at hand, can you try with a patched OpenBIOS using the
bus master patchset on the mailing list and also add some debugging to
your copy of
http://www.opensource.apple.com/source/AppleRTL8139Ethernet/AppleRTL8139Ethernet-141/RTL8139.cpp
or similar like this to display the csrMap and csrBase variables:


// Get the virtual address mapping of CSR registers located at
// Base Address Range 0 (0x10).

csrMap = pciNub->mapDeviceMemoryWithRegister( kIOPCIConfigBaseAddress1 );

DEBUG_LOG("csrMap: %x\n", csrMap);

if ( 0 == csrMap )
    break;

csrBase = (volatile void*)csrMap->getVirtualAddress();

DEBUG_LOG("csrBase: %x\n", csrBase);


At the very least these should give the addresses that the driver is
trying to use in order to access the chip. If you can try this both
before and after swapping the BARs over in QEMU that would be great.


ATB,

Mark.

  reply	other threads:[~2015-12-31 13:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-29 17:59 [Qemu-devel] [PATCH] Make rtl8139 network interface card compatible with Mac OS 10.4 Programmingkid
2015-12-29 21:04 ` Mark Cave-Ayland
2015-12-30  0:05   ` Programmingkid
2015-12-30  0:35     ` Programmingkid
2015-12-30 14:03       ` Mark Cave-Ayland
2015-12-30 16:47         ` Programmingkid
2015-12-30 16:58           ` Mark Cave-Ayland
2015-12-30 17:50             ` Programmingkid
2015-12-31 13:23               ` Mark Cave-Ayland [this message]
2015-12-31 18:26                 ` Programmingkid
2015-12-31 18:56                   ` Mark Cave-Ayland
2015-12-31 19:47                     ` Programmingkid
2016-01-02  4:00                     ` Programmingkid
2016-01-02  9:39                       ` Mark Cave-Ayland
2016-01-02 17:08                         ` Programmingkid
2016-01-02 20:46                           ` Mark Cave-Ayland
2016-01-01 21:36       ` Paolo Bonzini
2016-01-01 21:49         ` Programmingkid
2016-01-01 20:32 ` Paolo Bonzini
2016-01-01 20:42   ` Programmingkid
2016-01-01 22:36     ` Paolo Bonzini
2016-01-01 22:42       ` Programmingkid

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=56852C68.9050509@ilande.co.uk \
    --to=mark.cave-ayland@ilande.co.uk \
    --cc=jasowang@redhat.com \
    --cc=programmingkidx@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.