From: Jungseung Lee <js07.lee@samsung.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
Christoph Hellwig <hch@lst.de>,
js07.lee@gmail.com, linux-mmc@vger.kernel.org
Cc: Jungseung Lee <js07.lee@samsung.com>
Subject: [PATCH 2/2] mmc : implement REQ_OP_WRITE_ZEROES
Date: Tue, 07 Nov 2017 16:02:59 +0900 [thread overview]
Message-ID: <20171107070259.11664-2-js07.lee@samsung.com> (raw)
In-Reply-To: <20171107070259.11664-1-js07.lee@samsung.com>
Some devices return zeroes on read to unmmaped logical blocks.
Use this behavior to implement REQ_OP_WRITES_ZEROES.
Send TRIM operation for the non-partial erase at a convenient time.
Signed-off-by: Jungseung Lee <js07.lee@samsung.com>
---
drivers/mmc/core/block.c | 8 ++++++--
drivers/mmc/core/queue.c | 4 ++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index ea80ff4..41c4ec1 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1273,9 +1273,10 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
struct mmc_card *card = md->queue.card;
unsigned int from, nr, arg;
int err = 0, type = MMC_BLK_DISCARD;
+ int force_trim = (req_op(req) == REQ_OP_WRITE_ZEROES);
blk_status_t status = BLK_STS_OK;
- if (!mmc_can_erase(card)) {
+ if (!mmc_can_erase(card) || (!mmc_can_trim(card) && force_trim)) {
status = BLK_STS_NOTSUPP;
goto fail;
}
@@ -1283,7 +1284,9 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
from = blk_rq_pos(req);
nr = blk_rq_sectors(req);
- if (mmc_can_discard(card))
+ if (force_trim)
+ arg = MMC_TRIM_ARG;
+ else if (mmc_can_discard(card))
arg = MMC_DISCARD_ARG;
else if (mmc_can_trim(card))
arg = MMC_TRIM_ARG;
@@ -2032,6 +2035,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
mmc_blk_issue_rw_rq(mq, NULL);
mmc_blk_issue_drv_op(mq, req);
break;
+ case REQ_OP_WRITE_ZEROES:
case REQ_OP_DISCARD:
/*
* Complete ongoing async transfer before issuing
diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index 4f33d27..dc95b3a 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -144,6 +144,10 @@ static void mmc_queue_setup_discard(struct request_queue *q,
/* granularity must not be greater than max. discard */
if (card->pref_erase > max_discard)
q->limits.discard_granularity = 0;
+
+ if (card->quirks & MMC_QUIRK_UNMAPPED_ZEROES)
+ blk_queue_max_write_zeroes_sectors(q, UINT_MAX);
+
if (mmc_can_secure_erase_trim(card))
queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, q);
}
--
2.10.1
next prev parent reply other threads:[~2017-11-07 7:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171107070318eucas1p18f1f745136c9cea51468a20004a55666@eucas1p1.samsung.com>
2017-11-07 7:02 ` [PATCH 1/2] mmc : Add unmmapped zero quirk flag Jungseung Lee
2017-11-07 7:02 ` Jungseung Lee [this message]
2017-11-07 7:10 ` [PATCH 2/2] mmc : implement REQ_OP_WRITE_ZEROES Christoph Hellwig
2017-11-07 12:54 ` Ulf Hansson
2017-11-08 14:25 ` Jungseung Lee
2017-11-09 12:33 ` Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171107070259.11664-2-js07.lee@samsung.com \
--to=js07.lee@samsung.com \
--cc=hch@lst.de \
--cc=js07.lee@gmail.com \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox