Skip to contentSkip to conversation

drm/rockchip: remove redundant statement

PATCH Applied John Keeping 2 participants 4 messages Apr 5, 2016 – Apr 11, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/rockchip: remove redundant statement

The call to arm_iommu_detach_device() on the previous line sets dev->archdata.mapping to NULL so this call is always a no-op.

---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +0 -1
index f556a8f..7695c79 100644
@@ -244,7 +244,6 @@ static int rockchip_drm_unload(struct drm_device *drm_dev)
 	drm_kms_helper_poll_fini(drm_dev);
 	component_unbind_all(dev, drm_dev);
 	arm_iommu_detach_device(dev);
-	arm_iommu_release_mapping(dev->archdata.mapping);
 	drm_mode_config_cleanup(drm_dev);
 	drm_dev->dev_private = NULL;
 
Signature · 1 line
2.8.0.rc4.238.g874082a
#1 lore raw

PATCH 2/2 drm/rockchip: don't leak iommu mapping

arm_iommu_attach_device() takes its own reference to the mapping we give it. Since we do not keep a reference to the mapping ourselves, we must release it before returning.

Also fix the error path, which fails to release the mapping if it has called arm_iommu_detach_device() since that clears archdata.mapping.

---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +2 -1
index 7695c79..1e2d88b 100644
@@ -218,6 +218,7 @@ static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
 	if (ret)
 		goto err_vblank_cleanup;
 
+	arm_iommu_release_mapping(mapping);
 	return 0;
 err_vblank_cleanup:
 	drm_vblank_cleanup(drm_dev);
@@ -228,7 +229,7 @@ err_unbind:
 err_detach_device:
 	arm_iommu_detach_device(dev);
 err_release_mapping:
-	arm_iommu_release_mapping(dev->archdata.mapping);
+	arm_iommu_release_mapping(mapping);
 err_config_cleanup:
 	drm_mode_config_cleanup(drm_dev);
 	drm_dev->dev_private = NULL;
Signature · 1 line
2.8.0.rc4.238.g874082a
Applied
#3 lore raw
In reply to John Keeping
Quoted 13 lines · John Keeping

The call to arm_iommu_detach_device() on the previous line sets dev->archdata.mapping to NULL so this call is always a no-op.

---
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 -
  1 file changed, 1 deletion(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +0 -0
index f556a8f..7695c79 100644

drivers/gpu/drm/rockchip/rockchip_drm_drv.c static int rockchip_drm_unload(struct drm_device *drm_dev) · line 249

Quoted 7 lines
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +0 -1
@@ -244,7 +244,6 @@ static int rockchip_drm_unload(struct drm_device *drm_dev)
  	drm_kms_helper_poll_fini(drm_dev);
  	component_unbind_all(dev, drm_dev);
  	arm_iommu_detach_device(dev);
-	arm_iommu_release_mapping(dev->archdata.mapping);
  	drm_mode_config_cleanup(drm_dev);
  	drm_dev->dev_private = NULL;
 

Applied to my drm-fixes

Thanks.:-)

Signature · 1 line
?ark Yao
Applied
#2 lore raw

Re: [PATCH 2/2] drm/rockchip: don't leak iommu mapping

In reply to John Keeping
Quoted 25 lines · John Keeping

arm_iommu_attach_device() takes its own reference to the mapping we give it. Since we do not keep a reference to the mapping ourselves, we must release it before returning.

Also fix the error path, which fails to release the mapping if it has called arm_iommu_detach_device() since that clears archdata.mapping.

---
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -0
index 7695c79..1e2d88b 100644
@@ -218,6 +218,7 @@ static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
  	if (ret)
  		goto err_vblank_cleanup;
 
+	arm_iommu_release_mapping(mapping);
  	return 0;
  err_vblank_cleanup:
  	drm_vblank_cleanup(drm_dev);

drivers/gpu/drm/rockchip/rockchip_drm_drv.c err_unbind: · line 235

Quoted 8 lines
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
@@ -228,7 +229,7 @@ err_unbind:
  err_detach_device:
  	arm_iommu_detach_device(dev);
  err_release_mapping:
-	arm_iommu_release_mapping(dev->archdata.mapping);
+	arm_iommu_release_mapping(mapping);
  err_config_cleanup:
  	drm_mode_config_cleanup(drm_dev);
  	drm_dev->dev_private = NULL;

Applied to my drm-fixes

Thanks.

Signature · 1 line
?ark Yao