Enable hierarchy irqdomian on x86 platforms
Subsystems (7)
v3 cover Enable hierarchy irqdomian on x86 platforms
This is the last part to enable support of hierarchy domain on x86 platforms.
It first converts IOAPIC to support hierarchy irqdomain, then cleans up all unused code and interfaces. It also introduces a kernel boot parameter to configure CPU vector allocation policies.
It's based on my previous patch set at:
https://www.mail-archive.com/[email protected]/msg760868.html
And you may access it at:
https://github.com/jiangliu/linux.git irqdomain/p3v3
It has been tested on Intel 64-bit server and 32-bit laptop. It also passes Fengguang's 0day tests. Helps are welcomed for testing:
1) Intel MID platform
2) Intel CE or OLPC platforms
Patch 1-3 kills pre_init_apic_IRQ0().
Patch 4-9 convert IOAPIC to use hierarch irqdomain
Patch 10-36 clean up code, unused interfaces etc.
Patch 37-38 introduces a mechanism to configure CPU vector allocation
policies.
Jiang Liu (37):
x86, intel-mid, trivial: Refine code syntax for sfi_parse_mtmr() x86, irq: Kill unused pre_init_apic_IRQ0()
x86, irq: Prepare IOAPIC interfaces to support hierarchy irqdomain x86, irq: Implement callbacks to enable hierarchy irqdomain on
IOAPICs
x86, irq: Refine the way to allocate irq_cfg for legacy IRQs x86, irq: Simplify the way to print IOAPIC entry
x86, irq: Introduce helper functions to support hierarchy irqdomain
for IOAPIC
x86, irq: Convert IOAPIC to use hierarchy irqdomain interfaces x86, irq: Kill unused old IOAPIC irqdomain interfaces x86, irq: Kill unused struct mp_pin_info
x86, irq: Kill x86_io_apic_ops.print_entries and related interfaces x86, irq: Kill x86_io_apic_ops.setup_entry and related interfaces x86, irq: Kill x86_io_apic_ops.set_affinity and related interfaces x86, irq: Kill x86_io_apic_ops.eoi_ioapic_pin and related interfaces x86, irq: Kill GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
x86: Clean up unused forward declarations in x86_init.h
x86: irq_remapping: Clean up unsued code
iommu/vt-d: Clean up unsued code
iommu/amd: Clean up unsued code
x86: irq_remapping: Clean up unused interfaces
x86, irq: Kill irq_cfg.irq_remapped
iommu/vt-d: Move struct irq_2_iommu into intel_irq_remapping.c iommu/amd: Move struct irq_2_irte into amd_iommu.c
x86, irq: Move irq_cfg.irq_2_pin into io_apic.c
x86, irq: Kill struct io_apic_irq_attr
x86, irq: Kill x86_io_apic_ops.write and x86_io_apic_ops.modify x86, irq: Clean up io_apic.h
x86, irq: Use cached IOAPIC entry instead of reading from hardware x86, irq: Kill unused alloc_irq_and_cfg_at()
x86, irq: Change functions only used in vector.c as static x86, irq: Kill function apic_set_affinity()
x86, irq: Move check of cfg->move_in_progress into
send_cleanup_vector()
x86, irq: Move private data in struct irq_cfg into dedicated data
structure
x86, irq: Refine the way to calculate NR_IRQS
ACPI, irq, x86: Kill private function mp_register_gsi()/
mp_unregister_gsi()
x86, irq: Introduce mechanism to support different vector allocation
policies
x86, irq: Add kernel parameter vector_alloc to set CPU vector
allocation policy
Thomas Gleixner (1):
x86, intel-mid: Delay initialization of APB timer
Documentation/kernel-parameters.txt | 6 + arch/x86/Kconfig | 1 - arch/x86/include/asm/hw_irq.h | 53 +- arch/x86/include/asm/io_apic.h | 81 +- arch/x86/include/asm/irq_remapping.h | 36 - arch/x86/include/asm/irq_vectors.h | 18 +- arch/x86/include/asm/x86_init.h | 16 - arch/x86/kernel/acpi/boot.c | 69 +- arch/x86/kernel/apb_timer.c | 4 - arch/x86/kernel/apic/io_apic.c | 1071 +++++++++----------- arch/x86/kernel/apic/vector.c | 416 ++++---- arch/x86/kernel/devicetree.c | 37 +- arch/x86/kernel/mpparse.c | 6 +- arch/x86/kernel/x86_init.c | 6 - arch/x86/pci/intel_mid_pci.c | 6 +- .../platform/intel-mid/device_libs/platform_wdt.c | 5 +- arch/x86/platform/intel-mid/intel-mid.c | 18 +- arch/x86/platform/intel-mid/sfi.c | 30 +- arch/x86/platform/sfi/sfi.c | 5 +- arch/x86/platform/uv/uv_irq.c | 3 +- drivers/iommu/amd_iommu.c | 153 +-- drivers/iommu/intel_irq_remapping.c | 206 +--- drivers/iommu/irq_remapping.c | 84 -- drivers/iommu/irq_remapping.h | 16 - 24 files changed, 876 insertions(+), 1470 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v3 1/38 x86, intel-mid: Delay initialization of APB timer
From: Thomas Gleixner <[email protected]>
MID has no PIC, but depending on the platform it requires the abt_timer, which is connected to irq0. The timer is set up at late_time_init().
But, looking at the MID code it seems, that there is no reason to do so. The only code which might need the timer working is the TSC calibration code, but thats a non issue on MID as that is using its own empty calibration function. And check_timer() is not invoked either because MID has no PIC and therefor no legacy irqs.
So if you look at intel_mid_time_init() then you'll see that in the ARAT case the timer setup is skipped already. So until the point where x86_init.timers.setup_percpu_clockev() is called for the boot cpu nothing really needs a timer on MID.
According to the MID code the apbt horror is only used for moorestown. Medfield and later use the local apic timer without the apbt nonsense.
The best thing we can do is to drop moorestown support and get rid of that apbt nonsense alltogether.
I don't think anyone deeply cares about it not being supported from 3.18 on. The number of devices which sport a moorestown should be pretty limited and the only relevant use case of those is to act as a pocket heater with short battery life time. Its pretty pointless to update kernels on pocket heaters except for bragging reasons.
If someone at Intel really thinks that we need to keep moorestown alive for other than documentary and sentimental reasons, then we can move the apbt setup to x86_init.timers.setup_percpu_clockev(). At that point the IOAPIC is setup already, so it should just work.
--- arch/x86/kernel/apb_timer.c | 4 ---- arch/x86/platform/intel-mid/intel-mid.c | 18 +++++++++++++----- arch/x86/platform/intel-mid/sfi.c | 2 -- 3 files changed, 13 insertions(+), 11 deletions(-)
arch/x86/kernel/apb_timer.c +0 -4
@@ -179,10 +179,6 @@ static int __init apbt_clockevent_register(void)static void apbt_setup_irq (struct apbt_dev *adev) { -/* timer0 irq has been setup early */ -if (adev->irq ==0 ) -return ; -irq_modify_status (adev->irq,0 ,IRQ_MOVE_PCNTXT );irq_set_affinity (adev->irq,cpumask_of (adev->cpu)); }
arch/x86/platform/intel-mid/intel-mid.c +13 -5
@@ -81,26 +81,34 @@ static unsigned long __init intel_mid_calibrate_tsc(void)return 0 ; } +static void __init intel_mid_setup_bp_timer (void ) +{ +apbt_time_init (); +setup_boot_APIC_clock (); +} +static void __init intel_mid_time_init (void ) {sfi_table_parse (SFI_SIG_MTMR ,NULL ,NULL , sfi_parse_mtmr); +switch (intel_mid_timer_options) {case INTEL_MID_TIMER_APBT_ONLY :break ;case INTEL_MID_TIMER_LAPIC_APBT : - x86_init.timers.setup_percpu_clockev = setup_boot_APIC_clock; +/* Use apbt and local apic */ + x86_init.timers.setup_percpu_clockev = intel_mid_setup_bp_timer; x86_cpuinit.setup_percpu_clockev = setup_secondary_APIC_clock; -break ; +return ;default :if (!boot_cpu_has (X86_FEATURE_ARAT ))break ; +/* Lapic only, no apbt */ x86_init.timers.setup_percpu_clockev = setup_boot_APIC_clock; x86_cpuinit.setup_percpu_clockev = setup_secondary_APIC_clock;return ; } -/* we need at least one APB timer */ -pre_init_apic_IRQ0 (); -apbt_time_init (); + + x86_init.timers.setup_percpu_clockev = apbt_time_init; }static void intel_mid_arch_setup (void )
arch/x86/platform/intel-mid/sfi.c +0 -2
@@ -95,8 +95,6 @@ int __init sfi_parse_mtmr(struct sfi_table_header *table)pr_debug ("timer[%d]: paddr = 0x%08x, freq = %dHz, irq = %d\n" , totallen, (u32 )pentry->phys_addr, pentry->freq_hz, pentry->irq); -if (!pentry->irq) -continue ; mp_irq.type =MP_INTSRC ; mp_irq.irqtype = mp_INT;/* triggering mode edge bit 2-3, active high polarity bit 0-1 */
Signature · 1 line
1.7.10.4
PATCH v3 2/38 x86, intel-mid, trivial: Refine code syntax for sfi_parse_mtmr()
In reply to Jiang LiuCorrectly indent code in function sfi_parse_mtmr().
--- arch/x86/platform/intel-mid/sfi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/x86/platform/intel-mid/sfi.c +10 -10
@@ -95,16 +95,16 @@ int __init sfi_parse_mtmr(struct sfi_table_header *table)pr_debug ("timer[%d]: paddr = 0x%08x, freq = %dHz, irq = %d\n" , totallen, (u32 )pentry->phys_addr, pentry->freq_hz, pentry->irq); - mp_irq.type =MP_INTSRC ; - mp_irq.irqtype = mp_INT; -/* triggering mode edge bit 2-3, active high polarity bit 0-1 */ - mp_irq.irqflag =5 ; - mp_irq.srcbus =MP_BUS_ISA ; - mp_irq.srcbusirq = pentry->irq;/* IRQ */ - mp_irq.dstapic =MP_APIC_ALL ; - mp_irq.dstirq = pentry->irq; -mp_save_irq (&mp_irq); -mp_map_gsi_to_irq (pentry->irq,IOAPIC_MAP_ALLOC ); + mp_irq.type =MP_INTSRC ; + mp_irq.irqtype = mp_INT; +/* triggering mode edge bit 2-3, active high polarity bit 0-1 */ + mp_irq.irqflag =5 ; + mp_irq.srcbus =MP_BUS_ISA ; + mp_irq.srcbusirq = pentry->irq;/* IRQ */ + mp_irq.dstapic =MP_APIC_ALL ; + mp_irq.dstirq = pentry->irq; +mp_save_irq (&mp_irq); +mp_map_gsi_to_irq (pentry->irq,IOAPIC_MAP_ALLOC ); }return 0 ;
Signature · 1 line
1.7.10.4
PATCH v3 3/38 x86, irq: Kill unused pre_init_apic_IRQ0()
In reply to Jiang LiuNow there's no user of pre_init_apic_IRQ0(), so kill it.
--- arch/x86/include/asm/io_apic.h | 1 - arch/x86/kernel/apic/io_apic.c | 17 ----------------- 2 files changed, 18 deletions(-)
arch/x86/include/asm/io_apic.h +0 -1
@@ -204,7 +204,6 @@ 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 );extern void mp_save_irq (struct mpc_intsrc *m);
arch/x86/kernel/apic/io_apic.c +0 -17
@@ -3088,20 +3088,3 @@ int mp_set_gsi_attr(u32 gsi, int trigger, int polarity, int node)return ret; } - -/* Enable IOAPIC early just for system timer */ -void __init pre_init_apic_IRQ0 (void ) -{ -struct io_apic_irq_attr attr = {0 ,0 ,0 ,0 }; - -printk (KERN_INFO "Early APIC setup for system timer0\n" ); -#ifndef CONFIG_SMP -physid_set_mask_of_physid (boot_cpu_physical_apicid, - &phys_cpu_present_map); -#endif -setup_local_APIC (); - -io_apic_setup_irq_pin (0 ,0 , &attr); -irq_set_chip_and_handler_name (0 , &ioapic_chip, handle_edge_irq, -"edge" ); -}
Signature · 1 line
1.7.10.4
PATCH v3 4/38 x86, irq: Prepare IOAPIC interfaces to support hierarchy irqdomain
In reply to Jiang LiuIntroduce helper functions to manipulate struct irq_alloc_info for IOAPIC. Also add extra parameter to IOAPIC interfaces to prepare for hierarchy irqdomain. Function mp_set_gsi_attr() will be killed once we have switched to hierarchy irqdomain.
--- arch/x86/include/asm/hw_irq.h | 2 + arch/x86/include/asm/io_apic.h | 14 ++++++- arch/x86/kernel/acpi/boot.c | 9 +++-- arch/x86/kernel/apic/io_apic.c | 39 +++++++++++++------- arch/x86/pci/intel_mid_pci.c | 4 +- .../platform/intel-mid/device_libs/platform_wdt.c | 4 +- arch/x86/platform/intel-mid/sfi.c | 9 +++-- 7 files changed, 58 insertions(+), 23 deletions(-)
arch/x86/include/asm/hw_irq.h +2 -0
@@ -149,8 +149,10 @@ struct irq_alloc_info {struct {int ioapic_id;int ioapic_pin; +int ioapic_node;u32 ioapic_trigger :1 ;u32 ioapic_polarity :1 ; +u32 ioapic_valid :1 ;struct IO_APIC_route_entry *ioapic_entry; };#endif
arch/x86/include/asm/io_apic.h +12 -2
@@ -95,6 +95,8 @@ struct IR_IO_APIC_route_entry { index :15 ; } __attribute__ ((packed)); +struct irq_alloc_info ; +#define IOAPIC_AUTO -1#define IOAPIC_EDGE 0#define IOAPIC_LEVEL 1
@@ -194,7 +196,8 @@ 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,unsigned int flags); +extern int mp_map_gsi_to_irq (u32 gsi,unsigned int flags, +struct irq_alloc_info *info);extern void mp_unmap_irq (int irq);extern int mp_register_ioapic (int id,u32 address,u32 gsi_base,struct ioapic_domain_cfg *cfg);
@@ -203,6 +206,8 @@ extern int mp_ioapic_registered(u32 gsi_base);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 void ioapic_set_alloc_attr (struct irq_alloc_info *info, +int node,int trigger,int polarity);extern int mp_set_gsi_attr (u32 gsi,int trigger,int polarity,int node);extern void mp_save_irq (struct mpc_intsrc *m);
@@ -253,7 +258,12 @@ static inline void print_IO_APICs(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,unsigned int flags) {return gsi; } +static inline int mp_map_gsi_to_irq (u32 gsi,unsigned int flags, +struct irq_alloc_info *info) +{ +return gsi; +} +static inline void mp_unmap_irq (int irq) { }static inline int save_ioapic_entries (void )
arch/x86/kernel/acpi/boot.c +6 -3
@@ -404,6 +404,7 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) {int irq, node; +struct irq_alloc_info info;if (acpi_irq_model !=ACPI_IRQ_MODEL_IOAPIC )return gsi;
@@ -416,7 +417,8 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,return -1 ; } - irq =mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC ); +ioapic_set_alloc_attr (&info, node, trigger, polarity); + irq =mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC , &info);if (irq <0 )return irq;
@@ -434,7 +436,7 @@ static void mp_unregister_gsi(u32 gsi)if (acpi_irq_model !=ACPI_IRQ_MODEL_IOAPIC )return ; - irq =mp_map_gsi_to_irq (gsi,0 ); + irq =mp_map_gsi_to_irq (gsi,0 ,NULL );if (irq >0 )mp_unmap_irq (irq); }
@@ -618,7 +620,8 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp) }else {mutex_lock (&acpi_ioapic_lock); irq =mp_map_gsi_to_irq (gsi, -IOAPIC_MAP_ALLOC |IOAPIC_MAP_CHECK ); +IOAPIC_MAP_ALLOC |IOAPIC_MAP_CHECK , +NULL );mutex_unlock (&acpi_ioapic_lock);if (irq <0 )return -1 ;
arch/x86/kernel/apic/io_apic.c +26 -13
@@ -938,7 +938,19 @@ static int irq_trigger(int idx)return trigger; } -static int alloc_irq_from_domain (struct irq_domain *domain,u32 gsi,int pin) +void ioapic_set_alloc_attr (struct irq_alloc_info *info,int node, +int trigger,int polarity) +{ +init_irq_alloc_info (info,NULL ); + info->type =X86_IRQ_ALLOC_TYPE_IOAPIC ; + info->ioapic_node = node; + info->ioapic_trigger = trigger; + info->ioapic_polarity = polarity; + info->ioapic_valid =1 ; +} + +static int alloc_irq_from_domain (struct irq_domain *domain,u32 gsi,int pin, +struct irq_alloc_info *info) {int irq =-1 ;int ioapic = (int )(long )domain->host_data;
@@ -971,11 +983,11 @@ static int alloc_irq_from_domain(struct irq_domain *domain, u32 gsi, int pin) }static int mp_map_pin_to_irq (u32 gsi,int idx,int ioapic,int pin, -unsigned int flags) +unsigned int flags,struct irq_alloc_info *info) {int irq;struct irq_domain *domain =mp_ioapic_irqdomain (ioapic); -struct mp_pin_info *info =mp_pin_info (ioapic, pin); +struct mp_pin_info *pinfo =mp_pin_info (ioapic, pin);if (!domain)return -1 ;
@@ -997,30 +1009,30 @@ static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin,if (idx >=0 &&test_bit (mp_irqs[idx].srcbus, mp_bus_not_pci)) { irq = mp_irqs[idx].srcbusirq;if (flags &IOAPIC_MAP_ALLOC ) { -if (info->count ==0 && +if (pinfo->count ==0 &&mp_irqdomain_map (domain, irq, pin) !=0 ) irq =-1 ;/* special handling for timer IRQ0 */ if (irq ==0 ) - info->count++; + pinfo->count++; } }else { irq =irq_find_mapping (domain, pin);if (irq <=0 && (flags &IOAPIC_MAP_ALLOC )) - irq =alloc_irq_from_domain (domain, gsi, pin); + irq =alloc_irq_from_domain (domain, gsi, pin, info); }if (flags &IOAPIC_MAP_ALLOC ) {/* special handling for legacy IRQs */ -if (irq <nr_legacy_irqs () && info->count ==1 && +if (irq <nr_legacy_irqs () && pinfo->count ==1 &&mp_irqdomain_map (domain, irq, pin) !=0 ) irq =-1 ;if (irq >0 ) - info->count++; -else if (info->count ==0 ) - info->set =0 ; + pinfo->count++; +else if (pinfo->count ==0 ) + pinfo->set =0 ; }mutex_unlock (&ioapic_mutex);
@@ -1058,10 +1070,11 @@ static int pin_2_irq(int idx, int ioapic, int pin, unsigned int flags) }#endif -return mp_map_pin_to_irq (gsi, idx, ioapic, pin, flags); +return mp_map_pin_to_irq (gsi, idx, ioapic, pin, flags,NULL ); } -int mp_map_gsi_to_irq (u32 gsi,unsigned int flags) +int mp_map_gsi_to_irq (u32 gsi,unsigned int flags, +struct irq_alloc_info *info) {int ioapic, pin, idx;
@@ -1074,7 +1087,7 @@ int mp_map_gsi_to_irq(u32 gsi, unsigned int flags)if ((flags &IOAPIC_MAP_CHECK ) && idx <0 )return -1 ; -return mp_map_pin_to_irq (gsi, idx, ioapic, pin, flags); +return mp_map_pin_to_irq (gsi, idx, ioapic, pin, flags, info); }void mp_unmap_irq (int irq)
arch/x86/pci/intel_mid_pci.c +3 -1
@@ -208,6 +208,7 @@ static int pci_write(struct pci_bus *bus, unsigned int devfn, int where,static int intel_mid_pci_irq_enable (struct pci_dev *dev) { +struct irq_alloc_info info;int polarity;if (dev->irq_managed && dev->irq >0 )
@@ -217,6 +218,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev) polarity =0 ;/* active high */ else polarity =1 ;/* active low */ +ioapic_set_alloc_attr (&info,dev_to_node (&dev->dev),1 , polarity);/* * MRST only have IOAPIC, the PCI irq lines are 1:1 mapped to
@@ -224,7 +226,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)*/ 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 ) +if (mp_map_gsi_to_irq (dev->irq,IOAPIC_MAP_ALLOC , &info) <0 )return -EBUSY ; dev->irq_managed =1 ;
arch/x86/platform/intel-mid/device_libs/platform_wdt.c +3 -1
@@ -27,6 +27,7 @@ static struct platform_device wdt_dev = {static int tangier_probe (struct platform_device *pdev) {int gsi; +struct irq_alloc_info info;struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;if (!pdata)
@@ -34,8 +35,9 @@ static int tangier_probe(struct platform_device *pdev)/* IOAPIC builds identity mapping between GSI and IRQ on MID */ gsi = pdata->irq; +ioapic_set_alloc_attr (&info,cpu_to_node (0 ),1 ,0 );if (mp_set_gsi_attr (gsi,1 ,0 ,cpu_to_node (0 )) || -mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC ) <=0 ) { +mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC , &info) <=0 ) {dev_warn (&pdev->dev,"cannot find interrupt %d in ioapic\n" , gsi);return -EINVAL ;
arch/x86/platform/intel-mid/sfi.c +6 -3
@@ -104,7 +104,7 @@ int __init sfi_parse_mtmr(struct sfi_table_header *table) mp_irq.dstapic =MP_APIC_ALL ; mp_irq.dstirq = pentry->irq;mp_save_irq (&mp_irq); -mp_map_gsi_to_irq (pentry->irq,IOAPIC_MAP_ALLOC ); +mp_map_gsi_to_irq (pentry->irq,IOAPIC_MAP_ALLOC ,NULL ); }return 0 ;
@@ -175,7 +175,7 @@ int __init sfi_parse_mrtc(struct sfi_table_header *table) mp_irq.dstapic =MP_APIC_ALL ; mp_irq.dstirq = pentry->irq;mp_save_irq (&mp_irq); -mp_map_gsi_to_irq (pentry->irq,IOAPIC_MAP_ALLOC ); +mp_map_gsi_to_irq (pentry->irq,IOAPIC_MAP_ALLOC ,NULL ); }return 0 ; }
@@ -434,6 +434,7 @@ static int __init sfi_parse_devs(struct sfi_table_header *table)struct devs_id *dev =NULL ;int num, i, ret;int polarity; +struct irq_alloc_info info; sb = (struct sfi_table_simple *)table; num = SFI_GET_NUM_ENTRIES(sb, struct sfi_device_table_entry);
@@ -467,9 +468,11 @@ static int __init sfi_parse_devs(struct sfi_table_header *table) polarity =1 ; } +ioapic_set_alloc_attr (&info,NUMA_NO_NODE ,1 , polarity); ret =mp_set_gsi_attr (irq,1 , polarity,NUMA_NO_NODE );if (ret ==0 ) - ret =mp_map_gsi_to_irq (irq,IOAPIC_MAP_ALLOC ); + ret =mp_map_gsi_to_irq (irq,IOAPIC_MAP_ALLOC , + &info);WARN_ON (ret <0 ); }
Signature · 1 line
1.7.10.4
PATCH v3 5/38 x86, irq: Implement callbacks to enable hierarchy irqdomain on IOAPICs
In reply to Jiang LiuImplement required callbacks to prepare for enabling hierarchy irqdomain on IOAPICs. Later we will clean up IOAPIC code a lot by using hierarchy irqdomain framework.
--- arch/x86/include/asm/io_apic.h | 10 +++ arch/x86/kernel/apic/io_apic.c | 159 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 166 insertions(+), 3 deletions(-)
arch/x86/include/asm/io_apic.h +10 -0
@@ -96,6 +96,7 @@ struct IR_IO_APIC_route_entry { } __attribute__ ((packed));struct irq_alloc_info ; +struct irq_data ;#define IOAPIC_AUTO -1#define IOAPIC_EDGE 0
@@ -206,6 +207,15 @@ extern int mp_ioapic_registered(u32 gsi_base);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_irqdomain_alloc (struct irq_domain *domain,unsigned int virq, +unsigned int nr_irqs,void *arg); +extern void mp_irqdomain_free (struct irq_domain *domain,unsigned int virq, +unsigned int nr_irqs); +extern void mp_irqdomain_activate (struct irq_domain *domain, +struct irq_data *irq_data); +extern void mp_irqdomain_deactivate (struct irq_domain *domain, +struct irq_data *irq_data); +extern int mp_irqdomain_ioapic_idx (struct irq_domain *domain);extern void ioapic_set_alloc_attr (struct irq_alloc_info *info,int node,int trigger,int polarity);extern int mp_set_gsi_attr (u32 gsi,int trigger,int polarity,int node);
arch/x86/kernel/apic/io_apic.c +156 -3
196 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 6/38 x86, irq: Refine the way to allocate irq_cfg for legacy IRQs
In reply to Jiang LiuTo support legacy ISA IRQs, we need to preallocate irq_cfg structures for legacy ISA IRQs. Refine the way to allocate irq_cfg for legacy ISA IRQs, so it's more friend to hierarchy irqdomain implementation.
--- arch/x86/kernel/apic/io_apic.c | 13 +------------ arch/x86/kernel/apic/vector.c | 42 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 13 deletions(-)
arch/x86/kernel/apic/io_apic.c +1 -12
@@ -254,8 +254,7 @@ static void free_ioapic_saved_registers(int idx)int __init arch_early_ioapic_init (void ) { -struct irq_cfg *cfg; -int i, node =cpu_to_node (0 ); +int i;if (!nr_legacy_irqs ()) io_apic_irqs = ~0UL ;
@@ -263,16 +262,6 @@ int __init arch_early_ioapic_init(void)for_each_ioapic (i)alloc_ioapic_saved_registers (i); -/* -* For legacy IRQ's, start with assigning irq0 to irq15 to -* IRQ0_VECTOR to IRQ15_VECTOR for all cpu's. -*/ -for (i =0 ; i <nr_legacy_irqs (); i++) { - cfg =alloc_irq_and_cfg_at (i, node); - cfg->vector =IRQ0_VECTOR + i; -cpumask_setall (cfg->domain); - } -return 0 ; }
arch/x86/kernel/apic/vector.c +41 -1
68 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 7/38 x86, irq: Simplify the way to print IOAPIC entry
In reply to Jiang LiuSimplify the way to print IOAPIC entry content, so we could kill native_io_apic_print_entries(), intel_ir_io_apic_print_entries() and x86_io_apic_ops.print_entries() later.
--- arch/x86/kernel/apic/io_apic.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
arch/x86/kernel/apic/io_apic.c +28 -2
@@ -1424,6 +1424,33 @@ void ioapic_zap_locks(void)raw_spin_lock_init (&ioapic_lock); } +static void io_apic_print_entries (unsigned int apic,unsigned int nr_entries) +{ +int i; +char buf[256 ]; +struct IO_APIC_route_entry entry; +struct IR_IO_APIC_route_entry *ir_entry = (void *)&entry; + +printk (KERN_DEBUG "IOAPIC %d:\n" , apic); +for (i =0 ; i <= nr_entries; i++) { + entry =ioapic_read_entry (apic, i); +snprintf (buf,sizeof (buf), +" pin%02x, %s, %s, %s, V(%02X), IRR(%1d), S(%1d)" , + i, entry.mask ?"enabled" :"disabled" , + entry.trigger ?"level" :"edge" , + entry.polarity ?"high" :"low" , + entry.vector, entry.irr, entry.delivery_status); +if (ir_entry->format) +printk (KERN_DEBUG "%s, remapped, I(%04X), Z(%X)\n" , + buf, (ir_entry->index <<15 ) | ir_entry->index, + ir_entry->zero); +else +printk (KERN_DEBUG "%s, %s, D(%02X), M(%1d)\n" , + buf, entry.dest_mode ?"logical" :"physical" , + entry.dest, entry.delivery_mode); + } +} +static void __init print_IO_APIC (int ioapic_idx) {union IO_APIC_reg_00 reg_00;
@@ -1477,8 +1504,7 @@ static void __init print_IO_APIC(int ioapic_idx) }printk (KERN_DEBUG ".... IRQ redirection table:\n" ); - - x86_io_apic_ops.print_entries (ioapic_idx, reg_01.bits.entries); +io_apic_print_entries (ioapic_idx, reg_01.bits.entries); }void __init print_IO_APICs (void )
Signature · 1 line
1.7.10.4
PATCH v3 8/38 x86, irq: Introduce helper functions to support hierarchy irqdomain for IOAPIC
In reply to Jiang LiuIntroduce several helper functions, which will be used to enable hierarchy irqdomain for IOAPIC.
--- arch/x86/kernel/apic/io_apic.c | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
arch/x86/kernel/apic/io_apic.c +59 -0
@@ -67,6 +67,8 @@#define for_each_irq_pin (entry, head) \ list_for_each_entry(entry, &head, list) +int acpi_get_override_irq (u32 gsi,int *trigger,int *polarity); +/* * Is the SiS APIC rmw bug present ? * -1 = don't know, 0 = no, 1 = yes
@@ -82,6 +84,7 @@ struct mp_chip_data {struct IO_APIC_route_entry entry;int trigger;int polarity; +u32 count;bool isa_irq; };
@@ -945,6 +948,42 @@ void ioapic_set_alloc_attr(struct irq_alloc_info *info, int node, info->ioapic_valid =1 ; } +static void ioapic_copy_alloc_attr (struct irq_alloc_info *dst, +struct irq_alloc_info *src, +u32 gsi,int ioapic_idx,int pin) +{ +int trigger, polarity; + +copy_irq_alloc_info (dst, src); + dst->type =X86_IRQ_ALLOC_TYPE_IOAPIC ; + dst->ioapic_id =mpc_ioapic_id (ioapic_idx); + dst->ioapic_pin = pin; + dst->ioapic_valid =1 ; +if (src && src->ioapic_valid) { + dst->ioapic_node = src->ioapic_node; + dst->ioapic_trigger = src->ioapic_trigger; + dst->ioapic_polarity = src->ioapic_polarity; + }else { + dst->ioapic_node =NUMA_NO_NODE ; +if (acpi_get_override_irq (gsi, &trigger, &polarity) >=0 ) { + dst->ioapic_trigger = trigger; + dst->ioapic_polarity = polarity; + }else { +/* +* PCI interrupts are always polarity one level +* triggered. +*/ + dst->ioapic_trigger =1 ; + dst->ioapic_polarity =1 ; + } + } +} + +static int ioapic_alloc_attr_node (struct irq_alloc_info *info) +{ +return (info && info->ioapic_valid) ? info->ioapic_node :NUMA_NO_NODE ; +} +static void mp_register_handler (unsigned int irq,unsigned long trigger) {irq_flow_handler_t hdl;
@@ -962,6 +1001,26 @@ static void mp_register_handler(unsigned int irq, unsigned long trigger)__irq_set_handler (irq, hdl,0 , fasteoi ?"fasteoi" :"edge" ); } +static bool mp_check_pin_attr (int irq,struct irq_alloc_info *info) +{ +struct mp_chip_data *data =irq_get_chip_data (irq); + +/* +* setup_IO_APIC_irqs() programs all legacy IRQs with default trigger +* and polarity attirbutes. So allow the first user to reprogram the +* pin with real trigger and polarity attributes. +*/ +if (irq <nr_legacy_irqs () && data->count ==1 ) { +if (info->ioapic_trigger != data->trigger) +mp_register_handler (irq, data->trigger); + data->entry.trigger = data->trigger = info->ioapic_trigger; + data->entry.polarity = data->polarity = info->ioapic_polarity; + } + +return data->trigger == info->ioapic_trigger && + data->polarity == info->ioapic_polarity; +} +static int alloc_irq_from_domain (struct irq_domain *domain,u32 gsi,int pin,struct irq_alloc_info *info) {
Signature · 1 line
1.7.10.4
PATCH v3 9/38 x86, irq: Convert IOAPIC to use hierarchy irqdomain interfaces
In reply to Jiang LiuConvert IOAPIC driver to support and use hierarchy irqdomain interfaces. It's a little big, but it always break bisectings if we split it into multiple patches.
--- arch/x86/kernel/acpi/boot.c | 11 +- arch/x86/kernel/apic/io_apic.c | 301 +++++++++++++------- arch/x86/kernel/devicetree.c | 37 +-- arch/x86/kernel/mpparse.c | 6 +- arch/x86/pci/intel_mid_pci.c | 2 - .../platform/intel-mid/device_libs/platform_wdt.c | 3 +- arch/x86/platform/intel-mid/sfi.c | 5 +- arch/x86/platform/sfi/sfi.c | 5 +- 8 files changed, 234 insertions(+), 136 deletions(-)
arch/x86/kernel/acpi/boot.c +4 -7
@@ -412,11 +412,6 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger, 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 ; - } -ioapic_set_alloc_attr (&info, node, trigger, polarity); irq =mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC , &info);if (irq <0 )
@@ -442,8 +437,10 @@ static void mp_unregister_gsi(u32 gsi) }static struct irq_domain_ops acpi_irqdomain_ops = { - .map = mp_irqdomain_map, - .unmap = mp_irqdomain_unmap, + .alloc = mp_irqdomain_alloc, + .free = mp_irqdomain_free, + .activate = mp_irqdomain_activate, + .deactivate = mp_irqdomain_deactivate, }; static int __init
arch/x86/kernel/apic/io_apic.c +205 -96
477 lines not on this page · raw message
arch/x86/kernel/devicetree.c +15 -22
@@ -196,38 +196,31 @@ static struct of_ioapic_type of_ioapic_type[] = }, }; -static int ioapic_xlate (struct irq_domain *domain, -struct device_node *controller, -const u32 *intspec,u32 intsize, -irq_hw_number_t *out_hwirq,u32 *out_type) +static int dt_irqdomain_alloc (struct irq_domain *domain,unsigned int virq, +unsigned int nr_irqs,void *arg) { +struct of_phandle_args *irq_data = (void *)arg;struct of_ioapic_type *it; -u32 line, idx, gsi; +struct irq_alloc_info tmp; -if (WARN_ON (intsize <2 )) +if (WARN_ON (irq_data->args_count <2 ))return -EINVAL ; - - line = intspec[0 ]; - -if (intspec[1 ] >=ARRAY_SIZE (of_ioapic_type)) +if (irq_data->args[1 ] >=ARRAY_SIZE (of_ioapic_type))return -EINVAL ; - it = &of_ioapic_type[intspec[1 ]]; + it = &of_ioapic_type[irq_data->args[1 ]]; +ioapic_set_alloc_attr (&tmp,NUMA_NO_NODE , it->trigger, it->polarity); + tmp.ioapic_id =mpc_ioapic_id (mp_irqdomain_ioapic_idx (domain)); + tmp.ioapic_pin = irq_data->args[0 ]; - idx = (u32 )(long )domain->host_data; - 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; -return 0 ; +return mp_irqdomain_alloc (domain, virq, nr_irqs, &tmp); }const struct irq_domain_ops ioapic_irq_domain_ops = { - .map = mp_irqdomain_map, - .unmap = mp_irqdomain_unmap, - .xlate = ioapic_xlate, + .alloc = dt_irqdomain_alloc, + .free = mp_irqdomain_free, + .activate = mp_irqdomain_activate, + .deactivate = mp_irqdomain_deactivate, };static void __init dtb_add_ioapic (struct device_node *dn)
arch/x86/kernel/mpparse.c +4 -2
@@ -114,8 +114,10 @@ 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, + .alloc = mp_irqdomain_alloc, + .free = mp_irqdomain_free, + .activate = mp_irqdomain_activate, + .deactivate = mp_irqdomain_deactivate, };static void __init MP_ioapic_info (struct mpc_ioapic *m)
arch/x86/pci/intel_mid_pci.c +0 -2
@@ -224,8 +224,6 @@ 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_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 , &info) <0 )return -EBUSY ;
arch/x86/platform/intel-mid/device_libs/platform_wdt.c +1 -2
@@ -36,8 +36,7 @@ static int tangier_probe(struct platform_device *pdev)/* IOAPIC builds identity mapping between GSI and IRQ on MID */ gsi = pdata->irq;ioapic_set_alloc_attr (&info,cpu_to_node (0 ),1 ,0 ); -if (mp_set_gsi_attr (gsi,1 ,0 ,cpu_to_node (0 )) || -mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC , &info) <=0 ) { +if (mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC , &info) <=0 ) {dev_warn (&pdev->dev,"cannot find interrupt %d in ioapic\n" , gsi);return -EINVAL ;
arch/x86/platform/intel-mid/sfi.c +1 -4
@@ -469,10 +469,7 @@ static int __init sfi_parse_devs(struct sfi_table_header *table) }ioapic_set_alloc_attr (&info,NUMA_NO_NODE ,1 , polarity); - ret =mp_set_gsi_attr (irq,1 , polarity,NUMA_NO_NODE ); -if (ret ==0 ) - ret =mp_map_gsi_to_irq (irq,IOAPIC_MAP_ALLOC , - &info); + ret =mp_map_gsi_to_irq (irq,IOAPIC_MAP_ALLOC , &info);WARN_ON (ret <0 ); }
arch/x86/platform/sfi/sfi.c +4 -1
@@ -72,7 +72,10 @@ static int __init sfi_parse_cpus(struct sfi_table_header *table)#ifdef CONFIG_X86_IO_APIC static struct irq_domain_ops sfi_ioapic_irqdomain_ops = { - .map = mp_irqdomain_map, + .alloc = mp_irqdomain_alloc, + .free = mp_irqdomain_free, + .activate = mp_irqdomain_activate, + .deactivate = mp_irqdomain_deactivate, };static int __init sfi_parse_ioapic (struct sfi_table_header *table)
Signature · 1 line
1.7.10.4
PATCH v3 10/38 x86, irq: Kill unused old IOAPIC irqdomain interfaces
In reply to Jiang LiuNow we have converted to hierarchy irqdomain, so kill unused old IOAPIC irqdomain interfaces and code.
--- arch/x86/include/asm/io_apic.h | 4 - arch/x86/kernel/apic/io_apic.c | 202 +--------------------------------------- 2 files changed, 1 insertion(+), 205 deletions(-)
arch/x86/include/asm/io_apic.h +0 -4
@@ -204,9 +204,6 @@ extern int mp_register_ioapic(int id, u32 address, u32 gsi_base, struct ioapic_domain_cfg *cfg);extern int mp_unregister_ioapic (u32 gsi_base);extern int mp_ioapic_registered (u32 gsi_base); -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_irqdomain_alloc (struct irq_domain *domain,unsigned int virq,unsigned int nr_irqs,void *arg); extern void mp_irqdomain_free(struct irq_domain *domain, unsigned int virq,
@@ -218,7 +215,6 @@ extern void mp_irqdomain_deactivate(struct irq_domain *domain,extern int mp_irqdomain_ioapic_idx (struct irq_domain *domain);extern void ioapic_set_alloc_attr (struct irq_alloc_info *info,int node,int trigger,int polarity); -extern int mp_set_gsi_attr (u32 gsi,int trigger,int polarity,int node);extern void mp_save_irq (struct mpc_intsrc *m);
arch/x86/kernel/apic/io_apic.c +1 -201
245 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 11/38 x86, irq: Kill unused struct mp_pin_info
In reply to Jiang LiuNow nobody makes use of struct mp_pin_info, so kill it.
--- arch/x86/kernel/apic/io_apic.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-)
arch/x86/kernel/apic/io_apic.c +3 -27
@@ -88,13 +88,6 @@ struct mp_chip_data {bool isa_irq; }; -struct mp_pin_info { -int trigger; -int polarity; -int set; -u32 count; -}; - static struct ioapic { /* * # of IRQ routing registers
@@ -110,7 +103,6 @@ static struct ioapic {struct mp_ioapic_gsi gsi_config;struct ioapic_domain_cfg irqdomain_cfg;struct irq_domain *irqdomain; -struct mp_pin_info *pin_info;struct resource *iomem_res; } ioapics[MAX_IO_APICS ];
@@ -156,11 +148,6 @@ static inline int mp_init_irq_at_boot(int ioapic, int irq)return ioapic ==0 || (irq >=0 && irq <nr_legacy_irqs ()); } -static inline struct mp_pin_info *mp_pin_info (int ioapic_idx,int pin) -{ -return ioapics[ioapic_idx].pin_info + pin; -} -static inline struct irq_domain *mp_ioapic_irqdomain (int ioapic) {return ioapics[ioapic].irqdomain;
@@ -2422,7 +2409,6 @@ out:static int mp_irqdomain_create (int ioapic) { -size_t size;struct irq_alloc_info info;struct irq_domain *parent;int hwirqs =mp_ioapic_pin_count (ioapic);
@@ -2430,11 +2416,6 @@ static int mp_irqdomain_create(int ioapic)struct ioapic_domain_cfg *cfg = &ip->irqdomain_cfg;struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (ioapic); - size =sizeof (struct mp_pin_info ) *mp_ioapic_pin_count (ioapic); - ip->pin_info =kzalloc (size,GFP_KERNEL ); -if (!ip->pin_info) -return -ENOMEM ; -if (cfg->type ==IOAPIC_DOMAIN_INVALID )return 0 ;
@@ -2447,13 +2428,10 @@ static int mp_irqdomain_create(int ioapic) ip->irqdomain =irq_domain_add_linear (cfg->dev, hwirqs, cfg->ops, (void *)(long )ioapic); -if (ip->irqdomain) { - ip->irqdomain->parent = parent; - }else { -kfree (ip->pin_info); - ip->pin_info =NULL ; +if (!ip->irqdomain)return -ENOMEM ; - } + + ip->irqdomain->parent = parent;if (cfg->type ==IOAPIC_DOMAIN_LEGACY || cfg->type ==IOAPIC_DOMAIN_STRICT )
@@ -2469,8 +2447,6 @@ static void ioapic_destroy_irqdomain(int idx)irq_domain_remove (ioapics[idx].irqdomain); ioapics[idx].irqdomain =NULL ; } -kfree (ioapics[idx].pin_info); - ioapics[idx].pin_info =NULL ; }void __init setup_IO_APIC (void )
Signature · 1 line
1.7.10.4
PATCH v3 12/38 x86, irq: Kill x86_io_apic_ops.print_entries and related interfaces
In reply to Jiang LiuNow there is no user of x86_io_apic_ops.print_entries anymore, so kill it.
--- arch/x86/include/asm/io_apic.h | 3 -- arch/x86/include/asm/x86_init.h | 1 - arch/x86/kernel/apic/io_apic.c | 55 ----------------------------------- arch/x86/kernel/x86_init.c | 1 - drivers/iommu/intel_irq_remapping.c | 7 ----- 5 files changed, 67 deletions(-)
arch/x86/include/asm/io_apic.h +0 -3
@@ -225,8 +225,6 @@ extern unsigned int native_io_apic_read(unsigned int apic, unsigned int reg);extern void native_io_apic_write (unsigned int apic,unsigned int reg,unsigned int val);extern void native_io_apic_modify (unsigned int apic,unsigned int reg,unsigned int val);extern void native_disable_io_apic (void ); -extern void native_io_apic_print_entries (unsigned int apic,unsigned int nr_entries); -extern void intel_ir_io_apic_print_entries (unsigned int apic,unsigned int nr_entries);extern int native_ioapic_set_affinity (struct irq_data *,const struct cpumask *,bool );
@@ -290,7 +288,6 @@ static inline void disable_ioapic_support(void) { }#define native_io_apic_write NULL#define native_io_apic_modify NULL#define native_disable_io_apic NULL -#define native_io_apic_print_entries NULL#define native_ioapic_set_affinity NULL#define native_setup_ioapic_entry NULL#define native_eoi_ioapic_pin NULL
arch/x86/include/asm/x86_init.h +0 -1
@@ -194,7 +194,6 @@ struct x86_io_apic_ops {void (*write) (unsigned int apic,unsigned int reg,unsigned int value);void (*modify) (unsigned int apic,unsigned int reg,unsigned int value);void (*disable)(void ); -void (*print_entries)(unsigned int apic,unsigned int nr_entries);int (*set_affinity)(struct irq_data *data,const struct cpumask *mask,bool force);
arch/x86/kernel/apic/io_apic.c +0 -55
61 lines not on this page · raw message
arch/x86/kernel/x86_init.c +0 -1
@@ -154,7 +154,6 @@ struct x86_io_apic_ops x86_io_apic_ops = { .write = native_io_apic_write, .modify = native_io_apic_modify, .disable = native_disable_io_apic, - .print_entries = native_io_apic_print_entries, .set_affinity = native_ioapic_set_affinity, .setup_entry = native_setup_ioapic_entry, .eoi_ioapic_pin = native_eoi_ioapic_pin,
drivers/iommu/intel_irq_remapping.c +0 -7
@@ -660,13 +660,6 @@ static int __init intel_enable_irq_remapping(void) irq_remapping_enabled =1 ; -/* -* VT-d has a different layout for IO-APIC entries when -* interrupt remapping is enabled. So it needs a special routine -* to print IO-APIC entries for debugging purposes too. -*/ - x86_io_apic_ops.print_entries = intel_ir_io_apic_print_entries; -pr_info ("Enabled IRQ remapping in %s mode\n" , eim ?"x2apic" :"xapic" );return eim ?IRQ_REMAP_X2APIC_MODE :IRQ_REMAP_XAPIC_MODE ;
Signature · 1 line
1.7.10.4
PATCH v3 13/38 x86, irq: Kill x86_io_apic_ops.setup_entry and related interfaces
In reply to Jiang LiuNow there is no user of x86_io_apic_ops.setup_entry anymore, so kill it.
--- arch/x86/include/asm/io_apic.h | 4 ---- arch/x86/include/asm/irq_remapping.h | 13 ------------- arch/x86/include/asm/x86_init.h | 3 --- arch/x86/kernel/apic/io_apic.c | 24 ------------------------ arch/x86/kernel/x86_init.c | 1 - drivers/iommu/irq_remapping.c | 13 ------------- 6 files changed, 58 deletions(-)
arch/x86/include/asm/io_apic.h +0 -4
@@ -150,9 +150,6 @@ struct irq_cfg;extern void ioapic_insert_resources (void );extern int arch_early_ioapic_init (void ); -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_eoi_ioapic_pin (int apic,int pin,int vector);
@@ -289,7 +286,6 @@ static inline void disable_ioapic_support(void) { }#define native_io_apic_modify NULL#define native_disable_io_apic NULL#define native_ioapic_set_affinity NULL -#define native_setup_ioapic_entry NULL#define native_eoi_ioapic_pin NULL#endif
arch/x86/include/asm/irq_remapping.h +0 -13
@@ -44,11 +44,6 @@ extern int irq_remapping_enable(void);extern void irq_remapping_disable (void );extern int irq_remapping_reenable (int );extern int irq_remap_enable_fault_handling (void ); -extern int setup_ioapic_remapped_entry (int irq, -struct IO_APIC_route_entry *entry, -unsigned int destination, -int vector, -struct io_apic_irq_attr *attr);extern void free_remapped_irq (int irq);extern void panic_if_irq_remap (const char *msg); extern bool setup_remapped_irq(int irq,
@@ -85,14 +80,6 @@ static inline int irq_remapping_enable(void) { return -ENODEV; }static inline void irq_remapping_disable (void ) { }static inline int irq_remapping_reenable (int eim) {return -ENODEV ; }static inline int irq_remap_enable_fault_handling (void ) {return -ENODEV ; } -static inline int setup_ioapic_remapped_entry (int irq, -struct IO_APIC_route_entry *entry, -unsigned int destination, -int vector, -struct io_apic_irq_attr *attr) -{ -return -ENODEV ; -}static inline void free_remapped_irq (int irq) { }static inline void panic_if_irq_remap (const char *msg)
arch/x86/include/asm/x86_init.h +0 -3
@@ -197,9 +197,6 @@ struct x86_io_apic_ops {int (*set_affinity)(struct irq_data *data,const struct cpumask *mask,bool force); -int (*setup_entry)(int irq,struct IO_APIC_route_entry *entry, -unsigned int destination,int vector, -struct io_apic_irq_attr *attr);void (*eoi_ioapic_pin)(int apic,int pin,int vector); };
arch/x86/kernel/apic/io_apic.c +0 -24
@@ -1289,30 +1289,6 @@ static inline int IO_APIC_irq_trigger(int irq) }#endif -int native_setup_ioapic_entry (int irq,struct IO_APIC_route_entry *entry, -unsigned int destination,int vector, -struct io_apic_irq_attr *attr) -{ -memset (entry,0 ,sizeof (*entry)); - - entry->delivery_mode = apic->irq_delivery_mode; - entry->dest_mode = apic->irq_dest_mode; - entry->dest = destination; - entry->vector = vector; - entry->mask =0 ;/* enable IRQ */ - entry->trigger = attr->trigger; - entry->polarity = attr->polarity; - -/* -* Mask level triggered irqs. -* Use IRQ_DELAYED_DISABLE for edge triggered irqs. -*/ -if (attr->trigger) - entry->mask =1 ; - -return 0 ; -} -static void __init setup_IO_APIC_irqs (void ) {unsigned int ioapic, pin;
arch/x86/kernel/x86_init.c +0 -1
@@ -155,6 +155,5 @@ struct x86_io_apic_ops x86_io_apic_ops = { .modify = native_io_apic_modify, .disable = native_disable_io_apic, .set_affinity = native_ioapic_set_affinity, - .setup_entry = native_setup_ioapic_entry, .eoi_ioapic_pin = native_eoi_ioapic_pin, };
drivers/iommu/irq_remapping.c +0 -13
@@ -63,7 +63,6 @@ static void __init irq_remapping_modify_x86_ops(void) { x86_io_apic_ops.disable = irq_remapping_disable_io_apic; x86_io_apic_ops.set_affinity = set_remapped_irq_affinity; - x86_io_apic_ops.setup_entry = setup_ioapic_remapped_entry; x86_io_apic_ops.eoi_ioapic_pin = eoi_ioapic_pin_remapped; }
@@ -178,18 +177,6 @@ int __init irq_remap_enable_fault_handling(void)return remap_ops->enable_faulting (); } -int setup_ioapic_remapped_entry (int irq, -struct IO_APIC_route_entry *entry, -unsigned int destination,int vector, -struct io_apic_irq_attr *attr) -{ -if (!remap_ops || !remap_ops->setup_ioapic_entry) -return -ENODEV ; - -return remap_ops->setup_ioapic_entry (irq, entry, destination, - vector, attr); -} -static int set_remapped_irq_affinity (struct irq_data *data,const struct cpumask *mask,bool force) {
Signature · 1 line
1.7.10.4
PATCH v3 14/38 x86, irq: Kill x86_io_apic_ops.set_affinity and related interfaces
In reply to Jiang LiuNow there is no user of x86_io_apic_ops.set_affinity anymore, so kill it.
--- arch/x86/include/asm/io_apic.h | 4 ---- arch/x86/include/asm/x86_init.h | 3 --- arch/x86/kernel/apic/io_apic.c | 25 +------------------------ arch/x86/kernel/x86_init.c | 1 - drivers/iommu/irq_remapping.c | 16 ---------------- 5 files changed, 1 insertion(+), 48 deletions(-)
arch/x86/include/asm/io_apic.h +0 -4
@@ -222,9 +222,6 @@ extern unsigned int native_io_apic_read(unsigned int apic, unsigned int reg);extern void native_io_apic_write (unsigned int apic,unsigned int reg,unsigned int val);extern void native_io_apic_modify (unsigned int apic,unsigned int reg,unsigned int val);extern void native_disable_io_apic (void ); -extern int native_ioapic_set_affinity (struct irq_data *, -const struct cpumask *, -bool );static inline unsigned int io_apic_read (unsigned int apic,unsigned int reg) {
@@ -285,7 +282,6 @@ static inline void disable_ioapic_support(void) { }#define native_io_apic_write NULL#define native_io_apic_modify NULL#define native_disable_io_apic NULL -#define native_ioapic_set_affinity NULL#define native_eoi_ioapic_pin NULL#endif
arch/x86/include/asm/x86_init.h +0 -3
@@ -194,9 +194,6 @@ struct x86_io_apic_ops {void (*write) (unsigned int apic,unsigned int reg,unsigned int value);void (*modify) (unsigned int apic,unsigned int reg,unsigned int value);void (*disable)(void ); -int (*set_affinity)(struct irq_data *data, -const struct cpumask *mask, -bool force);void (*eoi_ioapic_pin)(int apic,int pin,int vector); };
arch/x86/kernel/apic/io_apic.c +1 -24
@@ -1777,29 +1777,6 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq } } -int native_ioapic_set_affinity (struct irq_data *data, -const struct cpumask *mask, -bool force) -{ -unsigned int dest, irq = data->irq; -unsigned long flags; -int ret; - -if (!config_enabled (CONFIG_SMP )) -return -EPERM ; - -raw_spin_lock_irqsave (&ioapic_lock, flags); - ret =apic_set_affinity (data, mask, &dest); -if (!ret) { -/* Only the high 8 bits are valid. */ - dest =SET_APIC_LOGICAL_ID (dest); -__target_IO_APIC_irq (irq, dest,irqd_cfg (data)); - ret =IRQ_SET_MASK_OK_NOCOPY ; - } -raw_spin_unlock_irqrestore (&ioapic_lock, flags); -return ret; -} -atomic_t irq_mis_count;#ifdef CONFIG_GENERIC_PENDING_IRQ
@@ -2676,7 +2653,7 @@ void __init setup_ioapic_dest(void)else mask = apic->target_cpus (); - x86_io_apic_ops.set_affinity (idata, mask, false); +irq_set_affinity (irq, mask); } }
arch/x86/kernel/x86_init.c +0 -1
@@ -154,6 +154,5 @@ struct x86_io_apic_ops x86_io_apic_ops = { .write = native_io_apic_write, .modify = native_io_apic_modify, .disable = native_disable_io_apic, - .set_affinity = native_ioapic_set_affinity, .eoi_ioapic_pin = native_eoi_ioapic_pin, };
drivers/iommu/irq_remapping.c +0 -16
@@ -26,10 +26,6 @@ int no_x2apic_optout;static struct irq_remap_ops *remap_ops; -static int set_remapped_irq_affinity (struct irq_data *data, -const struct cpumask *mask, -bool force); -static bool irq_remapped (struct irq_cfg *cfg) {return (cfg->remapped ==1 );
@@ -62,7 +58,6 @@ static void eoi_ioapic_pin_remapped(int apic, int pin, int vector)static void __init irq_remapping_modify_x86_ops (void ) { x86_io_apic_ops.disable = irq_remapping_disable_io_apic; - x86_io_apic_ops.set_affinity = set_remapped_irq_affinity; x86_io_apic_ops.eoi_ioapic_pin = eoi_ioapic_pin_remapped; }
@@ -177,16 +172,6 @@ int __init irq_remap_enable_fault_handling(void)return remap_ops->enable_faulting (); } -static int set_remapped_irq_affinity (struct irq_data *data, -const struct cpumask *mask,bool force) -{ -if (!config_enabled (CONFIG_SMP ) || !remap_ops || - !remap_ops->set_affinity) -return 0 ; - -return remap_ops->set_affinity (data, mask, force); -} -void free_remapped_irq (int irq) {struct irq_cfg *cfg =irq_cfg (irq);
@@ -238,7 +223,6 @@ void irq_remap_modify_chip_defaults(struct irq_chip *chip) chip->irq_print_chip = ir_print_prefix; chip->irq_ack = ir_ack_apic_edge; chip->irq_eoi = ir_ack_apic_level; - chip->irq_set_affinity = x86_io_apic_ops.set_affinity; }bool setup_remapped_irq (int irq,struct irq_cfg *cfg,struct irq_chip *chip)
Signature · 1 line
1.7.10.4
PATCH v3 15/38 x86, irq: Kill x86_io_apic_ops.eoi_ioapic_pin and related interfaces
In reply to Jiang LiuNow there is no user of x86_io_apic_ops.eoi_ioapic_pin anymore, so kill it.
--- arch/x86/include/asm/io_apic.h | 7 ------- arch/x86/include/asm/x86_init.h | 1 - arch/x86/kernel/apic/io_apic.c | 20 ++++---------------- arch/x86/kernel/x86_init.c | 1 - drivers/iommu/irq_remapping.c | 19 ------------------- 5 files changed, 4 insertions(+), 44 deletions(-)
arch/x86/include/asm/io_apic.h +0 -7
@@ -150,10 +150,6 @@ struct irq_cfg;extern void ioapic_insert_resources (void );extern int arch_early_ioapic_init (void ); -extern void eoi_ioapic_irq (unsigned int irq,struct irq_cfg *cfg); - -extern void native_eoi_ioapic_pin (int apic,int pin,int vector); -extern int save_ioapic_entries (void );extern void mask_ioapic_entries (void );extern int restore_ioapic_entries (void );
@@ -237,8 +233,6 @@ static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned x86_io_apic_ops.modify (apic, reg, value); } -extern void io_apic_eoi (unsigned int apic,unsigned int vector); -extern void setup_IO_APIC (void );extern void enable_IO_APIC (void );extern void disable_IO_APIC (void );
@@ -282,7 +276,6 @@ static inline void disable_ioapic_support(void) { }#define native_io_apic_write NULL#define native_io_apic_modify NULL#define native_disable_io_apic NULL -#define native_eoi_ioapic_pin NULL#endif #endif /* _ASM_X86_IO_APIC_H */
arch/x86/include/asm/x86_init.h +0 -1
@@ -194,7 +194,6 @@ struct x86_io_apic_ops {void (*write) (unsigned int apic,unsigned int reg,unsigned int value);void (*modify) (unsigned int apic,unsigned int reg,unsigned int value);void (*disable)(void ); -void (*eoi_ioapic_pin)(int apic,int pin,int vector); };extern struct x86_init_ops x86_init;
arch/x86/kernel/apic/io_apic.c +4 -16
@@ -268,7 +268,7 @@ static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx) + (mpc_ioapic_addr (idx) & ~PAGE_MASK ); } -void io_apic_eoi (unsigned int apic,unsigned int vector) +static inline void io_apic_eoi (unsigned int apic,unsigned int vector) {struct io_apic __iomem *io_apic =io_apic_base (apic);writel (vector, &io_apic->eoi);
@@ -524,7 +524,7 @@ static void unmask_ioapic_irq(struct irq_data *data)* Otherwise, we simulate the EOI message manually by changing the trigger * mode to edge and then back to level, with RTE being masked during this. */ -void native_eoi_ioapic_pin (int apic,int pin,int vector) +static void __eoi_ioapic_pin (int apic,int pin,int vector) {if (mpc_ioapic_ver (apic) >=0x20 ) {io_apic_eoi (apic, vector);
@@ -555,19 +555,7 @@ void eoi_ioapic_pin(int vector, struct irq_cfg *cfg)raw_spin_lock_irqsave (&ioapic_lock, flags);for_each_irq_pin (entry, cfg->irq_2_pin) -native_eoi_ioapic_pin (entry->apic, entry->pin, vector); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); -} - -void eoi_ioapic_irq (unsigned int irq,struct irq_cfg *cfg) -{ -struct irq_pin_list *entry; -unsigned long flags; - -raw_spin_lock_irqsave (&ioapic_lock, flags); -for_each_irq_pin (entry, cfg->irq_2_pin) - x86_io_apic_ops.eoi_ioapic_pin (entry->apic, entry->pin, - cfg->vector); +__eoi_ioapic_pin (entry->apic, entry->pin, vector);raw_spin_unlock_irqrestore (&ioapic_lock, flags); }
@@ -603,7 +591,7 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)ioapic_write_entry (apic, pin, entry); }raw_spin_lock_irqsave (&ioapic_lock, flags); -native_eoi_ioapic_pin (apic, pin, entry.vector); +__eoi_ioapic_pin (apic, pin, entry.vector);raw_spin_unlock_irqrestore (&ioapic_lock, flags); }
arch/x86/kernel/x86_init.c +0 -1
@@ -154,5 +154,4 @@ struct x86_io_apic_ops x86_io_apic_ops = { .write = native_io_apic_write, .modify = native_io_apic_modify, .disable = native_disable_io_apic, - .eoi_ioapic_pin = native_eoi_ioapic_pin, };
drivers/iommu/irq_remapping.c +0 -19
@@ -44,21 +44,9 @@ static void irq_remapping_disable_io_apic(void)disconnect_bsp_APIC (0 ); } -static void eoi_ioapic_pin_remapped (int apic,int pin,int vector) -{ -/* -* Intr-remapping uses pin number as the virtual vector -* in the RTE. Actual vector is programmed in -* intr-remapping table entry. Hence for the io-apic -* EOI we use the pin number. -*/ -io_apic_eoi (apic, pin); -} -static void __init irq_remapping_modify_x86_ops (void ) { x86_io_apic_ops.disable = irq_remapping_disable_io_apic; - x86_io_apic_ops.eoi_ioapic_pin = eoi_ioapic_pin_remapped; }static __init int setup_nointremap (char *str)
@@ -194,12 +182,6 @@ void ir_ack_apic_edge(struct irq_data *data)ack_APIC_irq (); } -static void ir_ack_apic_level (struct irq_data *data) -{ -ack_APIC_irq (); -eoi_ioapic_irq (data->irq,irqd_cfg (data)); -} -void irq_remapping_print_chip (struct irq_data *data,struct seq_file *p) {/*
@@ -222,7 +204,6 @@ void irq_remap_modify_chip_defaults(struct irq_chip *chip) { chip->irq_print_chip = ir_print_prefix; chip->irq_ack = ir_ack_apic_edge; - chip->irq_eoi = ir_ack_apic_level; }bool setup_remapped_irq (int irq,struct irq_cfg *cfg,struct irq_chip *chip)
Signature · 1 line
1.7.10.4
PATCH v3 16/38 x86, irq: Kill GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
In reply to Jiang LiuThere's no user of irq_alloc_hwirqs(), irq_alloc_hwirq(), irq_free_hwirqs() and irq_free_hwirq() anymore, so kill GENERIC_IRQ_LEGACY_ALLOC_HWIRQ and related code.
--- arch/x86/Kconfig | 1 - arch/x86/kernel/apic/vector.c | 34 ---------------------------------- 2 files changed, 35 deletions(-)
arch/x86/Kconfig +0 -1
@@ -882,7 +882,6 @@ config X86_UP_IOAPIC config X86_LOCAL_APIC def_bool y depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC || PCI_MSI - select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ select IRQ_DOMAIN select IRQ_DOMAIN_HIERARCHY select PCI_MSI_IRQ_DOMAIN if PCI_MSI
arch/x86/kernel/apic/vector.c +0 -34
@@ -660,40 +660,6 @@ void irq_force_complete_move(int irq) }#endif -/* -* Dynamic irq allocate and deallocation. Should be replaced by irq domains! -*/ -int arch_setup_hwirq (unsigned int irq,int node) -{ -struct irq_cfg *cfg; -unsigned long flags; -int ret; - - cfg =alloc_irq_cfg (node); -if (!cfg) -return -ENOMEM ; - -raw_spin_lock_irqsave (&vector_lock, flags); - ret =__assign_irq_vector (irq, cfg, apic->target_cpus ()); -raw_spin_unlock_irqrestore (&vector_lock, flags); - -if (!ret) -irq_set_chip_data (irq, cfg); -else -free_irq_cfg (cfg); -return ret; -} - -void arch_teardown_hwirq (unsigned int irq) -{ -struct irq_cfg *cfg =irq_cfg (irq); - -free_remapped_irq (irq); -clear_irq_vector (irq, cfg); -irq_set_chip_data (irq,NULL ); -free_irq_cfg (cfg); -} -static void __init print_APIC_field (int base) {int i;
Signature · 1 line
1.7.10.4
PATCH v3 17/38 x86: Clean up unused forward declarations in x86_init.h
In reply to Jiang Liu--- arch/x86/include/asm/x86_init.h | 6 ------ 1 file changed, 6 deletions(-)
arch/x86/include/asm/x86_init.h +0 -6
@@ -171,7 +171,6 @@ struct x86_platform_ops { };struct pci_dev ; -struct msi_msg ;struct msi_desc ;struct x86_msi_ops {
@@ -183,11 +182,6 @@ struct x86_msi_ops {u32 (*msix_mask_irq)(struct msi_desc *desc,u32 flag); }; -struct IO_APIC_route_entry ; -struct io_apic_irq_attr ; -struct irq_data ; -struct cpumask ; -struct x86_io_apic_ops {void (*init) (void );unsigned int (*read) (unsigned int apic,unsigned int reg);
Signature · 1 line
1.7.10.4
PATCH v3 18/38 x86: irq_remapping: Clean up unsued code
In reply to Jiang LiuNow we have converted to hierarchy irqdomain, so clean up unused code.
--- arch/x86/include/asm/irq_remapping.h | 23 ---------------------- arch/x86/kernel/apic/vector.c | 1 - drivers/iommu/irq_remapping.c | 36 ---------------------------------- 3 files changed, 60 deletions(-)
arch/x86/include/asm/irq_remapping.h +0 -23
@@ -26,12 +26,7 @@#include <asm/hw_irq.h> #include <asm/io_apic.h> -struct IO_APIC_route_entry ; -struct io_apic_irq_attr ; -struct irq_chip ;struct msi_msg ; -struct pci_dev ; -struct irq_cfg ;struct irq_alloc_info ;#ifdef CONFIG_IRQ_REMAP
@@ -44,13 +39,7 @@ extern int irq_remapping_enable(void);extern void irq_remapping_disable (void );extern int irq_remapping_reenable (int );extern int irq_remap_enable_fault_handling (void ); -extern void free_remapped_irq (int irq);extern void panic_if_irq_remap (const char *msg); -extern bool setup_remapped_irq (int irq, -struct irq_cfg *cfg, -struct irq_chip *chip); - -void irq_remap_modify_chip_defaults (struct irq_chip *chip);extern struct irq_domain *irq_remapping_get_ir_irq_domain (struct irq_alloc_info *info);
@@ -80,23 +69,11 @@ static inline int irq_remapping_enable(void) { return -ENODEV; }static inline void irq_remapping_disable (void ) { }static inline int irq_remapping_reenable (int eim) {return -ENODEV ; }static inline int irq_remap_enable_fault_handling (void ) {return -ENODEV ; } -static inline void free_remapped_irq (int irq) { }static inline void panic_if_irq_remap (const char *msg) { } -static inline void irq_remap_modify_chip_defaults (struct irq_chip *chip) -{ -} - -static inline bool setup_remapped_irq (int irq, -struct irq_cfg *cfg, -struct irq_chip *chip) -{ -return false; -} -static inline struct irq_domain *irq_remapping_get_ir_irq_domain (struct irq_alloc_info *info) {
arch/x86/kernel/apic/vector.c +0 -1
@@ -283,7 +283,6 @@ static void x86_vector_free_irqs(struct irq_domain *domain,for (i =0 ; i < nr_irqs; i++) { irq_data =irq_domain_get_irq_data (x86_vector_domain, virq + i);if (irq_data && irq_data->chip_data) { -free_remapped_irq (virq);clear_irq_vector (virq + i, irq_data->chip_data);free_irq_cfg (irq_data->chip_data);#ifdef CONFIG_X86_IO_APIC
drivers/iommu/irq_remapping.c +0 -36
@@ -26,11 +26,6 @@ int no_x2apic_optout;static struct irq_remap_ops *remap_ops; -static bool irq_remapped (struct irq_cfg *cfg) -{ -return (cfg->remapped ==1 ); -} -static void irq_remapping_disable_io_apic (void ) {/*
@@ -160,17 +155,6 @@ int __init irq_remap_enable_fault_handling(void)return remap_ops->enable_faulting (); } -void free_remapped_irq (int irq) -{ -struct irq_cfg *cfg =irq_cfg (irq); - -if (!remap_ops || !remap_ops->free_irq) -return ; - -if (irq_remapped (cfg)) - remap_ops->free_irq (irq); -} -void panic_if_irq_remap (const char *msg) {if (irq_remapping_enabled)
@@ -195,26 +179,6 @@ void irq_remapping_print_chip(struct irq_data *data, struct seq_file *p)seq_printf (p," %s" , data->chip->name); } -static void ir_print_prefix (struct irq_data *data,struct seq_file *p) -{ -seq_printf (p," IR-%s" , data->chip->name); -} - -void irq_remap_modify_chip_defaults (struct irq_chip *chip) -{ - chip->irq_print_chip = ir_print_prefix; - chip->irq_ack = ir_ack_apic_edge; -} - -bool setup_remapped_irq (int irq,struct irq_cfg *cfg,struct irq_chip *chip) -{ -if (!irq_remapped (cfg)) -return false; -irq_set_status_flags (irq,IRQ_MOVE_PCNTXT ); -irq_remap_modify_chip_defaults (chip); -return true; -} -/** * irq_remapping_get_ir_irq_domain - Get the irqdomain associated the IOMMU * device serving @info
Signature · 1 line
1.7.10.4
PATCH v3 19/38 iommu/vt-d: Clean up unsued code
In reply to Jiang LiuNow we have converted to hierarchy irqdomain, so clean up unused code.
--- drivers/iommu/intel_irq_remapping.c | 187 +---------------------------------- 1 file changed, 1 insertion(+), 186 deletions(-)
drivers/iommu/intel_irq_remapping.c +1 -186
@@ -63,35 +63,6 @@ static struct irq_domain_ops intel_ir_domain_ops;static int __init parse_ioapics_under_ir (void ); -static struct irq_2_iommu *irq_2_iommu (unsigned int irq) -{ -struct irq_cfg *cfg =irq_cfg (irq); -return cfg ? &cfg->irq_2_iommu :NULL ; -} - -static int get_irte (int irq,struct irte *entry) -{ -struct irq_2_iommu *irq_iommu =irq_2_iommu (irq); -unsigned long flags; -int index; - -if (!entry || !irq_iommu) -return -1 ; - -raw_spin_lock_irqsave (&irq_2_ir_lock, flags); - -if (unlikely (!irq_iommu->iommu)) { -raw_spin_unlock_irqrestore (&irq_2_ir_lock, flags); -return -1 ; - } - - index = irq_iommu->irte_index + irq_iommu->sub_handle; - *entry = *(irq_iommu->iommu->ir_table->base + index); - -raw_spin_unlock_irqrestore (&irq_2_ir_lock, flags); -return 0 ; -} -static int alloc_irte (struct intel_iommu *iommu,int irq,struct irq_2_iommu *irq_iommu,u16 count) {
@@ -229,29 +200,6 @@ static int clear_entries(struct irq_2_iommu *irq_iommu)return qi_flush_iec (iommu, index, irq_iommu->irte_mask); } -static int free_irte (int irq) -{ -struct irq_2_iommu *irq_iommu =irq_2_iommu (irq); -unsigned long flags; -int rc; - -if (!irq_iommu || irq_iommu->iommu ==NULL ) -return -1 ; - -raw_spin_lock_irqsave (&irq_2_ir_lock, flags); - - rc =clear_entries (irq_iommu); - - irq_iommu->iommu =NULL ; - irq_iommu->irte_index =0 ; - irq_iommu->sub_handle =0 ; - irq_iommu->irte_mask =0 ; - -raw_spin_unlock_irqrestore (&irq_2_ir_lock, flags); - -return rc; -} -/* * source validation type */
@@ -875,8 +823,7 @@ error:return -1 ; } -static void prepare_irte (struct irte *irte,int vector, -unsigned int dest) +static void prepare_irte (struct irte *irte,int vector,unsigned int dest) {memset (irte,0 ,sizeof (*irte));
@@ -896,135 +843,6 @@ static void prepare_irte(struct irte *irte, int vector, irte->redir_hint =1 ; } -static int intel_setup_ioapic_entry (int irq, -struct IO_APIC_route_entry *route_entry, -unsigned int destination,int vector, -struct io_apic_irq_attr *attr) -{ -int ioapic_id =mpc_ioapic_id (attr->ioapic); -struct intel_iommu *iommu; -struct IR_IO_APIC_route_entry *entry; -struct irte irte; -int index; - -down_read (&dmar_global_lock); - iommu =map_ioapic_to_ir (ioapic_id); -if (!iommu) { -pr_warn ("No mapping iommu for ioapic %d\n" , ioapic_id); - index = -ENODEV ; - }else { - index =alloc_irte (iommu, irq,irq_2_iommu (irq),1 ); -if (index <0 ) { -pr_warn ("Failed to allocate IRTE for ioapic %d\n" , - ioapic_id); - index = -ENOMEM ; - } - } -up_read (&dmar_global_lock); -if (index <0 ) -return index; - -prepare_irte (&irte, vector, destination); - -/* Set source-id of interrupt request */ -set_ioapic_sid (&irte, ioapic_id); - -modify_irte (irq_2_iommu (irq), &irte); - -apic_printk (APIC_VERBOSE ,KERN_DEBUG "IOAPIC[%d]: " -"Set IRTE entry (P:%d FPD:%d Dst_Mode:%d " -"Redir_hint:%d Trig_Mode:%d Dlvry_Mode:%X " -"Avail:%X Vector:%02X Dest:%08X " -"SID:%04X SQ:%X SVT:%X)\n" , - attr->ioapic, irte.present, irte.fpd, irte.dst_mode, - irte.redir_hint, irte.trigger_mode, irte.dlvry_mode, - irte.avail, irte.vector, irte.dest_id, - irte.sid, irte.sq, irte.svt); - - entry = (struct IR_IO_APIC_route_entry *)route_entry; -memset (entry,0 ,sizeof (*entry)); - - entry->index2 = (index >>15 ) &0x1 ; - entry->zero =0 ; - entry->format =1 ; - entry->index = (index &0x7fff ); -/* -* IO-APIC RTE will be configured with virtual vector. -* irq handler will do the explicit EOI to the io-apic. -*/ - entry->vector = attr->ioapic_pin; - entry->mask =0 ;/* enable IRQ */ - entry->trigger = attr->trigger; - entry->polarity = attr->polarity; - -/* Mask level triggered irqs. -* Use IRQ_DELAYED_DISABLE for edge triggered irqs. -*/ -if (attr->trigger) - entry->mask =1 ; - -return 0 ; -} - -/* -* Migrate the IO-APIC irq in the presence of intr-remapping. -* -* For both level and edge triggered, irq migration is a simple atomic -* update(of vector and cpu destination) of IRTE and flush the hardware cache. -* -* For level triggered, we eliminate the io-apic RTE modification (with the -* updated vector information), by using a virtual vector (io-apic pin number). -* Real vector that is used for interrupting cpu will be coming from -* the interrupt-remapping table entry. -* -* As the migration is a simple atomic update of IRTE, the same mechanism -* is used to migrate MSI irq's in the presence of interrupt-remapping. -*/ -static int -intel_ioapic_set_affinity (struct irq_data *data,const struct cpumask *mask, -bool force) -{ -struct irq_cfg *cfg =irqd_cfg (data); -unsigned int dest, irq = data->irq; -struct irte irte; -int err; - -if (get_irte (irq, &irte)) -return -EBUSY ; - - err =assign_irq_vector (irq, cfg, mask); -if (err) -return err; - - err = apic->cpu_mask_to_apicid_and (cfg->domain, mask, &dest); -if (err) { -if (assign_irq_vector (irq, cfg, data->affinity)) -pr_err ("Failed to recover vector for irq %d\n" , irq); -return err; - } - - irte.vector = cfg->vector; - irte.dest_id =IRTE_DEST (dest); - -/* -* Atomically updates the IRTE with the new destination, vector -* and flushes the interrupt entry cache. -*/ -modify_irte (irq_2_iommu (irq), &irte); - -/* -* After this point, all the interrupts will start arriving -* at the new destination. So, time to cleanup the previous -* vector allocation. -*/ -if (cfg->move_in_progress) -send_cleanup_vector (cfg); - -cpumask_copy (data->affinity, mask); - -return 0 ; -} -static struct irq_domain *intel_get_ir_irq_domain (struct irq_alloc_info *info) {struct intel_iommu *iommu =NULL ;
@@ -1079,9 +897,6 @@ struct irq_remap_ops intel_irq_remap_ops = { .disable = disable_irq_remapping, .reenable = reenable_irq_remapping, .enable_faulting = enable_drhd_fault_handling, - .setup_ioapic_entry = intel_setup_ioapic_entry, - .set_affinity = intel_ioapic_set_affinity, - .free_irq = free_irte, .get_ir_irq_domain = intel_get_ir_irq_domain, .get_irq_domain = intel_get_irq_domain, };
Signature · 1 line
1.7.10.4
PATCH v3 20/38 iommu/amd: Clean up unsued code
In reply to Jiang LiuNow we have converted to hierarchy irqdomain, so clean up unused code.
--- drivers/iommu/amd_iommu.c | 144 --------------------------------------------- 1 file changed, 144 deletions(-)
drivers/iommu/amd_iommu.c +0 -144
@@ -3996,22 +3996,6 @@ out:return index; } -static int get_irte (u16 devid,int index,union irte *irte) -{ -struct irq_remap_table *table; -unsigned long flags; - - table =get_irq_table (devid, false); -if (!table) -return -ENOMEM ; - -spin_lock_irqsave (&table->lock, flags); - irte->val = table->table[index]; -spin_unlock_irqrestore (&table->lock, flags); - -return 0 ; -} -static int modify_irte (u16 devid,int index,union irte irte) {struct irq_remap_table *table;
@@ -4058,131 +4042,6 @@ static void free_irte(u16 devid, int index)iommu_completion_wait (iommu); } -static int setup_ioapic_entry (int irq,struct IO_APIC_route_entry *entry, -unsigned int destination,int vector, -struct io_apic_irq_attr *attr) -{ -struct irq_remap_table *table; -struct irq_2_irte *irte_info; -struct irq_cfg *cfg; -union irte irte; -int ioapic_id; -int index; -int devid; -int ret; - - cfg =irq_cfg (irq); -if (!cfg) -return -EINVAL ; - - irte_info = &cfg->irq_2_irte; - ioapic_id =mpc_ioapic_id (attr->ioapic); - devid =get_ioapic_devid (ioapic_id); - -if (devid <0 ) -return devid; - - table =get_irq_table (devid, true); -if (table ==NULL ) -return -ENOMEM ; - - index = attr->ioapic_pin; - -/* Setup IRQ remapping info */ - cfg->remapped =1 ; - irte_info->devid = devid; - irte_info->index = index; - -/* Setup IRTE for IOMMU */ - irte.val =0 ; - irte.fields.vector = vector; - irte.fields.int_type = apic->irq_delivery_mode; - irte.fields.destination = destination; - irte.fields.dm = apic->irq_dest_mode; - irte.fields.valid =1 ; - - ret =modify_irte (devid, index, irte); -if (ret) -return ret; - -/* Setup IOAPIC entry */ -memset (entry,0 ,sizeof (*entry)); - - entry->vector = index; - entry->mask =0 ; - entry->trigger = attr->trigger; - entry->polarity = attr->polarity; - -/* -* Mask level triggered irqs. -*/ -if (attr->trigger) - entry->mask =1 ; - -return 0 ; -} - -static int set_affinity (struct irq_data *data,const struct cpumask *mask, -bool force) -{ -struct irq_2_irte *irte_info; -unsigned int dest, irq; -struct irq_cfg *cfg; -union irte irte; -int err; - -if (!config_enabled (CONFIG_SMP )) -return -1 ; - - cfg =irqd_cfg (data); - irq = data->irq; - irte_info = &cfg->irq_2_irte; - -if (!cpumask_intersects (mask, cpu_online_mask)) -return -EINVAL ; - -if (get_irte (irte_info->devid, irte_info->index, &irte)) -return -EBUSY ; - -if (assign_irq_vector (irq, cfg, mask)) -return -EBUSY ; - - err = apic->cpu_mask_to_apicid_and (cfg->domain, mask, &dest); -if (err) { -if (assign_irq_vector (irq, cfg, data->affinity)) -pr_err ("AMD-Vi: Failed to recover vector for irq %d\n" , irq); -return err; - } - - irte.fields.vector = cfg->vector; - irte.fields.destination = dest; - -modify_irte (irte_info->devid, irte_info->index, irte); - -if (cfg->move_in_progress) -send_cleanup_vector (cfg); - -cpumask_copy (data->affinity, mask); - -return 0 ; -} - -static int free_irq (int irq) -{ -struct irq_2_irte *irte_info; -struct irq_cfg *cfg; - - cfg =irq_cfg (irq); -if (!cfg) -return -EINVAL ; - - irte_info = &cfg->irq_2_irte; - -free_irte (irte_info->devid, irte_info->index); - -return 0 ; -} -static int get_devid (struct irq_alloc_info *info) {int devid =-1 ;
@@ -4256,9 +4115,6 @@ struct irq_remap_ops amd_iommu_irq_ops = { .disable = amd_iommu_disable, .reenable = amd_iommu_reenable, .enable_faulting = amd_iommu_enable_faulting, - .setup_ioapic_entry = setup_ioapic_entry, - .set_affinity = set_affinity, - .free_irq = free_irq, .get_ir_irq_domain = get_ir_irq_domain, .get_irq_domain = get_irq_domain, };
Signature · 1 line
1.7.10.4
PATCH v3 21/38 x86: irq_remapping: Clean up unused interfaces
In reply to Jiang LiuNow we have converted to hierarchy irqdomain, so clean up unused interfaces.
--- drivers/iommu/irq_remapping.h | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/iommu/irq_remapping.h +0 -16
@@ -24,11 +24,7 @@#ifdef CONFIG_IRQ_REMAP -struct IO_APIC_route_entry ; -struct io_apic_irq_attr ;struct irq_data ; -struct cpumask ; -struct pci_dev ;struct msi_msg ;struct irq_domain ;struct irq_alloc_info ;
@@ -58,18 +54,6 @@ struct irq_remap_ops {/* Enable fault handling */ int (*enable_faulting)(void ); -/* IO-APIC setup routine */ -int (*setup_ioapic_entry)(int irq,struct IO_APIC_route_entry *, -unsigned int ,int , -struct io_apic_irq_attr *); - -/* Set the CPU affinity of a remapped interrupt */ -int (*set_affinity)(struct irq_data *data,const struct cpumask *mask, -bool force); - -/* Free an IRQ */ -int (*free_irq)(int ); -/* Get the irqdomain associated the IOMMU device */ struct irq_domain *(*get_ir_irq_domain)(struct irq_alloc_info *);
Signature · 1 line
1.7.10.4
PATCH v3 22/38 x86, irq: Kill irq_cfg.irq_remapped
In reply to Jiang LiuNow there is no user of irq_cfg.irq_remapped, so kill it.
--- arch/x86/include/asm/hw_irq.h | 1 - drivers/iommu/amd_iommu.c | 1 - drivers/iommu/intel_irq_remapping.c | 2 -- 3 files changed, 4 deletions(-)
arch/x86/include/asm/hw_irq.h +0 -1
@@ -191,7 +191,6 @@ struct irq_cfg {u8 vector; u8 move_in_progress : 1; #ifdef CONFIG_IRQ_REMAP - u8 remapped : 1; union { struct irq_2_iommu irq_2_iommu; struct irq_2_irte irq_2_irte;
drivers/iommu/amd_iommu.c +0 -1
@@ -4129,7 +4129,6 @@ static void irq_remapping_prepare_irte(struct amd_ir_data *data,struct msi_msg *msg = &data->msi_entry;struct IO_APIC_route_entry *entry; - irq_cfg->remapped =1 ; data->irq_2_irte.devid = devid; data->irq_2_irte.index = index + sub_handle;
drivers/iommu/intel_irq_remapping.c +0 -2
@@ -67,7 +67,6 @@ static int alloc_irte(struct intel_iommu *iommu, int irq, struct irq_2_iommu *irq_iommu, u16 count) {struct ir_table *table = iommu->ir_table; -struct irq_cfg *cfg =irq_cfg (irq);unsigned int mask =0 ;unsigned long flags;int index;
@@ -94,7 +93,6 @@ static int alloc_irte(struct intel_iommu *iommu, int irq,if (index <0 ) {pr_warn ("IR%d: can't allocate an IRTE\n" , iommu->seq_id); }else { - cfg->remapped =1 ; irq_iommu->iommu = iommu; irq_iommu->irte_index = index; irq_iommu->sub_handle =0 ;
Signature · 1 line
1.7.10.4
PATCH v3 23/38 iommu/vt-d: Move struct irq_2_iommu into intel_irq_remapping.c
In reply to Jiang LiuNow only intel_irq_remapping.c access irq_2_iommu, so move it from hw_irq.h into intel_irq_remapping.c.
--- arch/x86/include/asm/hw_irq.h | 9 --------- drivers/iommu/intel_irq_remapping.c | 7 +++++++ 2 files changed, 7 insertions(+), 9 deletions(-)
arch/x86/include/asm/hw_irq.h +0 -9
@@ -95,14 +95,6 @@ extern void trace_call_function_single_interrupt(void);#endif /* CONFIG_TRACING */ #ifdef CONFIG_IRQ_REMAP -/* Intel specific interrupt remapping information */ -struct irq_2_iommu { - struct intel_iommu *iommu; - u16 irte_index; - u16 sub_handle; - u8 irte_mask; -}; - /* AMD specific interrupt remapping information */ struct irq_2_irte { u16 devid; /* Device ID for IRTE table */
@@ -192,7 +184,6 @@ struct irq_cfg { u8 move_in_progress : 1;#ifdef CONFIG_IRQ_REMAP union { -struct irq_2_iommu irq_2_iommu;struct irq_2_irte irq_2_irte; };#endif
drivers/iommu/intel_irq_remapping.c +7 -0
@@ -32,6 +32,13 @@ struct hpet_scope {unsigned int devfn; }; +struct irq_2_iommu { +struct intel_iommu *iommu; +u16 irte_index; +u16 sub_handle; +u8 irte_mask; +}; +struct intel_ir_data {struct irq_2_iommu irq_2_iommu;struct irte irte_entry;
Signature · 1 line
1.7.10.4
PATCH v3 24/38 iommu/amd: Move struct irq_2_irte into amd_iommu.c
In reply to Jiang LiuNow only amd_iommu.c access irq_2_irte, so move it from hw_irq.h into amd_iommu.c.
--- arch/x86/include/asm/hw_irq.h | 13 ------------- drivers/iommu/amd_iommu.c | 5 +++++ 2 files changed, 5 insertions(+), 13 deletions(-)
arch/x86/include/asm/hw_irq.h +0 -13
@@ -94,14 +94,6 @@ extern void trace_call_function_single_interrupt(void);#define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi#endif /* CONFIG_TRACING */ -#ifdef CONFIG_IRQ_REMAP -/* AMD specific interrupt remapping information */ -struct irq_2_irte { -u16 devid;/* Device ID for IRTE table */ -u16 index;/* Index into IRTE table*/ -}; -#endif /* CONFIG_IRQ_REMAP */ -struct irq_domain ;#ifdef CONFIG_X86_LOCAL_APIC
@@ -182,11 +174,6 @@ struct irq_cfg {unsigned int dest_apicid;u8 vector; u8 move_in_progress : 1; -#ifdef CONFIG_IRQ_REMAP -union { -struct irq_2_irte irq_2_irte; - }; -#endif union { #ifdef CONFIG_X86_IO_APIC struct {
drivers/iommu/amd_iommu.c +5 -0
@@ -3855,6 +3855,11 @@ union irte { } fields; }; +struct irq_2_irte { +u16 devid;/* Device ID for IRTE table */ +u16 index;/* Index into IRTE table*/ +}; +struct amd_ir_data {struct irq_2_irte irq_2_irte;union irte irte_entry;
Signature · 1 line
1.7.10.4
PATCH v3 25/38 x86, irq: Move irq_cfg.irq_2_pin into io_apic.c
In reply to Jiang LiuNow only io_apic.c accesses struct irq_cfg.irq_2_pin, so move irq_2_pin into struct mp_chip_data in io_apic.c to clean up struct irq_cfg further.
--- arch/x86/include/asm/hw_irq.h | 7 -- arch/x86/kernel/apic/io_apic.c | 164 +++++++++++++++++++--------------------- arch/x86/kernel/apic/vector.c | 3 - 3 files changed, 77 insertions(+), 97 deletions(-)
arch/x86/include/asm/hw_irq.h +0 -7
@@ -174,13 +174,6 @@ struct irq_cfg {unsigned int dest_apicid;u8 vector; u8 move_in_progress : 1; -union { -#ifdef CONFIG_X86_IO_APIC -struct { -struct list_head irq_2_pin; - }; -#endif - }; };extern struct irq_domain *x86_vector_domain;
arch/x86/kernel/apic/io_apic.c +77 -87
451 lines not on this page · raw message
arch/x86/kernel/apic/vector.c +0 -3
@@ -68,9 +68,6 @@ static struct irq_cfg *alloc_irq_cfg(int node) goto out_cfg;if (!zalloc_cpumask_var_node (&cfg->old_domain,GFP_KERNEL , node)) goto out_domain; -#ifdef CONFIG_X86_IO_APIC -INIT_LIST_HEAD (&cfg->irq_2_pin); -#endif return cfg; out_domain:free_cpumask_var (cfg->domain);
Signature · 1 line
1.7.10.4
PATCH v3 26/38 x86, irq: Kill struct io_apic_irq_attr
In reply to Jiang LiuNow there's no user of struct io_apic_irq_attr anymore, so kill it.
--- arch/x86/include/asm/io_apic.h | 7 ------- arch/x86/kernel/apic/io_apic.c | 10 ---------- 2 files changed, 17 deletions(-)
arch/x86/include/asm/io_apic.h +0 -7
@@ -157,13 +157,6 @@ extern int restore_ioapic_entries(void);extern void setup_ioapic_ids_from_mpc (void );extern void setup_ioapic_ids_from_mpc_nocheck (void ); -struct io_apic_irq_attr { -int ioapic; -int ioapic_pin; -int trigger; -int polarity; -}; -enum ioapic_domain_type {IOAPIC_DOMAIN_INVALID ,IOAPIC_DOMAIN_LEGACY ,
arch/x86/kernel/apic/io_apic.c +0 -10
@@ -2949,16 +2949,6 @@ int mp_ioapic_registered(u32 gsi_base)return 0 ; } -static inline void set_io_apic_irq_attr (struct io_apic_irq_attr *irq_attr, -int ioapic,int ioapic_pin, -int trigger,int polarity) -{ - irq_attr->ioapic = ioapic; - irq_attr->ioapic_pin = ioapic_pin; - irq_attr->trigger = trigger; - irq_attr->polarity = polarity; -} -static void mp_irqdomain_get_attr (u32 gsi,struct mp_chip_data *data,struct irq_alloc_info *info) {
Signature · 1 line
1.7.10.4
PATCH v3 27/38 x86, irq: Kill x86_io_apic_ops.write and x86_io_apic_ops.modify
In reply to Jiang Liux86_io_apic_ops.write is always set to native_io_apic_write(), and nobody overrides it. So get rid of the indirection by changing native_io_apic_write() as io_apic_write() and killing x86_io_apic_ops.write.
Do the same for x86_io_apic_ops.modify and native_io_apic_modify().
--- arch/x86/include/asm/io_apic.h | 13 ------------- arch/x86/include/asm/x86_init.h | 2 -- arch/x86/kernel/apic/io_apic.c | 6 ++++-- arch/x86/kernel/x86_init.c | 2 -- 4 files changed, 4 insertions(+), 19 deletions(-)
arch/x86/include/asm/io_apic.h +0 -13
@@ -208,8 +208,6 @@ extern void disable_ioapic_support(void);extern void __init native_io_apic_init_mappings (void );extern unsigned int native_io_apic_read (unsigned int apic,unsigned int reg); -extern void native_io_apic_write (unsigned int apic,unsigned int reg,unsigned int val); -extern void native_io_apic_modify (unsigned int apic,unsigned int reg,unsigned int val);extern void native_disable_io_apic (void );static inline unsigned int io_apic_read (unsigned int apic,unsigned int reg)
@@ -217,15 +215,6 @@ static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)return x86_io_apic_ops.read (apic, reg); } -static inline void io_apic_write (unsigned int apic,unsigned int reg,unsigned int value) -{ - x86_io_apic_ops.write (apic, reg, value); -} -static inline void io_apic_modify (unsigned int apic,unsigned int reg,unsigned int value) -{ - x86_io_apic_ops.modify (apic, reg, value); -} -extern void setup_IO_APIC (void );extern void enable_IO_APIC (void );extern void disable_IO_APIC (void );
@@ -266,8 +255,6 @@ static inline void mp_save_irq(struct mpc_intsrc *m) { };static inline void disable_ioapic_support (void ) { }#define native_io_apic_init_mappings NULL#define native_io_apic_read NULL -#define native_io_apic_write NULL -#define native_io_apic_modify NULL#define native_disable_io_apic NULL#endif
arch/x86/include/asm/x86_init.h +0 -2
@@ -185,8 +185,6 @@ struct x86_msi_ops {struct x86_io_apic_ops {void (*init) (void );unsigned int (*read) (unsigned int apic,unsigned int reg); -void (*write) (unsigned int apic,unsigned int reg,unsigned int value); -void (*modify) (unsigned int apic,unsigned int reg,unsigned int value);void (*disable)(void ); };
arch/x86/kernel/apic/io_apic.c +4 -2
@@ -277,7 +277,8 @@ unsigned int native_io_apic_read(unsigned int apic, unsigned int reg)return readl (&io_apic->data); } -void native_io_apic_write (unsigned int apic,unsigned int reg,unsigned int value) +static void io_apic_write (unsigned int apic,unsigned int reg, +unsigned int value) {struct io_apic __iomem *io_apic =io_apic_base (apic);
@@ -291,7 +292,8 @@ void native_io_apic_write(unsigned int apic, unsigned int reg, unsigned int valu* * Older SiS APIC requires we rewrite the index register */ -void native_io_apic_modify (unsigned int apic,unsigned int reg,unsigned int value) +static void io_apic_modify (unsigned int apic,unsigned int reg, +unsigned int value) {struct io_apic __iomem *io_apic =io_apic_base (apic);
arch/x86/kernel/x86_init.c +0 -2
@@ -151,7 +151,5 @@ u32 arch_msix_mask_irq(struct msi_desc *desc, u32 flag)struct x86_io_apic_ops x86_io_apic_ops = { .init = native_io_apic_init_mappings, .read = native_io_apic_read, - .write = native_io_apic_write, - .modify = native_io_apic_modify, .disable = native_disable_io_apic, };
Signature · 1 line
1.7.10.4
PATCH v3 28/38 x86, irq: Clean up io_apic.h
In reply to Jiang LiuClean up io_apic.h by:
1) moving definition of struct mp_ioapic_gsi into io_apic.c
2) changing mp_pin_to_gsi() and mp_ioapic_gsi_routing() as static
3) killing unused MP_MAX_IOAPIC_PIN
4) killing useless forward declaration
5) killing useless comments
--- arch/x86/include/asm/io_apic.h | 14 ++------------ arch/x86/kernel/apic/io_apic.c | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 27 deletions(-)
arch/x86/include/asm/io_apic.h +2 -12
@@ -113,9 +113,6 @@ extern int nr_ioapics;extern int mpc_ioapic_id (int ioapic);extern unsigned int mpc_ioapic_addr (int ioapic); -extern struct mp_ioapic_gsi *mp_ioapic_gsi_routing (int ioapic); - -#define MP_MAX_IOAPIC_PIN 127/* # of MP IRQ source entries */ extern int mp_irq_entries;
@@ -135,6 +132,8 @@ extern int noioapicquirk;/* -1 if "noapic" boot option passed */ extern int noioapicreroute; +extern u32 gsi_top; +extern unsigned long io_apic_irqs;#define IO_APIC_IRQ (x) (((x) >= NR_IRQS_LEGACY) || ((1 << (x)) & io_apic_irqs))
@@ -146,7 +145,6 @@ extern unsigned long io_apic_irqs;#define io_apic_assign_pci_irqs \ (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) -struct irq_cfg ;extern void ioapic_insert_resources (void );extern int arch_early_ioapic_init (void );
@@ -174,15 +172,8 @@ struct ioapic_domain_cfg {struct device_node *dev; }; -struct mp_ioapic_gsi { -u32 gsi_base; -u32 gsi_end; -}; -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,unsigned int flags,struct irq_alloc_info *info);extern void mp_unmap_irq (int irq);
@@ -231,7 +222,6 @@ static inline int arch_early_ioapic_init(void) { return 0; }static inline void print_IO_APICs (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,unsigned int flags,struct irq_alloc_info *info) {
arch/x86/kernel/apic/io_apic.c +8 -15
@@ -63,7 +63,6 @@#define for_each_ioapic_pin (idx, pin) \ for_each_ioapic((idx)) \ for_each_pin((idx), (pin)) -#define for_each_irq_pin (entry, head) \ list_for_each_entry(entry, &head, list)
@@ -94,6 +93,11 @@ struct mp_chip_data {bool isa_irq; }; +struct mp_ioapic_gsi { +u32 gsi_base; +u32 gsi_end; +}; + static struct ioapic { /* * # of IRQ routing registers
@@ -124,7 +128,7 @@ unsigned int mpc_ioapic_addr(int ioapic_idx)return ioapics[ioapic_idx].mp_config.apicaddr; } -struct mp_ioapic_gsi *mp_ioapic_gsi_routing (int ioapic_idx) +static inline struct mp_ioapic_gsi *mp_ioapic_gsi_routing (int ioapic_idx) {return &ioapics[ioapic_idx].gsi_config; }
@@ -136,7 +140,7 @@ static inline int mp_ioapic_pin_count(int ioapic)return gsi_cfg->gsi_end - gsi_cfg->gsi_base +1 ; } -u32 mp_pin_to_gsi (int ioapic,int pin) +static inline u32 mp_pin_to_gsi (int ioapic,int pin) {return mp_ioapic_gsi_routing (ioapic)->gsi_base + pin; }
@@ -1146,8 +1150,7 @@ static int pin_2_irq(int idx, int ioapic, int pin, unsigned int flags)return mp_map_pin_to_irq (gsi, idx, ioapic, pin, flags,NULL ); } -int mp_map_gsi_to_irq (u32 gsi,unsigned int flags, -struct irq_alloc_info *info) +int mp_map_gsi_to_irq (u32 gsi,unsigned int flags,struct irq_alloc_info *info) {int ioapic, pin, idx;
@@ -1709,7 +1712,6 @@ static int __init timer_irq_works(void)* This is not complete - we should be able to fake * an edge even if it isn't on the 8259A... */ -static unsigned int startup_ioapic_irq (struct irq_data *data) {int was_pending =0 , irq = data->irq;
@@ -1727,15 +1729,6 @@ static unsigned int startup_ioapic_irq(struct irq_data *data)return was_pending; } -/* -* Level and edge triggered IO-APIC interrupts need different handling, -* so we use two separate IRQ descriptors. Edge triggered IRQs can be -* handled with the level-triggered descriptor, but that one has slightly -* more overhead. Level-triggered interrupts cannot be handled with the -* edge-triggered handler, without risking IRQ storms and other ugly -* races. -*/ -static void __target_IO_APIC_irq (unsigned int irq,struct irq_cfg *cfg,struct mp_chip_data *data) {
Signature · 1 line
1.7.10.4
PATCH v3 29/38 x86, irq: Use cached IOAPIC entry instead of reading from hardware
In reply to Jiang LiuUse cahced IOAPIC entry instead of reading data from IOAPIC hardware registers to improve performance.
--- arch/x86/kernel/apic/io_apic.c | 78 +++++++++++----------------------------- 1 file changed, 21 insertions(+), 57 deletions(-)
arch/x86/kernel/apic/io_apic.c +21 -57
@@ -69,8 +69,13 @@int acpi_get_override_irq (u32 gsi,int *trigger,int *polarity);/* -* Is the SiS APIC rmw bug present ? +* Is the SiS APIC rmw bug present ? * -1 = don't know, 0 = no, 1 = yes +* When doing a read-modify-write operation on IOAPIC registers, older SiS APIC +* requires we rewrite the index register again where the read already set up +* the index register. +* The code to make use of sis_apic_bug has been removed, but we don't want to +* loss this knowledge. */ int sis_apic_bug =-1 ;
@@ -290,22 +295,6 @@ static void io_apic_write(unsigned int apic, unsigned int reg,writel (value, &io_apic->data); } -/* -* Re-write a value: to be used for read-modify-write -* cycles where the read already set up the index register. -* -* Older SiS APIC requires we rewrite the index register -*/ -static void io_apic_modify (unsigned int apic,unsigned int reg, -unsigned int value) -{ -struct io_apic __iomem *io_apic =io_apic_base (apic); - -if (sis_apic_bug) -writel (reg, &io_apic->index); -writel (value, &io_apic->data); -} -union entry_union {struct {u32 w1, w2; };struct IO_APIC_route_entry entry;
@@ -442,29 +431,23 @@ static void __init replace_pin_at_irq_node(struct mp_chip_data *data, int node,add_pin_to_irq_node (data, node, newapic, newpin); } -static void __io_apic_modify_irq (struct irq_pin_list *entry, -int mask_and,int mask_or, -void (*final)(struct irq_pin_list *entry)) -{ -unsigned int reg, pin; - - pin = entry->pin; - reg =io_apic_read (entry->apic,0x10 + pin *2 ); - reg &= mask_and; - reg |= mask_or; -io_apic_modify (entry->apic,0x10 + pin *2 , reg); -if (final) -final (entry); -} -static void io_apic_modify_irq (struct mp_chip_data *data,int mask_and,int mask_or,void (*final)(struct irq_pin_list *entry)) { +union entry_union eu;struct irq_pin_list *entry; -for_each_irq_pin (entry, data->irq_2_pin) -__io_apic_modify_irq (entry, mask_and, mask_or, final); + eu.entry = data->entry; + eu.w1 &= mask_and; + eu.w1 |= mask_or; + data->entry = eu.entry; + +for_each_irq_pin (entry, data->irq_2_pin) { +__ioapic_write_entry (entry->apic, entry->pin, data->entry); +if (final) +final (entry); + } }static void io_apic_sync (struct irq_pin_list *entry)
@@ -1729,28 +1712,6 @@ static unsigned int startup_ioapic_irq(struct irq_data *data)return was_pending; } -static void __target_IO_APIC_irq (unsigned int irq,struct irq_cfg *cfg, -struct mp_chip_data *data) -{ -int apic, pin; -struct irq_pin_list *entry; -u8 vector = cfg->vector; -unsigned int dest =SET_APIC_LOGICAL_ID (cfg->dest_apicid); - -for_each_irq_pin (entry, data->irq_2_pin) { -unsigned int reg; - - apic = entry->apic; - pin = entry->pin; - -io_apic_write (apic,0x11 + pin*2 , dest); - reg =io_apic_read (apic,0x10 + pin*2 ); - reg &= ~IO_APIC_REDIR_VECTOR_MASK ; - reg |= vector; -io_apic_modify (apic,0x10 + pin*2 , reg); - } -} -atomic_t irq_mis_count;#ifdef CONFIG_GENERIC_PENDING_IRQ
@@ -1916,6 +1877,7 @@ static int ioapic_set_affinity(struct irq_data *irq_data, {struct irq_data *parent = irq_data->parent_data;struct mp_chip_data *data = irq_data->chip_data; +struct irq_pin_list *entry;struct irq_cfg *cfg;unsigned long flags;int ret;
@@ -1926,7 +1888,9 @@ static int ioapic_set_affinity(struct irq_data *irq_data, cfg =irqd_cfg (irq_data); data->entry.dest =SET_APIC_LOGICAL_ID (cfg->dest_apicid); data->entry.vector = cfg->vector; -__target_IO_APIC_irq (irq_data->irq, cfg, irq_data->chip_data); +for_each_irq_pin (entry, data->irq_2_pin) +__ioapic_write_entry (entry->apic, entry->pin, + data->entry); }raw_spin_unlock_irqrestore (&ioapic_lock, flags);
Signature · 1 line
1.7.10.4
PATCH v3 30/38 x86, irq: Kill unused alloc_irq_and_cfg_at()
In reply to Jiang LiuThere's no caller of alloc_irq_and_cfg_at() anymore, so kill it.
--- arch/x86/include/asm/hw_irq.h | 1 - arch/x86/kernel/apic/vector.c | 21 --------------------- 2 files changed, 22 deletions(-)
arch/x86/include/asm/hw_irq.h +0 -1
@@ -184,7 +184,6 @@ extern void copy_irq_alloc_info(struct irq_alloc_info *dst, struct irq_alloc_info *src);extern struct irq_cfg *irq_cfg (unsigned int irq);extern struct irq_cfg *irqd_cfg (struct irq_data *irq_data); -extern struct irq_cfg *alloc_irq_and_cfg_at (unsigned int at,int node);extern void lock_vector_lock (void );extern void unlock_vector_lock (void );extern int assign_irq_vector (int ,struct irq_cfg *,const struct cpumask *);
arch/x86/kernel/apic/vector.c +0 -21
@@ -76,27 +76,6 @@ out_cfg:return NULL ; } -struct irq_cfg *alloc_irq_and_cfg_at (unsigned int at,int node) -{ -int res =irq_alloc_desc_at (at, node); -struct irq_cfg *cfg; - -if (res <0 ) { -if (res != -EEXIST ) -return NULL ; - cfg =irq_cfg (at); -if (cfg) -return cfg; - } - - cfg =alloc_irq_cfg (node); -if (cfg) -irq_set_chip_data (at, cfg); -else -irq_free_desc (at); -return cfg; -} -static void free_irq_cfg (struct irq_cfg *cfg) {if (cfg) {
Signature · 1 line
1.7.10.4
PATCH v3 31/38 x86, irq: Change functions only used in vector.c as static
In reply to Jiang LiuFunction {assign|clear}_irq_vector() and apic_retrigger_irq() are only used in file vector.c, so change them as static.
--- arch/x86/include/asm/hw_irq.h | 3 --- arch/x86/kernel/apic/vector.c | 7 ++++--- 2 files changed, 4 insertions(+), 6 deletions(-)
arch/x86/include/asm/hw_irq.h +0 -3
@@ -186,8 +186,6 @@ extern struct irq_cfg *irq_cfg(unsigned int irq);extern struct irq_cfg *irqd_cfg (struct irq_data *irq_data);extern void lock_vector_lock (void );extern void unlock_vector_lock (void ); -extern int assign_irq_vector (int ,struct irq_cfg *,const struct cpumask *); -extern void clear_irq_vector (int irq,struct irq_cfg *cfg);extern void setup_vector_irq (int cpu);#ifdef CONFIG_SMP extern void send_cleanup_vector (struct irq_cfg *);
@@ -197,7 +195,6 @@ static inline void send_cleanup_vector(struct irq_cfg *c) { }static inline void irq_complete_move (struct irq_cfg *c) { }#endif -extern int apic_retrigger_irq (struct irq_data *data);extern void apic_ack_edge (struct irq_data *data);extern int apic_set_affinity (struct irq_data *data,const struct cpumask *mask,unsigned int *dest_id);
arch/x86/kernel/apic/vector.c +4 -3
@@ -185,7 +185,8 @@ next:return err; } -int assign_irq_vector (int irq,struct irq_cfg *cfg,const struct cpumask *mask) +static int assign_irq_vector (int irq,struct irq_cfg *cfg, +const struct cpumask *mask) {int err;unsigned long flags;
@@ -196,7 +197,7 @@ int assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask)return err; } -void clear_irq_vector (int irq,struct irq_cfg *cfg) +static void clear_irq_vector (int irq,struct irq_cfg *cfg) {int cpu, vector;unsigned long flags;
@@ -441,7 +442,7 @@ void setup_vector_irq(int cpu)__setup_vector_irq (cpu); } -int apic_retrigger_irq (struct irq_data *data) +static int apic_retrigger_irq (struct irq_data *data) {struct irq_cfg *cfg =irqd_cfg (data);unsigned long flags;
Signature · 1 line
1.7.10.4
PATCH v3 32/38 x86, irq: Kill function apic_set_affinity()
In reply to Jiang LiuNow there's no user of apic_set_affinity(), so kill it.
Also rename vector_set_affinity() to apic_set_affinity() for consistency.
--- arch/x86/include/asm/hw_irq.h | 2 -- arch/x86/kernel/apic/vector.c | 40 +++------------------------------------- 2 files changed, 3 insertions(+), 39 deletions(-)
arch/x86/include/asm/hw_irq.h +0 -2
@@ -196,8 +196,6 @@ static inline void irq_complete_move(struct irq_cfg *c) { }#endif extern void apic_ack_edge (struct irq_data *data); -extern int apic_set_affinity (struct irq_data *data,const struct cpumask *mask, -unsigned int *dest_id);#else /* CONFIG_X86_LOCAL_APIC */ static inline void lock_vector_lock (void ) {}static inline void unlock_vector_lock (void ) {}
arch/x86/kernel/apic/vector.c +3 -37
@@ -463,42 +463,8 @@ void apic_ack_edge(struct irq_data *data)ack_APIC_irq (); } -/* -* Either sets data->affinity to a valid value, and returns -* ->cpu_mask_to_apicid of that in dest_id, or returns -1 and -* leaves data->affinity untouched. -*/ -int apic_set_affinity (struct irq_data *data,const struct cpumask *mask, -unsigned int *dest_id) -{ -struct irq_cfg *cfg =irqd_cfg (data); -unsigned int irq = data->irq; -int err; - -if (!config_enabled (CONFIG_SMP )) -return -EPERM ; - -if (!cpumask_intersects (mask, cpu_online_mask)) -return -EINVAL ; - - err =assign_irq_vector (irq, cfg, mask); -if (err) -return err; - - err = apic->cpu_mask_to_apicid_and (mask, cfg->domain, dest_id); -if (err) { -if (assign_irq_vector (irq, cfg, data->affinity)) -pr_err ("Failed to recover vector for irq %d\n" , irq); -return err; - } - -cpumask_copy (data->affinity, mask); - -return 0 ; -} - -static int vector_set_affinity (struct irq_data *irq_data, -const struct cpumask *dest,bool force) +static int apic_set_affinity (struct irq_data *irq_data, +const struct cpumask *dest,bool force) {int err;int irq = irq_data->irq;
@@ -524,7 +490,7 @@ static int vector_set_affinity(struct irq_data *irq_data,static struct irq_chip vector_chip = { .irq_ack = apic_ack_edge, - .irq_set_affinity = vector_set_affinity, + .irq_set_affinity = apic_set_affinity, .irq_retrigger = apic_retrigger_irq, };
Signature · 1 line
1.7.10.4
PATCH v3 33/38 x86, irq: Move check of cfg->move_in_progress into send_cleanup_vector()
In reply to Jiang LiuMove check of cfg->move_in_progress into send_cleanup_vector() to prepare for simplifying struct irq_cfg.
--- arch/x86/kernel/apic/vector.c | 10 ++++++++-- arch/x86/platform/uv/uv_irq.c | 3 +-- drivers/iommu/amd_iommu.c | 3 +-- drivers/iommu/intel_irq_remapping.c | 3 +-- 4 files changed, 11 insertions(+), 8 deletions(-)
arch/x86/kernel/apic/vector.c +8 -2
@@ -495,7 +495,7 @@ static struct irq_chip vector_chip = { };#ifdef CONFIG_SMP -void send_cleanup_vector (struct irq_cfg *cfg) +static void __send_cleanup_vector (struct irq_cfg *cfg) {cpumask_var_t cleanup_mask;
@@ -513,6 +513,12 @@ void send_cleanup_vector(struct irq_cfg *cfg) cfg->move_in_progress =0 ; } +void send_cleanup_vector (struct irq_cfg *cfg) +{ +if (cfg->move_in_progress) +__send_cleanup_vector (cfg); +} + asmlinkage __visible void smp_irq_move_cleanup_interrupt(void) {unsigned vector, me;
@@ -583,7 +589,7 @@ static void __irq_complete_move(struct irq_cfg *cfg, unsigned vector) me =smp_processor_id ();if (vector == cfg->vector &&cpumask_test_cpu (me, cfg->domain)) -send_cleanup_vector (cfg); +__send_cleanup_vector (cfg); }void irq_complete_move (struct irq_cfg *cfg)
arch/x86/platform/uv/uv_irq.c +1 -2
@@ -63,8 +63,7 @@ uv_set_irq_affinity(struct irq_data *data, const struct cpumask *mask, ret = parent->chip->irq_set_affinity (parent, mask, force);if (ret >=0 ) {uv_program_mmr (cfg, data->chip_data); -if (cfg->move_in_progress) -send_cleanup_vector (cfg); +send_cleanup_vector (cfg); }return ret;
drivers/iommu/amd_iommu.c +1 -2
@@ -4331,8 +4331,7 @@ static int amd_ir_set_affinity(struct irq_data *data,* at the new destination. So, time to cleanup the previous * vector allocation. */ -if (cfg->move_in_progress) -send_cleanup_vector (cfg); +send_cleanup_vector (cfg);return IRQ_SET_MASK_OK_DONE ; }
drivers/iommu/intel_irq_remapping.c +1 -2
@@ -947,8 +947,7 @@ intel_ir_set_affinity(struct irq_data *data, const struct cpumask *mask,* at the new destination. So, time to cleanup the previous * vector allocation. */ -if (cfg->move_in_progress) -send_cleanup_vector (cfg); +send_cleanup_vector (cfg);return IRQ_SET_MASK_OK_DONE ; }
Signature · 1 line
1.7.10.4
PATCH v3 34/38 x86, irq: Move private data in struct irq_cfg into dedicated data structure
In reply to Jiang LiuSeveral fields in struct irq_cfg are private to vector.c, so move it into dedicated data structure. This helps to hide implementation details.
--- arch/x86/include/asm/hw_irq.h | 3 - arch/x86/kernel/apic/vector.c | 221 ++++++++++++++++++++++------------------- 2 files changed, 119 insertions(+), 105 deletions(-)
arch/x86/include/asm/hw_irq.h +0 -3
@@ -169,11 +169,8 @@ struct irq_alloc_info {#define X86_IRQ_ALLOC_CONTIGOUS_VECTORS 0x1struct irq_cfg { -cpumask_var_t domain; -cpumask_var_t old_domain;unsigned int dest_apicid;u8 vector; -u8 move_in_progress :1 ; };extern struct irq_domain *x86_vector_domain;
arch/x86/kernel/apic/vector.c +119 -102
484 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 35/38 x86, irq: Refine the way to calculate NR_IRQS
In reply to Jiang LiuNow we have made MSI independent of IOAPIC, so we need to refine the way to calculate NR_IRQS to support configuration with MSI enabled but IOAPIC disabled.
--- arch/x86/include/asm/irq_vectors.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
arch/x86/include/asm/irq_vectors.h +11 -7
@@ -155,18 +155,22 @@ static inline int invalid_vm86_irq(int irq)* static arrays. */ -#define NR_IRQS_LEGACY 16 +#define NR_IRQS_LEGACY 16 -#define IO_APIC_VECTOR_LIMIT ( 32 * MAX_IO_APICS ) +#define CPU_VECTOR_LIMIT (64 * NR_CPUS) +#define IO_APIC_VECTOR_LIMIT (32 * MAX_IO_APICS) -#ifdef CONFIG_X86_IO_APIC -# define CPU_VECTOR_LIMIT (64 * NR_CPUS) -# define NR_IRQS \ +#if defined(CONFIG_X86_IO_APIC ) && defined(CONFIG_PCI_MSI ) +#define NR_IRQS \ (CPU_VECTOR_LIMIT > IO_APIC_VECTOR_LIMIT ? \ (NR_VECTORS + CPU_VECTOR_LIMIT) : \ (NR_VECTORS + IO_APIC_VECTOR_LIMIT)) -#else /* !CONFIG_X86_IO_APIC: */ -# define NR_IRQS NR_IRQS_LEGACY +#elif defined(CONFIG_X86_IO_APIC ) +#define NR_IRQS (NR_VECTORS + IO_APIC_VECTOR_LIMIT) +#elif defined(CONFIG_PCI_MSI ) +#define NR_IRQS (NR_VECTORS + CPU_VECTOR_LIMIT) +#else +#define NR_IRQS NR_IRQS_LEGACY#endif #endif /* _ASM_X86_IRQ_VECTORS_H */
Signature · 1 line
1.7.10.4
PATCH v3 36/38 ACPI, irq, x86: Kill private function mp_register_gsi()/ mp_unregister_gsi()
In reply to Jiang LiuFunction mp_register_gsi() is only called once, so fold it into caller acpi_register_gsi_ioapic(). Do the same for mp_unregister_gsi().
--- arch/x86/kernel/acpi/boot.c | 57 ++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 39 deletions(-)
arch/x86/kernel/acpi/boot.c +18 -39
@@ -400,42 +400,6 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,return 0 ; } -static int mp_register_gsi (struct device *dev,u32 gsi,int trigger, -int polarity) -{ -int irq, node; -struct irq_alloc_info info; - -if (acpi_irq_model !=ACPI_IRQ_MODEL_IOAPIC ) -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 ; -ioapic_set_alloc_attr (&info, node, trigger, polarity); - irq =mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC , &info); -if (irq <0 ) -return irq; - -/* Don't set up the ACPI SCI because it's already set up */ -if (enable_update_mptable && acpi_gbl_FADT.sci_interrupt != gsi) -mp_config_acpi_gsi (dev, gsi, trigger, polarity); - -return irq; -} - -static void mp_unregister_gsi (u32 gsi) -{ -int irq; - -if (acpi_irq_model !=ACPI_IRQ_MODEL_IOAPIC ) -return ; - - irq =mp_map_gsi_to_irq (gsi,0 ,NULL ); -if (irq >0 ) -mp_unmap_irq (irq); -} -static struct irq_domain_ops acpi_irqdomain_ops = { .alloc = mp_irqdomain_alloc, .free = mp_irqdomain_free,
@@ -657,10 +621,21 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi, int trigger, int polarity) { int irq = gsi; -#ifdef CONFIG_X86_IO_APIC +int node; +struct irq_alloc_info info; + + node = dev ?dev_to_node (dev) :NUMA_NO_NODE ; + trigger = trigger ==ACPI_EDGE_SENSITIVE ?0 :1 ; + polarity = polarity ==ACPI_ACTIVE_HIGH ?0 :1 ; +ioapic_set_alloc_attr (&info, node, trigger, polarity); +mutex_lock (&acpi_ioapic_lock); - irq =mp_register_gsi (dev, gsi, trigger, polarity); + irq =mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC , &info); +/* Don't set up the ACPI SCI because it's already set up */ +if (irq >=0 && enable_update_mptable && + acpi_gbl_FADT.sci_interrupt != gsi) +mp_config_acpi_gsi (dev, gsi, trigger, polarity);mutex_unlock (&acpi_ioapic_lock);#endif
@@ -670,8 +645,12 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,static void acpi_unregister_gsi_ioapic (u32 gsi) {#ifdef CONFIG_X86_IO_APIC +int irq; +mutex_lock (&acpi_ioapic_lock); -mp_unregister_gsi (gsi); + irq =mp_map_gsi_to_irq (gsi,0 ,NULL ); +if (irq >0 ) +mp_unmap_irq (irq);mutex_unlock (&acpi_ioapic_lock);#endif }
Signature · 1 line
1.7.10.4
PATCH v3 37/38 x86, irq: Introduce mechanism to support different vector allocation policies
In reply to Jiang LiuIntroduce mechanism to support different vector allocation policies, so platform or user may choose the best suitable CPU vector allocation policy. Currently two policies are supported:
1) allocate CPU vector from cpumask_of_node(dev_to_node(dev))
2) allocate from apic->target_cpus(), this is the default policy
Platform driver may call set_vector_alloc_policy() to choose the preferred policies.
This mechanism may be used to support NumaConnect systems to allocate CPU vectors from device local node.
We may also enhance to support per-cpu vector allocation if it's needed.
--- arch/x86/include/asm/hw_irq.h | 12 ++++++++ arch/x86/kernel/apic/vector.c | 66 +++++++++++++++++++++++++++++++++++------ 2 files changed, 69 insertions(+), 9 deletions(-)
arch/x86/include/asm/hw_irq.h +12 -0
@@ -168,6 +168,17 @@ struct irq_alloc_info {/* Request contigious CPU vectors */ #define X86_IRQ_ALLOC_CONTIGOUS_VECTORS 0x1 +enum { +/* Allocate vector from cpumask_of_node(dev_to_node(dev)) */ +X86_VECTOR_POL_NODE =0x1 , +/* Allocate vector from apic->target_cpus() */ +X86_VECTOR_POL_DEFAULT =0x2 , +/* Allocate vector from cpumask assigned by caller */ +X86_VECTOR_POL_CALLER =0x4 , +X86_VECTOR_POL_MIN =X86_VECTOR_POL_NODE , +X86_VECTOR_POL_MAX =X86_VECTOR_POL_CALLER , +}; +struct irq_cfg {unsigned int dest_apicid;u8 vector;
@@ -183,6 +194,7 @@ extern struct irq_cfg *irq_cfg(unsigned int irq);extern struct irq_cfg *irqd_cfg (struct irq_data *irq_data);extern void lock_vector_lock (void );extern void unlock_vector_lock (void ); +extern void set_vector_alloc_policy (unsigned int policy);extern void setup_vector_irq (int cpu);#ifdef CONFIG_SMP extern void send_cleanup_vector (struct irq_cfg *);
arch/x86/kernel/apic/vector.c +57 -9
108 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 38/38 x86, irq: Add kernel parameter vector_alloc to set CPU vector allocation policy
In reply to Jiang LiuParameter vector_alloc should be set to an integer with:
bit 0: enable allocating CPU vector from CPUs on device local node.
That's to allocate from cpumask_of_node(irq_data->node).
bit 1: enable the default policy, which is to allocate from
apic->target_cpus().When allocating vectors, it tries all enabled policies from lower bit position to higher bit position.
This option could be use to optimize interrupt distribution on large system such as NumaChip etc.
--- Documentation/kernel-parameters.txt | 6 ++++++ arch/x86/kernel/apic/vector.c | 11 +++++++++++ 2 files changed, 17 insertions(+)
Documentation/kernel-parameters.txt +6 -0
@@ -3709,6 +3709,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted. vector= [IA-64,SMP] vector=percpu: enable percpu vector domain + vector_alloc= [x86,SMP] + vector_alloc=policy: policy is a bitmap, bit 0 + for allocating CPU vector from CPUs on device local + node; bit 1 for the default policy to allocating from + apic->target_cpus(). All higher bits are reserved. + video= [FB] Frame buffer configuration See Documentation/fb/modedb.txt.
arch/x86/kernel/apic/vector.c +11 -0
@@ -79,6 +79,17 @@ void set_vector_alloc_policy(unsigned int policy) x86_vector_alloc_policy = policy |X86_VECTOR_POL_CALLER ; } +static int __init apic_parse_vector_policy (char *str) +{ +int policy; + +if (get_option (&str, &policy) ==1 ) +set_vector_alloc_policy (policy); + +return 1 ; +} +__setup ("vector_alloc=" , apic_parse_vector_policy); +static struct apic_chip_data *alloc_apic_chip_data (int node) {struct apic_chip_data *data;
Signature · 1 line
1.7.10.4
Hi Jiang,
Quoted 17 lines · Jiang Liu
This is the last part to enable support of hierarchy domain on x86 platforms.
It first converts IOAPIC to support hierarchy irqdomain, then cleans up all unused code and interfaces. It also introduces a kernel boot parameter to configure CPU vector allocation policies.
It's based on my previous patch set at:
https://www.mail-archive.com/[email protected]/msg760868.html
And you may access it at:
https://github.com/jiangliu/linux.git irqdomain/p3v3It has been tested on Intel 64-bit server and 32-bit laptop. It also passes Fengguang's 0day tests. Helps are welcomed for testing:
1) Intel MID platform
2) Intel CE or OLPC platforms
Quoted 5 lines
Patch 1-3 kills
pre_init_apic_IRQ0().
Patch 4-9 convert IOAPIC to use hierarch irqdomain
Patch 10-36 clean up code, unused interfaces etc.
Patch 37-38 introduces a mechanism to configure CPU vector allocation
policies.
Did some more testing on my machines and it looks good now, no more boot panics or other anomalies. So feel free to add my
Quoted 26 lines · Joerg Roedel
Hi Jiang,
Quoted 17 lines · Jiang Liu
This is the last part to enable support of hierarchy domain on x86 platforms.
It first converts IOAPIC to support hierarchy irqdomain, then cleans up all unused code and interfaces. It also introduces a kernel boot parameter to configure CPU vector allocation policies.
It's based on my previous patch set at:
https://www.mail-archive.com/[email protected]/msg760868.html
And you may access it at:
https://github.com/jiangliu/linux.git irqdomain/p3v3It has been tested on Intel 64-bit server and 32-bit laptop. It also passes Fengguang's 0day tests. Helps are welcomed for testing:
1) Intel MID platform
2) Intel CE or OLPC platformsQuoted 5 lines
Patch 1-3 kills
pre_init_apic_IRQ0().
Patch 4-9 convert IOAPIC to use hierarch irqdomain
Patch 10-36 clean up code, unused interfaces etc.
Patch 37-38 introduces a mechanism to configure CPU vector allocation
policies.
Quoted 4 lines
Did some more testing on my machines and it looks good now, no more boot panics or other anomalies. So feel free to add my
Tested-by Joerg Roedel <[email protected]>
Thanks, Joerg:)