Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp902956rdb; Fri, 20 Oct 2023 02:56:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHdEJwVoyOAyVWaN/nTuMVpRxTmGk7+31nfwXJbRoIvIoWCys/IaYxlGaeCOMMrkjxR8y2 X-Received: by 2002:a17:90b:4b02:b0:27d:5964:4ee6 with SMTP id lx2-20020a17090b4b0200b0027d59644ee6mr1342193pjb.2.1697795772841; Fri, 20 Oct 2023 02:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697795772; cv=none; d=google.com; s=arc-20160816; b=ytWJlXLoeEpL6dkE/cRLUI3J+WNiC2vDzYygl1VdZlUj6pmeJCnIbVaGa3vZGyku7Q mK5oPFVvlhhMn0HYw+oEbpJ/ODXrHjz9C7GISUvKDffeXe4pHoidNXWH/Hso4nSJgM/h D8yU+7CuwiHnnyG10yndJ/lkwPvqxnucFGOKY329o/VUbaO4g+pDnNiLf3xnPdk/OlG5 Kf0dokQwd/W/Wckprt/kKEAlA1//qrJ+ReuLfZb5Lbvi3CsfdQUSBeZPVlE+BCXWSNGJ e/QHymfteSVsu9CWLDvlNkSYuW8Zs/8NW6oUefz/b2P1yxWD0t6A1flhU/9O+QVf9vVB bFdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=lzNAsgDlCymNlDro9lRINrWSpZTudubXUwErhlRG6cU=; fh=Npbsl4wZoEamx2UPYNP9T0etb7NL4VF2oqkICSKVdJE=; b=T0wfEWx3bGNWHV430J/6sqokfzvLzBlc8wYgVm2N7UPWi5R92XVNAubozyWqIAe2cV qKXBAM8oc66cWmrAl75WHcnWdEHbPihDT1LOgEX5mYRDYSpAP3hf6ZbbEM+GuCmkf0cr Y4kX2VoxmyYkeaXowp5JJiUXyah35BScxSuegQNGUt4fpx7dioInGdrHH42QAcvLFA5M hEvXb5vYuLxcXLJJncg33kbAH4z5J8CHOjJO8XyYI3v6D5//yLhc5/tx1pUfIdRU1xaV bqyM/+dTYBBA916pk6G/CQUGv4MZdRNpsgnJbkq4CS8fSaG7HsJl2Z+2yM1o3s5Xu6CS bh8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AUJJlKph; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id 33-20020a17090a09a400b002768cfbe6desi4156841pjo.112.2023.10.20.02.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:56:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AUJJlKph; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BFBED801B9E7; Fri, 20 Oct 2023 02:56:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376715AbjJTJz7 (ORCPT + 99 others); Fri, 20 Oct 2023 05:55:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376319AbjJTJz6 (ORCPT ); Fri, 20 Oct 2023 05:55:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B119DC2; Fri, 20 Oct 2023 02:55:56 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03568C433C8; Fri, 20 Oct 2023 09:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697795756; bh=Z8ZuvLU9qD1wAS9sgFRuBmjbVEM7Pn+nD5WWqHJs10M=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=AUJJlKphrqw/o7lmtSQ+IkqWYh8FwAzZh4+CvrE6unyvvs3EQGCT5g/YTWZTTcKpS 3tscwUlRHcVkD5AvTyY5/rX5LfoJ4dSlRuNzNO3PGkbwl6jQ4oCCI4BMm3kQftVhvH VRPKVmf5M4QDnnJy06buHR/ZKq3ZUNAgwoIYH9TChGSW/5l9TW3xXkHO11u0EzEANG whJs0N6uL5udv7BZ0zh3XaiaOAZdxqEhjlMtC3crlOzXstm4C74Nvh8ZHFR+MFI3RF 3aDRCXQCRFea8KycE+r5iHmcYlc1/TXKhp8QT+8YrKpLpIjoqIxrGcnmj1oGc6L3DW lAnCrZgHvoqZQ== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Anup Patel , Paolo Bonzini , Atish Patra , Palmer Dabbelt , Paul Walmsley , Greg Kroah-Hartman , Jiri Slaby Cc: 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, Atish Patra , Anup Patel Subject: Re: [PATCH v3 8/9] tty: Add SBI debug console support to HVC SBI driver In-Reply-To: <20231020072140.900967-9-apatel@ventanamicro.com> References: <20231020072140.900967-1-apatel@ventanamicro.com> <20231020072140.900967-9-apatel@ventanamicro.com> Date: Fri, 20 Oct 2023 11:55:53 +0200 Message-ID: <87mswdbot2.fsf@all.your.base.are.belong.to.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 02:56:10 -0700 (PDT) Anup Patel writes: > 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 >=20=20 > 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, which > diff --git a/drivers/tty/hvc/hvc_riscv_sbi.c b/drivers/tty/hvc/hvc_riscv_= 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 *bu= f, int count) > return i; > } >=20=20 > -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, > }; >=20=20 > -static int __init hvc_sbi_init(void) > +static int hvc_sbi_dbcn_tty_put(uint32_t vtermno, const char *buf, int c= ount) > { > - 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_page(buf); > + if (PAGE_SIZE < (offset_in_page(buf) + count)) > + count =3D PAGE_SIZE - offset_in_page(buf); Thanks for fixing the cross-page issue. Now you're cutting the buffer off. What about doing two SBI calls instead? (Dito on the get side) Bj=C3=B6rn