Re: [PATCH RFC 06/15] ims-msi: Enable IMS interrupts

Thomas Gleixner
2020-04-25T22:14:19Z

Dave Jiang <dave.jiang@intel.com> writes:
>
> +struct irq_domain *dev_get_ims_domain(struct device *dev)
> +{
> + struct irq_alloc_info info;
> +
> + if (dev_is_mdev(dev))
> + dev = mdev_to_parent(dev);
> +
> + init_irq_alloc_info(&info, NULL);
> + info.type = X86_IRQ_ALLOC_TYPE_IMS;

So all IMS capabale devices run on X86? I thought these things are PCIe
cards which can be plugged into any platform which supports PCIe.

> + info.dev = dev;
> +
> + return irq_remapping_get_irq_domain(&info);
> +}
> +
> static struct msi_domain_ops dev_ims_domain_ops = {
> .get_hwirq = dev_ims_get_hwirq,
> .msi_prepare = dev_ims_prepare,
> diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c
> index 6d8840db4a85..204ce8041c17 100644
> --- a/drivers/base/platform-msi.c
> +++ b/drivers/base/platform-msi.c
> @@ -118,6 +118,8 @@ static void platform_msi_free_descs(struct device *dev, int base, int nvec,
> kfree(platform_msi_group);
> }
> }
> +
> + dev->platform_msi_type = 0;

I can clearly see the advantage of using '0' over 'NOT_PLAT_MSI'
here. '0' is definitely more intuitive.

> }
>
> static int platform_msi_alloc_descs_with_irq(struct device *dev, int virq,
> @@ -205,18 +207,22 @@ platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec,
> * accordingly (which would impact the max number of MSI
> * capable devices).
> */
> - if (!dev->msi_domain || !platform_ops->write_msg || !nvec ||
> - nvec > MAX_DEV_MSIS)
> + if (!platform_ops->write_msg || !nvec || nvec > MAX_DEV_MSIS)
> return ERR_PTR(-EINVAL);
> - if (dev->msi_domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) {
> - dev_err(dev, "Incompatible msi_domain, giving up\n");
> - return ERR_PTR(-EINVAL);
> - }
> + if (dev->platform_msi_type == GEN_PLAT_MSI) {
> + if (!dev->msi_domain)
> + return ERR_PTR(-EINVAL);
> +
> + if (dev->msi_domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) {
> + dev_err(dev, "Incompatible msi_domain, giving up\n");
> + return ERR_PTR(-EINVAL);
> + }
>
> - /* Already had a helping of MSI? Greed... */
> - if (!list_empty(platform_msi_current_group_entry_list(dev)))
> - return ERR_PTR(-EBUSY);
> + /* Already had a helping of MSI? Greed... */
> + if (!list_empty(platform_msi_current_group_entry_list(dev)))
> + return ERR_PTR(-EBUSY);
> + }
>
> datap = kzalloc(sizeof(*datap), GFP_KERNEL);
> if (!datap)
> @@ -254,6 +260,7 @@ static void platform_msi_free_priv_data(struct platform_msi_priv_data *data)
> int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
> const struct platform_msi_ops *platform_ops)
> {
> + dev->platform_msi_type = GEN_PLAT_MSI;
> return platform_msi_domain_alloc_irqs_group(dev, nvec, platform_ops,
> NULL);
> }
> @@ -265,12 +272,18 @@ int platform_msi_domain_alloc_irqs_group(struct device *dev, unsigned int nvec,
> {
> struct platform_msi_group_entry *platform_msi_group;
> struct platform_msi_priv_data *priv_data;
> + struct irq_domain *domain;
> int err;
>
> - dev->platform_msi_type = GEN_PLAT_MSI;

Groan. If you move the type assignment to the caller then do so in a
separate patch. These all in one combo changes are simply not reviewable
without getting nuts.

> - if (group_id)
> + if (!dev->platform_msi_type) {

That's really consistent. If the caller does not store a type upfront
then it becomes IMS automagically. Can you pretty please stop to think
that this IMS stuff is the center of the universe? To be clear, it's
just another variant of half thought out hardware design fail as all the
other stuff we already have to support.

Abusing dev->platform_msi_type to decide about the nature of the call
and then decide that anything which does not set it upfront is IMS is
really future proof.

> *group_id = ++dev->group_id;
> + dev->platform_msi_type = IMS;

Oh a new type name 'IMS'. Well suited into the naming scheme.

> + domain = dev_get_ims_domain(dev);

No. This is completely inconsistent again and a blatant violation of
layering.

Thanks,

tglx