]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mtip32xx: convert to batch completion
authorKent Overstreet <koverstreet@google.com>
Wed, 20 Feb 2013 02:16:57 +0000 (13:16 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:54:12 +0000 (16:54 +1100)
Signed-off-by: Kent Overstreet <koverstreet@google.com>
Cc: Zach Brown <zab@redhat.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Asai Thambi S P <asamymuthupa@micron.com>
Cc: Selvan Mani <smani@micron.com>
Cc: Sam Bradshaw <sbradshaw@micron.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/mtip32xx/mtip32xx.c
drivers/block/mtip32xx/mtip32xx.h

index 11cc9522cdd439ff3db29825037c4f866bc28abb..8bedaf46792fd253e966765d0c3a0a5f87c910c5 100644 (file)
@@ -161,11 +161,9 @@ static void mtip_command_cleanup(struct driver_data *dd)
                        command = &port->commands[commandindex];
 
                        if (atomic_read(&command->active)
-                           && (command->async_callback)) {
-                               command->async_callback(command->async_data,
-                                       -ENODEV);
-                               command->async_callback = NULL;
-                               command->async_data = NULL;
+                           && (command->bio)) {
+                               bio_endio(command->bio, -ENODEV);
+                               command->bio = NULL;
                        }
 
                        dma_unmap_sg(&port->dd->pdev->dev,
@@ -606,11 +604,9 @@ static void mtip_timeout_function(unsigned long int data)
                        writel(1 << bit, port->completed[group]);
 
                        /* Call the async completion callback. */
-                       if (likely(command->async_callback))
-                               command->async_callback(command->async_data,
-                                                        -EIO);
-                       command->async_callback = NULL;
-                       command->comp_func = NULL;
+                       if (likely(command->bio))
+                               bio_endio(command->bio, -EIO);
+                       command->bio = NULL;
 
                        /* Unmap the DMA scatter list entries */
                        dma_unmap_sg(&port->dd->pdev->dev,
@@ -679,7 +675,8 @@ static void mtip_timeout_function(unsigned long int data)
 static void mtip_async_complete(struct mtip_port *port,
                                int tag,
                                void *data,
-                               int status)
+                               int status,
+                               struct batch_complete *batch)
 {
        struct mtip_cmd *command;
        struct driver_data *dd = data;
@@ -696,11 +693,10 @@ static void mtip_async_complete(struct mtip_port *port,
        }
 
        /* Upper layer callback */
-       if (likely(command->async_callback))
-               command->async_callback(command->async_data, cb_status);
+       if (likely(command->bio))
+               bio_endio_batch(command->bio, cb_status, batch);
 
-       command->async_callback = NULL;
-       command->comp_func = NULL;
+       command->bio = NULL;
 
        /* Unmap the DMA scatter list entries */
        dma_unmap_sg(&dd->pdev->dev,
@@ -733,24 +729,22 @@ static void mtip_async_complete(struct mtip_port *port,
 static void mtip_completion(struct mtip_port *port,
                            int tag,
                            void *data,
-                           int status)
+                           int status,
+                           struct batch_complete *batch)
 {
-       struct mtip_cmd *command = &port->commands[tag];
        struct completion *waiting = data;
        if (unlikely(status == PORT_IRQ_TF_ERR))
                dev_warn(&port->dd->pdev->dev,
                        "Internal command %d completed with TFE\n", tag);
 
-       command->async_callback = NULL;
-       command->comp_func = NULL;
-
        complete(waiting);
 }
 
 static void mtip_null_completion(struct mtip_port *port,
                            int tag,
                            void *data,
-                           int status)
+                           int status,
+                           struct batch_complete *batch)
 {
        return;
 }
@@ -796,7 +790,7 @@ static void mtip_handle_tfe(struct driver_data *dd)
                atomic_inc(&cmd->active); /* active > 1 indicates error */
                if (cmd->comp_data && cmd->comp_func) {
                        cmd->comp_func(port, MTIP_TAG_INTERNAL,
-                                       cmd->comp_data, PORT_IRQ_TF_ERR);
+                                       cmd->comp_data, PORT_IRQ_TF_ERR, NULL);
                }
                goto handle_tfe_exit;
        }
@@ -829,7 +823,7 @@ static void mtip_handle_tfe(struct driver_data *dd)
                                cmd->comp_func(port,
                                         tag,
                                         cmd->comp_data,
-                                        0);
+                                        0, NULL);
                        } else {
                                dev_err(&port->dd->pdev->dev,
                                        "Missing completion func for tag %d",
@@ -916,7 +910,7 @@ static void mtip_handle_tfe(struct driver_data *dd)
                                        if (cmd->comp_func) {
                                                cmd->comp_func(port, tag,
                                                        cmd->comp_data,
-                                                       -ENODATA);
+                                                       -ENODATA, NULL);
                                        }
                                        continue;
                                }
