Commit 368c89d7 authored by Felipe Franciosi's avatar Felipe Franciosi Committed by Jens Axboe

mtip32xx: Unmap the DMA segments before completing the IO request

If the buffers are unmapped after completing a request, then stale data
might be in the request.
Signed-off-by: default avatarFelipe Franciosi <felipe@paradoxo.org>
Cc: stable@kernel.org
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 1044b1bb
...@@ -266,6 +266,12 @@ static void mtip_async_complete(struct mtip_port *port, ...@@ -266,6 +266,12 @@ static void mtip_async_complete(struct mtip_port *port,
"Command tag %d failed due to TFE\n", tag); "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 */ /* Upper layer callback */
if (likely(command->async_callback)) if (likely(command->async_callback))
command->async_callback(command->async_data, cb_status); command->async_callback(command->async_data, cb_status);
...@@ -273,12 +279,6 @@ static void mtip_async_complete(struct mtip_port *port, ...@@ -273,12 +279,6 @@ static void mtip_async_complete(struct mtip_port *port,
command->async_callback = NULL; command->async_callback = NULL;
command->comp_func = 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 */ /* Clear the allocated and active bits for the command */
atomic_set(&port->commands[tag].active, 0); atomic_set(&port->commands[tag].active, 0);
release_slot(port, tag); release_slot(port, tag);
...@@ -709,6 +709,12 @@ static void mtip_timeout_function(unsigned long int data) ...@@ -709,6 +709,12 @@ static void mtip_timeout_function(unsigned long int data)
*/ */
writel(1 << bit, port->completed[group]); 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. */ /* Call the async completion callback. */
if (likely(command->async_callback)) if (likely(command->async_callback))
command->async_callback(command->async_data, command->async_callback(command->async_data,
...@@ -716,12 +722,6 @@ static void mtip_timeout_function(unsigned long int data) ...@@ -716,12 +722,6 @@ static void mtip_timeout_function(unsigned long int data)
command->async_callback = NULL; command->async_callback = NULL;
command->comp_func = 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 * Clear the allocated bit and active tag for the
* command. * command.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment