Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp198535rdb; Thu, 19 Oct 2023 01:28:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoE6qyYREO1Qwg9etHt981OZJCE9iBmutKEOmvu6KT1O9tS1kmQ+rze7gI8wYWdHf4M/ar X-Received: by 2002:aa7:96d8:0:b0:68f:dfea:9100 with SMTP id h24-20020aa796d8000000b0068fdfea9100mr1202641pfq.21.1697704080431; Thu, 19 Oct 2023 01:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697704080; cv=none; d=google.com; s=arc-20160816; b=U0iO30B/lmSu0Mvev9IqEVxTUl712Q20dc+3uE7OGCdLCwZiBdnbU0n7Rc/aNgwxnH QRMrMOt+qtbowu12ceKB09FWj364FtLImO2fwoshPfff3DKxBH5XROlnaqZQWhN2S2ab 04c/7LOcJCPFSlZdhR/AdNkyKKQ5EGi7sJXb84w4ELUmb4Dxme44LjqYcuKReVPd/mCW 9g8wJarj1JxOksARof4OlNaCMnidWLHzJZXaBYB3MGSL7tTnmMTYUpPXxxK87Ft+1VPV oBb4mBCvOTm2EGsZuh/9kk4grsvGpsTJKZqVnDbCV7OKVV2CJEzWjet62YbV25SKfgwv Vgxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aS9ZmATMA5UdrpXcs84XzGO/WomcKSWd4ogsdFNAVRI=; fh=HphsaL+YRSr8xSEjXKGEGNHhmBU1p3niIw2svRX7Lek=; b=RT60AqRt8CvkgAvJD8C+flG9gUxCtxkXOF9k7YXlc0c4G6QHXZLTTU3/SXXifaXHZE NoxOT7kedlzdvl7FyjFS3/nbuS7HoAfyZIHNpaWo+2IJpXPYIZloezHFKU/mDA0pcnRn LNgCI/WJcfXvbq0MiMAxac7Ng+yteKpbftrRx2SUkVSq44B2LQdgBv7bUeL/Gpt1sUNb abJTJ2XESiURywLbHicnaURNib+M7EYzZUdQnT2rysvt/meq/o0UJofLmnSztGBgxGaQ n3AztlXoe7U9ZxbLV0ZEVUEAJadDMtWKw0+TPUekO80RnU9vZJNCo3iI+eZAkr8DXSCA f8Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=XeWRh86N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id i185-20020a6387c2000000b005acd0dd0da0si3799626pge.70.2023.10.19.01.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 01:28:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=XeWRh86N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id ED81C811ADA1; Thu, 19 Oct 2023 01:27:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344923AbjJSI11 (ORCPT + 99 others); Thu, 19 Oct 2023 04:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235305AbjJSI1Y (ORCPT ); Thu, 19 Oct 2023 04:27:24 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3162E182 for ; Thu, 19 Oct 2023 01:27:22 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-408425c7c10so6770185e9.0 for ; Thu, 19 Oct 2023 01:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697704040; x=1698308840; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=aS9ZmATMA5UdrpXcs84XzGO/WomcKSWd4ogsdFNAVRI=; b=XeWRh86NjQnJhCBd8Cr+Vl4dZlXoiCz0GwycngbJlR16x1ywvojIjh/UUDdn7MHnNq VqwtW1qQGPrXZ0fZQGGc9U6ybwc8y0HmfLDerpVU6QRjNXeJqRRm3vFTXkwfUZRHtslf 4XNr+sqxHbvhiVFOkgO4gz+YtI8lfSRtdtDbaCJFydbNfCfwaGgHdqmjgg2SWbGvvPgH AF46fUdxRtIY8bpcoxoCHrZE0EkVj0HdWLotshF/LILmyJ4y2GLpprUfpXNaigkLPe4+ Ro549X/Nx3m0SnNguhOZJbl3GRqXuyP7ZJokkFvtKjMDu5xvFKoPfeSnJ6C3bKDpR7R9 iS8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697704040; x=1698308840; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aS9ZmATMA5UdrpXcs84XzGO/WomcKSWd4ogsdFNAVRI=; b=XEWpYQkMHETlw36QRiMrgNO/Kl0wdhFwdDiTFTuBtUi7XJTgz1cLRBoUVkYgjsjg8E qNK4y29u14LwaV6TwRTR2i7nPPG+EOfq6HcVgGzTQSjI1Ao9kisqfZ8B4uVXyOk++cAR hLy1Z3lYn79LNGakiM07j2WwAkC9HF2XOLfoDMa2ZmwIoYZeqi3Kd9oY1ccAutcvAny2 Y04yJliljHNBtWwTkBXScMjPcotZWyBwoxtWkvvyt7QL7AFy5RkfgLg5ONwEmBS0+0C0 NEuUvzgjERYYBymM4UQzzZSpozuObT6pmSTxElPsuqVpLepFO6fJc/3RR1a6TpXKtZ2u V/UA== X-Gm-Message-State: AOJu0YxDIcsFRLlCGZFSumCqjN1TLinCOT4mjxGEZpOK9CMCvYVinHbW CNkcrQC9IT1upFkyMPp2GE1c7Q== X-Received: by 2002:a05:600c:3542:b0:401:73b2:f039 with SMTP id i2-20020a05600c354200b0040173b2f039mr1228282wmq.7.1697704040501; Thu, 19 Oct 2023 01:27:20 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id o36-20020a05600c512400b00405959469afsm3842187wms.3.2023.10.19.01.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 01:27:19 -0700 (PDT) Date: Thu, 19 Oct 2023 10:27:13 +0200 From: Andrew Jones To: Anup Patel Cc: Paolo Bonzini , Atish Patra , Palmer Dabbelt , Paul Walmsley , Greg Kroah-Hartman , Jiri Slaby , Conor Dooley , 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 Subject: Re: [PATCH v2 6/8] tty/serial: Add RISC-V SBI debug console based earlycon Message-ID: <20231019-f3c3768f5e95e747e1457c49@orel> References: <20231012051509.738750-1-apatel@ventanamicro.com> <20231012051509.738750-7-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231012051509.738750-7-apatel@ventanamicro.com> 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 19 Oct 2023 01:27:58 -0700 (PDT) On Thu, Oct 12, 2023 at 10:45:07AM +0530, Anup Patel wrote: > 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 > Reviewed-by: Andrew Jones