Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform-msi: Add ABI to show msi_irqs of platform devices

PCI devices expose the associated MSI interrupts via sysfs, but platform
devices which utilize MSI interrupts do not. This information is important
for user space tools to optimize affinity settings.

Utilize the generic MSI sysfs facility to expose this information for
platform MSI.

Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210813035628.6844-3-21cnbao@gmail.com

authored by

Barry Song and committed by
Thomas Gleixner
00ed1401 2f170814

+29 -5
+14
Documentation/ABI/testing/sysfs-bus-platform
··· 28 28 value comes from an ACPI _PXM method or a similar firmware 29 29 source. Initial users for this file would be devices like 30 30 arm smmu which are populated by arm64 acpi_iort. 31 + 32 + What: /sys/bus/platform/devices/.../msi_irqs/ 33 + Date: August 2021 34 + Contact: Barry Song <song.bao.hua@hisilicon.com> 35 + Description: 36 + The /sys/devices/.../msi_irqs directory contains a variable set 37 + of files, with each file being named after a corresponding msi 38 + irq vector allocated to that device. 39 + 40 + What: /sys/bus/platform/devices/.../msi_irqs/<N> 41 + Date: August 2021 42 + Contact: Barry Song <song.bao.hua@hisilicon.com> 43 + Description: 44 + This attribute will show "msi" if <N> is a valid msi irq
+15 -5
drivers/base/platform-msi.c
··· 21 21 * and the callback to write the MSI message. 22 22 */ 23 23 struct platform_msi_priv_data { 24 - struct device *dev; 25 - void *host_data; 26 - msi_alloc_info_t arg; 27 - irq_write_msi_msg_t write_msg; 28 - int devid; 24 + struct device *dev; 25 + void *host_data; 26 + const struct attribute_group **msi_irq_groups; 27 + msi_alloc_info_t arg; 28 + irq_write_msi_msg_t write_msg; 29 + int devid; 29 30 }; 30 31 31 32 /* The devid allocator */ ··· 273 272 if (err) 274 273 goto out_free_desc; 275 274 275 + priv_data->msi_irq_groups = msi_populate_sysfs(dev); 276 + if (IS_ERR(priv_data->msi_irq_groups)) { 277 + err = PTR_ERR(priv_data->msi_irq_groups); 278 + goto out_free_irqs; 279 + } 280 + 276 281 return 0; 277 282 283 + out_free_irqs: 284 + msi_domain_free_irqs(dev->msi_domain, dev); 278 285 out_free_desc: 279 286 platform_msi_free_descs(dev, 0, nvec); 280 287 out_free_priv_data: ··· 302 293 struct msi_desc *desc; 303 294 304 295 desc = first_msi_entry(dev); 296 + msi_destroy_sysfs(dev, desc->platform.msi_priv_data->msi_irq_groups); 305 297 platform_msi_free_priv_data(desc->platform.msi_priv_data); 306 298 } 307 299