Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Mar 2007 18:18:22 +0100
From:      Jean-Yves Lefort <jylefort@FreeBSD.org>
To:        Nick Withers <nick@nickwithers.com>
Cc:        freebsd-gnome@freebsd.org, manphiz@gmail.com
Subject:   Re: Possible missing file in hal installation
Message-ID:  <20070320181822.c02595b9.jylefort@FreeBSD.org>
In-Reply-To: <20070320213838.dbef0f41.nick@nickwithers.com>
References:  <20070319205346.e5e46409.nick@nickwithers.com> <20070320063524.421ad658.jylefort@FreeBSD.org> <20070320213838.dbef0f41.nick@nickwithers.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--Signature=_Tue__20_Mar_2007_18_18_22_+0100_3dkELgrL8LFq1s.8
Content-Type: multipart/mixed;
	boundary="Multipart=_Tue__20_Mar_2007_18_18_22_+0100_G5MA_sIPNzrLXyI8"


--Multipart=_Tue__20_Mar_2007_18_18_22_+0100_G5MA_sIPNzrLXyI8
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

On Tue, 20 Mar 2007 21:38:38 +1100
Nick Withers <nick@nickwithers.com> wrote:

> On Tue, 20 Mar 2007 06:35:24 +0100
> Jean-Yves Lefort <jylefort@FreeBSD.org> wrote:
>
> > On Mon, 19 Mar 2007 20:53:46 +1100
> > Nick Withers <nick@nickwithers.com> wrote:
> >
> > > Firstly, I've just pasted the existing thread in from
> > > "http://lists.freebsd.org/pipermail/freebsd-gnome/2007-January/016501.html",
> > > sorry if I stuffed it up at all and my apologies to those with
> > > threaded mail clients...
> > >
> > > > On Wed, 2007-01-03 at 21:13 +0800, manphiz at gmail.com wrote:
> > > > > Joe Marcus Clarke wrote:
> > > > > > No, there is nothing useful here.  The ktrace looks good.
> > > > > > The last thing hald does is read the PCI config registers
> > > > > > (part of the initial PCI bus probe).  You need to get a
> > > > > > full backtrace from hald once it appears to lock up.  To do
> > > > > > that, you should run hald manually, then use gdb to bind to
> > > > > > it once it's locked up.  Then get a full backtrace.
> > > > > >
> > > > > > Joe
> > > > > >
> > > > > >
> > > > > Thanks a lot for the instruction! I attached to the
> > > > > deadlocked process, and get this backtrace:
> > > > >
> > > > > (gdb) bt
> > > > > #0  hf_pci_probe () at hf-pci.c:150
> > > > > #1  0x0805ced7 in osspec_probe () at osspec.c:96
> > > > > #2  0x080551dd in main (argc=3, argv=0xbfbfeb5c) at hald.c:578
> > > >
> > > > This backtrace doesn't make sense.  Line 150 of hf-pci.c is not
> > > > in hf_pci_probe().  The real line 150 represents a loop that
> > > > iterates through the devices list.  This list must be finite.
> > > > I don't see how this problem could occur based on this
> > > > information.
> > >
> > > I appear to be in a similar scenario on my HP Compaq Presario
> > > B3820 (believe I'm using the latest firmware versions).
> > >
>
> (snip)
>
> > > If anyone's got an idea or two up their sleeves about how I might
> > > go about fixing this, I'd be very grateful to hear about it!
> >
> > Please install sysutils/pciutils and send me the output of "lspci
> > -v".
>
> With pleasure!
> ____
>
> presario# lspci -v
> pcilib: Bus 02 seen twice (firmware bug). Ignored.
> 00:00.0 Host bridge: Intel Corporation 82855PM Processor to I/O Controller (rev 21)
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, fast devsel, latency 0
>         Memory at e0000000 (32-bit, prefetchable)
>         Capabilities: [e4] Vendor Specific Information
>         Capabilities: [a0] AGP version 2.0
>
> 00:01.0 PCI bridge: Intel Corporation 82855PM Processor to AGP Controller (rev 21) (prog-if 00 [Normal decode])
>         Flags: bus master, 66MHz, fast devsel, latency 96
>         Bus: primary=00, secondary=01, subordinate=01, sec-latency=64
>         I/O behind bridge: 00003000-00003fff
>         Memory behind bridge: d0100000-d01fffff
>         Prefetchable memory behind bridge: d8000000-dfffffff
>
> 00:1d.0 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 (rev 03) (prog-if 00 [UHCI])
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 0, IRQ 9
>         I/O ports at 1800
>
> 00:1d.1 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 (rev 03) (prog-if 00 [UHCI])
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 0, IRQ 9
>         I/O ports at 1820
>
> 00:1d.2 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 (rev 03) (prog-if 00 [UHCI])
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 0, IRQ 9
>         I/O ports at 1840
>
> 00:1d.7 USB Controller: Intel Corporation 82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller (rev 03) (prog-if 20 [EHCI])
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 0, IRQ 7
>         Memory at d0000000 (32-bit, non-prefetchable)
>         Capabilities: [50] Power Management version 2
>         Capabilities: [58] Debug port
>
> 00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 83) (prog-if 00 [Normal decode])
>         Flags: bus master, fast devsel, latency 0
>         Bus: primary=00, secondary=02, subordinate=02, sec-latency=64
>         I/O behind bridge: 00004000-00004fff
>         Memory behind bridge: d0200000-d02fffff
>
> 00:1f.0 ISA bridge: Intel Corporation 82801DBM (ICH4-M) LPC Interface Bridge (rev 03)
>         Flags: bus master, medium devsel, latency 0
>
> 00:1f.1 IDE interface: Intel Corporation 82801DBM (ICH4-M) IDE Controller (rev 03) (prog-if 8a [Master SecP PriP])
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 0, IRQ 255
>         I/O ports at <unassigned>
>         I/O ports at <unassigned>
>         I/O ports at <unassigned>
>         I/O ports at <unassigned>
>         I/O ports at 1860
>
> 00:1f.3 SMBus: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller (rev 03)
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: medium devsel, IRQ 9
>         I/O ports at 1880
>
> 00:1f.5 Multimedia audio controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 03)
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 0, IRQ 9
>         I/O ports at 1c00
>         I/O ports at 18c0
>         Memory at d0000c00 (32-bit, non-prefetchable)
>         Memory at d0000800 (32-bit, non-prefetchable)
>         Capabilities: [50] Power Management version 2
>
> 00:1f.6 Modem: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Modem Controller (rev 03) (prog-if 00 [Generic])
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 0, IRQ 9
>         I/O ports at 2400
>         I/O ports at 2000
>         Capabilities: [50] Power Management version 2
>
> 01:00.0 VGA compatible controller: ATI Technologies Inc RV350 [Mobility Radeon 9600 M10] (prog-if 00 [VGA])
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, fast Back2Back, 66MHz, medium devsel, latency 66, IRQ 9
>         Memory at d8000000 (32-bit, prefetchable)
>         I/O ports at 3000
>         Memory at d0100000 (32-bit, non-prefetchable)
>         Capabilities: [58] AGP version 2.0
>         Capabilities: [50] Power Management version 2
>
> 02:07.0 CardBus bridge: Ricoh Co Ltd RL5c476 II (rev a9)
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 32, IRQ 9
>         Memory at d0202000 (32-bit, non-prefetchable)
>         Bus: primary=00, secondary=02, subordinate=02, sec-latency=32
>         16-bit legacy interface ports at 0001
>
> 02:07.1 CardBus bridge: Ricoh Co Ltd RL5c476 II (rev a9)
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 32, IRQ 9
>         Memory at d0203000 (32-bit, non-prefetchable)
>         Bus: primary=00, secondary=03, subordinate=03, sec-latency=32
>         16-bit legacy interface ports at 0001
>
> 02:07.2 FireWire (IEEE 1394): Ricoh Co Ltd R5C552 IEEE 1394 Controller (rev 01) (prog-if 10 [OHCI])
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 64, IRQ 9
>         Memory at d0201000 (32-bit, non-prefetchable)
>         Capabilities: [dc] Power Management version 2
>
> 02:08.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)
>         Subsystem: Hewlett-Packard Company Unknown device 3089
>         Flags: bus master, medium devsel, latency 64, IRQ 9
>         I/O ports at 4000
>         Memory at d0201800 (32-bit, non-prefetchable)
>         Capabilities: [50] Power Management version 2
>
> 02:09.0 Network controller: Intel Corporation PRO/Wireless 2200BG Network Connection (rev 05)
>         Subsystem: Hewlett-Packard Company Unknown device 12f6
>         Flags: bus master, medium devsel, latency 64, IRQ 9
>         Memory at d0200000 (32-bit, non-prefetchable)
>         Capabilities: [dc] Power Management version 2
> ____
>
> Also, since I forgot last time and in case it's useful, here's a
> dmesg:
> ____
>
> Copyright (c) 1992-2007 The FreeBSD Project.
> Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
>         The Regents of the University of California. All rights reserved.
> FreeBSD is a registered trademark of The FreeBSD Foundation.
> FreeBSD 6.2-RELEASE-p3 #0: Sun Mar 18 00:29:02 EST 2007
>     nick@presario.shmon.net:/usr/obj/usr/src/sys/PRESARIO
> Timecounter "i8254" frequency 1193182 Hz quality 0
> CPU: Intel(R) Pentium(R) M processor 1.70GHz (1694.51-MHz 686-class CPU)
>   Origin = "GenuineIntel"  Id = 0x6d6  Stepping = 6
>   Features=0xafe9f9bf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,PBE>
>   Features2=0x180<EST,TM2>
> real memory  = 536281088 (511 MB)
> avail memory = 514777088 (490 MB)
> kbd1 at kbdmux0
> acpi0: <PTLTD CooperSp> on motherboard
> acpi0: Power Button (fixed)
> Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
> acpi_timer0: <24-bit timer at 3.579545MHz> port 0x1008-0x100b on acpi0
> acpi_ec0: <Embedded Controller: GPE 0x1c> port 0x62,0x66 on acpi0
> cpu0: <ACPI CPU> on acpi0
> acpi_perf0: <ACPI CPU Frequency Control> on cpu0
> acpi_perf0: failed in PERF_STATUS attach
> device_attach: acpi_perf0 attach returned 6
> acpi_perf0: <ACPI CPU Frequency Control> on cpu0
> acpi_perf0: failed in PERF_STATUS attach
> device_attach: acpi_perf0 attach returned 6
> acpi_throttle0: <ACPI CPU Throttling> on cpu0
> acpi_acad0: <AC Adapter> on acpi0
> battery0: <ACPI Control Method Battery> on acpi0
> acpi_lid0: <Control Method Lid Switch> on acpi0
> acpi_button0: <Power Button> on acpi0
> acpi_button1: <Sleep Button> on acpi0
> pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
> pci_link0: BIOS IRQ 10 for 0.29.INTA is invalid
> pci_link3: BIOS IRQ 3 for 0.29.INTB is invalid
> pci_link2: BIOS IRQ 11 for 0.29.INTC is invalid
> pci_link1: BIOS IRQ 5 for 0.31.INTB is invalid
> pci0: <ACPI PCI bus> on pcib0
> agp0: <Intel 82855 host to AGP bridge> mem 0xe0000000-0xefffffff at device 0.0 on pci0
> pcib1: <ACPI PCI-PCI bridge> at device 1.0 on pci0
> pci_link0: BIOS IRQ 10 for 1.0.INTA is invalid
> pci1: <ACPI PCI bus> on pcib1
> drm0: <ATI Radeon RV350 Mobility 9600 M10 NP> port 0x3000-0x30ff mem 0xd8000000-0xdfffffff,0xd0100000-0xd010ffff irq 9 at device 0.0 on pci1
> info: [drm] AGP at 0xe0000000 256MB
> info: [drm] Initialized radeon 1.24.0 20060225
> uhci0: <Intel 82801DB (ICH4) USB controller USB-A> port 0x1800-0x181f irq 9 at device 29.0 on pci0
> uhci0: [GIANT-LOCKED]
> usb0: <Intel 82801DB (ICH4) USB controller USB-A> on uhci0
> usb0: USB revision 1.0
> uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
> uhub0: 2 ports with 2 removable, self powered
> uhci1: <Intel 82801DB (ICH4) USB controller USB-B> port 0x1820-0x183f irq 9 at device 29.1 on pci0
> uhci1: [GIANT-LOCKED]
> usb1: <Intel 82801DB (ICH4) USB controller USB-B> on uhci1
> usb1: USB revision 1.0
> uhub1: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
> uhub1: 2 ports with 2 removable, self powered
> uhci2: <Intel 82801DB (ICH4) USB controller USB-C> port 0x1840-0x185f irq 9 at device 29.2 on pci0
> uhci2: [GIANT-LOCKED]
> usb2: <Intel 82801DB (ICH4) USB controller USB-C> on uhci2
> usb2: USB revision 1.0
> uhub2: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
> uhub2: 2 ports with 2 removable, self powered
> ehci0: <Intel 82801DB/L/M (ICH4) USB 2.0 controller> mem 0xd0000000-0xd00003ff irq 7 at device 29.7 on pci0
> ehci0: [GIANT-LOCKED]
> usb3: EHCI version 1.0
> usb3: companion controllers, 2 ports each: usb0 usb1 usb2
> usb3: <Intel 82801DB/L/M (ICH4) USB 2.0 controller> on ehci0
> usb3: USB revision 2.0
> uhub3: Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
> uhub3: 6 ports with 6 removable, self powered
> pcib2: <ACPI PCI-PCI bridge> at device 30.0 on pci0
> pci_link2: BIOS IRQ 11 for 2.7.INTC is invalid
> pci_link1: BIOS IRQ 5 for 2.8.INTA is invalid
> pci_link2: BIOS IRQ 11 for 2.9.INTA is invalid
> pci2: <ACPI PCI bus> on pcib2
> cbb0: <RF5C476 PCI-CardBus Bridge> at device 7.0 on pci2
> cardbus0: <CardBus bus> on cbb0
> pccard0: <16-bit PCCard bus> on cbb0
> cbb1: <RF5C476 PCI-CardBus Bridge> at device 7.1 on pci2
> cardbus1: <CardBus bus> on cbb1
> pccard1: <16-bit PCCard bus> on cbb1
> fwohci0: <Ricoh R5C552> mem 0xd0201000-0xd02017ff irq 9 at device 7.2 on pci2
> fwohci0: OHCI version 1.0 (ROM=1)
> fwohci0: No. of Isochronous channels is 4.
> fwohci0: EUI64 10:cf:fd:00:00:13:93:66
> fwohci0: Phy 1394a available S400, 2 ports.
> fwohci0: Link S400, max_rec 2048 bytes.
> firewire0: <IEEE1394(FireWire) bus> on fwohci0
> fwohci0: Initiate bus reset
> fwohci0: node_id=0xc800ffc0, gen=1, CYCLEMASTER mode
> firewire0: 1 nodes, maxhop <= 0, cable IRM = 0 (me)
> firewire0: bus manager 0 (me)
> rl0: <RealTek 8139 10/100BaseTX> port 0x4000-0x40ff mem 0xd0201800-0xd02018ff irq 9 at device 8.0 on pci2
> miibus0: <MII bus> on rl0
> rlphy0: <RealTek internal media interface> on miibus0
> rlphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
> rl0: Ethernet address: 00:13:21:10:b0:77
> iwi0: <Intel(R) PRO/Wireless 2200BG> mem 0xd0200000-0xd0200fff irq 9 at device 9.0 on pci2
> iwi0: Ethernet address: 00:0e:35:d6:8b:3f
> isab0: <PCI-ISA bridge> at device 31.0 on pci0
> isa0: <ISA bus> on isab0
> atapci0: <Intel ICH4 UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x1860-0x186f at device 31.1 on pci0
> ata0: <ATA channel 0> on atapci0
> ata1: <ATA channel 1> on atapci0
> pci0: <serial bus, SMBus> at device 31.3 (no driver attached)
> pcm0: <Intel ICH4 (82801DB)> port 0x1c00-0x1cff,0x18c0-0x18ff mem 0xd0000c00-0xd0000dff,0xd0000800-0xd00008ff irq 9 at device 31.5 on pci0
> pcm0: <Analog Devices AD1981B AC97 Codec>
> pci0: <simple comms, generic modem> at device 31.6 (no driver attached)
> acpi_tz0: <Thermal Zone> on acpi0
> atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
> atkbd0: <AT Keyboard> irq 1 on atkbdc0
> kbd0 at atkbd0
> atkbd0: [GIANT-LOCKED]
> psm0: <PS/2 Mouse> irq 12 on atkbdc0
> psm0: [GIANT-LOCKED]
> psm0: model Generic PS/2 mouse, device ID 0
> pmtimer0 on isa0
> orm0: <ISA Option ROMs> at iomem 0xc0000-0xcffff,0xd0000-0xd0fff,0xdf000-0xdffff,0xe0000-0xe3fff on isa0
> sc0: <System console> at flags 0x100 on isa0
> sc0: VGA <16 virtual consoles, flags=0x300>
> vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
> ukbd0: Logitech Logitech USB Keyboard, rev 1.10/15.00, addr 2, iclass 3/1
> kbd2 at ukbd0
> uhid0: Logitech Logitech USB Keyboard, rev 1.10/15.00, addr 2, iclass 3/1
> ums0: Logitech USB-PS/2 Optical Mouse, rev 2.00/21.00, addr 2, iclass 3/1
> ums0: 8 buttons and Z dir.
> Timecounter "TSC" frequency 1694511574 Hz quality 800
> Timecounters tick every 1.000 msec
> ipfw2 (+ipv6) initialized, divert loadable, rule-based forwarding disabled, default to deny, logging limited to 1000 packets/entry by default
> ad0: 57231MB <HTS548060M9AT00 MGBOA53A> at ata0-master UDMA100
> cpu0: Cx states changed
> acd0: FAILURE - MODE_SENSE_BIG timed out
> acd0: DVDR <HL-DT-ST DVD-RW GWA-4080N/0G03> at ata1-master UDMA33
> cd0 at ata1 bus 0 target 0 lun 0
> cd0: <HL-DT-ST DVD-RW GWA-4080N 0G03> Removable CD-ROM SCSI-0 device
> cd0: 33.000MB/s transfers
> cd0: cd present [3474532 x 2048 byte records]
> Trying to mount root from ufs:/dev/ad0s1a

