iommu/of: Only do IOMMU lookup for available ones
PATCH 1/1 iommu/of: Only do IOMMU lookup for available ones
The for_each_matching_node_and_match() would return every matching nodes including unavailable ones.
It's pointless to init unavailable IOMMUs, so add a sanity check to avoid that.
---
drivers/iommu/of_iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/of_iommu.c +3 -0
@@ -240,6 +240,9 @@ static int __init of_iommu_init(void)for_each_matching_node_and_match (np, matches, &match) {const of_iommu_init_fn init_fn = match->data; +if (!of_device_is_available (np)) +continue ; +if (init_fn &&init_fn (np))pr_err ("Failed to initialise IOMMU %pOF\n" , np); }
Signature · 1 line
2.11.0
Robin Murphy
reviewerHi Jeffy,
Quoted 5 lines · Jeffy Chen
The
for_each_matching_node_and_match()would return every matching nodes including unavailable ones.It's pointless to init unavailable IOMMUs, so add a sanity check to avoid that.
Even better would be to clean up the last remaining init_fn user and get rid of the whole business. With the probe-deferral mechanism, early initialisation hooks are no longer needed, and the IOMMU_OF_DECLARE section really only remains as a way of detecting builtin drivers long before their registration initcalls run.
Robin.
Quoted 21 lines
Signed-off-by Jeffy Chen <[email protected]>---
drivers/iommu/of_iommu.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iommu/of_iommu.c +3
-0@@ -240,6 +240,9 @@ static int __init of_iommu_init(void)for_each_matching_node_and_match (np, matches, &match) {const of_iommu_init_fn init_fn = match->data; +if (!of_device_is_available (np)) +continue ; +if (init_fn &&init_fn (np))pr_err ("Failed to initialise IOMMU %pOF\n" , np); }
Joerg Roedel
maintainerQuoted 17 lines · Jeffy Chen
The
for_each_matching_node_and_match()would return every matching nodes including unavailable ones.It's pointless to init unavailable IOMMUs, so add a sanity check to avoid that.
Signed-off-by Jeffy Chen <[email protected]>---
drivers/iommu/of_iommu.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iommu/of_iommu.c +0
-0
drivers/iommu/of_iommu.c static int __init of_iommu_init(void) · line 245
Quoted 6 lines
drivers/iommu/of_iommu.c +3
-0@@ -240,6 +240,9 @@ static int __init of_iommu_init(void)for_each_matching_node_and_match (np, matches, &match) {const of_iommu_init_fn init_fn = match->data; +if (!of_device_is_available (np)) +continue ; +
Makes sense to me, but I'd like to have an OK from Robin or Will (added to Cc) before applying this.
Joerg
Quoted 21 lines · Joerg Roedel
Quoted 20 lines · Jeffy Chen
The
for_each_matching_node_and_match()would return every matching nodes including unavailable ones.It's pointless to init unavailable IOMMUs, so add a sanity check to avoid that.
Signed-off-by Jeffy Chen <[email protected]>---
drivers/iommu/of_iommu.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iommu/of_iommu.c +0
-0@@ -240,6 +240,9 @@ static int __init of_iommu_init(void)for_each_matching_node_and_match (np, matches, &match) {const of_iommu_init_fn init_fn = match->data;
Quoted 6 lines
drivers/iommu/of_iommu.c static int __init of_iommu_init(void) · line 245
Quoted 3 lines
drivers/iommu/of_iommu.c +3
-0+if (!of_device_is_available (np)) +continue ; +Makes sense to me, but I'd like to have an OK from Robin or Will (added to Cc) before applying this.
I don't think this patch makes a lot of sense in isolation: the SMMU drivers themselves will likely still probe, and it's unclear what we should about DMA when an IOMMU is not deemed to be available. See:
https://patchwork.kernel.org/patch/9681211/
Jeffy -- are you solving a real issue here, or is this just an attempt at some cleanup?
Will
Hi Will,
Thanks for your reply.
Quoted 11 lines · Will Deacon
Quoted 3 lines
Quoted 3 lines
Makes sense to me, but I'd like to have an OK from Robin or Will (added to Cc) before applying this.
I don't think this patch makes a lot of sense in isolation: the SMMU drivers themselves will likely still probe, and it's unclear what we should about DMA when an IOMMU is not deemed to be available. See:
https://patchwork.kernel.org/patch/9681211/
Jeffy -- are you solving a real issue here, or is this just an attempt at some cleanup?
hmmm, it's just a cleanup, but it seems like we already removed this of_iommu_init_fn in:b0c560f7d8a4 iommu: Clean up of_iommu_init_fn
so this patch can be disregarded too :)
Quoted 5 lines
Will