Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp500568rdb; Fri, 17 Nov 2023 05:11:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKtPolMEKmB5CDh9Jqigl+64hy5TBUzBj4hFFoodRG2Sb2yyl00X7qhD+VU2cTLx+UrYqd X-Received: by 2002:a05:6808:699:b0:3a8:4e27:3af3 with SMTP id k25-20020a056808069900b003a84e273af3mr21198613oig.48.1700226710420; Fri, 17 Nov 2023 05:11:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700226710; cv=none; d=google.com; s=arc-20160816; b=IluLUqOHIBBGGc8pMwEdqRmh1FLfcYqqxJyJ7eUXrXNccVXefn/6hyJ3p/pmI4ZFr1 EMJX2iGzGAihfBMeXAJ/742gk4wPdz2LqgyvbocPsew3ox2QM6YYHWskdUrfTHdmoi3s 0MacOJEVrDqiAHu9b5zRdIxZv7rQ1a9PfqqnBaM0NGk1KYb6enuSoxi5fL/Viv8BdFoS YRmsZkVQIkEJfLeFSSnqL4shTOtGgMI96cTTfBAA5C786QD1wgSDEfA3UUXqdH0hmNTO yjA73NbQdjaJnvwcsRT3ifyn4TOpj46FlVMGMzoGIoFX/wyHc3MfEN/7IzwJjZ5BM6uH +r0g== 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=LKUefcBQ+EC714qLkuUiemu7uqNkdjRTt9mSK5vZdm4=; fh=D/tq91XXrpJ6i5f+vk0n/dU20ZnLOBY+HujV3+UQi+8=; b=Ebvt1qexRnJySbDYCANjbeO164p4zhym7wlKOoPiUlnhda9nOVaA9MyZhFk3FLznpc jGpWIIRpDXY2ol9nUzVS/QhN8DlQJRfaIqSeKfddg3j+AggyCdQbcVNJ2VV8VhvM8EX9 1DjPUFe7iLX3RqupUxApo61O+BkyPR4b6xCOVivBBb3I1o9qWLMUPLFuAv8covsWJQR7 kptLSbrkUhfeFLRcUw2uj5Tewo9uFK+UZ6BB91lXVf+ieYOg6XiiJVUdECOYCEH1szug ZvJYUTN82JorHf79ZatdrMAMu+Gs2T9+lciSdz2+gTr8RHivJiqWqy4yj8SVs9Lb+bOY H+jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=pEisnRAi; 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w65-20020a636244000000b005c1f196f7d8si1923626pgb.787.2023.11.17.05.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 05:11:50 -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=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=pEisnRAi; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CF5FF80B8E79; Fri, 17 Nov 2023 05:10:54 -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 S1345923AbjKQNKw (ORCPT + 99 others); Fri, 17 Nov 2023 08:10:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbjKQNKv (ORCPT ); Fri, 17 Nov 2023 08:10:51 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE138D55 for ; Fri, 17 Nov 2023 05:10:47 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6bb4abb8100so1811686b3a.2 for ; Fri, 17 Nov 2023 05:10:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1700226647; x=1700831447; 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=LKUefcBQ+EC714qLkuUiemu7uqNkdjRTt9mSK5vZdm4=; b=pEisnRAiQxKlwszHPUIFw9wYMNMvstfy3NgRZzltfBgQGbro872DcP/qLQzxIx11ra CE8xaMxdx8dAatc917mhZXeszwOhzWfgtqUvi8VnxIWZqYS8vFO3ojLM1/FarNqmz3s4 Tn1Atdeg3xpGqJVcHCYm6cEQEdXM0UdZRGFqj76OtfLFJQ+EXAkvKnh5CRD9yn9PMRcR sjTwetcfkl51/huIv2Khe46fMzfD1thAnnoGXmfUz6WMYXOAd4hYvQRhiciGWT3IeKq5 G3tbAwHZHpfP27JAEG3liyQLrB6LsrQmK8W1k4MT4boe6yxeQspkE+rz/LvoP8FwyjOm QsJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700226647; x=1700831447; 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=LKUefcBQ+EC714qLkuUiemu7uqNkdjRTt9mSK5vZdm4=; b=mbxo1vTKX5uRTwQ3R5Oz+zpWK2D8kw3iALRYHKOgmgU2pMykJZpctA5PWg3qpMY2EA L7Tq6Tl5M+XwOiUeRTCR6ZeeHz3NaymSzcUQbyRBXonQ1/waxcSZh5iZkgVt6hG4y1qg 9456N27fXkvuyQghhXzALX2CKvoWcPPpAJ/CuO+Ay2R/6Ug+kETqcRcFPBFBBNs00gnq reroBg/vzeuPlGXZbmU5D1X0RdDHM6B/oYoPc5fEZBuQZDSdCOJXucR7F20AT7c/WsVR +6yieZ0rvczPDlPTlnyNnYN4kgztJVFmnzugRJmk7VuJq7V2mmeccFZqLINmHzTAX5v+ rRZQ== X-Gm-Message-State: AOJu0YyIAZuWh4ZElUk/+GTnCsTtQcUe6DkhA95dLazH+C4DfUFLp8TE B40PoHYCyitFQ7YSSZTX7kyUuXhP7up4Uh6bHxYWTA== X-Received: by 2002:a05:6a20:3c91:b0:187:eb60:d6de with SMTP id b17-20020a056a203c9100b00187eb60d6demr3743444pzj.27.1700226647148; Fri, 17 Nov 2023 05:10:47 -0800 (PST) MIME-Version: 1.0 References: <20231020072140.900967-1-apatel@ventanamicro.com> <20231020072140.900967-8-apatel@ventanamicro.com> <2023102120-unleveled-composed-45a2@gregkh> In-Reply-To: <2023102120-unleveled-composed-45a2@gregkh> From: Anup Patel Date: Fri, 17 Nov 2023 18:40:35 +0530 Message-ID: Subject: Re: [PATCH v3 7/9] tty/serial: Add RISC-V SBI debug console based earlycon To: Greg Kroah-Hartman Cc: Anup Patel , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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]); Fri, 17 Nov 2023 05:10:54 -0800 (PST) On Sat, Oct 21, 2023 at 10:16=E2=80=AFPM Greg Kroah-Hartman wrote: > > 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/seri= al/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, 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) > > +{ > > + phys_addr_t pa =3D __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. On RV32 systems, the physical address can be 34bits wide hence the on RV32 we have to pass physical address as two parameters whereas on RV64 entier physical address can be passed as single parameter. > > 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? Yes, it is better to have a wrapper function to hide the differences of RV32 and RV64 systems. I will update. > > thanks, > > greg k-h > > -- > kvm-riscv mailing list > kvm-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kvm-riscv Regards, Anup