2022-11-11 13:58:18

by Thomas Gleixner

[permalink] [raw]
Subject: [patch 12/39] genirq/msi: Add bus token to struct msi_domain_info

From: Ahmed S. Darwish <[email protected]>

Add a bus token member to struct msi_domain_info and let
msi_create_irq_domain() set the bus token.

That allows to remove the bus token updates at the call sites.

Suggested-by: Thomas Gleixner <[email protected]>
Signed-off-by: Ahmed S. Darwish <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
---
include/linux/msi.h | 19 +++++++++++--------
kernel/irq/msi.c | 7 +++++--
2 files changed, 16 insertions(+), 10 deletions(-)

--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -16,6 +16,7 @@
* abuse. The only function which is relevant for drivers is msi_get_virq().
*/

+#include <linux/irqdomain_defs.h>
#include <linux/cpumask.h>
#include <linux/xarray.h>
#include <linux/mutex.h>
@@ -365,6 +366,7 @@ struct msi_domain_ops {
/**
* struct msi_domain_info - MSI interrupt domain data
* @flags: Flags to decribe features and capabilities
+ * @bus_token: The domain bus token
* @ops: The callback data structure
* @chip: Optional: associated interrupt chip
* @chip_data: Optional: associated interrupt chip data
@@ -374,14 +376,15 @@ struct msi_domain_ops {
* @data: Optional: domain specific data
*/
struct msi_domain_info {
- u32 flags;
- struct msi_domain_ops *ops;
- struct irq_chip *chip;
- void *chip_data;
- irq_flow_handler_t handler;
- void *handler_data;
- const char *handler_name;
- void *data;
+ u32 flags;
+ enum irq_domain_bus_token bus_token;
+ struct msi_domain_ops *ops;
+ struct irq_chip *chip;
+ void *chip_data;
+ irq_flow_handler_t handler;
+ void *handler_data;
+ const char *handler_name;
+ void *data;
};

/* Flags for msi_domain_info */
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -694,8 +694,11 @@ struct irq_domain *msi_create_irq_domain
domain = irq_domain_create_hierarchy(parent, IRQ_DOMAIN_FLAG_MSI, 0,
fwnode, &msi_domain_ops, info);

- if (domain && !domain->name && info->chip)
- domain->name = info->chip->name;
+ if (domain) {
+ if (!domain->name && info->chip)
+ domain->name = info->chip->name;
+ irq_domain_update_bus_token(domain, info->bus_token);
+ }

return domain;
}



2022-11-16 19:06:07

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: [patch 12/39] genirq/msi: Add bus token to struct msi_domain_info

On Fri, Nov 11, 2022 at 02:54:33PM +0100, Thomas Gleixner wrote:
> From: Ahmed S. Darwish <[email protected]>
>
> Add a bus token member to struct msi_domain_info and let
> msi_create_irq_domain() set the bus token.
>
> That allows to remove the bus token updates at the call sites.
>
> Suggested-by: Thomas Gleixner <[email protected]>
> Signed-off-by: Ahmed S. Darwish <[email protected]>
> Signed-off-by: Thomas Gleixner <[email protected]>
> ---
> include/linux/msi.h | 19 +++++++++++--------
> kernel/irq/msi.c | 7 +++++--
> 2 files changed, 16 insertions(+), 10 deletions(-)

Reviewed-by: Jason Gunthorpe <[email protected]>

> struct msi_domain_info {
> - u32 flags;
> - struct msi_domain_ops *ops;
> - struct irq_chip *chip;
> - void *chip_data;
> - irq_flow_handler_t handler;
> - void *handler_data;
> - const char *handler_name;
> - void *data;
> + u32 flags;
> + enum irq_domain_bus_token bus_token;
> + struct msi_domain_ops *ops;
> + struct irq_chip *chip;
> + void *chip_data;
> + irq_flow_handler_t handler;
> + void *handler_data;
> + const char *handler_name;
> + void *data;
> };

This is why I've been frowning on horizontal alignment :(

Jason

2022-11-16 23:09:48

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [patch 12/39] genirq/msi: Add bus token to struct msi_domain_info

On Wed, Nov 16 2022 at 13:49, Jason Gunthorpe wrote:

