use irqdomain to dynamically allocate IRQ for IOAPIC
Subsystems (8)
v3 cover use irqdomain to dynamically allocate IRQ for IOAPIC
On x86 platforms, IRQ number are statically allocated to IOAPIC pins at boot. There are two issues with this design. First it causes trouble to IOAPIC hotplug because we need to allocate a block of IRQ numbers for each IOAPIC. Second it may waste IRQ nubmers even if some IOAPIC pins are not used because IRQ numbers are statically assigned.
This patchset tries to enable dynamic IRQ number allocation for IOAPIC by adopting the irqdomain framework, it solves the two issues mentioned above. It also simplifies the IOAPIC driver by consolidating ways to program IOAPIC pins with the irqdomain map interface.
We will enhance the IOAPIC driver core to support ACPI based IOAPIC hotplug once the IOAPIC driver has been converted to irqdomain.
This patchset applies to tip/irq/core and you may pull from
https://github.com/jiangliu/linux.git ioapic/irqdomain
The patchset has been tested on a two socket 64 bit Intel platforms with:
1) ACPI and mpparse enabled (boot successfully)
2) Mpparse enabled with ACPI disabled (boot successfully)
3) ACPI enabled with Mpparse disabled (boot successfully)
4) boot parameter "pci=nomsi"
5) boot parameter "acpi=noirq"
6) boot parameter "pci=noacpi"
7) UP mode (SMP disabled)
It has also been tested on an one socket laptop with 32bit Ubuntu with:
1) ACPI and mpparse enabled (boot successfully)
2) Mpparse enabled with ACPI disabled (boot successfully)
3) ACPI enabled with Mpparse disabled (boot successfully)
4) boot parameter "pci=nomsi"
5) boot parameter "acpi=noirq"
6) boot parameter "pci=noacpi"
7) UP mode (SMP disabled)
8) UP mode with IOAPIC disabled
It also builds successfully (but without booting due to hardware resource constraints) for 32 bit platforms with following configuraitons:
1) SFI enabled
2) devicetree (CE4100) enabled
V2->V3
1) Implement irqdomain unmap() interface and free IRQ when it's not used
2) Fix posssible conflicts with native and PV Xen IRQ management
3) Fix build errors on CE4100
4) Code quality and readability improvement
V1->V2
1) Rebase to tip/irq/core
2) reorder patches to put bugfixes at the head
3) fix bug in handling shared ISA IRQs
4) refine commit messages
Patch 1 is simple bugfix for MSI.
Patch 2-16 are trivial code improvements, bugfixes and preparation.
Patch 17-24 enable basic irqdomain support and IRQ number dynamic allocation.
Patch 25-29 consoldate the way to program IOAPIC pins by using irqdomain map() interface.
Patch 30-31 cleans up unused interfaces and functions in IOAPIC driver.
Patch 32-37 implement irqdoamin unmap() interfaces and free IRQ when it's not used
Tests and comments are warmly welcomed!
Jiang Liu (37):
x86, irq: update high address field when updating affinity for MSI
IRQ
genirq, trivial: improve documentation to match current
implementation
x86, mpparse: use pr_lvl() helper utilities to replace
printk(KERN_LVL)
x86, mpparse: simplify arch/x86/include/asm/mpspec.h
x86, PCI, ACPI: use kmalloc_node() to optimize for performance x86, acpi, irq: kill static function irq_to_gsi()
x86, ACPI, trivial: minor improvements to arch/x86/kernel/acpi/boot.c x86, ACPI, irq: enhance error handling in function
acpi_register_gsi()
x86, ACPI, irq: fix possible eror in GSI to IRQ mapping for legacy
IRQ
x86, irq, trivial: minor improvements of IRQ related code x86, ioapic: kill unused global variable timer_through_8259 x86, ioapic: kill static variable nr_irqs_gsi
x86, ioapic: introduce helper utilities to walk ioapics and pins x86, ioapic: use irq_cfg() instead of irq_get_chip_data() for better
readability
x86, irq: reorganize IO_APIC_get_PCI_irq_vector() to prepare for
irqdomain
x86, irq: introduce some helper utilities to improve readability x86, ACPI, irq: consolidate algorithm of mapping (ioapic, pin) to IRQ
number
x86, irq, ACPI: change __acpi_register_gsi to return IRQ number
instead of GSI
x86, irq: introduce mechanisms to support dynamically allocate IRQ
for IOAPIC
x86, irq: enhance mp_register_ioapic() to support irqdomain x86, ACPI, irq: provide basic irqdomain support
x86, mpparse, irq: provide basic irqdomain support
x86, SFI, irq: provide basic irqdomain support
x86, devicetree, irq: use common mechanism to support irqdomain x86, irq: introduce two helper functions to support irqdomain map
operation
x86, irq, ACPI: use common irqdomain map interface to program IOAPIC
pins
x86, irq, mpparse: use common irqdomain map interface to program
IOAPIC pins
x86, irq, SFI: use common irqdomain map interface to program IOAPIC
pins
x86, irq, devicetree: use common irqdomain map interface to program
IOAPIC pins
x86, irq: clean up unused IOAPIC interface
x86, irq: simplify the way to handle ISA IRQ
genirq: export irq_domain_disassociate() to architecture interrupt
drivers
x86, irq: introduce helper functions to release IOAPIC pin x86, irq, ACPI: release IOAPIC pin when PCI device is disabled x86, irq, mpparse: release IOAPIC pin when PCI device is disabled x86, irq, SFI: release IOAPIC pin when PCI device is disabled x86, irq, devicetree: release IOAPIC pin when PCI device is disabled
Documentation/IRQ-domain.txt | 3 +- arch/x86/Kconfig | 1 + arch/x86/include/asm/apic.h | 4 +- arch/x86/include/asm/hardirq.h | 3 - arch/x86/include/asm/io_apic.h | 49 +-- arch/x86/include/asm/mpspec.h | 13 - arch/x86/include/asm/prom.h | 2 - arch/x86/kernel/acpi/boot.c | 231 ++++++------- arch/x86/kernel/apic/apic.c | 2 +- arch/x86/kernel/apic/io_apic.c | 681 +++++++++++++++++++++++-------------- arch/x86/kernel/devicetree.c | 96 +----- arch/x86/kernel/irqinit.c | 6 - arch/x86/kernel/mpparse.c | 98 +++--- arch/x86/pci/acpi.c | 6 +- arch/x86/pci/intel_mid_pci.c | 27 +- arch/x86/pci/irq.c | 15 +- arch/x86/platform/intel-mid/sfi.c | 56 ++- arch/x86/platform/sfi/sfi.c | 13 +- drivers/acpi/pci_irq.c | 3 +- include/linux/irqdomain.h | 2 + kernel/irq/internals.h | 2 +- kernel/irq/irqdomain.c | 8 +- 22 files changed, 715 insertions(+), 606 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v3 1/37 x86, irq: update high address field when updating affinity for MSI IRQ
If x2apic is enabled, the MSI high address field should also be aslo updated when setting affinity for MSI IRQ, otherwise the MSI IRQ may target wrong APIC IDs.
--- arch/x86/kernel/apic/io_apic.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kernel/apic/io_apic.c +4 -0
@@ -3007,6 +3007,10 @@ msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)__get_cached_msi_msg (data->msi_desc, &msg); + msg.address_hi =MSI_ADDR_BASE_HI ; +if (x2apic_enabled ()) + msg.address_hi |=MSI_ADDR_EXT_DEST_ID (dest); + msg.data &= ~MSI_DATA_VECTOR_MASK ; msg.data |=MSI_DATA_VECTOR (cfg->vector); msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK ;
Signature · 1 line
1.7.10.4
Re: [Patch V3 01/37] x86, irq: update high address field when updating affinity for MSI IRQ
Quoted 3 lines · Jiang Liu
If x2apic is enabled, the MSI high address field should also be aslo updated when setting affinity for MSI IRQ, otherwise the MSI IRQ may target wrong APIC IDs.
That should be tagged for stable, right?
Quoted 24 lines
Signed-off-by Jiang Liu <[email protected]>--- arch/x86/kernel/apic/io_apic.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/kernel/apic/io_apic.c +4
-0@@ -3007,6 +3007,10 @@ msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)__get_cached_msi_msg (data->msi_desc, &msg); + msg.address_hi =MSI_ADDR_BASE_HI ; +if (x2apic_enabled ()) + msg.address_hi |=MSI_ADDR_EXT_DEST_ID (dest); + msg.data &= ~MSI_DATA_VECTOR_MASK ; msg.data |=MSI_DATA_VECTOR (cfg->vector); msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK ;Signature · 1 line
1.7.10.4
Re: [Patch V3 01/37] x86, irq: update high address field when updating affinity for MSI IRQ
Yes, I think it should be marked for stable branches.
Quoted 32 lines · Thomas Gleixner
Quoted 3 lines · Jiang Liu
If x2apic is enabled, the MSI high address field should also be aslo updated when setting affinity for MSI IRQ, otherwise the MSI IRQ may target wrong APIC IDs.
That should be tagged for stable, right?
Quoted 24 lines
Signed-off-by Jiang Liu <[email protected]>--- arch/x86/kernel/apic/io_apic.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/kernel/apic/io_apic.c +4
-0@@ -3007,6 +3007,10 @@ msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)__get_cached_msi_msg (data->msi_desc, &msg); + msg.address_hi =MSI_ADDR_BASE_HI ; +if (x2apic_enabled ()) + msg.address_hi |=MSI_ADDR_EXT_DEST_ID (dest); + msg.data &= ~MSI_DATA_VECTOR_MASK ; msg.data |=MSI_DATA_VECTOR (cfg->vector); msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK ;Signature · 1 line
1.7.10.4
PATCH v3 2/37 genirq, trivial: improve documentation to match current implementation
In reply to Jiang Liu--- Documentation/IRQ-domain.txt | 3 +-- kernel/irq/internals.h | 2 +- kernel/irq/irqdomain.c | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-)
Documentation/IRQ-domain.txt +1 -2
@@ -41,8 +41,7 @@ An interrupt controller driver creates and registers an irq_domain by calling one of the irq_domain_add_*() functions (each mapping method has a different allocator function, more on that later). The function will return a pointer to the irq_domain on success. The caller must -provide the allocator function with an irq_domain_ops structure with -the .map callback populated as a minimum. +provide the allocator function with an irq_domain_ops structure. In most cases, the irq_domain will begin empty without any mappings between hwirq and IRQ numbers. Mappings are added to the irq_domain
kernel/irq/internals.h +1 -1
@@ -33,7 +33,7 @@ enum { };/* -* Bit masks for desc->state +* Bit masks for desc->core_internal_state__do_not_mess_with_it * * IRQS_AUTODETECT - autodetection in progress * IRQS_SPURIOUS_DISABLED - was disabled due to spurious interrupt
kernel/irq/irqdomain.c +3 -3
@@ -27,14 +27,14 @@ static struct irq_domain *irq_default_domain;* __irq_domain_add() - Allocate a new irq_domain data structure * @of_node: optional device-tree node of the interrupt controller * @size: Size of linear map; 0 for radix mapping only +* @hwirq_max: Maximum number of interrupts supported by controller * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no * direct mapping * @ops: map/unmap domain callbacks * @host_data: Controller private data pointer * -* Allocates and initialize and irq_domain structure. Caller is expected to -* register allocated irq_domain with irq_domain_register(). Returns pointer -* to IRQ domain, or NULL on failure. +* Allocates and initialize and irq_domain structure. +* Returns pointer to IRQ domain, or NULL on failure. */ struct irq_domain *__irq_domain_add(struct device_node *of_node, int size, irq_hw_number_t hwirq_max, int direct_max,
Signature · 1 line
1.7.10.4
tip-bot for Jiang Liu
merge bot[tip:irq/core] genirq: Improve documentation to match current implementation
genirq: Improve documentation to match current implementation
Commit-ID: a257954bb38ab23dbf93df812b4b2c01cae29d8b Gitweb: http://git.kernel.org/tip/a257954bb38ab23dbf93df812b4b2c01cae29d8b Author: Jiang Liu <[email protected]> AuthorDate: Tue, 27 May 2014 16:07:37 +0800 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 27 May 2014 10:16:44 +0200
genirq: Improve documentation to match current implementation
--- Documentation/IRQ-domain.txt | 3 +-- kernel/irq/internals.h | 2 +- kernel/irq/irqdomain.c | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-)
Documentation/IRQ-domain.txt +1 -2
@@ -41,8 +41,7 @@ An interrupt controller driver creates and registers an irq_domain by calling one of the irq_domain_add_*() functions (each mapping method has a different allocator function, more on that later). The function will return a pointer to the irq_domain on success. The caller must -provide the allocator function with an irq_domain_ops structure with -the .map callback populated as a minimum. +provide the allocator function with an irq_domain_ops structure. In most cases, the irq_domain will begin empty without any mappings between hwirq and IRQ numbers. Mappings are added to the irq_domain
kernel/irq/internals.h +1 -1
@@ -33,7 +33,7 @@ enum { };/* -* Bit masks for desc->state +* Bit masks for desc->core_internal_state__do_not_mess_with_it * * IRQS_AUTODETECT - autodetection in progress * IRQS_SPURIOUS_DISABLED - was disabled due to spurious interrupt
kernel/irq/irqdomain.c +3 -3
@@ -27,14 +27,14 @@ static struct irq_domain *irq_default_domain;* __irq_domain_add() - Allocate a new irq_domain data structure * @of_node: optional device-tree node of the interrupt controller * @size: Size of linear map; 0 for radix mapping only +* @hwirq_max: Maximum number of interrupts supported by controller * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no * direct mapping * @ops: map/unmap domain callbacks * @host_data: Controller private data pointer * -* Allocates and initialize and irq_domain structure. Caller is expected to -* register allocated irq_domain with irq_domain_register(). Returns pointer -* to IRQ domain, or NULL on failure. +* Allocates and initialize and irq_domain structure. +* Returns pointer to IRQ domain, or NULL on failure. */ struct irq_domain *__irq_domain_add(struct device_node *of_node, int size, irq_hw_number_t hwirq_max, int direct_max,
PATCH v3 3/37 x86, mpparse: use pr_lvl() helper utilities to replace printk(KERN_LVL)
In reply to Jiang LiuUse pr_lvl() helper utilities to replace printk(KERN_LVL) for readability, no function changes.
--- arch/x86/kernel/mpparse.c | 84 +++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 45 deletions(-)
arch/x86/kernel/mpparse.c +39 -45
@@ -67,7 +67,7 @@ static void __init MP_processor_info(struct mpc_cpu *m) boot_cpu_physical_apicid = m->apicid; } -printk (KERN_INFO "Processor #%d%s\n" , m->apicid, bootup_cpu); +pr_info ("Processor #%d%s\n" , m->apicid, bootup_cpu);generic_processor_info (apicid, m->apicver); }
@@ -87,9 +87,8 @@ static void __init MP_bus_info(struct mpc_bus *m)#if MAX_MP_BUSSES <256 if (m->busid >=MAX_MP_BUSSES ) { -printk (KERN_WARNING "MP table busid value (%d) for bustype %s " -" is too large, max. supported is %d\n" , - m->busid, str,MAX_MP_BUSSES -1 ); +pr_warn ("MP table busid value (%d) for bustype %s is too large, max. supported is %d\n" , + m->busid, str,MAX_MP_BUSSES -1 );return ; }#endif
@@ -110,7 +109,7 @@ static void __init MP_bus_info(struct mpc_bus *m) mp_bus_id_to_type[m->busid] =MP_BUS_EISA ;#endif }else -printk (KERN_WARNING "Unknown bustype %s - ignoring\n" , str); +pr_warn ("Unknown bustype %s - ignoring\n" , str); }static void __init MP_ioapic_info (struct mpc_ioapic *m)
@@ -148,34 +147,33 @@ static int __init smp_check_mpc(struct mpc_table *mpc, char *oem, char *str) {if (memcmp (mpc->signature,MPC_SIGNATURE ,4 )) { -printk (KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n" , +pr_err ("MPTABLE: bad signature [%c%c%c%c]!\n" , mpc->signature[0 ], mpc->signature[1 ], mpc->signature[2 ], mpc->signature[3 ]);return 0 ; }if (mpf_checksum ((unsigned char *)mpc, mpc->length)) { -printk (KERN_ERR "MPTABLE: checksum error!\n" ); +pr_err ("MPTABLE: checksum error!\n" );return 0 ; }if (mpc->spec !=0x01 && mpc->spec !=0x04 ) { -printk (KERN_ERR "MPTABLE: bad table version (%d)!!\n" , - mpc->spec); +pr_err ("MPTABLE: bad table version (%d)!!\n" , mpc->spec);return 0 ; }if (!mpc->lapic) { -printk (KERN_ERR "MPTABLE: null local APIC address!\n" ); +pr_err ("MPTABLE: null local APIC address!\n" );return 0 ; }memcpy (oem, mpc->oem,8 ); oem[8 ] =0 ; -printk (KERN_INFO "MPTABLE: OEM ID: %s\n" , oem); +pr_info ("MPTABLE: OEM ID: %s\n" , oem);memcpy (str, mpc->productid,12 ); str[12 ] =0 ; -printk (KERN_INFO "MPTABLE: Product ID: %s\n" , str); +pr_info ("MPTABLE: Product ID: %s\n" , str); -printk (KERN_INFO "MPTABLE: APIC at: 0x%X\n" , mpc->lapic); +pr_info ("MPTABLE: APIC at: 0x%X\n" , mpc->lapic);return 1 ; }
@@ -188,8 +186,8 @@ static void skip_entry(unsigned char **ptr, int *count, int size)static void __init smp_dump_mptable (struct mpc_table *mpc,unsigned char *mpt) { -printk (KERN_ERR "Your mptable is wrong, contact your HW vendor!\n" -"type %x\n" , *mpt); +pr_err ("Your mptable is wrong, contact your HW vendor!\ntype %x\n" , + *mpt);print_hex_dump (KERN_ERR ," " ,DUMP_PREFIX_ADDRESS ,16 ,1 , mpc, mpc->length,1 ); }
@@ -259,7 +257,7 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early) }if (!num_processors) -printk (KERN_ERR "MPTABLE: no processors registered!\n" ); +pr_err ("MPTABLE: no processors registered!\n" );return num_processors; }
@@ -295,16 +293,13 @@ static void __init construct_default_ioirq_mptable(int mpc_default_type)* If it does, we assume it's valid. */ if (mpc_default_type ==5 ) { -printk (KERN_INFO "ISA/PCI bus type with no IRQ information... " -"falling back to ELCR\n" ); +pr_info ("ISA/PCI bus type with no IRQ information... falling back to ELCR\n" );if (ELCR_trigger (0 ) ||ELCR_trigger (1 ) ||ELCR_trigger (2 ) ||ELCR_trigger (13 )) -printk (KERN_ERR "ELCR contains invalid data... " -"not using ELCR\n" ); +pr_err ("ELCR contains invalid data... not using ELCR\n" );else { -printk (KERN_INFO -"Using ELCR to identify PCI interrupts\n" ); +pr_info ("Using ELCR to identify PCI interrupts\n" ); ELCR_fallback =1 ; } }
@@ -353,7 +348,7 @@ static void __init construct_ioapic_table(int mpc_default_type) bus.busid =0 ;switch (mpc_default_type) {default : -printk (KERN_ERR "???\nUnknown standard configuration %d\n" , +pr_err ("???\nUnknown standard configuration %d\n" , mpc_default_type);/* fall through */ case 1 :
@@ -462,7 +457,7 @@ static int __init check_physptr(struct mpf_intel *mpf, unsigned int early)#ifdef CONFIG_X86_LOCAL_APIC smp_found_config =0 ;#endif -printk (KERN_ERR "BIOS bug, MP table errors detected!...\n" +pr_err ("BIOS bug, MP table errors detected!...\n" "... disabling SMP support. (tell your hw vendor)\n" );early_iounmap (mpc, size);return -1 ;
@@ -481,7 +476,7 @@ static int __init check_physptr(struct mpf_intel *mpf, unsigned int early)if (!mp_irq_entries) {struct mpc_bus bus; -printk (KERN_ERR "BIOS bug, no explicit IRQ entries, " +pr_err ("BIOS bug, no explicit IRQ entries, " "using default mptable. (tell your hw vendor)\n" ); bus.type =MP_BUS ;
@@ -516,14 +511,14 @@ void __init default_get_smp_config(unsigned int early)if (acpi_lapic && acpi_ioapic)return ; -printk (KERN_INFO "Intel MultiProcessor Specification v1.%d\n" , - mpf->specification); +pr_info ("Intel MultiProcessor Specification v1.%d\n" , + mpf->specification);#if defined(CONFIG_X86_LOCAL_APIC ) && defined(CONFIG_X86_32 )if (mpf->feature2 & (1 <<7 )) { -printk (KERN_INFO " IMCR and PIC compatibility mode.\n" ); +pr_info (" IMCR and PIC compatibility mode.\n" ); pic_mode =1 ; }else { -printk (KERN_INFO " Virtual Wire compatibility mode.\n" ); +pr_info (" Virtual Wire compatibility mode.\n" ); pic_mode =0 ; }#endif
@@ -539,8 +534,7 @@ void __init default_get_smp_config(unsigned int early)return ; } -printk (KERN_INFO "Default MP configuration #%d\n" , - mpf->feature1); +pr_info ("Default MP configuration #%d\n" , mpf->feature1);construct_default_ISA_mptable (mpf->feature1); }else if (mpf->physptr) {
@@ -550,7 +544,7 @@ void __init default_get_smp_config(unsigned int early)BUG ();if (!early) -printk (KERN_INFO "Processors: %d\n" , num_processors); +pr_info ("Processors: %d\n" , num_processors);/* * Only use the first configuration found. */
@@ -583,10 +577,10 @@ static int __init smp_scan_config(unsigned long base, unsigned long length)#endif mpf_found = mpf; -printk (KERN_INFO "found SMP MP-table at [mem %#010llx-%#010llx] mapped at [%p]\n" , - (unsigned long long )virt_to_phys (mpf), - (unsigned long long )virt_to_phys (mpf) + -sizeof (*mpf) -1 , mpf); +pr_info ("found SMP MP-table at [mem %#010llx-%#010llx] mapped at [%p]\n" , + (unsigned long long )virt_to_phys (mpf), + (unsigned long long )virt_to_phys (mpf) + +sizeof (*mpf) -1 , mpf); mem =virt_to_phys (mpf);memblock_reserve (mem,sizeof (*mpf));
@@ -735,7 +729,7 @@ static int __init replace_intsrc_all(struct mpc_table *mpc,int nr_m_spare =0 ;unsigned char *mpt = ((unsigned char *)mpc) + count; -printk (KERN_INFO "mpc_length %x\n" , mpc->length); +pr_info ("mpc_length %x\n" , mpc->length);while (count < mpc->length) {switch (*mpt) {case MP_PROCESSOR :
@@ -862,13 +856,13 @@ static int __init update_mp_table(void)if (!smp_check_mpc (mpc, oem, str))return 0 ; -printk (KERN_INFO "mpf: %llx\n" , (u64 )virt_to_phys (mpf)); -printk (KERN_INFO "physptr: %x\n" , mpf->physptr); +pr_info ("mpf: %llx\n" , (u64 )virt_to_phys (mpf)); +pr_info ("physptr: %x\n" , mpf->physptr);if (mpc_new_phys && mpc->length > mpc_new_length) { mpc_new_phys =0 ; -printk (KERN_INFO "mpc_new_length is %ld, please use alloc_mptable=8k\n" , - mpc_new_length); +pr_info ("mpc_new_length is %ld, please use alloc_mptable=8k\n" , + mpc_new_length); }if (!mpc_new_phys) {
@@ -879,10 +873,10 @@ static int __init update_mp_table(void) mpc->checksum =0xff ; new =mpf_checksum ((unsigned char *)mpc, mpc->length);if (old == new) { -printk (KERN_INFO "mpc is readonly, please try alloc_mptable instead\n" ); +pr_info ("mpc is readonly, please try alloc_mptable instead\n" );return 0 ; } -printk (KERN_INFO "use in-position replacing\n" ); +pr_info ("use in-position replacing\n" ); }else { mpf->physptr = mpc_new_phys; mpc_new =phys_to_virt (mpc_new_phys);
@@ -892,7 +886,7 @@ static int __init update_mp_table(void)if (mpc_new_phys - mpf->physptr) {struct mpf_intel *mpf_new;/* steal 16 bytes from [0, 1k) */ -printk (KERN_INFO "mpf new: %x\n" ,0x400 -16 ); +pr_info ("mpf new: %x\n" ,0x400 -16 ); mpf_new =phys_to_virt (0x400 -16 );memcpy (mpf_new, mpf,16 ); mpf = mpf_new;
@@ -900,7 +894,7 @@ static int __init update_mp_table(void) } mpf->checksum =0 ; mpf->checksum -=mpf_checksum ((unsigned char *)mpf,16 ); -printk (KERN_INFO "physptr new: %x\n" , mpf->physptr); +pr_info ("physptr new: %x\n" , mpf->physptr); }/*
Signature · 1 line
1.7.10.4
Re: [Patch V3 03/37] x86, mpparse: use pr_lvl() helper utilities to replace printk(KERN_LVL)
Quoted 4 lines · Jiang Liu
Use
pr_lvl()helper utilities to replaceprintk(KERN_LVL)for readability, no function changes.Signed-off-by Jiang Liu <[email protected]>
Eek, lots of newlines in single printks without pr_cont() that are existing, probably to make them more visible during debugging. I think we could clean this up even further, but the printk(KERN_LVL) -> pr_lvl() conversion of this patch is a step in the right direction.
PATCH v3 4/37 x86, mpparse: simplify arch/x86/include/asm/mpspec.h
In reply to Jiang LiuSimplify arch/x86/include/asm/mpspec.h by
1) Change max_physical_apicid to static as it's only used in apic.c.
2) Kill declaration of mpc_default_type, it's never defined.
3) Delete default_acpi_madt_oem_check(), it has already been declared in apic.h.
4) Change mp_override_legacy_irq(), mp_config_acpi_legacy_irqs() and mp_register_gsi() as static because they are only used in acpi/boot.c.
--- arch/x86/include/asm/apic.h | 4 ++-- arch/x86/include/asm/io_apic.h | 3 --- arch/x86/include/asm/mpspec.h | 13 ------------- arch/x86/kernel/acpi/boot.c | 12 +++++++++--- arch/x86/kernel/apic/apic.c | 2 +- 5 files changed, 12 insertions(+), 22 deletions(-)
arch/x86/include/asm/apic.h +2 -2
@@ -502,8 +502,6 @@ static inline unsigned default_get_apic_id(unsigned long x)#define DEFAULT_TRAMPOLINE_PHYS_HIGH 0x469#ifdef CONFIG_X86_64 -extern int default_acpi_madt_oem_check (char *,char *); -extern void apic_send_IPI_self (int vector);DECLARE_PER_CPU (int, x2apic_extra_bits);
@@ -552,6 +550,8 @@ static inline int default_apic_id_valid(int apicid)return (apicid <255 ); } +extern int default_acpi_madt_oem_check (char *,char *); +extern void default_setup_apic_routing (void );extern struct apic apic_noop;
arch/x86/include/asm/io_apic.h +0 -3
@@ -118,9 +118,6 @@ extern int mp_irq_entries;/* MP IRQ source entries */ extern struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES ]; -/* non-0 if default (table-less) MP configuration */ -extern int mpc_default_type; -/* Older SiS APIC requires we rewrite the index register */ extern int sis_apic_bug;
arch/x86/include/asm/mpspec.h +0 -13
@@ -40,8 +40,6 @@ extern int mp_bus_id_to_type[MAX_MP_BUSSES]; extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);extern unsigned int boot_cpu_physical_apicid; -extern unsigned int max_physical_apicid; -extern int mpc_default_type;extern unsigned long mp_lapic_addr;#ifdef CONFIG_X86_LOCAL_APIC
@@ -88,15 +86,6 @@ static inline void early_reserve_e820_mpc_new(void) { }#endif int generic_processor_info (int apicid,int version); -#ifdef CONFIG_ACPI -extern void mp_register_ioapic (int id,u32 address,u32 gsi_base); -extern void mp_override_legacy_irq (u8 bus_irq,u8 polarity,u8 trigger, -u32 gsi); -extern void mp_config_acpi_legacy_irqs (void ); -struct device ; -extern int mp_register_gsi (struct device *dev,u32 gsi,int edge_level, -int active_high_low); -#endif /* CONFIG_ACPI */ #define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_LOCAL_APIC)
@@ -163,6 +152,4 @@ extern physid_mask_t phys_cpu_present_map;extern int generic_mps_oem_check (struct mpc_table *,char *,char *); -extern int default_acpi_madt_oem_check (char *,char *); -#endif /* _ASM_X86_MPSPEC_H */
arch/x86/kernel/acpi/boot.c +9 -3
@@ -345,6 +345,10 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e#endif /*CONFIG_X86_LOCAL_APIC */ #ifdef CONFIG_X86_IO_APIC +static void mp_override_legacy_irq (u8 bus_irq,u8 polarity,u8 trigger, +u32 gsi); +static int mp_register_gsi (struct device *dev,u32 gsi,int trigger, +int polarity);static int __init acpi_parse_ioapic (struct acpi_subtable_header * header,const unsigned long end)
@@ -903,7 +907,8 @@ static int __init acpi_parse_madt_lapic_entries(void)#ifdef CONFIG_X86_IO_APIC #define MP_ISA_BUS 0 -void __init mp_override_legacy_irq (u8 bus_irq,u8 polarity,u8 trigger,u32 gsi) +static void __init mp_override_legacy_irq (u8 bus_irq,u8 polarity,u8 trigger, +u32 gsi) {int ioapic;int pin;
@@ -938,7 +943,7 @@ void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi) isa_irq_to_gsi[bus_irq] = gsi; } -void __init mp_config_acpi_legacy_irqs (void ) +static void __init mp_config_acpi_legacy_irqs (void ) {int i;struct mpc_intsrc mp_irq;
@@ -1040,7 +1045,8 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,return 0 ; } -int mp_register_gsi (struct device *dev,u32 gsi,int trigger,int polarity) +static int mp_register_gsi (struct device *dev,u32 gsi,int trigger, +int polarity) {int ioapic;int ioapic_pin;
arch/x86/kernel/apic/apic.c +1 -1
@@ -67,7 +67,7 @@ EXPORT_SYMBOL_GPL(boot_cpu_physical_apicid);/* * The highest APIC ID seen during enumeration. */ -unsigned int max_physical_apicid; +static unsigned int max_physical_apicid;/* * Bitmask of physically existing CPUs:
Signature · 1 line
1.7.10.4
PATCH v3 5/37 x86, PCI, ACPI: use kmalloc_node() to optimize for performance
In reply to Jiang LiuUse kmalloc_node() instead of kmalloc() when possible to optimize for performance on NUMA platforms.
--- arch/x86/pci/acpi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/pci/acpi.c +3 -3
@@ -448,7 +448,7 @@ static void probe_pci_root_info(struct pci_root_info *info,return ; size =sizeof (*info->res) * info->res_num; - info->res =kzalloc (size,GFP_KERNEL ); + info->res =kzalloc_node (size,GFP_KERNEL , info->sd.node);if (!info->res) { info->res_num =0 ;return ;
@@ -456,7 +456,7 @@ static void probe_pci_root_info(struct pci_root_info *info, size =sizeof (*info->res_offset) * info->res_num; info->res_num =0 ; - info->res_offset =kzalloc (size,GFP_KERNEL ); + info->res_offset =kzalloc_node (size,GFP_KERNEL , info->sd.node);if (!info->res_offset) {kfree (info->res); info->res =NULL ;
@@ -495,7 +495,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)if (node !=NUMA_NO_NODE && !node_online (node)) node =NUMA_NO_NODE ; - info =kzalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc_node (sizeof (*info),GFP_KERNEL , node);if (!info) {printk (KERN_WARNING "pci_bus %04x:%02x: " "ignored (out of memory)\n" , domain, busnum);
Signature · 1 line
1.7.10.4
Re: [Patch V3 05/37] x86, PCI, ACPI: use kmalloc_node() to optimize for performance
Quoted 4 lines · Jiang Liu
Use
kmalloc_node()instead ofkmalloc()when possible to optimize for performance on NUMA platforms.Signed-off-by Jiang Liu <[email protected]>
I think this is micro-optimization, because I don't think these structures are referenced often. It might be nicer if we could arrange to run this path on the local node, as we do in pci_call_probe(), so all allocs would happen there. But I'm OK with this as-is.
Quoted 38 lines
--- arch/x86/pci/acpi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/x86/pci/acpi.c +3
-4@@ -448,7 +448,7 @@ static void probe_pci_root_info(struct pci_root_info *info,return ; size =sizeof (*info->res) * info->res_num; - info->res =kzalloc (size,GFP_KERNEL ); + info->res =kzalloc_node (size,GFP_KERNEL , info->sd.node);if (!info->res) { info->res_num =0 ;return ;@@ -456,7 +456,7 @@ static void probe_pci_root_info(struct pci_root_info *info, size =sizeof (*info->res_offset) * info->res_num; info->res_num =0 ; - info->res_offset =kzalloc (size,GFP_KERNEL ); + info->res_offset =kzalloc_node (size,GFP_KERNEL , info->sd.node);if (!info->res_offset) {kfree (info->res); info->res =NULL ;@@ -495,7 +495,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)if (node !=NUMA_NO_NODE && !node_online (node)) node =NUMA_NO_NODE ; - info =kzalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc_node (sizeof (*info),GFP_KERNEL , node);if (!info) {printk (KERN_WARNING "pci_bus %04x:%02x: " "ignored (out of memory)\n" , domain, busnum); --1.7.10.4
Re: [Patch V3 05/37] x86, PCI, ACPI: use kmalloc_node() to optimize for performance
In reply to Jiang LiuQuoted 4 lines · Jiang Liu
Use
kmalloc_node()instead ofkmalloc()when possible to optimize for performance on NUMA platforms.Signed-off-by Jiang Liu <[email protected]>
All the handling to make sure sd->node refers to either NUMA_NO_NODE (fallback to local allocation) or an online node looks to be handled properly.
PATCH v3 6/37 x86, acpi, irq: kill static function irq_to_gsi()
In reply to Jiang LiuStatic function irq_to_gsi() is only called by acpi_isa_irq_to_gsi(), so kill function irq_to_gsi() and simplify acpi_isa_irq_to_gsi().
--- arch/x86/kernel/acpi/boot.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)
arch/x86/kernel/acpi/boot.c +6 -20
@@ -120,22 +120,6 @@ static unsigned int gsi_to_irq(unsigned int gsi)return irq; } -static u32 irq_to_gsi (int irq) -{ -unsigned int gsi; - -if (irq <NR_IRQS_LEGACY ) - gsi = isa_irq_to_gsi[irq]; -else if (irq < gsi_top) - gsi = irq; -else if (irq < (gsi_top +NR_IRQS_LEGACY )) - gsi = irq - gsi_top; -else - gsi =0xffffffff ; - -return gsi; -} -/* * This is just a simple wrapper around early_ioremap(), * with sanity checks for phys == 0 and size == 0.
@@ -527,10 +511,12 @@ EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);int acpi_isa_irq_to_gsi (unsigned isa_irq,u32 *gsi) { -if (isa_irq >=16 ) -return -1 ; - *gsi =irq_to_gsi (isa_irq); -return 0 ; +if (isa_irq <NR_IRQS_LEGACY ) { + *gsi = isa_irq_to_gsi[isa_irq]; +return 0 ; + } + +return -1 ; } static int acpi_register_gsi_pic(struct device *dev, u32 gsi,
Signature · 1 line
1.7.10.4
PATCH v3 7/37 x86, ACPI, trivial: minor improvements to arch/x86/kernel/acpi/boot.c
In reply to Jiang Liu1) Remove out-of-date comment
2) Kill unused function acpi_set_irq_model_pic()
3) Use NR_IRQS_LEGACY instead of hard-coded 16
4) Trivial syntax improvements
--- arch/x86/kernel/acpi/boot.c | 50 ++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 34 deletions(-)
arch/x86/kernel/acpi/boot.c +16 -34
@@ -370,11 +370,6 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger,if (acpi_sci_flags &ACPI_MADT_POLARITY_MASK ) polarity = acpi_sci_flags &ACPI_MADT_POLARITY_MASK ; -/* -* mp_config_acpi_legacy_irqs() already setup IRQs < 16 -* If GSI is < 16, this will update its flags, -* else it will create a new mp_irqs[] entry. -*/ mp_override_legacy_irq (bus_irq, polarity, trigger, gsi);/*
@@ -573,14 +568,7 @@ void acpi_unregister_gsi(u32 gsi) }EXPORT_SYMBOL_GPL (acpi_unregister_gsi); -void __init acpi_set_irq_model_pic (void ) -{ - acpi_irq_model =ACPI_IRQ_MODEL_PIC ; - __acpi_register_gsi = acpi_register_gsi_pic; - acpi_ioapic =0 ; -} - -void __init acpi_set_irq_model_ioapic (void ) +static void __init acpi_set_irq_model_ioapic (void ) { acpi_irq_model =ACPI_IRQ_MODEL_IOAPIC ; __acpi_register_gsi = acpi_register_gsi_ioapic;
@@ -819,9 +807,8 @@ static int __init early_acpi_parse_madt_lapic_addr_ovr(void)* and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). */ - count = -acpi_table_parse_madt (ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE , - acpi_parse_lapic_addr_ovr,0 ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE , + acpi_parse_lapic_addr_ovr,0 );if (count <0 ) { printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
@@ -846,9 +833,8 @@ static int __init acpi_parse_madt_lapic_entries(void)* and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). */ - count = -acpi_table_parse_madt (ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE , - acpi_parse_lapic_addr_ovr,0 ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE , + acpi_parse_lapic_addr_ovr,0 );if (count <0 ) { printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
@@ -876,11 +862,10 @@ static int __init acpi_parse_madt_lapic_entries(void)return count; } - x2count = -acpi_table_parse_madt (ACPI_MADT_TYPE_LOCAL_X2APIC_NMI , - acpi_parse_x2apic_nmi,0 ); - count = -acpi_table_parse_madt (ACPI_MADT_TYPE_LOCAL_APIC_NMI , acpi_parse_lapic_nmi,0 ); + x2count =acpi_table_parse_madt (ACPI_MADT_TYPE_LOCAL_X2APIC_NMI , + acpi_parse_x2apic_nmi,0 ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_LOCAL_APIC_NMI , + acpi_parse_lapic_nmi,0 );if (count <0 || x2count <0 ) { printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");/* TBD: Cleanup to allow fallback to MPS */
@@ -947,7 +932,7 @@ static void __init mp_config_acpi_legacy_irqs(void)* Use the default configuration for the IRQs 0-15. Unless * overridden by (MADT) interrupt source override entries. */ -for (i =0 ; i <16 ; i++) { +for (i =0 ; i <NR_IRQS_LEGACY ; i++) {int ioapic, pin;unsigned int dstapic;int idx;
@@ -1103,9 +1088,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)return -ENODEV ; } - count = -acpi_table_parse_madt (ACPI_MADT_TYPE_IO_APIC , acpi_parse_ioapic, -MAX_IO_APICS ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_IO_APIC , acpi_parse_ioapic, +MAX_IO_APICS );if (!count) { printk(KERN_ERR PREFIX "No IOAPIC entries present\n");return -ENODEV ;
@@ -1114,9 +1098,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)return count; } - count = -acpi_table_parse_madt (ACPI_MADT_TYPE_INTERRUPT_OVERRIDE , acpi_parse_int_src_ovr, - nr_irqs); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_INTERRUPT_OVERRIDE , + acpi_parse_int_src_ovr, nr_irqs);if (count <0 ) { printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n");
@@ -1135,9 +1118,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)/* Fill in identity legacy mappings where no override */ mp_config_acpi_legacy_irqs (); - count = -acpi_table_parse_madt (ACPI_MADT_TYPE_NMI_SOURCE , acpi_parse_nmi_src, - nr_irqs); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_NMI_SOURCE , + acpi_parse_nmi_src, nr_irqs);if (count <0 ) { printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");/* TBD: Cleanup to allow fallback to MPS */
Signature · 1 line
1.7.10.4
PATCH v3 8/37 x86, ACPI, irq: enhance error handling in function acpi_register_gsi()
In reply to Jiang LiuFunction mp_register_gsi() may return invalid GSI if error happens, so enhance acpi_register_gsi() to handle possible error cases.
--- arch/x86/kernel/acpi/boot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kernel/acpi/boot.c +6 -4
@@ -97,6 +97,8 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 }; +#define ACPI_INVALID_GSI INT_MIN +static unsigned int gsi_to_irq (unsigned int gsi) {unsigned int irq = gsi +NR_IRQS_LEGACY ;
@@ -553,13 +555,13 @@ int (*acpi_suspend_lowlevel)(void);*/ int acpi_register_gsi (struct device *dev,u32 gsi,int trigger,int polarity) { -unsigned int irq;unsigned int plat_gsi = gsi; plat_gsi = (*__acpi_register_gsi)(dev, gsi, trigger, polarity); - irq =gsi_to_irq (plat_gsi); +if (plat_gsi !=ACPI_INVALID_GSI ) +return gsi_to_irq (plat_gsi); -return irq; +return -1 ; }EXPORT_SYMBOL_GPL (acpi_register_gsi);
@@ -1054,7 +1056,7 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger, polarity == ACPI_ACTIVE_HIGH ? 0 : 1); ret =io_apic_set_pci_routing (dev,gsi_to_irq (gsi), &irq_attr);if (ret <0 ) - gsi =INT_MIN ; + gsi =ACPI_INVALID_GSI ;return gsi; }
Signature · 1 line
1.7.10.4
PATCH v3 9/37 x86, ACPI, irq: fix possible eror in GSI to IRQ mapping for legacy IRQ
In reply to Jiang LiuA default identity mapping between GSI and IRQ is built for legacy IRQs. So when overriding the default identity mapping for legacy IRQs, we should also invalidate isa_irq_to_gsi[gsi] when setting isa_irq_to_gsi[irq] = gsi. Otherwise there may be two entries with the same GSI in the isa_irq_to_gsi array, and acpi_isa_irq_to_gsi() may give wrong result.
--- arch/x86/kernel/acpi/boot.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/x86/kernel/acpi/boot.c +9 -1
@@ -508,7 +508,8 @@ EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);int acpi_isa_irq_to_gsi (unsigned isa_irq,u32 *gsi) { -if (isa_irq <NR_IRQS_LEGACY ) { +if (isa_irq <NR_IRQS_LEGACY && + isa_irq_to_gsi[isa_irq] !=ACPI_INVALID_GSI ) { *gsi = isa_irq_to_gsi[isa_irq];return 0 ; }
@@ -913,6 +914,13 @@ static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,mp_save_irq (&mp_irq); +/* +* Reset default identity mapping if gsi is also an legacy IRQ, +* otherwise there will be more than one entry with the same GSI +* and acpi_isa_irq_to_gsi() may give wrong result. +*/ +if (gsi <NR_IRQS_LEGACY && isa_irq_to_gsi[gsi] == gsi) + isa_irq_to_gsi[gsi] =ACPI_INVALID_GSI ; isa_irq_to_gsi[bus_irq] = gsi; }
Signature · 1 line
1.7.10.4
PATCH v3 10/37 x86, irq, trivial: minor improvements of IRQ related code
In reply to Jiang Liu1) Kill unused MAX_HARDIRQS_PER_CPU.
2) Improve function prototype declararions.
3) simple typo fix, change "gsit" to "gsi".
4) use macro VECTOR_UNDEFINED instead of hard-coded -1.
--- arch/x86/include/asm/hardirq.h | 3 --- arch/x86/include/asm/io_apic.h | 16 +++++++--------- arch/x86/kernel/apic/io_apic.c | 10 +++++----- 3 files changed, 12 insertions(+), 17 deletions(-)
arch/x86/include/asm/hardirq.h +0 -3
@@ -40,9 +40,6 @@ typedef struct {DECLARE_PER_CPU_SHARED_ALIGNED (irq_cpustat_t, irq_stat); -/* We can have at most NR_VECTORS irqs routed to a cpu at a time */ -#define MAX_HARDIRQS_PER_CPU NR_VECTORS -#define __ARCH_IRQ_STAT#define inc_irq_stat (member) this_cpu_inc(irq_stat.member)
arch/x86/include/asm/io_apic.h +7 -9
@@ -144,22 +144,20 @@ struct io_apic_irq_attr;struct irq_cfg ;extern int io_apic_set_pci_routing (struct device *dev,int irq,struct io_apic_irq_attr *irq_attr); -void setup_IO_APIC_irq_extra (u32 gsi); +extern void setup_IO_APIC_irq_extra (u32 gsi);extern void ioapic_insert_resources (void );extern int native_setup_ioapic_entry (int ,struct IO_APIC_route_entry *,unsigned int ,int ,struct io_apic_irq_attr *); -extern int native_setup_ioapic_entry (int ,struct IO_APIC_route_entry *, -unsigned int ,int , -struct io_apic_irq_attr *);extern void eoi_ioapic_irq (unsigned int irq,struct irq_cfg *cfg);extern void native_compose_msi_msg (struct pci_dev *pdev,unsigned int irq,unsigned int dest,struct msi_msg *msg,u8 hpet_id);extern void native_eoi_ioapic_pin (int apic,int pin,int vector); -int io_apic_setup_irq_pin_once (unsigned int irq,int node,struct io_apic_irq_attr *attr); +extern int io_apic_setup_irq_pin_once (unsigned int irq,int node, +struct io_apic_irq_attr *attr);extern int save_ioapic_entries (void );extern void mask_ioapic_entries (void );
@@ -172,11 +170,11 @@ struct mp_ioapic_gsi{u32 gsi_base;u32 gsi_end; }; -extern struct mp_ioapic_gsi mp_gsi_routing[];extern u32 gsi_top; -int mp_find_ioapic (u32 gsi); -int mp_find_ioapic_pin (int ioapic,u32 gsi); -void __init mp_register_ioapic (int id,u32 address,u32 gsi_base); + +extern int mp_find_ioapic (u32 gsi); +extern int mp_find_ioapic_pin (int ioapic,u32 gsi); +extern void __init mp_register_ioapic (int id,u32 address,u32 gsi_base);extern void __init pre_init_apic_IRQ0 (void );extern void mp_save_irq (struct mpc_intsrc *m);
arch/x86/kernel/apic/io_apic.c +5 -5
@@ -1010,7 +1010,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,break ;if (!test_bit (lbus, mp_bus_not_pci) && - !mp_irqs[i].irqtype && + mp_irqs[i].irqtype == mp_INT && (bus == lbus) && (slot == ((mp_irqs[i].srcbusirq >>2 ) &0x1f ))) {int irq =pin_2_irq (i, ioapic_idx, mp_irqs[i].dstirq);
@@ -1359,7 +1359,7 @@ static void __init __io_apic_setup_irqs(unsigned int ioapic_idx) irq =pin_2_irq (idx, ioapic_idx, pin); -if ((ioapic_idx >0 ) && (irq >16 )) +if ((ioapic_idx >0 ) && (irq >NR_IRQS_LEGACY ))continue ;/*
@@ -1388,7 +1388,7 @@ static void __init setup_IO_APIC_irqs(void) }/* -* for the gsit that is not in first ioapic +* for the gsi that is not in first ioapic * but could not use acpi_register_gsi() * like some special sci in IBM x3330 */
@@ -2225,7 +2225,7 @@ asmlinkage __visible void smp_irq_move_cleanup_interrupt(void) apic->send_IPI_self (IRQ_MOVE_CLEANUP_VECTOR ); goto unlock; } -__this_cpu_write (vector_irq[vector],-1 ); +__this_cpu_write (vector_irq[vector],VECTOR_UNDEFINED ); unlock:raw_spin_unlock (&desc->lock); }
@@ -3546,7 +3546,7 @@ void __init setup_ioapic_dest(void)continue ; irq =pin_2_irq (irq_entry, ioapic, pin); -if ((ioapic >0 ) && (irq >16 )) +if ((ioapic >0 ) && (irq >NR_IRQS_LEGACY ))continue ; idata =irq_get_irq_data (irq);
Signature · 1 line
1.7.10.4
PATCH v3 11/37 x86, ioapic: kill unused global variable timer_through_8259
In reply to Jiang Liu--- arch/x86/include/asm/io_apic.h | 4 ---- arch/x86/kernel/apic/io_apic.c | 3 --- 2 files changed, 7 deletions(-)
arch/x86/include/asm/io_apic.h +0 -4
@@ -130,9 +130,6 @@ extern int noioapicquirk;/* -1 if "noapic" boot option passed */ extern int noioapicreroute; -/* 1 if the timer IRQ uses the '8259A Virtual Wire' mode */ -extern int timer_through_8259; -/* * If we use the IO-APIC for IRQ routing, disable automatic * assignment of PCI IRQ's.
@@ -212,7 +209,6 @@ extern void io_apic_eoi(unsigned int apic, unsigned int vector);#define io_apic_assign_pci_irqs 0#define setup_ioapic_ids_from_mpc x86_init_noop -static const int timer_through_8259 =0 ;static inline void ioapic_insert_resources (void ) { }#define gsi_top (NR_IRQS_LEGACY)static inline int mp_find_ioapic (u32 gsi) {return 0 ; }
arch/x86/kernel/apic/io_apic.c +0 -3
@@ -2649,8 +2649,6 @@ static int __init disable_timer_pin_setup(char *arg) }early_param ("disable_timer_pin_1" , disable_timer_pin_setup); -int timer_through_8259__initdata ; -/* * This code may look a bit paranoid, but it's supposed to cooperate with * a wide range of boards and BIOS bugs. Fortunately only the timer IRQ
@@ -2755,7 +2753,6 @@ static inline void __init check_timer(void) legacy_pic->unmask (0 );if (timer_irq_works ()) {apic_printk (APIC_QUIET ,KERN_INFO "....... works.\n" ); - timer_through_8259 =1 ; goto out; }/*
Signature · 1 line
1.7.10.4
PATCH v3 12/37 x86, ioapic: kill static variable nr_irqs_gsi
In reply to Jiang LiuStatic variable nr_irqs_gsi is used to maintain the lowest dynamic allocatable IRQ number. It may cause trouble when enabling dynamic IRQ allocation for IOAPIC, so use arch_dynirq_lower_bound() to avoid directly accessing nr_irqs_gsi and kill nr_irqs_gsi.
--- arch/x86/kernel/apic/io_apic.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)
arch/x86/kernel/apic/io_apic.c +5 -19
@@ -118,9 +118,6 @@ struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES];/* # of MP IRQ source entries */ int mp_irq_entries; -/* GSI interrupts */ -static int nr_irqs_gsi =NR_IRQS_LEGACY ; -#ifdef CONFIG_EISA int mp_bus_id_to_type[MAX_MP_BUSSES ];#endif
@@ -3333,20 +3330,11 @@ static int __init io_apic_get_redir_entries(int ioapic)return reg_01.bits.entries +1 ; } -static void __init probe_nr_irqs_gsi (void ) -{ -int nr; - - nr = gsi_top +NR_IRQS_LEGACY ; -if (nr > nr_irqs_gsi) - nr_irqs_gsi = nr; - -printk (KERN_DEBUG "nr_irqs_gsi: %d\n" , nr_irqs_gsi); -} -unsigned int arch_dynirq_lower_bound (unsigned int from) { -return from < nr_irqs_gsi ? nr_irqs_gsi : from; +unsigned int min = gsi_top +NR_IRQS_LEGACY ; + +return from < min ? min : from; }int __init arch_probe_nr_irqs (void )
@@ -3356,12 +3344,12 @@ int __init arch_probe_nr_irqs(void)if (nr_irqs > (NR_VECTORS * nr_cpu_ids)) nr_irqs =NR_VECTORS * nr_cpu_ids; - nr = nr_irqs_gsi +8 * nr_cpu_ids; + nr = (gsi_top +NR_IRQS_LEGACY ) +8 * nr_cpu_ids;#if defined(CONFIG_PCI_MSI ) || defined(CONFIG_HT_IRQ )/* * for MSI and HT dyn irq */ - nr += nr_irqs_gsi *16 ; + nr += (gsi_top +NR_IRQS_LEGACY ) *16 ;#endif if (nr < nr_irqs) nr_irqs = nr;
@@ -3634,8 +3622,6 @@ fake_ioapic_page: ioapic_res->end = ioapic_phys +IO_APIC_SLOT_SIZE -1 ; ioapic_res++; } - -probe_nr_irqs_gsi (); }void __init ioapic_insert_resources (void )
Signature · 1 line
1.7.10.4
PATCH v3 13/37 x86, ioapic: introduce helper utilities to walk ioapics and pins
In reply to Jiang LiuIntroduce helper utilities for_each_ioapic(), for_each_ioapic_reverse(), for_each_pin() and for_each_ioapic_pin() to walk ioapics and pins. They will be rewritten e will rewrite later to support IOAPIC hotplug.
--- arch/x86/kernel/apic/io_apic.c | 120 +++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 58 deletions(-)
arch/x86/kernel/apic/io_apic.c +62 -58
@@ -62,6 +62,16 @@#define __apicdebuginit (type) static type __init +#define for_each_ioapic (idx) \ + for ((idx) = 0; (idx) < nr_ioapics; (idx)++) +#define for_each_ioapic_reverse (idx) \ + for ((idx) = nr_ioapics - 1; (idx) >= 0; (idx)--) +#define for_each_pin (idx, pin) \ + for ((pin) = 0; (pin) < ioapics[(idx)].nr_registers; (pin)++) +#define for_each_ioapic_pin (idx, pin) \ + for_each_ioapic((idx)) \ + for_each_pin((idx), (pin)) +#define for_each_irq_pin (entry, head) \ for (entry = head; entry; entry = entry->next)
@@ -191,7 +201,7 @@ int __init arch_early_irq_init(void)if (!legacy_pic->nr_legacy_irqs) io_apic_irqs = ~0UL ; -for (i =0 ; i < nr_ioapics; i++) { +for_each_ioapic (i) { ioapics[i].saved_registers =kzalloc (sizeof (struct IO_APIC_route_entry ) * ioapics[i].nr_registers,GFP_KERNEL );
@@ -624,9 +634,8 @@ static void clear_IO_APIC (void) {int apic, pin; -for (apic =0 ; apic < nr_ioapics; apic++) -for (pin =0 ; pin < ioapics[apic].nr_registers; pin++) -clear_IO_APIC_pin (apic, pin); +for_each_ioapic_pin (apic, pin) +clear_IO_APIC_pin (apic, pin); }#ifdef CONFIG_X86_32
@@ -675,13 +684,13 @@ int save_ioapic_entries(void)int apic, pin;int err =0 ; -for (apic =0 ; apic < nr_ioapics; apic++) { +for_each_ioapic (apic) {if (!ioapics[apic].saved_registers) { err = -ENOMEM ;continue ; } -for (pin =0 ; pin < ioapics[apic].nr_registers; pin++) +for_each_pin (apic, pin) ioapics[apic].saved_registers[pin] =ioapic_read_entry (apic, pin); }
@@ -696,11 +705,11 @@ void mask_ioapic_entries(void) {int apic, pin; -for (apic =0 ; apic < nr_ioapics; apic++) { +for_each_ioapic (apic) {if (!ioapics[apic].saved_registers)continue ; -for (pin =0 ; pin < ioapics[apic].nr_registers; pin++) { +for_each_pin (apic, pin) {struct IO_APIC_route_entry entry; entry = ioapics[apic].saved_registers[pin];
@@ -719,11 +728,11 @@ int restore_ioapic_entries(void) {int apic, pin; -for (apic =0 ; apic < nr_ioapics; apic++) { +for_each_ioapic (apic) {if (!ioapics[apic].saved_registers)continue ; -for (pin =0 ; pin < ioapics[apic].nr_registers; pin++) +for_each_pin (apic, pin)ioapic_write_entry (apic, pin, ioapics[apic].saved_registers[pin]); }
@@ -782,7 +791,7 @@ static int __init find_isa_irq_apic(int irq, int type)if (i < mp_irq_entries) {int ioapic_idx; -for (ioapic_idx =0 ; ioapic_idx < nr_ioapics; ioapic_idx++) +for_each_ioapic (ioapic_idx)if (mpc_ioapic_id (ioapic_idx) == mp_irqs[i].dstapic)return ioapic_idx; }
@@ -1001,7 +1010,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,for (i =0 ; i < mp_irq_entries; i++) {int lbus = mp_irqs[i].srcbus; -for (ioapic_idx =0 ; ioapic_idx < nr_ioapics; ioapic_idx++) +for_each_ioapic (ioapic_idx)if (mpc_ioapic_id (ioapic_idx) == mp_irqs[i].dstapic || mp_irqs[i].dstapic ==MP_APIC_ALL )break ;
@@ -1224,12 +1233,10 @@ static inline int IO_APIC_irq_trigger(int irq) {int apic, idx, pin; -for (apic =0 ; apic < nr_ioapics; apic++) { -for (pin =0 ; pin < ioapics[apic].nr_registers; pin++) { - idx =find_irq_entry (apic, pin, mp_INT); -if ((idx !=-1 ) && (irq ==pin_2_irq (idx, apic, pin))) -return irq_trigger (idx); - } +for_each_ioapic_pin (apic, pin) { + idx =find_irq_entry (apic, pin, mp_INT); +if ((idx !=-1 ) && (irq ==pin_2_irq (idx, apic, pin))) +return irq_trigger (idx); }/* * nonexistent IRQs are edge default
@@ -1349,7 +1356,7 @@ static void __init __io_apic_setup_irqs(unsigned int ioapic_idx)struct io_apic_irq_attr attr;unsigned int pin, irq; -for (pin =0 ; pin < ioapics[ioapic_idx].nr_registers; pin++) { +for_each_pin (ioapic_idx, pin) { idx =find_irq_entry (ioapic_idx, pin, mp_INT);if (io_apic_pin_not_connected (idx, ioapic_idx, pin))continue ;
@@ -1380,7 +1387,7 @@ static void __init setup_IO_APIC_irqs(void)apic_printk (APIC_VERBOSE ,KERN_DEBUG "init IO_APIC IRQs\n" ); -for (ioapic_idx =0 ; ioapic_idx < nr_ioapics; ioapic_idx++) +for_each_ioapic (ioapic_idx)__io_apic_setup_irqs (ioapic_idx); }
@@ -1583,7 +1590,7 @@ __apicdebuginit(void) print_IO_APICs(void)struct irq_chip *chip;printk (KERN_DEBUG "number of MP IRQ sources: %d.\n" , mp_irq_entries); -for (ioapic_idx =0 ; ioapic_idx < nr_ioapics; ioapic_idx++) +for_each_ioapic (ioapic_idx)printk (KERN_DEBUG "number of IO-APIC #%d registers: %d.\n" ,mpc_ioapic_id (ioapic_idx), ioapics[ioapic_idx].nr_registers);
@@ -1594,7 +1601,7 @@ __apicdebuginit(void) print_IO_APICs(void)*/ printk (KERN_INFO "testing the IO APIC.......................\n" ); -for (ioapic_idx =0 ; ioapic_idx < nr_ioapics; ioapic_idx++) +for_each_ioapic (ioapic_idx)print_IO_APIC (ioapic_idx);printk (KERN_DEBUG "IRQ to pin mappings:\n" );
@@ -1825,26 +1832,22 @@ static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };void __init enable_IO_APIC (void ) {int i8259_apic, i8259_pin; -int apic; +int apic, pin;if (!legacy_pic->nr_legacy_irqs)return ; -for (apic =0 ; apic < nr_ioapics; apic++) { -int pin; +for_each_ioapic_pin (apic, pin) {/* See if any of the pins is in ExtINT mode */ -for (pin =0 ; pin < ioapics[apic].nr_registers; pin++) { -struct IO_APIC_route_entry entry; - entry =ioapic_read_entry (apic, pin); +struct IO_APIC_route_entry entry =ioapic_read_entry (apic, pin); -/* If the interrupt line is enabled and in ExtInt mode -* I have found the pin where the i8259 is connected. -*/ -if ((entry.mask ==0 ) && (entry.delivery_mode == dest_ExtINT)) { - ioapic_i8259.apic = apic; - ioapic_i8259.pin = pin; - goto found_i8259; - } +/* If the interrupt line is enabled and in ExtInt mode +* I have found the pin where the i8259 is connected. +*/ +if ((entry.mask ==0 ) && (entry.delivery_mode == dest_ExtINT)) { + ioapic_i8259.apic = apic; + ioapic_i8259.pin = pin; + goto found_i8259; } } found_i8259:
@@ -1947,7 +1950,7 @@ void __init setup_ioapic_ids_from_mpc_nocheck(void)/* * Set the IOAPIC ID to the value stored in the MPC table. */ -for (ioapic_idx =0 ; ioapic_idx < nr_ioapics; ioapic_idx++) { +for_each_ioapic (ioapic_idx) {/* Read the register 0 value */ raw_spin_lock_irqsave (&ioapic_lock, flags); reg_00.raw =io_apic_read (ioapic_idx,0 );
@@ -2874,7 +2877,7 @@ static void ioapic_resume(void) {int ioapic_idx; -for (ioapic_idx = nr_ioapics -1 ; ioapic_idx >=0 ; ioapic_idx--) +for_each_ioapic_reverse (ioapic_idx)resume_ioapic_id (ioapic_idx);restore_ioapic_entries ();
@@ -3464,9 +3467,8 @@ static u8 __init io_apic_unique_id(u8 id)DECLARE_BITMAP (used,256 );bitmap_zero (used,256 ); -for (i =0 ; i < nr_ioapics; i++) { +for_each_ioapic (i)__set_bit (mpc_ioapic_id (i), used); - }if (!test_bit (id, used))return id;return find_first_zero_bit (used,256 );
@@ -3524,8 +3526,7 @@ void __init setup_ioapic_dest(void)if (skip_ioapic_setup ==1 )return ; -for (ioapic =0 ; ioapic < nr_ioapics; ioapic++) -for (pin =0 ; pin < ioapics[ioapic].nr_registers; pin++) { +for_each_ioapic_pin (ioapic, pin) { irq_entry =find_irq_entry (ioapic, pin, mp_INT);if (irq_entry ==-1 )continue ;
@@ -3554,29 +3555,33 @@ void __init setup_ioapic_dest(void)static struct resource *ioapic_resources; -static struct resource *__init ioapic_setup_resources (int nr_ioapics) +static struct resource *__init ioapic_setup_resources (void ) {unsigned long n;struct resource *res;char *mem; -int i; +int i, num =0 ; -if (nr_ioapics <=0 ) +for_each_ioapic (i) + num++; +if (num ==0 )return NULL ; n =IOAPIC_RESOURCE_NAME_SIZE +sizeof (struct resource ); - n *= nr_ioapics; + n *= num; mem =alloc_bootmem (n); res = (void *)mem; - mem +=sizeof (struct resource ) * nr_ioapics; + mem +=sizeof (struct resource ) * num; -for (i =0 ; i < nr_ioapics; i++) { - res[i].name = mem; - res[i].flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + num =0 ; +for_each_ioapic (i) { + res[num].name = mem; + res[num].flags =IORESOURCE_MEM |IORESOURCE_BUSY ;snprintf (mem,IOAPIC_RESOURCE_NAME_SIZE ,"IOAPIC %u" , i); mem +=IOAPIC_RESOURCE_NAME_SIZE ; + num++; } ioapic_resources = res;
@@ -3590,8 +3595,8 @@ void __init native_io_apic_init_mappings(void)struct resource *ioapic_res;int i; - ioapic_res =ioapic_setup_resources (nr_ioapics); -for (i =0 ; i < nr_ioapics; i++) { + ioapic_res =ioapic_setup_resources (); +for_each_ioapic (i) {if (smp_found_config) { ioapic_phys =mpc_ioapic_addr (i);#ifdef CONFIG_X86_32
@@ -3636,7 +3641,7 @@ void __init ioapic_insert_resources(void)return ; } -for (i =0 ; i < nr_ioapics; i++) { +for_each_ioapic (i) {insert_resource (&iomem_resource, r); r++; }
@@ -3644,16 +3649,15 @@ void __init ioapic_insert_resources(void)int mp_find_ioapic (u32 gsi) { -int i =0 ; +int i;if (nr_ioapics ==0 )return -1 ;/* Find the IOAPIC that manages this GSI. */ -for (i =0 ; i < nr_ioapics; i++) { +for_each_ioapic (i) {struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (i); -if ((gsi >= gsi_cfg->gsi_base) - && (gsi <= gsi_cfg->gsi_end)) +if (gsi >= gsi_cfg->gsi_base && gsi <= gsi_cfg->gsi_end)return i; }
@@ -3665,7 +3669,7 @@ int mp_find_ioapic_pin(int ioapic, u32 gsi) {struct mp_ioapic_gsi *gsi_cfg; -if (WARN_ON (ioapic ==-1 )) +if (WARN_ON (ioapic <0 ))return -1 ; gsi_cfg =mp_ioapic_gsi_routing (ioapic);
Signature · 1 line
1.7.10.4
PATCH v3 14/37 x86, ioapic: use irq_cfg() instead of irq_get_chip_data() for better readability
In reply to Jiang LiuUse defined helper function irq_cfg() instead of irq_get_chip_data() for better readability.
--- arch/x86/kernel/apic/io_apic.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/x86/kernel/apic/io_apic.c +10 -10
@@ -230,7 +230,7 @@ int __init arch_early_irq_init(void)return 0 ; } -static struct irq_cfg *irq_cfg (unsigned int irq) +static inline struct irq_cfg *irq_cfg (unsigned int irq) {return irq_get_chip_data (irq); }
@@ -272,7 +272,7 @@ static struct irq_cfg *alloc_irq_and_cfg_at(unsigned int at, int node)if (res <0 ) {if (res != -EEXIST )return NULL ; - cfg =irq_get_chip_data (at); + cfg =irq_cfg (at);if (cfg)return cfg; }
@@ -1204,7 +1204,7 @@ void __setup_vector_irq(int cpu)raw_spin_lock (&vector_lock);/* Mark the inuse vectors */ for_each_active_irq (irq) { - cfg =irq_get_chip_data (irq); + cfg =irq_cfg (irq);if (!cfg)continue ;
@@ -1612,7 +1612,7 @@ __apicdebuginit(void) print_IO_APICs(void)if (chip != &ioapic_chip)continue ; - cfg =irq_get_chip_data (irq); + cfg =irq_cfg (irq);if (!cfg)continue ; entry = cfg->irq_2_pin;
@@ -2253,7 +2253,7 @@ static void irq_complete_move(struct irq_cfg *cfg)void irq_force_complete_move (int irq) { -struct irq_cfg *cfg =irq_get_chip_data (irq); +struct irq_cfg *cfg =irq_cfg (irq);if (!cfg)return ;
@@ -2526,7 +2526,7 @@ static inline void init_IO_APIC_traps(void)* 0x80, because int 0x80 is hm, kind of importantish. ;) */ for_each_active_irq (irq) { - cfg =irq_get_chip_data (irq); + cfg =irq_cfg (irq);if (IO_APIC_IRQ (irq) && cfg && !cfg->vector) {/* * Hmm.. We don't have an entry for this,
@@ -2659,7 +2659,7 @@ early_param("disable_timer_pin_1", disable_timer_pin_setup);*/ static inline void __init check_timer (void ) { -struct irq_cfg *cfg =irq_get_chip_data (0 ); +struct irq_cfg *cfg =irq_cfg (0 );int node =cpu_to_node (0 );int apic1, pin1, apic2, pin2;unsigned long flags;
@@ -2923,7 +2923,7 @@ int arch_setup_hwirq(unsigned int irq, int node)void arch_teardown_hwirq (unsigned int irq) { -struct irq_cfg *cfg =irq_get_chip_data (irq); +struct irq_cfg *cfg =irq_cfg (irq);unsigned long flags;free_remapped_irq (irq);
@@ -3052,7 +3052,7 @@ int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,if (!irq_offset)write_msi_msg (irq, &msg); -setup_remapped_irq (irq,irq_get_chip_data (irq), chip); +setup_remapped_irq (irq,irq_cfg (irq), chip);irq_set_chip_and_handler_name (irq, chip, handle_edge_irq,"edge" );
@@ -3187,7 +3187,7 @@ int default_setup_hpet_msi(unsigned int irq, unsigned int id)hpet_msi_write (irq_get_handler_data (irq), &msg);irq_set_status_flags (irq,IRQ_MOVE_PCNTXT ); -setup_remapped_irq (irq,irq_get_chip_data (irq), chip); +setup_remapped_irq (irq,irq_cfg (irq), chip);irq_set_chip_and_handler_name (irq, chip, handle_edge_irq,"edge" );return 0 ;
Signature · 1 line
1.7.10.4
PATCH v3 15/37 x86, irq: reorganize IO_APIC_get_PCI_irq_vector() to prepare for irqdomain
In reply to Jiang LiuReorganize function IO_APIC_get_PCI_irq_vector() a bit to better support coming irqdomain.
--- arch/x86/kernel/apic/io_apic.c | 61 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 28 deletions(-)
arch/x86/kernel/apic/io_apic.c +33 -28
@@ -997,7 +997,7 @@ static int pin_2_irq(int idx, int apic, int pin)int IO_APIC_get_PCI_irq_vector (int bus,int slot,int pin,struct io_apic_irq_attr *irq_attr) { -int ioapic_idx, i, best_guess =-1 ; +int irq, i, best_guess =-1 ; apic_printk(APIC_DEBUG, "querying PCI -> IRQ mapping bus:%d, slot:%d, pin:%d.\n",
@@ -1007,41 +1007,46 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin, "PCI BIOS passed nonexistent PCI bus %d!\n", bus);return -1 ; } +for (i =0 ; i < mp_irq_entries; i++) {int lbus = mp_irqs[i].srcbus; +int ioapic_idx, found =0 ; + +if (bus != lbus || mp_irqs[i].irqtype != mp_INT || + slot != ((mp_irqs[i].srcbusirq >>2 ) &0x1f )) +continue ;for_each_ioapic (ioapic_idx)if (mpc_ioapic_id (ioapic_idx) == mp_irqs[i].dstapic || - mp_irqs[i].dstapic ==MP_APIC_ALL ) + mp_irqs[i].dstapic ==MP_APIC_ALL ) { + found =1 ;break ; + } +if (!found) +continue ; -if (!test_bit (lbus, mp_bus_not_pci) && - mp_irqs[i].irqtype == mp_INT && - (bus == lbus) && - (slot == ((mp_irqs[i].srcbusirq >>2 ) &0x1f ))) { -int irq =pin_2_irq (i, ioapic_idx, mp_irqs[i].dstirq); - -if (!(ioapic_idx ||IO_APIC_IRQ (irq))) -continue ; +/* Skip ISA IRQs */ + irq =pin_2_irq (i, ioapic_idx, mp_irqs[i].dstirq); +if (ioapic_idx ==0 && !IO_APIC_IRQ (irq)) +continue ; -if (pin == (mp_irqs[i].srcbusirq &3 )) { -set_io_apic_irq_attr (irq_attr, ioapic_idx, - mp_irqs[i].dstirq, -irq_trigger (i), -irq_polarity (i)); -return irq; - } -/* -* Use the first all-but-pin matching entry as a -* best-guess fuzzy result for broken mptables. -*/ -if (best_guess <0 ) { -set_io_apic_irq_attr (irq_attr, ioapic_idx, - mp_irqs[i].dstirq, -irq_trigger (i), -irq_polarity (i)); - best_guess = irq; - } +if (pin == (mp_irqs[i].srcbusirq &3 )) { +set_io_apic_irq_attr (irq_attr, ioapic_idx, + mp_irqs[i].dstirq, +irq_trigger (i), +irq_polarity (i)); +return irq; + } +/* +* Use the first all-but-pin matching entry as a +* best-guess fuzzy result for broken mptables. +*/ +if (best_guess <0 ) { +set_io_apic_irq_attr (irq_attr, ioapic_idx, + mp_irqs[i].dstirq, +irq_trigger (i), +irq_polarity (i)); + best_guess = irq; } }return best_guess;
Signature · 1 line
1.7.10.4
PATCH v3 16/37 x86, irq: introduce some helper utilities to improve readability
In reply to Jiang LiuIt also fixes an off by one bug in
if ((ioapic_idx > 0) && (irq > NR_IRQS_LEGACY)) It should be if ((ioapic_idx > 0) && (irq >= NR_IRQS_LEGACY))
--- arch/x86/include/asm/io_apic.h | 2 ++ arch/x86/kernel/apic/io_apic.c | 29 ++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-)
arch/x86/include/asm/io_apic.h +2 -0
@@ -171,6 +171,7 @@ extern u32 gsi_top;extern int mp_find_ioapic (u32 gsi);extern int mp_find_ioapic_pin (int ioapic,u32 gsi); +extern u32 mp_pin_to_gsi (int ioapic,int pin);extern void __init mp_register_ioapic (int id,u32 address,u32 gsi_base);extern void __init pre_init_apic_IRQ0 (void );
@@ -212,6 +213,7 @@ extern void io_apic_eoi(unsigned int apic, unsigned int vector);static inline void ioapic_insert_resources (void ) { }#define gsi_top (NR_IRQS_LEGACY)static inline int mp_find_ioapic (u32 gsi) {return 0 ; } +static inline u32 mp_pin_to_gsi (int ioapic,int pin) {return UINT_MAX ; }struct io_apic_irq_attr ; static inline int io_apic_set_pci_routing(struct device *dev, int irq,
arch/x86/kernel/apic/io_apic.c +22 -7
@@ -117,6 +117,24 @@ struct mp_ioapic_gsi *mp_ioapic_gsi_routing(int ioapic_idx)return &ioapics[ioapic_idx].gsi_config; } +static inline int mp_ioapic_pin_count (int ioapic) +{ +struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (ioapic); + +return gsi_cfg->gsi_end - gsi_cfg->gsi_base +1 ; +} + +u32 mp_pin_to_gsi (int ioapic,int pin) +{ +return mp_ioapic_gsi_routing (ioapic)->gsi_base + pin; +} + +/* Initialize all legacy IRQs and all pins on the first IOAPIC at boot */ +static inline int mp_init_irq_at_boot (int ioapic,int irq) +{ +return ioapic ==0 || (irq >=0 && irq <NR_IRQS_LEGACY ); +} +int nr_ioapics;/* The one past the highest gsi number used */
@@ -1367,8 +1385,7 @@ static void __init __io_apic_setup_irqs(unsigned int ioapic_idx)continue ; irq =pin_2_irq (idx, ioapic_idx, pin); - -if ((ioapic_idx >0 ) && (irq >NR_IRQS_LEGACY )) +if (!mp_init_irq_at_boot (ioapic_idx, irq))continue ;/*
@@ -1419,9 +1436,7 @@ void setup_IO_APIC_irq_extra(u32 gsi)return ; irq =pin_2_irq (idx, ioapic_idx, pin); - -/* Only handle the non legacy irqs on secondary ioapics */ -if (ioapic_idx ==0 || irq <NR_IRQS_LEGACY ) +if (mp_init_irq_at_boot (ioapic_idx, irq))return ; set_io_apic_irq_attr(&attr, ioapic_idx, pin, irq_trigger(idx),
@@ -3535,9 +3550,9 @@ void __init setup_ioapic_dest(void) irq_entry =find_irq_entry (ioapic, pin, mp_INT);if (irq_entry ==-1 )continue ; - irq =pin_2_irq (irq_entry, ioapic, pin); -if ((ioapic >0 ) && (irq >NR_IRQS_LEGACY )) + irq =pin_2_irq (irq_entry, ioapic, pin); +if (!mp_init_irq_at_boot (ioapic, irq))continue ; idata =irq_get_irq_data (irq);
Signature · 1 line
1.7.10.4
PATCH v3 17/37 x86, ACPI, irq: consolidate algorithm of mapping (ioapic, pin) to IRQ number
In reply to Jiang LiuCurrently ACPI and ioapic both implement algorithms to map (ioapic, pin) to IRQ number. So consolidate the common part into one place, which is also preparing for irqdomain support.
It introduces mp_map_gsi_to_irq(), which will be used to allocate IRQ number IOAPIC pins when irqdomain is enabled.
Also rename gsi_to_irq() to map_gsi_to_irq(), later we will introduce unmap_gsi_to_irq() when enabling IOAPIC hotplug.
--- arch/x86/include/asm/io_apic.h | 2 ++ arch/x86/kernel/acpi/boot.c | 47 +++++++++++++++++++--------------------- arch/x86/kernel/apic/io_apic.c | 27 +++++++++++++---------- 3 files changed, 39 insertions(+), 37 deletions(-)
arch/x86/include/asm/io_apic.h +2 -0
@@ -172,6 +172,7 @@ extern u32 gsi_top;extern int mp_find_ioapic (u32 gsi);extern int mp_find_ioapic_pin (int ioapic,u32 gsi);extern u32 mp_pin_to_gsi (int ioapic,int pin); +extern int mp_map_gsi_to_irq (u32 gsi);extern void __init mp_register_ioapic (int id,u32 address,u32 gsi_base);extern void __init pre_init_apic_IRQ0 (void );
@@ -214,6 +215,7 @@ static inline void ioapic_insert_resources(void) { }#define gsi_top (NR_IRQS_LEGACY)static inline int mp_find_ioapic (u32 gsi) {return 0 ; }static inline u32 mp_pin_to_gsi (int ioapic,int pin) {return UINT_MAX ; } +static inline int mp_map_gsi_to_irq (u32 gsi) {return gsi; }struct io_apic_irq_attr ; static inline int io_apic_set_pci_routing(struct device *dev, int irq,
arch/x86/kernel/acpi/boot.c +22 -25
95 lines not on this page · raw message
arch/x86/kernel/apic/io_apic.c +15 -12
@@ -963,11 +963,19 @@ static int irq_trigger(int idx)return trigger; } +int mp_map_gsi_to_irq (u32 gsi) +{ +/* +* Provide an identity mapping of gsi == irq except on truly weird +* platforms that have non isa irqs in the first 16 gsis. +*/ +return gsi >=NR_IRQS_LEGACY ? gsi : gsi_top + gsi; +} +static int pin_2_irq (int idx,int apic,int pin) {int irq;int bus = mp_irqs[idx].srcbus; -struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (apic);/* * Debugging check, we are in big trouble if this message pops up!
@@ -975,17 +983,6 @@ static int pin_2_irq(int idx, int apic, int pin)if (mp_irqs[idx].dstirq != pin)pr_err ("broken BIOS or MPTABLE parser, ayiee!!\n" ); -if (test_bit (bus, mp_bus_not_pci)) { - irq = mp_irqs[idx].srcbusirq; - }else { -u32 gsi = gsi_cfg->gsi_base + pin; - -if (gsi >=NR_IRQS_LEGACY ) - irq = gsi; -else - irq = gsi_top + gsi; - } -#ifdef CONFIG_X86_32 /* * PCI IRQ command line redirection. Yes, limits are hardcoded.
@@ -1000,11 +997,17 @@ static int pin_2_irq(int idx, int apic, int pin)apic_printk (APIC_VERBOSE ,KERN_DEBUG "using PIRQ%d -> IRQ %d\n" , pin-16 , irq); + return irq; } } }#endif +if (test_bit (bus, mp_bus_not_pci)) + irq = mp_irqs[idx].srcbusirq; +else + irq =mp_map_gsi_to_irq (mp_pin_to_gsi (apic, pin)); +return irq; }
Signature · 1 line
1.7.10.4
PATCH v3 18/37 x86, irq, ACPI: change __acpi_register_gsi to return IRQ number instead of GSI
In reply to Jiang LiuCurrently __acpi_register_gsi is defined to return GSI number and may be set to acpi_register_gsi_pic(), acpi_register_gsi_ioapic(), acpi_register_gsi_xen_hvm() and acpi_register_gsi_xen().
Among which, acpi_register_gsi_ioapic() returns GSI number, but acpi_register_gsi_xen_hvm() and acpi_register_gsi_xen() actually returns IRQ number instead of GSI. And for acpi_register_gsi_pic(), GSI number equals to IRQ number.
So change acpi_register_gsi_ioapic() to return IRQ number, it also simplifies the code.
--- arch/x86/kernel/acpi/boot.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
arch/x86/kernel/acpi/boot.c +8 -12
@@ -526,11 +526,13 @@ static int acpi_register_gsi_pic(struct device *dev, u32 gsi,static int acpi_register_gsi_ioapic (struct device *dev,u32 gsi,int trigger,int polarity) { +int irq = gsi; +#ifdef CONFIG_X86_IO_APIC - gsi =mp_register_gsi (dev, gsi, trigger, polarity); + irq =mp_register_gsi (dev, gsi, trigger, polarity);#endif -return gsi; +return irq; } int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
@@ -548,13 +550,7 @@ int (*acpi_suspend_lowlevel)(void);*/ int acpi_register_gsi (struct device *dev,u32 gsi,int trigger,int polarity) { -unsigned int plat_gsi; - - plat_gsi = (*__acpi_register_gsi)(dev, gsi, trigger, polarity); -if (plat_gsi !=ACPI_INVALID_GSI ) -return map_gsi_to_irq (plat_gsi); - -return -1 ; +return (*__acpi_register_gsi)(dev, gsi, trigger, polarity); }EXPORT_SYMBOL_GPL (acpi_register_gsi);
@@ -1036,7 +1032,7 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger, irq =map_gsi_to_irq (gsi);if (irq <0 ) -return ACPI_INVALID_GSI ; +return irq; ioapic =mp_find_ioapic (gsi);if (ioapic <0 ) {
@@ -1061,9 +1057,9 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger, polarity == ACPI_ACTIVE_HIGH ? 0 : 1); ret =io_apic_set_pci_routing (dev, irq, &irq_attr);if (ret <0 ) - gsi =ACPI_INVALID_GSI ; + irq =-1 ; -return gsi; +return irq; }/*
Signature · 1 line
1.7.10.4
PATCH v3 19/37 x86, irq: introduce mechanisms to support dynamically allocate IRQ for IOAPIC
In reply to Jiang LiuCurrently x86 support identity mapping between GSI(IOAPIC pin) and IRQ number, so continous IRQs at low end are statically allocated to IOAPICs at boot time. This design causes trouble to support IOAPIC hotplug.
This patch implements basic mechanism to dynamically allocate IRQ on demand for IOAPIC pins by using irqdomain framework.
It first adds several fields into struct ioapic to support irqdomain. Then it implements an algorithm to dynamically allocate IRQ number for IOAPIC pins on demand as below:
1) Legacy(ISA) IRQs is not managed by irqdomain because there may be multiple pins sharing the same IRQ number and current irqdomain only supports 1:1 mapping between pins and IRQ.
2) Build identity mapping for GSIs between NR_IRQS_LEGACY and arch_dynirq_lower_bound(0). This is typically used to support legacy IRQs and simple platforms.
3) Dynamically allocate IRQs for GSIs above arch_dynirq_lower_bound(0). This may be used to support big system and IOAPIC hotplug.
4) Dynamically allocate IRQs for non-ISA IRQs below NR_IRQS_LEGACY if platform doens't request identity mapping. This is to support some really weired platforms.
5) Build identity mapping for GSIs below NR_IRQS_LEGACY if platform requests identity mapping. This is to support MID and CE41000 etc.
Function arch_dynirq_lower_bound(0) will be enhanced in coming patch to enable dynamic IRQ allocation for IOAPIC. To ease our life, arch_dynirq_lower_bound(0) must be greater than or equal to NR_IRQS_LEGACY, otherwise it may break backward compatibilities.
--- arch/x86/Kconfig | 1 + arch/x86/include/asm/io_apic.h | 11 +++- arch/x86/kernel/acpi/boot.c | 8 +-- arch/x86/kernel/apic/io_apic.c | 142 ++++++++++++++++++++++++++++++---------- 4 files changed, 120 insertions(+), 42 deletions(-)
arch/x86/Kconfig +1 -0
@@ -832,6 +832,7 @@ config X86_IO_APIC def_bool y depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC || PCI_MSI select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ + select IRQ_DOMAIN config X86_REROUTE_FOR_BROKEN_BOOT_IRQS bool "Reroute for broken boot IRQs"
arch/x86/include/asm/io_apic.h +9 -2
@@ -98,6 +98,8 @@ struct IR_IO_APIC_route_entry {#define IOAPIC_AUTO -1#define IOAPIC_EDGE 0#define IOAPIC_LEVEL 1 +#define IOAPIC_MAP_ALLOC 0x1 +#define IOAPIC_MAP_CHECK 0x2#ifdef CONFIG_X86_IO_APIC
@@ -130,6 +132,9 @@ extern int noioapicquirk;/* -1 if "noapic" boot option passed */ extern int noioapicreroute; +/* Build identity mapping for non-ISA IRQs below NR_IRQS_LEGACY */ +extern int ioapic_identity_map; +/* * If we use the IO-APIC for IRQ routing, disable automatic * assignment of PCI IRQ's.
@@ -169,10 +174,12 @@ struct mp_ioapic_gsi{ };extern u32 gsi_top; +typedef struct irq_domain *(*ioapic_create_domain_fn )(int idx,void *arg); +extern int mp_find_ioapic (u32 gsi);extern int mp_find_ioapic_pin (int ioapic,u32 gsi);extern u32 mp_pin_to_gsi (int ioapic,int pin); -extern int mp_map_gsi_to_irq (u32 gsi); +extern int mp_map_gsi_to_irq (u32 gsi,unsigned int flags);extern void __init mp_register_ioapic (int id,u32 address,u32 gsi_base);extern void __init pre_init_apic_IRQ0 (void );
@@ -215,7 +222,7 @@ static inline void ioapic_insert_resources(void) { }#define gsi_top (NR_IRQS_LEGACY)static inline int mp_find_ioapic (u32 gsi) {return 0 ; }static inline u32 mp_pin_to_gsi (int ioapic,int pin) {return UINT_MAX ; } -static inline int mp_map_gsi_to_irq (u32 gsi) {return gsi; } +static inline int mp_map_gsi_to_irq (u32 gsi,unsigned int flags) {return gsi; }struct io_apic_irq_attr ; static inline int io_apic_set_pci_routing(struct device *dev, int irq,
arch/x86/kernel/acpi/boot.c +4 -4
@@ -99,7 +99,7 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {#define ACPI_INVALID_GSI INT_MIN -static int map_gsi_to_irq (unsigned int gsi) +static int map_gsi_to_irq (unsigned int gsi,unsigned int flags) {int i;
@@ -107,7 +107,7 @@ static int map_gsi_to_irq(unsigned int gsi)if (isa_irq_to_gsi[i] == gsi)return i; -return mp_map_gsi_to_irq (gsi); +return mp_map_gsi_to_irq (gsi, flags); }/*
@@ -483,7 +483,7 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)int acpi_gsi_to_irq (u32 gsi,unsigned int *irqp) { -int irq =map_gsi_to_irq (gsi); +int irq =map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC |IOAPIC_MAP_CHECK );if (irq >=0 ) {#ifdef CONFIG_X86_IO_APIC
@@ -1030,7 +1030,7 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,if (acpi_gbl_FADT.sci_interrupt == gsi)return gsi; - irq =map_gsi_to_irq (gsi); + irq =map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC );if (irq <0 )return irq;
arch/x86/kernel/apic/io_apic.c +106 -36
242 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [Patch V3 19/37] x86, irq: introduce mechanisms to support dynamically allocate IRQ for IOAPIC
Jiang,
Quoted 4 lines · Jiang Liu
arch/x86/kernel/apic/io_apic.c +3
-0+static int alloc_irq_from_domain (struct irq_domain *domain,u32 gsi,int pin) { +int irq =-1 ; +
arch/x86/kernel/apic/io_apic.c static int irq_trigger(int idx) · line 990
Quoted 10 lines
arch/x86/kernel/apic/io_apic.c +10
-0+if (gsi >=arch_dynirq_lower_bound (0 )) { + irq =irq_create_mapping (domain, pin); + }else if (gsi <NR_IRQS_LEGACY ) { +if (!ioapic_identity_map) + irq =irq_create_mapping (domain, pin); +else if (irq_domain_associate (domain, gsi, pin) ==0 ) + irq = gsi; + }else if (irq_create_strict_mappings (domain, gsi, pin,1 ) ==0 ) { + irq = gsi; + }
So you have these cases covered here:
1) The ACPI case of secondary ioapics. You only have the strict 1:1 mapping for the first ioapic
2) The gsi < NR_IRQS_LEGACY case where you have two options:
a) Let the core create a random virq number if ioapic_identity_map is 0
ioapic_identity_map is only set by SFI and devicetree
So in all other cases we fall into that code path for all legacy interrupts. So how is that supposed to work lets say for i8042 which has hardcoded irq 1 and 12?
irq_create_mapping(1)
hint = 1 % nr_irqs; --> 1
virq = irq_alloc_desc_from(hint, of_node_to_nid(domain->of_node));
This returns something >= 16, because the irq descriptors for 0-15 (LEGACY) are allocated already.
The pin association works, but how is the i8042 driver supposed to figure out that it should request the virq >=16 which was created instead of the hardcoded 1 ?
b) Associate the gsi and the pin
This only works because the virqs are already allocated at boot time unconditionally due to arch_probe_nr_irqs() returning NR_IRQS_LEGACY. So irq_domain_associate() works. Undocumented works by chance behaviour.
3) The case where gsi < arch_dynirq_lower_bound()
You create a strict mapping here, fine.
This is confusing at best.
First of all, we should use legacy_pic->nr_legacy_irqs instead of NR_IRQS_LEGACY all over the place.
mshyperv, ce4100 and intel-mid use the null_legacy_pic which has nr_legacy_irqs = 0 and everything else uses the real pic which has nr_legacy_irqs = NR_IRQS_LEGACY. So why do we even bother to allocate and deal with NR_IRQS_LEGACY in the cases where we have no legacy?
ce4100 is an oddball though. The ioapic is registered way before the interrupt subsystem is initialized and I have a hard time to understand that comment:
/* We can't set this earlier, because we need to calibrate the timer */
legacy_pic = &null_legacy_pic;The timer calibration happens after the interrupts are set up. I assume it's check_timer() which wants that, but we know exactly how the ce4100 works, so we might be able to avoid that whole "testing" stuff. Sebastian, any input on this?
If it turns out that ce4100 needs the inital real legacy pic for some magic reason we still can be clever by extending the legacy pic data structure to tell us about that change, i.e. instead of using legacy_pic->nr_legacy_irqs having a field "nr_allocated_irqs", which is set to NR_IRQS_LEGACY for the real pic and to 0 for the null_pic and let ce4100 set that field to NR_IRQS_LEGACY before switching the legacy_pic over to the null implementation.
But what's really disgusting is the magic ioapic_identity_map and the extra ACPI specific ioapic_dynirq_base hackery.
Why do we need strict mappings in the non ACPI case for all ioapic pins? What's so different about ACPI? Or is this just to avoid breaking the existing SFI/devicetree stuff. If that's the reason I'm fine with it, but ...
independent of this question we want to be more clever about the handling of strict, legacy and freely associated linux irq numbers.
So you have this weird ioapic_create_domain_fn callback in mp_register_ioapic, which is solely there so the different callers can hand in their domain ops and eventually set the magic ioapic_identity_map flag.
+void __init mp_register_ioapic(int id, u32 address, u32 gsi_base,
+ ioapic_create_domain_fn cb, void *arg)
What about having
struct ioapic_domain {
struct irqdomain *domain;
const struct irq_domain_ops *ops;
void *arg;
enum domain_type type;
};and add this struct to the ioapic struct. type is:
enum domain_type {
IOAPIC_STRICT,
IOAPIC_LEGACY,
IOAPIC_DYNAMIC,
};
Now the register function changes to:
void mp_register_ioapic(int id, u32 address, u32 gsi_base,
const struct irq_domain_ops *ops, int type)
{
...
ioapics[idx].irqdomain.ops = ops;
ioapics[idx].irqdomain.arg = arg;
ioapics[idx].irqdomain.type = type;
ioapics[idx].irqdomain.domain = NULL;
...
}and you can use mp_irqdomain_create() unconditionally for creating all domains. And there you do:
static int dynirq_lower_bound;
mp_irqdomain_create()
{
ioapic->irqdomain.domain = irq_domain_add_linear(...);
switch (ioapic->irqdomain.type) {
case IOAPIC_LEGACY:
/*
* Associate the legacy interrupts which have been
* already allocated.
*/
for (i = 0; i < legacy_pic->nr_allocated_irqs; i++)
irq_domain_associate(domain, i, i);
case IOAPIC_STRICT:
dynirq_lower_bound += ioapic->nr_gsis;
case IOAPIC_DYNAMIC:
break;
}
}So arch_dynirq_lower_bound() gets simplified to:
{
return dynirq_lower_bound;
}And alloc_irq_from_domain() becomes:
int alloc_irq_from_domain(struct ioapic_domain *domain, int gsi, int pin)
{
switch (domain->type) {
case IOAPIC_DYNAMIC:
return irq_create_mapping(domain->domain, pin);
case IOAPIC_LEGACY:
case IOAPIC_STRICT:
return irq_create_strict_mappings(domain, gsi, pin, 1);
}
}At the call site of alloc_irq_from_domain() you have already:
irq = irq_find_mapping(domain, pin);
if (irq <=0 ....)
alloc_irq_from_domain(domain, gsi, pin);So because we associated the legacy_pic->nr_allocated_irqs in mp_irqdomain_create() already, you'll never call into alloc_irq_from_domain() for those and the remaining ones for that first ioapic are handled by the IOAPIC_STRICT fall through.
For simplicity you can let SFI and devicetree register the ioapics with their specific domain ops plus IOAPIC_LEGACY for the first ioapic and IOAPIC_STRICT for all others. That also covers the case where the null_legacy_pic with legacy_pic->nr_allocated_irqs == 0 is used.
In the ACPI case you register with the acpi domain ops and IOAPIC_LEGACY for the first and IOAPIC_DYNAMIC for the extra ioapics.
Should be way cleaner and understandable, at least to me :)
Now there is that last oddity which bugs me in mp_map_pin_to_irq()
/*
* Don't use irqdomain to manage ISA IRQs because there may be
* multiple IOAPIC pins sharing the same ISA IRQ number and
* irqdomain only supports 1:1 mapping between IOAPIC pin and
* IRQ number.
*/
if (idx >= 0 && test_bit(mp_irqs[idx].srcbus, mp_bus_not_pci)) {
irq = mp_irqs[idx].srcbusirq;
if ((flags & IOAPIC_MAP_ALLOC) && info->count == 0 &&
mp_irqdomain_map(domain, irq, pin) != 0)
irq = -1;That really looks like a hack. I'm aware that the current irqdomain code cannot deal with that oddball case.
So what you are saying is that there are devices which have a separate physical wire to different ioapic pins, but the ioapic is supposed to bundle them to a shared interrupt.
I agree that this is odd enough to handle at the ioapic level, but it'd be nice to have a more elaborative comment on this.
Aside of the above I'm pretty happy about the progress of this patch set. One thing, which needs to be looked at are the usage sites of irq_data->irq, whether they are safe. I did not spot any unsafe ones, but a few functions which are called with irq_data->irq and make no use of it.
Thanks,
tglx
Re: [Patch V3 19/37] x86, irq: introduce mechanisms to support dynamically allocate IRQ for IOAPIC
Hi Thomas,
Thanks for your comments. Please refer to inline
comments below.
Quoted 40 lines · Thomas Gleixner
Jiang,
Quoted 4 lines · Jiang Liu
arch/x86/kernel/apic/io_apic.c +3
-0+static int alloc_irq_from_domain (struct irq_domain *domain,u32 gsi,int pin) { +int irq =-1 ; +arch/x86/kernel/apic/io_apic.c static int irq_trigger(int idx) · line 990
Quoted 10 lines
arch/x86/kernel/apic/io_apic.c +10
-0+if (gsi >=arch_dynirq_lower_bound (0 )) { + irq =irq_create_mapping (domain, pin); + }else if (gsi <NR_IRQS_LEGACY ) { +if (!ioapic_identity_map) + irq =irq_create_mapping (domain, pin); +else if (irq_domain_associate (domain, gsi, pin) ==0 ) + irq = gsi; + }else if (irq_create_strict_mappings (domain, gsi, pin,1 ) ==0 ) { + irq = gsi; + }So you have these cases covered here:
1) The ACPI case of secondary ioapics. You only have the strict 1:1 mapping for the first ioapic
2) The gsi <
NR_IRQS_LEGACYcase where you have two options:a) Let the core create a random virq number if
ioapic_identity_mapis 0
ioapic_identity_mapis only set by SFI and devicetreeSo in all other cases we fall into that code path for all legacy interrupts. So how is that supposed to work lets say for i8042 which has hardcoded irq 1 and 12?
irq_create_mapping(1)hint = 1 %
nr_irqs; --> 1
virq =irq_alloc_desc_from(hint, of_node_to_nid(domain->of_node));
Quoted 6 lines
This returns something >= 16, because the irq descriptors for 0-15 (LEGACY) are allocated already.
The pin association works, but how is the i8042 driver supposed to figure out that it should request the virq >=16 which was created instead of the hardcoded 1 ?
This is used to work around special non-ISA interrupts with GSI below NR_IRQS_LEGACY. The original code for the special case is:
/*
* Provide an identity mapping of gsi == irq except on truly
* weird platforms that have non isa irqs in the first 16 gsis. */
return gsi >= NR_IRQS_LEGACY ? gsi : gsi_top + gsi;
We have one path to handle ISA IRQs before calling alloc_irq_from_domain() as below:
if (idx >= 0 && test_bit(mp_irqs[idx].srcbus, mp_bus_not_pci))
return mp_irqs[idx].srcbusirq;Quoted 7 lines
b) Associate the gsi and the pin
This only works because the virqs are already allocated at boot time unconditionally due to
arch_probe_nr_irqs()returningNR_IRQS_LEGACY. Soirq_domain_associate()works. Undocumented works by chance behaviour.
Yes. It's a good suggestion to enhance legacy_pic to make this code more clear.
Quoted 7 lines
3) The case where gsi <
arch_dynirq_lower_bound()You create a strict mapping here, fine.
This is confusing at best.
Quoted 7 lines
First of all, we should use
legacy_pic->nr_legacy_irqsinstead ofNR_IRQS_LEGACYall over the place.mshyperv, ce4100 and intel-mid use the
null_legacy_picwhich hasnr_legacy_irqs= 0 and everything else uses the real pic which hasnr_legacy_irqs=NR_IRQS_LEGACY. So why do we even bother to allocate and deal withNR_IRQS_LEGACYin the cases where we have no legacy?
I'm not sure whether it works with ce4100, so used NR_IRQS_LEGACY instead of legacy_pic->nr_legacy_irqs for safety. Will try to refine it in next version.
Quoted 7 lines
ce4100 is an oddball though. The ioapic is registered way before the interrupt subsystem is initialized and I have a hard time to understand that comment:
/* We can't set this earlier, because we need to calibrate the timer */ legacy_pic = &null_legacy_pic;
I haven't figured out the story behind the comment yet:(
Quoted 6 lines
The timer calibration happens after the interrupts are set up. I assume it's
check_timer()which wants that, but we know exactly how the ce4100 works, so we might be able to avoid that whole "testing" stuff. Sebastian, any input on this?
Quoted 7 lines
If it turns out that ce4100 needs the inital real legacy pic for some magic reason we still can be clever by extending the legacy pic data structure to tell us about that change, i.e. instead of using
legacy_pic->nr_legacy_irqshaving a field "nr_allocated_irqs", which is set toNR_IRQS_LEGACYfor the real pic and to 0 for thenull_picand let ce4100 set that field toNR_IRQS_LEGACYbefore switching thelegacy_picover to the null implementation.
Good suggestion, will try this way.
Quoted 7 lines
But what's really disgusting is the magic
ioapic_identity_mapand the extra ACPI specificioapic_dynirq_basehackery.Why do we need strict mappings in the non ACPI case for all ioapic pins? What's so different about ACPI? Or is this just to avoid breaking the existing SFI/devicetree stuff. If that's the reason I'm fine with it, but ...
It's to avoid breaking SFI/intel_mid stuff. intel_mid assumes IRQ number equals to pin number and use pci_dev->irq to save both IRQ number and pin number.
Quoted 106 lines
independent of this question we want to be more clever about the handling of strict, legacy and freely associated linux irq numbers.
So you have this weird
ioapic_create_domain_fncallback inmp_register_ioapic, which is solely there so the different callers can hand in their domain ops and eventually set the magicioapic_identity_mapflag.(quoted diff) +2
-0+void __init mp_register_ioapic(int id, u32 address, u32 gsi_base, + ioapic_create_domain_fn cb, void *arg)What about having
struct ioapic_domain { struct irqdomain *domain; const struct irq_domain_ops *ops; void *arg; enum domain_type type; };and add this struct to the ioapic struct. type is:
enum
domain_type{
IOAPIC_STRICT,
IOAPIC_LEGACY,
IOAPIC_DYNAMIC,
};Now the register function changes to:
void mp_register_ioapic(int id, u32 address, u32
gsi_base,
const structirq_domain_ops*ops, int type){ ... ioapics[idx].irqdomain.ops = ops; ioapics[idx].irqdomain.arg = arg; ioapics[idx].irqdomain.type = type; ioapics[idx].irqdomain.domain = NULL; ... }and you can use
mp_irqdomain_create()unconditionally for creating all domains. And there you do:static int
dynirq_lower_bound;
mp_irqdomain_create(){ ioapic->irqdomain.domain = irq_domain_add_linear(...); switch (ioapic->irqdomain.type) { case IOAPIC_LEGACY: /* * Associate the legacy interrupts which have been * already allocated. */ for (i = 0; i < legacy_pic->nr_allocated_irqs; i++) irq_domain_associate(domain, i, i); case IOAPIC_STRICT: dynirq_lower_bound += ioapic->nr_gsis; case IOAPIC_DYNAMIC: break; } }So
arch_dynirq_lower_bound()gets simplified to:{ return dynirq_lower_bound; }And
alloc_irq_from_domain()becomes:int
alloc_irq_from_domain(struct ioapic_domain *domain, int gsi, int pin){ switch (domain->type) { case IOAPIC_DYNAMIC: return irq_create_mapping(domain->domain, pin); case IOAPIC_LEGACY: case IOAPIC_STRICT: return irq_create_strict_mappings(domain, gsi, pin, 1); } }At the call site of
alloc_irq_from_domain()you have already:irq = irq_find_mapping(domain, pin); if (irq <=0 ....) alloc_irq_from_domain(domain, gsi, pin);So because we associated the
legacy_pic->nr_allocated_irqsinmp_irqdomain_create()already, you'll never call intoalloc_irq_from_domain()for those and the remaining ones for that first ioapic are handled by theIOAPIC_STRICTfall through.For simplicity you can let SFI and devicetree register the ioapics with their specific domain ops plus
IOAPIC_LEGACYfor the first ioapic andIOAPIC_STRICTfor all others. That also covers the case where thenull_legacy_picwithlegacy_pic->nr_allocated_irqs== 0 is used.
Quoted 4 lines
In the ACPI case you register with the acpi domain ops and
IOAPIC_LEGACYfor the first andIOAPIC_DYNAMICfor the extra ioapics.Should be way cleaner and understandable, at least to me :)
Really good suggestions! Make thing much more clear.
Quoted 18 lines
Now there is that last oddity which bugs me in
mp_map_pin_to_irq()/*
* Don't use irqdomain to manage ISA IRQs because there may be
* multiple IOAPIC pins sharing the same ISA IRQ number and
* irqdomain only supports 1:1 mapping between IOAPIC pin and
* IRQ number.
*/if (idx >= 0 && test_bit(mp_irqs[idx].srcbus, mp_bus_not_pci)) { irq = mp_irqs[idx].srcbusirq; if ((flags & IOAPIC_MAP_ALLOC) && info->count == 0 && mp_irqdomain_map(domain, irq, pin) != 0) irq = -1;That really looks like a hack. I'm aware that the current irqdomain code cannot deal with that oddball case.
Quoted 6 lines
So what you are saying is that there are devices which have a separate physical wire to different ioapic pins, but the ioapic is supposed to bundle them to a shared interrupt.
I agree that this is odd enough to handle at the ioapic level, but it'd be nice to have a more elaborative comment on this.
Will try to improve the comment.
Quoted 6 lines
Aside of the above I'm pretty happy about the progress of this patch set. One thing, which needs to be looked at are the usage sites of
irq_data->irq, whether they are safe. I did not spot any unsafe ones, but a few functions which are called withirq_data->irqand make no use of it.
Sure, will check usages of irq_data->irq.
Really appreciate you suggestions, it will improve the code a lot. Thanks!
Gerry
Quoted 5 lines
Thanks,
tglx
Re: [Patch V3 19/37] x86, irq: introduce mechanisms to support dynamically allocate IRQ for IOAPIC
Quoted 28 lines · Jiang Liu
Quoted 21 lines · Thomas Gleixner
So you have these cases covered here:
1) The ACPI case of secondary ioapics. You only have the strict 1:1 mapping for the first ioapic
2) The gsi <
NR_IRQS_LEGACYcase where you have two options:a) Let the core create a random virq number if
ioapic_identity_mapis 0
ioapic_identity_mapis only set by SFI and devicetreeSo in all other cases we fall into that code path for all legacy interrupts. So how is that supposed to work lets say for i8042 which has hardcoded irq 1 and 12?
irq_create_mapping(1)hint = 1 %
nr_irqs; --> 1
virq =irq_alloc_desc_from(hint, of_node_to_nid(domain->of_node));Quoted 6 lines
This returns something >= 16, because the irq descriptors for 0-15 (LEGACY) are allocated already.
The pin association works, but how is the i8042 driver supposed to figure out that it should request the virq >=16 which was created instead of the hardcoded 1 ?
Quoted 7 lines
This is used to work around special non-ISA interrupts with GSI below
NR_IRQS_LEGACY. The original code for the special case is:
/*
* Provide an identity mapping of gsi == irq except on truly
* weird platforms that have non isa irqs in the first 16 gsis. */
return gsi >=NR_IRQS_LEGACY? gsi :gsi_top+ gsi;
That looks really, really wrong. What's wrong with assigning that irq irq number on those platforms?
The weird stuff is SFI and devicetree, if I understand your code correctly.
So if those platforms do not have actual legacy irqs, what's wrong with giving out the legacy numbers?
Quoted 4 lines
We have one path to handle ISA IRQs before calling
alloc_irq_from_domain()as below:if (idx >= 0 && test_bit(mp_irqs[idx].srcbus, mp_bus_not_pci)) return mp_irqs[idx].srcbusirq;
Ok.
Quoted 3 lines
Quoted 2 lines
/* We can't set this earlier, because we need to calibrate the timer */ legacy_pic = &null_legacy_pic;I haven't figured out the story behind the comment yet:(
Sebastian gave some insight.
Quoted 7 lines
Quoted 4 lines
Why do we need strict mappings in the non ACPI case for all ioapic pins? What's so different about ACPI? Or is this just to avoid breaking the existing SFI/devicetree stuff. If that's the reason I'm fine with it, but ...
It's to avoid breaking SFI/intel_mid stuff.
intel_midassumes IRQ number equals to pin number and usepci_dev->irqto save both IRQ number and pin number.
Fair enough.
Thanks,
tglx
Re: [Patch V3 19/37] x86, irq: introduce mechanisms to support dynamically allocate IRQ for IOAPIC
Quoted 9 lines · Thomas Gleixner
Quoted 7 lines · Jiang Liu
This is used to work around special non-ISA interrupts with GSI below
NR_IRQS_LEGACY. The original code for the special case is:
/*
* Provide an identity mapping of gsi == irq except on truly
* weird platforms that have non isa irqs in the first 16 gsis. */
return gsi >=NR_IRQS_LEGACY? gsi :gsi_top+ gsi;
Quoted 8 lines
That looks really, really wrong. What's wrong with assigning that irq irq number on those platforms?
The weird stuff is SFI and devicetree, if I understand your code correctly.
So if those platforms do not have actual legacy irqs, what's wrong with giving out the legacy numbers?
Though if it's a real issue, we can simply mark the ioapic on those devices as DYNAMIC and avoid that whole magic.
Thanks,
tglx
Re: [Patch V3 19/37] x86, irq: introduce mechanisms to support dynamically allocate IRQ for IOAPIC
In reply to Thomas GleixnerQuoted 11 lines · Thomas Gleixner
ce4100 is an oddball though. The ioapic is registered way before the interrupt subsystem is initialized and I have a hard time to understand that comment:
/* We can't set this earlier, because we need to calibrate the timer */ legacy_pic = &null_legacy_pic;The timer calibration happens after the interrupts are set up. I assume it's
check_timer()which wants that, but we know exactly how the ce4100 works, so we might be able to avoid that whole "testing" stuff. Sebastian, any input on this?
According to my memory there was some PIC init we need but I don't recall the details. However, booting the system with "legacy_pic = &null_legacy_pic;" in x86_ce4100_early_setup() gives me this:
[ 0.001000] Enabling APIC mode: Flat. Using 2 I/O APICs [ 0.001000] leaving PIC mode, enabling APIC mode. [ 0.001000] enabled ExtINT on CPU#0 [ 0.001000] ENABLING IO-APIC IRQs [ 0.001000] Setting 1 in the phys_id_present_map [ 0.001000] ...changing IO-APIC physical APIC ID to 1 ... ok. [ 0.001000] Setting 2 in the phys_id_present_map [ 0.001000] ...changing IO-APIC physical APIC ID to 2 ... ok. [ 0.001000] smpboot: CPU0: Intel(R) Atom(TM) CPU CE4150 @ 1.20GHz (fam: 06, model: 1c, stepping: 0a) [ 0.001000] Using local APIC timer interrupts. [ 0.001000] calibrating APIC timer ...
and we stand still. With the assignment as it is now:
[ 0.001000] Enabling APIC mode: Flat. Using 2 I/O APICs [ 0.001000] leaving PIC mode, enabling APIC mode. [ 0.001000] enabled ExtINT on CPU#0 [ 0.002312] ENABLING IO-APIC IRQs [ 0.003009] Setting 1 in the phys_id_present_map [ 0.004007] ...changing IO-APIC physical APIC ID to 1 ... ok. [ 0.005533] Setting 2 in the phys_id_present_map [ 0.006006] ...changing IO-APIC physical APIC ID to 2 ... ok. [ 0.008373] ..TIMER: vector=0x30 apic1=-1 pin1=-1 apic2=-1 pin2=-1 [ 0.009000] ...trying to set up timer as Virtual Wire IRQ... [ 0.019490] ..... works. [ 0.020005] smpboot: CPU0: Intel(R) Atom(TM) CPU CE4150 @ 1.20GHz (fam: 06, model: 1c, stepping: 0a) [ 0.024005] Using local APIC timer interrupts. [ 0.024005] calibrating APIC timer ... [ 0.026000] ... lapic delta = 624992 [ 0.026000] ... PM-Timer delta = 0 [ 0.026000] ..... delta 624992 [ 0.026000] ..... mult: 26843202 [ 0.026000] ..... calibration result: 99998 [ 0.026000] ..... CPU clock speed is 1199.0984 MHz. [ 0.026000] ..... host bus clock speed is 99.0998 MHz. [ 0.026000] ... verify APIC timer [ 0.128565] ... jiffies delta = 100 [ 0.129004] ... jiffies result ok
and it goes on. As you see, "..TIMER:" is missing in the upper output.
Quoted 4 lines
Thanks,
tglx
Sebastian
Re: [Patch V3 19/37] x86, irq: introduce mechanisms to support dynamically allocate IRQ for IOAPIC
Quoted 32 lines · Sebastian Andrzej Siewior
Quoted 11 lines · Thomas Gleixner
ce4100 is an oddball though. The ioapic is registered way before the interrupt subsystem is initialized and I have a hard time to understand that comment:
/* We can't set this earlier, because we need to calibrate the timer */ legacy_pic = &null_legacy_pic;The timer calibration happens after the interrupts are set up. I assume it's
check_timer()which wants that, but we know exactly how the ce4100 works, so we might be able to avoid that whole "testing" stuff. Sebastian, any input on this?According to my memory there was some PIC init we need but I don't recall the details. However, booting the system with "
legacy_pic=&null_legacy_pic;" inx86_ce4100_early_setup()gives me this:[ 0.001000] Enabling APIC mode: Flat. Using 2 I/O APICs [ 0.001000] leaving PIC mode, enabling APIC mode. [ 0.001000] enabled ExtINT on CPU#0 [ 0.001000] ENABLING IO-APIC IRQs [ 0.001000] Setting 1 in the phys_id_present_map [ 0.001000] ...changing IO-APIC physical APIC ID to 1 ... ok. [ 0.001000] Setting 2 in the phys_id_present_map [ 0.001000] ...changing IO-APIC physical APIC ID to 2 ... ok. [ 0.001000] smpboot: CPU0: Intel(R) Atom(TM) CPU CE4150 @ 1.20GHz (fam: 06, model: 1c, stepping: 0a) [ 0.001000] Using local APIC timer interrupts. [ 0.001000] calibrating APIC timer ...and we stand still. With the assignment as it is now:
Quoted 11 lines
[ 0.001000] Enabling APIC mode: Flat. Using 2 I/O APICs [ 0.001000] leaving PIC mode, enabling APIC mode. [ 0.001000] enabled ExtINT on CPU#0 [ 0.002312] ENABLING IO-APIC IRQs [ 0.003009] Setting 1 in the phys_id_present_map [ 0.004007] ...changing IO-APIC physical APIC ID to 1 ... ok. [ 0.005533] Setting 2 in the phys_id_present_map [ 0.006006] ...changing IO-APIC physical APIC ID to 2 ... ok. [ 0.008373] ..TIMER: vector=0x30 apic1=-1 pin1=-1 apic2=-1 pin2=-1 [ 0.009000] ...trying to set up timer as Virtual Wire IRQ... [ 0.019490] ..... works.
Right, so it needs the setup of irq 0 and that only happens when the legacy_pic->nr_legacy_irqs > 0.
Do you remember, why we switch to the null_pic later on?
Thanks,
tglx
Re: [Patch V3 19/37] x86, irq: introduce mechanisms to support dynamically allocate IRQ for IOAPIC
Quoted 5 lines · Thomas Gleixner
Right, so it needs the setup of irq 0 and that only happens when the
legacy_pic->nr_legacy_irqs> 0.Do you remember, why we switch to the
null_piclater on?
According to my memory all interrupts are serviced by the IOAPIC. The first 16 by the first IOAPIC, 17+ (everything behind the "PCI-bus") by the second IOAPIC. For that reason I didn't see a reason for the legacy PIC and set it to null_pic. Due to the timer problem it is delayed.
Quoted 3 lines
Thanks,
tglx
Sebastian
cover Deal with CE4100 and NR_IRQS_LEGACY
Based on the review comments, I have worked some patches to deal with CE4100 and NR_IRQS_LEGACY. Instead of sending out a big patchset, I just send these three patches for RFC to save the review efforts. They will be merge into the big patchset once we reach some agreement.
Jiang Liu (3):
ce4100, irq: make CE4100 depend on CONFIG_X86_IOAPIC ce4100, irq: do not set legacy_pic to null_legacy_pic x86, irq: count legacy IRQs by legacy_pic->nr_legacy_irqs instead of
NR_IRQS_LEGACY
arch/x86/Kconfig | 1 + arch/x86/include/asm/i8259.h | 2 ++ arch/x86/kernel/acpi/boot.c | 13 +++++------ arch/x86/kernel/apic/io_apic.c | 43 +++++++++++++++++++++---------------- arch/x86/kernel/devicetree.c | 12 +++++------ arch/x86/kernel/irqinit.c | 6 +++--- arch/x86/pci/xen.c | 6 +++--- arch/x86/platform/ce4100/ce4100.c | 11 ++-------- 8 files changed, 49 insertions(+), 45 deletions(-)
Signature · 1 line
1.7.10.4
RFC PATCH 1/3 ce4100, irq: make CE4100 depend on CONFIG_X86_IOAPIC
Intel CE4100 platforms need IOAPIC support becasue some devices are always connected to the second IOAPIC.
--- arch/x86/Kconfig | 1 + arch/x86/platform/ce4100/ce4100.c | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-)
arch/x86/Kconfig +1 -0
@@ -426,6 +426,7 @@ config X86_INTEL_CE bool "CE4100 TV platform" depends on PCI depends on PCI_GODIRECT + depends on X86_IO_APIC depends on X86_32 depends on X86_EXTENDED_PLATFORM select X86_REBOOTFIXUPS
arch/x86/platform/ce4100/ce4100.c +2 -7
@@ -135,14 +135,12 @@ static void __init sdv_arch_setup(void)sdv_serial_fixup (); } -#ifdef CONFIG_X86_IO_APIC static void sdv_pci_init (void ) {x86_of_pci_init ();/* We can't set this earlier, because we need to calibrate the timer */ legacy_pic = &null_legacy_pic; } -#endif /* * CE4100 specific x86_init function overrides and early setup
@@ -155,7 +153,9 @@ void __init x86_ce4100_early_setup(void) x86_init.resources.probe_roms = x86_init_noop; x86_init.mpparse.get_smp_config = x86_init_uint_noop; x86_init.mpparse.find_smp_config = x86_init_noop; + x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc_nocheck; x86_init.pci.init = ce4100_pci_init; + x86_init.pci.init_irq = sdv_pci_init;/* * By default, the reboot method is ACPI which is supported by the
@@ -166,10 +166,5 @@ void __init x86_ce4100_early_setup(void)*/ reboot_type =BOOT_KBD ; -#ifdef CONFIG_X86_IO_APIC - x86_init.pci.init_irq = sdv_pci_init; - x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc_nocheck; -#endif - pm_power_off = ce4100_power_off; }
Signature · 1 line
1.7.10.4
RFC PATCH 2/3 ce4100, irq: do not set legacy_pic to null_legacy_pic
In reply to Jiang LiuIntel CE4100 platforms has i8259 legacy interrupt controllers, so don't set legacy_pic to null_legacy_pic in late booting stage because we need legacy_pic to mask i8259 pins when enabling IOAPIC pins for safety.
--- arch/x86/platform/ce4100/ce4100.c | 2 -- 1 file changed, 2 deletions(-)
arch/x86/platform/ce4100/ce4100.c +0 -2
@@ -138,8 +138,6 @@ static void __init sdv_arch_setup(void)static void sdv_pci_init (void ) {x86_of_pci_init (); -/* We can't set this earlier, because we need to calibrate the timer */ - legacy_pic = &null_legacy_pic; }/*
Signature · 1 line
1.7.10.4
RFC PATCH 3/3 x86, irq: count legacy IRQs by legacy_pic->nr_legacy_irqs instead of NR_IRQS_LEGACY
In reply to Jiang LiuSome platforms, such as Intel MID and mshypv, do not support legacy interrupt controllers. So count legacy IRQs by legacy_pic->nr_legacy_irqs instead of hard-coded NR_IRQS_LEGACY.
--- arch/x86/include/asm/i8259.h | 2 ++ arch/x86/kernel/acpi/boot.c | 13 ++++++------ arch/x86/kernel/apic/io_apic.c | 43 +++++++++++++++++++++++----------------- arch/x86/kernel/devicetree.c | 12 +++++------ arch/x86/kernel/irqinit.c | 6 +++--- arch/x86/pci/xen.c | 6 +++--- 6 files changed, 46 insertions(+), 36 deletions(-)
arch/x86/include/asm/i8259.h +2 -0
@@ -67,4 +67,6 @@ struct legacy_pic {extern struct legacy_pic *legacy_pic;extern struct legacy_pic null_legacy_pic; +#define nr_legacy_irqs () (legacy_pic->nr_legacy_irqs) +#endif /* _ASM_X86_I8259_H */
arch/x86/kernel/acpi/boot.c +7 -6
@@ -43,6 +43,7 @@#include <asm/io.h> #include <asm/mpspec.h> #include <asm/smp.h> +#include <asm/i8259.h> #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */ static int __initdata acpi_force =0 ;
@@ -101,10 +102,10 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {static unsigned int gsi_to_irq (unsigned int gsi) { -unsigned int irq = gsi +NR_IRQS_LEGACY ; +unsigned int irq = gsi +nr_legacy_irqs ();unsigned int i; -for (i =0 ; i <NR_IRQS_LEGACY ; i++) { +for (i =0 ; i <nr_legacy_irqs (); i++) {if (isa_irq_to_gsi[i] == gsi) {return i; }
@@ -114,7 +115,7 @@ static unsigned int gsi_to_irq(unsigned int gsi)* except on truly weird platforms that have * non isa irqs in the first 16 gsis. */ -if (gsi >=NR_IRQS_LEGACY ) +if (gsi >=nr_legacy_irqs ()) irq = gsi;else irq = gsi_top + gsi;
@@ -371,7 +372,7 @@ static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,* otherwise there will be more than one entry with the same GSI * and acpi_isa_irq_to_gsi() may give wrong result. */ -if (gsi <NR_IRQS_LEGACY && isa_irq_to_gsi[gsi] == gsi) +if (gsi <nr_legacy_irqs () && isa_irq_to_gsi[gsi] == gsi) isa_irq_to_gsi[gsi] =ACPI_INVALID_GSI ; isa_irq_to_gsi[bus_irq] = gsi; }
@@ -628,7 +629,7 @@ EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);int acpi_isa_irq_to_gsi (unsigned isa_irq,u32 *gsi) { -if (isa_irq <NR_IRQS_LEGACY && +if (isa_irq <nr_legacy_irqs () && isa_irq_to_gsi[isa_irq] !=ACPI_INVALID_GSI ) { *gsi = isa_irq_to_gsi[isa_irq];return 0 ;
@@ -1017,7 +1018,7 @@ static void __init mp_config_acpi_legacy_irqs(void)* Use the default configuration for the IRQs 0-15. Unless * overridden by (MADT) interrupt source override entries. */ -for (i =0 ; i <NR_IRQS_LEGACY ; i++) { +for (i =0 ; i <nr_legacy_irqs (); i++) {int ioapic, pin;unsigned int dstapic;int idx;
arch/x86/kernel/apic/io_apic.c +25 -18
143 lines not on this page · raw message
arch/x86/kernel/devicetree.c +6 -6
@@ -316,7 +316,7 @@ static void dt_add_ioapic_domain(unsigned int ioapic_num,struct irq_domain *id;struct mp_ioapic_gsi *gsi_cfg;int ret; -int num; +int num, legacy_irqs =nr_legacy_irqs (); gsi_cfg =mp_ioapic_gsi_routing (ioapic_num); num = gsi_cfg->gsi_end - gsi_cfg->gsi_base +1 ;
@@ -326,17 +326,17 @@ static void dt_add_ioapic_domain(unsigned int ioapic_num,BUG_ON (!id);if (gsi_cfg->gsi_base ==0 ) {/* -* The first NR_IRQS_LEGACY irq descs are allocated in +* The first nr_legacy_irqs() irq descs are allocated in * early_irq_init() and need just a mapping. The * remaining irqs need both. All of them are preallocated * and assigned so we can keep the 1:1 mapping which the ioapic * is having. */ -irq_domain_associate_many (id,0 ,0 ,NR_IRQS_LEGACY ); +irq_domain_associate_many (id,0 ,0 , legacy_irqs); -if (num >NR_IRQS_LEGACY ) { - ret =irq_create_strict_mappings (id,NR_IRQS_LEGACY , -NR_IRQS_LEGACY , num -NR_IRQS_LEGACY ); +if (num > legacy_irqs) { + ret =irq_create_strict_mappings (id, legacy_irqs, + legacy_irqs, num - legacy_irqs);if (ret)pr_err ("Error creating mapping for the " "remaining IRQs: %d\n" , ret);
arch/x86/kernel/irqinit.c +3 -3
@@ -78,7 +78,7 @@ void __init init_ISA_irqs(void)#endif legacy_pic->init (0 ); -for (i =0 ; i < legacy_pic->nr_legacy_irqs; i++) +for (i =0 ; i <nr_legacy_irqs (); i++)irq_set_chip_and_handler_name (i, chip, handle_level_irq, name); }
@@ -100,7 +100,7 @@ void __init init_IRQ(void)* then this vector space can be freed and re-used dynamically as the * irq's migrate etc. */ -for (i =0 ; i < legacy_pic->nr_legacy_irqs; i++) +for (i =0 ; i <nr_legacy_irqs (); i++)per_cpu (vector_irq,0 )[IRQ0_VECTOR + i] = i; x86_init.irqs.intr_init ();
@@ -121,7 +121,7 @@ void setup_vector_irq(int cpu)* legacy PIC, for the new cpu that is coming online, setup the static * legacy vector to irq mapping: */ -for (irq =0 ; irq < legacy_pic->nr_legacy_irqs; irq++) +for (irq =0 ; irq <nr_legacy_irqs (); irq++)per_cpu (vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;#endif
arch/x86/pci/xen.c +3 -3
@@ -40,7 +40,7 @@ static int xen_pcifront_enable_irq(struct pci_dev *dev)/* In PV DomU the Xen PCI backend puts the PIRQ in the interrupt line.*/ pirq = gsi; -if (gsi <NR_IRQS_LEGACY ) +if (gsi <nr_legacy_irqs ()) share =0 ; rc =xen_bind_pirq_gsi_to_irq (gsi, pirq, share,"pcifront" );
@@ -511,7 +511,7 @@ int __init pci_xen_initial_domain(void)xen_setup_acpi_sci (); __acpi_register_gsi = acpi_register_gsi_xen;/* Pre-allocate legacy irqs */ -for (irq =0 ; irq <NR_IRQS_LEGACY ; irq++) { +for (irq =0 ; irq <nr_legacy_irqs (); irq++) {int trigger, polarity;if (acpi_get_override_irq (irq, &trigger, &polarity) ==-1 )
@@ -522,7 +522,7 @@ int __init pci_xen_initial_domain(void) true /* Map GSI to PIRQ */); }if (0 == nr_ioapics) { -for (irq =0 ; irq <NR_IRQS_LEGACY ; irq++) +for (irq =0 ; irq <nr_legacy_irqs (); irq++)xen_bind_pirq_gsi_to_irq (irq, irq,0 ,"xt-pic" ); }return 0 ;
Signature · 1 line
1.7.10.4
Re: [RFC Patch 3/3] x86, irq: count legacy IRQs by legacy_pic->nr_legacy_irqs instead of NR_IRQS_LEGACY
Quoted 3 lines · Jiang Liu
Some platforms, such as Intel MID and mshypv, do not support legacy interrupt controllers. So count legacy IRQs by
legacy_pic->nr_legacy_irqsinstead of hard-codedNR_IRQS_LEGACY.
Nice patch set!
Quoted 15 lines
Signed-off-by Jiang Liu <[email protected]>--- arch/x86/include/asm/i8259.h | 2 ++ arch/x86/kernel/acpi/boot.c | 13 ++++++------ arch/x86/kernel/apic/io_apic.c | 43 +++++++++++++++++++++++----------------- arch/x86/kernel/devicetree.c | 12 +++++------ arch/x86/kernel/irqinit.c | 6 +++--- arch/x86/pci/xen.c | 6 +++--- 6 files changed, 46 insertions(+), 36 deletions(-)arch/x86/include/asm/i8259.h +0
-0
arch/x86/include/asm/i8259.h struct legacy_pic { · line 70
Quoted 4 lines
arch/x86/include/asm/i8259.h +1
-0@@ -67,4 +67,6 @@ struct legacy_pic {extern struct legacy_pic *legacy_pic;extern struct legacy_pic null_legacy_pic; +#define nr_legacy_irqs () (legacy_pic->nr_legacy_irqs)
That wants to be a static inline, please.
Thanks,
tglx
Re: [RFC Patch 3/3] x86, irq: count legacy IRQs by legacy_pic->nr_legacy_irqs instead of NR_IRQS_LEGACY
In reply to Jiang LiuQuoted 3 lines · Jiang Liu
Some platforms, such as Intel MID and mshypv, do not support legacy interrupt controllers. So count legacy IRQs by
legacy_pic->nr_legacy_irqsinstead of hard-codedNR_IRQS_LEGACY.
Nice patch set!
Quoted 15 lines
Signed-off-by Jiang Liu <[email protected]>--- arch/x86/include/asm/i8259.h | 2 ++ arch/x86/kernel/acpi/boot.c | 13 ++++++------ arch/x86/kernel/apic/io_apic.c | 43 +++++++++++++++++++++++----------------- arch/x86/kernel/devicetree.c | 12 +++++------ arch/x86/kernel/irqinit.c | 6 +++--- arch/x86/pci/xen.c | 6 +++--- 6 files changed, 46 insertions(+), 36 deletions(-)arch/x86/include/asm/i8259.h +0
-0
arch/x86/include/asm/i8259.h struct legacy_pic { · line 70
Quoted 4 lines
arch/x86/include/asm/i8259.h +1
-0@@ -67,4 +67,6 @@ struct legacy_pic {extern struct legacy_pic *legacy_pic;extern struct legacy_pic null_legacy_pic; +#define nr_legacy_irqs () (legacy_pic->nr_legacy_irqs)
That wants to be a static inline, please.
Thanks,
tglx
RFC PATCH 3/3 x86, irq: count legacy IRQs by legacy_pic->nr_legacy_irqs instead of NR_IRQS_LEGACY
In reply to Jiang LiuSome platforms, such as Intel MID and mshypv, do not support legacy interrupt controllers. So count legacy IRQs by legacy_pic->nr_legacy_irqs instead of hard-coded NR_IRQS_LEGACY.
--- arch/x86/include/asm/i8259.h | 2 ++ arch/x86/kernel/acpi/boot.c | 13 ++++++------ arch/x86/kernel/apic/io_apic.c | 43 +++++++++++++++++++++++----------------- arch/x86/kernel/devicetree.c | 12 +++++------ arch/x86/kernel/irqinit.c | 6 +++--- arch/x86/pci/xen.c | 6 +++--- 6 files changed, 46 insertions(+), 36 deletions(-)
arch/x86/include/asm/i8259.h +2 -0
@@ -67,4 +67,6 @@ struct legacy_pic {extern struct legacy_pic *legacy_pic;extern struct legacy_pic null_legacy_pic; +#define nr_legacy_irqs () (legacy_pic->nr_legacy_irqs) +#endif /* _ASM_X86_I8259_H */
arch/x86/kernel/acpi/boot.c +7 -6
@@ -43,6 +43,7 @@#include <asm/io.h> #include <asm/mpspec.h> #include <asm/smp.h> +#include <asm/i8259.h> #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */ static int __initdata acpi_force =0 ;
@@ -101,10 +102,10 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {static unsigned int gsi_to_irq (unsigned int gsi) { -unsigned int irq = gsi +NR_IRQS_LEGACY ; +unsigned int irq = gsi +nr_legacy_irqs ();unsigned int i; -for (i =0 ; i <NR_IRQS_LEGACY ; i++) { +for (i =0 ; i <nr_legacy_irqs (); i++) {if (isa_irq_to_gsi[i] == gsi) {return i; }
@@ -114,7 +115,7 @@ static unsigned int gsi_to_irq(unsigned int gsi)* except on truly weird platforms that have * non isa irqs in the first 16 gsis. */ -if (gsi >=NR_IRQS_LEGACY ) +if (gsi >=nr_legacy_irqs ()) irq = gsi;else irq = gsi_top + gsi;
@@ -371,7 +372,7 @@ static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,* otherwise there will be more than one entry with the same GSI * and acpi_isa_irq_to_gsi() may give wrong result. */ -if (gsi <NR_IRQS_LEGACY && isa_irq_to_gsi[gsi] == gsi) +if (gsi <nr_legacy_irqs () && isa_irq_to_gsi[gsi] == gsi) isa_irq_to_gsi[gsi] =ACPI_INVALID_GSI ; isa_irq_to_gsi[bus_irq] = gsi; }
@@ -628,7 +629,7 @@ EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);int acpi_isa_irq_to_gsi (unsigned isa_irq,u32 *gsi) { -if (isa_irq <NR_IRQS_LEGACY && +if (isa_irq <nr_legacy_irqs () && isa_irq_to_gsi[isa_irq] !=ACPI_INVALID_GSI ) { *gsi = isa_irq_to_gsi[isa_irq];return 0 ;
@@ -1017,7 +1018,7 @@ static void __init mp_config_acpi_legacy_irqs(void)* Use the default configuration for the IRQs 0-15. Unless * overridden by (MADT) interrupt source override entries. */ -for (i =0 ; i <NR_IRQS_LEGACY ; i++) { +for (i =0 ; i <nr_legacy_irqs (); i++) {int ioapic, pin;unsigned int dstapic;int idx;
arch/x86/kernel/apic/io_apic.c +25 -18
143 lines not on this page · raw message
arch/x86/kernel/devicetree.c +6 -6
@@ -316,7 +316,7 @@ static void dt_add_ioapic_domain(unsigned int ioapic_num,struct irq_domain *id;struct mp_ioapic_gsi *gsi_cfg;int ret; -int num; +int num, legacy_irqs =nr_legacy_irqs (); gsi_cfg =mp_ioapic_gsi_routing (ioapic_num); num = gsi_cfg->gsi_end - gsi_cfg->gsi_base +1 ;
@@ -326,17 +326,17 @@ static void dt_add_ioapic_domain(unsigned int ioapic_num,BUG_ON (!id);if (gsi_cfg->gsi_base ==0 ) {/* -* The first NR_IRQS_LEGACY irq descs are allocated in +* The first nr_legacy_irqs() irq descs are allocated in * early_irq_init() and need just a mapping. The * remaining irqs need both. All of them are preallocated * and assigned so we can keep the 1:1 mapping which the ioapic * is having. */ -irq_domain_associate_many (id,0 ,0 ,NR_IRQS_LEGACY ); +irq_domain_associate_many (id,0 ,0 , legacy_irqs); -if (num >NR_IRQS_LEGACY ) { - ret =irq_create_strict_mappings (id,NR_IRQS_LEGACY , -NR_IRQS_LEGACY , num -NR_IRQS_LEGACY ); +if (num > legacy_irqs) { + ret =irq_create_strict_mappings (id, legacy_irqs, + legacy_irqs, num - legacy_irqs);if (ret)pr_err ("Error creating mapping for the " "remaining IRQs: %d\n" , ret);
arch/x86/kernel/irqinit.c +3 -3
@@ -78,7 +78,7 @@ void __init init_ISA_irqs(void)#endif legacy_pic->init (0 ); -for (i =0 ; i < legacy_pic->nr_legacy_irqs; i++) +for (i =0 ; i <nr_legacy_irqs (); i++)irq_set_chip_and_handler_name (i, chip, handle_level_irq, name); }
@@ -100,7 +100,7 @@ void __init init_IRQ(void)* then this vector space can be freed and re-used dynamically as the * irq's migrate etc. */ -for (i =0 ; i < legacy_pic->nr_legacy_irqs; i++) +for (i =0 ; i <nr_legacy_irqs (); i++)per_cpu (vector_irq,0 )[IRQ0_VECTOR + i] = i; x86_init.irqs.intr_init ();
@@ -121,7 +121,7 @@ void setup_vector_irq(int cpu)* legacy PIC, for the new cpu that is coming online, setup the static * legacy vector to irq mapping: */ -for (irq =0 ; irq < legacy_pic->nr_legacy_irqs; irq++) +for (irq =0 ; irq <nr_legacy_irqs (); irq++)per_cpu (vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;#endif
arch/x86/pci/xen.c +3 -3
@@ -40,7 +40,7 @@ static int xen_pcifront_enable_irq(struct pci_dev *dev)/* In PV DomU the Xen PCI backend puts the PIRQ in the interrupt line.*/ pirq = gsi; -if (gsi <NR_IRQS_LEGACY ) +if (gsi <nr_legacy_irqs ()) share =0 ; rc =xen_bind_pirq_gsi_to_irq (gsi, pirq, share,"pcifront" );
@@ -511,7 +511,7 @@ int __init pci_xen_initial_domain(void)xen_setup_acpi_sci (); __acpi_register_gsi = acpi_register_gsi_xen;/* Pre-allocate legacy irqs */ -for (irq =0 ; irq <NR_IRQS_LEGACY ; irq++) { +for (irq =0 ; irq <nr_legacy_irqs (); irq++) {int trigger, polarity;if (acpi_get_override_irq (irq, &trigger, &polarity) ==-1 )
@@ -522,7 +522,7 @@ int __init pci_xen_initial_domain(void) true /* Map GSI to PIRQ */); }if (0 == nr_ioapics) { -for (irq =0 ; irq <NR_IRQS_LEGACY ; irq++) +for (irq =0 ; irq <nr_legacy_irqs (); irq++)xen_bind_pirq_gsi_to_irq (irq, irq,0 ,"xt-pic" ); }return 0 ;
Signature · 1 line
1.7.10.4
PATCH v3 20/37 x86, irq: enhance mp_register_ioapic() to support irqdomain
In reply to Jiang LiuAdd extra arguments to function mp_register_ioapic() to support irqdomain. When registering IOAPIC, caller may provide a callback and corresponding argument to create irqdomain for this IOAPIC. The callback will be called later when initializing IOAPIC subsystem.
We also provide a common implementation mp_create_irqdomain() to create irqdomain for IOAPICs, which may be used by platform drivers.
Global variable ioapic_dynirq_base is provided for platform drivers to override return value of arch_dynirq_lower_bound(), thus enable or disable dynamic IRQ allocation for IOAPIC.
--- arch/x86/include/asm/io_apic.h | 10 ++++++++- arch/x86/kernel/acpi/boot.c | 3 ++- arch/x86/kernel/apic/io_apic.c | 48 ++++++++++++++++++++++++++++++++++++++-- arch/x86/kernel/devicetree.c | 2 +- arch/x86/kernel/mpparse.c | 2 +- arch/x86/platform/sfi/sfi.c | 2 +- 6 files changed, 60 insertions(+), 7 deletions(-)
arch/x86/include/asm/io_apic.h +9 -1
@@ -135,6 +135,9 @@ extern int noioapicreroute;/* Build identity mapping for non-ISA IRQs below NR_IRQS_LEGACY */ extern int ioapic_identity_map; +/* Build identity mapping for GSIs below it */ +extern int ioapic_dynirq_base; +/* * If we use the IO-APIC for IRQ routing, disable automatic * assignment of PCI IRQ's.
@@ -174,13 +177,18 @@ struct mp_ioapic_gsi{ };extern u32 gsi_top; +struct device_node ; +struct irq_domain_ops ;typedef struct irq_domain *(*ioapic_create_domain_fn )(int idx,void *arg);extern int mp_find_ioapic (u32 gsi);extern int mp_find_ioapic_pin (int ioapic,u32 gsi);extern u32 mp_pin_to_gsi (int ioapic,int pin);extern int mp_map_gsi_to_irq (u32 gsi,unsigned int flags); -extern void __init mp_register_ioapic (int id,u32 address,u32 gsi_base); +extern void __init mp_register_ioapic (int id,u32 address,u32 gsi_base, +ioapic_create_domain_fn cb,void *arg); +extern struct irq_domain *mp_irqdomain_create (int ioapic, +struct device_node *np,const struct irq_domain_ops *ops);extern void __init pre_init_apic_IRQ0 (void );extern void mp_save_irq (struct mpc_intsrc *m);
arch/x86/kernel/acpi/boot.c +2 -1
@@ -337,7 +337,8 @@ acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)acpi_table_print_madt_entry (header);mp_register_ioapic (ioapic->id, - ioapic->address, ioapic->global_irq_base); + ioapic->address, ioapic->global_irq_base, +NULL ,NULL );return 0 ; }
arch/x86/kernel/apic/io_apic.c +46 -2
92 lines not on this page · raw message
arch/x86/kernel/devicetree.c +1 -1
@@ -176,7 +176,7 @@ static void __init dtb_add_ioapic(struct device_node *dn) dn->full_name);return ; } -mp_register_ioapic (++ioapic_id, r.start, gsi_top); +mp_register_ioapic (++ioapic_id, r.start, gsi_top,NULL ,NULL ); }static void __init dtb_ioapic_setup (void )
arch/x86/kernel/mpparse.c +1 -1
@@ -115,7 +115,7 @@ static void __init MP_bus_info(struct mpc_bus *m)static void __init MP_ioapic_info (struct mpc_ioapic *m) {if (m->flags &MPC_APIC_USABLE ) -mp_register_ioapic (m->apicid, m->apicaddr, gsi_top); +mp_register_ioapic (m->apicid, m->apicaddr, gsi_top,NULL ,NULL ); }static void __init print_mp_irq_info (struct mpc_intsrc *mp_irq)
arch/x86/platform/sfi/sfi.c +1 -1
@@ -82,7 +82,7 @@ static int __init sfi_parse_ioapic(struct sfi_table_header *table) pentry = (struct sfi_apic_table_entry *)sb->pentry;for (i =0 ; i < num; i++) { -mp_register_ioapic (i, pentry->phys_addr, gsi_top); +mp_register_ioapic (i, pentry->phys_addr, gsi_top,NULL ,NULL ); pentry++; }
Signature · 1 line
1.7.10.4
PATCH v3 21/37 x86, ACPI, irq: provide basic irqdomain support
In reply to Jiang LiuEnhance ACPI driver to provide basic irqdomain support for IOAPIC.
--- arch/x86/kernel/acpi/boot.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
arch/x86/kernel/acpi/boot.c +19 -1
@@ -31,6 +31,7 @@#include <linux/module.h> #include <linux/dmi.h> #include <linux/irq.h> +#include <linux/irqdomain.h> #include <linux/slab.h> #include <linux/bootmem.h> #include <linux/ioport.h>
@@ -324,6 +325,23 @@ static void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,static int mp_register_gsi (struct device *dev,u32 gsi,int trigger,int polarity); +static struct irq_domain_ops acpi_irqdomain_ops; + +static struct irq_domain *acpi_create_irqdomain (int idx,void *arg) +{ +struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (idx); + +/* +* Statically allocate IRQ number for legacy IRQs and all pins on the +* first IOAPIC. +*/ +if (gsi_cfg->gsi_base <NR_IRQS_LEGACY && + ioapic_dynirq_base < gsi_cfg->gsi_end) + ioapic_dynirq_base = gsi_cfg->gsi_end +1 ; + +return mp_irqdomain_create (idx,NULL , &acpi_irqdomain_ops); +} +static int __init acpi_parse_ioapic (struct acpi_subtable_header * header,const unsigned long end) {
@@ -338,7 +356,7 @@ acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)mp_register_ioapic (ioapic->id, ioapic->address, ioapic->global_irq_base, -NULL ,NULL ); + acpi_create_irqdomain,NULL );return 0 ; }
Signature · 1 line
1.7.10.4
PATCH v3 22/37 x86, mpparse, irq: provide basic irqdomain support
In reply to Jiang LiuEnhance mpparse to provide basic support of irqdomain with identity mapping between GSIs and IRQs.
--- arch/x86/kernel/mpparse.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/x86/kernel/mpparse.c +10 -1
@@ -19,6 +19,7 @@#include <linux/module.h> #include <linux/smp.h> #include <linux/pci.h> +#include <linux/irqdomain.h> #include <asm/mtrr.h> #include <asm/mpspec.h>
@@ -112,10 +113,18 @@ static void __init MP_bus_info(struct mpc_bus *m)pr_warn ("Unknown bustype %s - ignoring\n" , str); } +static struct irq_domain_ops mp_ioapic_irqdomain_ops; + +static struct irq_domain *mp_ioapic_create_irqdomain (int ioapic,void *arg) +{ +return mp_irqdomain_create (ioapic,NULL , &mp_ioapic_irqdomain_ops); +} +static void __init MP_ioapic_info (struct mpc_ioapic *m) {if (m->flags &MPC_APIC_USABLE ) -mp_register_ioapic (m->apicid, m->apicaddr, gsi_top,NULL ,NULL ); +mp_register_ioapic (m->apicid, m->apicaddr, gsi_top, + mp_ioapic_create_irqdomain,NULL ); }static void __init print_mp_irq_info (struct mpc_intsrc *mp_irq)
Signature · 1 line
1.7.10.4
PATCH v3 23/37 x86, SFI, irq: provide basic irqdomain support
In reply to Jiang LiuEnhance SFI to provide basic support of irqdomain with identity mapping between GSIs and IRQs.
--- arch/x86/pci/intel_mid_pci.c | 3 +++ arch/x86/platform/intel-mid/sfi.c | 2 ++ arch/x86/platform/sfi/sfi.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-)
arch/x86/pci/intel_mid_pci.c +3 -0
@@ -217,6 +217,9 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)* MRST only have IOAPIC, the PCI irq lines are 1:1 mapped to * IOAPIC RTE entries, so we just enable RTE for the device. */ +if (mp_map_gsi_to_irq (dev->irq,IOAPIC_MAP_ALLOC ) <0 ) +return -EBUSY ; + irq_attr.ioapic =mp_find_ioapic (dev->irq); irq_attr.ioapic_pin = dev->irq; irq_attr.trigger =1 ;/* level */
arch/x86/platform/intel-mid/sfi.c +2 -0
@@ -473,6 +473,8 @@ static int __init sfi_parse_devs(struct sfi_table_header *table)/* PNW and CLV go with active low */ irq_attr.polarity =1 ; } +WARN_ON (mp_map_gsi_to_irq (irq, +IOAPIC_MAP_ALLOC ) <0 );io_apic_set_pci_routing (NULL , irq, &irq_attr); } }else {
arch/x86/platform/sfi/sfi.c +10 -1
@@ -25,6 +25,7 @@#include <linux/init.h> #include <linux/sfi.h> #include <linux/io.h> +#include <linux/irqdomain.h> #include <asm/io_apic.h> #include <asm/mpspec.h>
@@ -70,6 +71,13 @@ static int __init sfi_parse_cpus(struct sfi_table_header *table)#endif /* CONFIG_X86_LOCAL_APIC */ #ifdef CONFIG_X86_IO_APIC +static struct irq_domain_ops sfi_ioapic_irqdomain_ops; + +static struct irq_domain *sfi_ioapic_create_irqdomain (int ioapic,void *arg) +{ + ioapic_identity_map =1 ; +return mp_irqdomain_create (ioapic,NULL , &sfi_ioapic_irqdomain_ops); +}static int __init sfi_parse_ioapic (struct sfi_table_header *table) {
@@ -82,7 +90,8 @@ static int __init sfi_parse_ioapic(struct sfi_table_header *table) pentry = (struct sfi_apic_table_entry *)sb->pentry;for (i =0 ; i < num; i++) { -mp_register_ioapic (i, pentry->phys_addr, gsi_top,NULL ,NULL ); +mp_register_ioapic (i, pentry->phys_addr, gsi_top, + sfi_ioapic_create_irqdomain,NULL ); pentry++; }
Signature · 1 line
1.7.10.4
PATCH v3 24/37 x86, devicetree, irq: use common mechanism to support irqdomain
In reply to Jiang LiuNow the ioapic driver provides a common interface to create irqdomain, so replace the private implementation.
--- arch/x86/include/asm/prom.h | 2 -- arch/x86/kernel/devicetree.c | 81 +++++------------------------------------- arch/x86/kernel/irqinit.c | 6 ---- 3 files changed, 8 insertions(+), 81 deletions(-)
arch/x86/include/asm/prom.h +0 -2
@@ -26,12 +26,10 @@extern int of_ioapic;extern u64 initial_dtb;extern void add_dtb (u64 data); -extern void x86_add_irq_domains (void );void x86_of_pci_init (void );void x86_dtb_init (void );#else static inline void add_dtb (u64 data) { } -static inline void x86_add_irq_domains (void ) { }static inline void x86_of_pci_init (void ) { }static inline void x86_dtb_init (void ) { }#define of_ioapic 0
arch/x86/kernel/devicetree.c +8 -73
106 lines not on this page · raw message
arch/x86/kernel/irqinit.c +0 -6
@@ -87,12 +87,6 @@ void __init init_IRQ(void)int i;/* -* We probably need a better place for this, but it works for -* now ... -*/ -x86_add_irq_domains (); - -/* * On cpu 0, Assign IRQ0_VECTOR..IRQ15_VECTOR's to IRQ 0..15. * If these IRQ's are handled by legacy interrupt-controllers like PIC, * then this configuration will likely be static after the boot. If
Signature · 1 line
1.7.10.4
PATCH v3 25/37 x86, irq: introduce two helper functions to support irqdomain map operation
In reply to Jiang LiuCurrently there are multiple entries to program IOAPIC pins, such as io_apic_setup_irq_pin_once(), io_apic_set_pci_routing() and setup_IO_APIC_irq_extra() etc.
This patch introduces two functions to help consolidate the code to program IOAPIC pins. Function mp_set_pin_attr() is used to optionally set trigger, polarity and NUMA node property for an IOAPIC pin. If mp_set_pin_attr() is not invoked for a pin, the default configuration from BIOS will be used.
Function mp_irqdomain_map() is an common implementation of irqdomain map() operation. It figures out attribures for pin and then actually programs the IOAPIC pin. We hope this will be the only entrance for programming IOAPIC pin.
And the flow will:
1) caller such as xxx_pci_irq_enable figures out pin attributes.
2) Invoke mp_set_pin_attr() to set attributes for a pin. If the pin has already bin programmed, mp_set_pin_attr() will aslo detects attribute confictions.
3) Invoke mp_map_pin_to_irq()
3.1) If IRQ has already been assigned, return irq_find_mapping() 3.2) Else irq_create_mapping()
->irq_domain_associate() ->mp_irqdomain_map() ->io_apic_setup_irq_pin()
So every pin will only programmed once by mp_irqdomain_map(), so we could kill io_apic_setup_irq_pin_once(), io_apic_set_pci_routing() and setup_IO_APIC_irq_extra() etc.
--- arch/x86/include/asm/io_apic.h | 3 ++ arch/x86/kernel/apic/io_apic.c | 93 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-)
arch/x86/include/asm/io_apic.h +3 -0
@@ -189,6 +189,9 @@ extern void __init mp_register_ioapic(int id, u32 address, u32 gsi_base, ioapic_create_domain_fn cb, void *arg);extern struct irq_domain *mp_irqdomain_create (int ioapic,struct device_node *np,const struct irq_domain_ops *ops); +extern int mp_irqdomain_map (struct irq_domain *domain,unsigned int virq, +irq_hw_number_t hwirq); +extern int mp_set_gsi_attr (u32 gsi,int trigger,int polarity,int node);extern void __init pre_init_apic_IRQ0 (void );extern void mp_save_irq (struct mpc_intsrc *m);
arch/x86/kernel/apic/io_apic.c +92 -1
139 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 26/37 x86, irq, ACPI: use common irqdomain map interface to program IOAPIC pins
In reply to Jiang LiuRefine ACPI to use common irqdomain map interface to program IOAPIC pins, so we can unify the callsite to progam IOAPIC pins.
--- arch/x86/kernel/acpi/boot.c | 44 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-)
arch/x86/kernel/acpi/boot.c +12 -32
@@ -325,7 +325,9 @@ static void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,static int mp_register_gsi (struct device *dev,u32 gsi,int trigger,int polarity); -static struct irq_domain_ops acpi_irqdomain_ops; +static struct irq_domain_ops acpi_irqdomain_ops = { + .map = mp_irqdomain_map, +};static struct irq_domain *acpi_create_irqdomain (int idx,void *arg) {
@@ -505,10 +507,6 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)int irq =map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC |IOAPIC_MAP_CHECK );if (irq >=0 ) { -#ifdef CONFIG_X86_IO_APIC -if (acpi_irq_model ==ACPI_IRQ_MODEL_IOAPIC ) -setup_IO_APIC_irq_extra (gsi); -#endif *irqp = irq;return 0 ; }
@@ -1036,11 +1034,7 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,static int mp_register_gsi (struct device *dev,u32 gsi,int trigger,int polarity) { -int irq; -int ioapic; -int ioapic_pin; -struct io_apic_irq_attr irq_attr; -int ret; +int irq, node;if (acpi_irq_model !=ACPI_IRQ_MODEL_IOAPIC )return gsi;
@@ -1049,35 +1043,21 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,if (acpi_gbl_FADT.sci_interrupt == gsi)return gsi; + trigger = trigger ==ACPI_EDGE_SENSITIVE ?0 :1 ; + polarity = polarity ==ACPI_ACTIVE_HIGH ?0 :1 ; + node = dev ?dev_to_node (dev) :NUMA_NO_NODE ; +if (mp_set_gsi_attr (gsi, trigger, polarity, node)) { +pr_warn ("Failed to set pin attr for GSI%d\n" , gsi); +return -1 ; + } + irq =map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC );if (irq <0 )return irq; - ioapic =mp_find_ioapic (gsi); -if (ioapic <0 ) { -printk (KERN_WARNING "No IOAPIC for GSI %u\n" , gsi); -return gsi; - } - - ioapic_pin =mp_find_ioapic_pin (ioapic, gsi); - -if (ioapic_pin >MP_MAX_IOAPIC_PIN ) { -printk (KERN_ERR "Invalid reference to IOAPIC pin " -"%d-%d\n" ,mpc_ioapic_id (ioapic), - ioapic_pin); -return gsi; - } -if (enable_update_mptable)mp_config_acpi_gsi (dev, gsi, trigger, polarity); -set_io_apic_irq_attr (&irq_attr, ioapic, ioapic_pin, - trigger ==ACPI_EDGE_SENSITIVE ?0 :1 , - polarity ==ACPI_ACTIVE_HIGH ?0 :1 ); - ret =io_apic_set_pci_routing (dev, irq, &irq_attr); -if (ret <0 ) - irq =-1 ; -return irq; }
Signature · 1 line
1.7.10.4
PATCH v3 27/37 x86, irq, mpparse: use common irqdomain map interface to program IOAPIC pins
In reply to Jiang LiuRefine mpparse to use common irqdomain map interface to program IOAPIC pins, so we can unify the callsite to progam IOAPIC pins.
--- arch/x86/kernel/mpparse.c | 4 +++- arch/x86/pci/irq.c | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/mpparse.c +3 -1
@@ -113,7 +113,9 @@ static void __init MP_bus_info(struct mpc_bus *m)pr_warn ("Unknown bustype %s - ignoring\n" , str); } -static struct irq_domain_ops mp_ioapic_irqdomain_ops; +static struct irq_domain_ops mp_ioapic_irqdomain_ops = { + .map = mp_irqdomain_map, +};static struct irq_domain *mp_ioapic_create_irqdomain (int ioapic,void *arg) {
arch/x86/pci/irq.c +0 -2
@@ -1227,8 +1227,6 @@ static int pirq_enable_irq(struct pci_dev *dev) } dev = temp_dev;if (irq >=0 ) { -io_apic_set_pci_routing (&dev->dev, irq, - &irq_attr); dev->irq = irq;dev_info (&dev->dev,"PCI->APIC IRQ transform: " "INT %c -> IRQ %d\n" ,'A' + pin -1 , irq);
Signature · 1 line
1.7.10.4
PATCH v3 28/37 x86, irq, SFI: use common irqdomain map interface to program IOAPIC pins
In reply to Jiang LiuRefine SFI to use common irqdomain map interface to program IOAPIC pins, so we can unify the callsite to progam IOAPIC pins.
--- arch/x86/pci/intel_mid_pci.c | 19 +++++------- arch/x86/platform/intel-mid/sfi.c | 58 ++++++++++++++++--------------------- arch/x86/platform/sfi/sfi.c | 4 ++- 3 files changed, 35 insertions(+), 46 deletions(-)
arch/x86/pci/intel_mid_pci.c +7 -12
@@ -208,27 +208,22 @@ static int pci_write(struct pci_bus *bus, unsigned int devfn, int where,static int intel_mid_pci_irq_enable (struct pci_dev *dev) { -u8 pin; -struct io_apic_irq_attr irq_attr; +int polarity; -pci_read_config_byte (dev,PCI_INTERRUPT_PIN , &pin); +if (intel_mid_identify_cpu () ==INTEL_MID_CPU_CHIP_TANGIER ) + polarity =0 ;/* active high */ +else + polarity =1 ;/* active low */ /* * MRST only have IOAPIC, the PCI irq lines are 1:1 mapped to * IOAPIC RTE entries, so we just enable RTE for the device. */ +if (mp_set_gsi_attr (dev->irq,1 , polarity,dev_to_node (&dev->dev))) +return -EBUSY ;if (mp_map_gsi_to_irq (dev->irq,IOAPIC_MAP_ALLOC ) <0 )return -EBUSY ; - irq_attr.ioapic =mp_find_ioapic (dev->irq); - irq_attr.ioapic_pin = dev->irq; - irq_attr.trigger =1 ;/* level */ -if (intel_mid_identify_cpu () ==INTEL_MID_CPU_CHIP_TANGIER ) - irq_attr.polarity =0 ;/* active high */ -else - irq_attr.polarity =1 ;/* active low */ -io_apic_set_pci_routing (&dev->dev, dev->irq, &irq_attr); -return 0 ; }
arch/x86/platform/intel-mid/sfi.c +25 -33
71 lines not on this page · raw message
arch/x86/platform/sfi/sfi.c +3 -1
@@ -71,7 +71,9 @@ static int __init sfi_parse_cpus(struct sfi_table_header *table)#endif /* CONFIG_X86_LOCAL_APIC */ #ifdef CONFIG_X86_IO_APIC -static struct irq_domain_ops sfi_ioapic_irqdomain_ops; +static struct irq_domain_ops sfi_ioapic_irqdomain_ops = { + .map = mp_irqdomain_map, +};static struct irq_domain *sfi_ioapic_create_irqdomain (int ioapic,void *arg) {
Signature · 1 line
1.7.10.4
PATCH v3 29/37 x86, irq, devicetree: use common irqdomain map interface to program IOAPIC pins
In reply to Jiang LiuRefine devicetree to use common irqdomain map interface to program IOAPIC pins, so we can unify the callsite to progam IOAPIC pins.
--- arch/x86/kernel/devicetree.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
arch/x86/kernel/devicetree.c +5 -9
@@ -280,10 +280,8 @@ static int ioapic_xlate(struct irq_domain *domain, const u32 *intspec, u32 intsize, irq_hw_number_t *out_hwirq, u32 *out_type) { - struct io_apic_irq_attr attr; struct of_ioapic_type *it; -u32 line, idx; -int rc; +u32 line, idx, gsi;if (WARN_ON (intsize <2 ))return -EINVAL ;
@@ -296,12 +294,9 @@ static int ioapic_xlate(struct irq_domain *domain, it = &of_ioapic_type[intspec[1 ]]; idx = (u32 )(long )domain->host_data; -set_io_apic_irq_attr (&attr, idx, line, it->trigger, it->polarity); - - rc =io_apic_setup_irq_pin_once (irq_find_mapping (domain, line), -cpu_to_node (0 ), &attr); -if (rc) -return rc; + gsi =mp_pin_to_gsi (idx, line); +if (mp_set_gsi_attr (gsi, it->trigger, it->polarity,cpu_to_node (0 ))) +return -EBUSY ; *out_hwirq = line; *out_type = it->out_type;
@@ -309,6 +304,7 @@ static int ioapic_xlate(struct irq_domain *domain, }const struct irq_domain_ops ioapic_irq_domain_ops = { + .map = mp_irqdomain_map, .xlate = ioapic_xlate, };
Signature · 1 line
1.7.10.4
PATCH v3 30/37 x86, irq: clean up unused IOAPIC interface
In reply to Jiang LiuNow we have converted all x86 platforms to use the common irqdomain map interface. There's no caller of io_apic_set_pci_routing(), setup_IO_APIC_irq_extra() and io_apic_setup_irq_pin_once() any more, so kill them.
--- arch/x86/include/asm/io_apic.h | 9 ------ arch/x86/kernel/apic/io_apic.c | 70 ---------------------------------------- 2 files changed, 79 deletions(-)
arch/x86/include/asm/io_apic.h +0 -9
@@ -147,9 +147,6 @@ extern int ioapic_dynirq_base;struct io_apic_irq_attr ;struct irq_cfg ; -extern int io_apic_set_pci_routing (struct device *dev,int irq, -struct io_apic_irq_attr *irq_attr); -extern void setup_IO_APIC_irq_extra (u32 gsi);extern void ioapic_insert_resources (void ); extern int native_setup_ioapic_entry(int, struct IO_APIC_route_entry *,
@@ -161,8 +158,6 @@ extern void native_compose_msi_msg(struct pci_dev *pdev, unsigned int irq, unsigned int dest, struct msi_msg *msg, u8 hpet_id);extern void native_eoi_ioapic_pin (int apic,int pin,int vector); -extern int io_apic_setup_irq_pin_once (unsigned int irq,int node, -struct io_apic_irq_attr *attr);extern int save_ioapic_entries (void );extern void mask_ioapic_entries (void );
@@ -235,10 +230,6 @@ static inline int mp_find_ioapic(u32 gsi) { return 0; }static inline u32 mp_pin_to_gsi (int ioapic,int pin) {return UINT_MAX ; }static inline int mp_map_gsi_to_irq (u32 gsi,unsigned int flags) {return gsi; } -struct io_apic_irq_attr ; -static inline int io_apic_set_pci_routing (struct device *dev,int irq, -struct io_apic_irq_attr *irq_attr) {return 0 ; } -static inline int save_ioapic_entries (void ) {return -ENOMEM ;
arch/x86/kernel/apic/io_apic.c +0 -70
94 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 31/37 x86, irq: simplify the way to handle ISA IRQ
In reply to Jiang LiuOn startup, setup_IO_APIC_irqs() will program all IOAPIC pins for ISA IRQs. Later when mp_map_pin_to_irq() is called, it just returns ISA IRQ number without programming corresponding IOAPIC pin.
This patch consolidates the way to program IOAPIC pins for both ISA and non-ISA IRQs into mp_map_pin_to_irq() as below:
1) For ISA IRQs, mp_irqs array is used to map IOAPIC pin to IRQ and mp_irqdomain_map() is used to actually program the pin.
2) For non-ISA IRQs, irqdomain is used to map IOAPIC pin to IRQ, and mp_irqdomain_map() is also used to actually program the pin.
--- arch/x86/kernel/acpi/boot.c | 15 +------ arch/x86/kernel/apic/io_apic.c | 88 ++++++++++++---------------------------- 2 files changed, 29 insertions(+), 74 deletions(-)
arch/x86/kernel/acpi/boot.c +2 -13
@@ -100,17 +100,6 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {#define ACPI_INVALID_GSI INT_MIN -static int map_gsi_to_irq (unsigned int gsi,unsigned int flags) -{ -int i; - -for (i =0 ; i <NR_IRQS_LEGACY ; i++) -if (isa_irq_to_gsi[i] == gsi) -return i; - -return mp_map_gsi_to_irq (gsi, flags); -} -/* * This is just a simple wrapper around early_ioremap(), * with sanity checks for phys == 0 and size == 0.
@@ -504,7 +493,7 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)int acpi_gsi_to_irq (u32 gsi,unsigned int *irqp) { -int irq =map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC |IOAPIC_MAP_CHECK ); +int irq =mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC |IOAPIC_MAP_CHECK );if (irq >=0 ) { *irqp = irq;
@@ -1051,7 +1040,7 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,return -1 ; } - irq =map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC ); + irq =mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC );if (irq <0 )return irq;
arch/x86/kernel/apic/io_apic.c +27 -61
125 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 32/37 genirq: export irq_domain_disassociate() to architecture interrupt drivers
In reply to Jiang LiuExport irq_domain_disassociate() to architecture interrupt drivers, so it could be used to handle legacy IRQ descriptors on x86.
--- include/linux/irqdomain.h | 2 ++ kernel/irq/irqdomain.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
include/linux/irqdomain.h +2 -0
@@ -172,6 +172,8 @@ extern int irq_domain_associate(struct irq_domain *domain, unsigned int irq,extern void irq_domain_associate_many (struct irq_domain *domain,unsigned int irq_base,irq_hw_number_t hwirq_base,int count); +extern void irq_domain_disassociate (struct irq_domain *domain, +unsigned int irq);extern unsigned int irq_create_mapping (struct irq_domain *host,irq_hw_number_t hwirq);
kernel/irq/irqdomain.c +1 -1
@@ -231,7 +231,7 @@ void irq_set_default_host(struct irq_domain *domain) }EXPORT_SYMBOL_GPL (irq_set_default_host); -static void irq_domain_disassociate (struct irq_domain *domain,unsigned int irq) +void irq_domain_disassociate (struct irq_domain *domain,unsigned int irq) {struct irq_data *irq_data =irq_get_irq_data (irq);irq_hw_number_t hwirq;
Signature · 1 line
1.7.10.4
PATCH v3 33/37 x86, irq: introduce helper functions to release IOAPIC pin
In reply to Jiang LiuIntroduce function mp_unmap_irq() to release IOAPIC IRQ when IRQ is not used any more, which will typically called by pcibios_disabled_irq.
And function mp_irqdomain_unmap() is a common implementation of irq_domain_ops.unmap for IOAPIC.
--- arch/x86/include/asm/io_apic.h | 3 ++ arch/x86/kernel/apic/io_apic.c | 60 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
arch/x86/include/asm/io_apic.h +3 -0
@@ -180,12 +180,14 @@ extern int mp_find_ioapic(u32 gsi);extern int mp_find_ioapic_pin (int ioapic,u32 gsi);extern u32 mp_pin_to_gsi (int ioapic,int pin);extern int mp_map_gsi_to_irq (u32 gsi,unsigned int flags); +extern void mp_unmap_irq (int irq);extern void __init mp_register_ioapic (int id,u32 address,u32 gsi_base,ioapic_create_domain_fn cb,void *arg);extern struct irq_domain *mp_irqdomain_create (int ioapic,struct device_node *np,const struct irq_domain_ops *ops);extern int mp_irqdomain_map (struct irq_domain *domain,unsigned int virq,irq_hw_number_t hwirq); +extern void mp_irqdomain_unmap (struct irq_domain *domain,unsigned int virq);extern int mp_set_gsi_attr (u32 gsi,int trigger,int polarity,int node);extern void __init pre_init_apic_IRQ0 (void );
@@ -229,6 +231,7 @@ static inline void ioapic_insert_resources(void) { }static inline int mp_find_ioapic (u32 gsi) {return 0 ; }static inline u32 mp_pin_to_gsi (int ioapic,int pin) {return UINT_MAX ; }static inline int mp_map_gsi_to_irq (u32 gsi,unsigned int flags) {return gsi; } +static inline void mp_unmap_irq (int irq) { }static inline int save_ioapic_entries (void ) {
arch/x86/kernel/apic/io_apic.c +60 -0
78 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 34/37 x86, irq, ACPI: release IOAPIC pin when PCI device is disabled
In reply to Jiang LiuRelease IOAPIC pin associated with PCI device when the PCI device is disabled.
--- arch/x86/kernel/acpi/boot.c | 28 ++++++++++++++++++++++++++++ drivers/acpi/pci_irq.c | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-)
arch/x86/kernel/acpi/boot.c +28 -0
@@ -313,9 +313,11 @@ static void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi);static int mp_register_gsi (struct device *dev,u32 gsi,int trigger,int polarity); +static void mp_unregister_gsi (u32 gsi);static struct irq_domain_ops acpi_irqdomain_ops = { .map = mp_irqdomain_map, + .unmap = mp_irqdomain_unmap, };static struct irq_domain *acpi_create_irqdomain (int idx,void *arg)
@@ -541,8 +543,16 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,return irq; } +static void acpi_unregister_gsi_ioapic (u32 gsi) +{ +#ifdef CONFIG_X86_IO_APIC +mp_unregister_gsi (gsi); +#endif +} +int (*__acpi_register_gsi)(struct device *dev,u32 gsi,int trigger,int polarity) = acpi_register_gsi_pic; +void (*__acpi_unregister_gsi)(u32 gsi) =NULL ;#ifdef CONFIG_ACPI_SLEEP int (*acpi_suspend_lowlevel)(void ) = x86_acpi_suspend_lowlevel;
@@ -562,6 +572,8 @@ EXPORT_SYMBOL_GPL(acpi_register_gsi);void acpi_unregister_gsi (u32 gsi) { +if (__acpi_unregister_gsi) + (*__acpi_unregister_gsi)(gsi); }EXPORT_SYMBOL_GPL (acpi_unregister_gsi);
@@ -569,6 +581,7 @@ static void __init acpi_set_irq_model_ioapic(void) { acpi_irq_model =ACPI_IRQ_MODEL_IOAPIC ; __acpi_register_gsi = acpi_register_gsi_ioapic; + __acpi_unregister_gsi = acpi_unregister_gsi_ioapic; acpi_ioapic =1 ; }
@@ -1050,6 +1063,21 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,return irq; } +static void mp_unregister_gsi (u32 gsi) +{ +int irq; + +if (acpi_irq_model !=ACPI_IRQ_MODEL_IOAPIC ) +return ; + +if (acpi_gbl_FADT.sci_interrupt == gsi) +return ; + + irq =mp_map_gsi_to_irq (gsi,0 ); +if (irq >0 ) +mp_unmap_irq (irq); +} +/* * Parse IOAPIC related entries in MADT * returns 0 on success, < 0 on error
drivers/acpi/pci_irq.c +2 -1
@@ -498,5 +498,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev)*/ dev_dbg (&dev->dev,"PCI INT %c disabled\n" ,pin_name (pin)); -acpi_unregister_gsi (gsi); +if (gsi >=0 && dev->irq >0 ) +acpi_unregister_gsi (gsi); }
Signature · 1 line
1.7.10.4
PATCH v3 35/37 x86, irq, mpparse: release IOAPIC pin when PCI device is disabled
In reply to Jiang LiuRelease IOAPIC pin associated with PCI device when the PCI device is disabled.
--- arch/x86/kernel/mpparse.c | 1 + arch/x86/pci/irq.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-)
arch/x86/kernel/mpparse.c +1 -0
@@ -115,6 +115,7 @@ static void __init MP_bus_info(struct mpc_bus *m)static struct irq_domain_ops mp_ioapic_irqdomain_ops = { .map = mp_irqdomain_map, + .unmap = mp_irqdomain_unmap, };static struct irq_domain *mp_ioapic_create_irqdomain (int ioapic,void *arg)
arch/x86/pci/irq.c +11 -2
@@ -26,6 +26,7 @@ static int acer_tm360_irqrouting;static struct irq_routing_table *pirq_table;static int pirq_enable_irq (struct pci_dev *dev); +static void pirq_disable_irq (struct pci_dev *dev);/* * Never use: 0, 1, 2 (timer, keyboard, and cascade)
@@ -53,7 +54,7 @@ struct irq_router_handler { };int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq; -void (*pcibios_disable_irq)(struct pci_dev *dev) =NULL ; +void (*pcibios_disable_irq)(struct pci_dev *dev) = pirq_disable_irq;/* * Check passed address for the PCI IRQ Routing Table signature
@@ -1186,7 +1187,7 @@ void pcibios_penalize_isa_irq(int irq, int active)static int pirq_enable_irq (struct pci_dev *dev) { -u8 pin; +u8 pin =0 ;pci_read_config_byte (dev,PCI_INTERRUPT_PIN , &pin);if (pin && !pcibios_lookup_irq (dev,1 )) {
@@ -1252,3 +1253,11 @@ static int pirq_enable_irq(struct pci_dev *dev) }return 0 ; } + +static void pirq_disable_irq (struct pci_dev *dev) +{ +if (io_apic_assign_pci_irqs && dev->irq) { +mp_unmap_irq (dev->irq); + dev->irq =0 ; + } +}
Signature · 1 line
1.7.10.4
PATCH v3 36/37 x86, irq, SFI: release IOAPIC pin when PCI device is disabled
In reply to Jiang LiuRelease IOAPIC pin associated with PCI device when the PCI device is disabled.
--- arch/x86/pci/intel_mid_pci.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/pci/intel_mid_pci.c +7 -0
@@ -227,6 +227,12 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)return 0 ; } +static void intel_mid_pci_irq_disable (struct pci_dev *dev) +{ +if (dev->irq >0 ) +mp_unmap_irq (dev->irq); +} +struct pci_ops intel_mid_pci_ops = { .read = pci_read, .write = pci_write,
@@ -243,6 +249,7 @@ int __init intel_mid_pci_init(void)pr_info ("Intel MID platform detected, using MID PCI ops\n" );pci_mmcfg_late_init (); pcibios_enable_irq = intel_mid_pci_irq_enable; + pcibios_disable_irq = intel_mid_pci_irq_disable; pci_root_ops = intel_mid_pci_ops; pci_soc_mode =1 ;/* Continue with standard init */
Signature · 1 line
1.7.10.4
PATCH v3 37/37 x86, irq, devicetree: release IOAPIC pin when PCI device is disabled
In reply to Jiang LiuRelease IOAPIC pin associated with PCI device when the PCI device is disabled.
--- arch/x86/kernel/devicetree.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/devicetree.c +1 -0
@@ -305,6 +305,7 @@ static int ioapic_xlate(struct irq_domain *domain,const struct irq_domain_ops ioapic_irq_domain_ops = { .map = mp_irqdomain_map, + .unmap = mp_irqdomain_unmap, .xlate = ioapic_xlate, };
Signature · 1 line
1.7.10.4