Skip to content

Commit

Permalink
mmc: sdhci-of-dwcmshc: fix rpmb access
Browse files Browse the repository at this point in the history
Commit a44f7cb ("mmc: core: use mrq->sbc when sending CMD23 for
RPMB") began to use ACMD23 for RPMB if the host supports ACMD23. In
RPMB ACM23 case, we need to set bit 31 to CMD23 argument, otherwise
RPMB write operation will return general fail.

However, no matter V4 is enabled or not, the dwcmshc's ARGUMENT2
register is 32-bit block count register which doesn't support stuff
bits of CMD23 argument. So let's handle this specific ACMD23 case.

From another side, this patch also prepare for future v4 enabling
for dwcmshc, because from the 4.10 spec, the ARGUMENT2 register is
redefined as 32bit block count which doesn't support stuff bits of
CMD23 argument.

Fixes: a44f7cb ("mmc: core: use mrq->sbc when sending CMD23 for RPMB")
Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20201229161625.38255233@xhacker.debian
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
  • Loading branch information
Jisheng Zhang authored and storulf committed Jan 11, 2021
1 parent 7c53f6b commit ca1219c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions drivers/mmc/host/sdhci-of-dwcmshc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "sdhci-pltfm.h"

#define SDHCI_DWCMSHC_ARG2_STUFF GENMASK(31, 16)

/* DWCMSHC specific Mode Select value */
#define DWCMSHC_CTRL_HS400 0x7

Expand Down Expand Up @@ -49,6 +51,29 @@ static void dwcmshc_adma_write_desc(struct sdhci_host *host, void **desc,
sdhci_adma_write_desc(host, desc, addr, len, cmd);
}

static void dwcmshc_check_auto_cmd23(struct mmc_host *mmc,
struct mmc_request *mrq)
{
struct sdhci_host *host = mmc_priv(mmc);

/*
* No matter V4 is enabled or not, ARGUMENT2 register is 32-bit
* block count register which doesn't support stuff bits of
* CMD23 argument on dwcmsch host controller.
*/
if (mrq->sbc && (mrq->sbc->arg & SDHCI_DWCMSHC_ARG2_STUFF))
host->flags &= ~SDHCI_AUTO_CMD23;
else
host->flags |= SDHCI_AUTO_CMD23;
}

static void dwcmshc_request(struct mmc_host *mmc, struct mmc_request *mrq)
{
dwcmshc_check_auto_cmd23(mmc, mrq);

sdhci_request(mmc, mrq);
}

static void dwcmshc_set_uhs_signaling(struct sdhci_host *host,
unsigned int timing)
{
Expand Down Expand Up @@ -133,6 +158,8 @@ static int dwcmshc_probe(struct platform_device *pdev)

sdhci_get_of_property(pdev);

host->mmc_host_ops.request = dwcmshc_request;

err = sdhci_add_host(host);
if (err)
goto err_clk;
Expand Down

0 comments on commit ca1219c

Please sign in to comment.