From 6501ab5e380cf25dad85705856bfdde439dbcbd2 Mon Sep 17 00:00:00 2001 From: Pranith Kumar Date: Wed, 21 Jan 2015 21:26:09 -0500 Subject: powerpc/powernv: Skip registering log region when CONFIG_PRINTK=n When CONFIG_PRINTK=n, log_buf_addr_get() returns NULL and log_buf_len_get() return 0. Check for these return values and skip registering the dump buffer. Signed-off-by: Pranith Kumar Reviewed-by: Stewart Smith Signed-off-by: Michael Ellerman --- arch/powerpc/platforms/powernv/opal.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'arch/powerpc/platforms/powernv/opal.c') diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index f10b9ec8c1f5..1db119f0f4ee 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -667,7 +667,13 @@ static void __init opal_dump_region_init(void) /* Register kernel log buffer */ addr = log_buf_addr_get(); + if (addr == NULL) + return; + size = log_buf_len_get(); + if (size == 0) + return; + rc = opal_register_dump_region(OPAL_DUMP_REGION_LOG_BUF, __pa(addr), size); /* Don't warn if this is just an older OPAL that doesn't -- cgit v1.2.2 From 08135139430fabdeaa990da8a9e0d436aad0672b Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Wed, 28 Jan 2015 15:10:33 +1100 Subject: powerpc/powernv: Remove "opal" prefix from pr_xxx()s In commit c8742f85125d "powerpc/powernv: Expose OPAL firmware symbol map" I added pr_fmt() to opal.c. This left some existing pr_xxx()s with duplicate "opal" prefixes, eg: opal: opal: Found 0 interrupts reserved for OPAL Fix them all up. Also make the "Not not found" message a bit more verbose. Signed-off-by: Michael Ellerman --- arch/powerpc/platforms/powernv/opal.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'arch/powerpc/platforms/powernv/opal.c') diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 1db119f0f4ee..8f5bbfae9c32 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -208,7 +208,7 @@ static int __init opal_register_exception_handlers(void) * start catching/handling HMI directly in Linux. */ if (!opal_check_token(OPAL_HANDLE_HMI)) { - pr_info("opal: Old firmware detected, OPAL handles HMIs.\n"); + pr_info("Old firmware detected, OPAL handles HMIs.\n"); opal_register_exception_handler( OPAL_HYPERVISOR_MAINTENANCE_HANDLER, 0, glue); @@ -709,7 +709,7 @@ static int __init opal_init(void) opal_node = of_find_node_by_path("/ibm,opal"); if (!opal_node) { - pr_warn("opal: Node not found\n"); + pr_warn("Device node not found\n"); return -ENODEV; } @@ -732,7 +732,7 @@ static int __init opal_init(void) /* Find all OPAL interrupts and request them */ irqs = of_get_property(opal_node, "opal-interrupts", &irqlen); - pr_debug("opal: Found %d interrupts reserved for OPAL\n", + pr_debug("Found %d interrupts reserved for OPAL\n", irqs ? (irqlen / 4) : 0); opal_irq_count = irqlen / 4; opal_irqs = kzalloc(opal_irq_count * sizeof(unsigned int), GFP_KERNEL); @@ -740,13 +740,13 @@ static int __init opal_init(void) unsigned int hwirq = be32_to_cpup(irqs); unsigned int irq = irq_create_mapping(NULL, hwirq); if (irq == NO_IRQ) { - pr_warning("opal: Failed to map irq 0x%x\n", hwirq); + pr_warning("Failed to map irq 0x%x\n", hwirq); continue; } rc = request_irq(irq, opal_interrupt, 0, "opal", NULL); if (rc) - pr_warning("opal: Error %d requesting irq %d" - " (0x%x)\n", rc, irq, hwirq); + pr_warning("Error %d requesting irq %d (0x%x)\n", + rc, irq, hwirq); opal_irqs[i] = irq; } -- cgit v1.2.2 From c1c3a526bb4ddbec7639a9fb3b84fede25b201d9 Mon Sep 17 00:00:00 2001 From: Gavin Shan Date: Fri, 23 Jan 2015 14:25:05 +1100 Subject: powerpc/powernv: Separate function for OPAL IRQ setup The patch put the OPAL interrupt setup logic in opal_init() into seperate function opal_irq_init() for easier code maintaining. The patch doesn't introduce logic changes except: * Rename variable names. * Release virtual IRQ upon error from request_irq(). * Don't cache the virtual IRQ to opal_irqs[] upon error from request_irq(). Suggested-by: Michael Ellerman Signed-off-by: Gavin Shan Signed-off-by: Michael Ellerman --- arch/powerpc/platforms/powernv/opal.c | 61 +++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 20 deletions(-) (limited to 'arch/powerpc/platforms/powernv/opal.c') diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 8f5bbfae9c32..933c7fbd6b54 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -701,11 +701,49 @@ static void opal_i2c_create_devs(void) of_platform_device_create(np, NULL, NULL); } +static void __init opal_irq_init(struct device_node *dn) +{ + const __be32 *irqs; + int i, irqlen; + + /* Get interrupt property */ + irqs = of_get_property(opal_node, "opal-interrupts", &irqlen); + pr_debug("Found %d interrupts reserved for OPAL\n", + irqs ? (irqlen / 4) : 0); + + /* Install interrupt handlers */ + opal_irq_count = irqlen / 4; + opal_irqs = kzalloc(opal_irq_count * sizeof(unsigned int), GFP_KERNEL); + for (i = 0; irqs && i < opal_irq_count; i++, irqs++) { + unsigned int irq, virq; + int rc; + + /* Get hardware and virtual IRQ */ + irq = be32_to_cpup(irqs); + virq = irq_create_mapping(NULL, irq); + if (virq == NO_IRQ) { + pr_warn("Failed to map irq 0x%x\n", irq); + continue; + } + + /* Install interrupt handler */ + rc = request_irq(virq, opal_interrupt, 0, "opal", NULL); + if (rc) { + irq_dispose_mapping(virq); + pr_warn("Error %d requesting irq %d (0x%x)\n", + rc, virq, irq); + continue; + } + + /* Cache IRQ */ + opal_irqs[i] = virq; + } +} + static int __init opal_init(void) { struct device_node *np, *consoles; - const __be32 *irqs; - int rc, i, irqlen; + int rc; opal_node = of_find_node_by_path("/ibm,opal"); if (!opal_node) { @@ -731,24 +769,7 @@ static int __init opal_init(void) opal_i2c_create_devs(); /* Find all OPAL interrupts and request them */ - irqs = of_get_property(opal_node, "opal-interrupts", &irqlen); - pr_debug("Found %d interrupts reserved for OPAL\n", - irqs ? (irqlen / 4) : 0); - opal_irq_count = irqlen / 4; - opal_irqs = kzalloc(opal_irq_count * sizeof(unsigned int), GFP_KERNEL); - for (i = 0; irqs && i < (irqlen / 4); i++, irqs++) { - unsigned int hwirq = be32_to_cpup(irqs); - unsigned int irq = irq_create_mapping(NULL, hwirq); - if (irq == NO_IRQ) { - pr_warning("Failed to map irq 0x%x\n", hwirq); - continue; - } - rc = request_irq(irq, opal_interrupt, 0, "opal", NULL); - if (rc) - pr_warning("Error %d requesting irq %d (0x%x)\n", - rc, irq, hwirq); - opal_irqs[i] = irq; - } + opal_irq_init(opal_node); /* Create "opal" kobject under /sys/firmware */ rc = opal_sysfs_init(); -- cgit v1.2.2 From 31494cf3532cfee0bf5c913ac9962971aab7b1d4 Mon Sep 17 00:00:00 2001 From: Gavin Shan Date: Fri, 23 Jan 2015 14:25:06 +1100 Subject: powerpc/powernv: Don't alloc IRQ map if necessary On PowerNV platform, the OPAL interrupts are exported by firmware through device-node property (/ibm,opal::opal-interrupts). Under some extreme circumstances (e.g. simulator), we don't have this property found from the device tree. For that case, we shouldn't allocate the interrupt map. Otherwise, slab complains allocating zero sized memory chunk. Signed-off-by: Gavin Shan Signed-off-by: Michael Ellerman --- arch/powerpc/platforms/powernv/opal.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'arch/powerpc/platforms/powernv/opal.c') diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 933c7fbd6b54..18fd4e71c9c1 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -708,11 +708,12 @@ static void __init opal_irq_init(struct device_node *dn) /* Get interrupt property */ irqs = of_get_property(opal_node, "opal-interrupts", &irqlen); - pr_debug("Found %d interrupts reserved for OPAL\n", - irqs ? (irqlen / 4) : 0); + opal_irq_count = irqs ? (irqlen / 4) : 0; + pr_debug("Found %d interrupts reserved for OPAL\n", opal_irq_count); + if (!opal_irq_count) + return; /* Install interrupt handlers */ - opal_irq_count = irqlen / 4; opal_irqs = kzalloc(opal_irq_count * sizeof(unsigned int), GFP_KERNEL); for (i = 0; irqs && i < opal_irq_count; i++, irqs++) { unsigned int irq, virq; -- cgit v1.2.2