Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp240691rdh; Thu, 23 Nov 2023 02:44:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4J6biVyI0Jx7WNtYA778i17fWYeucVfjDGCcB2NvtdA+XT8JU4gJYR4ZUD2kGBSfCuXRP X-Received: by 2002:a05:6870:ad09:b0:1f9:5490:8f3f with SMTP id nt9-20020a056870ad0900b001f954908f3fmr7356752oab.7.1700736289801; Thu, 23 Nov 2023 02:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700736289; cv=none; d=google.com; s=arc-20160816; b=S9uVwsBNPPnZ/sDc48trscozW+cpZPNYANn+wFokqISVjFMUheicG0S69R6nzviMOw mOfg7fX/FYch+o8QXfHoRJKFqsmUeBOiegoftlUCxMH33NlhCBZrRsSDuA6HqzM2/nB8 RHhRDp+28mjtUQTpALlejn0gMhNtB9M4OyW7sX55SDkL+ryUnqNyXDZCTqi6tQeRMzt1 SmoQtdhqdqMPECJl5/C5Z9crjz5SlviqcVqIGRgtz5vSkmC/pT5iosYhw5R3nDMB4Nq5 94NrjkAnlKvir/FBBmhBcc+iBoL2OXbODYjcIQG1js+slEogU9U2H+WJ7s3u+GsvgxDY +fNA== 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=unmTJjjQSG4GhQBCjfHPKG9Uy9nrMwsNNaOqoSHqW9g=; fh=ngzbsfZABp8wAytSZ5qcoSZItaRjcQ4/GYMgy2aVdNE=; b=HkkGpZ+25WIgHFMHKj609DWEXjSPdbIODtMFXWOdC/IZaYE/1aku6VR9x4VF/b9Phb OJQw3JiajGQTGpqMHUq9KycEVjky6qLOwpnR4PlkIKqfCEawxxUG2bzQi9JqvzEuwD8a BKuMnLUFKAYQDYHMCtv4Su9MFPE35XokHWMDVbl0sm8IqZE+Y+sXT7WieYJByx5C27Hk /lTHKudlzw2sRPLQI6Hyt+ub7mw6wOzGyGbNVZR78EXn5M+2VikIrZtraYXw3G7lyiup RglSULKJ682icggAeiaBZSqUYqVSMQg7ZB4OTHDUgBUpJDmnp8KlvXJBRcBv+mHqIKTM m+/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=mJ39gpRB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id x28-20020aa79a5c000000b006cb66a1fa04si987853pfj.33.2023.11.23.02.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 02:44:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=mJ39gpRB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 262EE8325FD3; Thu, 23 Nov 2023 02:44:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344684AbjKWKoa (ORCPT + 99 others); Thu, 23 Nov 2023 05:44:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjKWKo2 (ORCPT ); Thu, 23 Nov 2023 05:44:28 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 762BB91 for ; Thu, 23 Nov 2023 02:44:34 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6be1bc5aa1cso748942b3a.3 for ; Thu, 23 Nov 2023 02:44:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700736274; x=1701341074; 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=unmTJjjQSG4GhQBCjfHPKG9Uy9nrMwsNNaOqoSHqW9g=; b=mJ39gpRBk5Yq7BZAGzR631TPLGbHXdfHcR6bMU7BYSHGM0l4IXFcovt3rBxdKvSsSJ bGyNntZwwR2ez3745mP1wG5mHTWsA3iBPPHmf54EINfqXbpz7TShRulh1hyp5M/EZGDj +ppkUzMfZgquNGq/my9UHNKtWxeXoXmxPmbDb6sATgRUnII8N6UiV5j9/oapVx8+rN11 P/MSYdbFfhMW0HULg4r3qrHSdDs/wxSYxdDcdQqldp+aODoV9cbEByG99RVKe9rjKPcA UtenG26kIdlyE7OeDbKfNJYpJjrVarjWaiu7q+HESSZVipY1fc19F2Ed/tX8h2VaH06R BUpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700736274; x=1701341074; 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=unmTJjjQSG4GhQBCjfHPKG9Uy9nrMwsNNaOqoSHqW9g=; b=YgkkU91xdRuM+YBqrN2r3VEcKXFJmErwjYL8fARvGI1Pd6LXgSMv0RT9igqumMT844 rbpTPBNt6JLmn8iiI6XBCo+wSjwgcLjZtQRqXfzdyD7NmmgNA11m5us8FB+4hg4t8tF0 BcxLOxjJEOIgLxrjeQYTdK2oOL9/g1H/0l9teL1VISYcR0P/pb7RvUjjtT92VKxRKUg2 PbVg401PR9WdKfnLspXhZdQlAPui/N6wLo0/tUDBMgWrHzHPbOjk0QBEFLELtwlvQ+rM L1ABPl0XDwtu1Ld+9IzgySV173Cr3yUqGHIAxW/2ggIIiGUzZZOACzvYSOhuHdrY5RWo svsA== X-Gm-Message-State: AOJu0YyQUfyra9vQrcQUN9//e6zZLYPfxrBR7udHobRPs3yKeD3blqjA TVK2E6aNtPyGeYihbIJDHViDeaou0sOUwcXii1Q3GA== X-Received: by 2002:a05:6a20:320f:b0:187:4487:c5e9 with SMTP id hl15-20020a056a20320f00b001874487c5e9mr4048871pzc.47.1700736273705; Thu, 23 Nov 2023 02:44:33 -0800 (PST) MIME-Version: 1.0 References: <20231118033859.726692-1-apatel@ventanamicro.com> <20231118033859.726692-3-apatel@ventanamicro.com> In-Reply-To: From: Anup Patel Date: Thu, 23 Nov 2023 16:14:21 +0530 Message-ID: Subject: Re: [PATCH v4 2/5] RISC-V: Add SBI debug console helper routines To: Samuel Holland 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 23 Nov 2023 02:44:47 -0800 (PST) On Wed, Nov 22, 2023 at 4:15=E2=80=AFAM Samuel Holland wrote: > > 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(unsigne= d 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_a= ddr); > > +int sbi_debug_console_read(unsigned int num_bytes, phys_addr_t base_ad= dr); > > + > > #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_a= ddr) > > +{ > > + struct sbiret ret; > > + > > + if (!sbi_debug_console_available) > > + return -EOPNOTSUPP; > > + > > + if (IS_ENABLED(CONFIG_32BIT)) > > + ret =3D sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRIT= E, > > + num_bytes, lower_32_bits(base_addr), > > + upper_32_bits(base_addr), 0, 0, 0); > > + else > > + ret =3D sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRIT= E, > > + 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_ad= dr) > > +{ > > + struct sbiret ret; > > + > > + if (!sbi_debug_console_available) > > + return -EOPNOTSUPP; > > + > > + if (IS_ENABLED(CONFIG_32BIT)) > > + ret =3D 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 =3D 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? Yes, that's better. I will update. Regards, Anup