[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC 13/22] xen/arm: gic-hip04: Use SZ_4K rather than PAGE_SIZE
Make clear that the GIC interface is 4K and not rely on PAGE_SIZE == 4K. Also drop the checks on the page alignment which is not really useful. If we want to check buggy device tree we would need to do more check such as on the size... Although having a buggy device tree is very unlikely as developper would have catch error when bring up their board with a baremetal OS. Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx> Cc: Zoltan Kiss <zoltan.kiss@xxxxxxxxxx> --- xen/arch/arm/gic-hip04.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/gic-hip04.c b/xen/arch/arm/gic-hip04.c index 637e8aa..1b457ec 100644 --- a/xen/arch/arm/gic-hip04.c +++ b/xen/arch/arm/gic-hip04.c @@ -91,6 +91,9 @@ static DEFINE_PER_CPU(u16, gic_cpu_id); #define HIP04_GICH_APR 0x70 #define HIP04_GICH_LR 0x80 +#define SHIFT_4K 12 +#define MASK_4K (~(SZ_4K - 1)) + static inline void writeb_gicd(uint8_t val, unsigned int offset) { writeb_relaxed(val, gicv2.map_dbase + offset); @@ -113,15 +116,15 @@ static inline uint32_t readl_gicd(unsigned int offset) static inline void writel_gicc(uint32_t val, unsigned int offset) { - unsigned int page = offset >> PAGE_SHIFT; - offset &= ~PAGE_MASK; + unsigned int page = offset >> SHIFT_4K; + offset &= ~MASK_4K; writel_relaxed(val, gicv2.map_cbase[page] + offset); } static inline uint32_t readl_gicc(unsigned int offset) { - unsigned int page = offset >> PAGE_SHIFT; - offset &= ~PAGE_MASK; + unsigned int page = offset >> SHIFT_4K; + offset &= ~MASK_4K; return readl_relaxed(gicv2.map_cbase[page] + offset); } @@ -472,10 +475,10 @@ static int hip04gicv_setup(struct domain *d) return ret; if ( !platform_has_quirk(PLATFORM_QUIRK_GIC_64K_STRIDE) ) - ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase + PAGE_SIZE), - 2, paddr_to_pfn(gicv2.vbase + PAGE_SIZE)); + ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase + SZ_4K), + 2, paddr_to_pfn(gicv2.vbase + SZ_4K)); else - ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase + PAGE_SIZE), + ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase + SZ_4K), 2, paddr_to_pfn(gicv2.vbase + SZ_64K)); return ret; @@ -732,21 +735,21 @@ static int __init hip04gic_init(void) (gicv2.hbase & ~PAGE_MASK) || (gicv2.vbase & ~PAGE_MASK) ) panic("GIC-HIP04 interfaces not page aligned"); - gicv2.map_dbase = ioremap_nocache(gicv2.dbase, PAGE_SIZE); + gicv2.map_dbase = ioremap_nocache(gicv2.dbase, SZ_4K); if ( !gicv2.map_dbase ) panic("GIC-HIP04: Failed to ioremap for GIC distributor\n"); - gicv2.map_cbase[0] = ioremap_nocache(gicv2.cbase, PAGE_SIZE); + gicv2.map_cbase[0] = ioremap_nocache(gicv2.cbase, SZ_4K); if ( platform_has_quirk(PLATFORM_QUIRK_GIC_64K_STRIDE) ) - gicv2.map_cbase[1] = ioremap_nocache(gicv2.cbase + SZ_64K, PAGE_SIZE); + gicv2.map_cbase[1] = ioremap_nocache(gicv2.cbase + SZ_64K, SZ_4K); else - gicv2.map_cbase[1] = ioremap_nocache(gicv2.cbase + PAGE_SIZE, PAGE_SIZE); + gicv2.map_cbase[1] = ioremap_nocache(gicv2.cbase + SZ_4K, SZ_4K); if ( !gicv2.map_cbase[0] || !gicv2.map_cbase[1] ) panic("GIC-HIP04: Failed to ioremap for GIC CPU interface\n"); - gicv2.map_hbase = ioremap_nocache(gicv2.hbase, PAGE_SIZE); + gicv2.map_hbase = ioremap_nocache(gicv2.hbase, SZ_4K); if ( !gicv2.map_hbase ) panic("GIC-HIP04: Failed to ioremap for GIC Virtual interface\n"); -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |