Skip to content

Commit 28026cf

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
genirq/msi: Add .msi_teardown() callback as the reverse of .msi_prepare()
While the MSI ops do have a .msi_prepare() callback that is responsible for setting up the relevant (usually per-device) allocation, there is no callback reversing this setup. For this purpose, add .msi_teardown() callback. In order to avoid breaking the ITS driver that suffers from related issues, do not call the callback just yet. Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent a1d8a83 commit 28026cf

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

include/linux/msi.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ struct msi_domain_info;
423423
* @msi_init: Domain specific init function for MSI interrupts
424424
* @msi_free: Domain specific function to free a MSI interrupts
425425
* @msi_prepare: Prepare the allocation of the interrupts in the domain
426+
* @msi_teardown: Reverse the effects of @msi_prepare
426427
* @prepare_desc: Optional function to prepare the allocated MSI descriptor
427428
* in the domain
428429
* @set_desc: Set the msi descriptor for an interrupt
@@ -438,8 +439,9 @@ struct msi_domain_info;
438439
* @get_hwirq, @msi_init and @msi_free are callbacks used by the underlying
439440
* irqdomain.
440441
*
441-
* @msi_check, @msi_prepare, @prepare_desc and @set_desc are callbacks used by the
442-
* msi_domain_alloc/free_irqs*() variants.
442+
* @msi_check, @msi_prepare, @msi_teardown, @prepare_desc and
443+
* @set_desc are callbacks used by the msi_domain_alloc/free_irqs*()
444+
* variants.
443445
*
444446
* @domain_alloc_irqs, @domain_free_irqs can be used to override the
445447
* default allocation/free functions (__msi_domain_alloc/free_irqs). This
@@ -461,6 +463,8 @@ struct msi_domain_ops {
461463
int (*msi_prepare)(struct irq_domain *domain,
462464
struct device *dev, int nvec,
463465
msi_alloc_info_t *arg);
466+
void (*msi_teardown)(struct irq_domain *domain,
467+
msi_alloc_info_t *arg);
464468
void (*prepare_desc)(struct irq_domain *domain, msi_alloc_info_t *arg,
465469
struct msi_desc *desc);
466470
void (*set_desc)(msi_alloc_info_t *arg,
@@ -489,6 +493,7 @@ struct msi_domain_ops {
489493
* @handler: Optional: associated interrupt flow handler
490494
* @handler_data: Optional: associated interrupt flow handler data
491495
* @handler_name: Optional: associated interrupt flow handler name
496+
* @alloc_data: Optional: associated interrupt allocation data
492497
* @data: Optional: domain specific data
493498
*/
494499
struct msi_domain_info {
@@ -501,6 +506,7 @@ struct msi_domain_info {
501506
irq_flow_handler_t handler;
502507
void *handler_data;
503508
const char *handler_name;
509+
msi_alloc_info_t *alloc_data;
504510
void *data;
505511
};
506512

kernel/irq/msi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,11 @@ static int msi_domain_ops_prepare(struct irq_domain *domain, struct device *dev,
795795
return 0;
796796
}
797797

798+
static void msi_domain_ops_teardown(struct irq_domain *domain,
799+
msi_alloc_info_t *arg)
800+
{
801+
}
802+
798803
static void msi_domain_ops_set_desc(msi_alloc_info_t *arg,
799804
struct msi_desc *desc)
800805
{
@@ -820,6 +825,7 @@ static struct msi_domain_ops msi_domain_ops_default = {
820825
.get_hwirq = msi_domain_ops_get_hwirq,
821826
.msi_init = msi_domain_ops_init,
822827
.msi_prepare = msi_domain_ops_prepare,
828+
.msi_teardown = msi_domain_ops_teardown,
823829
.set_desc = msi_domain_ops_set_desc,
824830
};
825831

@@ -841,6 +847,8 @@ static void msi_domain_update_dom_ops(struct msi_domain_info *info)
841847
ops->msi_init = msi_domain_ops_default.msi_init;
842848
if (ops->msi_prepare == NULL)
843849
ops->msi_prepare = msi_domain_ops_default.msi_prepare;
850+
if (ops->msi_teardown == NULL)
851+
ops->msi_teardown = msi_domain_ops_default.msi_teardown;
844852
if (ops->set_desc == NULL)
845853
ops->set_desc = msi_domain_ops_default.set_desc;
846854
}

0 commit comments

Comments
 (0)