From patchwork Thu Aug 5 07:41:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1513779 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: 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=05V8yWRM; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Z4vuXB8E; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GgLCH0xnyz9sWS for ; Thu, 5 Aug 2021 17:41:31 +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:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4ZTQMgu3utAu5X6++H2T9JAVTcPG1W2qI3krMeYBca0=; b=05V8yWRM0KO1j2 dxXCISWni4BQehrtDGxMaqJbv2ODHiJ45w9Jq3xAMX9nJqXSHzGi/V4hblNxYAVuUkTsMN1ilezhV 7dC37dN7n0YfbhupVvvTbBP5erBU77SINFkVoEn+kkZk0p+BdFqv6F4DpsXhX5Qg+m1r932LtXU7d vlyrRGx8VJC7jOfV9WFxsX6zl6azjLP4vi1/h9rAWqHG7IflXDB70gChvMf29oRiWEkFYro/1rqzA JPTEzuHO88iTpSNBb5St8XZOkOlehg+5woIPhP6koHSlPrrS1eXvTBfADHQfuZhiERfXdxBImuJl2 i5Y/ceQ5kvweYHj5u/3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBY0L-008RNe-Tl; Thu, 05 Aug 2021 07:41:25 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBY0H-008RM6-TU for opensbi@lists.infradead.org; Thu, 05 Aug 2021 07:41:23 +0000 Received: by mail-pj1-x1036.google.com with SMTP id m10-20020a17090a34cab0290176b52c60ddso7335582pjf.4 for ; Thu, 05 Aug 2021 00:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=SvYfOKa5y2fj26P3ZxLgpnGMUMRX9/+Q62/F1l9i4L8=; b=Z4vuXB8EqapcQhbz4I513tKmV/YxcDI2Ii8lLvSnyZ/E+YuGk2wbhj8FJKXWE398Yw 9VROB22nXvDZJsIGz9KQN4XS7FLygsg9GFC6K3QGQEsltn+7BGcXpdy2JzHghSgUk1Zu UyrSOw9Uj9QY10b4p59yjQXl4XfWdWAo01ZnXMoX+Tqs5zB+pgmmIi9s6idFRfMyq+lr B8cKK8UL5FuCtrMo601edbmKKbq8EG7HBpcRX5Z9bUzPkX2JmawNr92plyzR2m67gPlt INb4yuAvBdt21lkZD/+I+8iadi1fv8yDrh+TC3vvGWEifTFwBZx7a5VkggCqnz2+1oSA ca4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=SvYfOKa5y2fj26P3ZxLgpnGMUMRX9/+Q62/F1l9i4L8=; b=HCfdoTdYAXjmKZhlu47SE/BQUmfxE0XwGUUbyLgC32kfbxi28UX6lZugGPTdctgB+/ xVrVQRAPCdfU/rtdhmXzsZgZqVlkmNTSctdVdZV9St8PGe5REUa7aGgUTDV+SN8ImUz9 agQjfPyyKqx0KQtDwuqVaFqOnxRNlAubvh57I1geSGsg4ll4wLc5FRuQ9CqUBKR1cXIY F8ynSBMyb+l2KrU/ZeM8aC5dNh9PnbCltJIqI5FlTOVcIV1Ac/GKj/8ZChLeq2viOJDU eyXvUrBKhaOWmA/vV9KeebgPnZFpUBn66scXRoRbIXKyhMvMxWN2DnTWZ2trvRxTvL8j Ho5w== X-Gm-Message-State: AOAM53192Uvbc29IUK4pN/lAM4D/liaKLGNUoJV7QNETNDSQeUW4FrIn EY2A/WS0A6+5vKszW25iat9OTQy9aS0= X-Google-Smtp-Source: ABdhPJxrysUv1D25gDhA2+pwv+6959sl17FX/I2P+1XY9zW4y9VQ6ZK2hmGl7A2cwI+2Kpp2DTUMGA== X-Received: by 2002:a17:902:e847:b029:12c:b6e4:b74c with SMTP id t7-20020a170902e847b029012cb6e4b74cmr2772791plg.73.1628149280295; Thu, 05 Aug 2021 00:41:20 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i6sm5466480pfa.44.2021.08.05.00.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Aug 2021 00:41:19 -0700 (PDT) From: Bin Meng To: Anup Patel , opensbi@lists.infradead.org Subject: [PATCH] lib/utils: fdt: Change addr and size to uint64_t Date: Thu, 5 Aug 2021 15:41:13 +0800 Message-Id: <20210805074113.5626-1-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210805_004122_021450_ACE9BD33 X-CRM114-Status: GOOD ( 12.20 ) 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: The maximum address and size encoded in DT are 64-bit numbers, so we should use uint64_t for 'addr' and 'size' in fdt_get_node_addr_size(). Signed-off-by: Bin Meng --- include/sbi_utils/fdt/fdt_helper.h | 6 +++--- lib/utils/fdt/fdt_helper.c | 19 +++++++++ lib/utils/gpio/fdt_gpio_sifive.c | 4 +++- lib/utils/reset/fdt_reset_sifive_test.c | 2 +- platform/fpg [...] 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 [2607:f8b0:4864:20:0:0:0:1036 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [bmeng.cn[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 The maximum address and size encoded in DT are 64-bit numbers, so we should use uint64_t for 'addr' and 'size' in fdt_get_node_addr_size(). Signed-off-by: Bin Meng Reviewed-by: Anup Patel --- include/sbi_utils/fdt/fdt_helper.h | 6 +++--- lib/utils/fdt/fdt_helper.c | 19 +++++++++---------- lib/utils/gpio/fdt_gpio_sifive.c | 4 +++- lib/utils/reset/fdt_reset_sifive_test.c | 2 +- platform/fpga/openpiton/platform.c | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h index 55b9382..32aebb4 100644 --- a/include/sbi_utils/fdt/fdt_helper.h +++ b/include/sbi_utils/fdt/fdt_helper.h @@ -43,8 +43,8 @@ int fdt_parse_phandle_with_args(void *fdt, int nodeoff, const char *prop, const char *cells_prop, int index, struct fdt_phandle_args *out_args); -int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr, - unsigned long *size); +int fdt_get_node_addr_size(void *fdt, int node, uint64_t *addr, + uint64_t *size); int fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid); @@ -75,7 +75,7 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, unsigned long *out_addr, unsigned long *out_size, u32 *out_first_hartid, u32 *out_hart_count); -int fdt_parse_compat_addr(void *fdt, unsigned long *addr, +int fdt_parse_compat_addr(void *fdt, uint64_t *addr, const char *compatible); #endif /* __FDT_HELPER_H__ */ diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index a970c0f..a27f5ba 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -120,7 +120,7 @@ int fdt_parse_phandle_with_args(void *fdt, int nodeoff, } static int fdt_translate_address(void *fdt, uint64_t reg, int parent, - unsigned long *addr) + uint64_t *addr) { int i, rlen; int cell_addr, cell_size; @@ -157,8 +157,7 @@ static int fdt_translate_address(void *fdt, uint64_t reg, int parent, return 0; } -int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr, - unsigned long *size) +int fdt_get_node_addr_size(void *fdt, int node, uint64_t *addr, uint64_t *size) { int parent, len, i, rc; int cell_addr, cell_size; @@ -266,7 +265,7 @@ int fdt_parse_gaisler_uart_node(void *fdt, int nodeoffset, { int len, rc; const fdt32_t *val; - unsigned long reg_addr, reg_size; + uint64_t reg_addr, reg_size; if (nodeoffset < 0 || !uart || !fdt) return SBI_ENODEV; @@ -304,7 +303,7 @@ int fdt_parse_shakti_uart_node(void *fdt, int nodeoffset, { int len, rc; const fdt32_t *val; - unsigned long reg_addr, reg_size; + uint64_t reg_addr, reg_size; if (nodeoffset < 0 || !uart || !fdt) return SBI_ENODEV; @@ -338,7 +337,7 @@ int fdt_parse_sifive_uart_node(void *fdt, int nodeoffset, { int len, rc; const fdt32_t *val; - unsigned long reg_addr, reg_size; + uint64_t reg_addr, reg_size; if (nodeoffset < 0 || !uart || !fdt) return SBI_ENODEV; @@ -376,7 +375,7 @@ int fdt_parse_uart8250_node(void *fdt, int nodeoffset, { int len, rc; const fdt32_t *val; - unsigned long reg_addr, reg_size; + uint64_t reg_addr, reg_size; if (nodeoffset < 0 || !uart || !fdt) return SBI_ENODEV; @@ -436,7 +435,7 @@ int fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic) { int len, rc; const fdt32_t *val; - unsigned long reg_addr, reg_size; + uint64_t reg_addr, reg_size; if (nodeoffset < 0 || !plic || !fdt) return SBI_ENODEV; @@ -472,7 +471,7 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, u32 *out_first_hartid, u32 *out_hart_count) { const fdt32_t *val; - unsigned long reg_addr, reg_size; + uint64_t reg_addr, reg_size; int i, rc, count, cpu_offset, cpu_intc_offset; u32 phandle, hwirq, hartid, first_hartid, last_hartid; u32 match_hwirq = (for_timer) ? IRQ_M_TIMER : IRQ_M_SOFT; @@ -535,7 +534,7 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, return 0; } -int fdt_parse_compat_addr(void *fdt, unsigned long *addr, +int fdt_parse_compat_addr(void *fdt, uint64_t *addr, const char *compatible) { int nodeoffset, rc; diff --git a/lib/utils/gpio/fdt_gpio_sifive.c b/lib/utils/gpio/fdt_gpio_sifive.c index abc9d72..00d3e14 100644 --- a/lib/utils/gpio/fdt_gpio_sifive.c +++ b/lib/utils/gpio/fdt_gpio_sifive.c @@ -71,15 +71,17 @@ static int sifive_gpio_init(void *fdt, int nodeoff, u32 phandle, { int rc; struct sifive_gpio_chip *chip; + uint64_t addr; if (SIFIVE_GPIO_CHIP_MAX <= sifive_gpio_chip_count) return SBI_ENOSPC; chip = &sifive_gpio_chip_array[sifive_gpio_chip_count]; - rc = fdt_get_node_addr_size(fdt, nodeoff, &chip->addr, NULL); + rc = fdt_get_node_addr_size(fdt, nodeoff, &addr, NULL); if (rc) return rc; + chip->addr = addr; chip->chip.driver = &fdt_gpio_sifive; chip->chip.id = phandle; chip->chip.ngpio = SIFIVE_GPIO_PINS_DEF; diff --git a/lib/utils/reset/fdt_reset_sifive_test.c b/lib/utils/reset/fdt_reset_sifive_test.c index f98f03d..b0b59e7 100644 --- a/lib/utils/reset/fdt_reset_sifive_test.c +++ b/lib/utils/reset/fdt_reset_sifive_test.c @@ -16,7 +16,7 @@ static int sifive_test_reset_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; - unsigned long addr; + uint64_t addr; rc = fdt_get_node_addr_size(fdt, nodeoff, &addr, NULL); if (rc) diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 57ec21b..6939b57 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -64,7 +64,7 @@ static int openpiton_early_init(bool cold_boot) void *fdt; struct platform_uart_data uart_data; struct plic_data plic_data; - unsigned long clint_addr; + uint64_t clint_addr; int rc; if (!cold_boot)