The attached patch should fix the problem. Please test it.

--
Jean-Yves Lefort

jylefort@FreeBSD.org
http://lefort.be.eu.org/

--Multipart=_Tue__20_Mar_2007_18_18_22_+0100_G5MA_sIPNzrLXyI8
Content-Type: text/plain;
 name="hal-pci.diff"
Content-Disposition: attachment;
 filename="hal-pci.diff"
Content-Transfer-Encoding: quoted-printable

Index: hald/freebsd/hf-pci.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /space/cvs/marcuscom-cvs/hal/hald/freebsd/hf-pci.c,v
retrieving revision 1.23
diff -u -r1.23 hf-pci.c
--- hald/freebsd/hf-pci.c	5 Nov 2006 21:21:45 -0000	1.23
+++ hald/freebsd/hf-pci.c	20 Mar 2007 17:15:56 -0000
@@ -3,7 +3,7 @@
  *
  * hf-pci.c : enumerate PCI devices
  *
- * Copyright (C) 2006 Jean-Yves Lefort <jylefort@FreeBSD.org>
+ * Copyright (C) 2006, 2007 Jean-Yves Lefort <jylefort@FreeBSD.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
=20
 #include <stdio.h>
 #include <string.h>
+#include <bitstring.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -48,11 +49,16 @@
=20
 /* from sys/dev/pci/pcireg.h */
 #define PCIR_SECBUS_1			0x19
