From: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
To: <xen-devel@lists.xenproject.org>
Cc: <sstabellini@kernel.org>, <stefano.stabellini@amd.com>,
<julien@xen.org>, <Volodymyr_Babchuk@epam.com>,
<bertrand.marquis@arm.com>,
Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Subject: [XEN v2 06/11] xen/arm: Introduce a wrapper for dt_device_get_address() to handle paddr_t
Date: Tue, 17 Jan 2023 17:43:53 +0000 [thread overview]
Message-ID: <20230117174358.15344-7-ayan.kumar.halder@amd.com> (raw)
In-Reply-To: <20230117174358.15344-1-ayan.kumar.halder@amd.com>
dt_device_get_address() can accept u64 only for address and size. The
various callers will use 'paddr_t' datatype for address and size.
'paddr_t' is currently defined as u64, but we may support u32 as well.
Thus, we need an appropriate wrapper which can handle this type
conversion.
The callers will now invoke dt_device_get_paddr(). This inturn invokes
dt_device_get_address() with u64 address/size. And then it typecasts
the u64 address/size to paddr_t address/size.
Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
---
Changes from -
v1 - 1. New patch introduced.
xen/arch/arm/domain_build.c | 5 +++--
xen/arch/arm/gic-v2.c | 11 ++++++-----
xen/arch/arm/gic-v3.c | 9 +++++----
xen/arch/arm/include/asm/device_tree.h | 19 +++++++++++++++++++
xen/arch/arm/platforms/exynos5.c | 7 ++++---
xen/arch/arm/platforms/sunxi.c | 3 ++-
xen/drivers/char/exynos4210-uart.c | 3 ++-
xen/drivers/char/ns16550.c | 3 ++-
xen/drivers/char/omap-uart.c | 3 ++-
xen/drivers/char/pl011.c | 3 ++-
xen/drivers/char/scif-uart.c | 3 ++-
xen/drivers/passthrough/arm/smmu.c | 3 ++-
12 files changed, 51 insertions(+), 21 deletions(-)
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index cf8ae37a14..21199b624b 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -7,6 +7,7 @@
#include <xen/domain_page.h>
#include <xen/sched.h>
#include <xen/sizes.h>
+#include <asm/device_tree.h>
#include <asm/irq.h>
#include <asm/regs.h>
#include <xen/errno.h>
@@ -1672,7 +1673,7 @@ static int __init find_memory_holes(const struct kernel_info *kinfo,
for ( i = 0; i < naddr; i++ )
{
- res = dt_device_get_address(np, i, &addr, &size);
+ res = dt_device_get_paddr(np, i, &addr, &size);
if ( res )
{
printk(XENLOG_ERR "Unable to retrieve address %u for %s\n",
@@ -2500,7 +2501,7 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev,
/* Give permission and map MMIOs */
for ( i = 0; i < naddr; i++ )
{
- res = dt_device_get_address(dev, i, &addr, &size);
+ res = dt_device_get_paddr(dev, i, &addr, &size);
if ( res )
{
printk(XENLOG_ERR "Unable to retrieve address %u for %s\n",
diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 5d4d298b86..5230c4ebaf 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -24,6 +24,7 @@
#include <xen/acpi.h>
#include <acpi/actables.h>
#include <asm/p2m.h>
+#include <asm/device_tree.h>
#include <asm/domain.h>
#include <asm/platform.h>
#include <asm/device.h>
@@ -993,7 +994,7 @@ static void gicv2_extension_dt_init(const struct dt_device_node *node)
continue;
/* Get register frame resource from DT. */
- if ( dt_device_get_address(v2m, 0, &addr, &size) )
+ if ( dt_device_get_paddr(v2m, 0, &addr, &size) )
panic("GICv2: Cannot find a valid v2m frame address\n");
/*
@@ -1018,19 +1019,19 @@ static void __init gicv2_dt_init(void)
paddr_t vsize;
const struct dt_device_node *node = gicv2_info.node;
- res = dt_device_get_address(node, 0, &dbase, NULL);
+ res = dt_device_get_paddr(node, 0, &dbase, NULL);
if ( res )
panic("GICv2: Cannot find a valid address for the distributor\n");
- res = dt_device_get_address(node, 1, &cbase, &csize);
+ res = dt_device_get_paddr(node, 1, &cbase, &csize);
if ( res )
panic("GICv2: Cannot find a valid address for the CPU\n");
- res = dt_device_get_address(node, 2, &hbase, NULL);
+ res = dt_device_get_paddr(node, 2, &hbase, NULL);
if ( res )
panic("GICv2: Cannot find a valid address for the hypervisor\n");
- res = dt_device_get_address(node, 3, &vbase, &vsize);
+ res = dt_device_get_paddr(node, 3, &vbase, &vsize);
if ( res )
panic("GICv2: Cannot find a valid address for the virtual CPU\n");
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 391dfa53d7..58d2eb0690 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -29,6 +29,7 @@
#include <asm/cpufeature.h>
#include <asm/device.h>
+#include <asm/device_tree.h>
#include <asm/gic.h>
#include <asm/gic_v3_defs.h>
#include <asm/gic_v3_its.h>
@@ -1377,7 +1378,7 @@ static void __init gicv3_dt_init(void)
int res, i;
const struct dt_device_node *node = gicv3_info.node;
- res = dt_device_get_address(node, 0, &dbase, NULL);
+ res = dt_device_get_paddr(node, 0, &dbase, NULL);
if ( res )
panic("GICv3: Cannot find a valid distributor address\n");
@@ -1395,7 +1396,7 @@ static void __init gicv3_dt_init(void)
{
paddr_t rdist_base, rdist_size;
- res = dt_device_get_address(node, 1 + i, &rdist_base, &rdist_size);
+ res = dt_device_get_paddr(node, 1 + i, &rdist_base, &rdist_size);
if ( res )
panic("GICv3: No rdist base found for region %d\n", i);
@@ -1417,10 +1418,10 @@ static void __init gicv3_dt_init(void)
* For GICv3 supporting GICv2, GICC and GICV base address will be
* provided.
*/
- res = dt_device_get_address(node, 1 + gicv3.rdist_count,
+ res = dt_device_get_paddr(node, 1 + gicv3.rdist_count,
&cbase, &csize);
if ( !res )
- dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
+ dt_device_get_paddr(node, 1 + gicv3.rdist_count + 2,
&vbase, &vsize);
}
diff --git a/xen/arch/arm/include/asm/device_tree.h b/xen/arch/arm/include/asm/device_tree.h
index 51e0f0ae20..7f58f1f278 100644
--- a/xen/arch/arm/include/asm/device_tree.h
+++ b/xen/arch/arm/include/asm/device_tree.h
@@ -11,6 +11,7 @@
#ifndef __ARCH_ARM_DEVICE_TREE__
#define __ARCH_ARM_DEVICE_TREE__
+#include <xen/device_tree.h>
#include <xen/libfdt/libfdt.h>
inline int fdt_get_mem_rsv_paddr(const void *fdt, int n,
@@ -29,6 +30,24 @@ inline int fdt_get_mem_rsv_paddr(const void *fdt, int n,
return ret;
}
+inline int dt_device_get_paddr(const struct dt_device_node *dev,
+ unsigned int index, paddr_t *addr,
+ paddr_t *size)
+{
+ u64 dt_addr, dt_size;
+ int ret;
+
+ ret = dt_device_get_address(dev, index, &dt_addr, &dt_size);
+
+ if ( addr )
+ *addr = dt_addr;
+
+ if ( size )
+ *size = dt_size;
+
+ return ret;
+}
+
#endif /* __ARCH_ARM_DEVICE_TREE__ */
/*
* Local variables:
diff --git a/xen/arch/arm/platforms/exynos5.c b/xen/arch/arm/platforms/exynos5.c
index f79fad9957..55b6ac1e7e 100644
--- a/xen/arch/arm/platforms/exynos5.c
+++ b/xen/arch/arm/platforms/exynos5.c
@@ -22,6 +22,7 @@
#include <xen/mm.h>
#include <xen/vmap.h>
#include <xen/delay.h>
+#include <asm/device_tree.h>
#include <asm/platforms/exynos5.h>
#include <asm/platform.h>
#include <asm/io.h>
@@ -52,7 +53,7 @@ static int exynos5_init_time(void)
return -ENXIO;
}
- rc = dt_device_get_address(node, 0, &mct_base_addr, &size);
+ rc = dt_device_get_paddr(node, 0, &mct_base_addr, &size);
if ( rc )
{
dprintk(XENLOG_ERR, "Error in \"samsung,exynos4210-mct\"\n");
@@ -125,7 +126,7 @@ static int __init exynos5_smp_init(void)
return -ENXIO;
}
- rc = dt_device_get_address(node, 0, &sysram_addr, &size);
+ rc = dt_device_get_paddr(node, 0, &sysram_addr, &size);
if ( rc )
{
dprintk(XENLOG_ERR, "Error in %s\n", compatible);
@@ -208,7 +209,7 @@ static int exynos5_get_pmu_baseandsize(paddr_t *power_base_addr, paddr_t *size)
return -ENXIO;
}
- rc = dt_device_get_address(node, 0, power_base_addr, size);
+ rc = dt_device_get_paddr(node, 0, power_base_addr, size);
if ( rc )
{
dprintk(XENLOG_ERR, "Error in \"samsung,exynos5XXX-pmu\"\n");
diff --git a/xen/arch/arm/platforms/sunxi.c b/xen/arch/arm/platforms/sunxi.c
index e8e4d88bef..ce47f97507 100644
--- a/xen/arch/arm/platforms/sunxi.c
+++ b/xen/arch/arm/platforms/sunxi.c
@@ -18,6 +18,7 @@
#include <xen/mm.h>
#include <xen/vmap.h>
+#include <asm/device_tree.h>
#include <asm/platform.h>
#include <asm/io.h>
@@ -50,7 +51,7 @@ static void __iomem *sunxi_map_watchdog(bool *new_wdt)
return NULL;
}
- ret = dt_device_get_address(node, 0, &wdt_start, &wdt_len);
+ ret = dt_device_get_paddr(node, 0, &wdt_start, &wdt_len);
if ( ret )
{
dprintk(XENLOG_ERR, "Cannot read watchdog register address\n");
diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
index 32cc8c78b5..6d2008c44f 100644
--- a/xen/drivers/char/exynos4210-uart.c
+++ b/xen/drivers/char/exynos4210-uart.c
@@ -24,6 +24,7 @@
#include <xen/irq.h>
#include <xen/mm.h>
#include <asm/device.h>
+#include <asm/device_tree.h>
#include <asm/exynos4210-uart.h>
#include <asm/io.h>
@@ -316,7 +317,7 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev,
uart->parity = PARITY_NONE;
uart->stop_bits = 1;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("exynos4210: Unable to retrieve the base"
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index 8ef895a2bb..7226f3c2f7 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -35,6 +35,7 @@
#include <asm/io.h>
#ifdef CONFIG_HAS_DEVICE_TREE
#include <asm/device.h>
+#include <asm/device_tree.h>
#endif
#ifdef CONFIG_X86
#include <asm/fixmap.h>
@@ -1757,7 +1758,7 @@ static int __init ns16550_uart_dt_init(struct dt_device_node *dev,
uart->parity = UART_PARITY_NONE;
uart->stop_bits = 1;
- res = dt_device_get_address(dev, 0, &uart->io_base, &uart->io_size);
+ res = dt_device_get_paddr(dev, 0, &uart->io_base, &uart->io_size);
if ( res )
return res;
diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
index 3b53e1909a..06200bc9f1 100644
--- a/xen/drivers/char/omap-uart.c
+++ b/xen/drivers/char/omap-uart.c
@@ -15,6 +15,7 @@
#include <xen/init.h>
#include <xen/irq.h>
#include <xen/device_tree.h>
+#include <asm/device_tree.h>
#include <asm/device.h>
#include <xen/errno.h>
#include <xen/mm.h>
@@ -344,7 +345,7 @@ static int __init omap_uart_init(struct dt_device_node *dev,
uart->parity = UART_PARITY_NONE;
uart->stop_bits = 1;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("omap-uart: Unable to retrieve the base"
diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 256ec11e3f..b4c1d9d592 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -26,6 +26,7 @@
#include <asm/device.h>
#include <xen/mm.h>
#include <xen/vmap.h>
+#include <asm/device_tree.h>
#include <asm/pl011-uart.h>
#include <asm/io.h>
@@ -265,7 +266,7 @@ static int __init pl011_dt_uart_init(struct dt_device_node *dev,
printk("WARNING: UART configuration is not supported\n");
}
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("pl011: Unable to retrieve the base"
diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
index b425881d06..af14388f70 100644
--- a/xen/drivers/char/scif-uart.c
+++ b/xen/drivers/char/scif-uart.c
@@ -26,6 +26,7 @@
#include <xen/mm.h>
#include <xen/delay.h>
#include <asm/device.h>
+#include <asm/device_tree.h>
#include <asm/scif-uart.h>
#include <asm/io.h>
@@ -318,7 +319,7 @@ static int __init scif_uart_init(struct dt_device_node *dev,
uart = &scif_com;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("scif-uart: Unable to retrieve the base"
diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
index 490d253d44..0c89cb644e 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -51,6 +51,7 @@
#include <xen/sizes.h>
#include <asm/atomic.h>
#include <asm/device.h>
+#include <asm/device_tree.h>
#include <asm/io.h>
#include <asm/iommu_fwspec.h>
#include <asm/platform.h>
@@ -101,7 +102,7 @@ static struct resource *platform_get_resource(struct platform_device *pdev,
switch (type) {
case IORESOURCE_MEM:
- ret = dt_device_get_address(pdev, num, &res.addr, &res.size);
+ ret = dt_device_get_paddr(pdev, num, &res.addr, &res.size);
return ((ret) ? NULL : &res);
--
2.17.1
next prev parent reply other threads:[~2023-01-17 17:45 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 17:43 [XEN v2 00/11] Add support for 32 bit physical address Ayan Kumar Halder
2023-01-17 17:43 ` [XEN v2 01/11] xen/ns16550: Remove unneeded truncation check in the DT init code Ayan Kumar Halder
2023-01-17 17:43 ` [XEN v2 02/11] xen/arm: Use the correct format specifier Ayan Kumar Halder
2023-01-19 22:54 ` Stefano Stabellini
2023-01-20 9:32 ` Julien Grall
2023-01-20 11:09 ` Ayan Kumar Halder
2023-01-20 14:40 ` Michal Orzel
2023-01-20 15:09 ` Julien Grall
2023-01-20 16:03 ` Michal Orzel
2023-01-20 17:49 ` Julien Grall
2023-01-20 18:08 ` Ayan Kumar Halder
2023-01-20 23:01 ` Stefano Stabellini
2023-01-21 10:24 ` Michal Orzel
2023-01-17 17:43 ` [XEN v2 03/11] xen/arm: domain_build: Replace use of paddr_t in find_domU_holes() Ayan Kumar Halder
2023-01-19 23:02 ` Stefano Stabellini
2023-01-20 9:48 ` Julien Grall
2023-01-20 9:52 ` Julien Grall
2023-01-17 17:43 ` [XEN v2 04/11] xen/arm: Typecast the DT values into paddr_t Ayan Kumar Halder
2023-01-19 23:20 ` Stefano Stabellini
2023-01-19 23:34 ` Stefano Stabellini
2023-01-20 10:16 ` Julien Grall
2023-01-31 10:51 ` Ayan Kumar Halder
2023-01-31 15:57 ` Julien Grall
2023-01-17 17:43 ` [XEN v2 05/11] xen/arm: Use paddr_t instead of u64 for address/size Ayan Kumar Halder
2023-01-18 8:40 ` Jan Beulich
2023-01-18 11:15 ` Ayan Kumar Halder
2023-01-18 13:14 ` Jan Beulich
2023-01-18 13:34 ` George Dunlap
2023-01-18 13:58 ` Jan Beulich
2023-01-18 14:45 ` George Dunlap
2023-01-19 23:24 ` Stefano Stabellini
2023-02-06 19:21 ` Ayan Kumar Halder
2023-02-07 9:03 ` Julien Grall
2023-02-07 10:59 ` Ayan Kumar Halder
2023-02-07 12:18 ` Julien Grall
2023-01-20 10:34 ` Julien Grall
2023-01-17 17:43 ` Ayan Kumar Halder [this message]
2023-01-19 23:35 ` [XEN v2 06/11] xen/arm: Introduce a wrapper for dt_device_get_address() to handle paddr_t Stefano Stabellini
2023-01-17 17:43 ` [XEN v2 07/11] xen/arm: smmu: Use writeq_relaxed_non_atomic() for writing to SMMU_CBn_TTBR0 Ayan Kumar Halder
2023-01-19 23:40 ` Stefano Stabellini
2023-01-17 17:43 ` [XEN v2 08/11] xen/arm: guest_walk: LPAE specific bits should be enclosed within "ifndef CONFIG_ARM_PA_32" Ayan Kumar Halder
2023-01-19 23:43 ` Stefano Stabellini
2023-01-20 10:39 ` Julien Grall
2023-01-17 17:43 ` [XEN v2 09/11] xen/arm: Introduce ARM_PA_32 to support 32 bit physical address Ayan Kumar Halder
2023-01-18 8:50 ` Jan Beulich
2023-01-18 11:57 ` Ayan Kumar Halder
2023-01-18 13:19 ` Jan Beulich
2023-01-19 23:48 ` Stefano Stabellini
2023-01-18 9:18 ` Julien Grall
2023-01-30 22:00 ` Julien Grall
2023-01-17 17:43 ` [XEN v2 10/11] xen/arm: Restrict zeroeth_table_offset for ARM_64 Ayan Kumar Halder
2023-01-20 0:19 ` Stefano Stabellini
2023-01-20 10:53 ` Julien Grall
2023-01-20 16:53 ` Stefano Stabellini
2023-01-17 17:43 ` [XEN v2 11/11] xen/arm: p2m: Enable support for 32bit IPA Ayan Kumar Halder
2023-01-20 0:05 ` Stefano Stabellini
2023-01-20 11:06 ` Julien Grall
2023-02-07 15:34 ` Ayan Kumar Halder
2023-02-09 11:45 ` Julien Grall
2023-02-10 15:39 ` Ayan Kumar Halder
2023-02-10 16:19 ` Julien Grall
2023-02-10 17:51 ` Ayan Kumar Halder
2023-02-10 17:58 ` Julien Grall
2023-01-18 10:12 ` [XEN v2 00/11] Add support for 32 bit physical address Michal Orzel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230117174358.15344-7-ayan.kumar.halder@amd.com \
--to=ayan.kumar.halder@amd.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=stefano.stabellini@amd.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.