Ian Campbell
2013-Nov-22 16:24 UTC
[PATCH v2 06/15] xen: arm64: Map xgene PCI memory regions and interrupts to dom0.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- v2: This replaces "HACK: xen: arm: map PCI controller ranges region MMIOs to dom0." --- xen/arch/arm/platforms/xgene-storm.c | 76 ++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c index 8658996..f3cc51b 100644 --- a/xen/arch/arm/platforms/xgene-storm.c +++ b/xen/arch/arm/platforms/xgene-storm.c @@ -24,12 +24,87 @@ #include <xen/mm.h> #include <xen/vmap.h> #include <asm/platform.h> +#include <asm/gic.h> static uint32_t xgene_storm_quirks(void) { return PLATFORM_QUIRK_DOM0_MAPPING_11|PLATFORM_QUIRK_GIC_64K_STRIDE; } +static int map_one_mmio(struct domain *d, const char *what, + paddr_t start, paddr_t end) +{ + int ret; + + printk("Additional MMIO %"PRIpaddr"-%"PRIpaddr" (%s)\n", + start, end, what); + ret = map_mmio_regions(d, start, end, start); + if ( ret ) + printk("Failed to map %s @ %"PRIpaddr" to dom%d\n", + what, start, d->domain_id); + return ret; +} + +static int map_one_spi(struct domain *d, const char *what, + unsigned int spi, unsigned int type) +{ + struct dt_irq irq; + int ret; + + irq.type = type; + + irq.irq = spi + 32; /* SPIs start at IRQ 32 */ + + printk("Additional IRQ %u (%s)\n", irq.irq, what); + + ret = gic_route_irq_to_guest(d, &irq, what); + if ( ret ) + printk("Failed to route %s to dom%d\n", what, d->domain_id); + + return ret; +} + +static int xgene_storm_specific_mapping(struct domain *d) +{ + int ret; + + /* Map the PCIe bus resources */ + ret = map_one_mmio(d, "PCI MEM REGION", 0xe000000000UL, 0xe010000000UL); + if ( ret ) + goto err; + + ret = map_one_mmio(d, "PCI IO REGION", 0xe080000000UL, 0xe080010000UL); + if ( ret ) + goto err; + + ret = map_one_mmio(d, "PCI CFG REGION", 0xe0d0000000UL, 0xe0d0200000UL); + if ( ret ) + goto err; + ret = map_one_mmio(d, "PCI MSI REGION", 0xe010000000UL, 0xe010800000UL); + if ( ret ) + goto err; + + ret = map_one_spi(d, "PCI#INTA", 0xc2, DT_IRQ_TYPE_LEVEL_HIGH); + if ( ret ) + goto err; + + ret = map_one_spi(d, "PCI#INTB", 0xc3, DT_IRQ_TYPE_LEVEL_HIGH); + if ( ret ) + goto err; + + ret = map_one_spi(d, "PCI#INTC", 0xc4, DT_IRQ_TYPE_LEVEL_HIGH); + if ( ret ) + goto err; + + ret = map_one_spi(d, "PCI#INTD", 0xc5, DT_IRQ_TYPE_LEVEL_HIGH); + if ( ret ) + goto err; + + ret = 0; +err: + return ret; +} + static const char const *xgene_storm_dt_compat[] __initdata { @@ -40,6 +115,7 @@ static const char const *xgene_storm_dt_compat[] __initdata PLATFORM_START(xgene_storm, "APM X-GENE STORM") .compatible = xgene_storm_dt_compat, .quirks = xgene_storm_quirks, + .specific_mapping = xgene_storm_specific_mapping, .dom0_evtchn_ppi = 24, PLATFORM_END -- 1.7.10.4
George Dunlap
2013-Nov-22 16:50 UTC
Re: [PATCH v2 06/15] xen: arm64: Map xgene PCI memory regions and interrupts to dom0.
On Fri, Nov 22, 2013 at 4:24 PM, Ian Campbell <ian.campbell@citrix.com> wrote:> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>Release-acked-by: George Dunlap <george.dunlap@eu.citrix.com>> --- > v2: This replaces "HACK: xen: arm: map PCI controller ranges region MMIOs to > dom0." > --- > xen/arch/arm/platforms/xgene-storm.c | 76 ++++++++++++++++++++++++++++++++++ > 1 file changed, 76 insertions(+) > > diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c > index 8658996..f3cc51b 100644 > --- a/xen/arch/arm/platforms/xgene-storm.c > +++ b/xen/arch/arm/platforms/xgene-storm.c > @@ -24,12 +24,87 @@ > #include <xen/mm.h> > #include <xen/vmap.h> > #include <asm/platform.h> > +#include <asm/gic.h> > > static uint32_t xgene_storm_quirks(void) > { > return PLATFORM_QUIRK_DOM0_MAPPING_11|PLATFORM_QUIRK_GIC_64K_STRIDE; > } > > +static int map_one_mmio(struct domain *d, const char *what, > + paddr_t start, paddr_t end) > +{ > + int ret; > + > + printk("Additional MMIO %"PRIpaddr"-%"PRIpaddr" (%s)\n", > + start, end, what); > + ret = map_mmio_regions(d, start, end, start); > + if ( ret ) > + printk("Failed to map %s @ %"PRIpaddr" to dom%d\n", > + what, start, d->domain_id); > + return ret; > +} > + > +static int map_one_spi(struct domain *d, const char *what, > + unsigned int spi, unsigned int type) > +{ > + struct dt_irq irq; > + int ret; > + > + irq.type = type; > + > + irq.irq = spi + 32; /* SPIs start at IRQ 32 */ > + > + printk("Additional IRQ %u (%s)\n", irq.irq, what); > + > + ret = gic_route_irq_to_guest(d, &irq, what); > + if ( ret ) > + printk("Failed to route %s to dom%d\n", what, d->domain_id); > + > + return ret; > +} > + > +static int xgene_storm_specific_mapping(struct domain *d) > +{ > + int ret; > + > + /* Map the PCIe bus resources */ > + ret = map_one_mmio(d, "PCI MEM REGION", 0xe000000000UL, 0xe010000000UL); > + if ( ret ) > + goto err; > + > + ret = map_one_mmio(d, "PCI IO REGION", 0xe080000000UL, 0xe080010000UL); > + if ( ret ) > + goto err; > + > + ret = map_one_mmio(d, "PCI CFG REGION", 0xe0d0000000UL, 0xe0d0200000UL); > + if ( ret ) > + goto err; > + ret = map_one_mmio(d, "PCI MSI REGION", 0xe010000000UL, 0xe010800000UL); > + if ( ret ) > + goto err; > + > + ret = map_one_spi(d, "PCI#INTA", 0xc2, DT_IRQ_TYPE_LEVEL_HIGH); > + if ( ret ) > + goto err; > + > + ret = map_one_spi(d, "PCI#INTB", 0xc3, DT_IRQ_TYPE_LEVEL_HIGH); > + if ( ret ) > + goto err; > + > + ret = map_one_spi(d, "PCI#INTC", 0xc4, DT_IRQ_TYPE_LEVEL_HIGH); > + if ( ret ) > + goto err; > + > + ret = map_one_spi(d, "PCI#INTD", 0xc5, DT_IRQ_TYPE_LEVEL_HIGH); > + if ( ret ) > + goto err; > + > + ret = 0; > +err: > + return ret; > +} > + > > static const char const *xgene_storm_dt_compat[] __initdata > { > @@ -40,6 +115,7 @@ static const char const *xgene_storm_dt_compat[] __initdata > PLATFORM_START(xgene_storm, "APM X-GENE STORM") > .compatible = xgene_storm_dt_compat, > .quirks = xgene_storm_quirks, > + .specific_mapping = xgene_storm_specific_mapping, > .dom0_evtchn_ppi = 24, > PLATFORM_END > > -- > 1.7.10.4 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Julien Grall
2013-Nov-22 16:59 UTC
Re: [PATCH v2 06/15] xen: arm64: Map xgene PCI memory regions and interrupts to dom0.
Can you add a comment to specify that for the future we plan to support PCI for all platforms ? (ie this patch a kind of "WORKAROUND" for now) On 11/22/2013 04:24 PM, Ian Campbell wrote:> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > --- > v2: This replaces "HACK: xen: arm: map PCI controller ranges region MMIOs to > dom0." > --- > xen/arch/arm/platforms/xgene-storm.c | 76 ++++++++++++++++++++++++++++++++++ > 1 file changed, 76 insertions(+) > > diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c > index 8658996..f3cc51b 100644 > --- a/xen/arch/arm/platforms/xgene-storm.c > +++ b/xen/arch/arm/platforms/xgene-storm.c > @@ -24,12 +24,87 @@ > #include <xen/mm.h> > #include <xen/vmap.h> > #include <asm/platform.h> > +#include <asm/gic.h> > > static uint32_t xgene_storm_quirks(void) > { > return PLATFORM_QUIRK_DOM0_MAPPING_11|PLATFORM_QUIRK_GIC_64K_STRIDE; > } > > +static int map_one_mmio(struct domain *d, const char *what, > + paddr_t start, paddr_t end) > +{ > + int ret; > + > + printk("Additional MMIO %"PRIpaddr"-%"PRIpaddr" (%s)\n", > + start, end, what); > + ret = map_mmio_regions(d, start, end, start); > + if ( ret ) > + printk("Failed to map %s @ %"PRIpaddr" to dom%d\n", > + what, start, d->domain_id); > + return ret; > +} > + > +static int map_one_spi(struct domain *d, const char *what, > + unsigned int spi, unsigned int type) > +{ > + struct dt_irq irq; > + int ret; > + > + irq.type = type; > + > + irq.irq = spi + 32; /* SPIs start at IRQ 32 */ > + > + printk("Additional IRQ %u (%s)\n", irq.irq, what); > + > + ret = gic_route_irq_to_guest(d, &irq, what); > + if ( ret ) > + printk("Failed to route %s to dom%d\n", what, d->domain_id); > + > + return ret; > +} > + > +static int xgene_storm_specific_mapping(struct domain *d) > +{ > + int ret; > + > + /* Map the PCIe bus resources */ > + ret = map_one_mmio(d, "PCI MEM REGION", 0xe000000000UL, 0xe010000000UL); > + if ( ret ) > + goto err; > + > + ret = map_one_mmio(d, "PCI IO REGION", 0xe080000000UL, 0xe080010000UL); > + if ( ret ) > + goto err; > + > + ret = map_one_mmio(d, "PCI CFG REGION", 0xe0d0000000UL, 0xe0d0200000UL); > + if ( ret ) > + goto err; > + ret = map_one_mmio(d, "PCI MSI REGION", 0xe010000000UL, 0xe010800000UL); > + if ( ret ) > + goto err; > + > + ret = map_one_spi(d, "PCI#INTA", 0xc2, DT_IRQ_TYPE_LEVEL_HIGH); > + if ( ret ) > + goto err; > + > + ret = map_one_spi(d, "PCI#INTB", 0xc3, DT_IRQ_TYPE_LEVEL_HIGH); > + if ( ret ) > + goto err; > + > + ret = map_one_spi(d, "PCI#INTC", 0xc4, DT_IRQ_TYPE_LEVEL_HIGH); > + if ( ret ) > + goto err; > + > + ret = map_one_spi(d, "PCI#INTD", 0xc5, DT_IRQ_TYPE_LEVEL_HIGH); > + if ( ret ) > + goto err; > + > + ret = 0; > +err: > + return ret; > +} > + > > static const char const *xgene_storm_dt_compat[] __initdata > { > @@ -40,6 +115,7 @@ static const char const *xgene_storm_dt_compat[] __initdata > PLATFORM_START(xgene_storm, "APM X-GENE STORM") > .compatible = xgene_storm_dt_compat, > .quirks = xgene_storm_quirks, > + .specific_mapping = xgene_storm_specific_mapping, > .dom0_evtchn_ppi = 24, > PLATFORM_END > >-- Julien Grall
Ian Campbell
2013-Nov-22 17:13 UTC
Re: [PATCH v2 06/15] xen: arm64: Map xgene PCI memory regions and interrupts to dom0.
On Fri, 2013-11-22 at 16:59 +0000, Julien Grall wrote:> Can you add a comment to specify that for the future we plan to support > PCI for all platforms ? (ie this patch a kind of "WORKAROUND" for now)I had intended to and plain forgot. Here is the incremental patch I just merged into this one: diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c index 3846f86..1f506fe 100644 --- a/xen/arch/arm/platforms/xgene-storm.c +++ b/xen/arch/arm/platforms/xgene-storm.c @@ -60,6 +60,12 @@ static int map_one_spi(struct domain *d, const char *what, return ret; } +/* + * Xen does not currently support mapping MMIO regions and interrupt + * for bus child devices (referenced via the "ranges" and + * "interrupt-map" properties to domain 0). Instead for now map the + * necessary resources manually. + */ static int xgene_storm_specific_mapping(struct domain *d) { int ret; That OK?
Julien Grall
2013-Nov-22 17:17 UTC
Re: [PATCH v2 06/15] xen: arm64: Map xgene PCI memory regions and interrupts to dom0.
On 11/22/2013 05:13 PM, Ian Campbell wrote:> On Fri, 2013-11-22 at 16:59 +0000, Julien Grall wrote: >> Can you add a comment to specify that for the future we plan to support >> PCI for all platforms ? (ie this patch a kind of "WORKAROUND" for now) > > I had intended to and plain forgot. > > Here is the incremental patch I just merged into this one:With this incremental patch: Acked-by: Julien Grall <julien.grall@linaro.org>> diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c > index 3846f86..1f506fe 100644 > --- a/xen/arch/arm/platforms/xgene-storm.c > +++ b/xen/arch/arm/platforms/xgene-storm.c > @@ -60,6 +60,12 @@ static int map_one_spi(struct domain *d, const char *what, > return ret; > } > > +/* > + * Xen does not currently support mapping MMIO regions and interrupt > + * for bus child devices (referenced via the "ranges" and > + * "interrupt-map" properties to domain 0). Instead for now map the > + * necessary resources manually. > + */ > static int xgene_storm_specific_mapping(struct domain *d) > { > int ret; > > That OK? >-- Julien Grall