blob: 56e9a803db21b237a291a93d5e4aff9b305eafe0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2003 Russell King, All Rights Reserved.
Pierre Ossman98ac2162006-12-23 20:03:02 +01003 * Copyright 2006-2007 Pierre Ossman
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 */
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090010#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/module.h>
12#include <linux/blkdev.h>
Rafael J. Wysocki83144182007-07-17 04:03:35 -070013#include <linux/freezer.h>
Christoph Hellwig87598a22006-11-13 20:23:52 +010014#include <linux/kthread.h>
Jens Axboe45711f12007-10-22 21:19:53 +020015#include <linux/scatterlist.h>
Santosh Shilimkar8e0cb8a2013-07-29 14:20:15 +010016#include <linux/dma-mapping.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18#include <linux/mmc/card.h>
19#include <linux/mmc/host.h>
Linus Walleij29eb7bd2016-09-20 11:34:38 +020020
Pierre Ossman98ac2162006-12-23 20:03:02 +010021#include "queue.h"
Linus Walleij29eb7bd2016-09-20 11:34:38 +020022#include "block.h"
Ulf Hansson55244c52017-01-13 14:14:08 +010023#include "core.h"
Ulf Hansson4facdde2017-01-13 14:14:14 +010024#include "card.h"
Adrian Hunter81196972017-11-29 15:41:03 +020025#include "host.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Adrian Hunter1e8e55b2017-11-29 15:41:04 +020027static inline bool mmc_cqe_dcmd_busy(struct mmc_queue *mq)
28{
29 /* Allow only 1 DCMD at a time */
30 return mq->in_flight[MMC_ISSUE_DCMD];
31}
32
33void mmc_cqe_check_busy(struct mmc_queue *mq)
34{
35 if ((mq->cqe_busy & MMC_CQE_DCMD_BUSY) && !mmc_cqe_dcmd_busy(mq))
36 mq->cqe_busy &= ~MMC_CQE_DCMD_BUSY;
37
38 mq->cqe_busy &= ~MMC_CQE_QUEUE_FULL;
39}
40
41static inline bool mmc_cqe_can_dcmd(struct mmc_host *host)
42{
43 return host->caps2 & MMC_CAP2_CQE_DCMD;
44}
45
Colin Ian King15ff2942017-11-30 11:37:38 +000046static enum mmc_issue_type mmc_cqe_issue_type(struct mmc_host *host,
47 struct request *req)
Adrian Hunter1e8e55b2017-11-29 15:41:04 +020048{
49 switch (req_op(req)) {
50 case REQ_OP_DRV_IN:
51 case REQ_OP_DRV_OUT:
52 case REQ_OP_DISCARD:
53 case REQ_OP_SECURE_ERASE:
54 return MMC_ISSUE_SYNC;
55 case REQ_OP_FLUSH:
56 return mmc_cqe_can_dcmd(host) ? MMC_ISSUE_DCMD : MMC_ISSUE_SYNC;
57 default:
58 return MMC_ISSUE_ASYNC;
59 }
60}
61
Adrian Hunter81196972017-11-29 15:41:03 +020062enum mmc_issue_type mmc_issue_type(struct mmc_queue *mq, struct request *req)
63{
Adrian Hunter1e8e55b2017-11-29 15:41:04 +020064 struct mmc_host *host = mq->card->host;
65
66 if (mq->use_cqe)
67 return mmc_cqe_issue_type(host, req);
68
Adrian Hunter81196972017-11-29 15:41:03 +020069 if (req_op(req) == REQ_OP_READ || req_op(req) == REQ_OP_WRITE)
70 return MMC_ISSUE_ASYNC;
71
72 return MMC_ISSUE_SYNC;
73}
74
Adrian Hunter1e8e55b2017-11-29 15:41:04 +020075static void __mmc_cqe_recovery_notifier(struct mmc_queue *mq)
76{
77 if (!mq->recovery_needed) {
78 mq->recovery_needed = true;
79 schedule_work(&mq->recovery_work);
80 }
81}
82
83void mmc_cqe_recovery_notifier(struct mmc_request *mrq)
84{
85 struct mmc_queue_req *mqrq = container_of(mrq, struct mmc_queue_req,
86 brq.mrq);
87 struct request *req = mmc_queue_req_to_req(mqrq);
88 struct request_queue *q = req->q;
89 struct mmc_queue *mq = q->queuedata;
90 unsigned long flags;
91
92 spin_lock_irqsave(q->queue_lock, flags);
93 __mmc_cqe_recovery_notifier(mq);
94 spin_unlock_irqrestore(q->queue_lock, flags);
95}
96
97static enum blk_eh_timer_return mmc_cqe_timed_out(struct request *req)
98{
99 struct mmc_queue_req *mqrq = req_to_mmc_queue_req(req);
100 struct mmc_request *mrq = &mqrq->brq.mrq;
101 struct mmc_queue *mq = req->q->queuedata;
102 struct mmc_host *host = mq->card->host;
103 enum mmc_issue_type issue_type = mmc_issue_type(mq, req);
104 bool recovery_needed = false;
105
106 switch (issue_type) {
107 case MMC_ISSUE_ASYNC:
108 case MMC_ISSUE_DCMD:
109 if (host->cqe_ops->cqe_timeout(host, mrq, &recovery_needed)) {
110 if (recovery_needed)
111 __mmc_cqe_recovery_notifier(mq);
112 return BLK_EH_RESET_TIMER;
113 }
114 /* No timeout */
115 return BLK_EH_HANDLED;
116 default:
117 /* Timeout is handled by mmc core */
118 return BLK_EH_RESET_TIMER;
119 }
120}
121
Adrian Hunter81196972017-11-29 15:41:03 +0200122static enum blk_eh_timer_return mmc_mq_timed_out(struct request *req,
123 bool reserved)
124{
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200125 struct request_queue *q = req->q;
126 struct mmc_queue *mq = q->queuedata;
127 unsigned long flags;
128 int ret;
129
130 spin_lock_irqsave(q->queue_lock, flags);
131
132 if (mq->recovery_needed || !mq->use_cqe)
133 ret = BLK_EH_RESET_TIMER;
134 else
135 ret = mmc_cqe_timed_out(req);
136
137 spin_unlock_irqrestore(q->queue_lock, flags);
138
139 return ret;
140}
141
142static void mmc_mq_recovery_handler(struct work_struct *work)
143{
144 struct mmc_queue *mq = container_of(work, struct mmc_queue,
145 recovery_work);
146 struct request_queue *q = mq->queue;
147
148 mmc_get_card(mq->card, &mq->ctx);
149
150 mq->in_recovery = true;
151
Adrian Hunter10f21df42017-11-29 15:41:07 +0200152 if (mq->use_cqe)
153 mmc_blk_cqe_recovery(mq);
154 else
155 mmc_blk_mq_recovery(mq);
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200156
157 mq->in_recovery = false;
158
159 spin_lock_irq(q->queue_lock);
160 mq->recovery_needed = false;
161 spin_unlock_irq(q->queue_lock);
162
163 mmc_put_card(mq->card, &mq->ctx);
164
165 blk_mq_run_hw_queues(q, true);
Adrian Hunter81196972017-11-29 15:41:03 +0200166}
167
Linus Walleij304419d2017-05-18 11:29:32 +0200168static struct scatterlist *mmc_alloc_sg(int sg_len, gfp_t gfp)
Per Forlin97868a22011-07-09 17:12:36 -0400169{
170 struct scatterlist *sg;
171
Linus Walleij304419d2017-05-18 11:29:32 +0200172 sg = kmalloc_array(sg_len, sizeof(*sg), gfp);
Adrian Hunter7b410d02017-03-13 14:36:36 +0200173 if (sg)
Per Forlin97868a22011-07-09 17:12:36 -0400174 sg_init_table(sg, sg_len);
Per Forlin97868a22011-07-09 17:12:36 -0400175
176 return sg;
177}
178
Adrian Huntere056a1b2011-06-28 17:16:02 +0300179static void mmc_queue_setup_discard(struct request_queue *q,
180 struct mmc_card *card)
181{
182 unsigned max_discard;
183
184 max_discard = mmc_calc_max_discard(card);
185 if (!max_discard)
186 return;
187
Bart Van Assche8b904b52018-03-07 17:10:10 -0800188 blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
Jens Axboe2bb4cd52015-07-14 08:15:12 -0600189 blk_queue_max_discard_sectors(q, max_discard);
Adrian Huntere056a1b2011-06-28 17:16:02 +0300190 q->limits.discard_granularity = card->pref_erase << 9;
191 /* granularity must not be greater than max. discard */
192 if (card->pref_erase > max_discard)
193 q->limits.discard_granularity = 0;
Maya Erez775a9362013-04-18 15:41:55 +0300194 if (mmc_can_secure_erase_trim(card))
Bart Van Assche8b904b52018-03-07 17:10:10 -0800195 blk_queue_flag_set(QUEUE_FLAG_SECERASE, q);
Adrian Huntere056a1b2011-06-28 17:16:02 +0300196}
197
Linus Walleij304419d2017-05-18 11:29:32 +0200198/**
199 * mmc_init_request() - initialize the MMC-specific per-request data
200 * @q: the request queue
201 * @req: the request
202 * @gfp: memory allocation policy
203 */
Adrian Hunter81196972017-11-29 15:41:03 +0200204static int __mmc_init_request(struct mmc_queue *mq, struct request *req,
205 gfp_t gfp)
Adrian Hunterf2b8b522016-11-29 12:09:12 +0200206{
Linus Walleij304419d2017-05-18 11:29:32 +0200207 struct mmc_queue_req *mq_rq = req_to_mmc_queue_req(req);
Linus Walleij304419d2017-05-18 11:29:32 +0200208 struct mmc_card *card = mq->card;
209 struct mmc_host *host = card->host;
Adrian Hunterc8539822016-11-29 12:09:11 +0200210
Linus Walleijde3ee992017-09-20 10:56:14 +0200211 mq_rq->sg = mmc_alloc_sg(host->max_segs, gfp);
212 if (!mq_rq->sg)
213 return -ENOMEM;
Adrian Hunter64e29e422016-11-29 12:09:13 +0200214
Adrian Hunterc5bda0c2016-11-29 12:09:15 +0200215 return 0;
216}
Adrian Hunter64e29e422016-11-29 12:09:13 +0200217
Linus Walleij304419d2017-05-18 11:29:32 +0200218static void mmc_exit_request(struct request_queue *q, struct request *req)
Adrian Hunterc5bda0c2016-11-29 12:09:15 +0200219{
Linus Walleij304419d2017-05-18 11:29:32 +0200220 struct mmc_queue_req *mq_rq = req_to_mmc_queue_req(req);
Adrian Hunter64e29e422016-11-29 12:09:13 +0200221
Linus Walleij304419d2017-05-18 11:29:32 +0200222 kfree(mq_rq->sg);
223 mq_rq->sg = NULL;
Adrian Hunterc09949c2016-11-29 12:09:14 +0200224}
225
Adrian Hunter81196972017-11-29 15:41:03 +0200226static int mmc_mq_init_request(struct blk_mq_tag_set *set, struct request *req,
227 unsigned int hctx_idx, unsigned int numa_node)
228{
229 return __mmc_init_request(set->driver_data, req, GFP_KERNEL);
230}
231
232static void mmc_mq_exit_request(struct blk_mq_tag_set *set, struct request *req,
233 unsigned int hctx_idx)
234{
235 struct mmc_queue *mq = set->driver_data;
236
237 mmc_exit_request(mq->queue, req);
238}
239
240/*
241 * We use BLK_MQ_F_BLOCKING and have only 1 hardware queue, which means requests
242 * will not be dispatched in parallel.
243 */
244static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
245 const struct blk_mq_queue_data *bd)
246{
247 struct request *req = bd->rq;
248 struct request_queue *q = req->q;
249 struct mmc_queue *mq = q->queuedata;
250 struct mmc_card *card = mq->card;
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200251 struct mmc_host *host = card->host;
Adrian Hunter81196972017-11-29 15:41:03 +0200252 enum mmc_issue_type issue_type;
253 enum mmc_issued issued;
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200254 bool get_card, cqe_retune_ok;
Adrian Hunter81196972017-11-29 15:41:03 +0200255 int ret;
256
257 if (mmc_card_removed(mq->card)) {
258 req->rq_flags |= RQF_QUIET;
259 return BLK_STS_IOERR;
260 }
261
262 issue_type = mmc_issue_type(mq, req);
263
264 spin_lock_irq(q->queue_lock);
265
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200266 if (mq->recovery_needed) {
267 spin_unlock_irq(q->queue_lock);
268 return BLK_STS_RESOURCE;
269 }
270
Adrian Hunter81196972017-11-29 15:41:03 +0200271 switch (issue_type) {
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200272 case MMC_ISSUE_DCMD:
273 if (mmc_cqe_dcmd_busy(mq)) {
274 mq->cqe_busy |= MMC_CQE_DCMD_BUSY;
275 spin_unlock_irq(q->queue_lock);
276 return BLK_STS_RESOURCE;
277 }
278 break;
Adrian Hunter81196972017-11-29 15:41:03 +0200279 case MMC_ISSUE_ASYNC:
280 break;
281 default:
282 /*
283 * Timeouts are handled by mmc core, and we don't have a host
284 * API to abort requests, so we can't handle the timeout anyway.
285 * However, when the timeout happens, blk_mq_complete_request()
286 * no longer works (to stop the request disappearing under us).
287 * To avoid racing with that, set a large timeout.
288 */
289 req->timeout = 600 * HZ;
290 break;
291 }
292
293 mq->in_flight[issue_type] += 1;
294 get_card = (mmc_tot_in_flight(mq) == 1);
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200295 cqe_retune_ok = (mmc_cqe_qcnt(mq) == 1);
Adrian Hunter81196972017-11-29 15:41:03 +0200296
297 spin_unlock_irq(q->queue_lock);
298
299 if (!(req->rq_flags & RQF_DONTPREP)) {
300 req_to_mmc_queue_req(req)->retries = 0;
301 req->rq_flags |= RQF_DONTPREP;
302 }
303
304 if (get_card)
305 mmc_get_card(card, &mq->ctx);
306
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200307 if (mq->use_cqe) {
308 host->retune_now = host->need_retune && cqe_retune_ok &&
309 !host->hold_retune;
310 }
311
Adrian Hunter81196972017-11-29 15:41:03 +0200312 blk_mq_start_request(req);
313
314 issued = mmc_blk_mq_issue_rq(mq, req);
315
316 switch (issued) {
317 case MMC_REQ_BUSY:
318 ret = BLK_STS_RESOURCE;
319 break;
320 case MMC_REQ_FAILED_TO_START:
321 ret = BLK_STS_IOERR;
322 break;
323 default:
324 ret = BLK_STS_OK;
325 break;
326 }
327
328 if (issued != MMC_REQ_STARTED) {
329 bool put_card = false;
330
331 spin_lock_irq(q->queue_lock);
332 mq->in_flight[issue_type] -= 1;
333 if (mmc_tot_in_flight(mq) == 0)
334 put_card = true;
335 spin_unlock_irq(q->queue_lock);
336 if (put_card)
337 mmc_put_card(card, &mq->ctx);
338 }
339
340 return ret;
341}
342
343static const struct blk_mq_ops mmc_mq_ops = {
344 .queue_rq = mmc_mq_queue_rq,
345 .init_request = mmc_mq_init_request,
346 .exit_request = mmc_mq_exit_request,
347 .complete = mmc_blk_mq_complete,
348 .timeout = mmc_mq_timed_out,
349};
350
Adrian Hunterc8b5fd02017-09-22 15:36:57 +0300351static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
352{
353 struct mmc_host *host = card->host;
354 u64 limit = BLK_BOUNCE_HIGH;
355
356 if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
357 limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT;
358
Bart Van Assche8b904b52018-03-07 17:10:10 -0800359 blk_queue_flag_set(QUEUE_FLAG_NONROT, mq->queue);
360 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, mq->queue);
Adrian Hunterc8b5fd02017-09-22 15:36:57 +0300361 if (mmc_can_erase(card))
362 mmc_queue_setup_discard(mq->queue, card);
363
364 blk_queue_bounce_limit(mq->queue, limit);
365 blk_queue_max_hw_sectors(mq->queue,
366 min(host->max_blk_count, host->max_req_size / 512));
367 blk_queue_max_segments(mq->queue, host->max_segs);
368 blk_queue_max_segment_size(mq->queue, host->max_seg_size);
369
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200370 INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler);
Adrian Hunter81196972017-11-29 15:41:03 +0200371 INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work);
372
373 mutex_init(&mq->complete_lock);
374
375 init_waitqueue_head(&mq->wait);
376}
377
378static int mmc_mq_init_queue(struct mmc_queue *mq, int q_depth,
379 const struct blk_mq_ops *mq_ops, spinlock_t *lock)
380{
381 int ret;
382
383 memset(&mq->tag_set, 0, sizeof(mq->tag_set));
384 mq->tag_set.ops = mq_ops;
385 mq->tag_set.queue_depth = q_depth;
386 mq->tag_set.numa_node = NUMA_NO_NODE;
387 mq->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE |
388 BLK_MQ_F_BLOCKING;
389 mq->tag_set.nr_hw_queues = 1;
390 mq->tag_set.cmd_size = sizeof(struct mmc_queue_req);
391 mq->tag_set.driver_data = mq;
392
393 ret = blk_mq_alloc_tag_set(&mq->tag_set);
394 if (ret)
395 return ret;
396
397 mq->queue = blk_mq_init_queue(&mq->tag_set);
398 if (IS_ERR(mq->queue)) {
399 ret = PTR_ERR(mq->queue);
400 goto free_tag_set;
401 }
402
403 mq->queue->queue_lock = lock;
404 mq->queue->queuedata = mq;
405
406 return 0;
407
408free_tag_set:
409 blk_mq_free_tag_set(&mq->tag_set);
410
411 return ret;
412}
413
414/* Set queue depth to get a reasonable value for q->nr_requests */
415#define MMC_QUEUE_DEPTH 64
416
417static int mmc_mq_init(struct mmc_queue *mq, struct mmc_card *card,
418 spinlock_t *lock)
419{
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200420 struct mmc_host *host = card->host;
Adrian Hunter81196972017-11-29 15:41:03 +0200421 int q_depth;
422 int ret;
423
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200424 /*
425 * The queue depth for CQE must match the hardware because the request
426 * tag is used to index the hardware queue.
427 */
428 if (mq->use_cqe)
429 q_depth = min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth);
430 else
431 q_depth = MMC_QUEUE_DEPTH;
Adrian Hunter81196972017-11-29 15:41:03 +0200432
433 ret = mmc_mq_init_queue(mq, q_depth, &mmc_mq_ops, lock);
434 if (ret)
435 return ret;
436
437 blk_queue_rq_timeout(mq->queue, 60 * HZ);
438
439 mmc_setup_queue(mq, card);
440
441 return 0;
Adrian Hunterc8b5fd02017-09-22 15:36:57 +0300442}
443
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444/**
445 * mmc_init_queue - initialise a queue structure.
446 * @mq: mmc queue
447 * @card: mmc card to attach this queue
448 * @lock: queue lock
Adrian Hunterd09408a2011-06-23 13:40:28 +0300449 * @subname: partition subname
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 *
451 * Initialise a MMC card request queue.
452 */
Adrian Hunterd09408a2011-06-23 13:40:28 +0300453int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
454 spinlock_t *lock, const char *subname)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455{
456 struct mmc_host *host = card->host;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 mq->card = card;
Adrian Hunter81196972017-11-29 15:41:03 +0200459
Adrian Hunter1e8e55b2017-11-29 15:41:04 +0200460 mq->use_cqe = host->cqe_enabled;
461
Adrian Hunter0fbfd122017-11-29 15:41:18 +0200462 return mmc_mq_init(mq, card, lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464
Adrian Hunter0fbfd122017-11-29 15:41:18 +0200465void mmc_queue_suspend(struct mmc_queue *mq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466{
Adrian Hunter81196972017-11-29 15:41:03 +0200467 blk_mq_quiesce_queue(mq->queue);
Pierre Ossman89b4e132006-11-14 22:08:16 +0100468
Adrian Hunter81196972017-11-29 15:41:03 +0200469 /*
470 * The host remains claimed while there are outstanding requests, so
471 * simply claiming and releasing here ensures there are none.
472 */
473 mmc_claim_host(mq->card->host);
474 mmc_release_host(mq->card->host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476
Adrian Hunter0fbfd122017-11-29 15:41:18 +0200477void mmc_queue_resume(struct mmc_queue *mq)
Adrian Hunter81196972017-11-29 15:41:03 +0200478{
479 blk_mq_unquiesce_queue(mq->queue);
480}
481
Adrian Hunter81196972017-11-29 15:41:03 +0200482void mmc_cleanup_queue(struct mmc_queue *mq)
483{
484 struct request_queue *q = mq->queue;
Adrian Hunter81196972017-11-29 15:41:03 +0200485
Adrian Hunter0fbfd122017-11-29 15:41:18 +0200486 /*
487 * The legacy code handled the possibility of being suspended,
488 * so do that here too.
489 */
490 if (blk_queue_quiesced(q))
491 blk_mq_unquiesce_queue(q);
Adrian Hunter81196972017-11-29 15:41:03 +0200492
Adrian Hunter81196972017-11-29 15:41:03 +0200493 blk_cleanup_queue(q);
494
495 /*
496 * A request can be completed before the next request, potentially
497 * leaving a complete_work with nothing to do. Such a work item might
498 * still be queued at this point. Flush it.
499 */
500 flush_work(&mq->complete_work);
501
502 mq->card = NULL;
503}
504
Pierre Ossman2ff1fa62008-07-22 14:35:42 +0200505/*
506 * Prepare the sg list(s) to be handed of to the host driver
507 */
Per Forlin97868a22011-07-09 17:12:36 -0400508unsigned int mmc_queue_map_sg(struct mmc_queue *mq, struct mmc_queue_req *mqrq)
Pierre Ossman98ccf142007-05-12 00:26:16 +0200509{
Linus Walleij67e69d52017-05-19 15:37:27 +0200510 struct request *req = mmc_queue_req_to_req(mqrq);
Pierre Ossman98ccf142007-05-12 00:26:16 +0200511
Linus Walleijde3ee992017-09-20 10:56:14 +0200512 return blk_rq_map_sg(mq->queue, req, mqrq->sg);
Pierre Ossman98ccf142007-05-12 00:26:16 +0200513}