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

platform-msi: Track shared domain allocation

We have two flavours of platform-MSI:

- MSIs generated by devices for themselves (the usual case)

- MSIs generated on behalf of other devices, as the generating
device is some form of bridge (either a wire-to-MSI bridge,
or even a non-transparent PCI bridge that repaints the PCI
requester ID).

In the latter case, the underlying interrupt architecture may need
to track this in order to keep the mapping alive even when no MSI
are currently being generated.

Add a set of flags to the generic msi_alloc_info_t structure, as
well as the MSI_ALLOC_FLAGS_PROXY_DEVICE flag that will get
advertized by the platform-MSI code when allocating an irqdomain
for a device.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Tested-by: John Garry <john.garry@huawei.com>
Link: https://lore.kernel.org/r/20201129135208.680293-2-maz@kernel.org

+11
+7
drivers/base/platform-msi.c
··· 59 59 return irq_domain_set_hwirq_and_chip(domain, virq, hwirq, 60 60 info->chip, info->chip_data); 61 61 } 62 + 63 + static void platform_msi_set_proxy_dev(msi_alloc_info_t *arg) 64 + { 65 + arg->flags |= MSI_ALLOC_FLAGS_PROXY_DEVICE; 66 + } 62 67 #else 63 68 #define platform_msi_set_desc NULL 64 69 #define platform_msi_init NULL 70 + #define platform_msi_set_proxy_dev(x) do {} while(0) 65 71 #endif 66 72 67 73 static void platform_msi_update_dom_ops(struct msi_domain_info *info) ··· 349 343 if (!domain) 350 344 goto free_priv; 351 345 346 + platform_msi_set_proxy_dev(&data->arg); 352 347 err = msi_domain_prepare_irqs(domain->parent, dev, nvec, &data->arg); 353 348 if (err) 354 349 goto free_domain;
+4
include/asm-generic/msi.h
··· 22 22 typedef struct msi_alloc_info { 23 23 struct msi_desc *desc; 24 24 irq_hw_number_t hwirq; 25 + unsigned long flags; 25 26 union { 26 27 unsigned long ul; 27 28 void *ptr; 28 29 } scratchpad[NUM_MSI_ALLOC_SCRATCHPAD_REGS]; 29 30 } msi_alloc_info_t; 31 + 32 + /* Device generating MSIs is proxying for another device */ 33 + #define MSI_ALLOC_FLAGS_PROXY_DEVICE (1UL << 0) 30 34 31 35 #define GENERIC_MSI_DOMAIN_OPS 1 32 36