Skip to content

Commit

Permalink
mmc: core: Add MMC Command Queue Support kernel parameter
Browse files Browse the repository at this point in the history
This parameter offers a workaround for cards that report command queue
(CMDQ) support but don't work correctly when CMDQ is enabled. At least
some ROCKPro64 + Foresee (32GB) eMMC card combinations have trouble
working correctly. Setting mmc_cmdqueue=off in kernel command line
disables CMDQ support and may help with troublesome hardware.
  • Loading branch information
nuumio authored and ayufan committed Dec 30, 2018
1 parent 730ae32 commit e8f6e49
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
8 changes: 8 additions & 0 deletions Documentation/admin-guide/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,14 @@
log everything. Information is printed at KERN_DEBUG
so loglevel=8 may also need to be specified.

mmc_cmdqueue= [MMC]
Enable or disable MMC command queue (CMDQ) support. When
enabled MMC driver will try to enable CMDQ for cards that
support it. When disabled CMDQ will not be enabled for any
card.
Format: <bool> (1/y/on=enable, 0/n/off=disable)
default: enabled

module.sig_enforce
[KNL] When CONFIG_MODULE_SIG is set, this means that
modules without (valid) signatures will fail to load.
Expand Down
29 changes: 19 additions & 10 deletions drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#include <linux/moduleparam.h>
#include <linux/err.h>
#include <linux/of.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -65,6 +65,10 @@ static const unsigned int taac_mant[] = {
__res & __mask; \
})

/* Enable / disable command queue support */
static bool mmc_cmdqueue_support = true;
core_param(mmc_cmdqueue, mmc_cmdqueue_support, bool, S_IRUGO);

/*
* Given the decoded CSD structure, decode the raw CID to our CID structure.
*/
Expand Down Expand Up @@ -1824,15 +1828,20 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
*/
card->ext_csd.cmdq_en = false;
if (card->ext_csd.cmdq_support && host->caps2 & MMC_CAP2_CQE) {
err = mmc_cmdq_enable(card);
if (err && err != -EBADMSG)
goto free_card;
if (err) {
pr_warn("%s: Enabling CMDQ failed\n",
mmc_hostname(card->host));
card->ext_csd.cmdq_support = false;
card->ext_csd.cmdq_depth = 0;
err = 0;
if (mmc_cmdqueue_support) {
err = mmc_cmdq_enable(card);
if (err && err != -EBADMSG)
goto free_card;
if (err) {
pr_warn("%s: Enabling CMDQ failed\n",
mmc_hostname(card->host));
card->ext_csd.cmdq_support = false;
card->ext_csd.cmdq_depth = 0;
err = 0;
}
} else {
pr_info("%s: CMDQ support disabled in kernel\n",
mmc_hostname(host));
}
}
/*
Expand Down

0 comments on commit e8f6e49

Please sign in to comment.