* [PATCH 1/4 v2] mmc: block: Anonymize the drv op data pointer
2017-06-05 12:15 [PATCH 0/4] Move debugfs to block layer, take 2 Linus Walleij
@ 2017-06-05 12:15 ` Linus Walleij
2017-06-05 12:15 ` [PATCH 2/4 v2] mmc: debugfs: No blocklayer = no card status and extcsd Linus Walleij
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2017-06-05 12:15 UTC (permalink / raw)
To: linux-mmc, Ulf Hansson, Adrian Hunter; +Cc: Linus Walleij
We have a data pointer for the ioctl() data, but we need to
pass other data along with the DRV_OP:s, so make this a
void * so it can be reused.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Break out from the other patch
---
drivers/mmc/core/block.c | 8 +++++---
drivers/mmc/core/queue.h | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 64f9fda92229..7a365d7641b5 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -598,7 +598,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
__GFP_RECLAIM);
idatas[0] = idata;
req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_IOCTL;
- req_to_mmc_queue_req(req)->idata = idatas;
+ req_to_mmc_queue_req(req)->drv_op_data = idatas;
req_to_mmc_queue_req(req)->ioc_count = 1;
blk_execute_rq(mq->queue, NULL, req, 0);
ioc_err = req_to_mmc_queue_req(req)->drv_op_result;
@@ -674,7 +674,7 @@ static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev,
idata[0]->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
__GFP_RECLAIM);
req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_IOCTL;
- req_to_mmc_queue_req(req)->idata = idata;
+ req_to_mmc_queue_req(req)->drv_op_data = idata;
req_to_mmc_queue_req(req)->ioc_count = num_of_cmds;
blk_execute_rq(mq->queue, NULL, req, 0);
ioc_err = req_to_mmc_queue_req(req)->drv_op_result;
@@ -1175,6 +1175,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
struct mmc_queue_req *mq_rq;
struct mmc_card *card = mq->card;
struct mmc_blk_data *md = mq->blkdata;
+ struct mmc_blk_ioc_data **idata;
int ret;
int i;
@@ -1182,8 +1183,9 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
switch (mq_rq->drv_op) {
case MMC_DRV_OP_IOCTL:
+ idata = mq_rq->drv_op_data;
for (i = 0; i < mq_rq->ioc_count; i++) {
- ret = __mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]);
+ ret = __mmc_blk_ioctl_cmd(card, md, idata[i]);
if (ret)
break;
}
diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h
index 361b46408e0f..cf26a15a64bf 100644
--- a/drivers/mmc/core/queue.h
+++ b/drivers/mmc/core/queue.h
@@ -51,7 +51,7 @@ struct mmc_queue_req {
struct mmc_async_req areq;
enum mmc_drv_op drv_op;
int drv_op_result;
- struct mmc_blk_ioc_data **idata;
+ void *drv_op_data;
unsigned int ioc_count;
};
--
2.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4 v2] mmc: debugfs: No blocklayer = no card status and extcsd
2017-06-05 12:15 [PATCH 0/4] Move debugfs to block layer, take 2 Linus Walleij
2017-06-05 12:15 ` [PATCH 1/4 v2] mmc: block: Anonymize the drv op data pointer Linus Walleij
@ 2017-06-05 12:15 ` Linus Walleij
2017-06-05 12:15 ` [PATCH 3/4 v2] mmc: debugfs: Move card status retrieveal into the block layer Linus Walleij
2017-06-05 12:15 ` [PATCH 4/4] mmc: debugfs: Move EXT CSD debugfs acces to " Linus Walleij
3 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2017-06-05 12:15 UTC (permalink / raw)
To: linux-mmc, Ulf Hansson, Adrian Hunter; +Cc: Linus Walleij
If we don't have the block layer enabled, we do not present card
status and extcsd in the debugfs.
Debugfs is not ABI, and maintaining files of no relevance for
non-block devices comes at a high maintenance cost if we shall
support it with the block layer compiled out.
The expected number of debugfs users utilizing these two
debugfs files is already low as there is an ioctl() to get the
same information using the mmc-tools, and of these few users
the expected number of people using it on SDIO or combo cards
are expected to be zero.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- New patch, just numbered v2 to keep the series together.
---
drivers/mmc/core/debugfs.c | 39 ++++++++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 9 deletions(-)
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index a1fba5732d66..b176932b8092 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -281,6 +281,8 @@ void mmc_remove_host_debugfs(struct mmc_host *host)
debugfs_remove_recursive(host->debugfs_root);
}
+#if IS_ENABLED(CONFIG_MMC_BLOCK)
+
static int mmc_dbg_card_status_get(void *data, u64 *val)
{
struct mmc_card *card = data;
@@ -360,6 +362,32 @@ static const struct file_operations mmc_dbg_ext_csd_fops = {
.llseek = default_llseek,
};
+static int mmc_add_block_debugfs(struct mmc_card *card, struct dentry *root)
+{
+ if (mmc_card_mmc(card) || mmc_card_sd(card)) {
+ if (!debugfs_create_file("status", S_IRUSR, root, card,
+ &mmc_dbg_card_status_fops))
+ return -EIO;
+ }
+
+ if (mmc_card_mmc(card)) {
+ if (!debugfs_create_file("ext_csd", S_IRUSR, root, card,
+ &mmc_dbg_ext_csd_fops))
+ return -EIO;
+ }
+
+ return 0;
+}
+
+#else /* !IS_ENABLED(CONFIG_MMC_BLOCK) */
+
+static int mmc_add_block_debugfs(struct mmc_card *card, struct dentry *root)
+{
+ return 0;
+}
+
+#endif
+
void mmc_add_card_debugfs(struct mmc_card *card)
{
struct mmc_host *host = card->host;
@@ -382,15 +410,8 @@ void mmc_add_card_debugfs(struct mmc_card *card)
if (!debugfs_create_x32("state", S_IRUSR, root, &card->state))
goto err;
- if (mmc_card_mmc(card) || mmc_card_sd(card))
- if (!debugfs_create_file("status", S_IRUSR, root, card,
- &mmc_dbg_card_status_fops))
- goto err;
-
- if (mmc_card_mmc(card))
- if (!debugfs_create_file("ext_csd", S_IRUSR, root, card,
- &mmc_dbg_ext_csd_fops))
- goto err;
+ if (mmc_add_block_debugfs(card, root))
+ goto err;
return;
--
2.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4 v2] mmc: debugfs: Move card status retrieveal into the block layer
2017-06-05 12:15 [PATCH 0/4] Move debugfs to block layer, take 2 Linus Walleij
2017-06-05 12:15 ` [PATCH 1/4 v2] mmc: block: Anonymize the drv op data pointer Linus Walleij
2017-06-05 12:15 ` [PATCH 2/4 v2] mmc: debugfs: No blocklayer = no card status and extcsd Linus Walleij
@ 2017-06-05 12:15 ` Linus Walleij
2017-06-05 18:07 ` kbuild test robot
2017-06-05 12:15 ` [PATCH 4/4] mmc: debugfs: Move EXT CSD debugfs acces to " Linus Walleij
3 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2017-06-05 12:15 UTC (permalink / raw)
To: linux-mmc, Ulf Hansson, Adrian Hunter; +Cc: Linus Walleij
This debugfs entry suffers from all the same starvation
issues as the other userspace things, under e.g. a heavy
dd operation.
It is therefore logical to move this over to the block layer
when it is enabled, using the new custom requests and issue
it using the block request queue.
This makes this debugfs card access land under the request
queue host lock instead of orthogonally taking the lock.
Tested during heavy dd load by cat:in the status file.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Rebased on the new series, add no stubs.
---
drivers/mmc/core/block.c | 28 ++++++++++++++++++++++++++++
drivers/mmc/core/block.h | 1 +
drivers/mmc/core/debugfs.c | 15 ++-------------
drivers/mmc/core/queue.h | 2 ++
4 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 7a365d7641b5..96fe0640c480 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1176,6 +1176,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
struct mmc_card *card = mq->card;
struct mmc_blk_data *md = mq->blkdata;
struct mmc_blk_ioc_data **idata;
+ u32 status;
int ret;
int i;
@@ -1205,6 +1206,11 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
card->ext_csd.boot_ro_lock |=
EXT_CSD_BOOT_WP_B_PWR_WP_EN;
break;
+ case MMC_DRV_OP_GET_CARD_STATUS:
+ ret = mmc_send_status(card, &status);
+ if (!ret)
+ ret = status;
+ break;
default:
pr_err("%s: unknown driver specific operation\n",
md->disk->disk_name);
@@ -1954,6 +1960,28 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
mmc_put_card(card);
}
+/* Called from debugfs for MMC/SD cards */
+int mmc_blk_card_status_get(struct mmc_card *card, u64 *val)
+{
+ struct mmc_blk_data *md = dev_get_drvdata(&card->dev);
+ struct mmc_queue *mq = &md->queue;
+ struct request *req;
+ int ret;
+
+ /* Ask the block layer about the card status */
+ req = blk_get_request(mq->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
+ req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_CARD_STATUS;
+ blk_execute_rq(mq->queue, NULL, req, 0);
+ ret = req_to_mmc_queue_req(req)->drv_op_result;
+ if (ret >= 0) {
+ *val = ret;
+ ret = 0;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(mmc_blk_card_status_get);
+
static inline int mmc_blk_readonly(struct mmc_card *card)
{
return mmc_card_readonly(card) ||
diff --git a/drivers/mmc/core/block.h b/drivers/mmc/core/block.h
index 860ca7c8df86..70861f3a059a 100644
--- a/drivers/mmc/core/block.h
+++ b/drivers/mmc/core/block.h
@@ -5,5 +5,6 @@ struct mmc_queue;
struct request;
void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req);
+int mmc_blk_card_status_get(struct mmc_card *card, u64 *val);
#endif
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index b176932b8092..dca5717c437b 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -22,6 +22,7 @@
#include "core.h"
#include "card.h"
#include "host.h"
+#include "block.h"
#include "mmc_ops.h"
#ifdef CONFIG_FAIL_MMC_REQUEST
@@ -285,19 +286,7 @@ void mmc_remove_host_debugfs(struct mmc_host *host)
static int mmc_dbg_card_status_get(void *data, u64 *val)
{
- struct mmc_card *card = data;
- u32 status;
- int ret;
-
- mmc_get_card(card);
-
- ret = mmc_send_status(data, &status);
- if (!ret)
- *val = status;
-
- mmc_put_card(card);
-
- return ret;
+ return mmc_blk_card_status_get(data, val);
}
DEFINE_SIMPLE_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
NULL, "%08llx\n");
diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h
index cf26a15a64bf..c2325c6659f5 100644
--- a/drivers/mmc/core/queue.h
+++ b/drivers/mmc/core/queue.h
@@ -36,10 +36,12 @@ struct mmc_blk_request {
* enum mmc_drv_op - enumerates the operations in the mmc_queue_req
* @MMC_DRV_OP_IOCTL: ioctl operation
* @MMC_DRV_OP_BOOT_WP: write protect boot partitions
+ * @MMC_DRV_OP_GET_CARD_STATUS: get card status
*/
enum mmc_drv_op {
MMC_DRV_OP_IOCTL,
MMC_DRV_OP_BOOT_WP,
+ MMC_DRV_OP_GET_CARD_STATUS,
};
struct mmc_queue_req {
--
2.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] mmc: debugfs: Move EXT CSD debugfs acces to block layer
2017-06-05 12:15 [PATCH 0/4] Move debugfs to block layer, take 2 Linus Walleij
` (2 preceding siblings ...)
2017-06-05 12:15 ` [PATCH 3/4 v2] mmc: debugfs: Move card status retrieveal into the block layer Linus Walleij
@ 2017-06-05 12:15 ` Linus Walleij
3 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2017-06-05 12:15 UTC (permalink / raw)
To: linux-mmc, Ulf Hansson, Adrian Hunter; +Cc: Linus Walleij
Just like the previous commit moving status retriveal for
MMC and SD cards into the block layer (when active), this
moves the retrieveal of the EXT CSD from the card from
the special ext_csd file into the block stack as well.
It has been tested with and without the block layer and
during heavy load from dd.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Rebased on the new series, add no stubs.
---
drivers/mmc/core/block.c | 21 +++++++++++++++++++++
drivers/mmc/core/block.h | 1 +
drivers/mmc/core/debugfs.c | 4 +---
drivers/mmc/core/queue.h | 2 ++
4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 96fe0640c480..4708f95ebdd0 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1176,6 +1176,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
struct mmc_card *card = mq->card;
struct mmc_blk_data *md = mq->blkdata;
struct mmc_blk_ioc_data **idata;
+ u8 **ext_csd;
u32 status;
int ret;
int i;
@@ -1211,6 +1212,10 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
if (!ret)
ret = status;
break;
+ case MMC_DRV_OP_GET_EXT_CSD:
+ ext_csd = mq_rq->drv_op_data;
+ ret = mmc_get_ext_csd(card, ext_csd);
+ break;
default:
pr_err("%s: unknown driver specific operation\n",
md->disk->disk_name);
@@ -1982,6 +1987,22 @@ int mmc_blk_card_status_get(struct mmc_card *card, u64 *val)
}
EXPORT_SYMBOL(mmc_blk_card_status_get);
+/* Called from debugfs for MMC cards */
+int mmc_blk_get_ext_csd(struct mmc_card *card, u8 **ext_csd)
+{
+ struct mmc_blk_data *md = dev_get_drvdata(&card->dev);
+ struct mmc_queue *mq = &md->queue;
+ struct request *req;
+
+ /* Ask the block layer about the EXT CSD */
+ req = blk_get_request(mq->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
+ req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_EXT_CSD;
+ req_to_mmc_queue_req(req)->drv_op_data = ext_csd;
+ blk_execute_rq(mq->queue, NULL, req, 0);
+ return req_to_mmc_queue_req(req)->drv_op_result;
+}
+EXPORT_SYMBOL(mmc_blk_get_ext_csd);
+
static inline int mmc_blk_readonly(struct mmc_card *card)
{
return mmc_card_readonly(card) ||
diff --git a/drivers/mmc/core/block.h b/drivers/mmc/core/block.h
index 70861f3a059a..377ebbf6a978 100644
--- a/drivers/mmc/core/block.h
+++ b/drivers/mmc/core/block.h
@@ -6,5 +6,6 @@ struct request;
void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req);
int mmc_blk_card_status_get(struct mmc_card *card, u64 *val);
+int mmc_blk_get_ext_csd(struct mmc_card *card, u8 **ext_csd);
#endif
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index dca5717c437b..cc1f7085111c 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -305,9 +305,7 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
if (!buf)
return -ENOMEM;
- mmc_get_card(card);
- err = mmc_get_ext_csd(card, &ext_csd);
- mmc_put_card(card);
+ err = mmc_blk_get_ext_csd(card, &ext_csd);
if (err)
goto out_free;
diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h
index c2325c6659f5..04fc89360a7a 100644
--- a/drivers/mmc/core/queue.h
+++ b/drivers/mmc/core/queue.h
@@ -37,11 +37,13 @@ struct mmc_blk_request {
* @MMC_DRV_OP_IOCTL: ioctl operation
* @MMC_DRV_OP_BOOT_WP: write protect boot partitions
* @MMC_DRV_OP_GET_CARD_STATUS: get card status
+ * @MMC_DRV_OP_GET_EXT_CSD: get the EXT CSD from an eMMC card
*/
enum mmc_drv_op {
MMC_DRV_OP_IOCTL,
MMC_DRV_OP_BOOT_WP,
MMC_DRV_OP_GET_CARD_STATUS,
+ MMC_DRV_OP_GET_EXT_CSD,
};
struct mmc_queue_req {
--
2.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread