Bug 30665

Summary: acpi_ec driver does not release its resources when it fails to attach
Product: Base System Reporter: yoshint <yoshint>
Component: kernAssignee: msmith
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description yoshint 2001-09-19 06:10:00 UTC
(Problem 1)
kernel crashes in the function 
AcpiExTruncateFor32bitTable() in boot time.
# This is probably nothing to do with acpi_ec driver.

>   .
>   .
>   .
>

Fix: For problem 1,
here is patch for /usr/src/sys/contrib/dev/acpica
How-To-Repeat: On notebook PC, FUJITSU FMV-BIBLO MC4/45C,
Install FreeBSD 5.0-CURRENT after 2001/Sep, where ACPI module is loaded from the first.
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 2002-01-30 13:48:35 UTC
Responsible Changed
From-To: freebsd-bugs->takawata

Over to maintainer.
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 2002-01-30 13:49:18 UTC
Responsible Changed
From-To: takawata->msmith

Oops, I missed the fact that the originator was asked to file this 
PR by Mike.
Comment 3 takawata 2002-01-30 14:11:49 UTC
How about this patch?

--- acpica.old/acpi_ec.c	Wed Jan 16 23:40:01 2002
+++ acpica/acpi_ec.c	Wed Jan 30 23:12:55 2002
@@ -355,7 +355,7 @@
 {
     struct acpi_ec_softc	*sc;
     ACPI_STATUS			Status;
-
+    int errval = 0;
     FUNCTION_TRACE(__func__);
 
     /*
@@ -373,7 +373,8 @@
     if ((sc->ec_data_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT, &sc->ec_data_rid,
 					      0, ~0, 1, RF_ACTIVE)) == NULL) {
 	device_printf(dev, "can't allocate data port\n");
-	return_VALUE(ENXIO);
+	errval = ENXIO;
+	goto out;
     }
     sc->ec_data_tag = rman_get_bustag(sc->ec_data_res);
     sc->ec_data_handle = rman_get_bushandle(sc->ec_data_res);
@@ -382,7 +383,8 @@
     if ((sc->ec_csr_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT, &sc->ec_csr_rid,
 					     0, ~0, 1, RF_ACTIVE)) == NULL) {
 	device_printf(dev, "can't allocate command/status port\n");
-	return_VALUE(ENXIO);
+	errval = ENXIO;
+	goto out;
     }
     sc->ec_csr_tag = rman_get_bustag(sc->ec_csr_res);
     sc->ec_csr_handle = rman_get_bushandle(sc->ec_csr_res);
@@ -396,7 +398,8 @@
     ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "attaching GPE\n"));
     if ((Status = acpi_EvaluateInteger(sc->ec_handle, "_GPE", &sc->ec_gpebit)) != AE_OK) {
 	device_printf(dev, "can't evaluate _GPE - %s\n", AcpiFormatException(Status));
-	return_VALUE(ENXIO);
+	errval =ENXIO;
+	goto out;
     }
 
     /*
@@ -411,7 +414,8 @@
 					EcGpeHandler, sc)) != AE_OK) {
 	device_printf(dev, "can't install GPE handler for %s - %s\n",
 		      acpi_name(sc->ec_handle), AcpiFormatException(Status));
-	return_VALUE(ENXIO);
+	errval = ENXIO;
+	goto out;
     }
 
     /* 
@@ -423,11 +427,19 @@
 	device_printf(dev, "can't install address space handler for %s - %s\n",
 		      acpi_name(sc->ec_handle), AcpiFormatException(Status));
 	panic("very suck");
-	return_VALUE(ENXIO);
+	errval = ENXIO;
+	goto out;
     }
     ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "attach complete\n"));
-
     return_VALUE(0);
+ out:
+    if(sc->ec_csr_res)
+	bus_release_resource(sc->ec_dev, SYS_RES_IOPORT, sc->ec_csr_rid, 
+			     sc->ec_csr_res);
+    if(sc->ec_data_res)
+        bus_release_resource(sc->ec_dev, SYS_RES_IOPORT, sc->ec_data_rid,
+			     sc->ec_data_res);
+    return_VALUE(errval);
 }
 
 static void
Comment 4 yoshint 2002-01-31 00:49:08 UTC
>> On Wed, 30 Jan 2002 23:11:49 +0900, Takanori Watanabe
>> <takawata@shidahara1.planet.sci.kobe-u.ac.jp> said:

Ta> How about this patch?

Thanks, it worked!
To be exact, not working but it can prevent kernel panic ;-)

This is boot -v log. Only acpi.ko was rebuild, date in kernel message
was "Tue Sep 18 20:06:43 JST 2001" as before.
I will try to update FreeBSD for recent 5-CURRENT.




Copyright (c) 1992-2001 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 5.0-CURRENT-20010911-JPSNAP #0: Tue Sep 18 20:06:43 JST 2001
    root@yue:/usr/src/sys/i386/compile/Yue
Calibrating clock(s) ... TSC clock: 448056018 Hz, i8254 clock: 1193191 Hz
CLK_USE_I8254_CALIBRATION not specified - using default frequency
Timecounter "i8254"  frequency 1193182 Hz
CLK_USE_TSC_CALIBRATION not specified - using old calibration method
Timecounter "TSC"  frequency 448055600 Hz
CPU: Pentium III/Pentium III Xeon/Celeron (448.06-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x681  Stepping = 1
  Features=0x383f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE>
real memory  = 201326592 (196608K bytes)
Physical memory chunk(s):
0x00001000 - 0x0009efff, 647168 bytes (158 pages)
0x004e6000 - 0x0bfdffff, 196059136 bytes (47866 pages)
0x0bff1000 - 0x0bff7fff, 28672 bytes (7 pages)
avail memory = 190898176 (186424K bytes)
bios32: Found BIOS32 Service Directory header at 0xc00f6680
bios32: Entry = 0xfd8a0 (c00fd8a0)  Rev = 0  Len = 1
pcibios: PCI BIOS entry at 0xfd8a0+0x11e
pnpbios: Found PnP BIOS data at 0xc00f66d0
pnpbios: Entry = f0000:90e7  Rev = 1.0
Other BIOS signatures found:
Preloaded elf kernel "kernel" at 0xc04c0000.
Preloaded elf module "acpi.ko" at 0xc04c00a8.
null: <null device, zero device>
mem: <memory & I/O>
Pentium Pro MTRR support enabled
random: <entropy source>
pci_open(1):	mode 1 addr port (0x0cf8) is 0x80000058
pci_open(1a):	mode1res=0x80000000 (0x80000000)
pci_cfgcheck:	device 0 [class=060000] [hdr=80] is there (id=71948086)
Using $PIR table, 6 entries at 0xc00fdf60
npx0: <math processor> on motherboard
npx0: INT 16 interface
acpi0: <FUJ    CHIFFONE> on motherboard
acpi0: power button is handled as a fixed feature programming model.
Timecounter "ACPI"  frequency 3579545 Hz
acpi_timer0: <24-bit timer at 3.579545MHz> port 0xff08-0xff0b on acpi0
acpi_cpu0: <CPU> on acpi0
acpi_tz0: <thermal zone> on acpi0
acpi_pcib0: <Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: physical bus=0
found->	vendor=0x8086, dev=0x7194, revid=0x01
	bus=0, slot=0, func=0
	class=06-00-00, hdrtype=0x00, mfdev=1
	map[10]: type 4, range 32, base 00001000, size  8, enabled
	map[14]: type 4, range 32, base 00001400, size  6, enabled
found->	vendor=0x8086, dev=0x7195, revid=0x00
	bus=0, slot=0, func=1
	class=04-01-00, hdrtype=0x00, mfdev=0
	intpin=b, irq=9
found->	vendor=0x0000, dev=0x0000, revid=0x00
	bus=0, slot=0, func=2
	class=00-00-00, hdrtype=0x00, mfdev=0
found->	vendor=0x8086, dev=0x7198, revid=0x01
	bus=0, slot=7, func=0
	class=06-80-00, hdrtype=0x00, mfdev=1
	map[20]: type 4, range 32, base 00001460, size  4, enabled
found->	vendor=0x8086, dev=0x7199, revid=0x00
	bus=0, slot=7, func=1
	class=01-01-80, hdrtype=0x00, mfdev=0
	map[20]: type 4, range 32, base 00001440, size  5, enabled
found->	vendor=0x8086, dev=0x719a, revid=0x00
	bus=0, slot=7, func=2
	class=0c-03-00, hdrtype=0x00, mfdev=0
	intpin=d, irq=15
found->	vendor=0x8086, dev=0x719b, revid=0x00
	bus=0, slot=7, func=3
	class=06-80-00, hdrtype=0x00, mfdev=0
	map[10]: type 1, range 32, base fe000000, size 16, enabled
	map[14]: type 4, range 32, base 00001470, size  3, enabled
found->	vendor=0x127a, dev=0x2015, revid=0x01
	bus=0, slot=16, func=0
	class=07-80-00, hdrtype=0x00, mfdev=0
	intpin=a, irq=9
	powerspec 2  supports D0 D3  current D0
found->	vendor=0x104c, dev=0xac50, revid=0x01
	bus=0, slot=19, func=0
	class=06-07-00, hdrtype=0x02, mfdev=0
	intpin=a, irq=9
	powerspec 1  supports D0 D1 D2 D3  current D0
	map[10]: type 1, range 32, base fe800000, size 22, enabled
	map[14]: type 1, range 32, base fe020000, size 17, enabled
	map[18]: type 1, range 32, base fe400000, size 22, enabled
found->	vendor=0x1023, dev=0x9525, revid=0x49
	bus=0, slot=20, func=0
	class=03-00-00, hdrtype=0x00, mfdev=0
	intpin=a, irq=9
	powerspec 1  supports D0 D1 D2 D3  current D0
pci0: <PCI bus> on acpi_pcib0
pcm0: <Intel 443MX> port 0x1400-0x143f,0x1000-0x10ff irq 9 at device 0.1 on pci0
pcm0: ac97 codec id 0x83847609 (SigmaTel STAC9721/9723)
pcm0: ac97 codec features 18 bit DAC, 18 bit ADC, 5 bit master volume, SigmaTel 3D Enhancement
pcm0: ac97 primary codec extended features AMAP
pcm: setmap 52c000, 4000; 0xca1c0000 -> 52c000
pcm: setmap 54a000, 4000; 0xca1c4000 -> 54a000
pcm: setmap 54e000, 4000; 0xca1c8000 -> 54e000
pci0: <old, non-VGA display device> at device 0.2 (no driver attached)
PCI-ISA bridge with incorrect subclass 0x80
PCI-ISA bridge with incorrect subclass 0x80
isab0: <PCI-ISA bridge> at device 7.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel PIIX4 ATA33 controller> port 0x1460-0x146f at device 7.1 on pci0
ata0: iobase=0x01f0 altiobase=0x03f6 bmaddr=0x1460
ata0: mask=03 ostat0=50 ostat2=00
ata0-master: ATAPI probe 00 00
ata0-slave: ATAPI probe 00 00
ata0: mask=03 stat0=50 stat1=00
ata0-master: ATA probe 01 a5
ata0: devices=01
ata0: at 0x1f0 irq 14 on atapci0
ata1: iobase=0x0170 altiobase=0x0376 bmaddr=0x1468
ata1: at 0x170 irq 15 on atapci0
uhci0: <Intel 82443MX USB controller> port 0x1440-0x145f irq 15 at device 7.2 on pci0
usb0: <Intel 82443MX USB controller> 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
ums0: Logitech N48 mouse, rev 1.00/11.01, addr 2, iclass 3/1
ums0: 3 buttons and Z dir.
acpi_timer0: functional ACPI timer detected, enabling fast timecount interface
pci0: <bridge, PCI-unknown> at device 7.3 (no driver attached)
pci0: <simple comms> at device 16.0 (no driver attached)
pccbb0: <TI1410 PCI-CardBus Bridge> irq 9 at device 19.0 on pci0
pccbb0: PCI Memory allocated: 10000000
cardbus0: <Cardbus bus (newcard)> on pccbb0
pccard0: <16-bit PCCard bus> on pccbb0
pci0: <display, VGA> at device 20.0 (no driver attached)
acpi_button0: <Power Button> on acpi0
acpi_acad0: <AC adapter> on acpi0
acpi_cmbat0: <Control method Battery> on acpi0
acpi_lid0: <Control Method Lid Switch> on acpi0
acpi_ec0: <embedded controller> port 0x66,0x62 on acpi0
acpi_ec0: can't install GPE handler for \\_SB_.PCI0.EIO_.EC__ - AE_EXIST
device_probe_and_attach: acpi_ec0 attach returned 6
sio0: irq maps: 0x1 0x1 0x1 0x1
sio0: probe failed test(s): 0 2 4 6 9
sio0: irq maps: 0x1 0x1 0x1 0x1
sio0: probe failed test(s): 0 2 4 6 9
acpi_ec0: <embedded controller> port 0x66,0x62 on acpi0
acpi_ec0: can't install GPE handler for \\_SB_.PCI0.EIO_.EC__ - AE_EXIST
device_probe_and_attach: acpi_ec0 attach returned 6
sio0: irq maps: 0x1 0x1 0x1 0x1
sio0: probe failed test(s): 0 2 4 6 9
sio0: irq maps: 0x1 0x1 0x1 0x1
sio0: probe failed test(s): 0 2 4 6 9
ata-: ata0 already exists, using ata2 instead
ata-: ata1 already exists, using ata3 instead
Trying Read_Port at 203
Trying Read_Port at 243
Trying Read_Port at 283
Trying Read_Port at 2c3
Trying Read_Port at 303
Trying Read_Port at 343
Trying Read_Port at 383
Trying Read_Port at 3c3
sc-: sc0 already exists, using sc1 instead
vga-: vga0 already exists, using vga1 instead
isa_probe_children: disabling PnP devices
isa_probe_children: probing non-PnP devices
orm0: <Option ROM> at iomem 0xc0000-0xcbfff on isa0
adv0 failed to probe on isa0
aha0 failed to probe on isa0
aic0 failed to probe on isa0
ata2 failed to probe at port 0x1f0 irq 14 on isa0
ata3 failed to probe at port 0x170 irq 15 on isa0
atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
atkbd: the current kbd controller command byte 0047
atkbd: keyboard ID 0x54ab (2)
kbd0 at atkbd0
kbd0: atkbd0, AT 101/102 (2), config:0x1, flags:0x3d0000
atkbd1: unable to allocate IRQ
psm0: current command byte:0047
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: model Generic PS/2 mouse, device ID 0-00, 2 buttons
psm0: config:00000000, flags:00000000, packet size:3
psm0: syncmask:c0, syncbits:00
bt0 failed to probe on isa0
cs0 failed to probe at port 0x300 on isa0
ed0 failed to probe at port 0x280 iomem 0xd8000 irq 10 on isa0
fdc0 failed to probe at port 0x3f0 irq 6 drq 2 on isa0
fe0 failed to probe at port 0x300 on isa0
ie0 failed to probe at port 0x300 iomem 0xd0000 irq 10 on isa0
le0 failed to probe at port 0x300 iomem 0xd0000 irq 5 on isa0
lnc0 failed to probe at port 0x280 irq 10 drq 0 on isa0
pcic0 failed to probe at port 0x3e0 iomem 0xd0000 on isa0
pcic1: not probed (disabled)
pmtimer0 on isa0
ppc0 failed to probe at irq 7 on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
sc0: fb0, kbd0, terminal emulator: sc (syscons terminal)
sio0: configured irq 4 not in bitmap of probed irqs 0
sio0: irq maps: 0x1 0x1 0x1 0x1
sio0: probe failed test(s): 0 1 2 4 6 7 9
sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
sio0: type 8250
sio1: configured irq 3 not in bitmap of probed irqs 0
sio1: irq maps: 0x1 0x1 0x1 0x1
sio1: probe failed test(s): 0 1 2 4 6 7 9
sio1 failed to probe at port 0x2f8-0x2ff irq 3 on isa0
sio2: not probed (disabled)
sio3: not probed (disabled)
sn0 failed to probe at port 0x300 irq 10 on isa0
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
fb0: vga0, vga, type:VGA (5), flags:0x7007f
fb0: port:0x3c0-0x3df, crtc:0x3d4, mem:0xa0000 0x20000
fb0: init mode:24, bios mode:3, current mode:24
fb0: window:0xc00b8000 size:32k gran:32k, buf:0 size:32k
vga0: vga: WARNING: video mode switching is not fully supported on this adapter
VGA parameters upon power-up
50 18 10 00 00 00 03 00 02 67 5f 4f 50 82 55 81 
bf 1f 00 4f 0d 0e 00 00 05 f0 9c 8e 8f 28 1f 96 
b9 a3 ff 00 01 02 03 04 05 14 07 38 39 3a 3b 3c 
3d 3e 3f 04 00 0f 08 00 00 00 00 00 10 0e 00 ff 
VGA parameters in BIOS for mode 24
50 18 10 00 10 00 03 00 02 67 5f 4f 50 82 55 81 
bf 1f 00 4f 0d 0e 00 00 00 00 9c 8e 8f 28 1f 96 
b9 a3 ff 00 01 02 03 04 05 14 07 38 39 3a 3b 3c 
3d 3e 3f 0c 00 0f 08 00 00 00 00 00 10 0e 00 ff 
EGA/VGA parameters to be used for mode 24
50 18 10 00 00 00 03 00 02 67 5f 4f 50 82 55 81 
bf 1f 00 4f 0d 0e 00 00 05 f0 9c 8e 8f 28 1f 96 
b9 a3 ff 00 01 02 03 04 05 14 07 38 39 3a 3b 3c 
3d 3e 3f 04 00 0f 08 00 00 00 00 00 10 0e 00 ff 
vt0 failed to probe on isa0
sc1: no video adapter found.
sc1: <System console> failed to probe on isa0
vga1: <Generic ISA VGA> failed to probe on isa0
isa_probe_children: probing PnP devices
BIOS Geometries:
 0:03fefe3f 0..1022=1023 cylinders, 0..254=255 heads, 1..63=63 sectors
 0 accounted for
Device configuration finished.
bpf: faith0 attached
bpf: lo0 attached
bpf: ppp0 attached
acpi_cpu0: set speed to 100.0%
acpi_cpu: CPU throttling enabled, 8 steps from 100% to 12.5%
acpi_acad0: On Line
ad0: success setting UDMA2 on Intel chip
Creating DISK ad0
ad0: <FUJITSU MHK2090AT/DE38> ATA-5 disk at ata0-master
ad0: 8623MB (17660160 sectors), 17520 C, 16 H, 63 S, 512 B
ad0: 16 secs/int, 1 depth queue, UDMA33
ad0: piomode=4 dmamode=2 udmamode=4 cblid=1
Mounting root from ufs:/dev/ad0s2a
ad0s1: type 0xb, start 401625, end = 15615179, size 15213555 : OK
ad0s2: type 0xa5, start 15615180, end = 17655434, size 2040255 : OK
ad0s4: type 0xa5, start 63, end = 401624, size 401562 : OK
pccbb0: card inserted: event=0x00000000, state=30000920
pccbb0: pccbb_power: CARD_VCC_0V and CARD_VPP_0V [44]
pccbb0: pccbb_power: CARD_VCC_3V and CARD_VPP_VCC [11]
found->	vendor=0x8086, dev=0x1229, revid=0x09
	class=02-00-00, hdrtype=0x00, mfdev=0
	cmdreg=0x0000, statreg=0x0290, cachelnsz=8 (dwords)
	lattimer=0xa8 (5040 ns), mingnt=0x08 (2000 ns), maxlat=0x38 (14000 ns)
	intpin=a, irq=0
cardbus0: Expecting link target, got 0x0
cardbus0: Resource not specified in CIS: id=10, size=1000
cardbus0: Resource not specified in CIS: id=14, size=40
cardbus0: Resource not specified in CIS: id=18, size=20000
cardbus0: Non-prefetchable memory at 44000000-44020fff
cardbus0: Non-prefetchable memory rid=18 at 44000000-4401ffff (20000)
cardbus0: Non-prefetchable memory rid=10 at 44020000-44020fff (1000)
cardbus0: IO port at 1100-113f
cardbus0: IO port rid=14 at 1100-113f
fxp0: <Intel Pro 10/100B/100+ Ethernet> port 0x1100-0x113f mem 0x44000000-0x4401ffff,0x44020000-0x44020fff irq 9 at device 0.0 on cardbus0
fxp0: using memory space register mapping
fxp0: Ethernet address 00:00:0e:d5:22:63
fxp0: PCI IDs: 8086 1229 10cf 1067 0009
fxp0: Chip Type: 0
inphy0: <i82555 10/100 media interface> on miibus0
inphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
bpf: fxp0 attached
start_init: trying /sbin/init
acpi_acad0: On Line
acpi_acad0: On Line
acpi_cmbat0: CANNOT FOUND _BIF (12300)
acpi_cmbat0: CANNOT FOUND _BIF (12300)
acpi_cmbat0: CANNOT FOUND _BIF (12300)
acpi_cmbat0: CANNOT FOUND _BIF (12300)
acpi_cmbat0: CANNOT FOUND _BIF (12300)
acpi_cmbat0: CANNOT FOUND _BIF (12300)
pid 288 (syslogd), uid 0: exited on signal 6 (core dumped)
splash: image decoder found: green_saver
Linux ELF exec handler installed
Comment 5 Takanori Watanabe freebsd_committer freebsd_triage 2002-01-31 12:28:09 UTC
State Changed
From-To: open->closed

First problem is not appeared in current version, and 
this code is managed by Intel, so local patch bloat is not  
desireable very mach. 
Second problem is fixed.