+#define PCIR_HDRTYPE			0x0e
+#define PCIM_HDRTYPE_BRIDGE		0x01
+#define PCIM_HDRTYPE_CARDBUS		0x02
=20
 typedef struct
 {
+  HalDevice		*device;
   struct pci_conf	p;
   int			secondary_bus;
+  int			header_type;
 } DeviceInfo;
=20
 static int hf_pci_fd;
@@ -140,73 +146,41 @@
     HAL_INFO(("unable to open %s: %s", HF_PCI_DEVICE, g_strerror(errno)));
 }
=20
-static GSList *
-hf_pci_lookup (GSList *devices, int bus)
-{
-  if (bus !=3D 0)
-    {
-      GSList *l;
-
-      HF_LIST_FOREACH(l, devices)
-	{
-	  DeviceInfo *info =3D l->data;
-
-	  if (info->secondary_bus =3D=3D bus)
-	    return l;
-	}
-    }
-
-  return NULL;
-}
-
-static GSList *
-hf_pci_get_root (GSList *devices)
-{
-  GSList *root;
-  DeviceInfo *info;
-  int bus;
-
-  g_return_val_if_fail(devices !=3D NULL, NULL);
-
-  root =3D devices;
-  info =3D root->data;
-
-  bus =3D info->p.pc_sel.pc_bus;
-  while (bus !=3D -1)
-    {
-      GSList *new_root;
-
-      new_root =3D hf_pci_lookup(devices, bus);
-      bus =3D -1;
-
-      if (new_root)
-	{
-	  root =3D new_root;
-	  info =3D root->data;
-	  bus =3D info->p.pc_sel.pc_bus;
-	}
-    }
-
-  return root;
-}
-
 static void
