From owner-freebsd-mips@FreeBSD.ORG Mon Aug 8 20:17:35 2011 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 23B06106566C for ; Mon, 8 Aug 2011 20:17:35 +0000 (UTC) (envelope-from rmh.aybabtu@gmail.com) Received: from mail-iy0-f172.google.com (mail-iy0-f172.google.com [209.85.210.172]) by mx1.freebsd.org (Postfix) with ESMTP id E55E28FC1C for ; Mon, 8 Aug 2011 20:17:34 +0000 (UTC) Received: by iye7 with SMTP id 7so9919229iye.17 for ; Mon, 08 Aug 2011 13:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=4ygRAzFqHOoxs/79R12mRBqLjmoySKb2VWx3Yb61W94=; b=XlNytoSw1n+Pjf3/6jF7cGJgK6s37DdWfwYlr2gYiCrDudS3hyoy33GQcfA0UcxcyW 5sL0OkgE19oR84Aunr2jqzgzMs3ixBiX4o7eQAMeelxvA3SYHUqoK5ladDj0tYeXFAGJ tn4YMV3IMx3LXRN1hQl4AbnaJz4AwMG9avAgU= MIME-Version: 1.0 Received: by 10.42.146.133 with SMTP id j5mr6150992icv.180.1312834654229; Mon, 08 Aug 2011 13:17:34 -0700 (PDT) Sender: rmh.aybabtu@gmail.com Received: by 10.43.45.134 with HTTP; Mon, 8 Aug 2011 13:17:34 -0700 (PDT) Date: Mon, 8 Aug 2011 22:17:34 +0200 X-Google-Sender-Auth: 8-5dvvJHZymcSx9oBza6OGiDag0 Message-ID: From: Robert Millan To: freebsd-mips@freebsd.org Content-Type: multipart/mixed; boundary=90e6ba613ad036d55604aa042315 Subject: [PATCH] missing bus_alloc_resouce() calls for i8259 X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2011 20:17:35 -0000 --90e6ba613ad036d55604aa042315 Content-Type: text/plain; charset=UTF-8 Attached patch fixes this problem when booting the MALTA flavour on QEMU: le0: irq 0 at device 11.0 on pci0 le0: Lazy allocation of 0x20 bytes rid 0x10 type 4 at 0x20 qemu: hardware error: register_ioport_write: invalid opaque >From QEMU side, it appears that this I/O allocation is using the wrong address: 0x20 is reserved for the i8259 controller. >From FreeBSD kernel side, it appears that 0x20 is assigned to le driver because it hasn't been allocated by anybody else. i8259 is hooked to PCI bus on MALTA (or at least on QEMU/MALTA), but there's no corresponding bus_alloc_resource() call. So I've added bus_alloc_resource() calls to register the i8259 as a child of GT64120 PCI bridge. It appears to work, as QEMU now breaks when allocating le ports at 0x40 rather than 0x20: le0: irq 0 at device 11.0 on pci0 le0: Lazy allocation of 0x20 bytes rid 0x10 type 4 at 0x40 qemu: hardware error: register_ioport_write: invalid opaque 0x40 is for i8254 controller. I could not find code to use this controller, but looking at platform_start() for MALTA I assume time is tracked by CPU count register without any external time source (not even for calibration! is that so?), and therefore i8254 is not used. Is there supposed to be a bus_alloc_resource() explicitly for i8254 too? I'm not sure if my patch is the right approach. In case it is, I know it's a bit kludgy; if you're interested, I could clean it up for your consideration. I'd propose adding a new function that takes care of i8259 stuff separately from gt_attach(), including bus_alloc_resource() registration and the register initialization above that. -- Robert Millan --90e6ba613ad036d55604aa042315 Content-Type: text/x-patch; charset=US-ASCII; name="006_mips_i8259_alloc.diff" Content-Disposition: attachment; filename="006_mips_i8259_alloc.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gr3vrkuu0 LS0tIGEvc3lzL21pcHMvbWFsdGEvZ3RfcGNpLmMKKysrIGIvc3lzL21pcHMvbWFsdGEvZ3RfcGNp LmMKQEAgLTQwMSw3ICs0MDEsMjIgQEAKIAl9CiAKIAkvKiBJbml0aWFsaXplIG1lbW9yeSBhbmQg aS9vIHJtYW5zLiAqLwotCWRldmljZV9hZGRfY2hpbGQoZGV2LCAicGNpIiwgYnVzbm8pOworCXsK KwkJZGV2aWNlX3QgY2hpbGQ7CisJCWludCByaWQ7CisJCXZvaWQgKnJlczsKKworCQljaGlsZCA9 IGRldmljZV9hZGRfY2hpbGQoZGV2LCAicGNpIiwgYnVzbm8pOworCisJCXJlcyA9IGJ1c19hbGxv Y19yZXNvdXJjZShjaGlsZCwgU1lTX1JFU19JT1BPUlQsICZyaWQsIElPX0lDVTEsIElPX0lDVTEg KyBJT19JQ1VTSVpFLCBJT19JQ1VTSVpFLCBSRl9BQ1RJVkUpOworCQlpZiAocmVzID09IE5VTEwp CisJCQlkZXZpY2VfcHJpbnRmKGNoaWxkLCAiY2Fubm90IGFsbG9jYXRlIHJlZ2lzdGVyc1xuIik7 CisKKwkJcmVzID0gYnVzX2FsbG9jX3Jlc291cmNlKGNoaWxkLCBTWVNfUkVTX0lPUE9SVCwgJnJp ZCwgSU9fSUNVMiwgSU9fSUNVMiArIElPX0lDVVNJWkUsIElPX0lDVVNJWkUsIFJGX0FDVElWRSk7 CisJCWlmIChyZXMgPT0gTlVMTCkKKwkJCWRldmljZV9wcmludGYoY2hpbGQsICJjYW5ub3QgYWxs b2NhdGUgcmVnaXN0ZXJzXG4iKTsKKwl9CisKIAlyZXR1cm4gKGJ1c19nZW5lcmljX2F0dGFjaChk ZXYpKTsKIH0KIAo= --90e6ba613ad036d55604aa042315--