Commit f2b8b522 authored by Adrian Hunter's avatar Adrian Hunter Committed by Ulf Hansson

mmc: queue: Factor out mmc_queue_alloc_bounce_sgs()

In preparation for supporting a queue of requests, factor out
mmc_queue_alloc_bounce_sgs().
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarHarjani Ritesh <riteshh@codeaurora.org>
[Ulf: Fixed compiler warning]
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent c853982e
...@@ -211,6 +211,30 @@ static bool mmc_queue_alloc_bounce_bufs(struct mmc_queue *mq, ...@@ -211,6 +211,30 @@ static bool mmc_queue_alloc_bounce_bufs(struct mmc_queue *mq,
return true; return true;
} }
static int mmc_queue_alloc_bounce_sgs(struct mmc_queue *mq,
unsigned int bouncesz)
{
struct mmc_queue_req *mqrq_cur = mq->mqrq_cur;
struct mmc_queue_req *mqrq_prev = mq->mqrq_prev;
int ret;
mqrq_cur->sg = mmc_alloc_sg(1, &ret);
if (ret)
return ret;
mqrq_cur->bounce_sg = mmc_alloc_sg(bouncesz / 512, &ret);
if (ret)
return ret;
mqrq_prev->sg = mmc_alloc_sg(1, &ret);
if (ret)
return ret;
mqrq_prev->bounce_sg = mmc_alloc_sg(bouncesz / 512, &ret);
return ret;
}
#endif #endif
/** /**
...@@ -227,6 +251,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, ...@@ -227,6 +251,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
{ {
struct mmc_host *host = card->host; struct mmc_host *host = card->host;
u64 limit = BLK_BOUNCE_HIGH; u64 limit = BLK_BOUNCE_HIGH;
bool bounce = false;
int ret; int ret;
struct mmc_queue_req *mqrq_cur = &mq->mqrq[0]; struct mmc_queue_req *mqrq_cur = &mq->mqrq[0];
struct mmc_queue_req *mqrq_prev = &mq->mqrq[1]; struct mmc_queue_req *mqrq_prev = &mq->mqrq[1];
...@@ -269,28 +294,15 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, ...@@ -269,28 +294,15 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
blk_queue_max_segments(mq->queue, bouncesz / 512); blk_queue_max_segments(mq->queue, bouncesz / 512);
blk_queue_max_segment_size(mq->queue, bouncesz); blk_queue_max_segment_size(mq->queue, bouncesz);
mqrq_cur->sg = mmc_alloc_sg(1, &ret); ret = mmc_queue_alloc_bounce_sgs(mq, bouncesz);
if (ret)
goto cleanup_queue;
mqrq_cur->bounce_sg =
mmc_alloc_sg(bouncesz / 512, &ret);
if (ret)
goto cleanup_queue;
mqrq_prev->sg = mmc_alloc_sg(1, &ret);
if (ret)
goto cleanup_queue;
mqrq_prev->bounce_sg =
mmc_alloc_sg(bouncesz / 512, &ret);
if (ret) if (ret)
goto cleanup_queue; goto cleanup_queue;
bounce = true;
} }
} }
#endif #endif
if (!mqrq_cur->bounce_buf && !mqrq_prev->bounce_buf) { if (!bounce) {
blk_queue_bounce_limit(mq->queue, limit); blk_queue_bounce_limit(mq->queue, limit);
blk_queue_max_hw_sectors(mq->queue, blk_queue_max_hw_sectors(mq->queue,
min(host->max_blk_count, host->max_req_size / 512)); min(host->max_blk_count, host->max_req_size / 512));
......
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