Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp340147rda; Sat, 21 Oct 2023 09:46:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUuggQvIz79GLvsg/jwi25pVdMwfwVC0Bgtd0aMKnB7m86NpiUa+PAD1Xx6QZoOxjxUmHz X-Received: by 2002:a05:6a21:790a:b0:17a:284:97c4 with SMTP id bg10-20020a056a21790a00b0017a028497c4mr5076598pzc.61.1697906792101; Sat, 21 Oct 2023 09:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697906792; cv=none; d=google.com; s=arc-20160816; b=QaeOhOkX45YvzCQpiklR/Vin7SD5mze3vaM0Zdu3o+FVJPGl3y0JNKrWzq2f31yae9 MOc/B+9nznFwgJJaFn8beSal90SnQu2WAXj2ZEW17iRRlOJTvoofigJobvTmjOoSSkWV Hl9sBWW5k2Rb4oci0XL1OZnI/vlfvq3pF5oZcda6Y3VO6KKC0dohnfwUQkxcQhwaukIW FOJn8HrcidBO6lJyZZ9U/nB6j6HKc//ElnwpsWkER2+uUxa5BRtgjIioIy8jMfDwdD8z WbTdud92l60Xww9EZnXC06YjUy66BrCTkdPq6ziR9AK3zc8hCwxmWiaDbDcIElRl1cAi cbmg== 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=i3IJ+hiEi2iZ3OUPTbWgCLbSlt9uspI8QGMucLWjuaQ=; fh=NKFL920pUMQopkg1dKfCPq22lKBlLOlyPGUlM3IaF/I=; b=SUFLgtxS5NgUgyXz0bOhTFzGM3pF4aOzFEehjjkf5QJjL5LrLhBajT1guIe7knP+um BOAcfa7bcuZGmwrbhZbAxBiUsspaKoXyucvzIoesTVSycDI4LfeIBP+PNGkv1yps3l09 VRjRqTvKQl7tTVWXxQruDCKBPFNeXv46Y3ZYEEddT972ClpPYXIEzunT2PCRvE6Stbn7 ZnYKa5qnwAOkOigthZdwuMqFEc+llyqczeK16eTyb/jEvVA3WS6hdce86GSwpRRFydZh uxQF7FbSXgjxFF/SeOOce9fxH3gcQJnBVpBF/eiktW1/xGp8YZHa2ndoa5+RyZGbjWAS U4kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="EG2rxm/n"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t191-20020a6381c8000000b0057808b558cesi3699733pgd.124.2023.10.21.09.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Oct 2023 09:46:32 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b="EG2rxm/n"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E5BEF8043908; Sat, 21 Oct 2023 09:46:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229501AbjJUQqB (ORCPT + 99 others); Sat, 21 Oct 2023 12:46:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231721AbjJUQp6 (ORCPT ); Sat, 21 Oct 2023 12:45:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E65B0DD; Sat, 21 Oct 2023 09:45:46 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA210C433C8; Sat, 21 Oct 2023 16:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1697906746; bh=MN1/oJukE4EkbtjF4EsDiPa4e+4k6rhpReY9dOx0rVo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EG2rxm/nXn3ve2cTPaP/raeMGmB70IeM1Ut27WsvANxOpR+Veq+GgHzIg+//lxz4d 6uLoJ0ZsctjIObzV1It7g+tCxrCAJLp6lzF65mWR7jFRpoYEsMeABM1F4q5uU5Dvok W1RsvxDiwmItNWuJHnqnamJDE9ZshM/EFWVQyZ1g= Date: Sat, 21 Oct 2023 18:45:43 +0200 From: Greg Kroah-Hartman To: Anup Patel Cc: Paolo Bonzini , Atish Patra , Palmer Dabbelt , Paul Walmsley , Jiri Slaby , 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 Subject: Re: [PATCH v3 7/9] tty/serial: Add RISC-V SBI debug console based earlycon Message-ID: <2023102120-unleveled-composed-45a2@gregkh> References: <20231020072140.900967-1-apatel@ventanamicro.com> <20231020072140.900967-8-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231020072140.900967-8-apatel@ventanamicro.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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]); Sat, 21 Oct 2023 09:46:23 -0700 (PDT) On Fri, Oct 20, 2023 at 12:51:38PM +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 > Reviewed-by: Andrew Jones > --- > 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); This is still a bit hard to follow, and I guarantee it will be a pain to maintain over time, trying to keep both calls in sync, right? Why not fix up sbi_ecall() to get this correct instead? It should be handling phys_addr_t values, not forcing you to do odd bit masking every single time you call it, right? That would make things much easier overall, and this patch simpler, as well as the next one. Oh wait, sbi_ecall() is crazy, and just a pass-through, so that's not going to work, you need a wrapper function for this mess to do that bit twiddeling for you instead of forcing you to do it each time, I guess that's what you are trying to do here, but ick, is it correct? thanks, greg k-h