Skip to content

Commit 00ed140

Browse files
Barry SongKAGA-KOKO
authored andcommitted
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Acked-by: Bjorn Helgaas <[email protected]> Acked-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2f17081 commit 00ed140

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

Documentation/ABI/testing/sysfs-bus-platform

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,17 @@ Description:
2828
value comes from an ACPI _PXM method or a similar firmware
2929
source. Initial users for this file would be devices like
3030
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 <[email protected]>
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 <[email protected]>
43+
Description:
44+
This attribute will show "msi" if <N> is a valid msi irq

drivers/base/platform-msi.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
* and the callback to write the MSI message.
2222
*/
2323
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;
2930
};
3031

3132
/* The devid allocator */
@@ -272,8 +273,16 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
272273
if (err)
273274
goto out_free_desc;
274275

276+
priv_data->msi_irq_groups = msi_populate_sysfs(dev);
277+
if (IS_ERR(priv_data->msi_irq_groups)) {
278+
err = PTR_ERR(priv_data->msi_irq_groups);
279+
goto out_free_irqs;
280+
}
281+
275282
return 0;
276283

284+
out_free_irqs:
285+
msi_domain_free_irqs(dev->msi_domain, dev);
277286
out_free_desc:
278287
platform_msi_free_descs(dev, 0, nvec);
279288
out_free_priv_data:
@@ -293,6 +302,7 @@ void platform_msi_domain_free_irqs(struct device *dev)
293302
struct msi_desc *desc;
294303

295304
desc = first_msi_entry(dev);
305+
msi_destroy_sysfs(dev, desc->platform.msi_priv_data->msi_irq_groups);
296306
platform_msi_free_priv_data(desc->platform.msi_priv_data);
297307
}
298308

0 commit comments

Comments
 (0)