diff options
author | Tomasz Nowicki <tn@semihalf.com> | 2016-09-12 14:32:23 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2016-09-12 15:32:41 -0400 |
commit | d14ae5e6bac36e88cd5deeee411104da424bc73d (patch) | |
tree | 492c771b7ad5b480ce6371b47501b0eddc863205 | |
parent | be2021baeed64d8947a56529fc383308918ecc41 (diff) |
irqchip/gicv3-its: Cleanup for ITS domain initialization
There is no point to initialize ITS without having msi-controller
property in corresponding DT node. However, its_probe is checking
msi-controller presence at the end, so we can save our time and do that
check prior to its_probe call. Also, for the code clarity purpose,
we put domain initialization to separate function.
Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r-- | drivers/irqchip/irq-gic-v3-its.c | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 36b9c28a5c91..943442d689d8 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
@@ -1614,13 +1614,37 @@ static void its_enable_quirks(struct its_node *its) | |||
1614 | gic_enable_quirks(iidr, its_quirks, its); | 1614 | gic_enable_quirks(iidr, its_quirks, its); |
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | static int its_init_domain(struct device_node *node, struct its_node *its, | ||
1618 | struct irq_domain *parent) | ||
1619 | { | ||
1620 | struct irq_domain *inner_domain; | ||
1621 | struct msi_domain_info *info; | ||
1622 | |||
1623 | info = kzalloc(sizeof(*info), GFP_KERNEL); | ||
1624 | if (!info) | ||
1625 | return -ENOMEM; | ||
1626 | |||
1627 | inner_domain = irq_domain_add_tree(node, &its_domain_ops, its); | ||
1628 | if (!inner_domain) { | ||
1629 | kfree(info); | ||
1630 | return -ENOMEM; | ||
1631 | } | ||
1632 | |||
1633 | inner_domain->parent = parent; | ||
1634 | inner_domain->bus_token = DOMAIN_BUS_NEXUS; | ||
1635 | info->ops = &its_msi_domain_ops; | ||
1636 | info->data = its; | ||
1637 | inner_domain->host_data = info; | ||
1638 | |||
1639 | return 0; | ||
1640 | } | ||
1641 | |||
1617 | static int __init its_probe(struct device_node *node, | 1642 | static int __init its_probe(struct device_node *node, |
1618 | struct irq_domain *parent) | 1643 | struct irq_domain *parent) |
1619 | { | 1644 | { |
1620 | struct resource res; | 1645 | struct resource res; |
1621 | struct its_node *its; | 1646 | struct its_node *its; |
1622 | void __iomem *its_base; | 1647 | void __iomem *its_base; |
1623 | struct irq_domain *inner_domain; | ||
1624 | u32 val; | 1648 | u32 val; |
1625 | u64 baser, tmp; | 1649 | u64 baser, tmp; |
1626 | int err; | 1650 | int err; |
@@ -1712,28 +1736,9 @@ static int __init its_probe(struct device_node *node, | |||
1712 | writeq_relaxed(0, its->base + GITS_CWRITER); | 1736 | writeq_relaxed(0, its->base + GITS_CWRITER); |
1713 | writel_relaxed(GITS_CTLR_ENABLE, its->base + GITS_CTLR); | 1737 | writel_relaxed(GITS_CTLR_ENABLE, its->base + GITS_CTLR); |
1714 | 1738 | ||
1715 | if (of_property_read_bool(node, "msi-controller")) { | 1739 | err = its_init_domain(node, its, parent); |
1716 | struct msi_domain_info *info; | 1740 | if (err) |
1717 | 1741 | goto out_free_tables; | |
1718 | info = kzalloc(sizeof(*info), GFP_KERNEL); | ||
1719 | if (!info) { | ||
1720 | err = -ENOMEM; | ||
1721 | goto out_free_tables; | ||
1722 | } | ||
1723 | |||
1724 | inner_domain = irq_domain_add_tree(node, &its_domain_ops, its); | ||
1725 | if (!inner_domain) { | ||
1726 | err = -ENOMEM; | ||
1727 | kfree(info); | ||
1728 | goto out_free_tables; | ||
1729 | } | ||
1730 | |||
1731 | inner_domain->parent = parent; | ||
1732 | inner_domain->bus_token = DOMAIN_BUS_NEXUS; | ||
1733 | info->ops = &its_msi_domain_ops; | ||
1734 | info->data = its; | ||
1735 | inner_domain->host_data = info; | ||
1736 | } | ||
1737 | 1742 | ||
1738 | spin_lock(&its_lock); | 1743 | spin_lock(&its_lock); |
1739 | list_add(&its->entry, &its_nodes); | 1744 | list_add(&its->entry, &its_nodes); |
@@ -1784,6 +1789,12 @@ int __init its_init(struct device_node *node, struct rdists *rdists, | |||
1784 | 1789 | ||
1785 | for (np = of_find_matching_node(node, its_device_id); np; | 1790 | for (np = of_find_matching_node(node, its_device_id); np; |
1786 | np = of_find_matching_node(np, its_device_id)) { | 1791 | np = of_find_matching_node(np, its_device_id)) { |
1792 | if (!of_property_read_bool(np, "msi-controller")) { | ||
1793 | pr_warn("%s: no msi-controller property, ITS ignored\n", | ||
1794 | np->full_name); | ||
1795 | continue; | ||
1796 | } | ||
1797 | |||
1787 | its_probe(np, parent_domain); | 1798 | its_probe(np, parent_domain); |
1788 | } | 1799 | } |
1789 | 1800 | ||