From: sricharan@codeaurora.org (Sricharan R)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 10/10] drivers: acpi: Handle IOMMU lookup failure with deferred probing or error
Date: Wed, 30 Nov 2016 05:52:24 +0530 [thread overview]
Message-ID: <1480465344-11862-11-git-send-email-sricharan@codeaurora.org> (raw)
In-Reply-To: <1480465344-11862-1-git-send-email-sricharan@codeaurora.org>
This is an equivalent to the DT's handling of the iommu master's probe
with deferred probing when the corrsponding iommu is not probed yet.
The lack of a registered IOMMU can be caused by the lack of a driver for
the IOMMU, the IOMMU device probe not having been performed yet, having
been deferred, or having failed.
The first case occurs when the firmware describes the bus master and
IOMMU topology correctly but no device driver exists for the IOMMU yet
or the device driver has not been compiled in. Return NULL, the caller
will configure the device without an IOMMU.
The second and third cases are handled by deferring the probe of the bus
master device which will eventually get reprobed after the IOMMU.
The last case is currently handled by deferring the probe of the bus
master device as well. A mechanism to either configure the bus master
device without an IOMMU or to fail the bus master device probe depending
on whether the IOMMU is optional or mandatory would be a good
enhancement.
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
---
drivers/acpi/arm64/iort.c | 17 ++++++++++++++++-
drivers/acpi/scan.c | 7 +++++--
drivers/pci/probe.c | 2 +-
include/acpi/acpi_bus.h | 2 +-
include/linux/acpi.h | 7 +++++--
5 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 47bace8..18ad4d9 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -537,8 +537,9 @@ static const struct iommu_ops *iort_iommu_xlate(struct device *dev,
return NULL;
ops = iommu_get_instance(iort_fwnode);
+ /* This means that the iommu driver is still not probed */
if (!ops)
- return NULL;
+ return ERR_PTR(-EPROBE_DEFER);
ret = arm_smmu_iort_xlate(dev, streamid, iort_fwnode, ops);
}
@@ -590,12 +591,26 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)
while (parent) {
ops = iort_iommu_xlate(dev, parent, streamid);
+ if (IS_ERR_OR_NULL(ops))
+ return ops;
parent = iort_node_get_id(node, &streamid,
IORT_IOMMU_TYPE, i++);
}
}
+ /*
+ * If we have reason to believe the IOMMU driver missed the initial
+ * add_device callback for dev, replay it to get things in order.
+ */
+ if (!IS_ERR_OR_NULL(ops) && ops->add_device &&
+ dev->bus && !dev->iommu_group) {
+ int err = ops->add_device(dev);
+
+ if (err)
+ ops = ERR_PTR(err);
+ }
+
return ops;
}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 80698d3..c80e51e 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1376,7 +1376,7 @@ enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
* @dev: The pointer to the device
* @attr: device dma attributes
*/
-void acpi_dma_configure(struct device *dev, enum dev_dma_attr attr)
+int acpi_dma_configure(struct device *dev, enum dev_dma_attr attr)
{
const struct iommu_ops *iommu;
@@ -1395,13 +1395,16 @@ void acpi_dma_configure(struct device *dev, enum dev_dma_attr attr)
dev->dma_mask = &dev->coherent_dma_mask;
iommu = iort_iommu_configure(dev);
-
+ if (IS_ERR(iommu))
+ return PTR_ERR(iommu);
/*
* Assume dma valid range starts at 0 and covers the whole
* coherent_dma_mask.
*/
arch_setup_dma_ops(dev, 0, dev->coherent_dma_mask + 1, iommu,
attr == DEV_DMA_COHERENT);
+
+ return 0;
}
EXPORT_SYMBOL_GPL(acpi_dma_configure);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6316cae..e32c7e5 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1739,7 +1739,7 @@ int pci_dma_configure(struct device *dev)
if (attr == DEV_DMA_NOT_SUPPORTED)
dev_warn(dev, "DMA not supported.\n");
else
- acpi_dma_configure(dev, attr);
+ ret = acpi_dma_configure(dev, attr);
}
pci_put_host_bridge_device(bridge);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 4242c31..9aa762f 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -573,7 +573,7 @@ struct acpi_pci_root {
bool acpi_dma_supported(struct acpi_device *adev);
enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev);
-void acpi_dma_configure(struct device *dev, enum dev_dma_attr attr);
+int acpi_dma_configure(struct device *dev, enum dev_dma_attr attr);
void acpi_dma_deconfigure(struct device *dev);
struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 8d15fc5..0e8d33f 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -765,8 +765,11 @@ static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
return DEV_DMA_NOT_SUPPORTED;
}
-static inline void acpi_dma_configure(struct device *dev,
- enum dev_dma_attr attr) { }
+static inline int acpi_dma_configure(struct device *dev,
+ enum dev_dma_attr attr)
+{
+ return 0;
+}
static inline void acpi_dma_deconfigure(struct device *dev) { }
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
next prev parent reply other threads:[~2016-11-30 0:22 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20161130002326epcas2p462e9291a284c562b3cfeb2ee4339c5af@epcas2p4.samsung.com>
2016-11-30 0:22 ` [PATCH v4 00/10] IOMMU probe deferral support Sricharan R
2016-11-30 0:22 ` [PATCH 01/10] iommu/of: Refactor of_iommu_configure() for error handling Sricharan R
2016-11-30 0:22 ` [PATCH 02/10] iommu/of: Prepare for deferred IOMMU configuration Sricharan R
2016-11-30 16:17 ` Lorenzo Pieralisi
2016-11-30 16:42 ` Robin Murphy
2016-12-01 11:29 ` Lorenzo Pieralisi
2016-12-01 11:50 ` Sricharan
2017-01-05 8:34 ` Sricharan
2017-01-05 12:27 ` Lorenzo Pieralisi
2017-01-05 13:52 ` Robin Murphy
2017-01-05 14:51 ` Sricharan
2017-01-06 16:24 ` Lorenzo Pieralisi
2017-01-19 14:40 ` Lorenzo Pieralisi
2017-01-19 15:10 ` Sricharan
2017-01-05 15:35 ` Lorenzo Pieralisi
2016-11-30 0:22 ` [PATCH 03/10] of: dma: Move range size workaround to of_dma_get_range() Sricharan R
2016-11-30 0:22 ` [PATCH 04/10] of: dma: Make of_dma_deconfigure() public Sricharan R
2016-11-30 0:22 ` [PATCH 05/10] drivers: platform: Configure dma operations at probe time Sricharan R
2016-11-30 0:22 ` [PATCH 06/10] iommu: of: Handle IOMMU lookup failure with deferred probing or error Sricharan R
2016-11-30 7:54 ` Marek Szyprowski
2016-11-30 11:27 ` Sricharan
2016-11-30 12:57 ` Robin Murphy
2016-11-30 14:01 ` Sricharan
2016-11-30 0:22 ` [PATCH 07/10] arm64: dma-mapping: Remove the notifier trick to handle early setting of dma_ops Sricharan R
2016-11-30 0:22 ` [PATCH 08/10] iommu/arm-smmu: Clean up early-probing workarounds Sricharan R
2016-11-30 0:22 ` [PATCH 09/10] drivers: acpi: Configure acpi devices dma operation at probe time Sricharan R
2016-11-30 0:22 ` Sricharan R [this message]
2016-11-30 8:19 ` [PATCH v4 00/10] IOMMU probe deferral support Marek Szyprowski
2016-11-30 11:28 ` Sricharan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1480465344-11862-11-git-send-email-sricharan@codeaurora.org \
--to=sricharan@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).