|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2] xen/arm: vpci: remove PCI I/O ranges property value
Hi Rahul, On 15/02/2022 15:36, Rahul Singh wrote: PCI I/O space are not mapped to dom0 when PCI passthrough is enabled, also there is no vpci trap handler register for IO bar. Remove PCI I/O ranges property value from dom0 device tree node so that dom0 linux will not allocate I/O space for PCI devices if pci-passthrough is enabled. Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx> --- xen/arch/arm/domain_build.c | 29 +++++++++++++++ xen/common/device_tree.c | 69 +++++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 10 +++++ 3 files changed, 108 insertions(+) For future version, please add a changelog. This helps to figure out what changed more easily. diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 6931c022a2..7cfe64fe97 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -648,6 +648,31 @@ static void __init allocate_static_memory(struct domain *d, } #endif+/* The logic above is exactly the same as in handle_linux_pci_domain(). Can we create an helper that could be used by both functions? This would help to keep the logic synchronized.
If I am not mistaken, the file common/device_tree.c is so far only containing code to parse the host device-tree. But now... you are introducing code to write the domain device-tree. I understand this is because dt_match_bus() is internal. However, I would rather prefer if we export dt_match_bus() & co and move this code to under arch/arm/pci/. Maybe we should introduce a file domain_build.c. Furthermore, the name of the function doesn't really match what the function does. It will generate "ranges" for the hostbridge and remove the I/O. We may want to perform other modifications on the range. So I would name the function something like: domain_build_generate_hostbridge_range() + const struct dt_device_node *parent = NULL; + const struct dt_bus *bus, *pbus; + unsigned int rlen; + int na, ns, pna, pns, rone; + const __be32 *ranges; + __be32 regs[((GUEST_ROOT_ADDRESS_CELLS * 2) + GUEST_ROOT_SIZE_CELLS + 1) GUEST_ROOT_*_CELLS are only valid for domU. In theory, there are no guarantee this will be bigger that what the host device-tree supports. So you want to use DT_MAX_ADDR_CELLS here. Looking at the code below. I couldn't find any check guaranteing the static array will be big enough to store the ranges provided by the host DT.+ * 2]; Most of the code in this function is the same as dt_for_each_range(). Can we refactor it to avoid code duplication? + unsigned int flags = bus->get_flags(ranges); + if ( flags & IORESOURCE_IO ) + continue; + + memcpy(addr, ranges, 4 * rone); + + addr += rone; + } + + return fdt_property(fdt, "ranges", regs, sizeof(regs)); +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index fd6cd00b43..580231f872 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -849,6 +849,16 @@ int dt_count_phandle_with_args(const struct dt_device_node *np, */ int dt_get_pci_domain_nr(struct dt_device_node *node);+/**+ * dt_pci_remove_io_range - Remove the PCI I/O range property value. + * @fdt: Pointer to the file descriptor tree. + * @node: Device tree node. + * + * This function will remove the PCI IO range property from the PCI device tree + * node. + */ +int dt_pci_remove_io_ranges(void *fdt, const struct dt_device_node *node); + struct dt_device_node *dt_find_node_by_phandle(dt_phandle handle);#ifdef CONFIG_DEVICE_TREE_DEBUG Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |