Commit cd9a8066 authored by Andre Przywara's avatar Andre Przywara Committed by Will Deacon
Browse files

FDT: use static phandles



The current implementation of fdt__alloc_phandle() suffers from being
implemented in a static inline function situated in a header file.
This will only create expected results within a single compilation
unit.
It seems a bit over the top to use a function to allocate phandles,
when at the end of the day a phandle is just a unique identifier.
To simplify things - especially with upcoming patches - we just
introduce an enum per architecture to hold all possible phandle sources
and use that instead of the dynamic allocation.

Acked-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent fc189e9c
#ifndef KVM__KVM_FDT_H
#define KVM__KVM_FDT_H
#include "arm-common/fdt-arch.h"
#endif /* KVM__KVM_FDT_H */
#ifndef KVM__KVM_FDT_H
#define KVM__KVM_FDT_H
#include "arm-common/fdt-arch.h"
#endif /* KVM__KVM_FDT_H */
......@@ -114,7 +114,6 @@ static int setup_fdt(struct kvm *kvm)
{
struct device_header *dev_hdr;
u8 staging_fdt[FDT_MAX_SIZE];
u32 gic_phandle = fdt__alloc_phandle();
u64 mem_reg_prop[] = {
cpu_to_fdt64(kvm->arch.memory_guest_start),
cpu_to_fdt64(kvm->ram_size),
......@@ -134,7 +133,7 @@ static int setup_fdt(struct kvm *kvm)
/* Header */
_FDT(fdt_begin_node(fdt, ""));
_FDT(fdt_property_cell(fdt, "interrupt-parent", gic_phandle));
_FDT(fdt_property_cell(fdt, "interrupt-parent", PHANDLE_GIC));
_FDT(fdt_property_string(fdt, "compatible", "linux,dummy-virt"));
_FDT(fdt_property_cell(fdt, "#address-cells", 0x2));
_FDT(fdt_property_cell(fdt, "#size-cells", 0x2));
......@@ -166,7 +165,7 @@ static int setup_fdt(struct kvm *kvm)
/* CPU and peripherals (interrupt controller, timers, etc) */
generate_cpu_nodes(fdt, kvm);
if (generate_cpu_peripheral_fdt_nodes)
generate_cpu_peripheral_fdt_nodes(fdt, kvm, gic_phandle);
generate_cpu_peripheral_fdt_nodes(fdt, kvm, PHANDLE_GIC);
/* Virtio MMIO devices */
dev_hdr = device__first_dev(DEVICE_BUS_MMIO);
......@@ -185,7 +184,7 @@ static int setup_fdt(struct kvm *kvm)
}
/* PCI host controller */
pci__generate_fdt_nodes(fdt, gic_phandle);
pci__generate_fdt_nodes(fdt, PHANDLE_GIC);
/* PSCI firmware */
_FDT(fdt_begin_node(fdt, "psci"));
......
#ifndef ARM__FDT_H
#define ARM__FDT_H
enum phandles {PHANDLE_RESERVED = 0, PHANDLE_GIC, PHANDLES_MAX};
#endif /* ARM__FDT_H */
......@@ -7,6 +7,8 @@
#include <linux/types.h>
#include "kvm/fdt-arch.h"
#define FDT_MAX_SIZE 0x10000
/* Those definitions are generic FDT values for specifying IRQ
......@@ -33,10 +35,4 @@ enum irq_type {
} \
} while (0)
static inline u32 fdt__alloc_phandle(void)
{
static u32 phandle = 0;
return ++phandle;
}
#endif /* KVM__FDT_H */
#ifndef KVM__KVM_FDT_H
#define KVM__KVM_FDT_H
enum phandles {PHANDLE_RESERVED = 0, PHANDLES_MAX};
#endif /* KVM__KVM_FDT_H */
#ifndef KVM__KVM_FDT_H
#define KVM__KVM_FDT_H
enum phandles {PHANDLE_RESERVED = 0, PHANDLE_XICP, PHANDLES_MAX};
#endif /* KVM__KVM_FDT_H */
......@@ -40,8 +40,6 @@
#define HUGETLBFS_PATH "/var/lib/hugetlbfs/global/pagesize-16MB/"
#define PHANDLE_XICP 0x00001111
static char kern_cmdline[2048];
struct kvm_ext kvm_req_ext[] = {
......
#ifndef X86__FDT_ARCH_H
#define X86__FDT_ARCH_H
enum phandles {PHANDLE_RESERVED = 0, PHANDLES_MAX};
#endif /* KVM__KVM_FDT_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment