Skip to content

Commit 2b160e1

Browse files
chenhuacaicthbleachbit
authored andcommitted
irqchip/loongson-pch-msi: Add machanism to limit msi allocation
Loongson machines can have as many as 256 logical cpus, but the maximum of msi vectors in one irqchip is also 256 (practically that is less than 256, because pch-pic consumes some of them). Even on a 64-core machine, 256 irqs can be easily exhausted if there are several NICs (NICs usually allocate msi irqs depending on the number of online cpus). So we want to limit the msi allocation. In this patch we add a machanism to limit msi allocation: 1, Modify input "nvec" by overriding the msi_domain_ops::msi_prepare(); 2, The default limit is 256, which is compatible with the old behavior; 3, Add a cmdline parameter "loongson_msi_limit=xxx" to control the limit. Signed-off-by: Juxin Gao <gaojuxin@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent e5a016b commit 2b160e1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

drivers/irqchip/irq-loongson-pch-msi.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,36 @@ static void pch_msi_compose_msi_msg(struct irq_data *data,
8585
msg->data = data->hwirq;
8686
}
8787

88+
#define DEFAULT_MSI_LIMITS 256
89+
90+
static int pch_msi_limits = DEFAULT_MSI_LIMITS;
91+
92+
static int __init pch_msi_limit(char *str)
93+
{
94+
get_option(&str, &pch_msi_limits);
95+
96+
if (pch_msi_limits <= 0)
97+
pch_msi_limits = DEFAULT_MSI_LIMITS;
98+
99+
return 0;
100+
}
101+
102+
early_param("loongson_msi_limit", pch_msi_limit);
103+
104+
static int pch_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *arg)
105+
{
106+
memset(arg, 0, sizeof(*arg));
107+
return clamp_val(nvec, 0, pch_msi_limits);
108+
}
109+
110+
static struct msi_domain_ops pch_msi_ops = {
111+
.msi_prepare = pch_msi_prepare,
112+
};
113+
88114
static struct msi_domain_info pch_msi_domain_info = {
89115
.flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
90116
MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX,
117+
.ops = &pch_msi_ops,
91118
.chip = &pch_msi_irq_chip,
92119
};
93120

0 commit comments

Comments
 (0)