-hf_pci_probe (void)
+hf_pci_probe_bus (HalDevice *parent, int bus, bitstr_t *busmap)
 {
+  struct pci_match_conf match_conf;
   struct pci_conf_io pc;
   struct pci_conf conf[255];
   struct pci_conf *p;
   GSList *devices =3D NULL;
+  GSList *l;
=20
-  if (hf_pci_fd < 0)
-    return;
+  g_return_if_fail(busmap !=3D NULL);
+  g_return_if_fail(bus >=3D 0 && bus <=3D 0xff);
+
+  /* test taken from sysutils/pciutils */
+  if (bit_test(busmap, bus))
+    {
+      HAL_WARNING(("PCI bus %.2x appearing twice (firmware bug), ignored",=
 bus));
+      return;
+    }
+
+  bit_set(busmap, bus);
=20
  start:
+  memset(&match_conf, 0, sizeof(match_conf));
+  match_conf.pc_sel.pc_bus =3D bus;
+  match_conf.flags =3D PCI_GETCONF_MATCH_BUS;
+
   memset(&pc, 0, sizeof(pc));
+  pc.pat_buf_len =3D sizeof(match_conf);
+  pc.num_patterns =3D 1;
+  pc.patterns =3D &match_conf;
   pc.match_buf_len =3D sizeof(conf);
   pc.matches =3D conf;
=20
-  /* build a list of PCI devices */
+  /* get the devices located on the specified bus */
=20
   do
     {
@@ -230,50 +204,64 @@
 	}
=20
       for (p =3D conf; p < &conf[pc.num_matches]; p++)
-	if (! hf_device_store_match(hald_get_gdl(),
-				    hal_property_new_int("pci.freebsd.bus", p->pc_sel.pc_bus),
-				    hal_property_new_int("pci.freebsd.device", p->pc_sel.pc_dev),
-				    hal_property_new_int("pci.freebsd.function", p->pc_sel.pc_func),
-				    NULL))
-	  {
-	    DeviceInfo *info;
-
-	    info =3D g_new(DeviceInfo, 1);
-	    info->p =3D *p;
-	    info->secondary_bus =3D hf_pci_get_register(p, PCIR_SECBUS_1);
+	{
+	  DeviceInfo *info;
+
+	  info =3D g_new(DeviceInfo, 1);
+	  info->device =3D hf_device_store_match(hald_get_gdl(),
+					       hal_property_new_int("pci.freebsd.bus", p->pc_sel.pc_bus),
+					       hal_property_new_int("pci.freebsd.device", p->pc_sel.pc_dev),
+					       hal_property_new_int("pci.freebsd.function", p->pc_sel.pc_func=
),
+					       NULL);
+	  info->p =3D *p;
+	  info->secondary_bus =3D hf_pci_get_register(p, PCIR_SECBUS_1);
+	  info->header_type =3D hf_pci_get_register(p, PCIR_HDRTYPE);
=20
-	    devices =3D g_slist_prepend(devices, info);
-	  }
+	  devices =3D g_slist_prepend(devices, info);
+	}
     }
   while (pc.status =3D=3D PCI_GETCONF_MORE_DEVS);
