Received: from eggs.gnu.org ([2001:4830:134:3::10]:59580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFPfN-0008Id-JM for qemu-devel@nongnu.org; Sat, 02 Jan 2016 12:08:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aFPfK-00082k-Dn for qemu-devel@nongnu.org; Sat, 02 Jan 2016 12:08:33 -0500 Received: from mail-io0-x22b.google.com ([2607:f8b0:4001:c06::22b]:33250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFPfK-00082e-AC for qemu-devel@nongnu.org; Sat, 02 Jan 2016 12:08:30 -0500 Received: by mail-io0-x22b.google.com with SMTP id q21so123903077iod.0 for ; Sat, 02 Jan 2016 09:08:30 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Programmingkid In-Reply-To: <56879ABD.9020607@ilande.co.uk> Date: Sat, 2 Jan 2016 12:08:28 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: <37C0F0B1-54C0-4AED-ABEE-5312C396AE98@gmail.com> References: <5682F552.90305@ilande.co.uk> <9C26B2B6-1384-437E-B60F-8CC452F2F159@gmail.com> <5683E43A.9040203@ilande.co.uk> <96B9267A-2429-4C38-B187-0A8F68B5A991@gmail.com> <56840D2B.7020908@ilande.co.uk> <251F828B-25A7-41D1-B536-4CEC57A02EDE@gmail.com> <56852C68.9050509@ilande.co.uk> <56857A42.8050903@ilande.co.uk> <697CCE7B-D01D-4009-9203-6D319A60AE77@gmail.com> <56879ABD.9020607@ilande.co.uk> Subject: Re: [Qemu-devel] [PATCH] Make rtl8139 network interface card compatible with Mac OS 10.4 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Cave-Ayland Cc: Paolo Bonzini , jasowang@redhat.com, qemu-devel qemu-devel On Jan 2, 2016, at 4:39 AM, Mark Cave-Ayland wrote: > On 02/01/16 04:00, Programmingkid wrote: >=20 >>> Well they are returning non-zero values, so that's good. After a bit >>> more poking, something doesn't make sense - in that same file >>> RTL8139::initPCIConfigSpace() claims to set the bus master bit, but = if I >>> add tracing to hw/pci/pci-host.c then I don't see any writes to the = PCI >>> command register outside of OpenBIOS? Any chance you can add = debugging >>> to the before and after values for the reg16 variable which this >>> function claims to set? >>>=20 >>> Also with similar tracing involved, apparently the writes to PCI I/O >>> space in order to access the chip registers are actually going = through >>> pci_host_config_write(), i.e. configuration space rather than I/O = space >>> which is why they aren't accessing the chip registers. So more = digging >>> is required to figure out why this is happening. >>>=20 >>=20 >> I added code to the initPCIConfigSpace() function that prints every = register from 0 to 0x3e. All of the registers returned zero. My patch = was fully applied when the driver printed all these values. I even had = all the registers set to 0x99 then printed all the registers again. The = registers all returned zero again. The driver was able to obtain the = correct device, function, and bus numbers. PCI configuration space is = not being accessed correctly by this driver.=20 >=20 > After some head scratching chasing this through for several hours > yesterday, I've worked out what is happening and have a patchset for > OpenBIOS which should fix the issue (will post later along with some > other PCI fixes for testing). >=20 > This is actually a bug in Darwin in that it doesn't parse the address > space part of the "ranges" property for the /pci node. OpenBIOS adds = all > 3 spaces to the "ranges" - configuration, I/O and memory compared to > real Macs which only add I/O and memory. Which is generally fine = because > each entry contains a 2-bit indicator so that the OS knows which entry > represents each address space. >=20 > Except that Darwin evidently doesn't bother parsing the address space > from each "range" entry and blindly assumes that entry 0 is I/O space > and entry 1 is memory space as would be found in a real Mac device = tree. > The result of this is that currently I/O accesses go to entry 0 = (config > space) and memory accesses go to entry 1 (I/O space) which is why the > RTL8139 happens to work with your patch to force bus mastering. >=20 > AFAICT with basic testing here, forcing the /pci node to mimic that of = a > real Mac by omitting the configuration space entry seems to fix all = PCI > accesses (or at least they get routed to the correct address spaces), = I > see an attempt to set the bus master bit in the command register, and = I > don't get a reset timeout on startup for the RTL8139 anymore. Wow, you figure out stuff fast! Will be waiting for your patches.=