]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/gpu/host1x/dev.c
gpu: host1x: Free the IOMMU domain when there is no device to attach
[karo-tx-linux.git] / drivers / gpu / host1x / dev.c
index ac65f52850a6351e3ecb3ee27816b4c3d8df5e67..7782725141648360cedd89f3363155da5f7c8d9c 100644 (file)
@@ -186,8 +186,13 @@ static int host1x_probe(struct platform_device *pdev)
                        return -ENOMEM;
 
                err = iommu_attach_device(host->domain, &pdev->dev);
-               if (err)
+               if (err == -ENODEV) {
+                       iommu_domain_free(host->domain);
+                       host->domain = NULL;
+                       goto skip_iommu;
+               } else if (err) {
                        goto fail_free_domain;
+               }
 
                geometry = &host->domain->geometry;
 
@@ -198,7 +203,9 @@ static int host1x_probe(struct platform_device *pdev)
                host->iova_end = geometry->aperture_end;
        }
 
-       err = host1x_channel_list_init(host);
+skip_iommu:
+       err = host1x_channel_list_init(&host->channel_list,
+                                      host->info->nb_channels);
        if (err) {
                dev_err(&pdev->dev, "failed to initialize channel list\n");
                goto fail_detach_device;
@@ -207,7 +214,7 @@ static int host1x_probe(struct platform_device *pdev)
        err = clk_prepare_enable(host->clk);
        if (err < 0) {
                dev_err(&pdev->dev, "failed to enable clock\n");
-               goto fail_detach_device;
+               goto fail_free_channels;
        }
 
        err = reset_control_deassert(host->rst);
@@ -244,6 +251,8 @@ fail_reset_assert:
        reset_control_assert(host->rst);
 fail_unprepare_disable:
        clk_disable_unprepare(host->clk);
+fail_free_channels:
+       host1x_channel_list_free(&host->channel_list);
 fail_detach_device:
        if (host->domain) {
                put_iova_domain(&host->iova);