From patchwork Thu Mar 24 14:44:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8661561 Return-Path: X-Original-To: patchwork-xen-devel@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 4C9F0C0553 for ; Thu, 24 Mar 2016 14:48:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 691D02017D for ; Thu, 24 Mar 2016 14:48:48 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D3E4203B4 for ; Thu, 24 Mar 2016 14:48:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj6Wi-0002oX-UT; Thu, 24 Mar 2016 14:46:20 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj6Wi-0002oI-71 for xen-devel@lists.xen.org; Thu, 24 Mar 2016 14:46:20 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 67/8A-07120-BBDF3F65; Thu, 24 Mar 2016 14:46:19 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-5.tower-21.messagelabs.com!1458830777!5758940!1 X-Originating-IP: [209.85.192.179] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22048 invoked from network); 24 Mar 2016 14:46:18 -0000 Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by server-5.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 24 Mar 2016 14:46:18 -0000 Received: by mail-pf0-f179.google.com with SMTP id x3so59414947pfb.1 for ; Thu, 24 Mar 2016 07:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vqrgdKusgrZQm7EtlOTxOYn5ornHIkq3sOHM2Yotw/o=; b=ZJ2RNJd61oIW3vfrY9rN92dR/wr/aK2wbBz4d51fbmA5spZ9OnXhttS9+HfuxMIy0M Jm8CEhQMtgH3KevSC7WuiglPBQPnVvMlYjiFEDSqv6fJJg2O4fZ3nf7MBatVUpxfEHeW Y/Fc/lg5zyCX/kQXU95CMDZdbsew+Y6mbF4N0= 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=vqrgdKusgrZQm7EtlOTxOYn5ornHIkq3sOHM2Yotw/o=; b=YaWbRJfs9znxOaMwJLCubBv9uf74gwOnaI5hRXN6C+cwrECDPMhU7zyoBx9NJjNq9K c1hOz74LYu76BfMkQmmFirclmeGujQ3yIrUDlBYg4F0xteP9aR9zKJeaYSf2aB/V+7WE vCVTlW/6k8kLc4FVHU6T1jm/PfMG/WWLG7mp7ztGFevXgrU65ZOIu1FNPIiR1EyReGI/ YkYlZ/vmENZAcsZ7lR/40bMmv1+iXdpPTGEOo9NlJ/va9vjKT6eKfsT5zJGwOJo9SudV XZS9JfQEMtxmwKeYyHPHvS3W8xpW3qZSY8Rgv5spLiU9AVx/8CMpbPxKNc3YqT2U2NdE jsrg== X-Gm-Message-State: AD7BkJJSrjHBbu1g6JETx+bFW7w3b53BpWMQ+2GTbGbKwaBZ4D05mD9hSU1pscflqD/5ECZR X-Received: by 10.98.70.138 with SMTP id o10mr13379752pfi.123.1458830776334; Thu, 24 Mar 2016 07:46:16 -0700 (PDT) Received: from localhost.localdomain ([104.238.45.135]) by smtp.gmail.com with ESMTPSA id lq10sm10780673pab.36.2016.03.24.07.46.07 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2016 07:46:15 -0700 (PDT) From: Shannon Zhao To: linux-arm-kernel@lists.infradead.org, stefano.stabellini@citrix.com, david.vrabel@citrix.com Date: Thu, 24 Mar 2016 22:44:20 +0800 Message-Id: <1458830676-27075-2-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458830676-27075-1-git-send-email-shannon.zhao@linaro.org> References: <1458830676-27075-1-git-send-email-shannon.zhao@linaro.org> Cc: devicetree@vger.kernel.org, linux-efi@vger.kernel.org, "Rafael J. Wysocki" , catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, peter.huangpeng@huawei.com, "open list:ACPI" , julien.grall@arm.com, shannon.zhao@linaro.org, zhaoshenglong@huawei.com, xen-devel@lists.xen.org, Len Brown Subject: [Xen-devel] [PATCH v7 01/17] Xen: ACPI: Hide UART used by Xen X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 ACPI 6.0 introduces a new table STAO to list the devices which are used by Xen and can't be used by Dom0. On Xen virtual platforms, the physical UART is used by Xen. So here it hides UART from Dom0. CC: "Rafael J. Wysocki" (supporter:ACPI) CC: Len Brown (supporter:ACPI) CC: linux-acpi@vger.kernel.org (open list:ACPI) Signed-off-by: Shannon Zhao --- drivers/acpi/scan.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 5f28cf7..e96a058 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -45,6 +45,7 @@ static LIST_HEAD(acpi_scan_handlers_list); DEFINE_MUTEX(acpi_device_lock); LIST_HEAD(acpi_wakeup_device_list); static DEFINE_MUTEX(acpi_hp_context_lock); +static u64 spcr_uart_addr; struct acpi_dep_data { struct list_head node; @@ -1453,6 +1454,41 @@ static int acpi_add_single_object(struct acpi_device **child, return 0; } +static acpi_status acpi_get_resource_memory(struct acpi_resource *ares, + void *context) +{ + struct resource *res = context; + + if (acpi_dev_resource_memory(ares, res)) + return AE_CTRL_TERMINATE; + + return AE_OK; +} + +static bool acpi_device_should_be_hidden(acpi_handle handle) +{ + acpi_status status; + struct resource res; + + /* Check if it should ignore the UART device */ + if (spcr_uart_addr != 0) { + if (!acpi_has_method(handle, METHOD_NAME__CRS)) + return false; + + status = acpi_walk_resources(handle, METHOD_NAME__CRS, + acpi_get_resource_memory, &res); + if (ACPI_FAILURE(status)) + return false; + + if (res.start == spcr_uart_addr) { + printk(KERN_INFO PREFIX "The UART device in SPCR table will be hidden\n"); + return true; + } + } + + return false; +} + static int acpi_bus_type_and_status(acpi_handle handle, int *type, unsigned long long *sta) { @@ -1466,6 +1502,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, switch (acpi_type) { case ACPI_TYPE_ANY: /* for ACPI_ROOT_OBJECT */ case ACPI_TYPE_DEVICE: + if (acpi_device_should_be_hidden(handle)) + return -ENODEV; + *type = ACPI_BUS_TYPE_DEVICE; status = acpi_bus_get_status_handle(handle, sta); if (ACPI_FAILURE(status)) @@ -1916,9 +1955,24 @@ static int acpi_bus_scan_fixed(void) return result < 0 ? result : 0; } +static void acpi_get_spcr_uart_addr(void) +{ + acpi_status status; + struct acpi_table_spcr *spcr_ptr; + + status = acpi_get_table(ACPI_SIG_SPCR, 0, + (struct acpi_table_header **)&spcr_ptr); + if (ACPI_SUCCESS(status)) + spcr_uart_addr = spcr_ptr->serial_port.address; + else + printk(KERN_WARNING PREFIX "STAO table present, but SPCR is missing\n"); +} + int __init acpi_scan_init(void) { int result; + acpi_status status; + struct acpi_table_stao *stao_ptr; acpi_pci_root_init(); acpi_pci_link_init(); @@ -1934,6 +1988,20 @@ int __init acpi_scan_init(void) acpi_scan_add_handler(&generic_device_handler); + /* + * If there is STAO table, check whether it needs to ignore the UART + * device in SPCR table. + */ + status = acpi_get_table(ACPI_SIG_STAO, 0, + (struct acpi_table_header **)&stao_ptr); + if (ACPI_SUCCESS(status)) { + if (stao_ptr->header.length > sizeof(struct acpi_table_stao)) + printk(KERN_INFO PREFIX "STAO Name List not yet supported."); + + if (stao_ptr->ignore_uart) + acpi_get_spcr_uart_addr(); + } + mutex_lock(&acpi_scan_lock); /* * Enumerate devices in the ACPI namespace.