@@ -946,7 +940,7 @@ static void mtip_handle_tfe(struct driver_data *dd)
                                        port,
                                        tag,
                                        cmd->comp_data,
-                                       PORT_IRQ_TF_ERR);
+                                       PORT_IRQ_TF_ERR, NULL);
                        else
                                dev_warn(&port->dd->pdev->dev,
                                        "Bad completion for tag %d\n",
@@ -973,6 +967,9 @@ static inline void mtip_workq_sdbfx(struct mtip_port *port, int group,
        struct driver_data *dd = port->dd;
        int tag, bit;
        struct mtip_cmd *command;
+       struct batch_complete batch;
+
+       batch_complete_init(&batch);
 
        if (!completed) {
                WARN_ON_ONCE(!completed);
@@ -997,7 +994,8 @@ static inline void mtip_workq_sdbfx(struct mtip_port *port, int group,
                                        port,
                                        tag,
                                        command->comp_data,
-                                       0);
+                                               0,
+                                               &batch);
                        } else {
                                dev_warn(&dd->pdev->dev,
                                        "Null completion "
@@ -1034,7 +1032,7 @@ static inline void mtip_process_legacy(struct driver_data *dd, u32 port_stat)
                        cmd->comp_func(port,
                                MTIP_TAG_INTERNAL,
                                cmd->comp_data,
-                               0);
+                               0, NULL);
                        return;
                }
        }
@@ -2554,8 +2552,8 @@ static int mtip_hw_ioctl(struct driver_data *dd, unsigned int cmd,
  *     None
  */
 static void mtip_hw_submit_io(struct driver_data *dd, sector_t sector,
-                             int nsect, int nents, int tag, void *callback,
-                             void *data, int dir)
+                             int nsect, int nents, int tag,
+                             struct bio *bio, int dir)
 {
        struct host_to_dev_fis  *fis;
        struct mtip_port *port = dd->port;
@@ -2610,12 +2608,7 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t sector,
        command->comp_func = mtip_async_complete;
        command->direction = dma_dir;
 
-       /*
-        * Set the completion function and data for the command passed
-        * from the upper layer.
-        */
-       command->async_data = data;
-       command->async_callback = callback;
+       command->bio = bio;
 
        /*
         * To prevent this command from being issued
@@ -3795,7 +3788,6 @@ static void mtip_make_request(struct request_queue *queue, struct bio *bio)
                                bio_sectors(bio),
                                nents,
                                tag,
-                               bio_endio,
                                bio,
                                bio_data_dir(bio));
        } else
index 3bffff5f670cc66f55f01ca5953f9d47702468ac..af8c6f79a8d8192b0274e399af45143710251893 100644 (file)
@@ -325,11 +325,9 @@ struct mtip_cmd {
        void (*comp_func)(struct mtip_port *port,
                                int tag,
                                void *data,
-                               int status);
-       /* Additional callback function that may be called by comp_func() */
-       void (*async_callback)(void *data, int status);
-
-       void *async_data; /* Addl. data passed to async_callback() */
+                               int status,
+                               struct batch_complete *batch);
+       struct bio *bio;
 
        int scatter_ents; /* Number of scatter list entries used */