Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1594208 > unrolled thread
| Started by | Hanjun Guo <guohanjun@huawei.com> |
|---|---|
| First post | 2017-03-07 14:00 +0100 |
| Last post | 2017-03-09 14:30 +0100 |
| Articles | 9 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v9 00/15] ACPI platform MSI support and its example mbigen Hanjun Guo <guohanjun@huawei.com> - 2017-03-07 14:00 +0100
[PATCH v9 12/15] msi: platform: make platform_msi_create_device_domain() ACPI aware Hanjun Guo <guohanjun@huawei.com> - 2017-03-07 14:00 +0100
[PATCH v9 15/15] irqchip: mbigen: Add ACPI support Hanjun Guo <guohanjun@huawei.com> - 2017-03-07 14:00 +0100
[PATCH v9 08/15] ACPI/IORT: Rename iort_node_map_rid() to make it generic Hanjun Guo <guohanjun@huawei.com> - 2017-03-07 14:00 +0100
[PATCH v9 11/15] ACPI: platform: setup MSI domain for ACPI based platform device Hanjun Guo <guohanjun@huawei.com> - 2017-03-07 14:00 +0100
[PATCH v9 14/15] irqchip: mbigen: introduce mbigen_of_create_domain() Hanjun Guo <guohanjun@huawei.com> - 2017-03-07 14:00 +0100
[PATCH v9 09/15] ACPI/IORT: Introduce iort_node_map_platform_id() to retrieve dev id Hanjun Guo <guohanjun@huawei.com> - 2017-03-07 14:10 +0100
Re: [PATCH v9 00/15] ACPI platform MSI support and its example mbigen Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-03-07 15:50 +0100
Re: [PATCH v9 00/15] ACPI platform MSI support and its example mbigen Hanjun Guo <hanjun.guo@linaro.org> - 2017-03-09 14:30 +0100
| From | Hanjun Guo <guohanjun@huawei.com> |
|---|---|
| Date | 2017-03-07 14:00 +0100 |
| Subject | [PATCH v9 00/15] ACPI platform MSI support and its example mbigen |
| Message-ID | <timIV-7Bl-3@gated-at.bofh.it> |
From: Hanjun Guo <hanjun.guo@linaro.org>
With platform msi support landed in the kernel, and the introduction
of IORT for GICv3 ITS (PCI MSI) and SMMU, the framework for platform msi
is ready, this patch set add few patches to enable the ACPI platform
msi support.
For platform device connecting to ITS on arm platform, we have IORT
table with the named componant node to describe the mappings of paltform
device and ITS, so we can retrieve the dev id and find its parent
irqdomain (ITS) from IORT table (simlar with the ACPI ITS support).
v8 -> v9:
- Rebased on top of 4.11-rc1 and retest;
- Some of patch's commit message was updated by Lorenzo and
it's clearer (thanks!)
No update in the code, hope it's the final revision.
v7 -> v8:
- Using _CRS instead of _PRS for Interrupt resources for mbigen
- reshuffle the patch slightly to introduce iort_node_map_platform_id()
first and then retrieve the dev id for platform MSI, no functional
change
- Fix the compile error with patch "irqchip: gicv3-its: platform-msi:
scan MADT to create platform msi domain", which forgot to add
<include/acpi_iort.h> (added in later patches in last version).
- renew some commit message which suggested by Lorenzo
- address some othe minor issues which commented by Lorenzo
- Add review and test tag as it's no functional change except
the last patch of mbigen
- rebase on top of 4.10-rc4 and test it on x86, ia64 and ARM64
platforms (also with Agustin's patch [1-2/3] "[PATCH V9 0/3] irqchip: qcom:
Add IRQ combiner driver" and Lorenzo's patch
https://patchwork.kernel.org/patch/9507041/)
v6 -> v7:
- Introduce iort_node_map_platform_id() to retrieve the
dev id for both NC (named component) -> ITS/SMMU and
NC -> SMMU -> ITS cases, suggested by Lorenzo;
- Reorder the patches and rewrite some commit message;
- Remove the test tags because it has major changes
to retrieve the dev id, Sinan, Majun, Xinwei, could
you please test them again on your platform?
- rebased on top of 4.10-rc3 and Lorenzo's patch
https://patchwork.kernel.org/patch/9507041/
- Tested against Agustin's patch [1-2/3] "[PATCH V9 0/3] irqchip: qcom:
Add IRQ combiner driver"
v5 -> v6:
- Call acpi_configure_pmsi_domain() for platform devices in
acpi_platform_notify() as it's cleaner (suggested by Rafael)
- Remove the "u8 type" for iort_id_map() because it's unused
- Rebase on top of 4.10-rc2
- Collect test and review tags
v4 -> v5:
- Add mbigen support back with tested on with Agustin's patchset,
and it's a good example of how ACPI platform MSI works
- rebased on top of lastest Linus tree (commit 52bce91 splice: reinstate SIGPIPE/EPIPE handling)
v3 -> v4:
- Drop mbi-gen patches to just submit platform msi support because
will rebase mbi-gen patches on top of Agustin's patchset, and discusion
is going there.
- Add a patch to support device topology such as NC(named componant, paltform device)
->SMMU->ITS which suggested by Lorenzo;
- rebased on top of Lorenzo's v9 of ACPI IORT ARM SMMU support;
- rebased on top of 4.9-rc7
v2 -> v3:
- Drop RFC tag
- Rebase against v4.9-rc2 and Lorenzo's v6 of ACPI IORT ARM SMMU support [1]
- Add 3 cleanup patches (patch 1, 2, 3)
- Drop arch_init call patch from last version
- Introduce a callback for platform device to set msi domain
- Introduce a new API to get paltform device's domain instead of
reusing the PCI one in previous version
- Add a patch to rework iort_node_get_id()
[1]: http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1251993.html
v1 -> v2:
- Fix the bug of if multi Interrupt() resoures in single _PRS,
we need to calculate all the irq numbers (I missed it in previous
version);
- Rebased on Marc's irq/irqchip-4.9 branch and Lorenzo's v5
SMMU patches (also Robin's SMMu patches)
- Add patch irqchip: mbigen: promote mbigen init.
Hanjun Guo (13):
ACPI/IORT: Fix the indentation in iort_scan_node()
ACPI/IORT: Add missing comment for iort_dev_find_its_id()
ACPI/IORT: Rework iort_match_node_callback() return value handling
irqchip: gic-v3-its: keep the include header files in alphabetic
order
irqchip: gicv3-its: platform-msi: refactor its_pmsi_prepare()
irqchip: gicv3-its: platform-msi: refactor its_pmsi_init() to prepare
for ACPI
irqchip: gicv3-its: platform-msi: scan MADT to create platform msi
domain
ACPI/IORT: Rename iort_node_map_rid() to make it generic
ACPI/IORT: Introduce iort_node_map_platform_id() to retrieve dev id
ACPI: platform-msi: retrieve dev id from IORT
ACPI: platform: setup MSI domain for ACPI based platform device
msi: platform: make platform_msi_create_device_domain() ACPI aware
irqchip: mbigen: Add ACPI support
Kefeng Wang (2):
irqchip: mbigen: drop module owner
irqchip: mbigen: introduce mbigen_of_create_domain()
drivers/acpi/arm64/iort.c | 158 +++++++++++++++++++++-----
drivers/acpi/glue.c | 6 +
drivers/base/platform-msi.c | 3 +-
drivers/irqchip/irq-gic-v3-its-platform-msi.c | 106 +++++++++++++----
drivers/irqchip/irq-gic-v3-its.c | 2 +-
drivers/irqchip/irq-mbigen.c | 110 +++++++++++++++---
include/linux/acpi_iort.h | 8 ++
7 files changed, 317 insertions(+), 76 deletions(-)
--
1.7.12.4
[toc] | [next] | [standalone]
| From | Hanjun Guo <guohanjun@huawei.com> |
|---|---|
| Date | 2017-03-07 14:00 +0100 |
| Subject | [PATCH v9 12/15] msi: platform: make platform_msi_create_device_domain() ACPI aware |
| Message-ID | <timSC-7EZ-19@gated-at.bofh.it> |
| In reply to | #1594208 |
From: Hanjun Guo <hanjun.guo@linaro.org>
The irqdomain creation that is carried out in:
platform_msi_create_device_domain()
relies on the fwnode_handle interrupt controller token to associate the
interrupt controller with a specific irqdomain. Current code relies on
the OF layer to retrieve a fwnode_handle for the device representing the
interrupt controller from its device->of_node pointer. This makes
platform_msi_create_device_domain() DT specific whilst it really is not
because after the merge of commit f94277af03ea ("of/platform: Initialise
dev->fwnode appropriately") the fwnode_handle can easily be retrieved
from the dev->fwnode pointer in a firmware agnostic way.
Update platform_msi_create_device_domain() to retrieve the interrupt
controller fwnode_handle from the dev->fwnode pointer so that it can
be used seamlessly in ACPI and DT systems.
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Ming Lei <ming.lei@canonical.com>
Tested-by: Wei Xu <xuwei5@hisilicon.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
drivers/base/platform-msi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c
index 0fc7c4d..d35e9a2 100644
--- a/drivers/base/platform-msi.c
+++ b/drivers/base/platform-msi.c
@@ -345,8 +345,7 @@ struct irq_domain *
data->host_data = host_data;
domain = irq_domain_create_hierarchy(dev->msi_domain, 0, nvec,
- of_node_to_fwnode(dev->of_node),
- ops, data);
+ dev->fwnode, ops, data);
if (!domain)
goto free_priv;
--
1.7.12.4
[toc] | [prev] | [next] | [standalone]
| From | Hanjun Guo <guohanjun@huawei.com> |
|---|---|
| Date | 2017-03-07 14:00 +0100 |
| Subject | [PATCH v9 15/15] irqchip: mbigen: Add ACPI support |
| Message-ID | <timSC-7EZ-25@gated-at.bofh.it> |
| In reply to | #1594208 |
From: Hanjun Guo <hanjun.guo@linaro.org>
With the preparation of platform msi support and interrupt producer
in DSDT, we can add mbigen ACPI support now.
We are using Interrupt resource type in _CRS methd to indicate number
of irq pins instead of num_pins in DT to avoid _DSD usage in this case.
For mbigen,
Device(MBI0) {
Name(_HID, "HISI0152")
Name(_UID, Zero)
Name(_CRS, ResourceTemplate() {
Memory32Fixed(ReadWrite, 0xa0080000, 0x10000)
Interrupt(ResourceProducer,...) {12,14,....}
})
}
For devices,
Device(COM0) {
Name(_HID, "ACPIIDxx")
Name(_UID, Zero)
Name(_CRS, ResourceTemplate() {
Memory32Fixed(ReadWrite, 0xb0030000, 0x10000)
Interrupt(ResourceConsumer,..., "\_SB.MBI0") {12}
})
}
With the help of platform msi and interrupt producer, then devices
will get the virq from mbigen's irqdomain.
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Ma Jun <majun258@huawei.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
drivers/irqchip/irq-mbigen.c | 70 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 67 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index 3756408..e6bb503 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <linux/acpi.h>
#include <linux/interrupt.h>
#include <linux/irqchip.h>
#include <linux/module.h>
@@ -180,7 +181,7 @@ static int mbigen_domain_translate(struct irq_domain *d,
unsigned long *hwirq,
unsigned int *type)
{
- if (is_of_node(fwspec->fwnode)) {
+ if (is_of_node(fwspec->fwnode) || is_acpi_device_node(fwspec->fwnode)) {
if (fwspec->param_count != 2)
return -EINVAL;
@@ -271,6 +272,54 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
return 0;
}
+#ifdef CONFIG_ACPI
+static acpi_status mbigen_acpi_process_resource(struct acpi_resource *ares,
+ void *context)
+{
+ struct acpi_resource_extended_irq *ext_irq;
+ u32 *num_irqs = context;
+
+ switch (ares->type) {
+ case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+ ext_irq = &ares->data.extended_irq;
+ *num_irqs += ext_irq->interrupt_count;
+ break;
+ default:
+ break;
+ }
+
+ return AE_OK;
+}
+
+static int mbigen_acpi_create_domain(struct platform_device *pdev,
+ struct mbigen_device *mgn_chip)
+{
+ struct irq_domain *domain;
+ u32 num_msis = 0;
+ acpi_status status;
+
+ status = acpi_walk_resources(ACPI_HANDLE(&pdev->dev), METHOD_NAME__CRS,
+ mbigen_acpi_process_resource, &num_msis);
+ if (ACPI_FAILURE(status) || num_msis == 0)
+ return -EINVAL;
+
+ domain = platform_msi_create_device_domain(&pdev->dev, num_msis,
+ mbigen_write_msg,
+ &mbigen_domain_ops,
+ mgn_chip);
+ if (!domain)
+ return -ENOMEM;
+
+ return 0;
+}
+#else
+static inline int mbigen_acpi_create_domain(struct platform_device *pdev,
+ struct mbigen_device *mgn_chip)
+{
+ return -ENODEV;
+}
+#endif
+
static int mbigen_device_probe(struct platform_device *pdev)
{
struct mbigen_device *mgn_chip;
@@ -289,9 +338,17 @@ static int mbigen_device_probe(struct platform_device *pdev)
if (IS_ERR(mgn_chip->base))
return PTR_ERR(mgn_chip->base);
- err = mbigen_of_create_domain(pdev, mgn_chip);
- if (err)
+ if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node)
+ err = mbigen_of_create_domain(pdev, mgn_chip);
+ else if (ACPI_COMPANION(&pdev->dev))
+ err = mbigen_acpi_create_domain(pdev, mgn_chip);
+ else
+ err = -EINVAL;
+
+ if (err) {
+ dev_err(&pdev->dev, "Failed to create mbi-gen@%p irqdomain", mgn_chip->base);
return err;
+ }
platform_set_drvdata(pdev, mgn_chip);
return 0;
@@ -303,10 +360,17 @@ static int mbigen_device_probe(struct platform_device *pdev)
};
MODULE_DEVICE_TABLE(of, mbigen_of_match);
+static const struct acpi_device_id mbigen_acpi_match[] = {
+ { "HISI0152", 0 },
+ {}
+};
+MODULE_DEVICE_TABLE(acpi, mbigen_acpi_match);
+
static struct platform_driver mbigen_platform_driver = {
.driver = {
.name = "Hisilicon MBIGEN-V2",
.of_match_table = mbigen_of_match,
+ .acpi_match_table = ACPI_PTR(mbigen_acpi_match),
},
.probe = mbigen_device_probe,
};
--
1.7.12.4
[toc] | [prev] | [next] | [standalone]
| From | Hanjun Guo <guohanjun@huawei.com> |
|---|---|
| Date | 2017-03-07 14:00 +0100 |
| Subject | [PATCH v9 08/15] ACPI/IORT: Rename iort_node_map_rid() to make it generic |
| Message-ID | <timSC-7EZ-31@gated-at.bofh.it> |
| In reply to | #1594208 |
From: Hanjun Guo <hanjun.guo@linaro.org>
iort_node_map_rid() was designed to take an input id (that is not
necessarily a PCI requester id) and map it to an output id (eg an SMMU
streamid or an ITS deviceid) according to the mappings provided by an
IORT node mapping entries. This means that the iort_node_map_rid() input
id is not always a PCI requester id as its name, parameters and local
variables suggest, which is misleading.
Apply the s/rid/id substitution to the iort_node_map_rid() mapping
function and its users to make sure its intended usage is clearer.
Suggested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Ming Lei <ming.lei@canonical.com>
Tested-by: Wei Xu <xuwei5@hisilicon.com>
Tested-by: Sinan Kaya <okaya@codeaurora.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Tomasz Nowicki <tn@semihalf.com>
---
drivers/acpi/arm64/iort.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index a6b807d..28d0088 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -355,11 +355,11 @@ struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node,
return NULL;
}
-static struct acpi_iort_node *iort_node_map_rid(struct acpi_iort_node *node,
- u32 rid_in, u32 *rid_out,
- u8 type_mask)
+static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node,
+ u32 id_in, u32 *id_out,
+ u8 type_mask)
{
- u32 rid = rid_in;
+ u32 id = id_in;
/* Parse the ID mapping tree to find specified node type */
while (node) {
@@ -367,8 +367,8 @@ static struct acpi_iort_node *iort_node_map_rid(struct acpi_iort_node *node,
int i;
if (IORT_TYPE_MASK(node->type) & type_mask) {
- if (rid_out)
- *rid_out = rid;
+ if (id_out)
+ *id_out = id;
return node;
}
@@ -385,9 +385,9 @@ static struct acpi_iort_node *iort_node_map_rid(struct acpi_iort_node *node,
goto fail_map;
}
- /* Do the RID translation */
+ /* Do the ID translation */
for (i = 0; i < node->mapping_count; i++, map++) {
- if (!iort_id_map(map, node->type, rid, &rid))
+ if (!iort_id_map(map, node->type, id, &id))
break;
}
@@ -399,9 +399,9 @@ static struct acpi_iort_node *iort_node_map_rid(struct acpi_iort_node *node,
}
fail_map:
- /* Map input RID to output RID unchanged on mapping failure*/
- if (rid_out)
- *rid_out = rid_in;
+ /* Map input ID to output ID unchanged on mapping failure */
+ if (id_out)
+ *id_out = id_in;
return NULL;
}
@@ -439,7 +439,7 @@ u32 iort_msi_map_rid(struct device *dev, u32 req_id)
if (!node)
return req_id;
- iort_node_map_rid(node, req_id, &dev_id, IORT_MSI_TYPE);
+ iort_node_map_id(node, req_id, &dev_id, IORT_MSI_TYPE);
return dev_id;
}
@@ -462,7 +462,7 @@ static int iort_dev_find_its_id(struct device *dev, u32 req_id,
if (!node)
return -ENXIO;
- node = iort_node_map_rid(node, req_id, NULL, IORT_MSI_TYPE);
+ node = iort_node_map_id(node, req_id, NULL, IORT_MSI_TYPE);
if (!node)
return -ENXIO;
@@ -591,8 +591,8 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)
if (!node)
return NULL;
- parent = iort_node_map_rid(node, rid, &streamid,
- IORT_IOMMU_TYPE);
+ parent = iort_node_map_id(node, rid, &streamid,
+ IORT_IOMMU_TYPE);
ops = iort_iommu_xlate(dev, parent, streamid);
--
1.7.12.4
[toc] | [prev] | [next] | [standalone]
| From | Hanjun Guo <guohanjun@huawei.com> |
|---|---|
| Date | 2017-03-07 14:00 +0100 |
| Subject | [PATCH v9 11/15] ACPI: platform: setup MSI domain for ACPI based platform device |
| Message-ID | <timSD-7EZ-33@gated-at.bofh.it> |
| In reply to | #1594208 |
From: Hanjun Guo <hanjun.guo@linaro.org>
By allowing platform MSI domain to be created on ACPI platforms,
a platform device MSI domain can be set-up when it is probed.
In order to do that, the MSI domain the platform device connects
to should be retrieved, so the iort_get_platform_device_domain() is
introduced to retrieve the domain from the IORT kernel layer.
With the domain retrieved, we need a proper way to set the
domain to platform device.
Given that some platform devices (irqchips) require the MSI irqdomain
to be their interrupt parent domain, the MSI irqdomain should be
determined before platform device is probed but after the platform
device is allocated which means that the code setting up the MSI
irqdomain, ie acpi_configure_pmsi_domain() should be called in
acpi_platform_notify() (that is triggered after adding a device but
before the respective driver is probed) for the platform MSI domain
code set-up path to work properly.
Acked-by: Rafael J. Wysocki <rafael@kernel.org> [for glue.c]
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
[lorenzo.pieralisi@arm.com: rewrote commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Ming Lei <ming.lei@canonical.com>
Tested-by: Wei Xu <xuwei5@hisilicon.com>
Tested-by: Sinan Kaya <okaya@codeaurora.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Tomasz Nowicki <tn@semihalf.com>
---
drivers/acpi/arm64/iort.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
drivers/acpi/glue.c | 6 ++++++
include/linux/acpi_iort.h | 3 +++
3 files changed, 59 insertions(+)
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index fb95ceb..22e08d2 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -548,6 +548,56 @@ struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id)
return irq_find_matching_fwnode(handle, DOMAIN_BUS_PCI_MSI);
}
+/**
+ * iort_get_platform_device_domain() - Find MSI domain related to a
+ * platform device
+ * @dev: the dev pointer associated with the platform device
+ *
+ * Returns: the MSI domain for this device, NULL otherwise
+ */
+static struct irq_domain *iort_get_platform_device_domain(struct device *dev)
+{
+ struct acpi_iort_node *node, *msi_parent;
+ struct fwnode_handle *iort_fwnode;
+ struct acpi_iort_its_group *its;
+ int i;
+
+ /* find its associated iort node */
+ node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT,
+ iort_match_node_callback, dev);
+ if (!node)
+ return NULL;
+
+ /* then find its msi parent node */
+ for (i = 0; i < node->mapping_count; i++) {
+ msi_parent = iort_node_map_platform_id(node, NULL,
+ IORT_MSI_TYPE, i);
+ if (msi_parent)
+ break;
+ }
+
+ if (!msi_parent)
+ return NULL;
+
+ /* Move to ITS specific data */
+ its = (struct acpi_iort_its_group *)msi_parent->node_data;
+
+ iort_fwnode = iort_find_domain_token(its->identifiers[0]);
+ if (!iort_fwnode)
+ return NULL;
+
+ return irq_find_matching_fwnode(iort_fwnode, DOMAIN_BUS_PLATFORM_MSI);
+}
+
+void acpi_configure_pmsi_domain(struct device *dev)
+{
+ struct irq_domain *msi_domain;
+
+ msi_domain = iort_get_platform_device_domain(dev);
+ if (msi_domain)
+ dev_set_msi_domain(dev, msi_domain);
+}
+
static int __get_pci_rid(struct pci_dev *pdev, u16 alias, void *data)
{
u32 *rid = data;
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index fb19e1c..ec31b43 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -6,6 +6,8 @@
*
* This file is released under the GPLv2.
*/
+
+#include <linux/acpi_iort.h>
#include <linux/export.h>
#include <linux/init.h>
#include <linux/list.h>
@@ -14,6 +16,7 @@
#include <linux/rwsem.h>
#include <linux/acpi.h>
#include <linux/dma-mapping.h>
+#include <linux/platform_device.h>
#include "internal.h"
@@ -322,6 +325,9 @@ static int acpi_platform_notify(struct device *dev)
if (!adev)
goto out;
+ if (dev->bus == &platform_bus_type)
+ acpi_configure_pmsi_domain(dev);
+
if (type && type->setup)
type->setup(dev);
else if (adev->handler && adev->handler->bind)
diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h
index d074c77..06b182e 100644
--- a/include/linux/acpi_iort.h
+++ b/include/linux/acpi_iort.h
@@ -34,6 +34,7 @@
bool iort_node_match(u8 type);
u32 iort_msi_map_rid(struct device *dev, u32 req_id);
struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id);
+void acpi_configure_pmsi_domain(struct device *dev);
int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id);
/* IOMMU interface */
void iort_set_dma_mask(struct device *dev);
@@ -47,6 +48,8 @@ static inline struct irq_domain *iort_get_device_domain(struct device *dev,
u32 req_id)
{ return NULL; }
+static inline void acpi_configure_pmsi_domain(struct device *dev) { }
+
static inline int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id)
{ return -ENODEV; }
--
1.7.12.4
[toc] | [prev] | [next] | [standalone]
| From | Hanjun Guo <guohanjun@huawei.com> |
|---|---|
| Date | 2017-03-07 14:00 +0100 |
| Subject | [PATCH v9 14/15] irqchip: mbigen: introduce mbigen_of_create_domain() |
| Message-ID | <timSD-7EZ-35@gated-at.bofh.it> |
| In reply to | #1594208 |
From: Kefeng Wang <wangkefeng.wang@huawei.com>
Introduce mbigen_of_create_domain() to consolidate OF related
code and prepare for ACPI later, no funtional change.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Reviewed-by: Ma Jun <majun258@huawei.com>
Tested-by: Ming Lei <ming.lei@canonical.com>
Tested-by: Wei Xu <xuwei5@hisilicon.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
drivers/irqchip/irq-mbigen.c | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index c01ab41..3756408 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -236,27 +236,15 @@ static int mbigen_irq_domain_alloc(struct irq_domain *domain,
.free = irq_domain_free_irqs_common,
};
-static int mbigen_device_probe(struct platform_device *pdev)
+static int mbigen_of_create_domain(struct platform_device *pdev,
+ struct mbigen_device *mgn_chip)
{
- struct mbigen_device *mgn_chip;
+ struct device *parent;
struct platform_device *child;
struct irq_domain *domain;
struct device_node *np;
- struct device *parent;
- struct resource *res;
u32 num_pins;
- mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL);
- if (!mgn_chip)
- return -ENOMEM;
-
- mgn_chip->pdev = pdev;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- mgn_chip->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(mgn_chip->base))
- return PTR_ERR(mgn_chip->base);
-
for_each_child_of_node(pdev->dev.of_node, np) {
if (!of_property_read_bool(np, "interrupt-controller"))
continue;
@@ -280,6 +268,31 @@ static int mbigen_device_probe(struct platform_device *pdev)
return -ENOMEM;
}
+ return 0;
+}
+
+static int mbigen_device_probe(struct platform_device *pdev)
+{
+ struct mbigen_device *mgn_chip;
+ struct resource *res;
+ int err;
+
+ mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL);
+ if (!mgn_chip)
+ return -ENOMEM;
+
+ mgn_chip->pdev = pdev;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ mgn_chip->base = devm_ioremap(&pdev->dev, res->start,
+ resource_size(res));
+ if (IS_ERR(mgn_chip->base))
+ return PTR_ERR(mgn_chip->base);
+
+ err = mbigen_of_create_domain(pdev, mgn_chip);
+ if (err)
+ return err;
+
platform_set_drvdata(pdev, mgn_chip);
return 0;
}
--
1.7.12.4
[toc] | [prev] | [next] | [standalone]
| From | Hanjun Guo <guohanjun@huawei.com> |
|---|---|
| Date | 2017-03-07 14:10 +0100 |
| Subject | [PATCH v9 09/15] ACPI/IORT: Introduce iort_node_map_platform_id() to retrieve dev id |
| Message-ID | <tin2i-7Xr-17@gated-at.bofh.it> |
| In reply to | #1594208 |
From: Hanjun Guo <hanjun.guo@linaro.org>
To retrieve dev id for IORT named components nodes there are
two steps involved (second is optional):
(1) Retrieve the initial id (this may well provide the final mapping)
(2) Map the id (optional if (1) represents the map type we need), this
is needed for use cases such as NC (named component) -> SMMU -> ITS
mappings.
the iort_node_get_id() function was created for step (1) above and
iort_node_map_rid() for step (2).
Create a wrapper, named iort_node_map_platform_id(), that encompasses
the two steps at once to retrieve the dev id to provide steps (1)-(2)
functionality.
iort_node_map_platform_id() will handle the parent type so type handling
in iort_node_get_id() is duplicated, remove it and update current
iort_node_get_id() users to move them over to iort_node_map_platform_id().
Suggested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Suggested-by: Tomasz Nowicki <tn@semihalf.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
[lorenzo.pieralisi@arm.com: rewrote commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Ming Lei <ming.lei@canonical.com>
Tested-by: Wei Xu <xuwei5@hisilicon.com>
Tested-by: Sinan Kaya <okaya@codeaurora.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Tomasz Nowicki <tn@semihalf.com>
---
drivers/acpi/arm64/iort.c | 43 ++++++++++++++++++++++++++++++++++---------
1 file changed, 34 insertions(+), 9 deletions(-)
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 28d0088..83cd59d 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -318,8 +318,7 @@ static int iort_id_map(struct acpi_iort_id_mapping *map, u8 type, u32 rid_in,
static
struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node,
- u32 *id_out, u8 type_mask,
- int index)
+ u32 *id_out, int index)
{
struct acpi_iort_node *parent;
struct acpi_iort_id_mapping *map;
@@ -341,9 +340,6 @@ struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node,
parent = ACPI_ADD_PTR(struct acpi_iort_node, iort_table,
map->output_reference);
- if (!(IORT_TYPE_MASK(parent->type) & type_mask))
- return NULL;
-
if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) {
if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT ||
node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) {
@@ -406,6 +402,34 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node,
return NULL;
}
+static
+struct acpi_iort_node *iort_node_map_platform_id(struct acpi_iort_node *node,
+ u32 *id_out, u8 type_mask,
+ int index)
+{
+ struct acpi_iort_node *parent;
+ u32 id;
+
+ /* step 1: retrieve the initial dev id */
+ parent = iort_node_get_id(node, &id, index);
+ if (!parent)
+ return NULL;
+
+ /*
+ * optional step 2: map the initial dev id if its parent is not
+ * the target type we want, map it again for the use cases such
+ * as NC (named component) -> SMMU -> ITS. If the type is matched,
+ * return the initial dev id and its parent pointer directly.
+ */
+ if (!(IORT_TYPE_MASK(parent->type) & type_mask))
+ parent = iort_node_map_id(parent, id, id_out, type_mask);
+ else
+ if (id_out)
+ *id_out = id;
+
+ return parent;
+}
+
static struct acpi_iort_node *iort_find_dev_node(struct device *dev)
{
struct pci_bus *pbus;
@@ -604,14 +628,15 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)
if (!node)
return NULL;
- parent = iort_node_get_id(node, &streamid,
- IORT_IOMMU_TYPE, i++);
+ parent = iort_node_map_platform_id(node, &streamid,
+ IORT_IOMMU_TYPE, i++);
while (parent) {
ops = iort_iommu_xlate(dev, parent, streamid);
- parent = iort_node_get_id(node, &streamid,
- IORT_IOMMU_TYPE, i++);
+ parent = iort_node_map_platform_id(node, &streamid,
+ IORT_IOMMU_TYPE,
+ i++);
}
}
--
1.7.12.4
[toc] | [prev] | [next] | [standalone]
| From | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> |
|---|---|
| Date | 2017-03-07 15:50 +0100 |
| Message-ID | <tioB5-pr-35@gated-at.bofh.it> |
| In reply to | #1594208 |
On Tue, Mar 07, 2017 at 08:39:55PM +0800, Hanjun Guo wrote: > From: Hanjun Guo <hanjun.guo@linaro.org> > > With platform msi support landed in the kernel, and the introduction > of IORT for GICv3 ITS (PCI MSI) and SMMU, the framework for platform msi > is ready, this patch set add few patches to enable the ACPI platform > msi support. > > For platform device connecting to ITS on arm platform, we have IORT > table with the named componant node to describe the mappings of paltform > device and ITS, so we can retrieve the dev id and find its parent > irqdomain (ITS) from IORT table (simlar with the ACPI ITS support). > > v8 -> v9: > - Rebased on top of 4.11-rc1 and retest; > - Some of patch's commit message was updated by Lorenzo and > it's clearer (thanks!) > > No update in the code, hope it's the final revision. I will be off the radar till -rc3 but I do not expect major changes to the series in its current form given that dependencies were merged in the merge window (ACPI IRQ probe deferral and IORT fixes). Thanks, Lorenzo > v7 -> v8: > - Using _CRS instead of _PRS for Interrupt resources for mbigen > > - reshuffle the patch slightly to introduce iort_node_map_platform_id() > first and then retrieve the dev id for platform MSI, no functional > change > > - Fix the compile error with patch "irqchip: gicv3-its: platform-msi: > scan MADT to create platform msi domain", which forgot to add > <include/acpi_iort.h> (added in later patches in last version). > > - renew some commit message which suggested by Lorenzo > > - address some othe minor issues which commented by Lorenzo > > - Add review and test tag as it's no functional change except > the last patch of mbigen > > - rebase on top of 4.10-rc4 and test it on x86, ia64 and ARM64 > platforms (also with Agustin's patch [1-2/3] "[PATCH V9 0/3] irqchip: qcom: > Add IRQ combiner driver" and Lorenzo's patch > https://patchwork.kernel.org/patch/9507041/) > > v6 -> v7: > - Introduce iort_node_map_platform_id() to retrieve the > dev id for both NC (named component) -> ITS/SMMU and > NC -> SMMU -> ITS cases, suggested by Lorenzo; > > - Reorder the patches and rewrite some commit message; > > - Remove the test tags because it has major changes > to retrieve the dev id, Sinan, Majun, Xinwei, could > you please test them again on your platform? > > - rebased on top of 4.10-rc3 and Lorenzo's patch > https://patchwork.kernel.org/patch/9507041/ > > - Tested against Agustin's patch [1-2/3] "[PATCH V9 0/3] irqchip: qcom: > Add IRQ combiner driver" > > v5 -> v6: > - Call acpi_configure_pmsi_domain() for platform devices in > acpi_platform_notify() as it's cleaner (suggested by Rafael) > - Remove the "u8 type" for iort_id_map() because it's unused > - Rebase on top of 4.10-rc2 > - Collect test and review tags > > v4 -> v5: > - Add mbigen support back with tested on with Agustin's patchset, > and it's a good example of how ACPI platform MSI works > - rebased on top of lastest Linus tree (commit 52bce91 splice: reinstate SIGPIPE/EPIPE handling) > > v3 -> v4: > - Drop mbi-gen patches to just submit platform msi support because > will rebase mbi-gen patches on top of Agustin's patchset, and discusion > is going there. > - Add a patch to support device topology such as NC(named componant, paltform device) > ->SMMU->ITS which suggested by Lorenzo; > - rebased on top of Lorenzo's v9 of ACPI IORT ARM SMMU support; > - rebased on top of 4.9-rc7 > > v2 -> v3: > - Drop RFC tag > - Rebase against v4.9-rc2 and Lorenzo's v6 of ACPI IORT ARM SMMU support [1] > - Add 3 cleanup patches (patch 1, 2, 3) > - Drop arch_init call patch from last version > - Introduce a callback for platform device to set msi domain > - Introduce a new API to get paltform device's domain instead of > reusing the PCI one in previous version > - Add a patch to rework iort_node_get_id() > > [1]: http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1251993.html > > v1 -> v2: > - Fix the bug of if multi Interrupt() resoures in single _PRS, > we need to calculate all the irq numbers (I missed it in previous > version); > - Rebased on Marc's irq/irqchip-4.9 branch and Lorenzo's v5 > SMMU patches (also Robin's SMMu patches) > - Add patch irqchip: mbigen: promote mbigen init. > > Hanjun Guo (13): > ACPI/IORT: Fix the indentation in iort_scan_node() > ACPI/IORT: Add missing comment for iort_dev_find_its_id() > ACPI/IORT: Rework iort_match_node_callback() return value handling > irqchip: gic-v3-its: keep the include header files in alphabetic > order > irqchip: gicv3-its: platform-msi: refactor its_pmsi_prepare() > irqchip: gicv3-its: platform-msi: refactor its_pmsi_init() to prepare > for ACPI > irqchip: gicv3-its: platform-msi: scan MADT to create platform msi > domain > ACPI/IORT: Rename iort_node_map_rid() to make it generic > ACPI/IORT: Introduce iort_node_map_platform_id() to retrieve dev id > ACPI: platform-msi: retrieve dev id from IORT > ACPI: platform: setup MSI domain for ACPI based platform device > msi: platform: make platform_msi_create_device_domain() ACPI aware > irqchip: mbigen: Add ACPI support > > Kefeng Wang (2): > irqchip: mbigen: drop module owner > irqchip: mbigen: introduce mbigen_of_create_domain() > > drivers/acpi/arm64/iort.c | 158 +++++++++++++++++++++----- > drivers/acpi/glue.c | 6 + > drivers/base/platform-msi.c | 3 +- > drivers/irqchip/irq-gic-v3-its-platform-msi.c | 106 +++++++++++++---- > drivers/irqchip/irq-gic-v3-its.c | 2 +- > drivers/irqchip/irq-mbigen.c | 110 +++++++++++++++--- > include/linux/acpi_iort.h | 8 ++ > 7 files changed, 317 insertions(+), 76 deletions(-) > > -- > 1.7.12.4 >
[toc] | [prev] | [next] | [standalone]
| From | Hanjun Guo <hanjun.guo@linaro.org> |
|---|---|
| Date | 2017-03-09 14:30 +0100 |
| Message-ID | <tj6iJ-5Jn-1@gated-at.bofh.it> |
| In reply to | #1594309 |
Hi Marc, On 2017/3/7 22:43, Lorenzo Pieralisi wrote: > On Tue, Mar 07, 2017 at 08:39:55PM +0800, Hanjun Guo wrote: >> From: Hanjun Guo <hanjun.guo@linaro.org> >> >> With platform msi support landed in the kernel, and the introduction >> of IORT for GICv3 ITS (PCI MSI) and SMMU, the framework for platform msi >> is ready, this patch set add few patches to enable the ACPI platform >> msi support. >> >> For platform device connecting to ITS on arm platform, we have IORT >> table with the named componant node to describe the mappings of paltform >> device and ITS, so we can retrieve the dev id and find its parent >> irqdomain (ITS) from IORT table (simlar with the ACPI ITS support). >> >> v8 -> v9: >> - Rebased on top of 4.11-rc1 and retest; >> - Some of patch's commit message was updated by Lorenzo and >> it's clearer (thanks!) >> >> No update in the code, hope it's the final revision. > > I will be off the radar till -rc3 but I do not expect major changes > to the series in its current form given that dependencies were merged > in the merge window (ACPI IRQ probe deferral and IORT fixes). What's your opinion on this patch set? especially for the last 3 patches for mbigen driver, please comment on it to see if I need to take further steps. Thanks Hanjun
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web