]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mtip32xx: Unmap the DMA segments before completing the IO request
authorFelipe Franciosi <felipe@paradoxo.org>
Thu, 13 Mar 2014 14:34:21 +0000 (14:34 +0000)
committerJiri Slaby <jslaby@suse.cz>
Thu, 15 May 2014 07:55:35 +0000 (09:55 +0200)
commit 368c89d7ac70f937c93cd6f3b65bcfdfb3ba794f upstream.

If the buffers are unmapped after completing a request, then stale data
might be in the request.

Signed-off-by: Felipe Franciosi <felipe@paradoxo.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/block/mtip32xx/mtip32xx.c

index bd3d207419589944b93f69326cc4d58cede3a001..4d26c25aa9c5c01a9b8a7852c4ffd7d3c2c3a9d7 100644 (file)
@@ -621,6 +621,12 @@ static void mtip_timeout_function(unsigned long int data)
                         */
                        writel(1 << bit, port->completed[group]);
 
+                       /* Unmap the DMA scatter list entries */
+                       dma_unmap_sg(&port->dd->pdev->dev,
+                                       command->sg,
+                                       command->scatter_ents,
+                                       command->direction);
+
                        /* Call the async completion callback. */
                        if (likely(command->async_callback))
                                command->async_callback(command->async_data,
@@ -628,12 +634,6 @@ static void mtip_timeout_function(unsigned long int data)
                        command->async_callback = NULL;
                        command->comp_func = NULL;
 
-                       /* Unmap the DMA scatter list entries */
-                       dma_unmap_sg(&port->dd->pdev->dev,
-                                       command->sg,
-                                       command->scatter_ents,
-                                       command->direction);
-
                        /*
                         * Clear the allocated bit and active tag for the
                         * command.
@@ -711,6 +711,12 @@ static void mtip_async_complete(struct mtip_port *port,
                        "Command tag %d failed due to TFE\n", tag);
        }
 
+       /* Unmap the DMA scatter list entries */
+       dma_unmap_sg(&dd->pdev->dev,
+               command->sg,
+               command->scatter_ents,
+               command->direction);
+
        /* Upper layer callback */
        if (likely(command->async_callback))
                command->async_callback(command->async_data, cb_status);
@@ -718,12 +724,6 @@ static void mtip_async_complete(struct mtip_port *port,
        command->async_callback = NULL;
        command->comp_func = NULL;
 
-       /* Unmap the DMA scatter list entries */
-       dma_unmap_sg(&dd->pdev->dev,
-               command->sg,
-               command->scatter_ents,
-               command->direction);
-
        /* Clear the allocated and active bits for the command */
        atomic_set(&port->commands[tag].active, 0);
        release_slot(port, tag);