remove ACPI motherboard driver, use PNP system driver instead
Subsystems (2)
cover remove ACPI motherboard driver, use PNP system driver instead
The ACPI motherboard driver is mostly redundant with the PNP system driver. This series moves the little bit of ACPI-specific stuff out of the motherboard driver into acpi/osl.c, adds a little bit to the PNP system driver so it covers all the remaining functionality of the ACPI driver, and removes the ACPI driver.
Feedback welcome.
Bjorn
PATCH 1/5 ACPI: move FADT resource reservations from motherboard driver to osl
Resources described by the FADT aren't really a good fit for the ACPI motherboard driver.
The motherboard driver cares about PNP0C01 and PNP0C02 devices and their resources.
The FADT describes some resources used by the ACPI core. Often, they are also described by by the _CRS of a motherboard device, but I think it's better to reserve them specifically in the ACPI osl.c because
(a) the motherboard driver is optional and ACPI uses the resources even if the driver is absent, and (b) I want to remove the ACPI motherboard driver because it's mostly redundant with the PNP system.c driver.
drivers/acpi/motherboard.c +0 -49
@@ -118,58 +118,9 @@ }, }; -static void __init acpi_request_region (struct acpi_generic_address *addr, -unsigned int length,char *desc) -{ -if (!addr->address || !length) -return ; - -if (addr->address_space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) -request_region (addr->address, length, desc); -else if (addr->address_space_id ==ACPI_ADR_SPACE_SYSTEM_MEMORY ) -request_mem_region (addr->address, length, desc); -} - -static void __init acpi_reserve_resources (void ) -{ -acpi_request_region (&acpi_gbl_FADT->xpm1a_evt_blk, - acpi_gbl_FADT->pm1_evt_len,"ACPI PM1a_EVT_BLK" ); - -acpi_request_region (&acpi_gbl_FADT->xpm1b_evt_blk, - acpi_gbl_FADT->pm1_evt_len,"ACPI PM1b_EVT_BLK" ); - -acpi_request_region (&acpi_gbl_FADT->xpm1a_cnt_blk, - acpi_gbl_FADT->pm1_cnt_len,"ACPI PM1a_CNT_BLK" ); - -acpi_request_region (&acpi_gbl_FADT->xpm1b_cnt_blk, - acpi_gbl_FADT->pm1_cnt_len,"ACPI PM1b_CNT_BLK" ); - -if (acpi_gbl_FADT->pm_tm_len ==4 ) -acpi_request_region (&acpi_gbl_FADT->xpm_tmr_blk,4 ,"ACPI PM_TMR" ); - -acpi_request_region (&acpi_gbl_FADT->xpm2_cnt_blk, - acpi_gbl_FADT->pm2_cnt_len,"ACPI PM2_CNT_BLK" ); - -/* Length of GPE blocks must be a non-negative multiple of 2 */ - -if (!(acpi_gbl_FADT->gpe0_blk_len &0x1 )) -acpi_request_region (&acpi_gbl_FADT->xgpe0_blk, - acpi_gbl_FADT->gpe0_blk_len,"ACPI GPE0_BLK" ); - -if (!(acpi_gbl_FADT->gpe1_blk_len &0x1 )) -acpi_request_region (&acpi_gbl_FADT->xgpe1_blk, - acpi_gbl_FADT->gpe1_blk_len,"ACPI GPE1_BLK" ); -} -static int __init acpi_motherboard_init (void ) {acpi_bus_register_driver (&acpi_motherboard_driver); -/* -* Guarantee motherboard IO reservation first -* This module must run after scan.c -*/ -if (!acpi_disabled) -acpi_reserve_resources ();return 0 ; }
drivers/acpi/osl.c +47 -0
59 lines not on this page · raw message
PATCH 2/5 PNP: reserve system board iomem resources as well as ioport resources
In reply to Bjorn HelgaasMost x86 boxes have no iomem system board resources, but some ia64 boxes do.
drivers/pnp/system.c +19 -7
@@ -3,7 +3,8 @@* * Some code is based on pnpbios_core.c * Copyright 2002 Adam Belay <[email protected]> -* +* (c) Copyright 2007 Hewlett-Packard Development Company, L.P. +* Bjorn Helgaas <[email protected]> */ #include <linux/pnp.h>
@@ -21,7 +22,7 @@ { "", 0 } }; -static void reserve_ioport_range (char *pnpid,int start,int end) +static void reserve_range (char *pnpid,int start,int end,int port) {struct resource *res;char *regionid;
@@ -30,7 +31,10 @@if ( regionid ==NULL )return ;snprintf (regionid,16 ,"pnp %s" , pnpid); - res =request_region (start,end-start+1 ,regionid); +if (port) + res =request_region (start,end-start+1 ,regionid); +else + res =request_mem_region (start,end-start+1 ,regionid);if ( res ==NULL )kfree ( regionid );else
@@ -41,8 +45,8 @@* have double reservations. */ printk (KERN_INFO -"pnp: %s: ioport range 0x%x-0x%x %s reserved\n" , - pnpid, start, end, +"pnp: %s: %s range 0x%x-0x%x %s reserved\n" , + pnpid, port ?"ioport" :"iomem" , start, end,NULL != res ?"has been" :"could not be" );
@@ -75,13 +79,21 @@/* invalid endpoint */ /* Do nothing */ continue ; -reserve_ioport_range ( +reserve_range ( dev->dev.bus_id,pnp_port_start (dev, i), -pnp_port_end (dev, i) +pnp_port_end (dev, i),1 ); } +for (i =0 ; i <PNP_MAX_MEM ; i++) { +if (!pnp_mem_valid (dev, i)) +continue ; + +reserve_range (dev->dev.bus_id,pnp_mem_start (dev, i), +pnp_mem_end (dev, i),0 ); + } +return ; }
PATCH 3/5 PNP: system.c whitespace cleanup
In reply to Bjorn HelgaasNo functional change.
drivers/pnp/system.c +11 -21
@@ -28,15 +28,15 @@char *regionid; regionid =kmalloc (16 ,GFP_KERNEL ); -if ( regionid ==NULL ) +if (regionid ==NULL )return ;snprintf (regionid,16 ,"pnp %s" , pnpid);if (port) res =request_region (start,end-start+1 ,regionid);else res =request_mem_region (start,end-start+1 ,regionid); -if ( res ==NULL ) -kfree ( regionid ); +if (res ==NULL ) +kfree (regionid);else res->flags &= ~IORESOURCE_BUSY ;/*
@@ -47,24 +47,18 @@printk (KERN_INFO "pnp: %s: %s range 0x%x-0x%x %s reserved\n" , pnpid, port ?"ioport" :"iomem" , start, end, -NULL != res ?"has been" :"could not be" - ); - -return ; +NULL != res ?"has been" :"could not be" ); } -static void reserve_resources_of_dev (struct pnp_dev *dev ) +static void reserve_resources_of_dev (struct pnp_dev *dev) {int i; -for (i=0 ;i<PNP_MAX_PORT ;i++) { +for (i =0 ; i <PNP_MAX_PORT ; i++) {if (!pnp_port_valid (dev, i)) -/* end of resources */ continue ;if (pnp_port_start (dev, i) ==0 ) -/* disabled */ -/* Do nothing */ -continue ; +continue ;/* disabled */ if (pnp_port_start (dev, i) <0x100 )/* * Below 0x100 is only standard PC hardware
@@ -76,14 +70,10 @@*/ continue ;if (pnp_port_end (dev, i) <pnp_port_start (dev, i)) -/* invalid endpoint */ -/* Do nothing */ -continue ; -reserve_range ( - dev->dev.bus_id, -pnp_port_start (dev, i), -pnp_port_end (dev, i),1 - ); +continue ;/* invalid */ + +reserve_range (dev->dev.bus_id,pnp_port_start (dev, i), +pnp_port_end (dev, i),1 ); }for (i =0 ; i <PNP_MAX_MEM ; i++) {
PATCH 4/5 i386: turn on CONFIG_PNP in defconfig
In reply to Bjorn HelgaasI'm trying to remove drivers/acpi/motherboard.c, which is mostly redundant with drivers/pnp/system.c. So make sure that we include the PNP driver in the default config. Most distros enable this already.
Turning on CONFIG_PNP also causes the following options to be enabled:
CONFIG_PNPACPI
CONFIG_SERIAL_8250_PNPCONFIG_SERIAL_8250_PNP causes legacy serial ports to be discovered twice, which is ugly but harmless:
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:07: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550Aarch/i386/defconfig +1 -1
@@ -466,7 +466,7 @@ # # Plug and Play support # -# CONFIG_PNP is not set +CONFIG_PNP=y # # Block devices
PATCH 5/5 ACPI: remove motherboard driver (redundant with PNP system driver)
In reply to Bjorn HelgaasThe PNP system board driver (drivers/pnp/system.c) contains all the same functionality, so we don't need the ACPI version.
Previously, a motherboard device would be claimed by *both* the ACPI and PNP drivers, resulting in stuff like this in /proc/ioports:
1200-121f : motherboard <-- from drivers/acpi/motherboard.c
1200-121f : pnp 00:0d <-- from drivers/pnp/system.cMake sure to enable CONFIG_PNP (and CONFIG_PNPACPI) to include the PNP system board driver.
drivers/acpi/Makefile +1 -1
@@ -37,7 +37,7 @@ obj-y += sleep/ obj-y += bus.o glue.o -obj-y += scan.o motherboard.o +obj-y += scan.o obj-$(CONFIG_ACPI_AC) += ac.o obj-$(CONFIG_ACPI_BATTERY) += battery.o obj-$(CONFIG_ACPI_BUTTON) += button.o
drivers/acpi/motherboard.c deleted +0 -131
131 lines not on this page · raw message
Re: [patch 1/5] ACPI: move FADT resource reservations from motherboard driver to osl
In reply to Bjorn HelgaasQuoted 6 lines · Bjorn Helgaas
Resources described by the FADT aren't really a good fit for the ACPI motherboard driver.
The motherboard driver cares about PNP0C01 and PNP0C02 devices and their resources.
Quoted 8 lines
The FADT describes some resources used by the ACPI core. Often, they are also described by by the
_CRSof a motherboard device, but I think it's better to reserve them specifically in the ACPIosl.cbecause
(a) the motherboard driver is optional and ACPI uses the resources even if the driver is absent, and (b) I want to remove the ACPI motherboard driver because it's mostly redundant with the PNPsystem.cdriver.Signed-off-by Bjorn Helgaas <[email protected]>
Thanks for the patch set, this is in the wish list for a long time.
drivers/acpi/osl.c line 130
Quoted 9 lines
drivers/acpi/osl.c +2
-0+acpi_status acpi_os_initialize (void ) {return AE_OK ;@@ -82,6 +127,8 @@acpi_status acpi_os_initialize1 (void ) { +acpi_reserve_resources ();
This sounds a little earlier. motherboard device usually returns a super set of the acpi io ports. reserving acpi io ports first might make some motherboard io port isn't reserved as there might be conflict.
Thanks,
Shaohua
Len Brown
reviewerRe: [patch 4/5] i386: turn on CONFIG_PNP in defconfig
In reply to Bjorn HelgaasQuoted 22 lines · Bjorn Helgaas
I'm trying to remove
drivers/acpi/motherboard.c, which is mostly redundant withdrivers/pnp/system.c. So make sure that we include the PNP driver in the default config. Most distros enable this already.Turning on
CONFIG_PNPalso causes the following options to be enabled:CONFIG_PNPACPI CONFIG_SERIAL_8250_PNP
CONFIG_SERIAL_8250_PNPcauses legacy serial ports to be discovered twice, which is ugly but harmless:serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A 00:07: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550ASigned-off-by Bjorn Helgaas <[email protected]>Index: mm-work13/arch/i386/defconfig
===================================================================
arch/i386/defconfig line 472
Quoted 8 lines
arch/i386/defconfig +1
-1@@ -466,7 +466,7 @@ # # Plug and Play support # -# CONFIG_PNP is not set +CONFIG_PNP=y # # Block devices
shouldn't CONFIG_PNPACPI=y also appear in defconfig with this change? If it doesn't, then somebody who runs make oldconfig will get prompted for it.
Also, do we need to be concerned about the case where CONFIG_PNP=nCONFIG_ACPI=y
This is the case that motherboard.c was intended to cover.
CONFIG_PNP depends on ACPI (or ISA)
But nothing mandates that somebody must select it.
what do you think?
-Len
-Len
Re: [patch 1/5] ACPI: move FADT resource reservations from motherboard driver to osl
In reply to Shaohua LiQuoted 6 lines · Shaohua Li
drivers/acpi/osl.c line 130
Quoted 3 lines
acpi_statusacpi_os_initialize1(void)
{drivers/acpi/osl.c +1
-0+acpi_reserve_resources ();This sounds a little earlier. motherboard device usually returns a super set of the acpi io ports. reserving acpi io ports first might make some motherboard io port isn't reserved as there might be conflict.
That's true; this does reserve the FADT resources earlier, and there are often conflicts.
I'll try to figure out a way to reserve the FADT resources later.
Re: [patch 4/5] i386: turn on CONFIG_PNP in defconfig
In reply to Len BrownQuoted 9 lines · Len Brown
Quoted 9 lines
arch/i386/defconfig +1
-1@@ -466,7 +466,7 @@ # # Plug and Play support # -# CONFIG_PNP is not set +CONFIG_PNP=y
Quoted 5 lines
arch/i386/defconfig line 472
Quoted 2 lines
arch/i386/defconfig +0
-0# # Block devicesshouldn't
CONFIG_PNPACPI=yalso appear in defconfig with this change? If it doesn't, then somebody who runs make oldconfig will get prompted for it.
Yes, you're right. I'll add PNPACPI=y in the next round.
Quoted 7 lines
Also, do we need to be concerned about the case where
CONFIG_PNP=nCONFIG_ACPI=y
This is the case thatmotherboard.cwas intended to cover.
CONFIG_PNPdepends on ACPI (or ISA)
But nothing mandates that somebody must select it.
Hmmm... true. Could we get away with having ACPI select PNP?
Two other, longer term thoughts:
1) I think it would be good if PNP reserved resources for all active devices, as PCI already does (though PCI might do it even for disabled devices). Then we really wouldn't need system.c or motherboard.c at all.
2) I think we should deprecate ACPI driver registration and do everything through PNP, with the ACPI stuff as an optional capability of PNP devices. Then PNP=n, ACPI=y really wouldn't make much sense.
Bjorn
Len Brown
reviewerRe: [patch 4/5] i386: turn on CONFIG_PNP in defconfig
Quoted 10 lines · Bjorn Helgaas
Quoted 9 lines · Len Brown
Quoted 9 lines
arch/i386/defconfig +1
-1@@ -466,7 +466,7 @@ # # Plug and Play support # -# CONFIG_PNP is not set +CONFIG_PNP=y
Quoted 7 lines
Quoted 5 lines
arch/i386/defconfig line 472
Quoted 2 lines
arch/i386/defconfig +0
-0# # Block devicesshouldn't
CONFIG_PNPACPI=yalso appear in defconfig with this change? If it doesn't, then somebody who runs make oldconfig will get prompted for it.Yes, you're right. I'll add PNPACPI=y in the next round.
Hmm, I guess if we're going to include it by default, it is time to delete its dependency on EXPERIMENTAL:
Though so many things depend on EXPERIMENTAL these days that maybe it doesn't mean so much.
config PNPACPI
bool "Plug and Play ACPI support (EXPERIMENTAL)" depends on PNP && ACPI && EXPERIMENTAL
Quoted 9 lines
Quoted 7 lines
Also, do we need to be concerned about the case where
CONFIG_PNP=nCONFIG_ACPI=y
This is the case thatmotherboard.cwas intended to cover.
CONFIG_PNPdepends on ACPI (or ISA)
But nothing mandates that somebody must select it.Hmmm... true. Could we get away with having ACPI select PNP?
Every time I've tried to use select in recent memory it seems something goes bad. I think there is a rule, such as the thing selected can not depend on anything else, which if violated breaks people's ranconfigs and adrian get grumpy about it.
So I think if we want to tie them together, then ACPI should actually depend on PNP -- which is consistent, with how ACPI depends on PM today.
Quoted 10 lines
Two other, longer term thoughts:
1) I think it would be good if PNP reserved resources for all active devices, as PCI already does (though PCI might do it even for disabled devices). Then we really wouldn't needsystem.cormotherboard.cat all.2) I think we should deprecate ACPI driver registration and do everything through PNP, with the ACPI stuff as an optional capability of PNP devices. Then PNP=n, ACPI=y really wouldn't make much sense.
Whelp, when we're guaranteed that PNP exists when ACPI exists then we can get smarter about PNP.
thanks,
-Len