Commit 986394da authored by Russell King's avatar Russell King

[MMC] Add support for passing scatterlists to MMC host drivers.

This is intended to remove block layer knowledge from MMC host
drivers.  Host drivers are expected to use the scatter list for
data transfers rather than accessing the struct request.
parent acf042ef
......@@ -200,6 +200,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
}
brq.mrq.stop = brq.data.blocks > 1 ? &brq.stop : NULL;
brq.data.sg = mq->sg;
brq.data.sg_len = blk_rq_map_sg(req->q, req, brq.data.sg);
mmc_wait_for_req(card->host, &brq.mrq);
if (brq.cmd.error) {
printk(KERN_ERR "%s: error %d sending read/write command\n",
......
......@@ -147,19 +147,31 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
mq->queue->queuedata = mq;
mq->req = NULL;
mq->sg = kmalloc(sizeof(struct scatterlist) * host->max_phys_segs,
GFP_KERNEL);
if (!mq->sg) {
ret = -ENOMEM;
goto cleanup;
}
init_completion(&mq->thread_complete);
init_waitqueue_head(&mq->thread_wq);
init_MUTEX(&mq->thread_sem);
ret = kernel_thread(mmc_queue_thread, mq, CLONE_KERNEL);
if (ret < 0) {
blk_cleanup_queue(mq->queue);
} else {
if (ret >= 0) {
wait_for_completion(&mq->thread_complete);
init_completion(&mq->thread_complete);
ret = 0;
goto out;
}
cleanup:
kfree(mq->sg);
mq->sg = NULL;
blk_cleanup_queue(mq->queue);
out:
return ret;
}
EXPORT_SYMBOL(mmc_init_queue);
......@@ -169,6 +181,10 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
mq->flags |= MMC_QUEUE_EXIT;
wake_up(&mq->thread_wq);
wait_for_completion(&mq->thread_complete);
kfree(mq->sg);
mq->sg = NULL;
blk_cleanup_queue(mq->queue);
mq->card = NULL;
......
......@@ -15,6 +15,7 @@ struct mmc_queue {
int (*issue_fn)(struct mmc_queue *, struct request *);
void *data;
struct request_queue *queue;
struct scatterlist *sg;
};
struct mmc_io_request {
......
......@@ -69,6 +69,9 @@ struct mmc_data {
struct mmc_command *stop; /* stop command */
struct mmc_request *mrq; /* assoicated request */
unsigned int sg_len; /* size of scatter list */
struct scatterlist *sg; /* I/O scatter list */
};
struct mmc_request {
......
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