Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp715793rdf; Tue, 21 Nov 2023 14:41:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeQra1h9hA+9BJk9tOJwtJwFrZwrT0+dewUCmks0mHWSMsqy9gKMptZ5y4SfOGEUTgz+2X X-Received: by 2002:a05:6a00:399d:b0:6cb:910a:c6fe with SMTP id fi29-20020a056a00399d00b006cb910ac6femr691228pfb.7.1700606497766; Tue, 21 Nov 2023 14:41:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700606497; cv=none; d=google.com; s=arc-20160816; b=tuKvVlb2JiS1dDttKCKExJvKkA/ih2r3tikzqJBjs/QTeNrfSKqI6onSeYBFy47aoX Qm/v1IynEQQo7XKTH1ciRsAr84R6ym75+YkNbVMtfNHK+anjJ2fTc1ymlHsQh/hlrQD3 CMmzBPmwwyv5suSDbVzigBtVpODvNRhqHC7QvNK8BBci//bj3ehQBNyEeu7M1vlLdIQx lucmfx9CcNzt1mGLkDdNwNcqSjeRK/UY0ppdRE375pHKdV84c+/vhEaN5bOfXaJx6V6T 80CDBxrpT/I4jjbifClz9jQfMh/v9rdHG5IlWseIqbbHAbQIClhL56NlQFGZhvGzqt3h YOVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=P6Y5P6vvizTkCcH4d/w5IMJ1P3rAQH0RFmdfD+hCzFk=; fh=dKdOWo3+MsSwCabFGsZM/yWJZ1dfU544XQuZhIwN0sQ=; b=eqWs5cuUjya0w5ZRgNq3veg6cS3fbZgyMrZtDuUgXsXJKn50QhJgbb5VbrhJ53yvJe 9ZVIgtZBTl30SnDVV6/NA4pj+I9X0YsQ0td0BGX+hqEmfzt1mFfNbjqdrnhkGMsEqEfI XjToBJR6mxCOvfqpU4Ts83vw3usAHDatxAFMIhSjCMz+GD54OuAGQImDT6lD4jMaRjn5 LEKjjWXJslVvCURK9XMMjpnfzvoDkZ2qX1342l9iICUFj1rFibyKNlV0OZb7/SbSbc0M r+/70lyNN3lVjVk0a8VBVJi3UHkZiUsI9gnPlW5NkbEb2uKBdyVpa773hCgFm6W0kz9S IuFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=SippKTRu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s3-20020a656443000000b005be3c09abebsi11291843pgv.225.2023.11.21.14.41.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 14:41:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=SippKTRu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9409C81668B9; Tue, 21 Nov 2023 14:41:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbjKUWld (ORCPT + 99 others); Tue, 21 Nov 2023 17:41:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbjKUWlc (ORCPT ); Tue, 21 Nov 2023 17:41:32 -0500 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6106E7 for ; Tue, 21 Nov 2023 14:41:28 -0800 (PST) Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-7a683bd610dso210724439f.1 for ; Tue, 21 Nov 2023 14:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1700606488; x=1701211288; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=P6Y5P6vvizTkCcH4d/w5IMJ1P3rAQH0RFmdfD+hCzFk=; b=SippKTRuhIN+Tm6Ut4P3RFBAAExms/ddv4eoR9OxmXCt/h7ClDFBpFqFz0wLphpMQr 5va03IrpKhS5jmjAWzObhba6k+AJcoIxy+X8SPt3LwZx+3eGzwqS8lBg8U4fFqvt0Jky WTLCgiJOXQnbD/9pFhV3rNIqjUe19MitqRtyg+pS3PvEps4QZbA8/FxGLyTx8jQ9vAfK oWXO6QAn7OuWdjrs3ZlagUTw+mnu8QYELLNOpuvHFguXSPUOUnV0df2XC7KnZSSAILPc UfVzanVQp53Jb6OcBOZ1NiBMb/oZ/hwUKgr0/UkhEDh1w4S/PugxU6AEb+lAPgI4ELbb tDkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700606488; x=1701211288; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P6Y5P6vvizTkCcH4d/w5IMJ1P3rAQH0RFmdfD+hCzFk=; b=MCGAqIQvteyVj3Wx/50XKkHzS75jh7QlwBefes2PcuJJg+AJcp+eN6RtiVefirQG33 rkCvp1WFPdRUCAxMagsKVf4dVoElWGbfODnMjPx1BWqF+EJGvXK9LyDwjdMLh6ZwpJMH wnRVZ+H2y6irhZNTG0LZ5PMozwrmF/Whs8BbjhkcCPU990mvrsqcaQyE33fiDM6mbyh4 xQS8Gn43bu68Mecmd3imXdIl3Ptke8IfwypSQwJ4IetI+we+sDxltxlGhVVeBCqXck9o y1PIDjCd6IMM8CFLsrQkB1l3xCs4HSBwwBXYvo/B33cWXU15PVzl9gymQF3n4e88G5zL dc9A== X-Gm-Message-State: AOJu0YzGTdlXffPWSiNXB9xbR0v20YlTpUPhpgM2RX60ryt5A+MUBZw7 ZhsYWDYaZgMnVerpNZNDjQcfHg== X-Received: by 2002:a6b:f719:0:b0:79f:d04d:ce5a with SMTP id k25-20020a6bf719000000b0079fd04dce5amr326806iog.2.1700606488169; Tue, 21 Nov 2023 14:41:28 -0800 (PST) Received: from ?IPV6:2605:a601:adae:4500:3d43:c8e2:1496:e620? ([2605:a601:adae:4500:3d43:c8e2:1496:e620]) by smtp.gmail.com with ESMTPSA id s7-20020a056602010700b007b34b374dd1sm509116iot.18.2023.11.21.14.41.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Nov 2023 14:41:27 -0800 (PST) Message-ID: <8c0f4eba-1923-4686-b07b-1f3b78b298e9@sifive.com> Date: Tue, 21 Nov 2023 16:41:26 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 3/5] tty/serial: Add RISC-V SBI debug console based earlycon Content-Language: en-US To: Anup Patel 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 References: <20231118033859.726692-1-apatel@ventanamicro.com> <20231118033859.726692-4-apatel@ventanamicro.com> From: Samuel Holland In-Reply-To: <20231118033859.726692-4-apatel@ventanamicro.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 14:41:36 -0800 (PST) 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/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);