mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
iommu: Clean up release_device checks
Since .release_device is now called through per-device ops, any call which gets as far as a driver definitely *is* for that driver, for a device which has successfully passed .probe_device, so all the checks to that effect are now redundant and can be removed. In the same vein we can also skip freeing fwspecs which are now managed by core code. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Link: https://lore.kernel.org/r/02671dbfad7a3343fc25a44222350efcb455fe3c.1655822151.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
b321a2fba2
commit
4d26ba671e
@ -564,9 +564,6 @@ static void apple_dart_release_device(struct device *dev)
|
|||||||
{
|
{
|
||||||
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
|
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
|
||||||
|
|
||||||
if (!cfg)
|
|
||||||
return;
|
|
||||||
|
|
||||||
dev_iommu_priv_set(dev, NULL);
|
dev_iommu_priv_set(dev, NULL);
|
||||||
kfree(cfg);
|
kfree(cfg);
|
||||||
}
|
}
|
||||||
|
@ -2702,20 +2702,14 @@ err_free_master:
|
|||||||
|
|
||||||
static void arm_smmu_release_device(struct device *dev)
|
static void arm_smmu_release_device(struct device *dev)
|
||||||
{
|
{
|
||||||
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
|
||||||
struct arm_smmu_master *master;
|
|
||||||
|
|
||||||
if (!fwspec || fwspec->ops != &arm_smmu_ops)
|
|
||||||
return;
|
|
||||||
|
|
||||||
master = dev_iommu_priv_get(dev);
|
|
||||||
if (WARN_ON(arm_smmu_master_sva_enabled(master)))
|
if (WARN_ON(arm_smmu_master_sva_enabled(master)))
|
||||||
iopf_queue_remove_device(master->smmu->evtq.iopf, dev);
|
iopf_queue_remove_device(master->smmu->evtq.iopf, dev);
|
||||||
arm_smmu_detach_dev(master);
|
arm_smmu_detach_dev(master);
|
||||||
arm_smmu_disable_pasid(master);
|
arm_smmu_disable_pasid(master);
|
||||||
arm_smmu_remove_master(master);
|
arm_smmu_remove_master(master);
|
||||||
kfree(master);
|
kfree(master);
|
||||||
iommu_fwspec_free(dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct iommu_group *arm_smmu_device_group(struct device *dev)
|
static struct iommu_group *arm_smmu_device_group(struct device *dev)
|
||||||
|
@ -1432,27 +1432,19 @@ out_free:
|
|||||||
static void arm_smmu_release_device(struct device *dev)
|
static void arm_smmu_release_device(struct device *dev)
|
||||||
{
|
{
|
||||||
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
||||||
struct arm_smmu_master_cfg *cfg;
|
struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev);
|
||||||
struct arm_smmu_device *smmu;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!fwspec || fwspec->ops != &arm_smmu_ops)
|
ret = arm_smmu_rpm_get(cfg->smmu);
|
||||||
return;
|
|
||||||
|
|
||||||
cfg = dev_iommu_priv_get(dev);
|
|
||||||
smmu = cfg->smmu;
|
|
||||||
|
|
||||||
ret = arm_smmu_rpm_get(smmu);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
arm_smmu_master_free_smes(cfg, fwspec);
|
arm_smmu_master_free_smes(cfg, fwspec);
|
||||||
|
|
||||||
arm_smmu_rpm_put(smmu);
|
arm_smmu_rpm_put(cfg->smmu);
|
||||||
|
|
||||||
dev_iommu_priv_set(dev, NULL);
|
dev_iommu_priv_set(dev, NULL);
|
||||||
kfree(cfg);
|
kfree(cfg);
|
||||||
iommu_fwspec_free(dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arm_smmu_probe_finalize(struct device *dev)
|
static void arm_smmu_probe_finalize(struct device *dev)
|
||||||
|
@ -532,16 +532,6 @@ static struct iommu_device *qcom_iommu_probe_device(struct device *dev)
|
|||||||
return &qcom_iommu->iommu;
|
return &qcom_iommu->iommu;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qcom_iommu_release_device(struct device *dev)
|
|
||||||
{
|
|
||||||
struct qcom_iommu_dev *qcom_iommu = to_iommu(dev);
|
|
||||||
|
|
||||||
if (!qcom_iommu)
|
|
||||||
return;
|
|
||||||
|
|
||||||
iommu_fwspec_free(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
|
static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
|
||||||
{
|
{
|
||||||
struct qcom_iommu_dev *qcom_iommu;
|
struct qcom_iommu_dev *qcom_iommu;
|
||||||
@ -591,7 +581,6 @@ static const struct iommu_ops qcom_iommu_ops = {
|
|||||||
.capable = qcom_iommu_capable,
|
.capable = qcom_iommu_capable,
|
||||||
.domain_alloc = qcom_iommu_domain_alloc,
|
.domain_alloc = qcom_iommu_domain_alloc,
|
||||||
.probe_device = qcom_iommu_probe_device,
|
.probe_device = qcom_iommu_probe_device,
|
||||||
.release_device = qcom_iommu_release_device,
|
|
||||||
.device_group = generic_device_group,
|
.device_group = generic_device_group,
|
||||||
.of_xlate = qcom_iommu_of_xlate,
|
.of_xlate = qcom_iommu_of_xlate,
|
||||||
.pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M,
|
.pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M,
|
||||||
|
@ -1251,9 +1251,6 @@ static void exynos_iommu_release_device(struct device *dev)
|
|||||||
struct exynos_iommu_owner *owner = dev_iommu_priv_get(dev);
|
struct exynos_iommu_owner *owner = dev_iommu_priv_get(dev);
|
||||||
struct sysmmu_drvdata *data;
|
struct sysmmu_drvdata *data;
|
||||||
|
|
||||||
if (!has_sysmmu(dev))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (owner->domain) {
|
if (owner->domain) {
|
||||||
struct iommu_group *group = iommu_group_get(dev);
|
struct iommu_group *group = iommu_group_get(dev);
|
||||||
|
|
||||||
|
@ -819,17 +819,12 @@ static void mtk_iommu_release_device(struct device *dev)
|
|||||||
struct device *larbdev;
|
struct device *larbdev;
|
||||||
unsigned int larbid;
|
unsigned int larbid;
|
||||||
|
|
||||||
if (!fwspec || fwspec->ops != &mtk_iommu_ops)
|
|
||||||
return;
|
|
||||||
|
|
||||||
data = dev_iommu_priv_get(dev);
|
data = dev_iommu_priv_get(dev);
|
||||||
if (MTK_IOMMU_IS_TYPE(data->plat_data, MTK_IOMMU_TYPE_MM)) {
|
if (MTK_IOMMU_IS_TYPE(data->plat_data, MTK_IOMMU_TYPE_MM)) {
|
||||||
larbid = MTK_M4U_TO_LARB(fwspec->ids[0]);
|
larbid = MTK_M4U_TO_LARB(fwspec->ids[0]);
|
||||||
larbdev = data->larb_imu[larbid].dev;
|
larbdev = data->larb_imu[larbid].dev;
|
||||||
device_link_remove(dev, larbdev);
|
device_link_remove(dev, larbdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
iommu_fwspec_free(dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mtk_iommu_get_group_id(struct device *dev, const struct mtk_iommu_plat_data *plat_data)
|
static int mtk_iommu_get_group_id(struct device *dev, const struct mtk_iommu_plat_data *plat_data)
|
||||||
|
@ -532,15 +532,10 @@ static void mtk_iommu_v1_release_device(struct device *dev)
|
|||||||
struct device *larbdev;
|
struct device *larbdev;
|
||||||
unsigned int larbid;
|
unsigned int larbid;
|
||||||
|
|
||||||
if (!fwspec || fwspec->ops != &mtk_iommu_v1_ops)
|
|
||||||
return;
|
|
||||||
|
|
||||||
data = dev_iommu_priv_get(dev);
|
data = dev_iommu_priv_get(dev);
|
||||||
larbid = mt2701_m4u_to_larb(fwspec->ids[0]);
|
larbid = mt2701_m4u_to_larb(fwspec->ids[0]);
|
||||||
larbdev = data->larb_imu[larbid].dev;
|
larbdev = data->larb_imu[larbid].dev;
|
||||||
device_link_remove(dev, larbdev);
|
device_link_remove(dev, larbdev);
|
||||||
|
|
||||||
iommu_fwspec_free(dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mtk_iommu_v1_hw_init(const struct mtk_iommu_v1_data *data)
|
static int mtk_iommu_v1_hw_init(const struct mtk_iommu_v1_data *data)
|
||||||
|
@ -383,16 +383,6 @@ static struct iommu_device *sprd_iommu_probe_device(struct device *dev)
|
|||||||
return &sdev->iommu;
|
return &sdev->iommu;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sprd_iommu_release_device(struct device *dev)
|
|
||||||
{
|
|
||||||
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
|
||||||
|
|
||||||
if (!fwspec || fwspec->ops != &sprd_iommu_ops)
|
|
||||||
return;
|
|
||||||
|
|
||||||
iommu_fwspec_free(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct iommu_group *sprd_iommu_device_group(struct device *dev)
|
static struct iommu_group *sprd_iommu_device_group(struct device *dev)
|
||||||
{
|
{
|
||||||
struct sprd_iommu_device *sdev = dev_iommu_priv_get(dev);
|
struct sprd_iommu_device *sdev = dev_iommu_priv_get(dev);
|
||||||
@ -417,7 +407,6 @@ static int sprd_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
|
|||||||
static const struct iommu_ops sprd_iommu_ops = {
|
static const struct iommu_ops sprd_iommu_ops = {
|
||||||
.domain_alloc = sprd_iommu_domain_alloc,
|
.domain_alloc = sprd_iommu_domain_alloc,
|
||||||
.probe_device = sprd_iommu_probe_device,
|
.probe_device = sprd_iommu_probe_device,
|
||||||
.release_device = sprd_iommu_release_device,
|
|
||||||
.device_group = sprd_iommu_device_group,
|
.device_group = sprd_iommu_device_group,
|
||||||
.of_xlate = sprd_iommu_of_xlate,
|
.of_xlate = sprd_iommu_of_xlate,
|
||||||
.pgsize_bitmap = ~0UL << SPRD_IOMMU_PAGE_SHIFT,
|
.pgsize_bitmap = ~0UL << SPRD_IOMMU_PAGE_SHIFT,
|
||||||
|
@ -981,13 +981,7 @@ static void viommu_probe_finalize(struct device *dev)
|
|||||||
|
|
||||||
static void viommu_release_device(struct device *dev)
|
static void viommu_release_device(struct device *dev)
|
||||||
{
|
{
|
||||||
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
struct viommu_endpoint *vdev = dev_iommu_priv_get(dev);
|
||||||
struct viommu_endpoint *vdev;
|
|
||||||
|
|
||||||
if (!fwspec || fwspec->ops != &viommu_ops)
|
|
||||||
return;
|
|
||||||
|
|
||||||
vdev = dev_iommu_priv_get(dev);
|
|
||||||
|
|
||||||
generic_iommu_put_resv_regions(dev, &vdev->resv_regions);
|
generic_iommu_put_resv_regions(dev, &vdev->resv_regions);
|
||||||
kfree(vdev);
|
kfree(vdev);
|
||||||
|
Loading…
Reference in New Issue
Block a user