switch (issue_type) { case MMC_ISSUE_ASYNC: case MMC_ISSUE_DCMD: if (host->cqe_ops->cqe_timeout(host, mrq, &recovery_needed)) { if (recovery_needed)
mmc_cqe_recovery_notifier(mrq); return BLK_EH_RESET_TIMER;
} /* The request has gone already */ return BLK_EH_DONE; default: /* Timeout is handled by mmc core */ return BLK_EH_RESET_TIMER;
}
}
max_discard = mmc_calc_max_discard(card); if (!max_discard) return;
lim->max_hw_discard_sectors = max_discard; if (mmc_card_can_secure_erase_trim(card))
lim->max_secure_erase_sectors = max_discard; if (mmc_card_can_trim(card) && card->erased_byte == 0)
lim->max_write_zeroes_sectors = max_discard;
/* granularity must not be greater than max. discard */ if (card->pref_erase > max_discard)
lim->discard_granularity = SECTOR_SIZE; else
lim->discard_granularity = card->pref_erase << 9;
}
if (mmc_card_removed(mq->card)) {
req->rq_flags |= RQF_QUIET; return BLK_STS_IOERR;
}
issue_type = mmc_issue_type(mq, req);
spin_lock_irq(&mq->lock);
if (mq->recovery_needed || mq->busy) {
spin_unlock_irq(&mq->lock); return BLK_STS_RESOURCE;
}
switch (issue_type) { case MMC_ISSUE_DCMD: if (mmc_cqe_dcmd_busy(mq)) {
mq->cqe_busy |= MMC_CQE_DCMD_BUSY;
spin_unlock_irq(&mq->lock); return BLK_STS_RESOURCE;
} break; case MMC_ISSUE_ASYNC: if (host->hsq_enabled && mq->in_flight[issue_type] > host->hsq_depth) {
spin_unlock_irq(&mq->lock); return BLK_STS_RESOURCE;
} break; default: /* * Timeouts are handled by mmc core, and we don't have a host * API to abort requests, so we can't handle the timeout anyway. * However, when the timeout happens, blk_mq_complete_request() * no longer works (to stop the request disappearing under us). * To avoid racing with that, set a large timeout.
*/
req->timeout = 600 * HZ; break;
}
/* Parallel dispatch of requests is not supported at the moment */
mq->busy = true;
switch (issued) { case MMC_REQ_BUSY:
ret = BLK_STS_RESOURCE; break; case MMC_REQ_FAILED_TO_START:
ret = BLK_STS_IOERR; break; default:
ret = BLK_STS_OK; break;
}
if (issued != MMC_REQ_STARTED) { bool put_card = false;
/* * Setting a virt_boundary implicity sets a max_segment_size, so try * to set the hardware one here.
*/ if (host->can_dma_map_merge) {
lim.virt_boundary_mask = dma_get_merge_boundary(mmc_dev(host));
lim.max_segments = MMC_DMA_MAP_MERGE_SEGMENTS;
} else {
lim.max_segment_size =
round_down(host->max_seg_size, lim.logical_block_size);
lim.max_segments = host->max_segs;
}
if (mmc_host_is_spi(host) && host->use_spi_crc)
lim.features |= BLK_FEAT_STABLE_WRITES;
disk = blk_mq_alloc_disk(&mq->tag_set, &lim, mq); if (IS_ERR(disk)) return disk;
mq->queue = disk->queue;
blk_queue_rq_timeout(mq->queue, 60 * HZ);
if (mmc_dev(host)->dma_parms)
dma_set_max_seg_size(mmc_dev(host), queue_max_segment_size(mq->queue));
/* Set queue depth to get a reasonable value for q->nr_requests */ #define MMC_QUEUE_DEPTH 64
/** * mmc_init_queue - initialise a queue structure. * @mq: mmc queue * @card: mmc card to attach this queue * @features: block layer features (BLK_FEAT_*) * * Initialise a MMC card request queue.
*/ struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, unsignedint features)
{ struct mmc_host *host = card->host; struct gendisk *disk; int ret;
mq->card = card;
spin_lock_init(&mq->lock);
memset(&mq->tag_set, 0, sizeof(mq->tag_set));
mq->tag_set.ops = &mmc_mq_ops; /* * The queue depth for CQE must match the hardware because the request * tag is used to index the hardware queue.
*/ if (host->cqe_enabled && !host->hsq_enabled)
mq->tag_set.queue_depth =
min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth); else
mq->tag_set.queue_depth = MMC_QUEUE_DEPTH;
mq->tag_set.numa_node = NUMA_NO_NODE;
mq->tag_set.flags = BLK_MQ_F_BLOCKING;
mq->tag_set.nr_hw_queues = 1;
mq->tag_set.cmd_size = sizeof(struct mmc_queue_req);
mq->tag_set.driver_data = mq;
/* * Since blk_mq_alloc_tag_set() calls .init_request() of mmc_mq_ops, * the host->can_dma_map_merge should be set before to get max_segs * from mmc_get_max_segments().
*/ if (mmc_merge_capable(host) &&
host->max_segs < MMC_DMA_MAP_MERGE_SEGMENTS &&
dma_get_merge_boundary(mmc_dev(host)))
host->can_dma_map_merge = 1; else
host->can_dma_map_merge = 0;
ret = blk_mq_alloc_tag_set(&mq->tag_set); if (ret) return ERR_PTR(ret);
disk = mmc_alloc_disk(mq, card, features); if (IS_ERR(disk))
blk_mq_free_tag_set(&mq->tag_set); return disk;
}
/* * The host remains claimed while there are outstanding requests, so * simply claiming and releasing here ensures there are none.
*/
mmc_claim_host(mq->card->host);
mmc_release_host(mq->card->host);
}
/* * The legacy code handled the possibility of being suspended, * so do that here too.
*/ if (blk_queue_quiesced(q))
blk_mq_unquiesce_queue(q);
/* * If the recovery completes the last (and only remaining) request in * the queue, and the card has been removed, we could end up here with * the recovery not quite finished yet, so cancel it.
*/
cancel_work_sync(&mq->recovery_work);
blk_mq_free_tag_set(&mq->tag_set);
/* * A request can be completed before the next request, potentially * leaving a complete_work with nothing to do. Such a work item might * still be queued at this point. Flush it.
*/
flush_work(&mq->complete_work);
mq->card = NULL;
}
/* * Prepare the sg list(s) to be handed of to the host driver
*/ unsignedint mmc_queue_map_sg(struct mmc_queue *mq, struct mmc_queue_req *mqrq)
{ struct request *req = mmc_queue_req_to_req(mqrq);
return blk_rq_map_sg(req, mqrq->sg);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.