Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1247910 > unrolled thread
| Started by | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| First post | 2015-10-15 17:50 +0200 |
| Last post | 2015-10-16 10:50 +0200 |
| Articles | 20 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH RFC 0/7] Adding core support for wire-MSI bridges Marc Zyngier <marc.zyngier@arm.com> - 2015-10-15 17:50 +0200
[PATCH RFC 2/7] platform-msi: Factor out allocation/free of private data Marc Zyngier <marc.zyngier@arm.com> - 2015-10-15 17:50 +0200
Re: [PATCH RFC 2/7] platform-msi: Factor out allocation/free of private data Jiang Liu <jiang.liu@linux.intel.com> - 2015-10-16 07:50 +0200
Re: [PATCH RFC 2/7] platform-msi: Factor out allocation/free of private data Marc Zyngier <marc.zyngier@arm.com> - 2015-10-16 11:00 +0200
[PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable Marc Zyngier <marc.zyngier@arm.com> - 2015-10-15 17:50 +0200
RE: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable Gabriele Paoloni <gabriele.paoloni@huawei.com> - 2015-10-15 19:30 +0200
Re: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable Marc Zyngier <marc.zyngier@arm.com> - 2015-10-15 19:40 +0200
RE: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable Gabriele Paoloni <gabriele.paoloni@huawei.com> - 2015-10-16 15:10 +0200
Re: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable Jiang Liu <jiang.liu@linux.intel.com> - 2015-10-16 07:50 +0200
Re: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable Marc Zyngier <marc.zyngier@arm.com> - 2015-10-16 10:50 +0200
Re: [PATCH RFC 0/7] Adding core support for wire-MSI bridges Arnd Bergmann <arnd@arndb.de> - 2015-10-15 17:50 +0200
Re: [PATCH RFC 0/7] Adding core support for wire-MSI bridges Marc Zyngier <marc.zyngier@arm.com> - 2015-10-15 18:10 +0200
Re: [PATCH RFC 0/7] Adding core support for wire-MSI bridges Arnd Bergmann <arnd@arndb.de> - 2015-10-15 21:20 +0200
Re: [PATCH RFC 0/7] Adding core support for wire-MSI bridges Marc Zyngier <marc.zyngier@arm.com> - 2015-10-16 10:10 +0200
Re: [PATCH RFC 0/7] Adding core support for wire-MSI bridges Arnd Bergmann <arnd@arndb.de> - 2015-10-16 10:50 +0200
[PATCH RFC 5/7] genirq/msi: Add msi_domain_populate_irqs Marc Zyngier <marc.zyngier@arm.com> - 2015-10-15 17:50 +0200
[PATCH RFC 1/7] platform-msi: Allow MSIs to be allocated in chunks Marc Zyngier <marc.zyngier@arm.com> - 2015-10-15 17:50 +0200
[PATCH RFC 6/7] platform-msi: Allow creation of a MSI-based stacked irq domain Marc Zyngier <marc.zyngier@arm.com> - 2015-10-15 17:50 +0200
Re: [PATCH RFC 0/7] Adding core support for wire-MSI bridges Jiang Liu <jiang.liu@linux.intel.com> - 2015-10-16 04:00 +0200
Re: [PATCH RFC 0/7] Adding core support for wire-MSI bridges Marc Zyngier <marc.zyngier@arm.com> - 2015-10-16 10:50 +0200
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-15 17:50 +0200 |
| Subject | [PATCH RFC 0/7] Adding core support for wire-MSI bridges |
| Message-ID | <qjSNk-2aP-7@gated-at.bofh.it> |
There seems to be a new class of interrupt controller out there whose
sole purpose (apart from making everybody's life a nightmare) is to
turn wired interrupts into MSIs.
Instead of considering that the MSIs allocated to a device are for the
direct use of that device, we can turn this set of MSIs into a irq
domain, and use that domain to build a standard irqchip on top of
that.
This requires some (slightly ugly) surgery in both the generic MSI and
platform MSI layers, but the amount of code is actually relatively
small (about +150 LoC so far).
On top of that, we add a dummy driver for a such a bridge, hoping that
this will give enough information to driver authors so that they can
use this new feature. An even more stupid client driver is provided to
show the interrupt stack allocation:
dummydev dummy-dev: Probing
dummydev dummy-dev: Allocated IRQ35
dummydev dummy-dev: Probing OK
dummydev dummy-dev: IRQ35 hwirq 5 domain msichip_domain_ops
dummydev dummy-dev: IRQ35 hwirq 0 domain msi_domain_ops
dummydev dummy-dev: IRQ35 hwirq 8192 domain its_domain_ops
dummydev dummy-dev: IRQ35 hwirq 8192 domain gic_irq_domain_ops
While this seems to work, it is far from being perfect:
- This is a prototype: error handling is rubbish, and there could be
better abstractions to use.
- It relies on not declaring this bridge with IRQCHIP_DECLARE in order
to prevent the DT layer from allocating interrupts behind our back.
- There is some probe ordering issues between the bridge and the wired
interrupt device, leading to the use of -EPROBE_DEFER.
The last two points could be addressed directly in the OF layer, as
this is a generic device ordering issue (and people are already
working on that).
I'd welcome any comment on that approach (though I'm going to make
myself scarse over the next two weeks).
Marc Zyngier (7):
platform-msi: Allow MSIs to be allocated in chunks
platform-msi: Factor out allocation/free of private data
irqdomain: Make irq_domain_alloc_irqs_recursive available
genirq/msi: Make the .prepare callback reusable
genirq/msi: Add msi_domain_populate_irqs
platform-msi: Allow creation of a MSI-based stacked irq domain
irqchip: [Example] dummy wired interrupt/MSI bridge driver
drivers/base/platform-msi.c | 185 ++++++++++++++++++++--------
drivers/irqchip/Kconfig | 7 ++
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-msichip.c | 271 ++++++++++++++++++++++++++++++++++++++++++
include/linux/irqdomain.h | 3 +
include/linux/msi.h | 16 +++
kernel/irq/irqdomain.c | 6 +-
kernel/irq/msi.c | 47 +++++++-
8 files changed, 481 insertions(+), 55 deletions(-)
create mode 100644 drivers/irqchip/irq-msichip.c
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-15 17:50 +0200 |
| Subject | [PATCH RFC 2/7] platform-msi: Factor out allocation/free of private data |
| Message-ID | <qjSX0-2mu-3@gated-at.bofh.it> |
| In reply to | #1247910 |
As we're going to have multiple paths to allocate/free the
platform-msi private data, factor this out into separate
utility functions.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
drivers/base/platform-msi.c | 84 ++++++++++++++++++++++++++-------------------
1 file changed, 48 insertions(+), 36 deletions(-)
diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c
index 6148c78..92666cd 100644
--- a/drivers/base/platform-msi.c
+++ b/drivers/base/platform-msi.c
@@ -189,21 +189,11 @@ struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode,
return domain;
}
-/**
- * platform_msi_domain_alloc_irqs - Allocate MSI interrupts for @dev
- * @dev: The device for which to allocate interrupts
- * @nvec: The number of interrupts to allocate
- * @write_msi_msg: Callback to write an interrupt message for @dev
- *
- * Returns:
- * Zero for success, or an error code in case of failure
- */
-int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
- irq_write_msi_msg_t write_msi_msg)
+static int platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec,
+ irq_write_msi_msg_t write_msi_msg,
+ struct platform_msi_priv_data **data)
{
- struct platform_msi_priv_data *priv_data;
- int err;
-
+ struct platform_msi_priv_data *datap;
/*
* Limit the number of interrupts to 256 per device. Should we
* need to bump this up, DEV_ID_SHIFT should be adjusted
@@ -222,22 +212,51 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
if (!list_empty(dev_to_msi_list(dev)))
return -EBUSY;
- priv_data = kzalloc(sizeof(*priv_data), GFP_KERNEL);
- if (!priv_data)
+ datap = *data = kzalloc(sizeof(**data), GFP_KERNEL);
+ if (!datap)
return -ENOMEM;
- priv_data->devid = ida_simple_get(&platform_msi_devid_ida,
- 0, 1 << DEV_ID_SHIFT, GFP_KERNEL);
- if (priv_data->devid < 0) {
- err = priv_data->devid;
- goto out_free_data;
+ datap->devid = ida_simple_get(&platform_msi_devid_ida,
+ 0, 1 << DEV_ID_SHIFT, GFP_KERNEL);
+ if (datap->devid < 0) {
+ int err = datap->devid;
+ kfree(*data);
+ return err;
}
- priv_data->write_msg = write_msi_msg;
+ datap->write_msg = write_msi_msg;
+
+ return 0;
+}
+
+static void platform_msi_free_priv_data(struct platform_msi_priv_data *data)
+{
+ ida_simple_remove(&platform_msi_devid_ida, data->devid);
+ kfree(data);
+}
+
+/**
+ * platform_msi_domain_alloc_irqs - Allocate MSI interrupts for @dev
+ * @dev: The device for which to allocate interrupts
+ * @nvec: The number of interrupts to allocate
+ * @write_msi_msg: Callback to write an interrupt message for @dev
+ *
+ * Returns:
+ * Zero for success, or an error code in case of failure
+ */
+int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
+ irq_write_msi_msg_t write_msi_msg)
+{
+ struct platform_msi_priv_data *priv_data;
+ int err;
+
+ err = platform_msi_alloc_priv_data(dev, nvec, write_msi_msg, &priv_data);
+ if (err)
+ return err;
err = platform_msi_alloc_descs(dev, nvec, priv_data);
if (err)
- goto out_free_id;
+ goto out_free_priv_data;
err = msi_domain_alloc_irqs(dev->msi_domain, dev, nvec);
if (err)
@@ -247,10 +266,8 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
out_free_desc:
platform_msi_free_descs(dev, 0, nvec);
-out_free_id:
- ida_simple_remove(&platform_msi_devid_ida, priv_data->devid);
-out_free_data:
- kfree(priv_data);
+out_free_priv_data:
+ platform_msi_free_priv_data(priv_data);
return err;
}
@@ -261,16 +278,11 @@ out_free_data:
*/
void platform_msi_domain_free_irqs(struct device *dev)
{
- struct msi_desc *desc;
-
- desc = first_msi_entry(dev);
- if (desc) {
- struct platform_msi_priv_data *data;
-
- data = desc->platform.msi_priv_data;
+ if (!list_empty(dev_to_msi_list(dev))) {
+ struct msi_desc *desc;
- ida_simple_remove(&platform_msi_devid_ida, data->devid);
- kfree(data);
+ desc = first_msi_entry(dev);
+ platform_msi_free_priv_data(desc->platform.msi_priv_data);
}
msi_domain_free_irqs(dev->msi_domain, dev);
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jiang Liu <jiang.liu@linux.intel.com> |
|---|---|
| Date | 2015-10-16 07:50 +0200 |
| Subject | Re: [PATCH RFC 2/7] platform-msi: Factor out allocation/free of private data |
| Message-ID | <qk63T-5e3-7@gated-at.bofh.it> |
| In reply to | #1247911 |
On 2015/10/15 23:39, Marc Zyngier wrote: > As we're going to have multiple paths to allocate/free the > platform-msi private data, factor this out into separate > utility functions. > > Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> > --- > drivers/base/platform-msi.c | 84 ++++++++++++++++++++++++++------------------- > 1 file changed, 48 insertions(+), 36 deletions(-) > > diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c > index 6148c78..92666cd 100644 > --- a/drivers/base/platform-msi.c > +++ b/drivers/base/platform-msi.c > @@ -189,21 +189,11 @@ struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode, > return domain; > } > > -/** > - * platform_msi_domain_alloc_irqs - Allocate MSI interrupts for @dev > - * @dev: The device for which to allocate interrupts > - * @nvec: The number of interrupts to allocate > - * @write_msi_msg: Callback to write an interrupt message for @dev > - * > - * Returns: > - * Zero for success, or an error code in case of failure > - */ > -int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, > - irq_write_msi_msg_t write_msi_msg) > +static int platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec, > + irq_write_msi_msg_t write_msi_msg, > + struct platform_msi_priv_data **data) How about making platform_msi_alloc_priv_data() return a pointer instead of an int, that may simplify the code a bit. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-16 11:00 +0200 |
| Subject | Re: [PATCH RFC 2/7] platform-msi: Factor out allocation/free of private data |
| Message-ID | <qk91N-1e0-37@gated-at.bofh.it> |
| In reply to | #1248351 |
On 16/10/15 06:46, Jiang Liu wrote: > On 2015/10/15 23:39, Marc Zyngier wrote: >> As we're going to have multiple paths to allocate/free the >> platform-msi private data, factor this out into separate >> utility functions. >> >> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> >> --- >> drivers/base/platform-msi.c | 84 ++++++++++++++++++++++++++------------------- >> 1 file changed, 48 insertions(+), 36 deletions(-) >> >> diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c >> index 6148c78..92666cd 100644 >> --- a/drivers/base/platform-msi.c >> +++ b/drivers/base/platform-msi.c >> @@ -189,21 +189,11 @@ struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode, >> return domain; >> } >> >> -/** >> - * platform_msi_domain_alloc_irqs - Allocate MSI interrupts for @dev >> - * @dev: The device for which to allocate interrupts >> - * @nvec: The number of interrupts to allocate >> - * @write_msi_msg: Callback to write an interrupt message for @dev >> - * >> - * Returns: >> - * Zero for success, or an error code in case of failure >> - */ >> -int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, >> - irq_write_msi_msg_t write_msi_msg) >> +static int platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec, >> + irq_write_msi_msg_t write_msi_msg, >> + struct platform_msi_priv_data **data) > How about making platform_msi_alloc_priv_data() return a pointer > instead of an int, that may simplify the code a bit. > That's a good point. I could encode the error code in the return pointer (PTR_ERR). Thanks, M. -- Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-15 17:50 +0200 |
| Subject | [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable |
| Message-ID | <qjSX0-2mu-5@gated-at.bofh.it> |
| In reply to | #1247910 |
The .prepare callbacks are so far only called from msi_domain_alloc_irqs.
In order to reuse that code, split that code and create a
msi_domain_prepare_irqs function that the existing code can call into.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
include/linux/msi.h | 4 ++++
kernel/irq/msi.c | 20 +++++++++++++++++---
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 32a24b9..5bb36a9 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -277,6 +277,10 @@ struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode,
int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
irq_write_msi_msg_t write_msi_msg);
void platform_msi_domain_free_irqs(struct device *dev);
+
+/* When an MSI domain is used as an intermediate domain */
+int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
+ int nvec, msi_alloc_info_t *args);
#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */
#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 95354bb..8e6e112 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -256,6 +256,22 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
&msi_domain_ops, info);
}
+int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
+ int nvec, msi_alloc_info_t *arg)
+{
+ struct msi_domain_info *info = domain->host_data;
+ struct msi_domain_ops *ops = info->ops;
+ int ret;
+
+ ret = ops->msi_check(domain, info, dev);
+ if (ret == 0)
+ ret = ops->msi_prepare(domain, dev, nvec, arg);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
/**
* msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain
* @domain: The domain to allocate from
@@ -274,9 +290,7 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
struct msi_desc *desc;
int i, ret, virq = -1;
- ret = ops->msi_check(domain, info, dev);
- if (ret == 0)
- ret = ops->msi_prepare(domain, dev, nvec, &arg);
+ ret = msi_domain_prepare_irqs(domain, dev, nvec, &arg);
if (ret)
return ret;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Gabriele Paoloni <gabriele.paoloni@huawei.com> |
|---|---|
| Date | 2015-10-15 19:30 +0200 |
| Subject | RE: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable |
| Message-ID | <qjUvM-4Ij-7@gated-at.bofh.it> |
| In reply to | #1247912 |
SGkgTWFyYw0KDQpJdCBsb29rcyBsaWtlIHRoaXMgcGF0Y2ggZmFpbHMgdG8gYXBwbHkgdG8gNC4z LXJjNS4uLi4NCg0KR2FiDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTog bGludXgtcGNpLW93bmVyQHZnZXIua2VybmVsLm9yZyBbbWFpbHRvOmxpbnV4LXBjaS0NCj4gb3du ZXJAdmdlci5rZXJuZWwub3JnXSBPbiBCZWhhbGYgT2YgTWFyYyBaeW5naWVyDQo+IFNlbnQ6IFRo dXJzZGF5LCBPY3RvYmVyIDE1LCAyMDE1IDQ6MzkgUE0NCj4gVG86IFRob21hcyBHbGVpeG5lcjsg SmlhbmcgTGl1OyBKYXNvbiBDb29wZXINCj4gQ2M6IG1hanVuIChGKTsgbGludXgtYXJtLWtlcm5l bEBsaXN0cy5pbmZyYWRlYWQub3JnOyBsaW51eC0NCj4gcGNpQHZnZXIua2VybmVsLm9yZzsgbGlu dXgta2VybmVsQHZnZXIua2VybmVsLm9yZw0KPiBTdWJqZWN0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ZWMsICZhcmcpOw0KPiAg CWlmIChyZXQpDQo+ICAJCXJldHVybiByZXQ7DQo+IA0KPiAtLQ0KPiAyLjEuNA0KPiANCj4gLS0N Cj4gVG8gdW5zdWJzY3JpYmUgZnJvbSB0aGlzIGxpc3Q6IHNlbmQgdGhlIGxpbmUgInVuc3Vic2Ny aWJlIGxpbnV4LXBjaSIgaW4NCj4gdGhlIGJvZHkgb2YgYSBtZXNzYWdlIHRvIG1ham9yZG9tb0B2 Z2VyLmtlcm5lbC5vcmcNCj4gTW9yZSBtYWpvcmRvbW8gaW5mbyBhdCAgaHR0cDovL3ZnZXIua2Vy bmVsLm9yZy9tYWpvcmRvbW8taW5mby5odG1sDQo= -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-15 19:40 +0200 |
| Subject | Re: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable |
| Message-ID | <qjUFs-4Ty-13@gated-at.bofh.it> |
| In reply to | #1248027 |
On 15/10/15 18:24, Gabriele Paoloni wrote: > Hi Marc > > It looks like this patch fails to apply to 4.3-rc5.... Which is by design. Try tip/irq/core. M. -- Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Gabriele Paoloni <gabriele.paoloni@huawei.com> |
|---|---|
| Date | 2015-10-16 15:10 +0200 |
| Subject | RE: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable |
| Message-ID | <qkcVI-7cO-19@gated-at.bofh.it> |
| In reply to | #1248035 |
PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ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ZSBsaW51eC1rZXJuZWwiDQo+IGluDQo+IHRo ZSBib2R5IG9mIGEgbWVzc2FnZSB0byBtYWpvcmRvbW9Admdlci5rZXJuZWwub3JnDQo+IE1vcmUg bWFqb3Jkb21vIGluZm8gYXQgIGh0dHA6Ly92Z2VyLmtlcm5lbC5vcmcvbWFqb3Jkb21vLWluZm8u aHRtbA0KPiBQbGVhc2UgcmVhZCB0aGUgRkFRIGF0ICBodHRwOi8vd3d3LnR1eC5vcmcvbGttbC8N Cg== -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jiang Liu <jiang.liu@linux.intel.com> |
|---|---|
| Date | 2015-10-16 07:50 +0200 |
| Subject | Re: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable |
| Message-ID | <qk63U-5e3-19@gated-at.bofh.it> |
| In reply to | #1247912 |
On 2015/10/15 23:39, Marc Zyngier wrote:
<snit>
> +int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
> + int nvec, msi_alloc_info_t *arg)
> +{
> + struct msi_domain_info *info = domain->host_data;
> + struct msi_domain_ops *ops = info->ops;
> + int ret;
> +
> + ret = ops->msi_check(domain, info, dev);
> + if (ret == 0)
> + ret = ops->msi_prepare(domain, dev, nvec, arg);
> + if (ret)
> + return ret;
> +
> + return 0;
Seems a simple "return ret" is enough:)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-16 10:50 +0200 |
| Subject | Re: [PATCH RFC 4/7] genirq/msi: Make the .prepare callback reusable |
| Message-ID | <qk8S7-12c-21@gated-at.bofh.it> |
| In reply to | #1248355 |
On 16/10/15 06:45, Jiang Liu wrote:
> On 2015/10/15 23:39, Marc Zyngier wrote:
> <snit>
>> +int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
>> + int nvec, msi_alloc_info_t *arg)
>> +{
>> + struct msi_domain_info *info = domain->host_data;
>> + struct msi_domain_ops *ops = info->ops;
>> + int ret;
>> +
>> + ret = ops->msi_check(domain, info, dev);
>> + if (ret == 0)
>> + ret = ops->msi_prepare(domain, dev, nvec, arg);
>> + if (ret)
>> + return ret;
>> +
>> + return 0;
> Seems a simple "return ret" is enough:)
Ah! yes! ;-)
M.
--
Jazz is not dead. It just smells funny...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-10-15 17:50 +0200 |
| Message-ID | <qjSX0-2mu-15@gated-at.bofh.it> |
| In reply to | #1247910 |
On Thursday 15 October 2015 16:39:21 Marc Zyngier wrote: > There seems to be a new class of interrupt controller out there whose > sole purpose (apart from making everybody's life a nightmare) is to > turn wired interrupts into MSIs. > > Instead of considering that the MSIs allocated to a device are for the > direct use of that device, we can turn this set of MSIs into a irq > domain, and use that domain to build a standard irqchip on top of > that. > > This requires some (slightly ugly) surgery in both the generic MSI and > platform MSI layers, but the amount of code is actually relatively > small (about +150 LoC so far). > > On top of that, we add a dummy driver for a such a bridge, hoping that > this will give enough information to driver authors so that they can > use this new feature. An even more stupid client driver is provided to > show the interrupt stack allocation: I'm pretty sure you've thought of this before and it doesn't work, but can you explain why we can't just treat this as an edge-triggered nested irqchip? As long as the weird hardware can be preconfigured by the bootloader, the device that is attached to it shouldn't care how the interrupt ends up at the CPU. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-15 18:10 +0200 |
| Message-ID | <qjTgm-2Z7-15@gated-at.bofh.it> |
| In reply to | #1247916 |
Hi Arnd, On 15/10/15 16:46, Arnd Bergmann wrote: > On Thursday 15 October 2015 16:39:21 Marc Zyngier wrote: >> There seems to be a new class of interrupt controller out there whose >> sole purpose (apart from making everybody's life a nightmare) is to >> turn wired interrupts into MSIs. >> >> Instead of considering that the MSIs allocated to a device are for the >> direct use of that device, we can turn this set of MSIs into a irq >> domain, and use that domain to build a standard irqchip on top of >> that. >> >> This requires some (slightly ugly) surgery in both the generic MSI and >> platform MSI layers, but the amount of code is actually relatively >> small (about +150 LoC so far). >> >> On top of that, we add a dummy driver for a such a bridge, hoping that >> this will give enough information to driver authors so that they can >> use this new feature. An even more stupid client driver is provided to >> show the interrupt stack allocation: > > I'm pretty sure you've thought of this before and it doesn't work, but > can you explain why we can't just treat this as an edge-triggered > nested irqchip? As long as the weird hardware can be preconfigured > by the bootloader, the device that is attached to it shouldn't > care how the interrupt ends up at the CPU. "Preconfigured" is the key word. While you can do something like that if your hardware treats MSIs just as if they were wired interrupts (something like GICv2m), it becomes far more hairy if the target of MSIs is something like a GICv3 ITS (which is the case for HiSilicon mbigen). The main reason is that the ITS relies on "translation tables" kept in memory, which the OS has to configure, and handing over pre-configured tables is not something I'm looking forward to doing. From a CPU point of view, this is akin entering the kernel with the MMU already on and no idmap... The approach taken here is to make the MSI-ness explicit at the irqchip level, and keep the interrupting device oblivious of that feature. Also, this relies on the fact that we can have one MSI per wire, meaning that we don't have to multiplex anything (no nested irqchip), and that we can rely on hierarchical domains, which simplifies the code (at least for the irqchip). Thanks, M. -- Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-10-15 21:20 +0200 |
| Message-ID | <qjWed-7ns-1@gated-at.bofh.it> |
| In reply to | #1247937 |
On Thursday 15 October 2015 17:01:02 Marc Zyngier wrote: > > "Preconfigured" is the key word. While you can do something like that if > your hardware treats MSIs just as if they were wired interrupts > (something like GICv2m), it becomes far more hairy if the target of MSIs > is something like a GICv3 ITS (which is the case for HiSilicon mbigen). > > The main reason is that the ITS relies on "translation tables" kept in > memory, which the OS has to configure, and handing over pre-configured > tables is not something I'm looking forward to doing. From a CPU point > of view, this is akin entering the kernel with the MMU already on and no > idmap... > > The approach taken here is to make the MSI-ness explicit at the irqchip > level, and keep the interrupting device oblivious of that feature. Also, > this relies on the fact that we can have one MSI per wire, meaning that > we don't have to multiplex anything (no nested irqchip), and that we can > rely on hierarchical domains, which simplifies the code (at least for > the irqchip). > Thanks, that already makes things much clearer. Just one more question: why can't those translation tables be configured statically by the irqchip driver? Is this all about being able to cut a few cycles in case of virtualization? I would assume that once you have gone through the overhead of having both an MSI and a normal interrupt line (with the need for serialization vs DMA), you can just as well trap to user space to deliver an IRQ to a guest. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-16 10:10 +0200 |
| Message-ID | <qk8fo-hv-11@gated-at.bofh.it> |
| In reply to | #1248092 |
On 15/10/15 20:16, Arnd Bergmann wrote: > On Thursday 15 October 2015 17:01:02 Marc Zyngier wrote: >> >> "Preconfigured" is the key word. While you can do something like that if >> your hardware treats MSIs just as if they were wired interrupts >> (something like GICv2m), it becomes far more hairy if the target of MSIs >> is something like a GICv3 ITS (which is the case for HiSilicon mbigen). >> >> The main reason is that the ITS relies on "translation tables" kept in >> memory, which the OS has to configure, and handing over pre-configured >> tables is not something I'm looking forward to doing. From a CPU point >> of view, this is akin entering the kernel with the MMU already on and no >> idmap... >> >> The approach taken here is to make the MSI-ness explicit at the irqchip >> level, and keep the interrupting device oblivious of that feature. Also, >> this relies on the fact that we can have one MSI per wire, meaning that >> we don't have to multiplex anything (no nested irqchip), and that we can >> rely on hierarchical domains, which simplifies the code (at least for >> the irqchip). >> > > Thanks, that already makes things much clearer. Just one more question: > why can't those translation tables be configured statically by the > irqchip driver? Is this all about being able to cut a few cycles > in case of virtualization? Having a static configuration, while doable, complicates things for everybody else. The LPI number used by the irqchip would need to be put an some "exclusion list" to make sure it is not reallocated for other subsystems (e.g PCI). The translation tables also define the target CPU, which could cause interesting problems once combined with CPU hotplug if the ITS is not completely in control of it. I'm not really getting your point about virtualization though. > I would assume that once you have gone through the overhead of having > both an MSI and a normal interrupt line (with the need for > serialization vs DMA), you can just as well trap to user space to > deliver an IRQ to a guest. The whole idea behind this bridge is to move wired interrupts to the periphery of a SoC. I don't think virtualization was part of the equation, but of course I can't speak for the "geniuses" behind the idea. Or maybe I'm reading your question the wrong way, which is entirely possible given the lack of caffeine. Thanks, M. -- Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-10-16 10:50 +0200 |
| Message-ID | <qk8S6-12c-15@gated-at.bofh.it> |
| In reply to | #1248447 |
On Friday 16 October 2015 09:03:14 Marc Zyngier wrote: > On 15/10/15 20:16, Arnd Bergmann wrote: > > On Thursday 15 October 2015 17:01:02 Marc Zyngier wrote: > >> > >> "Preconfigured" is the key word. While you can do something like that if > >> your hardware treats MSIs just as if they were wired interrupts > >> (something like GICv2m), it becomes far more hairy if the target of MSIs > >> is something like a GICv3 ITS (which is the case for HiSilicon mbigen). > >> > >> The main reason is that the ITS relies on "translation tables" kept in > >> memory, which the OS has to configure, and handing over pre-configured > >> tables is not something I'm looking forward to doing. From a CPU point > >> of view, this is akin entering the kernel with the MMU already on and no > >> idmap... > >> > >> The approach taken here is to make the MSI-ness explicit at the irqchip > >> level, and keep the interrupting device oblivious of that feature. Also, > >> this relies on the fact that we can have one MSI per wire, meaning that > >> we don't have to multiplex anything (no nested irqchip), and that we can > >> rely on hierarchical domains, which simplifies the code (at least for > >> the irqchip). > >> > > > > Thanks, that already makes things much clearer. Just one more question: > > why can't those translation tables be configured statically by the > > irqchip driver? Is this all about being able to cut a few cycles > > in case of virtualization? > > Having a static configuration, while doable, complicates things for > everybody else. The LPI number used by the irqchip would need to be put > an some "exclusion list" to make sure it is not reallocated for other > subsystems (e.g PCI). The translation tables also define the target CPU, > which could cause interesting problems once combined with CPU hotplug if > the ITS is not completely in control of it. > > I'm not really getting your point about virtualization though. I think I'm mainly still confused by how MSI is implemented on the CPU side. Your explanation makes sense though. > > I would assume that once you have gone through the overhead of having > > both an MSI and a normal interrupt line (with the need for > > serialization vs DMA), you can just as well trap to user space to > > deliver an IRQ to a guest. > > The whole idea behind this bridge is to move wired interrupts to the > periphery of a SoC. I don't think virtualization was part of the > equation, but of course I can't speak for the "geniuses" behind the idea. > > Or maybe I'm reading your question the wrong way, which is entirely > possible given the lack of caffeine. No, I think I get it now. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-15 17:50 +0200 |
| Subject | [PATCH RFC 5/7] genirq/msi: Add msi_domain_populate_irqs |
| Message-ID | <qjSX1-2mu-31@gated-at.bofh.it> |
| In reply to | #1247910 |
To be able to allocate interrupts from the MSI layer down,
add a new msi_domain_populate_irqs entry point.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
include/linux/msi.h | 2 ++
kernel/irq/msi.c | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 5bb36a9..e35558c 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -281,6 +281,8 @@ void platform_msi_domain_free_irqs(struct device *dev);
/* When an MSI domain is used as an intermediate domain */
int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
int nvec, msi_alloc_info_t *args);
+int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
+ int virq, int nvec, msi_alloc_info_t *args);
#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */
#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 8e6e112..53118e9 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -272,6 +272,33 @@ int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
return 0;
}
+int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
+ int virq, int nvec, msi_alloc_info_t *arg)
+{
+ struct msi_domain_info *info = domain->host_data;
+ struct msi_domain_ops *ops = info->ops;
+ struct msi_desc *desc;
+
+ for_each_msi_entry(desc, dev) {
+ int i, ret;
+
+ if (!(desc->irq >= virq && desc->irq < (virq + nvec)))
+ continue;
+
+ ops->set_desc(arg, desc);
+ /* Assumes the domain mutex is held! */
+ ret = irq_domain_alloc_irqs_recursive(domain, virq, nvec, arg);
+ /* FIXME: Error handling */
+ if (ret)
+ return ret;
+
+ for (i = 0; i < desc->nvec_used; i++)
+ irq_set_msi_desc_off(virq, i, desc);
+ }
+
+ return 0;
+}
+
/**
* msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain
* @domain: The domain to allocate from
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-15 17:50 +0200 |
| Subject | [PATCH RFC 1/7] platform-msi: Allow MSIs to be allocated in chunks |
| Message-ID | <qjSX1-2mu-41@gated-at.bofh.it> |
| In reply to | #1247910 |
MSIs for a given device are normally all allocated in one go.
Make sure the internal code can allocate them one at a time
if required.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
drivers/base/platform-msi.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c
index 5df4575..6148c78 100644
--- a/drivers/base/platform-msi.c
+++ b/drivers/base/platform-msi.c
@@ -25,6 +25,7 @@
#include <linux/slab.h>
#define DEV_ID_SHIFT 24
+#define MAX_DEV_MSIS (1 << (32 - DEV_ID_SHIFT))
/*
* Internal data structure containing a (made up, but unique) devid
@@ -110,13 +111,16 @@ static void platform_msi_update_chip_ops(struct msi_domain_info *info)
chip->irq_write_msi_msg = platform_msi_write_msg;
}
-static void platform_msi_free_descs(struct device *dev)
+static void platform_msi_free_descs(struct device *dev, int base, int nvec)
{
struct msi_desc *desc, *tmp;
list_for_each_entry_safe(desc, tmp, dev_to_msi_list(dev), list) {
- list_del(&desc->list);
- free_msi_entry(desc);
+ if (desc->platform.msi_index >= base &&
+ desc->platform.msi_index < (base + nvec)) {
+ list_del(&desc->list);
+ free_msi_entry(desc);
+ }
}
}
@@ -124,17 +128,22 @@ static int platform_msi_alloc_descs(struct device *dev, int nvec,
struct platform_msi_priv_data *data)
{
- int i;
+ struct msi_desc *desc;
+ int i, base = 0;
- for (i = 0; i < nvec; i++) {
- struct msi_desc *desc;
+ if (!list_empty(dev_to_msi_list(dev))) {
+ desc = list_last_entry(dev_to_msi_list(dev),
+ struct msi_desc, list);
+ base = desc->platform.msi_index + 1;
+ }
+ for (i = 0; i < nvec; i++) {
desc = alloc_msi_entry(dev);
if (!desc)
break;
desc->platform.msi_priv_data = data;
- desc->platform.msi_index = i;
+ desc->platform.msi_index = base + i;
desc->nvec_used = 1;
list_add_tail(&desc->list, dev_to_msi_list(dev));
@@ -142,7 +151,7 @@ static int platform_msi_alloc_descs(struct device *dev, int nvec,
if (i != nvec) {
/* Clean up the mess */
- platform_msi_free_descs(dev);
+ platform_msi_free_descs(dev, base, nvec);
return -ENOMEM;
}
@@ -201,8 +210,7 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
* accordingly (which would impact the max number of MSI
* capable devices).
*/
- if (!dev->msi_domain || !write_msi_msg || !nvec ||
- nvec > (1 << (32 - DEV_ID_SHIFT)))
+ if (!dev->msi_domain || !write_msi_msg || !nvec || nvec > MAX_DEV_MSIS)
return -EINVAL;
if (dev->msi_domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) {
@@ -238,7 +246,7 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
return 0;
out_free_desc:
- platform_msi_free_descs(dev);
+ platform_msi_free_descs(dev, 0, nvec);
out_free_id:
ida_simple_remove(&platform_msi_devid_ida, priv_data->devid);
out_free_data:
@@ -266,5 +274,5 @@ void platform_msi_domain_free_irqs(struct device *dev)
}
msi_domain_free_irqs(dev->msi_domain, dev);
- platform_msi_free_descs(dev);
+ platform_msi_free_descs(dev, 0, MAX_DEV_MSIS);
}
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-15 17:50 +0200 |
| Subject | [PATCH RFC 6/7] platform-msi: Allow creation of a MSI-based stacked irq domain |
| Message-ID | <qjSX1-2mu-45@gated-at.bofh.it> |
| In reply to | #1247910 |
We almost have all the needed bits to be able to create a irq domain
on top of a MSI domain.
For this, we enable a few things:
- the virq is stored in the msi_desc
- device, msi_alloc_info and domain-specific data
are stored in the platform_pric_data structure
- we introduce a new API for platform-msi:
/* Create a MSI-based domain */
struct irq_domain *
platform_msi_create_device_domain(struct device *dev,
unsigned int nvec,
irq_write_msi_msg_t write_msi_msg,
const struct irq_domain_ops *ops,
void *host_data);
/* Allocate MSIs in an MSI domain */
int platform_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
unsigned int nr_irqs);
/* Obtain the host data passed to platform_msi_create_device_domain */
void *platform_msi_get_host_data(struct irq_domain *domain);
This now allows a wired irq to MSI bridge to be created.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
drivers/base/platform-msi.c | 71 +++++++++++++++++++++++++++++++++++++++++++--
include/linux/msi.h | 10 +++++++
2 files changed, 79 insertions(+), 2 deletions(-)
diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c
index 92666cd..29e9b63 100644
--- a/drivers/base/platform-msi.c
+++ b/drivers/base/platform-msi.c
@@ -32,6 +32,9 @@
* and the callback to write the MSI message.
*/
struct platform_msi_priv_data {
+ struct device *dev;
+ void *host_data;
+ msi_alloc_info_t arg;
irq_write_msi_msg_t write_msg;
int devid;
};
@@ -124,8 +127,9 @@ static void platform_msi_free_descs(struct device *dev, int base, int nvec)
}
}
-static int platform_msi_alloc_descs(struct device *dev, int nvec,
- struct platform_msi_priv_data *data)
+static int platform_msi_alloc_descs_with_irq(struct device *dev, int virq,
+ int nvec,
+ struct platform_msi_priv_data *data)
{
struct msi_desc *desc;
@@ -145,6 +149,7 @@ static int platform_msi_alloc_descs(struct device *dev, int nvec,
desc->platform.msi_priv_data = data;
desc->platform.msi_index = base + i;
desc->nvec_used = 1;
+ desc->irq = virq ? virq + i : 0;
list_add_tail(&desc->list, dev_to_msi_list(dev));
}
@@ -159,6 +164,13 @@ static int platform_msi_alloc_descs(struct device *dev, int nvec,
return 0;
}
+static int platform_msi_alloc_descs(struct device *dev, int nvec,
+ struct platform_msi_priv_data *data)
+
+{
+ return platform_msi_alloc_descs_with_irq(dev, 0, nvec, data);
+}
+
/**
* platform_msi_create_irq_domain - Create a platform MSI interrupt domain
* @fwnode: Optional fwnode of the interrupt controller
@@ -225,6 +237,7 @@ static int platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec,
}
datap->write_msg = write_msi_msg;
+ datap->dev = dev;
return 0;
}
@@ -288,3 +301,57 @@ void platform_msi_domain_free_irqs(struct device *dev)
msi_domain_free_irqs(dev->msi_domain, dev);
platform_msi_free_descs(dev, 0, MAX_DEV_MSIS);
}
+
+void *platform_msi_get_host_data(struct irq_domain *domain)
+{
+ struct platform_msi_priv_data *data = domain->host_data;
+ return data->host_data;
+}
+
+struct irq_domain *
+platform_msi_create_device_domain(struct device *dev,
+ unsigned int nvec,
+ irq_write_msi_msg_t write_msi_msg,
+ const struct irq_domain_ops *ops,
+ void *host_data)
+{
+ struct platform_msi_priv_data *data;
+ struct irq_domain *domain;
+ int err;
+
+ err = platform_msi_alloc_priv_data(dev, nvec, write_msi_msg, &data);
+ if (err)
+ return NULL;
+
+ data->host_data = host_data;
+ domain = irq_domain_create_hierarchy(dev->msi_domain, 0, nvec,
+ of_node_to_fwnode(dev->of_node),
+ ops, data);
+ if (!domain) {
+ platform_msi_free_priv_data(data);
+ return NULL;
+ }
+
+ /* FIXME: Add better error handling... */
+ err = msi_domain_prepare_irqs(domain->parent, dev, nvec, &data->arg);
+ BUG_ON(err);
+
+ return domain;
+}
+
+int platform_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
+ unsigned int nr_irqs)
+{
+ struct platform_msi_priv_data *data = domain->host_data;
+ int err;
+
+ err = platform_msi_alloc_descs_with_irq(data->dev, virq, nr_irqs, data);
+ if (err)
+ return err;
+
+ err = msi_domain_populate_irqs(domain->parent, data->dev,
+ virq, nr_irqs, &data->arg);
+ /* FIXME: memory leak on error */
+ return err;
+}
+
diff --git a/include/linux/msi.h b/include/linux/msi.h
index e35558c..594b2113 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -172,6 +172,7 @@ struct msi_controller {
#include <asm/msi.h>
struct irq_domain;
+struct irq_domain_ops;
struct irq_chip;
struct device_node;
struct fwnode_handle;
@@ -283,6 +284,15 @@ int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
int nvec, msi_alloc_info_t *args);
int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
int virq, int nvec, msi_alloc_info_t *args);
+struct irq_domain *
+platform_msi_create_device_domain(struct device *dev,
+ unsigned int nvec,
+ irq_write_msi_msg_t write_msi_msg,
+ const struct irq_domain_ops *ops,
+ void *host_data);
+int platform_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
+ unsigned int nr_irqs);
+void *platform_msi_get_host_data(struct irq_domain *domain);
#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */
#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jiang Liu <jiang.liu@linux.intel.com> |
|---|---|
| Date | 2015-10-16 04:00 +0200 |
| Message-ID | <qk2tj-8h1-3@gated-at.bofh.it> |
| In reply to | #1247910 |
On 2015/10/15 23:39, Marc Zyngier wrote: > There seems to be a new class of interrupt controller out there whose > sole purpose (apart from making everybody's life a nightmare) is to > turn wired interrupts into MSIs. > > Instead of considering that the MSIs allocated to a device are for the > direct use of that device, we can turn this set of MSIs into a irq > domain, and use that domain to build a standard irqchip on top of > that. Hi Marc, There's a working to enable Intel VMD storage device, which has the similar requirement. Basically a PCIe hierarchy is hidden behind a parent PCIe device, so we need to use the PCIe irqs on parent to de-multiple PCIe IRQs from hidden PCIe devices. Seems a chance for consolidation here. cc Keith Busch <keith.busch@intel.com> who is the author of VMD device driver. Thanks! Gerry > > This requires some (slightly ugly) surgery in both the generic MSI and > platform MSI layers, but the amount of code is actually relatively > small (about +150 LoC so far). > > On top of that, we add a dummy driver for a such a bridge, hoping that > this will give enough information to driver authors so that they can > use this new feature. An even more stupid client driver is provided to > show the interrupt stack allocation: > > dummydev dummy-dev: Probing > dummydev dummy-dev: Allocated IRQ35 > dummydev dummy-dev: Probing OK > dummydev dummy-dev: IRQ35 hwirq 5 domain msichip_domain_ops > dummydev dummy-dev: IRQ35 hwirq 0 domain msi_domain_ops > dummydev dummy-dev: IRQ35 hwirq 8192 domain its_domain_ops > dummydev dummy-dev: IRQ35 hwirq 8192 domain gic_irq_domain_ops > > While this seems to work, it is far from being perfect: > > - This is a prototype: error handling is rubbish, and there could be > better abstractions to use. > > - It relies on not declaring this bridge with IRQCHIP_DECLARE in order > to prevent the DT layer from allocating interrupts behind our back. > > - There is some probe ordering issues between the bridge and the wired > interrupt device, leading to the use of -EPROBE_DEFER. > > The last two points could be addressed directly in the OF layer, as > this is a generic device ordering issue (and people are already > working on that). > > I'd welcome any comment on that approach (though I'm going to make > myself scarse over the next two weeks). > > Marc Zyngier (7): > platform-msi: Allow MSIs to be allocated in chunks > platform-msi: Factor out allocation/free of private data > irqdomain: Make irq_domain_alloc_irqs_recursive available > genirq/msi: Make the .prepare callback reusable > genirq/msi: Add msi_domain_populate_irqs > platform-msi: Allow creation of a MSI-based stacked irq domain > irqchip: [Example] dummy wired interrupt/MSI bridge driver > > drivers/base/platform-msi.c | 185 ++++++++++++++++++++-------- > drivers/irqchip/Kconfig | 7 ++ > drivers/irqchip/Makefile | 1 + > drivers/irqchip/irq-msichip.c | 271 ++++++++++++++++++++++++++++++++++++++++++ > include/linux/irqdomain.h | 3 + > include/linux/msi.h | 16 +++ > kernel/irq/irqdomain.c | 6 +- > kernel/irq/msi.c | 47 +++++++- > 8 files changed, 481 insertions(+), 55 deletions(-) > create mode 100644 drivers/irqchip/irq-msichip.c > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-10-16 10:50 +0200 |
| Message-ID | <qk8S6-12c-1@gated-at.bofh.it> |
| In reply to | #1248300 |
Hi Gerry, On 16/10/15 02:55, Jiang Liu wrote: > On 2015/10/15 23:39, Marc Zyngier wrote: >> There seems to be a new class of interrupt controller out there whose >> sole purpose (apart from making everybody's life a nightmare) is to >> turn wired interrupts into MSIs. >> >> Instead of considering that the MSIs allocated to a device are for the >> direct use of that device, we can turn this set of MSIs into a irq >> domain, and use that domain to build a standard irqchip on top of >> that. > Hi Marc, > There's a working to enable Intel VMD storage device, which > has the similar requirement. Basically a PCIe hierarchy is hidden > behind a parent PCIe device, so we need to use the PCIe irqs on parent > to de-multiple PCIe IRQs from hidden PCIe devices. Seems a chance for > consolidation here. Do you know if there is a 1-1 mapping between the interrupts seen by the parent device and those seen by the hidden devices? Or is it a case of having to demultiplex the MSIs? Looks like the former, but I'd like to be sure. I just had a quick look at the code there: https://lkml.org/lkml/2015/8/27/674 Is there anything more recent? > cc Keith Busch <keith.busch@intel.com> who is the author of > VMD device driver. Sure, will do when I repost this (probably in a few weeks), and assuming this fits the bill for Thomas and the MBIGEN folks. Thanks, M. -- Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web