From patchwork Fri Aug 8 23:17:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 35172 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8F18C21457 for ; Fri, 8 Aug 2014 23:20:24 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf25528739oag.0 for ; Fri, 08 Aug 2014 16:20:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=PlW0xgH9kR+DO+5JBIBvOX+qb+0aZ6A1vuZwJVqYq2c=; b=ZScw4ed/71eBAx385FSeXu3gNcCd9sXtsfzyDBVLgJatQf6g5H5TIEyQza1nAk9UMV z3vmfFOjKKKD7h+swKape8ALDzBlrOiqdwIYcxnvAvYkFxu0MuoDuDDhqjoyPytbln7S arrS37son5ci0W3/S75gTpuX1IQDPfAbZ2L2+orfvTvEn6YP+o2Fj+9TPI9g9wB3C9LB GcrteLH0fDL1vFkBJy3j0fsvSHM5Htjtx1/ZAn9n56UcId+c0CIoZFpAGUNWUfhSwWs+ Hnkq9Jt0zEFpqWWoZq/Pshs0pf3V71redVwznJSuPvOaLVaGrEyPsuIZmYxNRVm3nN4f lZew== X-Gm-Message-State: ALoCoQlm0IbExeO+JIdizGsXNCYVUZenijKSGNhGXB5QntCDDjs2iftYy6RfgdHn0ERQg3Sub5f/ X-Received: by 10.42.119.82 with SMTP id a18mr6457553icr.19.1407540024174; Fri, 08 Aug 2014 16:20:24 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.98 with SMTP id 89ls167551qgi.1.gmail; Fri, 08 Aug 2014 16:20:24 -0700 (PDT) X-Received: by 10.220.174.137 with SMTP id t9mr24424869vcz.12.1407540024082; Fri, 08 Aug 2014 16:20:24 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id o10si3364253vdj.82.2014.08.08.16.20.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 16:20:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ik5so9235820vcb.34 for ; Fri, 08 Aug 2014 16:20:24 -0700 (PDT) X-Received: by 10.52.28.231 with SMTP id e7mr37192vdh.55.1407540023608; Fri, 08 Aug 2014 16:20:23 -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.221.37.5 with SMTP id tc5csp160845vcb; Fri, 8 Aug 2014 16:20:23 -0700 (PDT) X-Received: by 10.66.122.175 with SMTP id lt15mr13581515pab.77.1407540022646; Fri, 08 Aug 2014 16:20:22 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id nu1si7107632pbb.216.2014.08.08.16.20.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Aug 2014 16:20:22 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XFtRE-0000zm-QF; Fri, 08 Aug 2014 23:19:08 +0000 Received: from mail-bn1lp0142.outbound.protection.outlook.com ([207.46.163.142] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XFtRA-0000dK-IJ for linux-arm-kernel@lists.infradead.org; Fri, 08 Aug 2014 23:19:05 +0000 Received: from BY1PR0201CA0014.namprd02.prod.outlook.com (25.160.191.152) by BN1PR02MB038.namprd02.prod.outlook.com (10.242.210.152) with Microsoft SMTP Server (TLS) id 15.0.1005.10; Fri, 8 Aug 2014 23:18:41 +0000 Received: from BL2FFO11FD037.protection.gbl (2a01:111:f400:7c09::158) by BY1PR0201CA0014.outlook.office365.com (2a01:111:e400:4814::24) with Microsoft SMTP Server (TLS) id 15.0.1005.10 via Frontend Transport; Fri, 8 Aug 2014 23:18:40 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BL2FFO11FD037.mail.protection.outlook.com (10.173.161.133) with Microsoft SMTP Server id 15.0.990.10 via Frontend Transport; Fri, 8 Aug 2014 23:18:39 +0000 X-WSS-ID: 0NA0GR1-08-MK1-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 20E2ED16062; Fri, 8 Aug 2014 18:18:36 -0500 (CDT) Received: from SATLEXDAG03.amd.com (10.181.40.7) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.2.328.9; Fri, 8 Aug 2014 18:19:07 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by satlexdag03.amd.com (10.181.40.7) with Microsoft SMTP Server id 14.2.328.9; Fri, 8 Aug 2014 19:18:14 -0400 From: To: , , Subject: [PATCH 4/4] irqchip: gic-v2m: Restructure the initalization code for v2m Date: Fri, 8 Aug 2014 18:17:16 -0500 Message-ID: <1407539836-9768-5-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1407539836-9768-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1407539836-9768-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019004)(6009001)(428002)(189002)(199002)(77156001)(88136002)(36756003)(74502001)(101416001)(50466002)(79102001)(95666004)(74662001)(31966008)(105586002)(85306004)(77982001)(106466001)(87936001)(68736004)(97736001)(62966002)(102836001)(48376002)(81342001)(44976005)(4396001)(87286001)(64706001)(21056001)(107046002)(84676001)(93916002)(46102001)(81542001)(77096002)(575784001)(86362001)(53416004)(33646002)(2201001)(92566001)(86152002)(50226001)(92726001)(19580395003)(19580405001)(47776003)(20776003)(229853001)(83322001)(89996001)(80022001)(104166001)(76176999)(76482001)(50986999)(85852003)(83072002)(99396002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR02MB038; H:atltwp02.amd.com; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; MX:1; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 02973C87BC Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-OriginatorOrg: amd4.onmicrosoft.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140808_161904_856197_9F7AF286 X-CRM114-Status: GOOD ( 22.63 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [207.46.163.142 listed in list.dnswl.org] -0.7 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.46.163.142 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record Cc: Mark Rutland , devicetree@vger.kernel.org, pawel.moll@arm.com, linux-doc@vger.kernel.org, Marc Zyngier , Catalin.Marinas@arm.com, Harish.Kasiviswanathan@amd.com, linux-kernel@vger.kernel.org, Will.Deacon@arm.com, Suravee Suthikulpanit , linux-pci@vger.kernel.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: suravee.suthikulpanit@amd.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 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 From: Suravee Suthikulpanit This patch remove register index 4 in gic binding, and introduce the "v2m" subnode. It also changes in the gic_of_init function to probe for v2m subnode before calling the gicv2m_of_init. Besides, this patch also moves the "struct msi_chip" from "struct gic_chip_data" to "struct v2m_data". Signed-off-by: Suravee Suthikulpanit Cc: Mark Rutland Cc: Marc Zyngier Cc: Jason Cooper --- Documentation/devicetree/bindings/arm/gic.txt | 37 +++++++-- drivers/irqchip/irq-gic-v2m.c | 115 +++++++++----------------- drivers/irqchip/irq-gic.c | 30 +++---- drivers/irqchip/irq-gic.h | 10 +-- 4 files changed, 91 insertions(+), 101 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/gic.txt b/Documentation/devicetree/bindings/arm/gic.txt index d2eea0b..9e38abe 100644 --- a/Documentation/devicetree/bindings/arm/gic.txt +++ b/Documentation/devicetree/bindings/arm/gic.txt @@ -12,7 +12,6 @@ Main node required properties: - compatible : should be one of: "arm,gic-400" - "arm,gic-400-v2m" "arm,cortex-a15-gic" "arm,cortex-a9-gic" "arm,cortex-a7-gic" @@ -49,7 +48,6 @@ Main node required properties: 1 | GIC cpu interface register base and size 2 | VGIC interface control register base and size (Optional) 3 | VGIC CPU interface register base and size (Optional) - 4 | GICv2m MSI interface register base and size (Optional) Optional - interrupts : Interrupt source of the parent interrupt controller on @@ -66,9 +64,6 @@ Optional input line is assigned dynamically when the corresponding peripheral's crossbar line is mapped. -- msi-controller : Identifies the node as an MSI controller. - (Required for GICv2m) - Example: intc: interrupt-controller@fff11000 { @@ -109,3 +104,35 @@ Example: <0x2c006000 0x2000>; interrupts = <1 9 0xf04>; }; + + +* GICv2m extension for MSI/MSI-x support (Optional) + +Certain revision of GIC-400 supports MSI/MSI-x via V2M register frame. +This is enabled by specifying v2m sub-node. + +Required properties: + +- msi-controller : Identifies the node as an MSI controller. + +- reg : GICv2m MSI interface register base and size + +Example: + + interrupt-controller@e1101000 { + compatible = "arm,gic-400"; + #interrupt-cells = <3>; + #address-cells = <2>; + #size-cells = <2>; + interrupt-controller; + interrupts = <1 8 0xf04>; + ranges = <0 0 0 0xe1100000 0 0x100000>; + reg = <0x0 0xe1110000 0 0x01000>, + <0x0 0xe112f000 0 0x02000>, + <0x0 0xe1140000 0 0x10000>, + <0x0 0xe1160000 0 0x10000>; + v2m { + msi-controller; + reg = <0x0 0x80000 0 0x1000>; + }; + }; diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 57b5a51..1ac0ace 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -42,8 +42,6 @@ #define V2M_MIN_SPI 32 #define V2M_MAX_SPI 1019 -#define GIC_OF_MSIV2M_RANGE_INDEX 4 - /* * alloc_msi_irq - Allocate MSIs from avaialbe MSI bitmap. * @data: Pointer to v2m_data @@ -85,17 +83,10 @@ static int alloc_msi_irq(struct v2m_data *data, int nvec, int *irq) return ret; } -static struct v2m_data *to_v2m_data(struct msi_chip *chip) -{ - struct gic_chip_data *gic = container_of(chip, struct gic_chip_data, - msi_chip); - return &gic->v2m_data; -} - static void gicv2m_teardown_msi_irq(struct msi_chip *chip, unsigned int irq) { int pos; - struct v2m_data *data = to_v2m_data(chip); + struct v2m_data *data = container_of(chip, struct v2m_data, msi_chip); spin_lock(&data->msi_cnt_lock); @@ -112,7 +103,7 @@ static int gicv2m_setup_msi_irq(struct msi_chip *chip, struct pci_dev *pdev, int avail, irq = 0; struct msi_msg msg; phys_addr_t addr; - struct v2m_data *data = to_v2m_data(chip); + struct v2m_data *data = container_of(chip, struct v2m_data, msi_chip); if (!desc) { dev_err(&pdev->dev, @@ -141,18 +132,46 @@ static int gicv2m_setup_msi_irq(struct msi_chip *chip, struct pci_dev *pdev, return 0; } -static int __init -gicv2m_msi_init(struct device_node *node, struct v2m_data *v2m) +static void gicv2m_mask_irq(struct irq_data *d) +{ + gic_mask_irq(d); + if (d->msi_desc) + mask_msi_irq(d); +} + +static void gicv2m_unmask_irq(struct irq_data *d) { + gic_unmask_irq(d); + if (d->msi_desc) + unmask_msi_irq(d); +} + +static struct irq_chip gicv2m_chip; + +#ifdef CONFIG_OF +int __init +gicv2m_of_init(struct device_node *node, struct gic_chip_data *gic) +{ + int ret; unsigned int val; + struct v2m_data *v2m = &gic->v2m_data; - if (of_address_to_resource(node, GIC_OF_MSIV2M_RANGE_INDEX, - &v2m->res)) { + v2m->msi_chip.owner = THIS_MODULE; + v2m->msi_chip.of_node = node; + v2m->msi_chip.setup_irq = gicv2m_setup_msi_irq; + v2m->msi_chip.teardown_irq = gicv2m_teardown_msi_irq; + ret = of_pci_msi_chip_add(&v2m->msi_chip); + if (ret) { + pr_info("GICv2m: Failed to add msi_chip.\n"); + return ret; + } + + if (of_address_to_resource(node, 0, &v2m->res)) { pr_err("GICv2m: Failed locate GICv2m MSI register frame\n"); return -EINVAL; } - v2m->base = of_iomap(node, GIC_OF_MSIV2M_RANGE_INDEX); + v2m->base = of_iomap(node, 0); if (!v2m->base) { pr_err("GICv2m: Failed to map GIC MSI registers\n"); return -EINVAL; @@ -184,65 +203,13 @@ gicv2m_msi_init(struct device_node *node, struct v2m_data *v2m) pr_info("GICv2m: SPI range [%d:%d]\n", v2m->spi_start, (v2m->spi_start + v2m->nr_spis)); - return 0; -} + memcpy(&gicv2m_chip, gic->irq_chip, sizeof(struct irq_chip)); + gicv2m_chip.name = "GICv2m", + gicv2m_chip.irq_mask = gicv2m_mask_irq; + gicv2m_chip.irq_unmask = gicv2m_unmask_irq; + gic->irq_chip = &gicv2m_chip; -static void gicv2m_mask_irq(struct irq_data *d) -{ - gic_mask_irq(d); - if (d->msi_desc) - mask_msi_irq(d); -} - -static void gicv2m_unmask_irq(struct irq_data *d) -{ - gic_unmask_irq(d); - if (d->msi_desc) - unmask_msi_irq(d); + return 0; } -static struct irq_chip gicv2m_chip = { - .name = "GICv2m", - .irq_mask = gicv2m_mask_irq, - .irq_unmask = gicv2m_unmask_irq, - .irq_eoi = gic_eoi_irq, - .irq_set_type = gic_set_type, - .irq_retrigger = gic_retrigger, -#ifdef CONFIG_SMP - .irq_set_affinity = gic_set_affinity, -#endif -#ifdef CONFIG_PM - .irq_set_wake = gic_set_wake, -#endif -}; - -#ifdef CONFIG_OF -static int __init -gicv2m_of_init(struct device_node *node, struct device_node *parent) -{ - struct gic_chip_data *gic; - int ret; - - ret = _gic_of_init(node, parent, &gicv2m_chip, &gic); - if (ret) { - pr_err("GICv2m: Failed to initialize GIC\n"); - return ret; - } - - gic->msi_chip.owner = THIS_MODULE; - gic->msi_chip.of_node = node; - gic->msi_chip.setup_irq = gicv2m_setup_msi_irq; - gic->msi_chip.teardown_irq = gicv2m_teardown_msi_irq; - ret = of_pci_msi_chip_add(&gic->msi_chip); - if (ret) { - /* - * Note: msi-controller is checked in of_pci_msi_chip_add(). - * MSI support is optional, and enabled only if msi-controller - * is specified. Hence, return 0. - */ - return 0; - } - - return gicv2m_msi_init(node, &gic->v2m_data); -} #endif /* CONFIG_OF */ diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index cedaeb4..d308d93 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -116,6 +116,7 @@ struct gic_chip_data *irq_data_get_gic_chip_data(struct irq_data *d) { struct gic_chip_data *gic_data; struct msi_chip *mchip; + struct v2m_data *v2mdat; /* * For MSI, irq_data.chip_data points to struct msi_chip. @@ -123,7 +124,8 @@ struct gic_chip_data *irq_data_get_gic_chip_data(struct irq_data *d) */ if (d->msi_desc) { mchip = irq_data_get_irq_chip_data(d); - gic_data = container_of(mchip, struct gic_chip_data, msi_chip); + v2mdat = container_of(mchip, struct v2m_data, msi_chip); + gic_data = container_of(v2mdat, struct gic_chip_data, v2m_data); } else { gic_data = irq_data_get_irq_chip_data(d); } @@ -989,14 +991,14 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start, #ifdef CONFIG_OF static int gic_cnt __initdata; -int __init -_gic_of_init(struct device_node *node, struct device_node *parent, - struct irq_chip *chip, struct gic_chip_data **gic) +static int +__init gic_of_init(struct device_node *node, struct device_node *parent) { + struct device_node *child; void __iomem *cpu_base; void __iomem *dist_base; u32 percpu_offset; - int irq; + int irq, ret; if (WARN_ON(!node)) return -ENODEV; @@ -1010,7 +1012,15 @@ _gic_of_init(struct device_node *node, struct device_node *parent, if (of_property_read_u32(node, "cpu-offset", &percpu_offset)) percpu_offset = 0; - gic_data[gic_cnt].irq_chip = chip; + gic_data[gic_cnt].irq_chip = &gic_chip; + + /* Currently, we only support one v2m subnode. */ + child = of_get_child_by_name(node, "v2m"); + if (child) { + ret = gicv2m_of_init(child, &gic_data[gic_cnt]); + if (ret) + return ret; + } gic_init_bases(gic_cnt, -1, dist_base, cpu_base, percpu_offset, node); if (!gic_cnt) @@ -1021,18 +1031,10 @@ _gic_of_init(struct device_node *node, struct device_node *parent, gic_cascade_irq(gic_cnt, irq); } - if (gic) - *gic = &gic_data[gic_cnt]; gic_cnt++; return 0; } -static int __init -gic_of_init(struct device_node *node, struct device_node *parent) -{ - return _gic_of_init(node, parent, &gic_chip, NULL); -} - IRQCHIP_DECLARE(gic_400, "arm,gic-400", gic_of_init); IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init); IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init); diff --git a/drivers/irqchip/irq-gic.h b/drivers/irqchip/irq-gic.h index 83aa772..2ec6bc3 100644 --- a/drivers/irqchip/irq-gic.h +++ b/drivers/irqchip/irq-gic.h @@ -11,6 +11,7 @@ union gic_base { #ifdef CONFIG_ARM_GIC_V2M struct v2m_data { spinlock_t msi_cnt_lock; + struct msi_chip msi_chip; struct resource res; /* GICv2m resource */ void __iomem *base; /* GICv2m virt address */ unsigned int spi_start; /* The SPI number that MSIs start */ @@ -35,20 +36,13 @@ struct gic_chip_data { void __iomem *(*get_base)(union gic_base *); #endif struct irq_chip *irq_chip; - struct msi_chip msi_chip; #ifdef CONFIG_ARM_GIC_V2M struct v2m_data v2m_data; #endif }; -#ifdef CONFIG_OF -int _gic_of_init(struct device_node *node, - struct device_node *parent, - struct irq_chip *chip, - struct gic_chip_data **gic) __init; -#endif - void gic_mask_irq(struct irq_data *d); void gic_unmask_irq(struct irq_data *d); +int gicv2m_of_init(struct device_node *node, struct gic_chip_data *gic) __init; #endif /* _IRQ_GIC_H_ */