From patchwork Thu Jun 6 09:17:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1944518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=RC3T1GFn; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=TwWnV3Y4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VvzJQ2fVsz20Q5 for ; Thu, 6 Jun 2024 19:17:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wPqHEcslCdFair9/HYEoyGBBBl3sgHC9zmbEQM5n4R0=; b=RC3T1GFn9bCm9c J7DpHyydo2p6vXT7nCX+M9WRcfOl3cC3zlv8hph7khE3L3aiwBbIEdA/idC0fqXAuhny6ld98Mcqi gF+TjA9A3xS8druFPohjdN4Wy8TaKy4ySFK9O93xUK8bWZ8n6J5CfVWMbq5m/jJxsEtFmSd+mqyzP GP+2TdYVBYZYBqGEHOS4uEpjnNe2c1KelU/phAUgkcCANGcPzR1hZBMypDfKLvyGJHElFbMp8+pZZ x3UxYioZ0axParPIv2480/plnhZiZN3mBbVGCXv9gXJQXhAlTNfWJihET7D8MPp0MKoLBlG4scqkD z4k8+CzdJ22cMV/kAeiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sF9Fj-000000095Jh-2317; Thu, 06 Jun 2024 09:17:47 +0000 Received: from m16.mail.126.com ([220.197.31.7]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sF9Fe-000000095EP-2SBH for opensbi@lists.infradead.org; Thu, 06 Jun 2024 09:17:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=/SvNc wmaKEmYqi17GGITFsFMtVHHN7r/MTc2aWkxySs=; b=TwWnV3Y4FfXtC+dualyvj RTd+K+rtJGaD88Z4TszZ7apaU2s3Uh0oNFBfgKTrg6kpaFf5bvsUOBy9Ibx9JSiY DJYegOykNPAGM8Bb+o/XFZrfhmwyWi8zI/dIvVk2rXfuKG6YL3eIl5krayE/8Yw+ MJnEaSmIp7jzh25qUDIe+4= Received: from T490.lan (unknown [112.83.182.153]) by gzga-smtp-mta-g0-5 (Coremail) with SMTP id _____wDXX8KnfmFmYexZBA--.59331S5; Thu, 06 Jun 2024 17:17:31 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 3/4] lib: utils/serial: add domains_init for 8250 Date: Thu, 6 Jun 2024 17:17:15 +0800 Message-ID: <20240606091723.896477-4-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240606091723.896477-1-wxjstz@126.com> References: <20240606091723.896477-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDXX8KnfmFmYexZBA--.59331S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxCFy5CFy3Aw17AryUGry3urg_yoW5Gr4rpF yDKFsxJFWUtFyxu3Z3Jr4vqr1rW3Z7uw1UKFnFkrsF9a1DZrWxXFW5J34Yyw4jq3yqyF43 ZFykJrWDA3W8Wr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zEt8n5UUUUU= X-Originating-IP: [112.83.182.153] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiIQ71OmVLaJOfGAAAsy X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240606_021743_012442_DFAC941F X-CRM114-Status: GOOD ( 10.21 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 8250 needs to add memregion to root_domain. Move this part of operation to sbi_console_device.domains_init Signed-off-by: Xiang W --- include/sbi_utils/serial/uart8250.h | 1 + lib/utils/serial/uart8250.c | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [220.197.31.7 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz(at)126.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 8250 needs to add memregion to root_domain. Move this part of operation to sbi_console_device.domains_init Signed-off-by: Xiang W --- include/sbi_utils/serial/uart8250.h | 1 + lib/utils/serial/uart8250.c | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/sbi_utils/serial/uart8250.h b/include/sbi_utils/serial/uart8250.h index be9483a..0949b96 100644 --- a/include/sbi_utils/serial/uart8250.h +++ b/include/sbi_utils/serial/uart8250.h @@ -18,6 +18,7 @@ struct uart8250_device { u32 baudrate; u32 reg_shift; u32 reg_width; + u32 reg_offset; }; void uart8250_putc(struct uart8250_device *dev, char ch); diff --git a/lib/utils/serial/uart8250.c b/lib/utils/serial/uart8250.c index db35ec3..754548f 100644 --- a/lib/utils/serial/uart8250.c +++ b/lib/utils/serial/uart8250.c @@ -92,10 +92,21 @@ static int uart8250_console_getc(void) return uart8250_getc(&console_dev); } +static int uart8250_domains_init(void) +{ + unsigned long base = (unsigned long)console_dev.base + - console_dev.reg_offset; + + return sbi_domain_root_add_memrange(base, PAGE_SIZE, PAGE_SIZE, + (SBI_DOMAIN_MEMREGION_MMIO | + SBI_DOMAIN_MEMREGION_SHARED_SURW_MRW)); +} + static struct sbi_console_device uart8250_console = { .name = "uart8250", .console_putc = uart8250_console_putc, - .console_getc = uart8250_console_getc + .console_getc = uart8250_console_getc, + .domains_init = uart8250_domains_init }; int uart8250_init(struct uart8250_device * dev, unsigned long base, u32 in_freq, @@ -103,11 +114,12 @@ int uart8250_init(struct uart8250_device * dev, unsigned long base, u32 in_freq, { u16 bdiv = 0; - dev->base = (volatile char *)base + reg_offset; - dev->reg_shift = reg_shift; - dev->reg_width = reg_width; - dev->in_freq = in_freq; - dev->baudrate = baudrate; + dev->base = (volatile char *)base + reg_offset; + dev->reg_offset = reg_offset; + dev->reg_shift = reg_shift; + dev->reg_width = reg_width; + dev->in_freq = in_freq; + dev->baudrate = baudrate; if (baudrate) bdiv = (in_freq + 8 * baudrate) / (16 * baudrate); @@ -147,7 +159,5 @@ int uart8250_console_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg sbi_console_set_device(&uart8250_console); - return sbi_domain_root_add_memrange(base, PAGE_SIZE, PAGE_SIZE, - (SBI_DOMAIN_MEMREGION_MMIO | - SBI_DOMAIN_MEMREGION_SHARED_SURW_MRW)); + return 0; }