From patchwork Tue Feb 23 11:30:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8391051 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9F21DC0553 for ; Tue, 23 Feb 2016 11:32:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D5ED202F8 for ; Tue, 23 Feb 2016 11:32:40 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F94D20274 for ; Tue, 23 Feb 2016 11:32:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aYBAO-0002tw-Ty; Tue, 23 Feb 2016 11:30:08 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aYBAO-0002sw-0s for xen-devel@lists.xenproject.org; Tue, 23 Feb 2016 11:30:08 +0000 Received: from [193.109.254.147] by server-11.bemta-14.messagelabs.com id 01/5C-28228-FB24CC65; Tue, 23 Feb 2016 11:30:07 +0000 X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1456227004!13803611!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42776 invoked from network); 23 Feb 2016 11:30:05 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-14.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 23 Feb 2016 11:30:05 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Tue, 23 Feb 2016 04:30:03 -0700 Message-Id: <56CC50C902000078000D52D7@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Tue, 23 Feb 2016 04:30:01 -0700 From: "Jan Beulich" To: "xen-devel" References: <56CC4F0B02000078000D5290@prv-mh.provo.novell.com> In-Reply-To: <56CC4F0B02000078000D5290@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Ian Campbell , Andrew Cooper , Keir Fraser , Ian Jackson , Tim Deegan Subject: [Xen-devel] [PATCH 3/4] console: adjust IRQ initialization X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order for a Xen internal PCI device driver to enable MSI on the device, we need another hook which the driver can use to create the IRQ (doing this in the init_preirq hook is too early, since IRQ code hasn't got initialized at that time yet, and doing it in init_postirq is too late because at least on x86 smp_intr_init() needs to know the IRQ number). On x86 this additionally requires a slight ordering change to IRQ initialization, to facilitate calling the new hook between basic initialization and the call path leading to smp_intr_init(). Signed-off-by: Jan Beulich console: adjust IRQ initialization In order for a Xen internal PCI device driver to enable MSI on the device, we need another hook which the driver can use to create the IRQ (doing this in the init_preirq hook is too early, since IRQ code hasn't got initialized at that time yet, and doing it in init_postirq is too late because at least on x86 smp_intr_init() needs to know the IRQ number). On x86 this additionally requires a slight ordering change to IRQ initialization, to facilitate calling the new hook between basic initialization and the call path leading to smp_intr_init(). Signed-off-by: Jan Beulich --- a/xen/arch/x86/i8259.c +++ b/xen/arch/x86/i8259.c @@ -342,8 +342,6 @@ void __init init_IRQ(void) init_8259A(0); - BUG_ON(init_irq_data() < 0); - for (irq = 0; platform_legacy_irq(irq); irq++) { struct irq_desc *desc = irq_to_desc(irq); --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -576,6 +576,7 @@ void __init noreturn __start_xen(unsigne unsigned long nr_pages, raw_max_page, modules_headroom, *module_map; int i, j, e820_warn = 0, bytes = 0; bool_t acpi_boot_table_init_done = 0; + int ret; struct domain *dom0; struct ns16550_defaults ns16550 = { .data_bits = 8, @@ -1281,6 +1282,12 @@ void __init noreturn __start_xen(unsigne x2apic_bsp_setup(); + ret = init_irq_data(); + if ( ret < 0 ) + panic("Error %d setting up IRQ data\n", ret); + + console_init_irq(); + init_IRQ(); module_map = xmalloc_array(unsigned long, BITS_TO_LONGS(mbi->mods_count)); @@ -1366,7 +1373,7 @@ void __init noreturn __start_xen(unsigne if ( (num_online_cpus() < max_cpus) && !cpu_online(i) ) { - int ret = cpu_up(i); + ret = cpu_up(i); if ( ret != 0 ) printk("Failed to bring up CPU %u (error %d)\n", i, ret); } --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -771,6 +771,11 @@ void __init console_init_ring(void) printk("Allocated console ring of %u KiB.\n", opt_conring_size >> 10); } +void __init console_init_irq(void) +{ + serial_init_irq(); +} + void __init console_init_postirq(void) { serial_init_postirq(); --- a/xen/drivers/char/serial.c +++ b/xen/drivers/char/serial.c @@ -504,6 +504,15 @@ void __init serial_init_preirq(void) com[i].driver->init_preirq(&com[i]); } +void __init serial_init_irq(void) +{ + unsigned int i; + + for ( i = 0; i < ARRAY_SIZE(com); i++ ) + if ( com[i].driver && com[i].driver->init_irq ) + com[i].driver->init_irq(&com[i]); +} + void __init serial_init_postirq(void) { int i; --- a/xen/include/xen/console.h +++ b/xen/include/xen/console.h @@ -15,6 +15,7 @@ int console_loglvl_op(struct xen_sysctl_ void console_init_preirq(void); void console_init_ring(void); +void console_init_irq(void); void console_init_postirq(void); void console_endboot(void); int console_has(const char *device); --- a/xen/include/xen/serial.h +++ b/xen/include/xen/serial.h @@ -64,6 +64,7 @@ struct serial_port { struct uart_driver { /* Driver initialisation (pre- and post-IRQ subsystem setup). */ void (*init_preirq)(struct serial_port *); + void (*init_irq)(struct serial_port *); void (*init_postirq)(struct serial_port *); /* Hook to clean up after Xen bootstrap (before domain 0 runs). */ void (*endboot)(struct serial_port *); @@ -99,8 +100,9 @@ struct uart_driver { #define SERHND_LO (1<<3) /* Ditto, except that the MSB is cleared. */ #define SERHND_COOKED (1<<4) /* Newline/carriage-return translation? */ -/* Two-stage initialisation (before/after IRQ-subsystem initialisation). */ +/* Three-stage initialisation (before/during/after IRQ-subsystem setup). */ void serial_init_preirq(void); +void serial_init_irq(void); void serial_init_postirq(void); /* Clean-up hook before domain 0 runs. */ Reviewed-by: Konrad Rzeszutek Wilk --- a/xen/arch/x86/i8259.c +++ b/xen/arch/x86/i8259.c @@ -342,8 +342,6 @@ void __init init_IRQ(void) init_8259A(0); - BUG_ON(init_irq_data() < 0); - for (irq = 0; platform_legacy_irq(irq); irq++) { struct irq_desc *desc = irq_to_desc(irq); --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -576,6 +576,7 @@ void __init noreturn __start_xen(unsigne unsigned long nr_pages, raw_max_page, modules_headroom, *module_map; int i, j, e820_warn = 0, bytes = 0; bool_t acpi_boot_table_init_done = 0; + int ret; struct domain *dom0; struct ns16550_defaults ns16550 = { .data_bits = 8, @@ -1281,6 +1282,12 @@ void __init noreturn __start_xen(unsigne x2apic_bsp_setup(); + ret = init_irq_data(); + if ( ret < 0 ) + panic("Error %d setting up IRQ data\n", ret); + + console_init_irq(); + init_IRQ(); module_map = xmalloc_array(unsigned long, BITS_TO_LONGS(mbi->mods_count)); @@ -1366,7 +1373,7 @@ void __init noreturn __start_xen(unsigne if ( (num_online_cpus() < max_cpus) && !cpu_online(i) ) { - int ret = cpu_up(i); + ret = cpu_up(i); if ( ret != 0 ) printk("Failed to bring up CPU %u (error %d)\n", i, ret); } --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -771,6 +771,11 @@ void __init console_init_ring(void) printk("Allocated console ring of %u KiB.\n", opt_conring_size >> 10); } +void __init console_init_irq(void) +{ + serial_init_irq(); +} + void __init console_init_postirq(void) { serial_init_postirq(); --- a/xen/drivers/char/serial.c +++ b/xen/drivers/char/serial.c @@ -504,6 +504,15 @@ void __init serial_init_preirq(void) com[i].driver->init_preirq(&com[i]); } +void __init serial_init_irq(void) +{ + unsigned int i; + + for ( i = 0; i < ARRAY_SIZE(com); i++ ) + if ( com[i].driver && com[i].driver->init_irq ) + com[i].driver->init_irq(&com[i]); +} + void __init serial_init_postirq(void) { int i; --- a/xen/include/xen/console.h +++ b/xen/include/xen/console.h @@ -15,6 +15,7 @@ int console_loglvl_op(struct xen_sysctl_ void console_init_preirq(void); void console_init_ring(void); +void console_init_irq(void); void console_init_postirq(void); void console_endboot(void); int console_has(const char *device); --- a/xen/include/xen/serial.h +++ b/xen/include/xen/serial.h @@ -64,6 +64,7 @@ struct serial_port { struct uart_driver { /* Driver initialisation (pre- and post-IRQ subsystem setup). */ void (*init_preirq)(struct serial_port *); + void (*init_irq)(struct serial_port *); void (*init_postirq)(struct serial_port *); /* Hook to clean up after Xen bootstrap (before domain 0 runs). */ void (*endboot)(struct serial_port *); @@ -99,8 +100,9 @@ struct uart_driver { #define SERHND_LO (1<<3) /* Ditto, except that the MSB is cleared. */ #define SERHND_COOKED (1<<4) /* Newline/carriage-return translation? */ -/* Two-stage initialisation (before/after IRQ-subsystem initialisation). */ +/* Three-stage initialisation (before/during/after IRQ-subsystem setup). */ void serial_init_preirq(void); +void serial_init_irq(void); void serial_init_postirq(void); /* Clean-up hook before domain 0 runs. */