> On Fri, Nov 11, 2022 at 02:54:33PM +0100, Thomas Gleixner wrote:
>> From: Ahmed S. Darwish <[email protected]>
>>
>> Add a bus token member to struct msi_domain_info and let
>> msi_create_irq_domain() set the bus token.
>>
>> That allows to remove the bus token updates at the call sites.
>>
>> Suggested-by: Thomas Gleixner <[email protected]>
>> Signed-off-by: Ahmed S. Darwish <[email protected]>
>> Signed-off-by: Thomas Gleixner <[email protected]>
>> ---
>> include/linux/msi.h | 19 +++++++++++--------
>> kernel/irq/msi.c | 7 +++++--
>> 2 files changed, 16 insertions(+), 10 deletions(-)
>
> Reviewed-by: Jason Gunthorpe <[email protected]>
>
>> struct msi_domain_info {
>> - u32 flags;
>> - struct msi_domain_ops *ops;
>> - struct irq_chip *chip;
>> - void *chip_data;
>> - irq_flow_handler_t handler;
>> - void *handler_data;
>> - const char *handler_name;
>> - void *data;
>> + u32 flags;
>> + enum irq_domain_bus_token bus_token;
>> + struct msi_domain_ops *ops;
>> + struct irq_chip *chip;
>> + void *chip_data;
>> + irq_flow_handler_t handler;
>> + void *handler_data;
>> + const char *handler_name;
>> + void *data;
>> };
>
> This is why I've been frowning on horizontal alignment :(

Yes, it's annoying when you have to adjust it, but it's fundamentaly
simpler to parse than the clogged together word salad.

Subject: [tip: irq/core] genirq/msi: Add bus token to struct msi_domain_info

The following commit has been merged into the irq/core branch of tip:

Commit-ID: 22db089a4437a72277677f99717af499560b13f2
Gitweb: https://git.kernel.org/tip/22db089a4437a72277677f99717af499560b13f2
Author: Ahmed S. Darwish <[email protected]>
AuthorDate: Fri, 11 Nov 2022 14:54:33 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Thu, 17 Nov 2022 15:15:19 +01:00

genirq/msi: Add bus token to struct msi_domain_info

Add a bus token member to struct msi_domain_info and let
msi_create_irq_domain() set the bus token.

That allows to remove the bus token updates at the call sites.

Suggested-by: Thomas Gleixner <[email protected]>
Signed-off-by: Ahmed S. Darwish <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
include/linux/msi.h | 19 +++++++++++--------
kernel/irq/msi.c | 7 +++++--
2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/include/linux/msi.h b/include/linux/msi.h
index ee735ff..2dfd7b2 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -16,6 +16,7 @@
* abuse. The only function which is relevant for drivers is msi_get_virq().
*/

+#include <linux/irqdomain_defs.h>
#include <linux/cpumask.h>
#include <linux/xarray.h>
#include <linux/mutex.h>
@@ -365,6 +366,7 @@ struct msi_domain_ops {
/**
* struct msi_domain_info - MSI interrupt domain data
* @flags: Flags to decribe features and capabilities
+ * @bus_token: The domain bus token
* @ops: The callback data structure
* @chip: Optional: associated interrupt chip
* @chip_data: Optional: associated interrupt chip data
@@ -374,14 +376,15 @@ struct msi_domain_ops {
* @data: Optional: domain specific data
*/
struct msi_domain_info {
- u32 flags;
- struct msi_domain_ops *ops;
- struct irq_chip *chip;
- void *chip_data;
- irq_flow_handler_t handler;
- void *handler_data;
- const char *handler_name;
- void *data;
+ u32 flags;
+ enum irq_domain_bus_token bus_token;
+ struct msi_domain_ops *ops;
+ struct irq_chip *chip;
+ void *chip_data;
+ irq_flow_handler_t handler;
+ void *handler_data;
+ const char *handler_name;
+ void *data;
};

/* Flags for msi_domain_info */
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index a2efa00..b46b747 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -694,8 +694,11 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
domain = irq_domain_create_hierarchy(parent, IRQ_DOMAIN_FLAG_MSI, 0,
fwnode, &msi_domain_ops, info);

- if (domain && !domain->name && info->chip)
- domain->name = info->chip->name;
+ if (domain) {
+ if (!domain->name && info->chip)
+ domain->name = info->chip->name;
+ irq_domain_update_bus_token(domain, info->bus_token);
+ }

return domain;
}