From patchwork Mon Jul 13 09:14:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 6776581 Return-Path: X-Original-To: patchwork-linux-arm@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 1C98FC05AD for ; Mon, 13 Jul 2015 09:17:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B47B42067A for ; Mon, 13 Jul 2015 09:17:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD9C52063C for ; Mon, 13 Jul 2015 09:17:24 +0000 (UTC) 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 1ZEZpd-000319-Nc; Mon, 13 Jul 2015 09:15:25 +0000 Received: from mail-bn1bn0101.outbound.protection.outlook.com ([157.56.110.101] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZEZpb-0001mC-8H for linux-arm-kernel@lists.infradead.org; Mon, 13 Jul 2015 09:15:24 +0000 Received: from BY2PR02CA0048.namprd02.prod.outlook.com (10.141.216.38) by BY1PR02MB1148.namprd02.prod.outlook.com (10.162.108.15) with Microsoft SMTP Server (TLS) id 15.1.213.14; Mon, 13 Jul 2015 09:15:00 +0000 Received: from BL2FFO11OLC005.protection.gbl (2a01:111:f400:7c09::110) by BY2PR02CA0048.outlook.office365.com (2a01:111:e400:2c40::38) with Microsoft SMTP Server (TLS) id 15.1.213.14 via Frontend Transport; Mon, 13 Jul 2015 09:14:55 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; arm.com; dkim=none (message not signed) header.d=none; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp01.amd.com (165.204.84.221) by BL2FFO11OLC005.mail.protection.outlook.com (10.173.160.91) with Microsoft SMTP Server id 15.1.213.8 via Frontend Transport; Mon, 13 Jul 2015 09:14:54 +0000 X-WSS-ID: 0NRF5OT-07-AAN-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 22846CAE7CA; Mon, 13 Jul 2015 05:14:52 -0400 (EDT) Received: from SATLEXDAG02.amd.com (10.181.40.5) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 13 Jul 2015 04:15:07 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by SATLEXDAG02.amd.com (10.181.40.5) with Microsoft SMTP Server id 14.3.195.1; Mon, 13 Jul 2015 05:14:51 -0400 From: Suravee Suthikulpanit To: , , , , Subject: [RFCv2 PATCH 2/8] gic: Introduce gic_init_irq_alloc_info() Date: Mon, 13 Jul 2015 16:14:18 +0700 Message-ID: <1436778864-17645-3-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1436778864-17645-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1436778864-17645-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC005; 1:wXFJmsLH9ABVBNqUEfC6Xvm/aEaFJKRXd0IuKHrWcxZsKJaNq6h/9O52Gsn6RXH+oEEYlR5dEw07H1uehfXrNsgpLmp8ZQ/NnU617KTDtOJDvmQ4TEtauNN7GYQvQ6pa4r7eguVEpp4MlqgFbXOEWsvsHwHHMu1xNGlAmq69uc/OsSUaaMxmNjKNy5TEkQZW2mDiGJs0QKU4RL1NWNQBjbhbtd/WibQZsbWQMdgTpcPhG3a7CApWJDIeUmIgYlt9q6K/ceq+YzuehCF/WwofJZRZ0W+unlv7ZV8eaWmsu6Gdr7MWnFcADK4d750QyOG83BjfREfMAcYsbN5ubZJQqZZGlwcVKZTOuyB8BUE6Qw7SEGiLGARd2A/PXcSIpFYMwy+1og2CvuU+XBqqrYan3NJjYOx1S3xcns6ACO2MInk= X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(428002)(189002)(199003)(77096005)(5001770100001)(62966003)(77156002)(5003940100001)(5003600100002)(2950100001)(87936001)(50986999)(2201001)(86362001)(19580405001)(229853001)(19580395003)(76176999)(48376002)(50226001)(53416004)(50466002)(189998001)(101416001)(92566002)(36756003)(46102003)(47776003)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR02MB1148; H:atltwp01.amd.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY1PR02MB1148; 2:Y+9tdVa13ZN4lNvhM84zcz+qfJsNcHmvuj8ivTgyDwd5iLo5OdWutQKf55R7FNLf; 3:geAD6+QiR9ASeopB8ksOty7rwuUualweTaTOkbeQwTgF5j1SkqtqBjgU4rNs2hNaQoKErpIL5ieua+nWoouJMaEzq98eb6z2xLP3pZ7pXFEitp14OvWIVBD26SVqWPwed3wEKliwjLy6mxKL1I696UGmYbOw63BL9XVmpZ2MkLJMcWXRgTG2Yt5MNMtJosZtZ04k8WstRf24maTrwXbbFLykZeRhlo2hWego9GDwFshfy7WomajYMPffDZ/DOOIG; 25:kSZsEgcD5669Zh7uypbfVYXp3/uHs9hs72gydzEnjcpmRFTCUngid0aHN0n+ePkOey7rrrsKMpeIo+m4Vjz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5x3684D1mn8s3xeLgfsXjENHDs= BY1PR02MB1148: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BY1PR02MB1148; BCL:0; PCL:0; RULEID:; SRVR:BY1PR02MB1148; X-Forefront-PRVS: 0636271852 X-Microsoft-Exchange-Diagnostics: 1; BY1PR02MB1148; 23:7g2PGsiWAcE8moL+N6SkHkhc+kMUR7bCAA6qSg3lGq/AioGL7OVJf2Wh7h3aNaWlbMRR1zHFsiDMxK2+2AV9JI2FvgkMhmBfQ9uiJi/MGbTAfpd7T+62u5gOazyHU89jWvVEOh1as/wRcTq2sUNiRW3ULSm5QClnltPk7ugI0PenCHaA+6ZVn8uYBSbQO0YlOUQ4hn6yKntEWLsk/00ycmwlvIhZk99c3wR+aBLBm5A6DwwDaoBGZzwU6Q6uR24aHFx71APVNTmEs5Mpe2DgyIBy+PgSDciN2Euymqj+rBtrM8H4FpRo+td2/HbXDs7+OT/7+CmOwaKffilmNJobAniSd0gU4zIUR7fdhexn25B3OSPnBsSnF/mwAFddGuNz1a3JrLHlJZGZjKzbMRjZrOB2bBzCmvAe7LjLWoefHtCKGT9ZGGjHUlbQhjlxXSxmHrZl9EQCYqx9g741AacoeNNA0Q0nKbgegS6B/YUu+PHNiJm6q+nCSh5FipkoptraDT45oJGeeXSIDErxG6RosUUoMw3z5j5mMbNcDn0B9ENp7uj5KDstmth/8Hx+N8eEwgXE6xLNRGFFbzr7eOwysWSsyzvNzQnw+3UWJBWG8eOD4+w0FPW72O2deIMNeB9ZUduQ7U4fnirugD4X8x1sPphMGyJMx+wutMdVGi8pl3BT3/wTql9S7DfFD/zelUGCgPm+SIMcrH80BChETE6HgG0Z4DRRp9EfSEHwWo10kBNxKnCeOK3hp+P6dq8E0qbkmFhF94VU4GUH0tzXsQzbvKmyO1o+ETDWgnClmhSC8QIezj5wfxxUzoAEHeFJ2a3098tR2VYNZcq7/renWu7BeZSb7LaAL9a7z1Nt0xQ9qIw= X-Microsoft-Exchange-Diagnostics: 1; BY1PR02MB1148; 5:Nk8wG9IqxH1nC1vS7CASeyiE8HIaVFKHW0xk3yF91q6PzC0FzaYmkD9n6OhIVU2FfxK4qvdQVT2bsWZHwxPmlSDYY3Ye/zsadovajO+w6u6VKMXHP39YvdB2OIK3rc5S2hhYJ09BFnuiLi5jm5My7Q==; 24:WvTwRBEcpduAH1BjtBW/dd0JksaQ23m7StkugX1ERog0yl0kEVnr3+WBzwzt5FKHVP8xUpL/ZQJOrkd3v/Tc49BuZAP3u9pyN2Zp4JCaEWU=; 20:oLhHAwOKWST5qfGctFlMzxAZlQjY3IQQsyO3ERaC/Cildpnxjl3sRDOmJP/+nRxYM81EVpkQHCdnxjhyrksgeA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2015 09:14:54.3483 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96; Ip=[165.204.84.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB1148 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150713_021523_644060_906ADA4F X-CRM114-Status: GOOD ( 18.43 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rjw@rjwysocki.net, al.stone@linaro.org, catalin.marinas@arm.com, sherry.hurwitz@amd.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, leo.duran@amd.com, Suravee Suthikulpanit , msalter@redhat.com, grant.likely@linaro.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 Currently, gic_irq_domain_alloc assumes that the arg parameter must be a pointer to of_phandle_args. This is not appropriate for using with ACPI. Furthermore, there are several irq mappings (i.e. SPI, PPI, and GSI), which can be used when allocating GIC irqs. This can be confusing when used in multiple initialization path (i.e. DT, ACPI, MSI, etc.). This patch introduces struct gic_irq_alloc_info, which replaces the of_phandle_args when calling gic_irq_domain_alloc(). Also, it introduces gic_init_irq_alloc_info(), a new helper function to help simplifying GIC irq allocation, which hooks into the new irq_domain_ops.init_alloc_info. Signed-off-by: Suravee Suthikulpanit --- drivers/irqchip/irq-gic.c | 82 ++++++++++++++++++++++++++++++++++------- include/linux/irqchip/arm-gic.h | 11 ++++++ 2 files changed, 79 insertions(+), 14 deletions(-) diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 7f943ef..8ac8ec4 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -852,22 +852,18 @@ static struct notifier_block gic_cpu_notifier = { static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *arg) { - int i; + int i, ret; irq_hw_number_t hwirq; + unsigned int type = IRQ_TYPE_NONE; + struct gic_irq_alloc_info *info = arg; + u32 intspec[3]; - if (acpi_disabled) { /* DT case */ - int ret; - unsigned int type = IRQ_TYPE_NONE; - struct of_phandle_args *irq_data = arg; - - ret = gic_irq_domain_xlate(domain, irq_data->np, - irq_data->args, - irq_data->args_count, &hwirq, &type); - if (ret) - return ret; - } else { /* ACPI case */ - hwirq = (irq_hw_number_t)*(u32 *)arg; - } + intspec[0] = info->gic_int_type; + intspec[1] = info->hwirq; + intspec[2] = info->irq_type; + ret = gic_irq_domain_xlate(domain, info->ref, intspec, 3, &hwirq, &type); + if (ret) + return ret; for (i = 0; i < nr_irqs; i++) gic_irq_domain_map(domain, virq + i, hwirq + i); @@ -875,10 +871,68 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, return 0; } +static int gic_init_irq_alloc_info(uint32_t *data, int nr, void *ref, + void **info) +{ + struct gic_irq_alloc_info *alloc_info; + unsigned int gic_int_type; + unsigned int hwirq; + unsigned int irq_type; + + if (nr != 3) + return -EINVAL; + + gic_int_type = data[0]; + hwirq = data[1]; + irq_type = data[2]; + + alloc_info = kzalloc(sizeof(struct gic_irq_alloc_info), GFP_KERNEL); + if (!alloc_info) + return -ENOMEM; + + if ((irq_type & IRQ_TYPE_SENSE_MASK) != IRQ_TYPE_LEVEL_HIGH && + (irq_type & IRQ_TYPE_SENSE_MASK) != IRQ_TYPE_EDGE_RISING) + return -EINVAL; + + alloc_info->irq_type = irq_type; + alloc_info->ref = ref; + + /* + * ACPI have no bindings to indicate SPI or PPI, so we + * use different mappings from DT in ACPI. + * + * For FDT + * PPI interrupt: in the range [0, 15]; + * SPI interrupt: in the range [0, 987]; + * + * For ACPI, GSI should be unique so using + * the hwirq directly for the mapping: + * PPI interrupt: in the range [16, 31]; + * SPI interrupt: in the range [32, 1019]; + */ + + if (gic_int_type != GIC_INT_TYPE_GSI) { + alloc_info->gic_int_type = gic_int_type; + alloc_info->hwirq = hwirq; + } else { + if (hwirq < 32) { + alloc_info->gic_int_type = GIC_INT_TYPE_PPI; + alloc_info->hwirq = hwirq - 16; + } else { + alloc_info->gic_int_type = GIC_INT_TYPE_SPI; + alloc_info->hwirq = hwirq - 32; + } + } + + *info = alloc_info; + return 0; +} + static const struct irq_domain_ops gic_irq_domain_hierarchy_ops = { .xlate = gic_irq_domain_xlate, .alloc = gic_irq_domain_alloc, .free = irq_domain_free_irqs_top, + .init_alloc_info = gic_init_irq_alloc_info, }; static const struct irq_domain_ops gic_irq_domain_ops = { diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h index 9de976b..4808514 100644 --- a/include/linux/irqchip/arm-gic.h +++ b/include/linux/irqchip/arm-gic.h @@ -89,12 +89,23 @@ #define GICH_MISR_EOI (1 << 0) #define GICH_MISR_U (1 << 1) +#define GIC_INT_TYPE_SPI 0 +#define GIC_INT_TYPE_PPI 1 +#define GIC_INT_TYPE_GSI ~0U + #ifndef __ASSEMBLY__ #include struct device_node; +struct gic_irq_alloc_info { + void *ref; + unsigned int irq_type; + unsigned int gic_int_type; + unsigned int hwirq; +}; + void gic_set_irqchip_flags(unsigned long flags); void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *, u32 offset, struct device_node *);