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: 24904 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A5276202B2 for ; Tue, 18 Feb 2014 16:25:03 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id vb8sf64569386obc.2 for ; Tue, 18 Feb 2014 08:25:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=xLTmcoRsg8pwtFpSXbzfxnTbMmgDrUa8mBXW/OONcoY=; b=LdLrHHKM2cV6a5D8eHcOfYo5mGSJG929EpRqFlPtjCRzcSbCLPeCKjioxy9PbWx950 Yl/Kb+G6EMPI6tOvmamA2DfPrLWmeRpkrBF5YF9TpHSLM51fOtmcT1UQ6yKKktK9nwHF YRRHGV9Rg69fiLTwjYS0WKzjWCvlRNBalHODzNjBtCT+rN+IEw7uDuTg5TSjkS6asb1P DKHfELatoExrdNKm+tdKmxJKr5w8GskIlPa22e+1kj0UCDhtxU8yaUvTJtCeO/gsSfRE KL3XgNcnLE5zLaPPhwgzA00WgyWBlpqjxRJWSgeO+AEEkO1QUbpV3UZbLcBYqtN9nmIq VYDg== X-Gm-Message-State: ALoCoQmmbbTsRbHv1j8LmaBKAnSfHdn/kEJytr46rqUUb2+j5zZVGUwmLRmLkc7HfoOvblTM/3gC X-Received: by 10.50.114.134 with SMTP id jg6mr2925328igb.2.1392740702539; Tue, 18 Feb 2014 08:25:02 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.227 with SMTP id m90ls1496291qga.38.gmail; Tue, 18 Feb 2014 08:25:02 -0800 (PST) X-Received: by 10.220.175.198 with SMTP id bb6mr9766725vcb.31.1392740702456; Tue, 18 Feb 2014 08:25:02 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id w1si5642450vet.87.2014.02.18.08.25.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 08:25:02 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so13931551veb.30 for ; Tue, 18 Feb 2014 08:25:02 -0800 (PST) X-Received: by 10.220.191.134 with SMTP id dm6mr22047990vcb.16.1392740702331; Tue, 18 Feb 2014 08:25:02 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp229262vcz; Tue, 18 Feb 2014 08:25:01 -0800 (PST) X-Received: by 10.67.23.135 with SMTP id ia7mr33625443pad.5.1392740701332; Tue, 18 Feb 2014 08:25:01 -0800 (PST) Received: from mail-pb0-f48.google.com (mail-pb0-f48.google.com [209.85.160.48]) by mx.google.com with ESMTPS id b4si18794312pbe.328.2014.02.18.08.25.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 08:25:01 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.48 is neither permitted nor denied by best guess record for domain of hanjun.guo@linaro.org) client-ip=209.85.160.48; Received: by mail-pb0-f48.google.com with SMTP id rr13so16885747pbb.7 for ; Tue, 18 Feb 2014 08:25:00 -0800 (PST) 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" Cc: Lan Tianyu , Joe Perches , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, patches@linaro.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Hanjun Guo 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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: