Skip to content

Commit 147c8f3

Browse files
author
Marc Zyngier
committed
irqchip/gic-v3-its: Move minimum LPI requirements to individual busses
At the moment, the core ITS driver imposes the allocation to be in chunks of 32. As we want to relax this on a per bus basis, let's move the the the allocation constraints to each bus. No functionnal change. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent fe8e935 commit 147c8f3

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ static int its_fsl_mc_msi_prepare(struct irq_domain *msi_domain,
4545
*/
4646
info->scratchpad[0].ul = mc_bus_dev->icid;
4747
msi_info = msi_get_domain_info(msi_domain->parent);
48+
49+
/* Allocate at least 32 MSIs, and always as a power of 2 */
50+
nvec = max_t(int, 32, roundup_pow_of_two(nvec));
4851
return msi_info->ops->msi_prepare(msi_domain->parent, dev, nvec, info);
4952
}
5053

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
8686
/* ITS specific DeviceID, as the core ITS ignores dev. */
8787
info->scratchpad[0].ul = pci_msi_domain_get_msi_rid(domain, pdev);
8888

89-
return msi_info->ops->msi_prepare(domain->parent,
90-
dev, max(nvec, alias_count), info);
89+
/* Allocate at least 32 MSIs, and always as a power of 2 */
90+
nvec = max(nvec, alias_count);
91+
nvec = max_t(int, 32, roundup_pow_of_two(nvec));
92+
return msi_info->ops->msi_prepare(domain->parent, dev, nvec, info);
9193
}
9294

9395
static struct msi_domain_ops its_pci_msi_ops = {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ static int its_pmsi_prepare(struct irq_domain *domain, struct device *dev,
7373
/* ITS specific DeviceID, as the core ITS ignores dev. */
7474
info->scratchpad[0].ul = dev_id;
7575

76+
/* Allocate at least 32 MSIs, and always as a power of 2 */
77+
nvec = max_t(int, 32, roundup_pow_of_two(nvec));
7678
return msi_info->ops->msi_prepare(domain->parent,
7779
dev, nvec, info);
7880
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,12 +2200,15 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
22002200
if (!its_alloc_device_table(its, dev_id))
22012201
return NULL;
22022202

2203+
if (WARN_ON(!is_power_of_2(nvecs)))
2204+
nvecs = roundup_pow_of_two(nvecs);
2205+
22032206
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
22042207
/*
2205-
* We allocate at least one chunk worth of LPIs bet device,
2206-
* and thus that many ITEs. The device may require less though.
2208+
* Even if the device wants a single LPI, the ITT must be
2209+
* sized as a power of two (and you need at least one bit...).
22072210
*/
2208-
nr_ites = max(IRQS_PER_CHUNK, roundup_pow_of_two(nvecs));
2211+
nr_ites = max(2, nvecs);
22092212
sz = nr_ites * its->ite_size;
22102213
sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1;
22112214
itt = kzalloc(sz, GFP_KERNEL);
@@ -2861,7 +2864,7 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
28612864

28622865
BUG_ON(!vm);
28632866

2864-
bitmap = its_lpi_alloc_chunks(nr_irqs, &base, &nr_ids);
2867+
bitmap = its_lpi_alloc_chunks(roundup_pow_of_two(nr_irqs), &base, &nr_ids);
28652868
if (!bitmap)
28662869
return -ENOMEM;
28672870

0 commit comments

Comments
 (0)