Enable the Command Queue if the host controller supports Software Command Queuing. It is not compatible with Packed Commands, so do not enable that at the same time. Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx> --- drivers/mmc/core/mmc.c | 17 ++++++++++++++++- include/linux/mmc/host.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2e54daa237f6..cefa1ddca182 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1735,6 +1735,20 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, } } + /* Enable Command Queue if supported */ + card->ext_csd.cmdq_en = false; + if (card->ext_csd.cmdq_support && host->caps & MMC_CAP_SWCMDQ) { + 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; + } + } /* * In some cases (e.g. RPMB or mmc_test), the Command Queue must be * disabled for a time, so a flag is needed to indicate to re-enable the @@ -1748,7 +1762,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, */ if (card->ext_csd.max_packed_writes >= 3 && card->ext_csd.max_packed_reads >= 5 && - host->caps2 & MMC_CAP2_PACKED_CMD) { + host->caps2 & MMC_CAP2_PACKED_CMD && + !card->ext_csd.cmdq_en) { err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_EXP_EVENTS_CTRL, EXT_CSD_PACKED_EVENT_EN, diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index c9ce8b0ae321..629a9bab6c4a 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -280,6 +280,7 @@ struct mmc_host { #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */ #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */ #define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */ +#define MMC_CAP_SWCMDQ (1 << 28) /* Software Command Queue */ #define MMC_CAP_CMD_DURING_TFR (1 << 29) /* Commands during data transfer */ #define MMC_CAP_CMD23 (1 << 30) /* CMD23 supported. */ #define MMC_CAP_HW_RESET (1 << 31) /* Hardware reset */ -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html