From patchwork Tue Feb 18 16:23:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 3673231 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 488729F2EC for ; Tue, 18 Feb 2014 16:27:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 727F720163 for ; Tue, 18 Feb 2014 16:27:09 +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 8171E20160 for ; Tue, 18 Feb 2014 16:27:08 +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 1WFnUV-00023m-Od; Tue, 18 Feb 2014 16:25:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFnUE-0004Be-Ni; Tue, 18 Feb 2014 16:25:34 +0000 Received: from mail-pb0-f52.google.com ([209.85.160.52]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFnTy-00048J-Cb for linux-arm-kernel@lists.infradead.org; Tue, 18 Feb 2014 16:25:19 +0000 Received: by mail-pb0-f52.google.com with SMTP id jt11so16993081pbb.11 for ; Tue, 18 Feb 2014 08:25:00 -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=xLTmcoRsg8pwtFpSXbzfxnTbMmgDrUa8mBXW/OONcoY=; b=S30vhcaEgB92eWlJa5uVz+zzplO8SvFjsrBGuQLbApiGQVwpyf/c9zvwKeDh8ZibdS UCwnJte+/eML+jFXXq5uR+5MRHMhlYEYBEcUUAbmPj8o94U90I7G8OP3Ii+za8Z4g+MU AkFPQHLfWt25KoqoGwoFw4TnKW9pkMiYnSnrOURhOTysj/R2c34GXe9axJIm+JXKMmfs 3mLlo1aNHqHnLL3rIyF9l1dLgmEIHV/JH7+Nc6tv1/6uE3HIAf8SVnWChUDhp1N4aGBF Qq+gRGVHCSnZvMGBWsSqzOJQcTb0vWr8slP7PkX42j3D7TA2xNBpwrlFM4L1NRseDM+I i/uQ== X-Gm-Message-State: ALoCoQlZHpNrTIdSrqc2RGCm6SVVFEhV/HCHkCNf4wxwUP6op/0hYcfQgjCUtolgnyNAGMCMu0OX X-Received: by 10.68.96.99 with SMTP id dr3mr34156361pbb.40.1392740700926; Tue, 18 Feb 2014 08:25:00 -0800 (PST) Received: from localhost ([39.181.46.96]) by mx.google.com with ESMTPSA id e6sm57386108pbg.4.2014.02.18.08.24.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 18 Feb 2014 08:24:59 -0800 (PST) From: Hanjun Guo To: "Rafael J. Wysocki" Subject: [PATCH v5 3/5] ACPI / processor: Introduce map_gic_id() to get apic id from MADT or _MAT method Date: Wed, 19 Feb 2014 00:23:56 +0800 Message-Id: <1392740638-2479-4-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392740638-2479-1-git-send-email-hanjun.guo@linaro.org> References: <1392740638-2479-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_112518_564124_06B16786 X-CRM114-Status: GOOD ( 14.13 ) X-Spam-Score: -2.6 (--) Cc: Lan Tianyu , patches@linaro.org, linaro-acpi@lists.linaro.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Hanjun Guo , Joe Perches , 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 4dcf776..d316d9b 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: