Introduce msi_domain_update_hwsize() helper for updating hwsize.
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Reviewed-by: Guanghui Feng <guanghuifeng@linux.alibaba.com>
---
include/linux/msi.h | 3 +++
kernel/irq/msi.c | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/linux/msi.h b/include/linux/msi.h
index fa41eed62868..6de938ba2245 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -647,6 +647,9 @@ bool msi_create_device_irq_domain(struct device *dev, unsigned int domid,
void *chip_data);
void msi_remove_device_irq_domain(struct device *dev, unsigned int domid);
+int msi_domain_update_hwsize(struct device *dev, unsigned int domid,
+ unsigned int hwsize_new);
+
bool msi_match_device_irq_domain(struct device *dev, unsigned int domid,
enum irq_domain_bus_token bus_token);
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 3cafa40e6ce3..162e7263ef7f 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -1133,6 +1133,28 @@ void msi_remove_device_irq_domain(struct device *dev, unsigned int domid)
kfree(container_of(info, struct msi_domain_template, info));
}
+int msi_domain_update_hwsize(struct device *dev, unsigned int domid,
+ unsigned int hwsize_new)
+{
+ struct msi_domain_info *info;
+ struct irq_domain *domain;
+
+ if (hwsize_new > MSI_XA_DOMAIN_SIZE)
+ return -EINVAL;
+ if (!hwsize_new)
+ hwsize_new = MSI_XA_DOMAIN_SIZE;
+
+ domain = msi_get_device_domain(dev, domid);
+ if (!domain)
+ return -ENODEV;
+
+ info = domain->host_data;
+ if (hwsize_new != info->hwsize)
+ info->hwsize = hwsize_new;
+
+ return 0;
+}
+
/**
* msi_match_device_irq_domain - Match a device irq domain against a bus token
* @dev: Pointer to the device
--
2.32.0.3.g01195cf9f
On Tue, Mar 24 2026 at 09:47, Guixin Liu wrote:
> +int msi_domain_update_hwsize(struct device *dev, unsigned int domid,
> + unsigned int hwsize_new)
> +{
> + struct msi_domain_info *info;
> + struct irq_domain *domain;
> +
> + if (hwsize_new > MSI_XA_DOMAIN_SIZE)
> + return -EINVAL;
> + if (!hwsize_new)
> + hwsize_new = MSI_XA_DOMAIN_SIZE;
> +
> + domain = msi_get_device_domain(dev, domid);
> + if (!domain)
> + return -ENODEV;
> +
> + info = domain->host_data;
> + if (hwsize_new != info->hwsize)
> + info->hwsize = hwsize_new;
This is incorrect because the underlying irqdomain has been created with
the original hardware size. So just fiddling with info->hwsize results
in inconsistent state.
在 2026/3/25 16:15, Thomas Gleixner 写道:
> On Tue, Mar 24 2026 at 09:47, Guixin Liu wrote:
>> +int msi_domain_update_hwsize(struct device *dev, unsigned int domid,
>> + unsigned int hwsize_new)
>> +{
>> + struct msi_domain_info *info;
>> + struct irq_domain *domain;
>> +
>> + if (hwsize_new > MSI_XA_DOMAIN_SIZE)
>> + return -EINVAL;
>> + if (!hwsize_new)
>> + hwsize_new = MSI_XA_DOMAIN_SIZE;
>> +
>> + domain = msi_get_device_domain(dev, domid);
>> + if (!domain)
>> + return -ENODEV;
>> +
>> + info = domain->host_data;
>> + if (hwsize_new != info->hwsize)
>> + info->hwsize = hwsize_new;
> This is incorrect because the underlying irqdomain has been created with
> the original hardware size. So just fiddling with info->hwsize results
> in inconsistent state.
I found that hwsize only affects the range checking when allocating and
releasing intterrupts after the irq_domain is established,
and the kernel does not allocate related resources based on it.
Cloud you plz tell me specifically where the inconsistency is? thanks.
Best Regards,
Guixin Liu
© 2016 - 2026 Red Hat, Inc.