Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp284308rdg; Tue, 10 Oct 2023 10:06:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEg36NxZSNFp8DdXb6a/FdP1ee2giqsI/ha3qCoz1YFhjSrRhYymAGdTDpOLNbRYWBOMJsS X-Received: by 2002:a17:90b:1d04:b0:268:808:8e82 with SMTP id on4-20020a17090b1d0400b0026808088e82mr24609686pjb.1.1696957583880; Tue, 10 Oct 2023 10:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696957583; cv=none; d=google.com; s=arc-20160816; b=xo9THlbXk+1ISNRy63CdziHmRDQyuN8XGguyyvuI/u/YV5YwIK/pqV4zadAl7VL++q +c6Ng4XfAb6t5xX1R8Wpu7QUA4EjPlq162PwFuzegzQHgOYomCctIKFjQmyaKMN1UzYj /0FwSfW1WbqAFaN9SrNBDVGScgeyMgNuFQTsrJwi5amMYGo0mHOu+mU45CqJrteEftt/ vanpN4jaPW/vI6UXWCosbYzgyJeCD/qdvy8Ui/puK6SCKjF4MQd3hVk2VeZAjV9GL4f+ kNIYXaVy8Vkzkt278AMTItouFzhmr4DrZhL8XOc1P9iI5nYl69BWSvgAU08+E0fjmTu+ jNLA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XoCkBvDoaE+G9yGkJwlCtJkOL/TuRqipkz8zh1jvWHI=; fh=7GYORjoWw1oF4BCDuq40hd+MOEKRwzNqXwnZ/K2vS9Q=; b=zeIkka8pSSPQdRqrwzpR6F8qJeRgr/nsoNLMmlXQOVm/3Vlv74oaNgP1PMu2alT/Mc 7buui+XeyR2j7qLm688cq3OaqGB8EyZal1gG8Oy/BfZKYqWIFRQvX0xvC22GTnWwqDNn 8ut1l8Y3GA4e6oLJwb6GYux50B6Z91nr+aQUOLNFqUvwr74h6UxHhg1WtNDkfrS7tS85 gJYqTqcZiUAsBtkdMhI9Kho3KibziY+hmJP0VxkBkoEu7CTLqyaw5zLj6QPIS2IVl2wb ZqUxLv9sCgZYXrhkA0hEiaR9qTZjoNVm3So0FyJbRt2vfeNVA0QXylAb9UNuEk55cZLf YWFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=AA2jQLm6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id lb5-20020a17090b4a4500b00274cd892b39si13236521pjb.132.2023.10.10.10.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 10:06:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=AA2jQLm6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id AB06A83A9F9E; Tue, 10 Oct 2023 10:06:15 -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 S234007AbjJJRGA (ORCPT + 99 others); Tue, 10 Oct 2023 13:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234049AbjJJRFj (ORCPT ); Tue, 10 Oct 2023 13:05:39 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A3AF0 for ; Tue, 10 Oct 2023 10:05:36 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c60f1a2652so420805ad.0 for ; Tue, 10 Oct 2023 10:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696957535; x=1697562335; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XoCkBvDoaE+G9yGkJwlCtJkOL/TuRqipkz8zh1jvWHI=; b=AA2jQLm6/yeH/yYoMJAer6K2L8kTm74KVZ2ig382ezZ5hfVEIfthok6IseJqgZoOlh vWfEIhzBiGXl3yYiJcNbH4JvQrrLKeqB6xJgDDKho5pYjvnH2TbGu/Ou7ADp/My5B6bc 1/Ere0xGHWsk9TFKbg03APmOpAdYBrE2L29GhruQ9gyvWfjZ4tl6ipieikZobQb/6P4O UV4bGnn6r7nn7E3xlaEzqJfcK5dGEnbRDxiO4MCqZS5gEPECi7TMkILDhBlm3CVGIMMg KJxmn91UM4Ptg96wP7F6dyOMQDMA1pqTZFpTMYQxhPdyuPN7bLqOcHaOlG9PdDlPCHZp IG/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696957535; x=1697562335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XoCkBvDoaE+G9yGkJwlCtJkOL/TuRqipkz8zh1jvWHI=; b=duGSL78HTrK81Hm8zvFrKikpYdRSVCgfPPxgyP61l5qF4iiS437dqSfyFW+EPU9s5o aY5loioG1k9qczjXz66PENUSmazYuXtYwN38EoAsCWD09/6uhOg1HLrYoYOUlYlJhqwu 9TKUAipn26IQCuuehRe+wIa+kumcPONXRxrHD56nB1QnmKAMwGUS2g8x8BegDq2iNB5Z uQIvDhwKoH8UHBU9sut0/niqrVXyrDgetrfrG4tzCxjj4wxBfh/z6GymaheC5SJRMZ5r 6BK6CAeYeyi/xGAo/GBBYn534MQJKRJf/FzRH9aQmvxlLWSX8BSZrjYTVL4qxLWP3bkw 2YBw== X-Gm-Message-State: AOJu0Yz2di/2SQxIkwTTS+RunpZrO2OQD3SC0jhK6TfSh4rjYlKm+0ie xPEoU1wQ5pyVJzlXNg5hZrydsw== X-Received: by 2002:a17:902:d2ca:b0:1c3:76c4:7242 with SMTP id n10-20020a170902d2ca00b001c376c47242mr26123429plc.22.1696957535339; Tue, 10 Oct 2023 10:05:35 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id w19-20020a1709027b9300b001b89536974bsm11979868pll.202.2023.10.10.10.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 10:05:34 -0700 (PDT) From: Anup Patel To: 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, Anup Patel Subject: [PATCH 4/6] tty/serial: Add RISC-V SBI debug console based earlycon Date: Tue, 10 Oct 2023 22:35:01 +0530 Message-Id: <20231010170503.657189-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010170503.657189-1-apatel@ventanamicro.com> References: <20231010170503.657189-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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]); Tue, 10 Oct 2023 10:06:15 -0700 (PDT) X-Spam-Level: ** We extend the existing RISC-V SBI earlycon support to use the new RISC-V SBI debug console extension. Signed-off-by: Anup Patel --- drivers/tty/serial/Kconfig | 2 +- drivers/tty/serial/earlycon-riscv-sbi.c | 35 ++++++++++++++++++++++--- 2 files changed, 32 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..b1da34e8d8cd 100644 --- a/drivers/tty/serial/earlycon-riscv-sbi.c +++ b/drivers/tty/serial/earlycon-riscv-sbi.c @@ -10,22 +10,49 @@ #include #include +#ifdef CONFIG_RISCV_SBI_V01 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); } +#endif + +static void sbi_dbcn_console_write(struct console *con, + const char *s, unsigned int n) +{ + phys_addr_t pa = __pa(s); + + sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRITE, +#ifdef CONFIG_32BIT + n, pa, (u64)pa >> 32, +#else + n, pa, 0, +#endif + 0, 0, 0); +} 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_spec_version >= sbi_mk_version(2, 0)) && + (sbi_probe_extension(SBI_EXT_DBCN) > 0)) + device->con->write = sbi_dbcn_console_write; + else +#ifdef CONFIG_RISCV_SBI_V01 + device->con->write = sbi_0_1_console_write; +#else + ret = -ENODEV; +#endif + + return ret; } EARLYCON_DECLARE(sbi, early_sbi_setup); -- 2.34.1