Skip to content

Commit 7f2baef

Browse files
committed
irqchip/gic-v3-its: Switch platform MSI to MSI parent
Similar to the previous conversion of the PCI/MSI support lift the prepare() callback from the existing platform MSI code and enable platform MSI and the related device domain bus tokens in select and the child domain initialization code. All platform MSI users are automatically using the new per device MSI model now. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Anna-Maria Behnsen <[email protected]> Signed-off-by: Shivamurthy Shastri <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 64a8553 commit 7f2baef

File tree

3 files changed

+73
-165
lines changed

3 files changed

+73
-165
lines changed

drivers/irqchip/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ obj-$(CONFIG_ARCH_REALVIEW) += irq-gic-realview.o
3232
obj-$(CONFIG_IRQ_MSI_LIB) += irq-msi-lib.o
3333
obj-$(CONFIG_ARM_GIC_V2M) += irq-gic-v2m.o
3434
obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-v3-mbi.o irq-gic-common.o
35-
obj-$(CONFIG_ARM_GIC_V3_ITS) += irq-gic-v3-its.o irq-gic-v3-its-platform-msi.o irq-gic-v4.o irq-gic-v3-its-msi-parent.o
35+
obj-$(CONFIG_ARM_GIC_V3_ITS) += irq-gic-v3-its.o irq-gic-v4.o irq-gic-v3-its-msi-parent.o
3636
obj-$(CONFIG_ARM_GIC_V3_ITS_FSL_MC) += irq-gic-v3-its-fsl-mc-msi.o
3737
obj-$(CONFIG_PARTITION_PERCPU) += irq-partition-percpu.o
3838
obj-$(CONFIG_HISILICON_IRQ_MBIGEN) += irq-mbigen.o

drivers/irqchip/irq-gic-v3-its-msi-parent.c

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Copyright (C) 2022 Linutronix GmbH
55
// Copyright (C) 2022 Intel
66

7+
#include <linux/acpi_iort.h>
78
#include <linux/pci.h>
89

910
#include "irq-gic-common.h"
@@ -96,6 +97,68 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
9697
#define its_pci_msi_prepare NULL
9798
#endif /* !CONFIG_PCI_MSI */
9899

100+
static int of_pmsi_get_dev_id(struct irq_domain *domain, struct device *dev,
101+
u32 *dev_id)
102+
{
103+
int ret, index = 0;
104+
105+
/* Suck the DeviceID out of the msi-parent property */
106+
do {
107+
struct of_phandle_args args;
108+
109+
ret = of_parse_phandle_with_args(dev->of_node,
110+
"msi-parent", "#msi-cells",
111+
index, &args);
112+
if (args.np == irq_domain_get_of_node(domain)) {
113+
if (WARN_ON(args.args_count != 1))
114+
return -EINVAL;
115+
*dev_id = args.args[0];
116+
break;
117+
}
118+
index++;
119+
} while (!ret);
120+
121+
return ret;
122+
}
123+
124+
int __weak iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id)
125+
{
126+
return -1;
127+
}
128+
129+
static int its_pmsi_prepare(struct irq_domain *domain, struct device *dev,
130+
int nvec, msi_alloc_info_t *info)
131+
{
132+
struct msi_domain_info *msi_info;
133+
u32 dev_id;
134+
int ret;
135+
136+
if (dev->of_node)
137+
ret = of_pmsi_get_dev_id(domain, dev, &dev_id);
138+
else
139+
ret = iort_pmsi_get_dev_id(dev, &dev_id);
140+
if (ret)
141+
return ret;
142+
143+
/* ITS specific DeviceID, as the core ITS ignores dev. */
144+
info->scratchpad[0].ul = dev_id;
145+
146+
/*
147+
* @domain->msi_domain_info->hwsize contains the size of the device
148+
* domain, but vector allocation happens one by one.
149+
*/
150+
msi_info = msi_get_domain_info(domain);
151+
if (msi_info->hwsize > nvec)
152+
nvec = msi_info->hwsize;
153+
154+
/* Allocate at least 32 MSIs, and always as a power of 2 */
155+
nvec = max_t(int, 32, roundup_pow_of_two(nvec));
156+
157+
msi_info = msi_get_domain_info(domain->parent);
158+
return msi_info->ops->msi_prepare(domain->parent,
159+
dev, nvec, info);
160+
}
161+
99162
static bool its_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
100163
struct irq_domain *real_parent, struct msi_domain_info *info)
101164
{
@@ -120,6 +183,14 @@ static bool its_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
120183
*/
121184
info->ops->msi_prepare = its_pci_msi_prepare;
122185
break;
186+
case DOMAIN_BUS_DEVICE_MSI:
187+
case DOMAIN_BUS_WIRED_TO_MSI:
188+
/*
189+
* FIXME: See the above PCI prepare comment. The domain
190+
* size is also known at domain creation time.
191+
*/
192+
info->ops->msi_prepare = its_pmsi_prepare;
193+
break;
123194
default:
124195
/* Confused. How did the lib return true? */
125196
WARN_ON_ONCE(1);
@@ -133,7 +204,7 @@ const struct msi_parent_ops gic_v3_its_msi_parent_ops = {
133204
.supported_flags = ITS_MSI_FLAGS_SUPPORTED,
134205
.required_flags = ITS_MSI_FLAGS_REQUIRED,
135206
.bus_select_token = DOMAIN_BUS_NEXUS,
136-
.bus_select_mask = MATCH_PCI_MSI,
207+
.bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI,
137208
.prefix = "ITS-",
138209
.init_dev_msi_info = its_init_dev_msi_info,
139210
};

drivers/irqchip/irq-gic-v3-its-platform-msi.c

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)