drm/omap: dmm_tiler: Fix interrupt request/free sequence during probe/remove
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Wed, 26 Sep 2018 09:11:29 +0000 (12:11 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 2 Oct 2018 06:36:56 +0000 (09:36 +0300)
The interrupts should be enabled after the driver initialization to avoid
early interrupts while the driver is not yet ready to handle them.

On removal the interrupts must be disabled before other resources are
released, freed up.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c

index be45f29..624d202 100644 (file)
@@ -614,6 +614,10 @@ static int omap_dmm_remove(struct platform_device *dev)
        unsigned long flags;
 
        if (omap_dmm) {
+               /* Disable all enabled interrupts */
+               dmm_write(omap_dmm, 0x7e7e7e7e, DMM_PAT_IRQENABLE_CLR);
+               free_irq(omap_dmm->irq, omap_dmm);
+
                /* free all area regions */
                spin_lock_irqsave(&list_lock, flags);
                list_for_each_entry_safe(block, _block, &omap_dmm->alloc_head,
@@ -636,8 +640,6 @@ static int omap_dmm_remove(struct platform_device *dev)
                if (omap_dmm->dummy_page)
                        __free_page(omap_dmm->dummy_page);
 
-               free_irq(omap_dmm->irq, omap_dmm);
-
                iounmap(omap_dmm->base);
                kfree(omap_dmm);
                omap_dmm = NULL;
@@ -724,24 +726,6 @@ static int omap_dmm_probe(struct platform_device *dev)
        dmm_write(omap_dmm, 0x88888888, DMM_TILER_OR__0);
        dmm_write(omap_dmm, 0x88888888, DMM_TILER_OR__1);
 
-       ret = request_irq(omap_dmm->irq, omap_dmm_irq_handler, IRQF_SHARED,
-                               "omap_dmm_irq_handler", omap_dmm);
-
-       if (ret) {
-               dev_err(&dev->dev, "couldn't register IRQ %d, error %d\n",
-                       omap_dmm->irq, ret);
-               omap_dmm->irq = -1;
-               goto fail;
-       }
-
-       /* Enable all interrupts for each refill engine except
-        * ERR_LUT_MISS<n> (which is just advisory, and we don't care
-        * about because we want to be able to refill live scanout
-        * buffers for accelerated pan/scroll) and FILL_DSC<n> which
-        * we just generally don't care about.
-        */
-       dmm_write(omap_dmm, 0x7e7e7e7e, DMM_PAT_IRQENABLE_SET);
-
        omap_dmm->dummy_page = alloc_page(GFP_KERNEL | __GFP_DMA32);
        if (!omap_dmm->dummy_page) {
                dev_err(&dev->dev, "could not allocate dummy page\n");
@@ -833,6 +817,24 @@ static int omap_dmm_probe(struct platform_device *dev)
                .p1.y = omap_dmm->container_height - 1,
        };
 
+       ret = request_irq(omap_dmm->irq, omap_dmm_irq_handler, IRQF_SHARED,
+                               "omap_dmm_irq_handler", omap_dmm);
+
+       if (ret) {
+               dev_err(&dev->dev, "couldn't register IRQ %d, error %d\n",
+                       omap_dmm->irq, ret);
+               omap_dmm->irq = -1;
+               goto fail;
+       }
+
+       /* Enable all interrupts for each refill engine except
+        * ERR_LUT_MISS<n> (which is just advisory, and we don't care
+        * about because we want to be able to refill live scanout
+        * buffers for accelerated pan/scroll) and FILL_DSC<n> which
+        * we just generally don't care about.
+        */
+       dmm_write(omap_dmm, 0x7e7e7e7e, DMM_PAT_IRQENABLE_SET);
+
        /* initialize all LUTs to dummy page entries */
        for (i = 0; i < omap_dmm->num_lut; i++) {
                area.tcm = omap_dmm->tcm[i];