From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C65E149C51 for ; Fri, 13 Jun 2025 13:29:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749821372; cv=none; b=Ap3qm6sB2UIqMLoPqQuFwsJZGrtRtGVpKGpYBa1qPLcU0JJpp2U0bfLn2Zl8KgVAPOWrd03w+7cCKTDXiaD2i8ObJUmAmFWcAthuvPhh8woSYxSWxJsi/0UjDaZ2ZAGWWce/UOO7qYYMp39FyOf1d4uHmcwMMqjsitoHXCBK+jY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749821372; c=relaxed/simple; bh=6lAJlnes6QqXwNak5p4WWw0SOJxyB3LYvEyInzKSXQY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IkZYdhHJDCrzCf/LTiULlLjEnIIJzNTeS1rd0OgQA6i09ro9gz53iVtx2RU3e1kV3lrJNRFpC7ibcWZLhTd6EaGuReVKmexzyjcLFzU4mKhcf8CXQpG0XD4LQqLgsKdCw+IiBH4JvnH9/JI31sjad3ScQAQfuCUmen+ldLI0nYY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=DhcdyrLh; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="DhcdyrLh" Date: Fri, 13 Jun 2025 15:29:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1749821365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qDFsYEgxo1GXhtFdQGrCC+9YCOStEBIAsgElrlaVhWs=; b=DhcdyrLhQdNsb4gZpeaIn1xkIfmF5quDJPQodcIzL76+o+IAvTDTXPpAkkddf/Jux25r7K mS6yCvB7i66zgNM6f4cH/+RM5qwf4C+zf0k82NBlcT9HK5BHm0bybQi+n23mJFsWP2pmOl 1zhMS9WQi2HAnHdbG2argozEOfKFqOo= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Andrew Jones To: Jesse Taube Cc: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, Atish Patra , Anup Patel , Palmer Dabbelt , =?utf-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , Himanshu Chauhan , Charlie Jenkins Subject: Re: [kvm-unit-tests PATCH 1/2] riscv: Allow SBI_CONSOLE with no uart in device tree Message-ID: <20250613-031a531dce64411cb0ba7774@orel> References: <20250612200747.683635-1-jesse@rivosinc.com> <20250613-68a39013932d854741a41c4c@orel> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT On Fri, Jun 13, 2025 at 05:11:19AM -0700, Jesse Taube wrote: > On Fri, Jun 13, 2025 at 12:53 AM Andrew Jones wrote: > > > > On Thu, Jun 12, 2025 at 01:07:47PM -0700, Jesse Taube wrote: > > > When CONFIG_SBI_CONSOLE is enabled and there is no uart defined in the > > > device tree kvm-unit-tests fails to start. > > > > > > Only check if uart exists in device tree if SBI_CONSOLE is false. > > > > > > Signed-off-by: Jesse Taube > > > --- > > > lib/riscv/io.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/lib/riscv/io.c b/lib/riscv/io.c > > > index fb40adb7..96a3c048 100644 > > > --- a/lib/riscv/io.c > > > +++ b/lib/riscv/io.c > > > @@ -104,6 +104,7 @@ static void uart0_init_acpi(void) > > > > > > void io_init(void) > > > { > > > +#ifndef CONFIG_SBI_CONSOLE > > > if (dt_available()) > > > uart0_init_fdt(); > > > else > > > @@ -114,6 +115,7 @@ void io_init(void) > > > "Found uart at %p, but early base is %p.\n", > > > uart0_base, UART_EARLY_BASE); > > > } > > > +#endif > > > > Doesn't this generate uart0_init_fdt/acpi defined but not used types of > > warnings? > > No, but it should have, I'll fix it. > > > We need to put everything unused under the #ifndef > > CONFIG_SBI_CONSOLE, just as uart0_read/write already are. Alternatively, > > we can keep everything out of the #ifndef and export. > > The problem is uart0_init_fdt panics if no compatible uart was found. Let's do #ifndef CONFIG_SBI_CONSOLE if (ret) { printf("%s: Compatible uart not found in the device tree, aborting...\n",__func__); abort(); } #else uart0_base = NULL; return; #endif And then in uart0_puts() do a assert(uart0_base); This rules out mapping a uart at physical address zero, but hopefully that's not a thing. If it ever does appear to be a thing, then we can just add a boolean to track whether the base address is valid or not. But we'll burn that bridge when we cross it later, if ever. Thanks, drew > > Thanks, > Jesse Taube > > void sbi_puts(const char *s); > > void uart0_puts(const char *s); > > > > then just have a single use of the #ifdef, > > > > void puts(const char *s) > > { > > #ifdef CONFIG_SBI_CONSOLE > > sbi_puts(s); > > #else > > uart0_puts(s); > > #endif > > } > > > > I think I like that better since it will ensure all code gets compile > > tested all the time and allow an SBI console using unit test to also > > access its uart if it has one, just because... > > > > Thanks, > > drew > > > > > > > } > > > > > > #ifdef CONFIG_SBI_CONSOLE > > > -- > > > 2.43.0 > > > > > > > > > -- > > > kvm-riscv mailing list > > > kvm-riscv@lists.infradead.org > > > http://lists.infradead.org/mailman/listinfo/kvm-riscv > > -- > kvm-riscv mailing list > kvm-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kvm-riscv