From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 10/13] irqchip: GICv3: ITS: DT probing and initialization
Date: Wed, 26 Nov 2014 10:14:34 +0000 [thread overview]
Message-ID: <5475A80A.3010305@arm.com> (raw)
In-Reply-To: <CALRxmdA=_aTbRM+471cSkxTtbZ=nErB+tsEBt3+6M9-zi7E5-w@mail.gmail.com>
Hi Stuart,
On 25/11/14 21:08, Stuart Yoder wrote:
> On Mon, Nov 24, 2014 at 8:35 AM, Marc Zyngier <marc.zyngier@arm.com> wrote:
>> Add the code that probes the ITS from the device tree,
>> and initialize it.
>>
>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>> drivers/irqchip/irq-gic-v3-its.c | 169 +++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 169 insertions(+)
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
>> index 532c6df..e9d1615 100644
>> --- a/drivers/irqchip/irq-gic-v3-its.c
>> +++ b/drivers/irqchip/irq-gic-v3-its.c
>> @@ -1231,3 +1231,172 @@ static const struct irq_domain_ops its_domain_ops = {
>> .alloc = its_irq_domain_alloc,
>> .free = its_irq_domain_free,
>> };
>> +
>> +static int its_probe(struct device_node *node, struct irq_domain *parent)
>> +{
>> + struct resource res;
>> + struct its_node *its;
>> + void __iomem *its_base;
>> + u32 val;
>> + u64 baser, tmp;
>> + int err;
>> +
>> + err = of_address_to_resource(node, 0, &res);
>> + if (err) {
>> + pr_warn("%s: no regs?\n", node->full_name);
>> + return -ENXIO;
>> + }
>> +
>> + its_base = ioremap(res.start, resource_size(&res));
>> + if (!its_base) {
>> + pr_warn("%s: unable to map registers\n", node->full_name);
>> + return -ENOMEM;
>> + }
>> +
>> + val = readl_relaxed(its_base + GITS_PIDR2) & GIC_PIDR2_ARCH_MASK;
>> + if (val != 0x30 && val != 0x40) {
>> + pr_warn("%s: no ITS detected, giving up\n", node->full_name);
>> + err = -ENODEV;
>> + goto out_unmap;
>> + }
>> +
>> + pr_info("ITS: %s\n", node->full_name);
>> +
>> + its = kzalloc(sizeof(*its), GFP_KERNEL);
>> + if (!its) {
>> + err = -ENOMEM;
>> + goto out_unmap;
>> + }
>> +
>> + raw_spin_lock_init(&its->lock);
>> + INIT_LIST_HEAD(&its->entry);
>> + INIT_LIST_HEAD(&its->its_device_list);
>> + its->base = its_base;
>> + its->phys_base = res.start;
>> + its->msi_chip.of_node = node;
>> + its->ite_size = ((readl_relaxed(its_base + GITS_TYPER) >> 4) & 0xf) + 1;
>> +
>> + its->cmd_base = kzalloc(ITS_CMD_QUEUE_SZ, GFP_KERNEL);
>> + if (!its->cmd_base) {
>> + err = -ENOMEM;
>> + goto out_free_its;
>> + }
>> + its->cmd_write = its->cmd_base;
>> +
>> + err = its_alloc_tables(its);
>> + if (err)
>> + goto out_free_cmd;
>> +
>> + err = its_alloc_collections(its);
>> + if (err)
>> + goto out_free_tables;
>> +
>> + baser = (virt_to_phys(its->cmd_base) |
>> + GITS_CBASER_WaWb |
>> + GITS_CBASER_InnerShareable |
>> + (ITS_CMD_QUEUE_SZ / SZ_4K - 1) |
>> + GITS_CBASER_VALID);
>> +
>> + writeq_relaxed(baser, its->base + GITS_CBASER);
>> + tmp = readq_relaxed(its->base + GITS_CBASER);
>> + writeq_relaxed(0, its->base + GITS_CWRITER);
>> + writel_relaxed(1, its->base + GITS_CTLR);
>> +
>> + if ((tmp ^ baser) & GITS_BASER_SHAREABILITY_MASK) {
>> + pr_info("ITS: using cache flushing for cmd queue\n");
>> + its->flags |= ITS_FLAGS_CMDQ_NEEDS_FLUSHING;
>> + }
>> +
>> + if (of_property_read_bool(its->msi_chip.of_node, "msi-controller")) {
>> + its->domain = irq_domain_add_tree(NULL, &its_domain_ops, its);
>> + if (!its->domain) {
>> + err = -ENOMEM;
>> + goto out_free_tables;
>> + }
>> +
>> + its->domain->parent = parent;
>> +
>> + its->msi_chip.domain = pci_msi_create_irq_domain(node,
>> + &its_pci_msi_domain_info,
>> + its->domain);
>> + if (!its->msi_chip.domain) {
>> + err = -ENOMEM;
>> + goto out_free_domains;
>> + }
>> +
>> + err = of_pci_msi_chip_add(&its->msi_chip);
>> + if (err)
>> + goto out_free_domains;
>> + }
>
> Hi Marc,
>
> We have a requirement to have both PCI and non-PCI buses use the GIC_ITS.
> Above, you have the hardcoded assumption that this is PCI. How do 2 different
> bus types share the ITS at the same time.
This set of patches specifically targets PCI, as this is the only thing
that I can realistically test.
When it comes to non-PCI uses of the ITS, it shouldn't be too hard: just
instantiate a non-PCI MSI domain sitting on top of the same ITS domain.
The split in responsibilities between MSI and ITS domains is designed to
cover exactly this.
This of course assumes that your non-PCI devices behave in a similar way
to PCI devices (programmable event ID, as well as unique, discoverable
device IDs).
Hope this helps,
M.
--
Jazz is not dead. It just smells funny...
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: Stuart Yoder <b08248@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Jason Cooper <jason@lakedaemon.net>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Jiang Liu <jiang.liu@linux.intel.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
Will Deacon <Will.Deacon@arm.com>,
Catalin Marinas <Catalin.Marinas@arm.com>,
Mark Rutland <Mark.Rutland@arm.com>,
"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
Robert Richter <robert.richter@caviumnetworks.com>,
"Yun Wu (Abel)" <wuyun.wu@huawei.com>
Subject: Re: [PATCH v3 10/13] irqchip: GICv3: ITS: DT probing and initialization
Date: Wed, 26 Nov 2014 10:14:34 +0000 [thread overview]
Message-ID: <5475A80A.3010305@arm.com> (raw)
In-Reply-To: <CALRxmdA=_aTbRM+471cSkxTtbZ=nErB+tsEBt3+6M9-zi7E5-w@mail.gmail.com>
Hi Stuart,
On 25/11/14 21:08, Stuart Yoder wrote:
> On Mon, Nov 24, 2014 at 8:35 AM, Marc Zyngier <marc.zyngier@arm.com> wrote:
>> Add the code that probes the ITS from the device tree,
>> and initialize it.
>>
>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>> drivers/irqchip/irq-gic-v3-its.c | 169 +++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 169 insertions(+)
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
>> index 532c6df..e9d1615 100644
>> --- a/drivers/irqchip/irq-gic-v3-its.c
>> +++ b/drivers/irqchip/irq-gic-v3-its.c
>> @@ -1231,3 +1231,172 @@ static const struct irq_domain_ops its_domain_ops = {
>> .alloc = its_irq_domain_alloc,
>> .free = its_irq_domain_free,
>> };
>> +
>> +static int its_probe(struct device_node *node, struct irq_domain *parent)
>> +{
>> + struct resource res;
>> + struct its_node *its;
>> + void __iomem *its_base;
>> + u32 val;
>> + u64 baser, tmp;
>> + int err;
>> +
>> + err = of_address_to_resource(node, 0, &res);
>> + if (err) {
>> + pr_warn("%s: no regs?\n", node->full_name);
>> + return -ENXIO;
>> + }
>> +
>> + its_base = ioremap(res.start, resource_size(&res));
>> + if (!its_base) {
>> + pr_warn("%s: unable to map registers\n", node->full_name);
>> + return -ENOMEM;
>> + }
>> +
>> + val = readl_relaxed(its_base + GITS_PIDR2) & GIC_PIDR2_ARCH_MASK;
>> + if (val != 0x30 && val != 0x40) {
>> + pr_warn("%s: no ITS detected, giving up\n", node->full_name);
>> + err = -ENODEV;
>> + goto out_unmap;
>> + }
>> +
>> + pr_info("ITS: %s\n", node->full_name);
>> +
>> + its = kzalloc(sizeof(*its), GFP_KERNEL);
>> + if (!its) {
>> + err = -ENOMEM;
>> + goto out_unmap;
>> + }
>> +
>> + raw_spin_lock_init(&its->lock);
>> + INIT_LIST_HEAD(&its->entry);
>> + INIT_LIST_HEAD(&its->its_device_list);
>> + its->base = its_base;
>> + its->phys_base = res.start;
>> + its->msi_chip.of_node = node;
>> + its->ite_size = ((readl_relaxed(its_base + GITS_TYPER) >> 4) & 0xf) + 1;
>> +
>> + its->cmd_base = kzalloc(ITS_CMD_QUEUE_SZ, GFP_KERNEL);
>> + if (!its->cmd_base) {
>> + err = -ENOMEM;
>> + goto out_free_its;
>> + }
>> + its->cmd_write = its->cmd_base;
>> +
>> + err = its_alloc_tables(its);
>> + if (err)
>> + goto out_free_cmd;
>> +
>> + err = its_alloc_collections(its);
>> + if (err)
>> + goto out_free_tables;
>> +
>> + baser = (virt_to_phys(its->cmd_base) |
>> + GITS_CBASER_WaWb |
>> + GITS_CBASER_InnerShareable |
>> + (ITS_CMD_QUEUE_SZ / SZ_4K - 1) |
>> + GITS_CBASER_VALID);
>> +
>> + writeq_relaxed(baser, its->base + GITS_CBASER);
>> + tmp = readq_relaxed(its->base + GITS_CBASER);
>> + writeq_relaxed(0, its->base + GITS_CWRITER);
>> + writel_relaxed(1, its->base + GITS_CTLR);
>> +
>> + if ((tmp ^ baser) & GITS_BASER_SHAREABILITY_MASK) {
>> + pr_info("ITS: using cache flushing for cmd queue\n");
>> + its->flags |= ITS_FLAGS_CMDQ_NEEDS_FLUSHING;
>> + }
>> +
>> + if (of_property_read_bool(its->msi_chip.of_node, "msi-controller")) {
>> + its->domain = irq_domain_add_tree(NULL, &its_domain_ops, its);
>> + if (!its->domain) {
>> + err = -ENOMEM;
>> + goto out_free_tables;
>> + }
>> +
>> + its->domain->parent = parent;
>> +
>> + its->msi_chip.domain = pci_msi_create_irq_domain(node,
>> + &its_pci_msi_domain_info,
>> + its->domain);
>> + if (!its->msi_chip.domain) {
>> + err = -ENOMEM;
>> + goto out_free_domains;
>> + }
>> +
>> + err = of_pci_msi_chip_add(&its->msi_chip);
>> + if (err)
>> + goto out_free_domains;
>> + }
>
> Hi Marc,
>
> We have a requirement to have both PCI and non-PCI buses use the GIC_ITS.
> Above, you have the hardcoded assumption that this is PCI. How do 2 different
> bus types share the ITS at the same time.
This set of patches specifically targets PCI, as this is the only thing
that I can realistically test.
When it comes to non-PCI uses of the ITS, it shouldn't be too hard: just
instantiate a non-PCI MSI domain sitting on top of the same ITS domain.
The split in responsibilities between MSI and ITS domains is designed to
cover exactly this.
This of course assumes that your non-PCI devices behave in a similar way
to PCI devices (programmable event ID, as well as unique, discoverable
device IDs).
Hope this helps,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2014-11-26 10:14 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-24 14:35 [PATCH v3 00/13] arm64: PCI/MSI: GICv3 ITS support (stacked domain edition) Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 01/13] arm64: PCI/MSI: Use asm-generic/msi.h Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 02/13] irqchip: GICv3: Convert to domain hierarchy Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 03/13] irqchip: GICv3: rework redistributor structure Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 04/13] irqchip: GICv3: ITS command queue Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-12-10 3:03 ` Yun Wu (Abel)
2014-12-10 3:03 ` Yun Wu (Abel)
2014-12-10 11:20 ` Marc Zyngier
2014-12-10 11:20 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 05/13] irqchip: GICv3: ITS: irqchip implementation Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 06/13] irqchip: GICv3: ITS: LPI allocator Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:57 ` Jiang Liu
2014-11-24 14:57 ` Jiang Liu
2014-11-24 15:32 ` Marc Zyngier
2014-11-24 15:32 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 07/13] irqchip: GICv3: ITS: tables allocators Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 08/13] irqchip: GICv3: ITS: device allocation and configuration Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 09/13] irqchip: GICv3: ITS: MSI support Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-12-04 21:52 ` Stuart Yoder
2014-12-04 21:52 ` Stuart Yoder
2014-12-04 21:58 ` Thomas Gleixner
2014-12-04 21:58 ` Thomas Gleixner
2014-12-05 10:10 ` Marc Zyngier
2014-12-05 10:10 ` Marc Zyngier
2014-12-08 3:28 ` Yun Wu (Abel)
2014-12-08 3:28 ` Yun Wu (Abel)
2014-12-08 9:32 ` Marc Zyngier
2014-12-08 9:32 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 10/13] irqchip: GICv3: ITS: DT probing and initialization Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-25 21:08 ` Stuart Yoder
2014-11-25 21:08 ` Stuart Yoder
2014-11-26 10:14 ` Marc Zyngier [this message]
2014-11-26 10:14 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 11/13] irqchip: GICv3: ITS: plug ITS init into main GICv3 code Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 12/13] irqchip: GICv3: ITS: enable compilation of the ITS driver Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-24 14:35 ` [PATCH v3 13/13] irqchip: GICv3: Binding updates for ITS Marc Zyngier
2014-11-24 14:35 ` Marc Zyngier
2014-11-26 8:06 ` [PATCH v3 00/13] arm64: PCI/MSI: GICv3 ITS support (stacked domain edition) Jason Cooper
2014-11-26 8:06 ` Jason Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5475A80A.3010305@arm.com \
--to=marc.zyngier@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.