From patchwork Thu Nov 2 10:13:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 10038337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A5FD4603B5 for ; Thu, 2 Nov 2017 10:16:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94FF828EDE for ; Thu, 2 Nov 2017 10:16:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89A9928EE1; Thu, 2 Nov 2017 10:16:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id B0C7928EE0 for ; Thu, 2 Nov 2017 10:16:04 +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 1eACV3-0001rj-A2; Thu, 02 Nov 2017 10:13:25 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eACV2-0001rS-80 for xen-devel@lists.xenproject.org; Thu, 02 Nov 2017 10:13:24 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 2A/F2-30895-3CFEAF95; Thu, 02 Nov 2017 10:13:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDIsWRWlGSWpSXmKPExsVyMfTAEd3D739 FGjTwWXzfMpnJgdHj8IcrLAGMUayZeUn5FQmsGb9Xb2YpOC5b8fHpQ/YGxv3iXYxcHEICMxgl 1j7cwg7isAjMY5ZoOreJBcSREOhnlXjQt5epi5EDyMmT6LogBGGmSRzYmdvFyAlkVkqs3XeDD cQWEtCSOHpqNivE0B1MEpNXLQJrZRMwkZjVIQFSIyKgJHFv1WQmkBpmgedMEocmfGUGSQgLBE s0rT7PAmKzCKhKXPr4jxHE5hXwlvh/sZ0ZYpmcxM1znWA2p4CPxJH+KYwQi70lZrasZJ/AKLi AkWEVo0ZxalFZapGukaleUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZguDEAwQ7G VQsCDzFKcjApifLe3fgrUogvKT+lMiOxOCO+qDQntfgQowwHh5IE78F3QDnBotT01Iq0zBxg4 MOkJTh4lEQg0rzFBYm5xZnpEKlTjPYcF+5c+sPEcWDPLSDZcfMukHw283UDsxBLXn5eqpQ472 6QNgGQtozSPLihsEi9xCgrJczLCHSmEE9BalFuZgmq/CtGcQ5GJWHeyyBTeDLzSuB2vwI6iwn oLC+JHyBnlSQipKQaGIPjzmhUc0rcb2Pu27JxpYssu7nrX9UVkj1vHfc4ZPKILgnRW3R9jfQq 4X7m6TMXnD+y4lf/p4kOVm+sjfc1BzQcaIkOsH1inlgjvFcnt+6I39ddF/Uvrlxx4O9h1eDno lXhu9w8NexL5K90vrDfq7850vW4acWu8pM/vMtmaH49n+XnMuNFqxJLcUaioRZzUXEiALcrwo zPAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-27.messagelabs.com!1509617601!104300418!1 X-Originating-IP: [209.85.192.196] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15523 invoked from network); 2 Nov 2017 10:13:22 -0000 Received: from mail-pf0-f196.google.com (HELO mail-pf0-f196.google.com) (209.85.192.196) by server-8.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 2 Nov 2017 10:13:22 -0000 Received: by mail-pf0-f196.google.com with SMTP id d28so4236685pfe.2 for ; Thu, 02 Nov 2017 03:13:22 -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=YGHgpgP/FNQcwMSYtJP7Rj6whArtKD4OjHtzhlHXhIM=; b=jUnMxKWBhEJMtf2jkNOddpbmry59JTpJOG/SYgEYBRV4jM5NrIXAstWi7bdocsxpOm D6rrxaG0GNfFg2uyJqB2QVrA6ghJl2V6kQ/Ol11IUSJqXYJctz3qKN1geeX9NP3JC+SI QRF9ffnSH3s6O++9JQTo/f87q1GeNrppOwQMk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YGHgpgP/FNQcwMSYtJP7Rj6whArtKD4OjHtzhlHXhIM=; b=W07rTWDDQAiNiUTyuO9t4n4obXTMdMfpePHIUzbZjUMcMgWOfBodbHwm3D+BJzmaWl MqCuAruzNfAUK48n86Kh3JGMkw+S79kGZ/fj+mwnNJBLejzo237X2bsduU9OCaTxhWV8 3Y2NEnLaPi6TDDz+NHNQazMjXtmWYVBeCx4wkxQLdhvb5zeDcynbqYUG9gfnkHiqU+g8 z/Px0w9D0RG0VwFLVtS72GuI9tmuoXBFu0EANJ4+aIrsl/UaY166a66qHJ4UVbTo2z1K izKIlBl21qDGmYTFoOTDkMJnUxIuFxk5Llwy3cwuf0Se9WX5/ttZ6qYE27BqZoT0BbmM xMhA== X-Gm-Message-State: AMCzsaUBZwOnijBmXJbskgof8/KKH1aiM3TAY3uQdzvacg6M6QyyuIqb kUngjnbgavj6gAC1RuvvI4w7P4sdCD0= X-Google-Smtp-Source: ABhQp+TxA8FIJAOsmIgNM8Tvhb8a8GOK5ED31OMxonljYCTFi0/KBZV8yR0Hug5nDZ8VuEe60VjENg== X-Received: by 10.98.137.156 with SMTP id n28mr3151603pfk.93.1509617601284; Thu, 02 Nov 2017 03:13:21 -0700 (PDT) Received: from blr-ubuntu-linaro.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id z8sm5502642pfl.135.2017.11.02.03.13.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Nov 2017 03:13:20 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 2 Nov 2017 15:43:09 +0530 Message-Id: <1509617589-22760-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509617589-22760-1-git-send-email-bhupinder.thakur@linaro.org> References: <1509617589-22760-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 2/2] xen: Fix 16550 UART console for HP Moonshot (Aarch64) platform 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-Virus-Scanned: ClamAV using ClamSMTP The console was not working on HP Moonshot (HPE Proliant Aarch64) because the UART registers were accessed as 8-bit aligned addresses. However, registers are 32-bit aligned for HP Moonshot. Since ACPI/SPCR table does not specify the register shift to be applied to the register offset, this patch implements an erratum to correctly set the register shift for HP Moonshot. Similar erratum was implemented in linux: commit 79a648328d2a604524a30523ca763fbeca0f70e3 Author: Loc Ho Date: Mon Jul 3 14:33:09 2017 -0700 ACPI: SPCR: Workaround for APM X-Gene 8250 UART 32-alignment errata APM X-Gene verion 1 and 2 have an 8250 UART with its register aligned to 32-bit. In addition, the latest released BIOS encodes the access field as 8-bit access instead 32-bit access. This causes no console with ACPI boot as the console will not match X-Gene UART port due to the lack of mmio32 option. Signed-off-by: Loc Ho Acked-by: Greg Kroah-Hartman Signed-off-by: Rafael J. Wysocki Signed-off-by: Bhupinder Thakur --- CC: Andrew Cooper CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall xen/drivers/char/ns16550.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index b3f6d85..e716aba 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -1542,6 +1542,33 @@ DT_DEVICE_END #ifdef CONFIG_ACPI #include +/* + * APM X-Gene v1 and v2 UART hardware is an 16550 like device but has its + * register aligned to 32-bit. In addition, the BIOS also encoded the + * access width to be 8 bits. This function detects this errata condition. + */ +static bool xgene_8250_erratum_present(struct acpi_table_spcr *tb) +{ + bool xgene_8250 = false; + + if ( tb->interface_type != ACPI_DBG2_16550_COMPATIBLE ) + return false; + + if ( memcmp(tb->header.oem_id, "APMC0D", ACPI_OEM_ID_SIZE) && + memcmp(tb->header.oem_id, "HPE ", ACPI_OEM_ID_SIZE) ) + return false; + + if ( !memcmp(tb->header.oem_table_id, "XGENESPC", + ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 0 ) + xgene_8250 = true; + + if ( !memcmp(tb->header.oem_table_id, "ProLiant", + ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 1 ) + xgene_8250 = true; + + return xgene_8250; +} + static int __init ns16550_acpi_uart_init(const void *data) { struct ns16550 *uart; @@ -1568,9 +1595,20 @@ static int __init ns16550_acpi_uart_init(const void *data) uart->io_base = spcr->serial_port.address; uart->irq = spcr->interrupt; uart->reg_width = spcr->serial_port.bit_width/8; - uart->reg_shift = 0; - uart->io_size = UART_MAX_REG<reg_shift; + if ( xgene_8250_erratum_present(spcr) ) + { + /* + * for xgene v1 and v2 the registers are 32-bit and so a + * register shift of 2 has to be applied to get the + * correct register offset. + */ + uart->reg_shift = 2; + } + else + uart->reg_shift = 0; + + uart->io_size = UART_MAX_REG<reg_shift; irq_set_type(spcr->interrupt, spcr->interrupt_type); uart->vuart.base_addr = uart->io_base;