diff mbox series

[V2,18/36] genirq/msi: Add msi_device_data::properties

Message ID 20211206210438.634566968@linutronix.de (mailing list archive)
State Superseded
Headers show
Series genirq/msi, PCI/MSI: Spring cleaning - Part 2 | expand

Commit Message

Thomas Gleixner Dec. 6, 2021, 10:39 p.m. UTC
Add a properties field which allows core code to store information for easy
retrieval in order to replace MSI descriptor fiddling.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
V2: Add a setter function to prepare for future changes
---
 include/linux/msi.h |   17 +++++++++++++++++
 kernel/irq/msi.c    |   24 ++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

Comments

Greg KH Dec. 7, 2021, 7:52 a.m. UTC | #1
On Mon, Dec 06, 2021 at 11:39:25PM +0100, Thomas Gleixner wrote:
> Add a properties field which allows core code to store information for easy
> retrieval in order to replace MSI descriptor fiddling.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cédric Le Goater Dec. 7, 2021, 9:04 a.m. UTC | #2
Hello Thomas,

On 12/6/21 23:39, Thomas Gleixner wrote:
> Add a properties field which allows core code to store information for easy
> retrieval in order to replace MSI descriptor fiddling.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> V2: Add a setter function to prepare for future changes
> ---
>   include/linux/msi.h |   17 +++++++++++++++++
>   kernel/irq/msi.c    |   24 ++++++++++++++++++++++++
>   2 files changed, 41 insertions(+)
> 
> --- a/include/linux/msi.h
> +++ b/include/linux/msi.h
> @@ -4,6 +4,7 @@
>   
>   #include <linux/cpumask.h>
>   #include <linux/list.h>
> +#include <linux/bits.h>
>   #include <asm/msi.h>
>   
>   /* Dummy shadow structures if an architecture does not define them */
> @@ -153,6 +154,22 @@ struct msi_device_data {
>   
>   int msi_setup_device_data(struct device *dev);
>   
> +/* MSI device properties */
> +#define MSI_PROP_PCI_MSI		BIT(0)
> +#define MSI_PROP_PCI_MSIX		BIT(1)
> +#define MSI_PROP_64BIT			BIT(2)
> +
> +#ifdef CONFIG_GENERIC_MSI_IRQ
> +bool msi_device_has_property(struct device *dev, unsigned long prop);
> +void msi_device_set_properties(struct device *dev, unsigned long prop);
> +#else
> +static inline bool msi_device_has_property(struct device *dev, unsigned long prop)
> +{
> +	return false;
> +}
> +static inline void msi_device_set_properties(struct device *dev, unsigned long prop) { }
> +#endif
> +
>   /* Helpers to hide struct msi_desc implementation details */
>   #define msi_desc_to_dev(desc)		((desc)->dev)
>   #define dev_to_msi_list(dev)		(&(dev)->msi_list)
> --- a/kernel/irq/msi.c
> +++ b/kernel/irq/msi.c
> @@ -60,6 +60,30 @@ void free_msi_entry(struct msi_desc *ent
>   	kfree(entry);
>   }
>   
> +/**
> + * msi_device_set_properties - Set device specific MSI properties
> + * @dev:	Pointer to the device which is queried
> + * @prop:	Properties to set
> + */
> +void msi_device_set_properties(struct device *dev, unsigned long prop)
> +{
> +	if (WARN_ON_ONCE(!dev->msi.data))
> +		return ;
> +	dev->msi.data->properties = 0;
It would work better if the prop variable was used instead of 0.

With that fixed,

Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.

> +}
> +
> +/**
> + * msi_device_has_property - Check whether a device has a specific MSI property
> + * @dev:	Pointer to the device which is queried
> + * @prop:	Property to check for
> + */
> +bool msi_device_has_property(struct device *dev, unsigned long prop)
> +{
> +	if (!dev->msi.data)
> +		return false;
> +	return !!(dev->msi.data->properties & prop);
> +}
> +
>   void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
>   {
>   	*msg = entry->msg;
>
Thomas Gleixner Dec. 7, 2021, 12:47 p.m. UTC | #3
On Tue, Dec 07 2021 at 10:04, Cédric Le Goater wrote:
>> +/**
>> + * msi_device_set_properties - Set device specific MSI properties
>> + * @dev:	Pointer to the device which is queried
>> + * @prop:	Properties to set
>> + */
>> +void msi_device_set_properties(struct device *dev, unsigned long prop)
>> +{
>> +	if (WARN_ON_ONCE(!dev->msi.data))
>> +		return ;
>> +	dev->msi.data->properties = 0;
> It would work better if the prop variable was used instead of 0.
>
> With that fixed,

Indeed. Copy & pasta w/o brain usage ...
Thomas Gleixner Dec. 7, 2021, 12:53 p.m. UTC | #4
On Tue, Dec 07 2021 at 13:47, Thomas Gleixner wrote:
> On Tue, Dec 07 2021 at 10:04, Cédric Le Goater wrote:
>>> +/**
>>> + * msi_device_set_properties - Set device specific MSI properties
>>> + * @dev:	Pointer to the device which is queried
>>> + * @prop:	Properties to set
>>> + */
>>> +void msi_device_set_properties(struct device *dev, unsigned long prop)
>>> +{
>>> +	if (WARN_ON_ONCE(!dev->msi.data))
>>> +		return ;
>>> +	dev->msi.data->properties = 0;
>> It would work better if the prop variable was used instead of 0.
>>
>> With that fixed,
>
> Indeed. Copy & pasta w/o brain usage ...

I've pushed out an incremental fix on top. Will be folded back.

     git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v2-part-3-1

Thanks,

        tglx
diff mbox series

Patch

--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -4,6 +4,7 @@ 
 
 #include <linux/cpumask.h>
 #include <linux/list.h>
+#include <linux/bits.h>
 #include <asm/msi.h>
 
 /* Dummy shadow structures if an architecture does not define them */
@@ -153,6 +154,22 @@  struct msi_device_data {
 
 int msi_setup_device_data(struct device *dev);
 
+/* MSI device properties */
+#define MSI_PROP_PCI_MSI		BIT(0)
+#define MSI_PROP_PCI_MSIX		BIT(1)
+#define MSI_PROP_64BIT			BIT(2)
+
+#ifdef CONFIG_GENERIC_MSI_IRQ
+bool msi_device_has_property(struct device *dev, unsigned long prop);
+void msi_device_set_properties(struct device *dev, unsigned long prop);
+#else
+static inline bool msi_device_has_property(struct device *dev, unsigned long prop)
+{
+	return false;
+}
+static inline void msi_device_set_properties(struct device *dev, unsigned long prop) { }
+#endif
+
 /* Helpers to hide struct msi_desc implementation details */
 #define msi_desc_to_dev(desc)		((desc)->dev)
 #define dev_to_msi_list(dev)		(&(dev)->msi_list)
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -60,6 +60,30 @@  void free_msi_entry(struct msi_desc *ent
 	kfree(entry);
 }
 
+/**
+ * msi_device_set_properties - Set device specific MSI properties
+ * @dev:	Pointer to the device which is queried
+ * @prop:	Properties to set
+ */
+void msi_device_set_properties(struct device *dev, unsigned long prop)
+{
+	if (WARN_ON_ONCE(!dev->msi.data))
+		return ;
+	dev->msi.data->properties = 0;
+}
+
+/**
+ * msi_device_has_property - Check whether a device has a specific MSI property
+ * @dev:	Pointer to the device which is queried
+ * @prop:	Property to check for
+ */
+bool msi_device_has_property(struct device *dev, unsigned long prop)
+{
+	if (!dev->msi.data)
+		return false;
+	return !!(dev->msi.data->properties & prop);
+}
+
 void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
 {
 	*msg = entry->msg;