From patchwork Tue May 5 13:50:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 48033 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 50CC120553 for ; Tue, 5 May 2015 13:52:51 +0000 (UTC) Received: by lbos2 with SMTP id s2sf50649504lbo.2 for ; Tue, 05 May 2015 06:52:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=mjZgw82Flvvh6+GuKqFIWZwEu1lTTT0aAo5daj5GdHU=; b=a0J06xRbgMvjD1Du+KSbtKH5jdEKZeyCbpvu9ZhnC4lntxLrzBZo2AreuN9330B+Xp 652hRzmpjpYf6R0x1e3V252A2CZ2DWknaCG43cHUMPiPnOY/bkQWJjc2WihDMum/NqIk sDlYHivVZlztSYtVRTnzjgRN9Qpa3JeEAZMhFnrQXEKA5oIU4IpRPI7tJivrVEcoNU0H DM9ejr4gTTi6zo4S9JXA31ePIK74CfLiADJn/ivt8rzls+fFPfhflP7B8CjtsClNibkj +aVuewsxReTRS18dObZ7CLJa577yu6c35OF1kSg1E8x8IzTv42vWr23kBjlrzTZcF22r m63Q== X-Gm-Message-State: ALoCoQmAkHs6wmQywlT9RBEwHNQUPUZPReW2v6J1tHkNmJUSshRe9HdAjoGFdx8ozO4gsi7biHNY X-Received: by 10.180.107.33 with SMTP id gz1mr1548264wib.3.1430833970198; Tue, 05 May 2015 06:52:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.102 with SMTP id s6ls887072lag.73.gmail; Tue, 05 May 2015 06:52:50 -0700 (PDT) X-Received: by 10.152.204.7 with SMTP id ku7mr2048604lac.38.1430833970040; Tue, 05 May 2015 06:52:50 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id y10si12492157lal.107.2015.05.05.06.52.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2015 06:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by layy10 with SMTP id y10so127971652lay.0 for ; Tue, 05 May 2015 06:52:50 -0700 (PDT) X-Received: by 10.152.2.227 with SMTP id 3mr23793092lax.73.1430833969944; Tue, 05 May 2015 06:52:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp2262278lbt; Tue, 5 May 2015 06:52:49 -0700 (PDT) X-Received: by 10.68.65.38 with SMTP id u6mr51102482pbs.41.1430833966005; Tue, 05 May 2015 06:52:46 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qx10si24428540pab.186.2015.05.05.06.52.45; Tue, 05 May 2015 06:52:45 -0700 (PDT) Received-SPF: none (google.com: linux-acpi-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992730AbbEENwn (ORCPT + 7 others); Tue, 5 May 2015 09:52:43 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:34574 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2992726AbbEENwh (ORCPT ); Tue, 5 May 2015 09:52:37 -0400 Received: by pdbqa5 with SMTP id qa5so196558835pdb.1 for ; Tue, 05 May 2015 06:52:35 -0700 (PDT) X-Received: by 10.68.108.65 with SMTP id hi1mr51390358pbb.129.1430833955490; Tue, 05 May 2015 06:52:35 -0700 (PDT) Received: from localhost ([180.150.157.4]) by mx.google.com with ESMTPSA id en2sm16176028pab.14.2015.05.05.06.52.32 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 05 May 2015 06:52:33 -0700 (PDT) From: Hanjun Guo To: Marc Zyngier , Jason Cooper , Will Deacon , Catalin Marinas , "Rafael J. Wysocki" Cc: Jiang Liu , Lorenzo Pieralisi , Arnd Bergmann , Tomasz Nowicki , Grant Likely , Thomas Gleixner , Olof Johansson , linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Hanjun Guo Subject: [RFC PATCH 4/9] irqchip: gic: ACPI: Use IRQCHIP_ACPI_DECLARE to simplify GICv2 init code Date: Tue, 5 May 2015 21:50:52 +0800 Message-Id: <1430833857-30736-5-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430833857-30736-1-git-send-email-hanjun.guo@linaro.org> References: <1430833857-30736-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , As the ACPI self-probe infrastructure for irqchip is ready, we use the infrastructure and the GIC version to simplify GICv2 init code. >From now on, GIC init calls reside in theirs drivers only. This means the code becomes cleaner and it is not spread outside irqchip driver. Signed-off-by: Hanjun Guo --- arch/arm64/include/asm/irq.h | 13 ------------- arch/arm64/kernel/acpi.c | 25 ------------------------- drivers/acpi/irq.c | 2 +- drivers/irqchip/irq-gic-acpi.c | 5 +++++ drivers/irqchip/irq-gic.c | 6 +++++- include/linux/acpi_irq.h | 4 +++- include/linux/irqchip/arm-gic-acpi.h | 10 ++-------- 7 files changed, 16 insertions(+), 49 deletions(-) diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h index bbb251b..94c5367 100644 --- a/arch/arm64/include/asm/irq.h +++ b/arch/arm64/include/asm/irq.h @@ -1,8 +1,6 @@ #ifndef __ASM_IRQ_H #define __ASM_IRQ_H -#include - #include struct pt_regs; @@ -10,15 +8,4 @@ struct pt_regs; extern void migrate_irqs(void); extern void set_handle_irq(void (*handle_irq)(struct pt_regs *)); -static inline void acpi_irq_init(void) -{ - /* - * Hardcode ACPI IRQ chip initialization to GICv2 for now. - * Proper irqchip infrastructure will be implemented along with - * incoming GICv2m|GICv3|ITS bits. - */ - acpi_gic_init(); -} -#define acpi_irq_init acpi_irq_init - #endif diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 8b83955..69809e7 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -318,28 +318,3 @@ void __init acpi_boot_table_init(void) disable_acpi(); } } - -void __init acpi_gic_init(void) -{ - struct acpi_table_header *table; - acpi_status status; - acpi_size tbl_size; - int err; - - if (acpi_disabled) - return; - - status = acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table, &tbl_size); - if (ACPI_FAILURE(status)) { - const char *msg = acpi_format_exception(status); - - pr_err("Failed to get MADT table, %s\n", msg); - return; - } - - err = gic_v2_acpi_init(table); - if (err) - pr_err("Failed to initialize GIC IRQ controller"); - - early_acpi_os_unmap_memory((char *)table, tbl_size); -} diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index 855ead9..7bd1ef6 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -25,7 +25,7 @@ irqchip_acpi_match_end __used __section(__irqchip_acpi_table_end); extern struct acpi_table_id __irqchip_acpi_table[]; -void __init acpi_irqchip_init(void) +void __init acpi_irq_init(void) { struct acpi_table_id *id; diff --git a/drivers/irqchip/irq-gic-acpi.c b/drivers/irqchip/irq-gic-acpi.c index 4796f07..7172ff1 100644 --- a/drivers/irqchip/irq-gic-acpi.c +++ b/drivers/irqchip/irq-gic-acpi.c @@ -21,6 +21,11 @@ static u8 gic_version __initdata = ACPI_MADT_GIC_VER_UNKNOWN; static phys_addr_t dist_phy_base __initdata; +u8 __init acpi_gic_version(void) +{ + return gic_version; +} + static int __init acpi_gic_parse_distributor(struct acpi_subtable_header *header, const unsigned long end) diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 7b315e3..476dc7b 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -1154,12 +1154,15 @@ gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header, return 0; } -int __init +static int __init gic_v2_acpi_init(struct acpi_table_header *table) { void __iomem *cpu_base, *dist_base; int count; + if (acpi_gic_version() >= ACPI_MADT_GIC_VER_V3) + return -ENODEV; + /* Collect CPU base addresses */ count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt), @@ -1210,4 +1213,5 @@ gic_v2_acpi_init(struct acpi_table_header *table) acpi_irq_model = ACPI_IRQ_MODEL_GIC; return 0; } +IRQCHIP_ACPI_DECLARE(gic_v2, ACPI_SIG_MADT, gic_v2_acpi_init); #endif diff --git a/include/linux/acpi_irq.h b/include/linux/acpi_irq.h index f10c872..4c0e108 100644 --- a/include/linux/acpi_irq.h +++ b/include/linux/acpi_irq.h @@ -3,7 +3,9 @@ #include -#ifndef acpi_irq_init +#ifdef CONFIG_ACPI +void acpi_irq_init(void); +#else static inline void acpi_irq_init(void) { } #endif diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h index 0d5f204..021e8e8 100644 --- a/include/linux/irqchip/arm-gic-acpi.h +++ b/include/linux/irqchip/arm-gic-acpi.h @@ -21,13 +21,7 @@ #define ACPI_GIC_CPU_IF_MEM_SIZE (SZ_8K) #define ACPI_GICV3_DIST_MEM_SIZE (SZ_64K) -struct acpi_table_header; - -int gic_v2_acpi_init(struct acpi_table_header *table); -void acpi_gic_init(void); int acpi_gic_version_init(void); -#else -static inline void acpi_gic_init(void) { } -#endif - +u8 acpi_gic_version(void); +#endif /* CONFIG_ACPI */ #endif /* ARM_GIC_ACPI_H_ */