=20
-  /* add the devices (parents first) */
+  /* add the devices and probe the children of bridges */
=20
-  while (devices)
+  HF_LIST_FOREACH(l, devices)
     {
-      GSList *root;
-      DeviceInfo *info;
-      HalDevice *parent =3D NULL;
+      DeviceInfo *info =3D l->data;
=20
-      root =3D hf_pci_get_root(devices);
-      g_assert(root !=3D NULL);
+      /*
+       * If the device already exists, we are reprobing (from
+       * osspec_device_reprobe()). In this case we must not add it
+       * again, but only probe its children if it is a bridge.
+       */
+      if (! info->device)
+	{
+	  info->device =3D hf_pci_device_new(parent, &info->p, info->secondary_bu=
s);
+	  if (hf_device_preprobe(info->device))
+	    hf_device_add(info->device);
+	  else
+	    continue;		/* device ignored */
+	}
=20
-      info =3D root->data;
+      if (info->header_type =3D=3D PCIM_HDRTYPE_BRIDGE || info->header_typ=
e =3D=3D PCIM_HDRTYPE_CARDBUS)
+	/* a bridge or cardbus, probe its children */
+	hf_pci_probe_bus(info->device, info->secondary_bus, busmap);
+    }
=20
-      if (info->p.pc_sel.pc_bus !=3D 0)
-	parent =3D hal_device_store_match_key_value_int(hald_get_gdl(), "pci.free=
bsd.secondary_bus", info->p.pc_sel.pc_bus);
+  /* cleanup */
=20
-      if (! parent || ! hal_device_property_get_bool(parent, "info.ignore"=
))
-	{
-	  HalDevice *device;
+  g_slist_foreach(devices, (GFunc) g_free, NULL);
+  g_slist_free(devices);
+}
=20
-	  device =3D hf_pci_device_new(parent, &info->p, info->secondary_bus);
-	  hf_device_preprobe_and_add(device);
-	}
+static void
+hf_pci_probe (void)
+{
+  bitstr_t bit_decl(busmap, 256) =3D { 0 };
=20
-      devices =3D g_slist_delete_link(devices, root);
-      g_free(info);
-    }
+  if (hf_pci_fd < 0)
+    return;
+
+  hf_pci_probe_bus(NULL, 0, busmap);
 }
=20
 HFHandler hf_pci_handler =3D {

--Multipart=_Tue__20_Mar_2007_18_18_22_+0100_G5MA_sIPNzrLXyI8--

--Signature=_Tue__20_Mar_2007_18_18_22_+0100_3dkELgrL8LFq1s.8
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (FreeBSD)

iD8DBQFGABdeyzD7UaO4AGoRAtfUAJ4xAKUgmcctRUBMjaYIyUgGNkgCUgCdHKGz
AjvNLtNmi8V9jrIDBVqm5jo=
=NHV0
-----END PGP SIGNATURE-----

--Signature=_Tue__20_Mar_2007_18_18_22_+0100_3dkELgrL8LFq1s.8--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070320181822.c02595b9.jylefort>