Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp717443rdf; Tue, 21 Nov 2023 14:46:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGuczqY2f2dFryuUsMTq0xonyu6WFGmx83Yk7Su4Tvo2eeP6IWTo3KqJGd8siRL3N3Nj55+ X-Received: by 2002:a05:6a00:8f:b0:68f:d35d:217e with SMTP id c15-20020a056a00008f00b0068fd35d217emr539352pfj.2.1700606768433; Tue, 21 Nov 2023 14:46:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700606768; cv=none; d=google.com; s=arc-20160816; b=Clv3i07M/vLRFsZnCo/QRkM6FCLiBFyfxV69nRx0vWXrNAaS0E9XHp/2nVr0PoFuZ5 5KRielEjKuAN3L21xgzxlZZFsJZzQmytvI1ClQ8bhctEogGBvGtHSsJ0birGz5Eh+X4G eikKe8lfG3VezkusFzobDv3T3h7LapySUU8P3kWhfAejEQYFBLHeY6SNXfQk33hFY+6v jFIzrCnSifWu2ffugYbIhkL4p2Fxi+CtEbD97iTPZAJ/di9RWDd+eiN43rFw4tYi62Y4 ZGg2qG5MBw2BEZ4Uztt5ZQa3SeF6dmXQD13pFfYE3gRYeCDEWgHBmGTqjypBbIbhhWew 8usA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=7iA+kWZUEVLsdUBXgt5tCOpWMD0Y1GKECDIJZh9fHq4=; fh=dKdOWo3+MsSwCabFGsZM/yWJZ1dfU544XQuZhIwN0sQ=; b=s+pyn5jSgvFIB5+JSAe6oc6dGlBW7CrAIJ+wFLUPSfLUC97MJGkoJ8UIuSInDWExEt KAQ87SHlRgykOnu3AaieBeFgnfY9+NGeiVvZsj93YcJPBlxwx65TnkfPMdk9kpIrH9wX IM69RanUSRmMBd11Du/Aas+rACUg4ihWCP3ZEi1RhzV29N4l5v0QHXC8l7QSILlwJ04E 5jlgOemUgtPUs67fEXali5KsakgGc9uAp0OWP6JFCWjzZGXPiQSYe/FWwzAAQEKi/kQZ sqxsq4j22pRtaJxtcaCRH6CB0iU4ycbbisB2AXpahAr5CEE2YC+3AHy0dGWASaOXiNJN tK/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=UZr8Dgb+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id h8-20020a63c008000000b005824bad8f83si11298687pgg.846.2023.11.21.14.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 14:46:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=UZr8Dgb+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CDA7B817297C; Tue, 21 Nov 2023 14:46:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbjKUWp7 (ORCPT + 99 others); Tue, 21 Nov 2023 17:45:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbjKUWp5 (ORCPT ); Tue, 21 Nov 2023 17:45:57 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F805DD for ; Tue, 21 Nov 2023 14:45:53 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7a66aa8ebb7so240603439f.3 for ; Tue, 21 Nov 2023 14:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1700606753; x=1701211553; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=7iA+kWZUEVLsdUBXgt5tCOpWMD0Y1GKECDIJZh9fHq4=; b=UZr8Dgb+BSFkZev0z0UBVkTSSjqphrlM04f0oWAyGm4QQbcZ1bMvz52iUmoRp1E/Xk ALT6YM6uBkYvNXIvPx0g+F8C3FXi973DOmH8bDp3mN8J4O/qOhQcSSQ/L00g4uLSz5kA yeXT+5AcL5bWNNvkngmtFA0SnxM3oylufc88V6Y+C3Hr8Ub+6kwiwnJCClwVaWuaULuD 24OwamcZA4RXeUcdZ/hXLBoyipb2PY/Fg5Of8iMUGNT1/sJ/HvzDB3xwMi9cSZk/ZRW+ I4gWhpNlQPVC5zrQYQSvXcNuAgUF+xC/1DsTnztrrqbkrBtdW70JGlqHx4L4y4EfHgxl iSrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700606753; x=1701211553; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7iA+kWZUEVLsdUBXgt5tCOpWMD0Y1GKECDIJZh9fHq4=; b=oNzgFSAdvqPtwTkCfuesDKrso0mzOoYvVpy7QNY2xznQvreO2CwZIsYvSahTpYKoJO qjU2kPCLRmGIKB7hm0dDczWQ80l/ZZjMONX2A56fqScU5FPJ0yMSWZrtJSseJcDT/2V6 ZngW6Zd65kX8qJ7VffV4sx9wltn3Ti22cOefS6XsluHdZOmNzZtcvFOmsJb/aJc+7D8J atbfVZSacK1visaLwft09Bg0DRRpdo00fn38iHGQppcDP6BSWXKcKoZmZXAGLkXRMmKM upy/ZUhlXQtXqnkeRDB2zCgm7JufoFCuYDf6RrXuZqy9Ur43r7AUnwS7xh4rQ8+AOVNI YDdw== X-Gm-Message-State: AOJu0YxduZRAcOLoPNLJm9FlPR2GVEjHMvT2/YL60VWEuDchUoClnIPR Nac0i93nVbtEzifAf/F4DpS3UQ== X-Received: by 2002:a6b:c812:0:b0:7a6:a089:572c with SMTP id y18-20020a6bc812000000b007a6a089572cmr316749iof.21.1700606752801; Tue, 21 Nov 2023 14:45:52 -0800 (PST) Received: from ?IPV6:2605:a601:adae:4500:3d43:c8e2:1496:e620? ([2605:a601:adae:4500:3d43:c8e2:1496:e620]) by smtp.gmail.com with ESMTPSA id p33-20020a056638192100b004664ef1a3c6sm1930255jal.155.2023.11.21.14.45.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Nov 2023 14:45:52 -0800 (PST) Message-ID: Date: Tue, 21 Nov 2023 16:45:51 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 2/5] RISC-V: Add SBI debug console helper routines Content-Language: en-US To: Anup Patel Cc: Conor Dooley , Andrew Jones , linux-riscv@lists.infradead.org, linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Greg Kroah-Hartman , Jiri Slaby References: <20231118033859.726692-1-apatel@ventanamicro.com> <20231118033859.726692-3-apatel@ventanamicro.com> From: Samuel Holland In-Reply-To: <20231118033859.726692-3-apatel@ventanamicro.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 14:46:05 -0800 (PST) Hi Anup, On 2023-11-17 9:38 PM, Anup Patel wrote: > Let us provide SBI debug console helper routines which can be > shared by serial/earlycon-riscv-sbi.c and hvc/hvc_riscv_sbi.c. > > Signed-off-by: Anup Patel > --- > arch/riscv/include/asm/sbi.h | 5 +++++ > arch/riscv/kernel/sbi.c | 43 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 48 insertions(+) > > diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h > index 66f3933c14f6..ee7aef5f6233 100644 > --- a/arch/riscv/include/asm/sbi.h > +++ b/arch/riscv/include/asm/sbi.h > @@ -334,6 +334,11 @@ static inline unsigned long sbi_mk_version(unsigned long major, > } > > int sbi_err_map_linux_errno(int err); > + > +extern bool sbi_debug_console_available; > +int sbi_debug_console_write(unsigned int num_bytes, phys_addr_t base_addr); > +int sbi_debug_console_read(unsigned int num_bytes, phys_addr_t base_addr); > + > #else /* CONFIG_RISCV_SBI */ > static inline int sbi_remote_fence_i(const struct cpumask *cpu_mask) { return -1; } > static inline void sbi_init(void) {} > diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c > index 5a62ed1da453..73a9c22c3945 100644 > --- a/arch/riscv/kernel/sbi.c > +++ b/arch/riscv/kernel/sbi.c > @@ -571,6 +571,44 @@ long sbi_get_mimpid(void) > } > EXPORT_SYMBOL_GPL(sbi_get_mimpid); > > +bool sbi_debug_console_available; > + > +int sbi_debug_console_write(unsigned int num_bytes, phys_addr_t base_addr) > +{ > + struct sbiret ret; > + > + if (!sbi_debug_console_available) > + return -EOPNOTSUPP; > + > + if (IS_ENABLED(CONFIG_32BIT)) > + ret = sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRITE, > + num_bytes, lower_32_bits(base_addr), > + upper_32_bits(base_addr), 0, 0, 0); > + else > + ret = sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRITE, > + num_bytes, base_addr, 0, 0, 0, 0); > + > + return ret.error ? sbi_err_map_linux_errno(ret.error) : ret.value; > +} > + > +int sbi_debug_console_read(unsigned int num_bytes, phys_addr_t base_addr) > +{ > + struct sbiret ret; > + > + if (!sbi_debug_console_available) > + return -EOPNOTSUPP; > + > + if (IS_ENABLED(CONFIG_32BIT)) > + ret = sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_READ, > + num_bytes, lower_32_bits(base_addr), > + upper_32_bits(base_addr), 0, 0, 0); > + else > + ret = sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_READ, > + num_bytes, base_addr, 0, 0, 0, 0); > + > + return ret.error ? sbi_err_map_linux_errno(ret.error) : ret.value; > +} Since every place that calls these functions will need to do the vmalloc lookup, would it make sense to do it here, and have these take a pointer instead? Regards, Samuel