Skip to content

Commit c98c182

Browse files
Qais YousefKAGA-KOKO
authored andcommitted
irqchip/mips-gic: Add device hierarchy domain
Now the root gic_irq_domain is split into device and IPI domains. This form provides a better representation of how the root domain is split into 2. One for devices and one for IPIs. Signed-off-by: Qais Yousef <qais.yousef@imgtec.com> Acked-by: Ralf Baechle <ralf@linux-mips.org> Cc: <jason@lakedaemon.net> Cc: <marc.zyngier@arm.com> Cc: <jiang.liu@linux.intel.com> Cc: <linux-mips@linux-mips.org> Cc: <lisa.parratt@imgtec.com> Cc: Qais Yousef <qsyousef@gmail.com> Link: http://lkml.kernel.org/r/1449580830-23652-14-git-send-email-qais.yousef@imgtec.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 2af70a9 commit c98c182

File tree

1 file changed

+83
-20
lines changed

1 file changed

+83
-20
lines changed

drivers/irqchip/irq-mips-gic.c

Lines changed: 83 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static void __iomem *gic_base;
4747
static struct gic_pcpu_mask pcpu_masks[NR_CPUS];
4848
static DEFINE_SPINLOCK(gic_lock);
4949
static struct irq_domain *gic_irq_domain;
50+
static struct irq_domain *gic_dev_domain;
5051
static struct irq_domain *gic_ipi_domain;
5152
static int gic_shared_intrs;
5253
static int gic_vpes;
@@ -793,25 +794,6 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
793794
return gic_shared_irq_domain_map(d, virq, hw, 0);
794795
}
795796

796-
static int gic_irq_domain_xlate(struct irq_domain *d, struct device_node *ctrlr,
797-
const u32 *intspec, unsigned int intsize,
798-
irq_hw_number_t *out_hwirq,
799-
unsigned int *out_type)
800-
{
801-
if (intsize != 3)
802-
return -EINVAL;
803-
804-
if (intspec[0] == GIC_SHARED)
805-
*out_hwirq = GIC_SHARED_TO_HWIRQ(intspec[1]);
806-
else if (intspec[0] == GIC_LOCAL)
807-
*out_hwirq = GIC_LOCAL_TO_HWIRQ(intspec[1]);
808-
else
809-
return -EINVAL;
810-
*out_type = intspec[2] & IRQ_TYPE_SENSE_MASK;
811-
812-
return 0;
813-
}
814-
815797
static int gic_irq_domain_alloc(struct irq_domain *d, unsigned int virq,
816798
unsigned int nr_irqs, void *arg)
817799
{
@@ -881,11 +863,86 @@ void gic_irq_domain_free(struct irq_domain *d, unsigned int virq,
881863
bitmap_set(ipi_resrv, base_hwirq, nr_irqs);
882864
}
883865

866+
int gic_irq_domain_match(struct irq_domain *d, struct device_node *node,
867+
enum irq_domain_bus_token bus_token)
868+
{
869+
/* this domain should'nt be accessed directly */
870+
return 0;
871+
}
872+
884873
static const struct irq_domain_ops gic_irq_domain_ops = {
885874
.map = gic_irq_domain_map,
886-
.xlate = gic_irq_domain_xlate,
887875
.alloc = gic_irq_domain_alloc,
888876
.free = gic_irq_domain_free,
877+
.match = gic_irq_domain_match,
878+
};
879+
880+
static int gic_dev_domain_xlate(struct irq_domain *d, struct device_node *ctrlr,
881+
const u32 *intspec, unsigned int intsize,
882+
irq_hw_number_t *out_hwirq,
883+
unsigned int *out_type)
884+
{
885+
if (intsize != 3)
886+
return -EINVAL;
887+
888+
if (intspec[0] == GIC_SHARED)
889+
*out_hwirq = GIC_SHARED_TO_HWIRQ(intspec[1]);
890+
else if (intspec[0] == GIC_LOCAL)
891+
*out_hwirq = GIC_LOCAL_TO_HWIRQ(intspec[1]);
892+
else
893+
return -EINVAL;
894+
*out_type = intspec[2] & IRQ_TYPE_SENSE_MASK;
895+
896+
return 0;
897+
}
898+
899+
static int gic_dev_domain_alloc(struct irq_domain *d, unsigned int virq,
900+
unsigned int nr_irqs, void *arg)
901+
{
902+
struct irq_fwspec *fwspec = arg;
903+
struct gic_irq_spec spec = {
904+
.type = GIC_DEVICE,
905+
.hwirq = fwspec->param[1],
906+
};
907+
int i, ret;
908+
bool is_shared = fwspec->param[0] == GIC_SHARED;
909+
910+
if (is_shared) {
911+
ret = irq_domain_alloc_irqs_parent(d, virq, nr_irqs, &spec);
912+
if (ret)
913+
return ret;
914+
}
915+
916+
for (i = 0; i < nr_irqs; i++) {
917+
irq_hw_number_t hwirq;
918+
919+
if (is_shared)
920+
hwirq = GIC_SHARED_TO_HWIRQ(spec.hwirq + i);
921+
else
922+
hwirq = GIC_LOCAL_TO_HWIRQ(spec.hwirq + i);
923+
924+
ret = irq_domain_set_hwirq_and_chip(d, virq + i,
925+
hwirq,
926+
&gic_level_irq_controller,
927+
NULL);
928+
if (ret)
929+
return ret;
930+
}
931+
932+
return 0;
933+
}
934+
935+
void gic_dev_domain_free(struct irq_domain *d, unsigned int virq,
936+
unsigned int nr_irqs)
937+
{
938+
/* no real allocation is done for dev irqs, so no need to free anything */
939+
return;
940+
}
941+
942+
static struct irq_domain_ops gic_dev_domain_ops = {
943+
.xlate = gic_dev_domain_xlate,
944+
.alloc = gic_dev_domain_alloc,
945+
.free = gic_dev_domain_free,
889946
};
890947

891948
static int gic_ipi_domain_xlate(struct irq_domain *d, struct device_node *ctrlr,
@@ -1026,6 +1083,12 @@ static void __init __gic_init(unsigned long gic_base_addr,
10261083
if (!gic_irq_domain)
10271084
panic("Failed to add GIC IRQ domain");
10281085

1086+
gic_dev_domain = irq_domain_add_hierarchy(gic_irq_domain, 0,
1087+
GIC_NUM_LOCAL_INTRS + gic_shared_intrs,
1088+
node, &gic_dev_domain_ops, NULL);
1089+
if (!gic_dev_domain)
1090+
panic("Failed to add GIC DEV domain");
1091+
10291092
gic_ipi_domain = irq_domain_add_hierarchy(gic_irq_domain,
10301093
IRQ_DOMAIN_FLAG_IPI_PER_CPU,
10311094
GIC_NUM_LOCAL_INTRS + gic_shared_intrs,

0 commit comments

Comments
 (0)