From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031463AbbDXPzI (ORCPT ); Fri, 24 Apr 2015 11:55:08 -0400 Received: from terminus.zytor.com ([198.137.202.10]:44420 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030332AbbDXPzB (ORCPT ); Fri, 24 Apr 2015 11:55:01 -0400 Date: Fri, 24 Apr 2015 08:53:56 -0700 From: tip-bot for Jiang Liu Message-ID: Cc: jiang.liu@linux.intel.com, tglx@linutronix.de, joro@8bytes.org, linux-kernel@vger.kernel.org, hpa@zytor.com, rdunlap@infradead.org, jroedel@suse.de, benh@kernel.crashing.org, gregkh@linuxfoundation.org, yinghai@kernel.org, bhelgaas@google.com, rjw@rjwysocki.net, david.a.cohen@linux.intel.com, bp@alien8.de, david.vrabel@citrix.com, konrad.wilk@oracle.com, sivanich@sgi.com, mingo@kernel.org, tony.luck@intel.com, grant.likely@linaro.org, linux@eikelenboom.it Reply-To: david.vrabel@citrix.com, konrad.wilk@oracle.com, david.a.cohen@linux.intel.com, bp@alien8.de, bhelgaas@google.com, yinghai@kernel.org, gregkh@linuxfoundation.org, rjw@rjwysocki.net, rdunlap@infradead.org, jroedel@suse.de, benh@kernel.crashing.org, grant.likely@linaro.org, linux@eikelenboom.it, tony.luck@intel.com, sivanich@sgi.com, mingo@kernel.org, tglx@linutronix.de, jiang.liu@linux.intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, joro@8bytes.org In-Reply-To: <1428905519-23704-37-git-send-email-jiang.liu@linux.intel.com> References: <1428905519-23704-37-git-send-email-jiang.liu@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/apic] x86/irq: Introduce helper functions to support hierarchical irqdomains for IOAPIC Git-Commit-ID: 96ed44b2d5e0e9d6e5b135e84ea5c8cd763ce861 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 96ed44b2d5e0e9d6e5b135e84ea5c8cd763ce861 Gitweb: http://git.kernel.org/tip/96ed44b2d5e0e9d6e5b135e84ea5c8cd763ce861 Author: Jiang Liu AuthorDate: Mon, 13 Apr 2015 14:11:58 +0800 Committer: Thomas Gleixner CommitDate: Fri, 24 Apr 2015 15:36:51 +0200 x86/irq: Introduce helper functions to support hierarchical irqdomains for IOAPIC Introduce several helper functions, which will be used to enable hierarchical irqdomain for IOAPIC. Signed-off-by: Jiang Liu Tested-by: Joerg Roedel Cc: Konrad Rzeszutek Wilk Cc: David Cohen Cc: Sander Eikelenboom Cc: David Vrabel Cc: Tony Luck Cc: Joerg Roedel Cc: Greg Kroah-Hartman Cc: Bjorn Helgaas Cc: Benjamin Herrenschmidt Cc: Rafael J. Wysocki Cc: Randy Dunlap Cc: Yinghai Lu Cc: Borislav Petkov Cc: Dimitri Sivanich Cc: Grant Likely Link: http://lkml.kernel.org/r/1428905519-23704-37-git-send-email-jiang.liu@linux.intel.com Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/io_apic.c | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 3c66096..c8f786b 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -82,6 +82,7 @@ struct mp_chip_data { struct IO_APIC_route_entry entry; int trigger; int polarity; + u32 count; bool isa_irq; }; @@ -945,6 +946,46 @@ void ioapic_set_alloc_attr(struct irq_alloc_info *info, int node, info->ioapic_valid = 1; } +#ifndef CONFIG_ACPI +int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity); +#endif + +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 +1003,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) {