mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
Revert "drm/rockchip: rewrite IOMMU support code"
This reverts commit b435f1a281.
Conflicts:
drivers/gpu/drm/rockchip/Kconfig
drivers/gpu/drm/rockchip/rockchip_drm_drv.h
Change-Id: I15d2d598514c2878a574219fe2268ee8d530d6e2
Signed-off-by: Randy Li <randy.li@rock-chips.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/dma-iommu.h>
|
||||
#include <asm/dma-iommu.h>
|
||||
|
||||
#include <drm/drmP.h>
|
||||
#include <drm/drm_atomic.h>
|
||||
@@ -614,8 +614,7 @@ err_unlock:
|
||||
int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
|
||||
struct device *dev)
|
||||
{
|
||||
struct rockchip_drm_private *private = drm_dev->dev_private;
|
||||
struct iommu_domain *domain = private->domain;
|
||||
struct dma_iommu_mapping *mapping = drm_dev->dev->archdata.mapping;
|
||||
int ret;
|
||||
|
||||
ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
|
||||
@@ -623,28 +622,14 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
|
||||
return ret;
|
||||
|
||||
dma_set_max_seg_size(dev, DMA_BIT_MASK(32));
|
||||
ret = iommu_attach_device(domain, dev);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to attach iommu device\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!common_iommu_setup_dma_ops(dev, 0x10000000, SZ_2G, domain->ops)) {
|
||||
dev_err(dev, "Failed to set dma_ops\n");
|
||||
iommu_detach_device(domain, dev);
|
||||
ret = -ENODEV;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return arm_iommu_attach_device(dev, mapping);
|
||||
}
|
||||
|
||||
void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
|
||||
struct device *dev)
|
||||
{
|
||||
struct rockchip_drm_private *private = drm_dev->dev_private;
|
||||
struct iommu_domain *domain = private->domain;
|
||||
|
||||
iommu_detach_device(domain, dev);
|
||||
arm_iommu_detach_device(dev);
|
||||
}
|
||||
|
||||
int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
|
||||
@@ -712,9 +697,9 @@ static void rockchip_drm_crtc_disable_vblank(struct drm_device *dev,
|
||||
static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
|
||||
{
|
||||
struct rockchip_drm_private *private;
|
||||
struct dma_iommu_mapping *mapping;
|
||||
struct device *dev = drm_dev->dev;
|
||||
struct drm_connector *connector;
|
||||
struct iommu_group *group;
|
||||
int ret;
|
||||
|
||||
private = devm_kzalloc(drm_dev->dev, sizeof(*private), GFP_KERNEL);
|
||||
@@ -742,36 +727,23 @@ static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
|
||||
goto err_config_cleanup;
|
||||
}
|
||||
|
||||
private->domain = iommu_domain_alloc(&platform_bus_type);
|
||||
if (!private->domain)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = iommu_get_dma_cookie(private->domain);
|
||||
if (ret)
|
||||
goto err_free_domain;
|
||||
|
||||
group = iommu_group_get(dev);
|
||||
if (!group) {
|
||||
group = iommu_group_alloc();
|
||||
if (IS_ERR(group)) {
|
||||
dev_err(dev, "Failed to allocate IOMMU group\n");
|
||||
goto err_put_cookie;
|
||||
}
|
||||
|
||||
ret = iommu_group_add_device(group, dev);
|
||||
iommu_group_put(group);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to add device to IOMMU group\n");
|
||||
goto err_put_cookie;
|
||||
}
|
||||
/* TODO(djkurtz): fetch the mapping start/size from somewhere */
|
||||
mapping = arm_iommu_create_mapping(&platform_bus_type, 0x00000000,
|
||||
SZ_2G);
|
||||
if (IS_ERR(mapping)) {
|
||||
ret = PTR_ERR(mapping);
|
||||
goto err_config_cleanup;
|
||||
}
|
||||
/*
|
||||
* Attach virtual iommu device, sub iommu device can share the same
|
||||
* mapping with it.
|
||||
*/
|
||||
ret = rockchip_drm_dma_attach_device(drm_dev, dev);
|
||||
|
||||
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
|
||||
if (ret)
|
||||
goto err_group_remove_device;
|
||||
goto err_release_mapping;
|
||||
|
||||
dma_set_max_seg_size(dev, DMA_BIT_MASK(32));
|
||||
|
||||
ret = arm_iommu_attach_device(dev, mapping);
|
||||
if (ret)
|
||||
goto err_release_mapping;
|
||||
|
||||
/* Try to bind all sub drivers. */
|
||||
ret = component_bind_all(dev, drm_dev);
|
||||
@@ -833,13 +805,9 @@ err_kms_helper_poll_fini:
|
||||
err_unbind:
|
||||
component_unbind_all(dev, drm_dev);
|
||||
err_detach_device:
|
||||
rockchip_drm_dma_detach_device(drm_dev, dev);
|
||||
err_group_remove_device:
|
||||
iommu_group_remove_device(dev);
|
||||
err_put_cookie:
|
||||
iommu_put_dma_cookie(private->domain);
|
||||
err_free_domain:
|
||||
iommu_domain_free(private->domain);
|
||||
arm_iommu_detach_device(dev);
|
||||
err_release_mapping:
|
||||
arm_iommu_release_mapping(dev->archdata.mapping);
|
||||
err_config_cleanup:
|
||||
drm_mode_config_cleanup(drm_dev);
|
||||
drm_dev->dev_private = NULL;
|
||||
@@ -849,16 +817,13 @@ err_config_cleanup:
|
||||
static int rockchip_drm_unload(struct drm_device *drm_dev)
|
||||
{
|
||||
struct device *dev = drm_dev->dev;
|
||||
struct rockchip_drm_private *private = drm_dev->dev_private;
|
||||
|
||||
rockchip_drm_fbdev_fini(drm_dev);
|
||||
drm_vblank_cleanup(drm_dev);
|
||||
drm_kms_helper_poll_fini(drm_dev);
|
||||
component_unbind_all(dev, drm_dev);
|
||||
rockchip_drm_dma_detach_device(drm_dev, dev);
|
||||
iommu_group_remove_device(dev);
|
||||
iommu_put_dma_cookie(private->domain);
|
||||
iommu_domain_free(private->domain);
|
||||
arm_iommu_detach_device(dev);
|
||||
arm_iommu_release_mapping(dev->archdata.mapping);
|
||||
drm_mode_config_cleanup(drm_dev);
|
||||
drm_dev->dev_private = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user