Skip to content

Commit aaebdf8

Browse files
Julien GrallMarc Zyngier
authored andcommitted
genirq/msi: Add a new field in msi_desc to store an IOMMU cookie
When an MSI doorbell is located downstream of an IOMMU, it is required to swizzle the physical address with an appropriately-mapped IOVA for any device attached to one of our DMA ops domain. At the moment, the allocation of the mapping may be done when composing the message. However, the composing may be done in non-preemtible context while the allocation requires to be called from preemptible context. A follow-up change will split the current logic in two functions requiring to keep an IOMMU cookie per MSI. A new field is introduced in msi_desc to store an IOMMU cookie. As the cookie may not be required in some configuration, the field is protected under a new config CONFIG_IRQ_MSI_IOMMU. A pair of helpers has also been introduced to access the field. Signed-off-by: Julien Grall <julien.grall@arm.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent 009669e commit aaebdf8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

include/linux/msi.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ struct msi_desc {
8686
struct device *dev;
8787
struct msi_msg msg;
8888
struct irq_affinity_desc *affinity;
89+
#ifdef CONFIG_IRQ_MSI_IOMMU
90+
const void *iommu_cookie;
91+
#endif
8992

9093
union {
9194
/* PCI MSI/X specific data */
@@ -129,6 +132,29 @@ struct msi_desc {
129132
#define for_each_msi_entry_safe(desc, tmp, dev) \
130133
list_for_each_entry_safe((desc), (tmp), dev_to_msi_list((dev)), list)
131134

135+
#ifdef CONFIG_IRQ_MSI_IOMMU
136+
static inline const void *msi_desc_get_iommu_cookie(struct msi_desc *desc)
137+
{
138+
return desc->iommu_cookie;
139+
}
140+
141+
static inline void msi_desc_set_iommu_cookie(struct msi_desc *desc,
142+
const void *iommu_cookie)
143+
{
144+
desc->iommu_cookie = iommu_cookie;
145+
}
146+
#else
147+
static inline const void *msi_desc_get_iommu_cookie(struct msi_desc *desc)
148+
{
149+
return NULL;
150+
}
151+
152+
static inline void msi_desc_set_iommu_cookie(struct msi_desc *desc,
153+
const void *iommu_cookie)
154+
{
155+
}
156+
#endif
157+
132158
#ifdef CONFIG_PCI_MSI
133159
#define first_pci_msi_entry(pdev) first_msi_entry(&(pdev)->dev)
134160
#define for_each_pci_msi_entry(desc, pdev) \

kernel/irq/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ config GENERIC_MSI_IRQ_DOMAIN
9191
select IRQ_DOMAIN_HIERARCHY
9292
select GENERIC_MSI_IRQ
9393

94+
config IRQ_MSI_IOMMU
95+
bool
96+
9497
config HANDLE_DOMAIN_IRQ
9598
bool
9699

0 commit comments

Comments
 (0)