From patchwork Tue Feb 18 13:54:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 3670931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ACB039F2EC for ; Tue, 18 Feb 2014 13:58:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95EAA20166 for ; Tue, 18 Feb 2014 13:58:43 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB05B201D3 for ; Tue, 18 Feb 2014 13:58:42 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFlAu-00010p-6I; Tue, 18 Feb 2014 13:57:28 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFlAW-0004du-Fw; Tue, 18 Feb 2014 13:57:04 +0000 Received: from mail-pa0-f52.google.com ([209.85.220.52]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFlA9-0004Xj-1c for linux-arm-kernel@lists.infradead.org; Tue, 18 Feb 2014 13:56:42 +0000 Received: by mail-pa0-f52.google.com with SMTP id bj1so16763725pad.39 for ; Tue, 18 Feb 2014 05:56:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5wXtgqGtdTjGlFT/+7lGAu5azawXiFWdJtp1jlfIfFY=; b=EnYgB5VWdKhnUKNFtDRK8bON83HSIQsruhNAtS9qL4p7CYtZaA5pLKZW6fjz1IwPgh WDIE2INUFza055v2SQW3OgO0vi+CRyFy/P99kfSN06SBK00c9Wp38Yh6mXjx0p1ZskWY klIYmfg+G3e7DS55/wALJxDxCzGMQmmwRot86K67qnS2+dhAhO/4+2w1bnBIpA2N5c86 PCPJNEEp1WYdBIiWEHo+flzYdVj1Gpe3oIze8lE2mayxtvvdghlNLV5NMM4wEIQ60f6t FftL1BEGsiY8Nzq77eeE2NCd5nTw0QQs47FFZBYp1Kx2ipocpF8wjFk0YcShjNcCyc2J B9xg== X-Gm-Message-State: ALoCoQl4CTd4n5y2o1Y5cW2FM5nsaqC/hoEvzpz59by4Bu8uyMocGn0cLDwoH6IqXmyc1CF2STGD X-Received: by 10.68.237.228 with SMTP id vf4mr33295192pbc.131.1392731779479; Tue, 18 Feb 2014 05:56:19 -0800 (PST) Received: from localhost ([39.181.46.96]) by mx.google.com with ESMTPSA id cz3sm56233588pbc.9.2014.02.18.05.56.16 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 18 Feb 2014 05:56:19 -0800 (PST) From: Hanjun Guo To: "Rafael J. Wysocki" Subject: [PATCH v4 3/5] ACPI / processor: Introduce map_gic_id() to get apic id from MADT or _MAT method Date: Tue, 18 Feb 2014 21:54:58 +0800 Message-Id: <1392731700-10992-4-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392731700-10992-1-git-send-email-hanjun.guo@linaro.org> References: <1392731700-10992-1-git-send-email-hanjun.guo@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140218_085641_242963_292F681F X-CRM114-Status: GOOD ( 13.93 ) X-Spam-Score: -2.6 (--) Cc: Lan Tianyu , linaro-acpi@lists.linaro.org, patches@linaro.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Hanjun Guo , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 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 Get apic id from MADT or _MAT method is not implemented on arm/arm64, and ACPI 5.0 introduces GIC Structure for it, so this patch introduces map_gic_id() to get apic id followed the ACPI 5.0 spec. Signed-off-by: Hanjun Guo --- drivers/acpi/processor_core.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 5bbc255..09fde83 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -71,6 +71,27 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, return 0; } +static int map_gic_id(struct acpi_subtable_header *entry, + int device_declaration, u32 acpi_id, int *apic_id) +{ + struct acpi_madt_generic_interrupt *gic = + (struct acpi_madt_generic_interrupt *)entry; + + if (!(gic->flags & ACPI_MADT_ENABLED)) + return -ENODEV; + + /* In the GIC interrupt model, logical processors are + * required to have a Processor Device object in the DSDT, + * so we should check device_declaration here + */ + if (device_declaration && (gic->uid == acpi_id)) { + *apic_id = gic->gic_id; + return 0; + } + + return -EINVAL; +} + static int map_madt_entry(int type, u32 acpi_id) { unsigned long madt_end, entry; @@ -106,6 +127,9 @@ static int map_madt_entry(int type, u32 acpi_id) } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { if (!map_lsapic_id(header, type, acpi_id, &apic_id)) break; + } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { + if (!map_gic_id(header, type, acpi_id, &apic_id)) + break; } entry += header->length; } @@ -136,6 +160,8 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) map_lapic_id(header, acpi_id, &apic_id); } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { map_lsapic_id(header, type, acpi_id, &apic_id); + } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { + map_gic_id(header, type, acpi_id, &apic_id); } exit: