From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E13BEC072A2 for ; Fri, 17 Nov 2023 13:12:36 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=gTICN5LQ; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4SWy4M3htmz3dLS for ; Sat, 18 Nov 2023 00:12:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=gTICN5LQ; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=brainfault.org (client-ip=2607:f8b0:4864:20::535; helo=mail-pg1-x535.google.com; envelope-from=anup@brainfault.org; receiver=lists.ozlabs.org) Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4SWy3G6dkcz3dW3 for ; Sat, 18 Nov 2023 00:11:38 +1100 (AEDT) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5aa481d53e5so1472461a12.1 for ; Fri, 17 Nov 2023 05:11:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1700226694; x=1700831494; darn=lists.ozlabs.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=6E9rdo8qzUdOfFpLyb8P/NwaQhOJy8xXp5m1DZcVMbs=; b=gTICN5LQSMK1QL5gJ6mYPfCV6pi8cK1WcCkjEmXJbKA0kvZmB3JTjzzatJuxPsEdQk iuhNnaLIO8sgu5O0mE/mdpG2um6hrx5WApfLfs1OPq/d15M+Qiy8oGRvLsPokk3MwMax qNuO0iG3hXXuLPBgvqcptGGWgIQRR1q8Dqx/5u1ZjpJ5qvjMfCz1YUoHDq/4LG2VR3ka sUmIGM0bbFvAg64HF9jkUHGFlxVk4BG5wIaPTMCpvYIlePdV7fE6YYDZoTUUkNr8ZLfh QqZAXNAr6v2+Y+cXSUDByUapDdt+kFeVYBvTG3H9NQGmY2+guNXzSeT6uLiEEMLIZY8q 6+ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700226694; x=1700831494; 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=6E9rdo8qzUdOfFpLyb8P/NwaQhOJy8xXp5m1DZcVMbs=; b=J9nWNKI4c1aOupH1BGJUyqhnsS+ZpTPCZrnh8SpIxqE6iRJy8wIaBtMExHe1uyffVA jZRMYjHEh9ZJhoxO2c5bgVa0+kCPBKW7x8vbmhSfW18IYSeAKtaPLsfpJ+tBxU054zvq UHeKA9t79A5HYSj75bKUbAMFsVEPa5JUsjploLS1iNjRWydR/ZEPgaoDDJ0UrV4L7K/N BNAWoxrrK6NFN24odpv/9hammZqGeeRegoW2TpHT4rjOyvw6KWu5lo4dPxJ7TbyvgSL5 RFtgM+TyjUJmg7/PClL9hP6/DUn1TKpNwplJoboHObbTz+I3jLmudzJJ+AH+EsI6oyQL iw+Q== X-Gm-Message-State: AOJu0Yxz7vzlEbEOdJFUBrA43a9XTjIbWdiTGQ9v/yTFd/H+ahp5vOSh Q2S63PkCCzRxyv8EEujFkRm9H516dzNG42Z0/o1LMQ== X-Google-Smtp-Source: AGHT+IFgkLOaY0/DJgU/R9AI39sZ+6DPT8zwZKvyF4UaFzfmMFJIGvIF2iBAT0bJLBWK5QSv+GXZ5swJVYptGL1IhU4= X-Received: by 2002:a17:90a:974a:b0:281:3a4a:2e61 with SMTP id i10-20020a17090a974a00b002813a4a2e61mr14672875pjw.14.1700226694377; Fri, 17 Nov 2023 05:11:34 -0800 (PST) MIME-Version: 1.0 References: <20231020072140.900967-1-apatel@ventanamicro.com> <20231020072140.900967-9-apatel@ventanamicro.com> <2023102153-retread-narrow-54ee@gregkh> In-Reply-To: <2023102153-retread-narrow-54ee@gregkh> From: Anup Patel Date: Fri, 17 Nov 2023 18:41:23 +0530 Message-ID: Subject: Re: [PATCH v3 8/9] tty: Add SBI debug console support to HVC SBI driver To: Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , linux-serial@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Atish Patra , Atish Patra , linux-kernel@vger.kernel.org, Conor Dooley , Palmer Dabbelt , kvm-riscv@lists.infradead.org, Paul Walmsley , Paolo Bonzini , linux-riscv@lists.infradead.org, Jiri Slaby , Andrew Jones Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Sat, Oct 21, 2023 at 10:16=E2=80=AFPM Greg Kroah-Hartman wrote: > > On Fri, Oct 20, 2023 at 12:51:39PM +0530, Anup Patel wrote: > > From: Atish Patra > > > > RISC-V SBI specification supports advanced debug console > > support via SBI DBCN extension. > > > > Extend the HVC SBI driver to support it. > > > > Signed-off-by: Atish Patra > > Signed-off-by: Anup Patel > > --- > > drivers/tty/hvc/Kconfig | 2 +- > > drivers/tty/hvc/hvc_riscv_sbi.c | 82 ++++++++++++++++++++++++++++++--- > > 2 files changed, 76 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/tty/hvc/Kconfig b/drivers/tty/hvc/Kconfig > > index 4f9264d005c0..6e05c5c7bca1 100644 > > --- a/drivers/tty/hvc/Kconfig > > +++ b/drivers/tty/hvc/Kconfig > > @@ -108,7 +108,7 @@ config HVC_DCC_SERIALIZE_SMP > > > > config HVC_RISCV_SBI > > bool "RISC-V SBI console support" > > - depends on RISCV_SBI_V01 > > + depends on RISCV_SBI > > select HVC_DRIVER > > help > > This enables support for console output via RISC-V SBI calls, w= hich > > diff --git a/drivers/tty/hvc/hvc_riscv_sbi.c b/drivers/tty/hvc/hvc_risc= v_sbi.c > > index 31f53fa77e4a..56da1a4b5aca 100644 > > --- a/drivers/tty/hvc/hvc_riscv_sbi.c > > +++ b/drivers/tty/hvc/hvc_riscv_sbi.c > > @@ -39,21 +39,89 @@ static int hvc_sbi_tty_get(uint32_t vtermno, char *= buf, int count) > > return i; > > } > > > > -static const struct hv_ops hvc_sbi_ops =3D { > > +static const struct hv_ops hvc_sbi_v01_ops =3D { > > .get_chars =3D hvc_sbi_tty_get, > > .put_chars =3D hvc_sbi_tty_put, > > }; > > > > -static int __init hvc_sbi_init(void) > > +static int hvc_sbi_dbcn_tty_put(uint32_t vtermno, const char *buf, int= count) > > { > > - return PTR_ERR_OR_ZERO(hvc_alloc(0, 0, &hvc_sbi_ops, 16)); > > + phys_addr_t pa; > > + struct sbiret ret; > > + > > + if (is_vmalloc_addr(buf)) { > > + pa =3D page_to_phys(vmalloc_to_page(buf)) + offset_in_pag= e(buf); > > + if (PAGE_SIZE < (offset_in_page(buf) + count)) > > + count =3D PAGE_SIZE - offset_in_page(buf); > > + } else { > > + pa =3D __pa(buf); > > + } > > + > > + if (IS_ENABLED(CONFIG_32BIT)) > > + ret =3D sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRIT= E, > > + count, lower_32_bits(pa), upper_32_bits(p= a), > > + 0, 0, 0); > > + else > > + ret =3D sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRIT= E, > > + count, pa, 0, 0, 0, 0); > > Again, you need a helper function here to keep you from having to keep > this all in sync. Sure, I will update. > > > + if (ret.error) > > + return 0; > > + > > + return count; > > } > > -device_initcall(hvc_sbi_init); > > > > -static int __init hvc_sbi_console_init(void) > > +static int hvc_sbi_dbcn_tty_get(uint32_t vtermno, char *buf, int count= ) > > { > > - hvc_instantiate(0, 0, &hvc_sbi_ops); > > + phys_addr_t pa; > > + struct sbiret ret; > > + > > + if (is_vmalloc_addr(buf)) { > > + pa =3D page_to_phys(vmalloc_to_page(buf)) + offset_in_pag= e(buf); > > + if (PAGE_SIZE < (offset_in_page(buf) + count)) > > + count =3D PAGE_SIZE - offset_in_page(buf); > > + } else { > > + pa =3D __pa(buf); > > + } > > + > > + if (IS_ENABLED(CONFIG_32BIT)) > > + ret =3D sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_READ= , > > + count, lower_32_bits(pa), upper_32_bits(p= a), > > + 0, 0, 0); > > + else > > + ret =3D sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_READ= , > > + count, pa, 0, 0, 0, 0); > > And here too. Okay. > > thanks, > > greg k-h Regards, Anup