Message ID | 20231118033859.726692-4-apatel@ventanamicro.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp970352vqn; Fri, 17 Nov 2023 19:40:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtskwzyO3kC+QaXfpu8nUmkELhtcmqIoQT0VnfV37t/ozDap6tTwb/EEKBE/DwtYq9TFKb X-Received: by 2002:a05:6870:d28d:b0:1f4:dd99:b07 with SMTP id d13-20020a056870d28d00b001f4dd990b07mr1363093oae.49.1700278821970; Fri, 17 Nov 2023 19:40:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700278821; cv=none; d=google.com; s=arc-20160816; b=poHHsLys+aGvwSWxei43z4RXm4wn5vHoL3E6pEsk81XREi1I3jKgCaZgJlPMo/EdDo Hhf3Ud4Qjnt1Bzed6DyAgLJNEhCc5s+fq85i9sOtafqX92dcwLmU+KjQKptakRDpT5L6 k7RCTN5KpGrJWjp6ne1cR3t47cw1q4UZ6DK1P+2D4fSkF3o5pEWsqX4hnDFjmAkUxmEu L8AhE+taZgW2cak0vYvy7Tun4hNd3kdtTyp2zhegWzI66eaDhLV3gE/WpF2lSbYPiTbv ZHsLN1ezEMvNpJovJQH1//XywgFdnq2ACuS2bdNxLuUnNMICYxQhocrMP5sRmMXJ36T4 eVRg== 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=Ii/r8hzimL/XtavRWrcGkJgKEnLeFuQkfTAUm70Wb2A=; fh=sCaLDPmI3z3WfJgoG5Ri8nSrNxiyuF4F9Uj24RFqprM=; b=D0DQsQftXUgywm3uvTCh1d1gB3j1nuBLNCWBKpkz+HlNZzBuhcpJ/QTNO2S3NuwMRt ELERkSjebj+cVIajdQM4cddgxSdgkFMhq/esrOcIGSeVn15OfPkXKFmkCnCgFa/bj8or hgXD2cafKCWjIZxqBMMTsq5HDnmK5+nXi3ipPReGerQBySfy+5WPnUHI7Uflpc6l31y3 RhQfmOsAce8FpuvGsgj6Ol8jhzNmvJJlabm2SrJZG9SME4bpTp7Sn4t0ao586SQG30DX Q/sy+sZkhZgkNxL2N0cBdUyigdTpzzVBWPIFrpaTvAAlDHTWSro1BExNdLtDi7LaKLtz fkHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=L7tk3XsP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b187-20020a6334c4000000b005b96fdd43cdsi3227407pga.759.2023.11.17.19.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 19:40:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=L7tk3XsP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 182DE805AA09; Fri, 17 Nov 2023 19:40:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346451AbjKRDjz (ORCPT <rfc822;jaysivo@gmail.com> + 29 others); Fri, 17 Nov 2023 22:39:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346461AbjKRDjt (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 17 Nov 2023 22:39:49 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D79D51739 for <linux-kernel@vger.kernel.org>; Fri, 17 Nov 2023 19:39:42 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-28003daaaa6so2214176a91.0 for <linux-kernel@vger.kernel.org>; Fri, 17 Nov 2023 19:39:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700278782; x=1700883582; 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=Ii/r8hzimL/XtavRWrcGkJgKEnLeFuQkfTAUm70Wb2A=; b=L7tk3XsPAJfBJui+7mljsx5jHduoziR5VxXsq4WSWgLyVhrKSG2R6kpLmbGgZLDnNB wqftKeb/NTcH74tLHPrV09IVx1PWAzvf8VDD4/9eQxKPe5DTpT4gqczLHCpkIUIFsxhw dQIKqTmDJK5dWM+uzcmcdnD7gB2FBY3Qu5mYbVoniYAqV0/DYD6syD+9naE1EE7gzz+I ZnYSZy7HvptS1saW9ulyRYdjhZiw58NDKM/oDZxJ3U5/JQqgFWGJOwOuelcuS18t5qoT E92fLTMkKAwAc7mCF8/bsREFCPb0kYIWAzR3b6pkAChA4yr5Msvd9uzTuKf7R9qFPLAt DNcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700278782; x=1700883582; 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=Ii/r8hzimL/XtavRWrcGkJgKEnLeFuQkfTAUm70Wb2A=; b=gROLCU5wwnb/xsfPLOrFgln94KK9rwphHUWqVi+NP+doYHC4galIvO0XQUkZVOio5G qcMA4ssAtRGO4B4t5yNhiaFd7jnmZLGKfuGw4Sv08x5SGbn4Hv372bB5Pdoqp4NuolwF iFVBoVx0uhQtYxEQ7hAfplHyglp917YiJLKd1u13m7zHw3rIyJz5uY0UieCGyfjxAC4t dk9k1BK6duBmciEob4DgKQcjLS3hcOAQXrGtlw9oJGIFQ/ULoxvZgW6JAcPp3Q4Cc0n1 0GQwWKnzrXdhpkB9Ht3G41gAcAi/dqTkZtgJgEIEKlyXw+v0LIKgc/m955E6jkI1+jW+ PHvw== X-Gm-Message-State: AOJu0YyjUv+t8AiEdXZeEOoJjOxG9z6w6s7P4WwnFazULP8zbDinTrsu PNaxw0PHphUCyF4iki3sqDIbC+mE3PYq7J78ryg= X-Received: by 2002:a17:90b:38cb:b0:27d:1376:3ae1 with SMTP id nn11-20020a17090b38cb00b0027d13763ae1mr1378816pjb.0.1700278781572; Fri, 17 Nov 2023 19:39:41 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.80.108]) by smtp.gmail.com with ESMTPSA id cz8-20020a17090ad44800b00280fcbbe774sm2053823pjb.10.2023.11.17.19.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 19:39:41 -0800 (PST) From: Anup Patel <apatel@ventanamicro.com> To: Palmer Dabbelt <palmer@dabbelt.com>, Paul Walmsley <paul.walmsley@sifive.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org> Cc: Conor Dooley <conor@kernel.org>, Andrew Jones <ajones@ventanamicro.com>, linux-riscv@lists.infradead.org, linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Anup Patel <apatel@ventanamicro.com> Subject: [PATCH v4 3/5] tty/serial: Add RISC-V SBI debug console based earlycon Date: Sat, 18 Nov 2023 09:08:57 +0530 Message-Id: <20231118033859.726692-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231118033859.726692-1-apatel@ventanamicro.com> References: <20231118033859.726692-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 17 Nov 2023 19:40:16 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782871566273574816 X-GMAIL-MSGID: 1782871566273574816 |
Series |
RISC-V SBI debug console extension support
|
|
Commit Message
Anup Patel
Nov. 18, 2023, 3:38 a.m. UTC
We extend the existing RISC-V SBI earlycon support to use the new RISC-V SBI debug console extension. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> --- drivers/tty/serial/Kconfig | 2 +- drivers/tty/serial/earlycon-riscv-sbi.c | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-)
Comments
Hi Anup, On 2023-11-17 9:38 PM, 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 <apatel@ventanamicro.com> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > --- > drivers/tty/serial/Kconfig | 2 +- > drivers/tty/serial/earlycon-riscv-sbi.c | 24 ++++++++++++++++++++---- > 2 files changed, 21 insertions(+), 5 deletions(-) > > diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig > index 732c893c8d16..1f2594b8ab9d 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..5351e1e31f45 100644 > --- a/drivers/tty/serial/earlycon-riscv-sbi.c > +++ b/drivers/tty/serial/earlycon-riscv-sbi.c > @@ -15,17 +15,33 @@ 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) > +{ > + sbi_debug_console_write(n, __pa(s)); This only works for strings in the linear mapping or the kernel mapping (not vmalloc, which includes the stack). So I don't think we can use __pa() here. > +} > + > 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_debug_console_available) { > + device->con->write = sbi_dbcn_console_write; > + } else { > + if (IS_ENABLED(CONFIG_RISCV_SBI_V01)) "else if", no need for the extra block/indentation. Regards, Samuel > + device->con->write = sbi_0_1_console_write; > + else > + ret = -ENODEV; > + } > + > + return ret; > } > EARLYCON_DECLARE(sbi, early_sbi_setup);
On Wed, Nov 22, 2023 at 4:11 AM Samuel Holland <samuel.holland@sifive.com> wrote: > > Hi Anup, > > On 2023-11-17 9:38 PM, 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 <apatel@ventanamicro.com> > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > > --- > > drivers/tty/serial/Kconfig | 2 +- > > drivers/tty/serial/earlycon-riscv-sbi.c | 24 ++++++++++++++++++++---- > > 2 files changed, 21 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig > > index 732c893c8d16..1f2594b8ab9d 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..5351e1e31f45 100644 > > --- a/drivers/tty/serial/earlycon-riscv-sbi.c > > +++ b/drivers/tty/serial/earlycon-riscv-sbi.c > > @@ -15,17 +15,33 @@ 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) > > +{ > > + sbi_debug_console_write(n, __pa(s)); > > This only works for strings in the linear mapping or the kernel mapping (not > vmalloc, which includes the stack). So I don't think we can use __pa() here. In which case, we need extend sbi_debug_console_write() to do the va-to-pa conversion for both earlycon-riscv-sbi.c and hvc_riscv_sbi.c > > > +} > > + > > 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_debug_console_available) { > > + device->con->write = sbi_dbcn_console_write; > > + } else { > > + if (IS_ENABLED(CONFIG_RISCV_SBI_V01)) > > "else if", no need for the extra block/indentation. Okay, I will update. > > Regards, > Samuel > > > + device->con->write = sbi_0_1_console_write; > > + else > > + ret = -ENODEV; > > + } > > + > > + return ret; > > } > > EARLYCON_DECLARE(sbi, early_sbi_setup); > Regards, Anup
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 732c893c8d16..1f2594b8ab9d 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..5351e1e31f45 100644 --- a/drivers/tty/serial/earlycon-riscv-sbi.c +++ b/drivers/tty/serial/earlycon-riscv-sbi.c @@ -15,17 +15,33 @@ 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) +{ + sbi_debug_console_write(n, __pa(s)); +} + 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_debug_console_available) { + 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);