Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions drivers/mmc/core/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,15 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
enum mmc_issued issued;
bool get_card, cqe_retune_ok;
blk_status_t ret;
bool write;

if (mmc_card_removed(mq->card)) {
req->rq_flags |= RQF_QUIET;
return BLK_STS_IOERR;
}

issue_type = mmc_issue_type(mq, req);
write = req_op(req) == REQ_OP_WRITE;

spin_lock_irq(&mq->lock);

Expand All @@ -271,7 +273,7 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
spin_unlock_irq(&mq->lock);
return BLK_STS_RESOURCE;
}
if (!host->hsq_enabled && host->cqe_enabled && req_op(req) == REQ_OP_WRITE &&
if (!host->hsq_enabled && host->cqe_enabled && write &&
mq->pending_writes >= card->max_posted_writes) {
spin_unlock_irq(&mq->lock);
return BLK_STS_RESOURCE;
Expand All @@ -292,7 +294,7 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
/* Parallel dispatch of requests is not supported at the moment */
mq->busy = true;

if (req_op(req) == REQ_OP_WRITE)
if (write)
mq->pending_writes++;
mq->in_flight[issue_type] += 1;
get_card = (mmc_tot_in_flight(mq) == 1);
Expand Down Expand Up @@ -333,7 +335,7 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
bool put_card = false;

spin_lock_irq(&mq->lock);
if (req_op(req) == REQ_OP_WRITE)
if (write)
mq->pending_writes--;
mq->in_flight[issue_type] -= 1;
if (mmc_tot_in_flight(mq) == 0)
Expand All @@ -345,6 +347,7 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
} else {
WRITE_ONCE(mq->busy, false);
}
WARN_ON_ONCE(mq->pending_writes < 0);

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion include/linux/mmc/card.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ struct mmc_card {

struct workqueue_struct *complete_wq; /* Private workqueue */

unsigned int max_posted_writes; /* command queue posted write limit */
int max_posted_writes; /* command queue posted write limit */
};

static inline bool mmc_large_sector(struct mmc_card *card)
Expand Down
Loading