2022-11-21 15:49:14

by Thomas Gleixner

[permalink] [raw]
Subject: [patch V2 19/33] genirq/msi: Provide msi_desc::msi_data

The upcoming support for PCI/IMS requires to store some information related
to the message handling in the MSI descriptor, e.g. PASID or a pointer to a
queue.

Provide a generic storage struct which maps over the existing PCI specific
storage which means the size of struct msi_desc is not getting bigger.

It contains a iomem pointer for device memory based IMS and a union of a
u64 and a void pointer which allows the device specific IMS implementations
to store the necessary information.

The iomem pointer is set up by the domain allocation functions.

The data union msi_dev_cookie is going to be handed in when allocating an
interrupt on an IMS domain so the irq chip callbacks of the IMS domain have
the necessary per vector information available. It also comes in handy when
cleaning up the platform MSI code for wire to MSI bridges which need to
hand down the type information to the underlying interrupt domain.

For the core code the cookie is opaque and meaningless. It just stores it
during an allocation through the upcoming interfaces for IMS and wire to
MSI brigdes.

Signed-off-by: Thomas Gleixner <[email protected]>
---
include/linux/msi.h | 38 +++++++++++++++++++++++++++++++++++++-
include/linux/msi_api.h | 17 +++++++++++++++++
2 files changed, 54 insertions(+), 1 deletion(-)

--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -125,6 +125,38 @@ struct pci_msi_desc {
};
};

+/**
+ * union msi_domain_cookie - Opaque MSI domain specific data
+ * @value: u64 value store
+ * @ptr: Pointer to domain specific data
+ * @iobase: Domain specific IOmem pointer
+ *
+ * The content of this data is implementation defined and used by the MSI
+ * domain to store domain specific information which is requried for
+ * interrupt chip callbacks.
+ */
+union msi_domain_cookie {
+ u64 value;
+ void *ptr;
+ void __iomem *iobase;
+};
+
+/**
+ * struct msi_desc_data - Generic MSI descriptor data
+ * @dcookie: Cookie for MSI domain specific data which is required
+ * for irq_chip callbacks
+ * @icookie: Cookie for the MSI interrupt instance provided by
+ * the usage site to the allocation function
+ *
+ * The content of this data is implementation defined, e.g. PCI/IMS
+ * implementations define the meaning of the data. The MSI core ignores
+ * this data completely.
+ */
+struct msi_desc_data {
+ union msi_domain_cookie dcookie;
+ union msi_instance_cookie icookie;
+};
+
#define MSI_MAX_INDEX ((unsigned int)USHRT_MAX)

/**
@@ -142,6 +174,7 @@ struct pci_msi_desc {
*
* @msi_index: Index of the msi descriptor
* @pci: PCI specific msi descriptor data
+ * @data: Generic MSI descriptor data
*/
struct msi_desc {
/* Shared device/bus type independent data */
@@ -161,7 +194,10 @@ struct msi_desc {
void *write_msi_msg_data;

u16 msi_index;
- struct pci_msi_desc pci;
+ union {
+ struct pci_msi_desc pci;
+ struct msi_desc_data data;
+ };
};

/*
--- a/include/linux/msi_api.h
+++ b/include/linux/msi_api.h
@@ -19,6 +19,23 @@ enum msi_domain_ids {
};

/**
+ * union msi_instance_cookie - MSI instance cookie
+ * @value: u64 value store
+ * @ptr: Pointer to usage site specific data
+ *
+ * This cookie is handed to the IMS allocation function and stored in the
+ * MSI descriptor for the interrupt chip callbacks.
+ *
+ * The content of this cookie is MSI domain implementation defined. For
+ * PCI/IMS implementations this could be a PASID or a pointer to queue
+ * memory.
+ */
+union msi_instance_cookie {
+ u64 value;
+ void *ptr;
+};
+
+/**
* msi_map - Mapping between MSI index and Linux interrupt number
* @index: The MSI index, e.g. slot in the MSI-X table or
* a software managed index if >= 0. If negative



2022-11-23 09:53:22

by Tian, Kevin

[permalink] [raw]
Subject: RE: [patch V2 19/33] genirq/msi: Provide msi_desc::msi_data

> From: Thomas Gleixner <[email protected]>
> Sent: Monday, November 21, 2022 10:38 PM
>
> The upcoming support for PCI/IMS requires to store some information
> related
> to the message handling in the MSI descriptor, e.g. PASID or a pointer to a
> queue.
>
> Provide a generic storage struct which maps over the existing PCI specific
> storage which means the size of struct msi_desc is not getting bigger.
>
> It contains a iomem pointer for device memory based IMS and a union of a
> u64 and a void pointer which allows the device specific IMS implementations
> to store the necessary information.

stale comment.

>
> The iomem pointer is set up by the domain allocation functions.
>
> The data union msi_dev_cookie is going to be handed in when allocating an

no msi_dev_cookie now.

2022-11-23 12:40:14

by Thomas Gleixner

[permalink] [raw]
Subject: RE: [patch V2 19/33] genirq/msi: Provide msi_desc::msi_data

On Wed, Nov 23 2022 at 08:27, Kevin Tian wrote:

>> From: Thomas Gleixner <[email protected]>
>> Sent: Monday, November 21, 2022 10:38 PM
>>
>> The upcoming support for PCI/IMS requires to store some information
>> related
>> to the message handling in the MSI descriptor, e.g. PASID or a pointer to a
>> queue.
>>
>> Provide a generic storage struct which maps over the existing PCI specific
>> storage which means the size of struct msi_desc is not getting bigger.
>>
>> It contains a iomem pointer for device memory based IMS and a union of a
>> u64 and a void pointer which allows the device specific IMS implementations
>> to store the necessary information.
>
> stale comment.
>
>>
>> The iomem pointer is set up by the domain allocation functions.
>>
>> The data union msi_dev_cookie is going to be handed in when allocating an
>
> no msi_dev_cookie now.

Ooops.