From patchwork Mon Apr 9 05:40:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 896125 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40KKJQ6Swwz9s27 for ; Mon, 9 Apr 2018 15:54:46 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DqUhqnBD"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40KKJQ4vRyzDrqP for ; Mon, 9 Apr 2018 15:54:46 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DqUhqnBD"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DqUhqnBD"; dkim-atps=neutral Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40KK0k63ptzDrZf for ; Mon, 9 Apr 2018 15:41:10 +1000 (AEST) Received: by mail-pf0-x242.google.com with SMTP id l27so5226247pfk.12 for ; Sun, 08 Apr 2018 22:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k3IAryGPOxkQSPn0xFI9k/UCfb7KIDjE4caLYn3xBmk=; b=DqUhqnBD6QB0rOMnrW6/gI1lIqFzRLL+2+FXkywKjDF7rfox9Kl0AWScW5mBGW+emV aTHzU9OPtxlQz0FedUXLZFEkoyNhMc6ncFElgxZx+KeMeGKs1SrP8FVZXiYWznKUeNbf X1+L/5Ql6IGr/4nXvxJgdlBxOT+aa7IFWwlyFUWtaK7U3PgfUvIcKmDIMWbrMVSxPXX7 i2OQK6/ena24a1zk0TGh3KprxJll8MVo76KZCC2j4yUDfMZbGEeDWVjN7NVqsZeEd/AN xa2qf+n+AREjWDMIKa4uSlWG9/h2UMuTMWHR9cQ1/yxSK4wB4tKJf56rFbgURnxp2cp1 noIQ== 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=k3IAryGPOxkQSPn0xFI9k/UCfb7KIDjE4caLYn3xBmk=; b=YlKyvMof6pfHWchdIjknmqWFrZjucqNqWBmfLVTmkHN5YdpZwSTCs+PyYGDYCiY9Ct kzN7oKjiAkB1NeItDDTQWvtCh8Bg9iYZNf1Nk5ZAMKSURVriun/9qwR79P6/on8zuXa+ vOdJhsXZodAmM8URF5Upz/DY9o/+qowvfujn1s+DerioqkjqdmtCOaB0yBTCYE5sAeyP WSYjtG0H/sAda/cIk37zTkf9zBU3Y6XkICJu8PN9lCjlmnMFWaJb97O3+O+jJDW6KjK9 njf2Yl5YdaOfmsxqnifXVtaLSX0TTJ/io/urgPIaAP5uifDURD2lqNu+ylFC9pFQgnpY Q/4g== X-Gm-Message-State: AElRT7GkTQTGJYyT0+J+MaBxiwa05Sy+qo0yoH5qXOO3bxJmtdsjLk7Q xRy0uWFq4PhPgxWd4RCfau9NnA== X-Google-Smtp-Source: AIpwx4886ZbimIKLOzxCHgpr9/1H4xJETd9ED73EDoXZiK+deZS5EF+fsVZxRR8sfLtKh0yGOc0CoQ== X-Received: by 10.99.47.4 with SMTP id v4mr24698581pgv.42.1523252468778; Sun, 08 Apr 2018 22:41:08 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id 204sm1043194pgb.67.2018.04.08.22.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 22:41:07 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/6] powerpc/powernv: opal-kmsg use flush fallback from console code Date: Mon, 9 Apr 2018 15:40:51 +1000 Message-Id: <20180409054056.27292-2-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180409054056.27292-1-npiggin@gmail.com> References: <20180409054056.27292-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Use the more refined and tested event polling loop from opal_put_chars as the fallback console flush in the opal-kmsg path. This loop is used by the console driver today, whereas the opal-kmsg fallback is not likely to have been used for years. Use WARN_ONCE rather than a printk when the fallback is invoked to prepare for moving the console flush into a common function. Cc: Russell Currey Signed-off-by: Nicholas Piggin Reviewed-by: Russell Currey --- arch/powerpc/platforms/powernv/opal-kmsg.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/platforms/powernv/opal-kmsg.c b/arch/powerpc/platforms/powernv/opal-kmsg.c index f8f41ccce75f..fd2bbf4fd6dc 100644 --- a/arch/powerpc/platforms/powernv/opal-kmsg.c +++ b/arch/powerpc/platforms/powernv/opal-kmsg.c @@ -51,20 +51,17 @@ static void force_opal_console_flush(struct kmsg_dumper *dumper, } while (rc == OPAL_PARTIAL); /* More to flush */ } else { - int i; + __be64 evt; + WARN_ONCE(1, "opal: OPAL_CONSOLE_FLUSH missing.\n"); /* * If OPAL_CONSOLE_FLUSH is not implemented in the firmware, * the console can still be flushed by calling the polling - * function enough times to flush the buffer. We don't know - * how much output still needs to be flushed, but we can be - * generous since the kernel is in panic and doesn't need - * to do much else. + * function while it has OPAL_EVENT_CONSOLE_OUTPUT events. */ - printk(KERN_NOTICE "opal: OPAL_CONSOLE_FLUSH missing.\n"); - for (i = 0; i < 1024; i++) { - opal_poll_events(NULL); - } + do { + opal_poll_events(&evt); + } while (be64_to_cpu(evt) & OPAL_EVENT_CONSOLE_OUTPUT); } } From patchwork Mon Apr 9 05:40:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 896126 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40KKMR2Klmz9rvt for ; Mon, 9 Apr 2018 15:57:23 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CXnCMaEf"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40KKMR0s5GzDqlJ for ; Mon, 9 Apr 2018 15:57:23 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CXnCMaEf"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::241; helo=mail-pf0-x241.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CXnCMaEf"; dkim-atps=neutral Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40KK0p0vJ9zDqfk for ; Mon, 9 Apr 2018 15:41:13 +1000 (AEST) Received: by mail-pf0-x241.google.com with SMTP id o16so5223991pfk.9 for ; Sun, 08 Apr 2018 22:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NlDOKnkG4QrPcfDs0ZdQLIds8f+OGL0qtWvWZxoIbew=; b=CXnCMaEf7P82guoxFYaqmm65D5mZSc1KPlkQr42sulT0YrR5DGpG6BshSiViX6wPuk jdy292ZL+I+5CyAYBlbXV4rYroGCL51SSALAAOPgzf5tVpGZXdwcXX4BUZJ4Gqh+o2Hn CsxLGQJXlc9J78WsNxD3qRLAyFqeW26Dw16RsbdNgvrnIupMBcDqpDbe2bLhV6V6FvdA N4ahP59cVCOxYUa76RqPuxVO8hll+JxyFmMjSitdoHmivDEGQmCcE5T2Va2BXgCn+JaY sTksyLd+R+czsKLa2QD2WoFYoYVJ/DcHF1qKJRrhVN8MxhtbQfogOi9aArh71OCPdaQG bGrA== 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=NlDOKnkG4QrPcfDs0ZdQLIds8f+OGL0qtWvWZxoIbew=; b=TGErdAnkP4a1uUSFPaxfyGkRqNFSIhu1bxmAt4AgDrlHy5sGrN8vDNDQuaQLcI1kWL MPKRYPSUgn55+F3gC8w+4R0+1wT5L8d6hlwbJ7yWFfUGw/KRQdUpJmssNRlvwLbms8JH jCnfmtSxsmdVZm7yt7YraYgm3k9uUZeMGiSTyGkGJ0DNnSLjh+slyGJfZEMjFFKDsxwe sDtSQk76HvbFCtyuCle0J/3RRPG1XoQSZsVnQzwmvzZmoSRecbZppqXSPjJcpfO/itbN BRaVk35FjoFgr6TcvyJtjoMfwNedUx36tHzQC37Mqf4oEW8HZpyob3hqrnPSgxAgRrvP eGjg== X-Gm-Message-State: ALQs6tDPLG8W09ycwWn5zDrVRwPh4JE9sFG0TcI/mzZskmD1tdqNhIhy TDDMlU394DAxT3V9bJE2sA142Q== X-Google-Smtp-Source: AIpwx48huDHZcycV/BWGCBBx7J8cC4/ooIyhkAe1WoVryGAwfDVFAwA7GzKOG9euJzrKXV9yj4eIPw== X-Received: by 10.101.72.133 with SMTP id n5mr1919932pgs.390.1523252472006; Sun, 08 Apr 2018 22:41:12 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id 204sm1043194pgb.67.2018.04.08.22.41.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 22:41:11 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/6] powerpc/powernv: Implement and use opal_flush_console Date: Mon, 9 Apr 2018 15:40:52 +1000 Message-Id: <20180409054056.27292-3-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180409054056.27292-1-npiggin@gmail.com> References: <20180409054056.27292-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" A new console flushing firmware API was introduced to replace event polling loops, and implemented in opal-kmsg with affddff69c55e ("powerpc/powernv: Add a kmsg_dumper that flushes console output on panic"), to flush the console in the panic path. The OPAL console driver has other situations where interrupts are off and it needs to flush the console synchronously. These still use a polling loop. So move the opal-kmsg flush code to opal_flush_console, and use the new function in opal-kmsg and opal_put_chars. Cc: Benjamin Herrenschmidt Cc: Russell Currey Signed-off-by: Nicholas Piggin Reviewed-by: Russell Currey --- arch/powerpc/include/asm/opal.h | 1 + arch/powerpc/platforms/powernv/opal-kmsg.c | 35 ++---------------- arch/powerpc/platforms/powernv/opal.c | 42 +++++++++++++++++++--- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index 03e1a920491e..bbff49fab0e5 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h @@ -303,6 +303,7 @@ extern void opal_configure_cores(void); extern int opal_get_chars(uint32_t vtermno, char *buf, int count); extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len); +extern int opal_flush_console(uint32_t vtermno); extern void hvc_opal_init_early(void); diff --git a/arch/powerpc/platforms/powernv/opal-kmsg.c b/arch/powerpc/platforms/powernv/opal-kmsg.c index fd2bbf4fd6dc..55691950d981 100644 --- a/arch/powerpc/platforms/powernv/opal-kmsg.c +++ b/arch/powerpc/platforms/powernv/opal-kmsg.c @@ -12,7 +12,6 @@ */ #include -#include #include #include @@ -24,11 +23,9 @@ * may not be completely printed. This function does not actually dump the * message, it just ensures that OPAL completely flushes the console buffer. */ -static void force_opal_console_flush(struct kmsg_dumper *dumper, +static void kmsg_dump_opal_console_flush(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason) { - s64 rc; - /* * Outside of a panic context the pollers will continue to run, * so we don't need to do any special flushing. @@ -36,37 +33,11 @@ static void force_opal_console_flush(struct kmsg_dumper *dumper, if (reason != KMSG_DUMP_PANIC) return; - if (opal_check_token(OPAL_CONSOLE_FLUSH)) { - do { - rc = OPAL_BUSY; - while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { - rc = opal_console_flush(0); - if (rc == OPAL_BUSY_EVENT) { - mdelay(OPAL_BUSY_DELAY_MS); - opal_poll_events(NULL); - } else if (rc == OPAL_BUSY) { - mdelay(OPAL_BUSY_DELAY_MS); - } - } - } while (rc == OPAL_PARTIAL); /* More to flush */ - - } else { - __be64 evt; - - WARN_ONCE(1, "opal: OPAL_CONSOLE_FLUSH missing.\n"); - /* - * If OPAL_CONSOLE_FLUSH is not implemented in the firmware, - * the console can still be flushed by calling the polling - * function while it has OPAL_EVENT_CONSOLE_OUTPUT events. - */ - do { - opal_poll_events(&evt); - } while (be64_to_cpu(evt) & OPAL_EVENT_CONSOLE_OUTPUT); - } + opal_flush_console(0); } static struct kmsg_dumper opal_kmsg_dumper = { - .dump = force_opal_console_flush + .dump = kmsg_dump_opal_console_flush }; void __init opal_kmsg_init(void) diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 0f03199a8664..d54ac3736c34 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -350,7 +350,6 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len) __be64 olen; s64 len, rc; unsigned long flags; - __be64 evt; if (!opal.entry) return -ENODEV; @@ -371,7 +370,7 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len) /* Closed -> drop characters */ if (rc) return total_len; - opal_poll_events(NULL); + opal_flush_console(vtermno); return -EAGAIN; } @@ -410,12 +409,47 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len) * things a bit later to limit that to synchronous path * such as the kernel console and xmon/udbg */ + opal_flush_console(vtermno); + } + spin_unlock_irqrestore(&opal_write_lock, flags); + + return written; +} + +int opal_flush_console(uint32_t vtermno) +{ + s64 rc; + + if (!opal_check_token(OPAL_CONSOLE_FLUSH)) { + __be64 evt; + + WARN_ONCE(1, "opal: OPAL_CONSOLE_FLUSH missing.\n"); + /* + * If OPAL_CONSOLE_FLUSH is not implemented in the firmware, + * the console can still be flushed by calling the polling + * function while it has OPAL_EVENT_CONSOLE_OUTPUT events. + */ do { opal_poll_events(&evt); } while (be64_to_cpu(evt) & OPAL_EVENT_CONSOLE_OUTPUT); + + return OPAL_SUCCESS; } - spin_unlock_irqrestore(&opal_write_lock, flags); - return written; + + do { + rc = OPAL_BUSY; + while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { + rc = opal_console_flush(vtermno); + if (rc == OPAL_BUSY_EVENT) { + mdelay(OPAL_BUSY_DELAY_MS); + opal_poll_events(NULL); + } else if (rc == OPAL_BUSY) { + mdelay(OPAL_BUSY_DELAY_MS); + } + } + } while (rc == OPAL_PARTIAL); /* More to flush */ + + return opal_error_code(rc); } static int opal_recover_mce(struct pt_regs *regs, From patchwork Mon Apr 9 05:40:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 896127 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40KKQG4Wb9z9rvt for ; Mon, 9 Apr 2018 15:59:50 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Dme2r6q8"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40KKQG2xTtzDqwW for ; Mon, 9 Apr 2018 15:59:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Dme2r6q8"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Dme2r6q8"; dkim-atps=neutral Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40KK0t30z0zDrJx for ; Mon, 9 Apr 2018 15:41:18 +1000 (AEST) Received: by mail-pl0-x244.google.com with SMTP id b6-v6so4481212pla.11 for ; Sun, 08 Apr 2018 22:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UIlw4hfRCusQ72obCcvz4ss1OcAYurUHOc0VwKYeJGM=; b=Dme2r6q82D0gHirctExC3pBgoG9Yqd6/gRUJzUCBfwXWwU7zEAf12nZPAbofrdg1po jZMka6AKe6l7nZjnK/pkoRayFCy42jOc/e9ZIpQlWjK0FT4SPOjDjRYvWXeUx/40FDbq 0UhCWD0CvlCOgvpC8SXm8wy1U/ByXa9ztL8eW+byZ+Y8hMeYWvqC+pIE1G4pioMmz5dr xcCU8fOzQQHTF82J5/TW7cHOCQNe9zFhn8MTMsRV9tWANczssmD0OOpLkaO2GYjS1uIU F879pNLIX/ebORUAPSuW4csbto8M4k6Zq2X9nrNa8/B9geBDZNoNPKsnLPuO4o3/4fIg c3hg== 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=UIlw4hfRCusQ72obCcvz4ss1OcAYurUHOc0VwKYeJGM=; b=f1r9SmL1lGqeIDStgcejdEAeEiDDW+zHlF133kxQcuwfss4O2u5jVVsW+HC/sSYqg5 Lge0ZKSjrG4o7uKGOKv+K4XNUhp6EBTXNtgijyQkgiOtV6vAKtrGaq1HXAPo9Lp4mfPL c9dCF+EX3eJVoOKPTusnKBSCIRcquTai3E8plN6eeUCcuoVlYfJ6ETsI8wTNqDsTN+Gz VJsl3wnxPknzGSGFCmrGNddw141C3Ksp5LDpDkKGEQS+GSmUhCuVzilAo6qnFc/FP4PR VY6qnBemtMYtbExN/NGVmV2WYJqhupiiB6eA9ANX3AEG9449Z47b4S+1YEs84V4KJNO9 fWlg== X-Gm-Message-State: ALQs6tDS1EMuNe0jdnl6NC6TKa6+/xq0h6FtqOodxJoYlVsjIK8a0onH gcOJpr7gf6iLVcGFK912hnmzjQ== X-Google-Smtp-Source: AIpwx4/dTIHL807n1gXaS5eM83zCQdARxgl/rXb+Jbq7Cewhclln5Lm8r6ZdYrNSC2NjXlkVU6amTA== X-Received: by 2002:a17:902:bcc5:: with SMTP id o5-v6mr7784892pls.56.1523252475333; Sun, 08 Apr 2018 22:41:15 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id 204sm1043194pgb.67.2018.04.08.22.41.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 22:41:14 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 3/6] powerpc/powernv: Remove OPALv1 support from opal console driver Date: Mon, 9 Apr 2018 15:40:53 +1000 Message-Id: <20180409054056.27292-4-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180409054056.27292-1-npiggin@gmail.com> References: <20180409054056.27292-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" opal_put_chars deals with partial writes because in OPALv1, opal_console_write_buffer_space did not work correctly. That firmware is not supported. This reworks the opal_put_chars code to no longer deal with partial writes and turn them into full writes. Partial write handling is still supported in terms of what gets returned to the caller, but it may not go to the console atomically. A warning message is printed in this case. This allows console flushing to be moved out of the opal_write_lock spinlock. That could cause the lock to be held for long periods if the console is busy (especially if it was being spammed by firmware), which is dangerous because the lock is taken by xmon to debug the system. Flushing outside the lock improves the situation a bit. Cc: Benjamin Herrenschmidt Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/powernv/opal.c | 86 +++++++++++++-------------- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index d54ac3736c34..a045c446a910 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -346,10 +346,10 @@ int opal_get_chars(uint32_t vtermno, char *buf, int count) int opal_put_chars(uint32_t vtermno, const char *data, int total_len) { - int written = 0; - __be64 olen; - s64 len, rc; unsigned long flags; + int written; + __be64 olen; + s64 rc; if (!opal.entry) return -ENODEV; @@ -357,62 +357,56 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len) /* We want put_chars to be atomic to avoid mangling of hvsi * packets. To do that, we first test for room and return * -EAGAIN if there isn't enough. - * - * Unfortunately, opal_console_write_buffer_space() doesn't - * appear to work on opal v1, so we just assume there is - * enough room and be done with it */ spin_lock_irqsave(&opal_write_lock, flags); rc = opal_console_write_buffer_space(vtermno, &olen); - len = be64_to_cpu(olen); - if (rc || len < total_len) { - spin_unlock_irqrestore(&opal_write_lock, flags); + if (rc || be64_to_cpu(olen) < total_len) { /* Closed -> drop characters */ if (rc) - return total_len; - opal_flush_console(vtermno); - return -EAGAIN; + written = total_len; + else + written = -EAGAIN; + goto out; } - /* We still try to handle partial completions, though they - * should no longer happen. - */ - - while (total_len > 0) { - olen = cpu_to_be64(total_len); - - rc = OPAL_BUSY; - while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { - rc = opal_console_write(vtermno, &olen, data); - if (rc == OPAL_BUSY_EVENT) { - mdelay(OPAL_BUSY_DELAY_MS); - opal_poll_events(NULL); - } else if (rc == OPAL_BUSY) { - mdelay(OPAL_BUSY_DELAY_MS); - } - } - - len = be64_to_cpu(olen); - - /* Closed or other error drop */ - if (rc != OPAL_SUCCESS) { - written += total_len; /* drop remaining chars */ - break; + /* Should not get a partial write here because space is available. */ + olen = cpu_to_be64(total_len); + rc = opal_console_write(vtermno, &olen, data); + if (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { + if (rc == OPAL_BUSY_EVENT) { + mdelay(OPAL_BUSY_DELAY_MS); + opal_poll_events(NULL); + } else if (rc == OPAL_BUSY_EVENT) { + mdelay(OPAL_BUSY_DELAY_MS); } + written = -EAGAIN; + goto out; + } - total_len -= len; - data += len; - written += len; + /* Closed or other error drop */ + if (rc != OPAL_SUCCESS) { + written = opal_error_code(rc); + goto out; + } - /* This is a bit nasty but we need that for the console to - * flush when there aren't any interrupts. We will clean - * things a bit later to limit that to synchronous path - * such as the kernel console and xmon/udbg - */ - opal_flush_console(vtermno); + written = be64_to_cpu(olen); + if (written < total_len) { + /* Should not happen */ + pr_warn("atomic console write returned partial len=%d written=%d\n", total_len, written); + if (!written) + written = -EAGAIN; } + +out: spin_unlock_irqrestore(&opal_write_lock, flags); + /* This is a bit nasty but we need that for the console to + * flush when there aren't any interrupts. We will clean + * things a bit later to limit that to synchronous path + * such as the kernel console and xmon/udbg + */ + opal_flush_console(vtermno); + return written; } From patchwork Mon Apr 9 05:40:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 896128 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40KKTR0hZ9z9s27 for ; Mon, 9 Apr 2018 16:02:35 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RLuaPHhA"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40KKTQ685vzDr5X for ; Mon, 9 Apr 2018 16:02:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RLuaPHhA"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::242; helo=mail-pl0-x242.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RLuaPHhA"; dkim-atps=neutral Received: from mail-pl0-x242.google.com (mail-pl0-x242.google.com [IPv6:2607:f8b0:400e:c01::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40KK0w0RWmzDrbT for ; Mon, 9 Apr 2018 15:41:19 +1000 (AEST) Received: by mail-pl0-x242.google.com with SMTP id t20-v6so1648064ply.9 for ; Sun, 08 Apr 2018 22:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1IMoFhwtlhVUgn/R05IRgXu6a3XyKEQ1l3Fyn7UVu50=; b=RLuaPHhAM9+1GVI3Rg/vIumP7M4afjq5/WOJAC3Ega3Jwyji10wWb+Rk+WxmFToIe9 KRcZGBF8ONFum+ZHrAtuwN8csDThlE+L9N+EZXu2X8ufxAk8VXg7fu9wIyT+gUdw9eF5 k7Hcaz52tLHvi/y9Zp+JU7ZJyD2+o3dmayr4BXTm9fuzbcLrejBDUWB+GBGaipuFrL+J KXp/pOp+ky4IEFWvG2lmRjk4nN2q2sbwLlcWId0w8gG0F/Ut835uXocmgfJylRCZE8E3 FxucH62JwIl2ziMzF+QfVlJ1pmgd5n3hIWxWOYZJ1IKjUdCozCmIqbQAIcJOKmpx7NNe 17iA== 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=1IMoFhwtlhVUgn/R05IRgXu6a3XyKEQ1l3Fyn7UVu50=; b=s1WDrySLIOJxUE+vdaJASa8r3ZQQrkW0h2sOceb8EQTHI5Y+2Wf8PiS8BewhdS7zgq DJRhmkT7s1qPry3ckm2KwH/RfieUWNxJYAF/Ft5x1lEC0zrVfn5rOc48fm0SArAoI7Bl 27wBGv8RlLNqryoyeD/fM6fqwl+JKsiu1ajLyaU0OqQjGpCbYa79ul+ld1vn8M6Z06Xp J9L+iLAtP3dQ05bO5xuiZnJSBcXsJ19BsTo8/RG/sK14We9Q7O3ov/C+hZvwHxZ1cb2J qxnJxE0lO25gL+OqdX5AfREE2OYa2Zzp6Rql8C9Znerho4LsAcoJeiUN1bEGP2QKV8zt uQZw== X-Gm-Message-State: AElRT7GfxbG3pJHRIaGKzS+i2QHy+93h9lnoGaMYB87tM/Yb5YvAFvTn n3SS5sA5CYqrMT5xuy1EbA0/Yw== X-Google-Smtp-Source: AIpwx4+ml1IGuOFrL8/NwZd5RDBMQtEMHy2BlcTSekolr2afMlKHljH1F6U2KNBrXvkm5PZ2e+ydIw== X-Received: by 2002:a17:902:a60d:: with SMTP id u13-v6mr37314265plq.305.1523252477946; Sun, 08 Apr 2018 22:41:17 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id 204sm1043194pgb.67.2018.04.08.22.41.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 22:41:17 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 4/6] powerpc/powernv: move opal console flushing to udbg Date: Mon, 9 Apr 2018 15:40:54 +1000 Message-Id: <20180409054056.27292-5-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180409054056.27292-1-npiggin@gmail.com> References: <20180409054056.27292-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" OPAL console writes do not have to synchronously flush firmware / hardware buffers unless they are going through the udbg path. Remove the unconditional flushing from opal_put_chars. Flush if there was no space in the buffer as an optimisation (callers loop waiting for success in that case). udbg flushing is moved to udbg_opal_putc. Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/powernv/opal.c | 12 +++++++----- drivers/tty/hvc/hvc_opal.c | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index a045c446a910..b05500a70f58 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -400,12 +400,14 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len) out: spin_unlock_irqrestore(&opal_write_lock, flags); - /* This is a bit nasty but we need that for the console to - * flush when there aren't any interrupts. We will clean - * things a bit later to limit that to synchronous path - * such as the kernel console and xmon/udbg + /* In the -EAGAIN case, callers loop, so we have to flush the console + * here in case they have interrupts off (and we don't want to wait + * for async flushing if we can make immediate progress here). If + * necessary the API could be made entirely non-flushing if the + * callers had a ->flush API to use. */ - opal_flush_console(vtermno); + if (written == -EAGAIN) + opal_flush_console(vtermno); return written; } diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c index 2ed07ca6389e..af122ad7f06d 100644 --- a/drivers/tty/hvc/hvc_opal.c +++ b/drivers/tty/hvc/hvc_opal.c @@ -275,6 +275,11 @@ static void udbg_opal_putc(char c) count = hvc_opal_hvsi_put_chars(termno, &c, 1); break; } + + /* This is needed for the cosole to flush + * when there aren't any interrupts. + */ + opal_flush_console(termno); } while(count == 0 || count == -EAGAIN); } From patchwork Mon Apr 9 05:40:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 896129 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40KKX65brkz9s0t for ; Mon, 9 Apr 2018 16:04:54 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hAGEPn4A"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40KKX645BZzDqvM for ; Mon, 9 Apr 2018 16:04:54 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hAGEPn4A"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::243; helo=mail-pl0-x243.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hAGEPn4A"; dkim-atps=neutral Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40KK0y5W9GzDrLj for ; Mon, 9 Apr 2018 15:41:22 +1000 (AEST) Received: by mail-pl0-x243.google.com with SMTP id v5-v6so4482643plo.4 for ; Sun, 08 Apr 2018 22:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5o74PmNcQvsV3/1Pq34862rHnDXFMWeJKsuO1SDaVSs=; b=hAGEPn4AIiy05bZ+mokFSIe66BKLWm+0bX4S1x3rCQyFLVnFRjAmWs61pFi7aJM79o LoCpMZPtuAlYHRRBLFStfiel/4hO0Q6D4TsWbM6P2KbSTc0ITHy2BS8SLArWBuEvOg+n te+Odvft9avCKzGd/xZQPsx4fQtCAv1ziegb2nuxvaF3UAuitR+HdrYm9ldcRflBtt7/ m3RM9MPTiDZ6TOo/l+g5hfm+501pq6B2RoT2xfksEuOqwgPjCie76+mQB1xRkaX72sb2 lzCz8xuXBgaaTEPKd/jo3htU7GZSfF/zcfOiBQzVdSVAV2txxJ6i5kduV/eBf3mYe21H 8+mw== 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=5o74PmNcQvsV3/1Pq34862rHnDXFMWeJKsuO1SDaVSs=; b=GKOO2ccXjGxtKUL1r8gZ+rYAw6XF21SKAsb8Gs6OBIAJ6TmOwwet+vGG5GvsAh1Ak1 UUg6AjmyTMPtvfxEZvI0ImmqFD8XXt7M61OduJU0VE8bfr13IaGxEUd3lA0y9mqlf0SD Jy7j/Rqi7J3SM260+OovoIrGb9ZL/DGMlWY1a0q/N1VWiuj5jad64ZNldrrZkO7ar0rb EBNWY5WmOL7Me39bUVeKY0uBpTp4tI6CzNEcXSrQPRUGbV80M9lq2avpJVCz1yWu88Os AEQ/Mp4EQSdSUyRQUWoymr3JEm6TT+7uwVyuNPSbvvbDfVfVsP3EB3fIkUVoMupRZ6Zo OPug== X-Gm-Message-State: AElRT7FjK4okIkJMhPP6/ejuJHRqtdOgVjuGLKm+bnPF6e8c5StfUOnp wxtnbrEF5aXmnk2B1MyiMHxwTg== X-Google-Smtp-Source: AIpwx4/wQFGl0n9tWDYhvp3g5Ezy056AYpfmjxBNSubkCmSJxaNZaVeqTQjoyMRnI8t9ty2uuWPfYw== X-Received: by 2002:a17:902:96a:: with SMTP id 97-v6mr27862500plm.266.1523252480863; Sun, 08 Apr 2018 22:41:20 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id 204sm1043194pgb.67.2018.04.08.22.41.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 22:41:20 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 5/6] powerpc/powernv: implement opal_put_chars_nonatomic Date: Mon, 9 Apr 2018 15:40:55 +1000 Message-Id: <20180409054056.27292-6-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180409054056.27292-1-npiggin@gmail.com> References: <20180409054056.27292-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The RAW console does not need writes to be atomic, so implement a _nonatomic variant which does not take a spinlock. This API is used in xmon, so the less locking thta's used, the better chance there is that a crash can be debugged. Cc: Benjamin Herrenschmidt Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/opal.h | 1 + arch/powerpc/platforms/powernv/opal.c | 35 +++++++++++++++++++-------- drivers/tty/hvc/hvc_opal.c | 4 +-- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index bbff49fab0e5..66954d671831 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h @@ -303,6 +303,7 @@ extern void opal_configure_cores(void); extern int opal_get_chars(uint32_t vtermno, char *buf, int count); extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len); +extern int opal_put_chars_nonatomic(uint32_t vtermno, const char *buf, int total_len); extern int opal_flush_console(uint32_t vtermno); extern void hvc_opal_init_early(void); diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index b05500a70f58..dc77fc57d1e9 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -344,9 +344,9 @@ int opal_get_chars(uint32_t vtermno, char *buf, int count) return 0; } -int opal_put_chars(uint32_t vtermno, const char *data, int total_len) +static int __opal_put_chars(uint32_t vtermno, const char *data, int total_len, bool atomic) { - unsigned long flags; + unsigned long flags = 0 /* shut up gcc */; int written; __be64 olen; s64 rc; @@ -354,11 +354,8 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len) if (!opal.entry) return -ENODEV; - /* We want put_chars to be atomic to avoid mangling of hvsi - * packets. To do that, we first test for room and return - * -EAGAIN if there isn't enough. - */ - spin_lock_irqsave(&opal_write_lock, flags); + if (atomic) + spin_lock_irqsave(&opal_write_lock, flags); rc = opal_console_write_buffer_space(vtermno, &olen); if (rc || be64_to_cpu(olen) < total_len) { /* Closed -> drop characters */ @@ -391,14 +388,18 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len) written = be64_to_cpu(olen); if (written < total_len) { - /* Should not happen */ - pr_warn("atomic console write returned partial len=%d written=%d\n", total_len, written); + if (atomic) { + /* Should not happen */ + pr_warn("atomic console write returned partial " + "len=%d written=%d\n", total_len, written); + } if (!written) written = -EAGAIN; } out: - spin_unlock_irqrestore(&opal_write_lock, flags); + if (atomic) + spin_unlock_irqrestore(&opal_write_lock, flags); /* In the -EAGAIN case, callers loop, so we have to flush the console * here in case they have interrupts off (and we don't want to wait @@ -412,6 +413,20 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len) return written; } +int opal_put_chars(uint32_t vtermno, const char *data, int total_len) +{ + /* We want put_chars to be atomic to avoid mangling of hvsi + * packets. To do that, we first test for room and return + * -EAGAIN if there isn't enough. + */ + return __opal_put_chars(vtermno, data, total_len, true); +} + +int opal_put_chars_nonatomic(uint32_t vtermno, const char *data, int total_len) +{ + return __opal_put_chars(vtermno, data, total_len, false); +} + int opal_flush_console(uint32_t vtermno) { s64 rc; diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c index af122ad7f06d..e151cfacf2a7 100644 --- a/drivers/tty/hvc/hvc_opal.c +++ b/drivers/tty/hvc/hvc_opal.c @@ -51,7 +51,7 @@ static u32 hvc_opal_boot_termno; static const struct hv_ops hvc_opal_raw_ops = { .get_chars = opal_get_chars, - .put_chars = opal_put_chars, + .put_chars = opal_put_chars_nonatomic, .notifier_add = notifier_add_irq, .notifier_del = notifier_del_irq, .notifier_hangup = notifier_hangup_irq, @@ -269,7 +269,7 @@ static void udbg_opal_putc(char c) do { switch(hvc_opal_boot_priv.proto) { case HV_PROTOCOL_RAW: - count = opal_put_chars(termno, &c, 1); + count = opal_put_chars_nonatomic(termno, &c, 1); break; case HV_PROTOCOL_HVSI: count = hvc_opal_hvsi_put_chars(termno, &c, 1); From patchwork Mon Apr 9 05:40:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 896130 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40KKb62Vk9z9s0t for ; Mon, 9 Apr 2018 16:07:30 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CkoMgtaN"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40KKb60RwVzDqvH for ; Mon, 9 Apr 2018 16:07:30 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CkoMgtaN"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::244; helo=mail-pf0-x244.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CkoMgtaN"; dkim-atps=neutral Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40KK121XZBzDr3t for ; Mon, 9 Apr 2018 15:41:26 +1000 (AEST) Received: by mail-pf0-x244.google.com with SMTP id a2so5234331pff.8 for ; Sun, 08 Apr 2018 22:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HEPXN3AH8tgZzHS4Ujcw5nnYG9YQTbYLQC+be7pmhgA=; b=CkoMgtaNL+ulR3V6iU77VzaewqM9E8emlZFLtUfdEc9didySqKJXY+PESZE/1J8U6X eAPYqZH813Cqazavic8s0R22bCh+7VW3PwZmKW8mjn/r6ye+8XivS1mNsDWa7eMJfmTb Igy0iN6bvjMwnEKyQAJigLDnlp16As2GWjll4+CJdLl269NEHS0/H4CCqJTguGzJ6fxJ Bkprfwoh9sgEHNmXckOg16it3Ct6aNqKG+UZlniazb4jmYwCZgsU3Mxl8i1/EhCEtNgb jkkGtbGjiEBMc1Kpg9ML5MRwSdjX0dO2t3HlkAW6uhlqG1xz+t5HR7MG7DHUVASjb7vg wyjw== 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=HEPXN3AH8tgZzHS4Ujcw5nnYG9YQTbYLQC+be7pmhgA=; b=MYUHDAePAdjhLDHlHgJg3FZNJQeydOWTRszjxBn2aHNhPjObzT9bBh+XUKzuE3E4ky uWccxK8KIQEzIbgBq374tApdgYvNxZC2hLa8N1R8w7YoxWQoCps6zM7ldVcnX+28SHNC PYnIJBPCKHRmB11zOwKm6oN20ESFMgtcQVuBvbELd8QW3ZZ4mCiXkJnmkSsssWY4F31U t2TktJWOt2MSFzBn3j1Ud6BEOg2FUk4lkAktJ1Z88qS3Y1MR4XAPfKnI4rzb9y4imYDO YWov3rRt/6nYJdiMPxhLfN+coAqakBLk7QQPvOe3UbFTzpxavuo8mtn9bYmHnwnJHFce I9kQ== X-Gm-Message-State: AElRT7FKa99Aagau8s7ipHye1MxULdTsw8fIekxrVxTfKb3uw8rjbiVG 4LAe0+DiFPGq+t2qzdFutxQuoQ== X-Google-Smtp-Source: AIpwx4+23zBnOYFJUtAKi3QFUGv1OzaPlieGQxrNeGc4BtuG+tLkL8fIZo7PmEWfP91d3+mDPFSkMQ== X-Received: by 10.98.133.212 with SMTP id m81mr28146869pfk.61.1523252483845; Sun, 08 Apr 2018 22:41:23 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id 204sm1043194pgb.67.2018.04.08.22.41.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 22:41:23 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 6/6] drivers/tty/hvc: remove unexplained "just in case" spin delay Date: Mon, 9 Apr 2018 15:40:56 +1000 Message-Id: <20180409054056.27292-7-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180409054056.27292-1-npiggin@gmail.com> References: <20180409054056.27292-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This delay was in the very first OPAL console commit 6.5 years ago. The firmware console has hardened sufficiently to remove it. Cc: Benjamin Herrenschmidt Signed-off-by: Nicholas Piggin Reviewed-by: Benjamin Herrenschmidt --- drivers/tty/hvc/hvc_opal.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c index e151cfacf2a7..436b98258e60 100644 --- a/drivers/tty/hvc/hvc_opal.c +++ b/drivers/tty/hvc/hvc_opal.c @@ -307,14 +307,8 @@ static int udbg_opal_getc(void) int ch; for (;;) { ch = udbg_opal_getc_poll(); - if (ch == -1) { - /* This shouldn't be needed...but... */ - volatile unsigned long delay; - for (delay=0; delay < 2000000; delay++) - ; - } else { + if (ch != -1) return ch; - } } }