Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp240363rdh; Thu, 23 Nov 2023 02:44:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGwlN2kCwTs6lpo3p1LZr2tYSUHoalmxgvxfpmiwvNMKrmd5Tc7j0HAdFDhOuSzADWY/ga X-Received: by 2002:a05:6808:bce:b0:3b8:3ec6:8a41 with SMTP id o14-20020a0568080bce00b003b83ec68a41mr5943875oik.45.1700736240557; Thu, 23 Nov 2023 02:44:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700736240; cv=none; d=google.com; s=arc-20160816; b=wbjipocfDdZg8BzX2ZL4E4YmbQdCs3BqbFnLq5w++esacDS36/WExMQyS2fCGIFe5G kQuEQg3CKYeFRquLFZ45Z9cm/RQa+GloBSF7+W76LaLmMd7b9d3lHo9QWZ7GFTUvtvIz NZLEcnPTLq1ixydEzupotTeByPlxv9NgdWPMJWMnkvQ+CO/UePipLUjYl3c43xVZi7ii yVXK6A4XeOVHN3EDEnJI2VBqVwYAWvH+TgusSmOzbn2EGni2/10/GMQYY7vuBjpffxnl 18oFdwB5f5sE8pLGtMJDRgNxhNfhEdFJkGOZLA4mWNnDe9SYbblS3HOw3ziiiGRwF9Uo D91Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6sXx1tqGc4gio/QqB9Zb7ckRSF4i2cZOS4lFJoNm/Vo=; fh=ngzbsfZABp8wAytSZ5qcoSZItaRjcQ4/GYMgy2aVdNE=; b=z+/YcM2AEHHIl8OD1wXeaPUqnaedUuaI7wBKUvqaNPSyrIqxEsDjvLD2l9z1xsNAUG VvtYUkBZTZnwirIVVe/R7PyXKR/GAtGelguiQHeDtjyJlI/w333SOcZ1NPMdCsOmTbLX QAY59qiYirn5YJ2RhdG9WlgUelPo4oqUt3JDJgKtPx1yJj01Z7/GnPCTpRYZTMaqkXGS 8N+4gpU+EiumTn/wbUVmic71dop7gTOYRKl1v50oUEJpH11aCD7zldYKwal4MnI04rH2 /hzZMxeUKIy+LwVkoG94bsDCYq62j+/09yauqpr8UXmE1pF+Q78VAlL7oZdEjHM9s/7f vO5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ciBEmrJg; 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 23-20020a630c57000000b005be1f24c815si1045972pgm.502.2023.11.23.02.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 02:44:00 -0800 (PST) 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=ciBEmrJg; 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 E814A8325FCE; Thu, 23 Nov 2023 02:43:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344742AbjKWKnh (ORCPT + 99 others); Thu, 23 Nov 2023 05:43:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjKWKnf (ORCPT ); Thu, 23 Nov 2023 05:43:35 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EBDB1BE for ; Thu, 23 Nov 2023 02:43:42 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5be30d543c4so513407a12.2 for ; Thu, 23 Nov 2023 02:43:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700736222; x=1701341022; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6sXx1tqGc4gio/QqB9Zb7ckRSF4i2cZOS4lFJoNm/Vo=; b=ciBEmrJg9nD8dBXHPjNsCi0nFqo5mPhOKfU9lqwTi+vXtkrFcNFH2oUUXjkgZ07Ewl oXT+q1Gwu6CfJvc/+nAwpWd48G9sQCEExhQf4YUQDGLiNqPydHWeQamOYIOUkFKc/ZJ0 AvkHPeeZT5ildW7jHYeU3CTZRpErLvqUxju4ajKZ5XutNPkq7uUODuPVM4kyQgRaLKU/ Cc4J1CWD0mHDByE5WrrqLx5kMPaYK5Qz+vOYcQYU1/YLSX+Ix6bAE201EkfHR4uR4CNx GpndpUd6Nw6q9a2c7GYNJ+jdfdxoJFRGYQCT1tl6TmNwpnIG4nxGEtckK9hxVs9m7Er+ IoqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700736222; x=1701341022; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6sXx1tqGc4gio/QqB9Zb7ckRSF4i2cZOS4lFJoNm/Vo=; b=YC10Xmw62Ol/yOqAUWr7Cx7peERpqiBczgDDQMcRhhwijKtiWTDqpaUGwpXkhReWeg np2n8v2cE/vTI52hmDXT/F0qtAurFdQOvm2Ifc9wK2dFlAVYEu+4Cera9CbNOmaj1uTZ 7/WxVcyAZBwaZFeQ2I+zrYBwo7b+MfmuqBIz6FrEJM+zogZ9uM69CrQe6ZgiM03QCxJH 6Oqbpl2GNb3SfnRC60hgnO/ZTOyQB0Bq3TZa8mU+acOxXwFqaJ1NHdt1UA8bYmBjOH4h aU0DANWHjqQZL9+jY7kW+3P2Qa7yGHVQ/A64Me/y07FVqX5cZwS7P8NvNhlaaeEx6Q9u ZSeg== X-Gm-Message-State: AOJu0Yx9tQu3mT1fUgfZEof8utunkhuCjl7GrgzqVt7hLvMKkACSuqU/ YLvkFMG+1F+VNGpCxVL6CxAdYZrX8SL3POzFULC3wA== X-Received: by 2002:a05:6a21:9982:b0:189:11e8:6237 with SMTP id ve2-20020a056a21998200b0018911e86237mr5725421pzb.51.1700736221598; Thu, 23 Nov 2023 02:43:41 -0800 (PST) MIME-Version: 1.0 References: <20231118033859.726692-1-apatel@ventanamicro.com> <20231118033859.726692-4-apatel@ventanamicro.com> <8c0f4eba-1923-4686-b07b-1f3b78b298e9@sifive.com> In-Reply-To: <8c0f4eba-1923-4686-b07b-1f3b78b298e9@sifive.com> From: Anup Patel Date: Thu, 23 Nov 2023 16:13:29 +0530 Message-ID: Subject: Re: [PATCH v4 3/5] tty/serial: Add RISC-V SBI debug console based earlycon To: Samuel Holland Cc: Conor Dooley , Andrew Jones , linux-riscv@lists.infradead.org, linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Greg Kroah-Hartman , Jiri Slaby Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 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, 23 Nov 2023 02:43:58 -0800 (PST) On Wed, Nov 22, 2023 at 4:11=E2=80=AFAM Samuel Holland 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 > > Reviewed-by: Andrew Jones > > --- > > 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/seri= al/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, unsign= ed 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 =3D 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() he= re. 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 =3D sbi_console_write; > > - return 0; > > + int ret =3D 0; > > + > > + if (sbi_debug_console_available) { > > + device->con->write =3D 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 =3D sbi_0_1_console_write; > > + else > > + ret =3D -ENODEV; > > + } > > + > > + return ret; > > } > > EARLYCON_DECLARE(sbi, early_sbi_setup); > Regards, Anup