From owner-freebsd-current@FreeBSD.ORG Tue Dec 13 16:01:48 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9BF1016A41F; Tue, 13 Dec 2005 16:01:48 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id B9CB243D6A; Tue, 13 Dec 2005 16:01:47 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 3721127 for multiple; Tue, 13 Dec 2005 11:04:00 -0500 Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.1/8.13.1) with ESMTP id jBDG1fds013472; Tue, 13 Dec 2005 11:01:41 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-current@freebsd.org Date: Tue, 13 Dec 2005 11:01:42 -0500 User-Agent: KMail/1.8.2 References: <20051211181324.G71610@ury.york.ac.uk> <1134481135.15730.76.camel@buffy.york.ac.uk> <1134485368.15730.95.camel@buffy.york.ac.uk> In-Reply-To: <1134485368.15730.95.camel@buffy.york.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-6" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200512131101.44375.jhb@freebsd.org> X-Spam-Status: No, score=-2.8 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: Gleb Smirnoff , imp@freebsd.org Subject: Re: puc fails to attach serial ports X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Dec 2005 16:01:48 -0000 On Tuesday 13 December 2005 09:49 am, Gavin Atkinson wrote: > On Tue, 2005-12-13 at 13:38 +0000, Gavin Atkinson wrote: > > On Mon, 2005-12-12 at 17:04 +0300, Gleb Smirnoff wrote: > > > On Sun, Dec 11, 2005 at 06:22:40PM +0000, Gavin Atkinson wrote: > > > G> I'm trying to use puc(4) under RELENG_6 to attach the two serial > > > ports on G> a PCI card I have, but it's not working. It also fails > > > under 6.0-RELEASE, G> I don't have the ability to test earlier > > > versions. > > > G> > > > G> How can I further diagnose why this card is not getting recognised? > > > > > > Afaik, you need 'device uart', that will attach to your pucs. > > > > No, as far as I can tell, it's sio that should be attaching. I've > > loaded the uart module anyway and it still fails. > > > > With BUS_DEBUG defined, I see the following: > > > > devclass_find_internal:761: looking for puc > > devclass_add_device:1356: (null) in devclass puc > > devclass_alloc_unit:1289: unit -1 in devclass puc > > devclass_alloc_unit:1329: now: unit 0 in devclass puc > > puc0: port 0x18c0-0x18df irq 25 at device 9.0 > > on pci0 > > puc0: Reserved 0x20 bytes for rid 0x10 type 4 at 0x18c0 > > port rid 16 bst 0, start 18c0, end 18df > > puc0: i 0, type sio, ressz 8, type 1 > > devclass_find_internal:761: looking for sio > > puc: Using sio2 > > device_add_child_ordered:1542: sio at puc with order 0 as unit 2 > > make_device:1427: sio at puc as unit 2 > > devclass_find_internal:761: looking for sio > > devclass_add_device:1356: (null) in devclass sio > > devclass_alloc_unit:1289: unit 2 in devclass sio > > devclass_alloc_unit:1329: now: unit 2 in devclass sio > > puc: type 1, bar 10, offset 0 > > devclass_find_driver_internal:1019: sio in devclass puc > > devclass_find_driver_internal:1026: not found > > puc0: i 1, type sio, ressz 8, type 1 > > devclass_find_internal:761: looking for sio > > puc: Using sio3 > > device_add_child_ordered:1542: sio at puc with order 0 as unit 3 > > make_device:1427: sio at puc as unit 3 > > devclass_find_internal:761: looking for sio > > devclass_add_device:1356: (null) in devclass sio > > devclass_alloc_unit:1289: unit 3 in devclass sio > > devclass_alloc_unit:1329: now: unit 3 in devclass sio > > puc: type 1, bar 10, offset 8 > > devclass_find_driver_internal:1019: sio in devclass puc > > devclass_find_driver_internal:1026: not found > > > > I'm sure somebody with more newbus knowledge will know exactly what that > > means... Are we somehow missing a devclass_add_driver(9) call from the > > puc initialisation? I'm almost at the point now where I can't > > understand how it could possibly be working for anyone else. > > OK, I've cracked what's happening. Indeed we are somehow missing a call > to devclass_add_driver(9). I was loading puc as a module, and in that > case the following relevant calls to devclass_add_driver are made: > > devclass_add_driver: adding puc to cardbus > devclass_add_driver: adding puc to pci > devclass_add_driver: adding puc to pccard > devclass_add_driver: adding uart to puc > devclass_add_driver: adding sio to pccard > devclass_add_driver: adding sio to pci > devclass_add_driver: adding sio to cardbus > devclass_add_driver: adding sio to isa > devclass_add_driver: adding sio to acpi > > When compiling puc into the kernel as opposed to using the module, the > following extra call is made: > > devclass_add_driver: adding sio to puc > > I don't understand why the DRIVER_METHOD(sio, puc, ...) is being ignored > in the puc-as-a-module case. Is this expected behaviour? I'm guessing > it's not. I do note also that ppc(4) is not added to the puc devclass, > presumably for the same reason. I'm also guessing things would work if > sio was a module too. > > It seems odd to me that a module cannot add an in-kernel driver to it's > devclass, but at this point I'm out of my depth as far as figuring out > how to fix it goes. Because sio(4) only includes sio_puc.c in the kernel if you have 'puc' in your kernel config, and the puc kernel module only includes the puc files, it doesn't include sio_puc.c and ppc_puc.c. uart has the same issue as well. Looking at the three attachments, there's no reason for them to be dependent on puc, they don't actually call any symbols in the puc(4) kernel module itself, so they can be compiled into kernels w/o puc without causing any harm. Then loading puc as a module would work. Here's a patch: Index: files =================================================================== RCS file: /usr/cvs/src/sys/conf/files,v retrieving revision 1.1076 diff -u -r1.1076 files --- files 12 Dec 2005 01:14:59 -0000 1.1076 +++ files 13 Dec 2005 16:00:04 -0000 @@ -815,7 +815,7 @@ dev/si/si_pci.c optional si pci dev/sio/sio_pccard.c optional sio pccard dev/sio/sio_pci.c optional sio pci -dev/sio/sio_puc.c optional sio puc pci +dev/sio/sio_puc.c optional sio pci dev/smbus/smb.c optional smb dev/smbus/smbconf.c optional smbus dev/smbus/smbus.c optional smbus @@ -928,7 +928,7 @@ dev/uart/uart_bus_isa.c optional uart isa dev/uart/uart_bus_pccard.c optional uart pccard dev/uart/uart_bus_pci.c optional uart pci -dev/uart/uart_bus_puc.c optional uart puc +dev/uart/uart_bus_puc.c optional uart dev/uart/uart_core.c optional uart dev/uart/uart_dbg.c optional uart gdb dev/uart/uart_dev_ns8250.c optional uart Index: files.alpha =================================================================== RCS file: /usr/cvs/src/sys/conf/files.alpha,v retrieving revision 1.123 diff -u -r1.123 files.alpha --- files.alpha 27 Nov 2005 21:41:58 -0000 1.123 +++ files.alpha 13 Dec 2005 16:00:09 -0000 @@ -170,7 +170,7 @@ dev/hwpmc/hwpmc_alpha.c optional hwpmc dev/kbd/kbd.c optional atkbd | sc | ukbd dev/ppc/ppc.c optional ppc -dev/ppc/ppc_puc.c optional ppc puc +dev/ppc/ppc_puc.c optional ppc dev/sio/sio.c optional sio dev/sio/sio_isa.c optional sio isa dev/syscons/schistory.c optional sc Index: files.i386 =================================================================== RCS file: /usr/cvs/src/sys/conf/files.i386,v retrieving revision 1.550 diff -u -r1.550 files.i386 --- files.i386 7 Dec 2005 21:30:46 -0000 1.550 +++ files.i386 13 Dec 2005 16:00:15 -0000 @@ -188,7 +188,7 @@ dev/nve/if_nve.c optional nve pci dev/pcf/pcf_isa.c optional pcf dev/ppc/ppc.c optional ppc -dev/ppc/ppc_puc.c optional ppc puc pci +dev/ppc/ppc_puc.c optional ppc pci dev/random/nehemiah.c optional random dev/sbni/if_sbni.c optional sbni dev/sbni/if_sbni_isa.c optional sbni isa Index: files.ia64 =================================================================== RCS file: /usr/cvs/src/sys/conf/files.ia64,v retrieving revision 1.84 diff -u -r1.84 files.ia64 --- files.ia64 27 Nov 2005 21:41:58 -0000 1.84 +++ files.ia64 13 Dec 2005 16:00:28 -0000 @@ -59,7 +59,7 @@ dev/hwpmc/hwpmc_ia64.c optional hwpmc dev/kbd/kbd.c optional atkbd | sc | ukbd dev/ppc/ppc.c optional ppc isa -dev/ppc/ppc_puc.c optional ppc puc +dev/ppc/ppc_puc.c optional ppc dev/syscons/schistory.c optional sc dev/syscons/scmouse.c optional sc dev/syscons/scterm-dumb.c optional sc Index: files.pc98 =================================================================== RCS file: /usr/cvs/src/sys/conf/files.pc98,v retrieving revision 1.334 diff -u -r1.334 files.pc98 --- files.pc98 7 Dec 2005 21:30:46 -0000 1.334 +++ files.pc98 13 Dec 2005 16:00:36 -0000 @@ -107,7 +107,7 @@ dev/mem/memutil.c optional mem dev/mse/mse.c optional mse dev/mse/mse_cbus.c optional mse isa -dev/ppc/ppc_puc.c optional ppc puc pci +dev/ppc/ppc_puc.c optional ppc pci dev/sbni/if_sbni.c optional sbni dev/sbni/if_sbni_pci.c optional sbni pci dev/snc/dp83932.c optional snc -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org