[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220914051503.10348-1-nicolinc@nvidia.com>
Date: Tue, 13 Sep 2022 22:15:01 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: <joro@...tes.org>, <will@...nel.org>, <robin.murphy@....com>
CC: <jgg@...dia.com>, <kevin.tian@...el.com>, <iommu@...ts.linux.dev>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH v2 05/13] iommu/fsl: Constrain return value of ->attach_dev()
Ensure attach_dev() callback functions only return errno values expected
from the attach_dev() op. In particular, only return -EINVAL when we are
sure that the device is incompatible with the domain.
Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
---
drivers/iommu/fsl_pamu_domain.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 011f9ab7f743..a391ac733b5e 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -258,7 +258,7 @@ static int fsl_pamu_attach_device(struct iommu_domain *domain,
liodn = of_get_property(dev->of_node, "fsl,liodn", &len);
if (!liodn) {
pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node);
- return -EINVAL;
+ return -ENODEV;
}
spin_lock_irqsave(&dma_domain->domain_lock, flags);
@@ -267,17 +267,21 @@ static int fsl_pamu_attach_device(struct iommu_domain *domain,
if (liodn[i] >= PAACE_NUMBER_ENTRIES) {
pr_debug("Invalid liodn %d, attach device failed for %pOF\n",
liodn[i], dev->of_node);
- ret = -EINVAL;
+ ret = -ENODEV;
break;
}
attach_device(dma_domain, liodn[i], dev);
ret = pamu_set_liodn(dma_domain, dev, liodn[i]);
- if (ret)
+ if (ret) {
+ ret = -ENODEV;
break;
+ }
ret = pamu_enable_liodn(liodn[i]);
- if (ret)
+ if (ret) {
+ ret = -ENODEV;
break;
+ }
}
spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
return ret;
--
2.17.1
Powered by blists - more mailing lists