From patchwork Mon Jul 13 09:14:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 6776611 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 CA422C05AC for ; Mon, 13 Jul 2015 09:17:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB4172068F for ; Mon, 13 Jul 2015 09:17:33 +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 B5DA32063C for ; Mon, 13 Jul 2015 09:17:32 +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 1ZEZqG-0003SN-3b; Mon, 13 Jul 2015 09:16:04 +0000 Received: from mail-bn1on0737.outbound.protection.outlook.com ([2a01:111:f400:fc10::737] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZEZq8-00036Z-2G for linux-arm-kernel@lists.infradead.org; Mon, 13 Jul 2015 09:15:56 +0000 Received: from BY2PR02CA0078.namprd02.prod.outlook.com (10.242.32.36) by BLUPR0201MB1491.namprd02.prod.outlook.com (10.163.119.157) with Microsoft SMTP Server (TLS) id 15.1.213.14; Mon, 13 Jul 2015 09:15:33 +0000 Received: from BL2FFO11FD034.protection.gbl (2a01:111:f400:7c09::106) by BY2PR02CA0078.outlook.office365.com (2a01:111:e400:2c2a::36) with Microsoft SMTP Server (TLS) id 15.1.213.14 via Frontend Transport; Mon, 13 Jul 2015 09:15:26 +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 BL2FFO11FD034.mail.protection.outlook.com (10.173.161.130) with Microsoft SMTP Server id 15.1.213.8 via Frontend Transport; Mon, 13 Jul 2015 09:15:26 +0000 X-WSS-ID: 0NRF5PP-07-AEC-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 atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2632FCAE7DB; Mon, 13 Jul 2015 05:15:24 -0400 (EDT) Received: from SATLEXDAG02.amd.com (10.181.40.5) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 13 Jul 2015 04:15:29 -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:15:23 -0400 From: Suravee Suthikulpanit To: , , , , Subject: [RFCv2 PATCH 6/8] gic: acpi: Introduce GIC MSI frame handle and helper functions Date: Mon, 13 Jul 2015 16:14:22 +0700 Message-ID: <1436778864-17645-7-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; BL2FFO11FD034; 1:Els/Is7wSv8kARmHs9izzb+iD7eZvn2UcXewYfGrDeUpsnSRhf+PrrgsJManCaiWqHpGbnR0Cvac7HlBhLxxAU0MWj7160YTtpGkCv0RCSU3su59iIHsH1Z6iIgs4KgNWLX84iY9sxT4DtfvPpr8OyLMxHwTdu8ywtutOGi+TOmOvgfCz7+gPCEusTvAD4JuXCdOHiXtXyGkEXShfh1ubgrMsxE9Uoqn9FnJGXYa95D0IIlXAbjQtssHwXZFacsB6aLKnvH24/c83uxUjNdkBGU/XINFXVIuTXbp5KEYvVSd+Ik8aQoHb/e58O3+HWBSlpaAWb8ZyHnY9in7J2Du5FzevPbjttN1xWCkGbK2uY+1Em2fdmzFAM4sgscP3g/k0K0ltuDjBS34yzBSCMxdN4Zw/5KO9KlGxUVzGNh8O4o= X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(428002)(189002)(199003)(76176999)(19580395003)(189998001)(50226001)(50466002)(62966003)(50986999)(19580405001)(101416001)(48376002)(53416004)(5001770100001)(229853001)(92566002)(5003940100001)(5003600100002)(77096005)(105586002)(47776003)(2950100001)(36756003)(2201001)(86362001)(46102003)(77156002)(87936001)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR0201MB1491; H:atltwp01.amd.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0201MB1491; 2:5zp6uGCN8Gtx9JGh5FMyEftxmnXy2BCqmu4ax99rJOkIK/vfF9q8B+wvRAc9L3Yi; 3:tgOam3uxO2AzzCamgzKPu+Kf6LLV0xFMMZHw57NuDi33mozQP1sO1/UIEzEjKo7CJsMQoZCmH7JQmsnHD3uODTv+ho+zchYfFxHA/daKxsI2VjNCYK8uiIcCWtiq/mHBZBkXsi1UBsCtbb8mNBNXqrlek6FGAle51a9UrpDGiQDWLZ4/nFPrJ/tWGr8lglxek+0SFycOgsofBr1cykFPBNas6365auFGzRzUhS1plFm5lOsc6+VER4O6O8YSxXJz; 25:ibu+PC3M2leOZTCt0N+4nuWItiYAFennGZA97XZi0L90Em+jmFt4rA/Ja6l0P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+smOWnXOpnWuX2TQwUyIc= BLUPR0201MB1491: 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:BLUPR0201MB1491; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0201MB1491; X-Forefront-PRVS: 0636271852 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0201MB1491; 23:xUR7qQFuxkUXjgklJZc5t0XicNeTwOvP5IAvsdX/dG7ulRqLHivM4qqGYS2PMHpqGd52l4EEsOPEKPKZtVGeQBAakXB9Xcgq/TIkUwzr/4hpYvQ1VNbPqbXgOVxiHgPTBghjZqH296OVeL1YrV7hopYqj3CPTowSGUXTZi2DInBVMgB4DfR0k/4cViznt+afkYaUHGWMfUgBzUlBZMxTBjSod3F1UeGzOLPIlv/nId2PTEMhuo76a6lqKllSiw91V3qXwCEShyFsHWGe8uJJGTWPghLKfwbz/Erpmm3mpeE6vfGlAMYWlC1nvpT4GvM6DjASem1kIHRILFoQ6d64anbt8f/sSPBKwNp3BMIQQc78GqgHoWKdO+sZJOwmYdvy95MOvXdHCFFuu/50AaxpB/BRcQg/x7Fnrh7opgnrlQczDTdsZvJztLzJoTVIVT3P+s6JiQ8vGUHVBkakrtk0qmOEl58lt/2NfzCl9u1cgyJkRZSGKkAs0RKjCBxroSHDy5wRktRbLZiuzbx6yzWmTWxXhc6L7ZjauTh7jcuNVFuEAbTLe0ft6rTsZamgMYRNoXwjI0ytbbKQnrbMxwkLSKUCut67kWOQVpCEiUJqlgk2gJ+3xDSjnCxZhWb7quD3MAHv01zBpM2raKqliYm8qVy1tv7hfFLD4dCtwm9E/tsYNYx8Yi+jR9xngpMT5iF/trcXDxJAJ6dKQ+oBy4d8XUz1R/QIxME8vXV940NiADzdadM4ACNxjcEgAwdevE0VYk5zaJbx7Rj3cTlM5FLzCk9xHIC0XCt4cMbn7cMIUSae5nJA7+sjip8ik0UeACrokKVL47V3sQiYF+48ZTIftHeOt+qi/lkHWoT8i7ceHRpO45IfIugmtUaznKqO7yNG X-Microsoft-Exchange-Diagnostics: 1; BLUPR0201MB1491; 5:Z/Un43SAc+5NrWWsmWlmw1CAQtjHME19A9pd+dKAY9gJbyi0qvZsntzs+DKA5KYAuC/6cqWyDwygqCTd/G6lie34ZgkYLF34++TGdJcI86oAxguxZIehncAPzkK9wGCbVGZj9279Br5S3GTCTBYFJQ==; 24:Ib0NJRBR3zLdkfmPaV1xYuLGCq6iG5hhlY+327VC5Ibu6AKXqqExE0mMTYKRb7bBE9OPf6mnBHjZRcepy9hG6aNhu7tzVyoVfXRWUPxJmow=; 20:KpvWVp9qBPC3qeMEE1qk0ObdzZqfLrPlEj4nED6FdMFOHlu4IXapHPl/gMjY8KvepUi4Naz8WYBKF2I4rwLung== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2015 09:15:26.0493 (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: BLUPR0201MB1491 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150713_021556_332781_76920E2F X-CRM114-Status: GOOD ( 14.08 ) 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 This patch introdues struct gic_msi_frame_handle, which can be used as a reference to GIC MSI frame in MADT. It also provides helper functions to help parsing and getting reference to each MSI frame. This avoids having to map and parse MADT multiple times. Signed-off-by: Suravee Suthikulpanit --- drivers/irqchip/irq-gic-acpi.c | 78 ++++++++++++++++++++++++++++++++++++ include/linux/irqchip/arm-gic-acpi.h | 3 ++ 2 files changed, 81 insertions(+) diff --git a/drivers/irqchip/irq-gic-acpi.c b/drivers/irqchip/irq-gic-acpi.c index f0772d9..6684a8f 100644 --- a/drivers/irqchip/irq-gic-acpi.c +++ b/drivers/irqchip/irq-gic-acpi.c @@ -16,6 +16,15 @@ #include #include +struct gic_msi_frame_handle { + struct list_head list; + struct acpi_madt_generic_msi_frame *frame; +}; + +static LIST_HEAD(msi_frame_list); + +static int acpi_num_msi_frame; + /* GIC version presented in MADT GIC distributor structure */ static u8 gic_version __initdata = ACPI_MADT_GIC_VERSION_NONE; @@ -141,6 +150,75 @@ static int __init acpi_gic_version_init(void) return 0; } +static int __init +acpi_parse_madt_msi(struct acpi_subtable_header *header, + const unsigned long end) +{ + struct gic_msi_frame_handle *ms; + struct acpi_madt_generic_msi_frame *frame; + + frame = (struct acpi_madt_generic_msi_frame *)header; + if (BAD_MADT_ENTRY(frame, end)) + return -EINVAL; + + ms = kzalloc(sizeof(struct gic_msi_frame_handle *), GFP_KERNEL); + if (!ms) + return -ENOMEM; + + ms->frame = frame; + + list_add(&ms->list, &msi_frame_list); + + return 0; +} + +inline int acpi_get_num_msi_frames(void) +{ + return acpi_num_msi_frame; +} + +int __init acpi_madt_msi_frame_init(struct acpi_table_header *table) +{ + int ret = 0; + + if (acpi_num_msi_frame > 0) + return ret; + + ret = acpi_parse_entries(ACPI_SIG_MADT, + sizeof(struct acpi_table_madt), + acpi_parse_madt_msi, table, + ACPI_MADT_TYPE_GENERIC_MSI_FRAME, 0); + if (ret == 0) { + pr_debug("No valid ACPI GIC MSI FRAME exist\n"); + return ret; + } + + acpi_num_msi_frame = ret; + return 0; +} + +int acpi_get_msi_frame(int index, struct acpi_madt_generic_msi_frame **p) +{ + int i = 0; + struct gic_msi_frame_handle *m; + + if (index >= acpi_num_msi_frame) + return -EINVAL; + + list_for_each_entry(m, &msi_frame_list, list) { + if (i == index) + break; + i++; + } + + if (i == acpi_num_msi_frame) + return -EINVAL; + + *p = m->frame; + return 0; +} + + /* * This special acpi_table_id is the sentinel at the end of the * acpi_table_id[] array of all irqchips. It is automatically placed at diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h index 0d43f515..9fb3577 100644 --- a/include/linux/irqchip/arm-gic-acpi.h +++ b/include/linux/irqchip/arm-gic-acpi.h @@ -22,6 +22,9 @@ #define ACPI_GICV3_DIST_MEM_SIZE (SZ_64K) u8 acpi_gic_version(void); +int acpi_madt_msi_frame_init(struct acpi_table_header *table); +int acpi_get_msi_frame(int index, struct acpi_madt_generic_msi_frame **p); +int acpi_get_num_msi_frames(void); #endif /* CONFIG_ACPI */ #endif /* ARM_GIC_ACPI_H_ */