Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp81850rdg; Wed, 11 Oct 2023 22:16:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGitNRNMqgfvWyEhjQO/Lr46/AJ1hczknQoTb+7rTvsZywURKLH+lITb+TplXNtglRQDjee X-Received: by 2002:a05:6a20:1593:b0:155:5c28:ea74 with SMTP id h19-20020a056a20159300b001555c28ea74mr24664684pzj.12.1697087814799; Wed, 11 Oct 2023 22:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697087814; cv=none; d=google.com; s=arc-20160816; b=CTfgqSCt2p0AHrtCbWFNBrXCA14ZkoJJlxZYe2XbxkghITPlcW8Oh8oG8IckhYd0uT qR8BuiAfhtifFGww/trtEXtcM0zLVgXfUykv2hJxAT1UBb9qs5mu2gt83gAM6zBeJFqm ShC2j66k1ssIL9J0Zn03x1CbxPgYUwq2yZsJKknrgCpGrPTgy/76kNy8jW0eO2RpCl66 1rLMWU/UnTSpBizJhH7iLrbGzDXyBLPcgmP7ApPvzAYRstdnrXGN2WnBuqrbeTk3kPfW z9+X7Ft9l5DysMSwkDopAEEAQzQD29KjTUToIbGciJSqQvoDNU8f00CSyMMpCJpQNHBq QoLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/KVKi7QKmfPZrGchNrI6Bys6/KZCng6FE4wZxaod/J0=; fh=7GYORjoWw1oF4BCDuq40hd+MOEKRwzNqXwnZ/K2vS9Q=; b=yHxHrkYrCEnkNVgxdz4x0N5E0OoGyOhx9zPehJr2M2CwgLFo3Iokrw4lGOHl5iGWFK NIf/Y9MDOG7v8+3/4nfCm+/bqIt8WYCUrEL275TYhMSPw0oGv3se2hs2srRqTOljr/fG WI0wxEt2lJn9BQYILezuSsS31Ck8L12685LyfL7LSO3LYzoS/7xtN7BJk0idWrJDnsfh UCepntv0nzh8kkqLR59zQftE1cLzKnVwnJbUP7GG2BzZlGmvGp8nG9A6DHwJoKdNy/ZA TeqM0wOJNNYbBkWw0wMSgb/oGqGwhuDGjYJ89eyDE8VTmJGsBvKdlDQlt45O+Pq++35G uNKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=DZaVzU0+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l12-20020a170903244c00b001bbae3ae2bcsi1434612pls.413.2023.10.11.22.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 22:16:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=DZaVzU0+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id E05CF80E8FDD; Wed, 11 Oct 2023 22:16:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377211AbjJLFQl (ORCPT + 99 others); Thu, 12 Oct 2023 01:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377379AbjJLFQM (ORCPT ); Thu, 12 Oct 2023 01:16:12 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F46BD45 for ; Wed, 11 Oct 2023 22:15:46 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c9b70b9656so4365815ad.1 for ; Wed, 11 Oct 2023 22:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697087745; x=1697692545; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/KVKi7QKmfPZrGchNrI6Bys6/KZCng6FE4wZxaod/J0=; b=DZaVzU0+AyzRJc3ufgtqqgJlOGxXQ3xades2Uu+jUbKqS15LvNRzis3rHmFBCFSNRG 6uxFbGimWp8FuwvYU5DZwy6hQG8VkS7CRwUWhIV7lv7/HhjQehL71w6bDjuPq4qVKYmY dquOpgiI3jkqDo9iQLKxKKuxKyc8CbTLhldvXQxnrjgOra/z5KK0U1HP26VFl9ofujqH 3EEcGu4sm/cF8k3mpcRVmjYhOe9qrz2vn1U9iX8lbCvj1M8DEW2xo7qO9aJWLvqm3qmW Wnk2XyWAqAblZoUQ3ZkzbQvrAHVeaD6yO9pBCoUxIOfyNbFOX0Rplf5j4S4VmRDW7AAb S7hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697087745; x=1697692545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/KVKi7QKmfPZrGchNrI6Bys6/KZCng6FE4wZxaod/J0=; b=V9jSBfHWo0QhzFLcpWv6hI3+FCX3AZALNSni8I8yIEXcmmgT4T1pktWKXcGw6/Byj3 M3Uw27oiKJZv9qx7cKhrhanskx4izJ2MplzwISRTJCn5bQ2KJ9w0N5uvHxV7lKQnIFaE u3iDkNRUZwFKJfiQwJBPyOHdxt0/ffmoBBlz8wjNQk/NdvNafFitf3ao7Wxd/vk/0kq3 nPc8o3BdGYuHdN4C/ricpSMD5jaJGQ5JxeaoY1ZGOzeSxnle1qqsl714ZERHhFCLKfOb 3V15zs2/wDrMxEN8JkhxKIrLRivINSAosAAljsEWKpDU61PLVIJxKy3UN/pUJc8CLFXR dGhg== X-Gm-Message-State: AOJu0YzDMmN+H+L19/CrerPVCf1AB+rxU3m9R6W31GQfUh5eFhULm+Xl Ns2wL6C5htl1FmhcU+S0A7hHcQ== X-Received: by 2002:a17:903:278e:b0:1c9:dc52:9d69 with SMTP id jw14-20020a170903278e00b001c9dc529d69mr1250864plb.64.1697087745576; Wed, 11 Oct 2023 22:15:45 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id s18-20020a17090330d200b001b9d95945afsm851309plc.155.2023.10.11.22.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 22:15:45 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra , Palmer Dabbelt , Paul Walmsley , Greg Kroah-Hartman , Jiri Slaby Cc: Conor Dooley , Andrew Jones , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v2 6/8] tty/serial: Add RISC-V SBI debug console based earlycon Date: Thu, 12 Oct 2023 10:45:07 +0530 Message-Id: <20231012051509.738750-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012051509.738750-1-apatel@ventanamicro.com> References: <20231012051509.738750-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 11 Oct 2023 22:16:51 -0700 (PDT) We extend the existing RISC-V SBI earlycon support to use the new RISC-V SBI debug console extension. Signed-off-by: Anup Patel --- drivers/tty/serial/Kconfig | 2 +- drivers/tty/serial/earlycon-riscv-sbi.c | 32 +++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index bdc568a4ab66..cec46091a716 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -87,7 +87,7 @@ config SERIAL_EARLYCON_SEMIHOST config SERIAL_EARLYCON_RISCV_SBI bool "Early console using RISC-V SBI" - depends on RISCV_SBI_V01 + depends on RISCV_SBI select SERIAL_CORE select SERIAL_CORE_CONSOLE select SERIAL_EARLYCON diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c index 27afb0b74ea7..c21cdef254e7 100644 --- a/drivers/tty/serial/earlycon-riscv-sbi.c +++ b/drivers/tty/serial/earlycon-riscv-sbi.c @@ -15,17 +15,41 @@ static void sbi_putc(struct uart_port *port, unsigned char c) sbi_console_putchar(c); } -static void sbi_console_write(struct console *con, - const char *s, unsigned n) +static void sbi_0_1_console_write(struct console *con, + const char *s, unsigned int n) { struct earlycon_device *dev = con->data; uart_console_write(&dev->port, s, n, sbi_putc); } +static void sbi_dbcn_console_write(struct console *con, + const char *s, unsigned int n) +{ + phys_addr_t pa = __pa(s); + + if (IS_ENABLED(CONFIG_32BIT)) + sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRITE, + n, lower_32_bits(pa), upper_32_bits(pa), 0, 0, 0); + else + sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRITE, + n, pa, 0, 0, 0, 0); +} + static int __init early_sbi_setup(struct earlycon_device *device, const char *opt) { - device->con->write = sbi_console_write; - return 0; + int ret = 0; + + if ((sbi_spec_version >= sbi_mk_version(2, 0)) && + (sbi_probe_extension(SBI_EXT_DBCN) > 0)) { + device->con->write = sbi_dbcn_console_write; + } else { + if (IS_ENABLED(CONFIG_RISCV_SBI_V01)) + device->con->write = sbi_0_1_console_write; + else + ret = -ENODEV; + } + + return ret; } EARLYCON_DECLARE(sbi, early_sbi_setup); -- 2.34.1