From patchwork Sat Feb 8 13:10:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 3610181 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2199BBF418 for ; Sat, 8 Feb 2014 13:11:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 554332010F for ; Sat, 8 Feb 2014 13:11:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C114200E5 for ; Sat, 8 Feb 2014 13:11:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750957AbaBHNL3 (ORCPT ); Sat, 8 Feb 2014 08:11:29 -0500 Received: from mail-pb0-f41.google.com ([209.85.160.41]:52694 "EHLO mail-pb0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751789AbaBHNLX (ORCPT ); Sat, 8 Feb 2014 08:11:23 -0500 Received: by mail-pb0-f41.google.com with SMTP id up15so4419565pbc.0 for ; Sat, 08 Feb 2014 05:11:22 -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=JDZH7HO2VpMoRn6GoLJmXduPOq+w6FMXqBCirUCaVws=; b=RgZ6TVMUivY8NABBTU/8MKytpz4prnFFhOoEBIr+ht3qgCl7KR+BHDniuVY/fjNm7P UFOfynApV37zygQcKX4R1IC2ID4bedED/3d6q3GNJmXSVi3TUd0H8RE879f78+9NTWf6 ra+Mw+T1Po1/KgG1hAyCZEcPikb5J7QcpC22NWZvPRmRdm03kNAmMY4ABEmQQppzctmX 3pT/6nWRXurMdwI+o+DuGeQ3/9M1NVwnnTc1bUVuyVsfANMzIvbDaus9qx5TwpSSeZBn UaGQVx2Hw8rtdw1Mh35XcUjGCOZh/QazO5k9JGDQ2QFfW76NkOSd8jN3wxgf0X83EuY6 Wk9Q== X-Gm-Message-State: ALoCoQlD6IGEInWFSNYGLNjrifQNfQScht76s/4Sjody1FKeWxNfODjazPQPnTG6lzMuFodhf0R6 X-Received: by 10.66.145.166 with SMTP id sv6mr14350742pab.31.1391865082514; Sat, 08 Feb 2014 05:11:22 -0800 (PST) Received: from localhost ([39.182.20.40]) by mx.google.com with ESMTPSA id xn12sm59402995pac.12.2014.02.08.05.11.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 08 Feb 2014 05:11:21 -0800 (PST) From: Hanjun Guo To: "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org, patches@linaro.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Hanjun Guo Subject: [PATCH v2 3/3] ACPI: Introduce map_gic_id() to get apic id from MADT or _MAT method Date: Sat, 8 Feb 2014 21:10:18 +0800 Message-Id: <1391865018-3446-4-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391865018-3446-1-git-send-email-hanjun.guo@linaro.org> References: <1391865018-3446-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 31a4281..5a50f03 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: