[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211206210438.038137622@linutronix.de>
Date: Mon, 6 Dec 2021 23:39:07 +0100 (CET)
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Bjorn Helgaas <helgaas@...nel.org>, Marc Zygnier <maz@...nel.org>,
Alex Williamson <alex.williamson@...hat.com>,
Kevin Tian <kevin.tian@...el.com>,
Jason Gunthorpe <jgg@...dia.com>,
Megha Dey <megha.dey@...el.com>,
Ashok Raj <ashok.raj@...el.com>, linux-pci@...r.kernel.org,
Cedric Le Goater <clg@...d.org>,
xen-devel@...ts.xenproject.org, Juergen Gross <jgross@...e.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Will Deacon <will@...nel.org>,
Santosh Shilimkar <ssantosh@...nel.org>,
iommu@...ts.linux-foundation.org, dmaengine@...r.kernel.org,
Stuart Yoder <stuyoder@...il.com>,
Laurentiu Tudor <laurentiu.tudor@....com>,
Nishanth Menon <nm@...com>, Tero Kristo <kristo@...nel.org>,
linux-arm-kernel@...ts.infradead.org,
Vinod Koul <vkoul@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Robin Murphy <robin.murphy@....com>,
Sinan Kaya <okaya@...nel.org>
Subject: [patch V2 07/36] genirq/msi: Provide msi_device_populate/destroy_sysfs()
Add new allocation functions which can be activated by domain info
flags. They store the groups pointer in struct msi_device_data.
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Reviewed-by: Jason Gunthorpe <jgg@...dia.com>
---
include/linux/msi.h | 4 ++++
kernel/irq/msi.c | 42 ++++++++++++++++++++++++++++++++++++++++--
2 files changed, 44 insertions(+), 2 deletions(-)
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -56,6 +56,8 @@ struct irq_data;
struct msi_desc;
struct pci_dev;
struct platform_msi_priv_data;
+struct attribute_group;
+
void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
#ifdef CONFIG_GENERIC_MSI_IRQ
void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg);
@@ -174,9 +176,11 @@ struct msi_desc {
/**
* msi_device_data - MSI per device data
* @properties: MSI properties which are interesting to drivers
+ * @attrs: Pointer to the sysfs attribute group
*/
struct msi_device_data {
unsigned long properties;
+ const struct attribute_group **attrs;
};
int msi_setup_device_data(struct device *dev);
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -213,6 +213,20 @@ const struct attribute_group **msi_popul
}
/**
+ * msi_device_populate_sysfs - Populate msi_irqs sysfs entries for a device
+ * @dev: The device (PCI, platform etc) which will get sysfs entries
+ */
+int msi_device_populate_sysfs(struct device *dev)
+{
+ const struct attribute_group **group = msi_populate_sysfs(dev);
+
+ if (IS_ERR(group))
+ return PTR_ERR(group);
+ dev->msi.data->attrs = group;
+ return 0;
+}
+
+/**
* msi_destroy_sysfs - Destroy msi_irqs sysfs entries for devices
* @dev: The device(PCI, platform etc) who will remove sysfs entries
* @msi_irq_groups: attribute_group for device msi_irqs entries
@@ -238,6 +252,17 @@ void msi_destroy_sysfs(struct device *de
kfree(msi_irq_groups);
}
}
+
+/**
+ * msi_device_destroy_sysfs - Destroy msi_irqs sysfs entries for a device
+ * @dev: The device (PCI, platform etc) for which to remove
+ * sysfs entries
+ */
+void msi_device_destroy_sysfs(struct device *dev)
+{
+ msi_destroy_sysfs(dev, dev->msi.data->attrs);
+ dev->msi.data->attrs = NULL;
+}
#endif
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
@@ -685,8 +710,19 @@ int msi_domain_alloc_irqs(struct irq_dom
{
struct msi_domain_info *info = domain->host_data;
struct msi_domain_ops *ops = info->ops;
+ int ret;
- return ops->domain_alloc_irqs(domain, dev, nvec);
+ ret = ops->domain_alloc_irqs(domain, dev, nvec);
+ if (ret)
+ return ret;
+
+ if (!(info->flags & MSI_FLAG_DEV_SYSFS))
+ return 0;
+
+ ret = msi_device_populate_sysfs(dev);
+ if (ret)
+ msi_domain_free_irqs(domain, dev);
+ return ret;
}
void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev)
@@ -725,7 +761,9 @@ void msi_domain_free_irqs(struct irq_dom
struct msi_domain_info *info = domain->host_data;
struct msi_domain_ops *ops = info->ops;
- return ops->domain_free_irqs(domain, dev);
+ if (info->flags & MSI_FLAG_DEV_SYSFS)
+ msi_device_destroy_sysfs(dev);
+ ops->domain_free_irqs(domain, dev);
}
/**
Powered by blists - more mailing lists