Commit fc8ab388 authored by Thomas Gleixner's avatar Thomas Gleixner

genirq/msi: Make descriptor allocation device domain aware

Change the descriptor allocation and insertion functions to take a domain
id to prepare for the upcoming multi MSI domain per device support.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Acked-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221124230314.163043028@linutronix.de
parent 1c893963
...@@ -286,7 +286,21 @@ static inline void msi_desc_set_iommu_cookie(struct msi_desc *desc, ...@@ -286,7 +286,21 @@ static inline void msi_desc_set_iommu_cookie(struct msi_desc *desc,
} }
#endif #endif
int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc); int msi_domain_insert_msi_desc(struct device *dev, unsigned int domid,
struct msi_desc *init_desc);
/**
* msi_insert_msi_desc - Allocate and initialize a MSI descriptor in the
* default irqdomain and insert it at @init_desc->msi_index
* @dev: Pointer to the device for which the descriptor is allocated
* @init_desc: Pointer to an MSI descriptor to initialize the new descriptor
*
* Return: 0 on success or an appropriate failure code.
*/
static inline int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc)
{
return msi_domain_insert_msi_desc(dev, MSI_DEFAULT_DOMAIN, init_desc);
}
void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index); void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index);
/** /**
......
...@@ -39,7 +39,7 @@ static inline int msi_sysfs_create_group(struct device *dev); ...@@ -39,7 +39,7 @@ static inline int msi_sysfs_create_group(struct device *dev);
* Return: pointer to allocated &msi_desc on success or %NULL on failure * Return: pointer to allocated &msi_desc on success or %NULL on failure
*/ */
static struct msi_desc *msi_alloc_desc(struct device *dev, int nvec, static struct msi_desc *msi_alloc_desc(struct device *dev, int nvec,
const struct irq_affinity_desc *affinity) const struct irq_affinity_desc *affinity)
{ {
struct msi_desc *desc = kzalloc(sizeof(*desc), GFP_KERNEL); struct msi_desc *desc = kzalloc(sizeof(*desc), GFP_KERNEL);
...@@ -64,9 +64,10 @@ static void msi_free_desc(struct msi_desc *desc) ...@@ -64,9 +64,10 @@ static void msi_free_desc(struct msi_desc *desc)
kfree(desc); kfree(desc);
} }
static int msi_insert_desc(struct msi_device_data *md, struct msi_desc *desc, unsigned int index) static int msi_insert_desc(struct msi_device_data *md, struct msi_desc *desc,
unsigned int domid, unsigned int index)
{ {
struct xarray *xa = &md->__domains[MSI_DEFAULT_DOMAIN].store; struct xarray *xa = &md->__domains[domid].store;
int ret; int ret;
desc->msi_index = index; desc->msi_index = index;
...@@ -77,15 +78,17 @@ static int msi_insert_desc(struct msi_device_data *md, struct msi_desc *desc, un ...@@ -77,15 +78,17 @@ static int msi_insert_desc(struct msi_device_data *md, struct msi_desc *desc, un
} }
/** /**
* msi_insert_msi_desc - Allocate and initialize a MSI descriptor and * msi_domain_insert_msi_desc - Allocate and initialize a MSI descriptor and
* insert it at @init_desc->msi_index * insert it at @init_desc->msi_index
* *
* @dev: Pointer to the device for which the descriptor is allocated * @dev: Pointer to the device for which the descriptor is allocated
* @domid: The id of the interrupt domain to which the desriptor is added
* @init_desc: Pointer to an MSI descriptor to initialize the new descriptor * @init_desc: Pointer to an MSI descriptor to initialize the new descriptor
* *
* Return: 0 on success or an appropriate failure code. * Return: 0 on success or an appropriate failure code.
*/ */
int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc) int msi_domain_insert_msi_desc(struct device *dev, unsigned int domid,
struct msi_desc *init_desc)
{ {
struct msi_desc *desc; struct msi_desc *desc;
...@@ -97,7 +100,8 @@ int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc) ...@@ -97,7 +100,8 @@ int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc)
/* Copy type specific data to the new descriptor. */ /* Copy type specific data to the new descriptor. */
desc->pci = init_desc->pci; desc->pci = init_desc->pci;
return msi_insert_desc(dev->msi.data, desc, init_desc->msi_index);
return msi_insert_desc(dev->msi.data, desc, domid, init_desc->msi_index);
} }
/** /**
...@@ -120,7 +124,7 @@ static int msi_add_simple_msi_descs(struct device *dev, unsigned int index, unsi ...@@ -120,7 +124,7 @@ static int msi_add_simple_msi_descs(struct device *dev, unsigned int index, unsi
desc = msi_alloc_desc(dev, 1, NULL); desc = msi_alloc_desc(dev, 1, NULL);
if (!desc) if (!desc)
goto fail_mem; goto fail_mem;
ret = msi_insert_desc(dev->msi.data, desc, idx); ret = msi_insert_desc(dev->msi.data, desc, MSI_DEFAULT_DOMAIN, idx);
if (ret) if (ret)
goto fail; goto fail;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment