• mmc_send_app_op_cond in drivers/mmc/core/sd_ops.c

    From manuscheung@gmail.com@21:1/5 to manus...@gmail.com on Fri Jun 23 04:07:24 2017
    On Friday, 23 June 2017 18:56:33 UTC+8, manus...@gmail.com wrote:
    Hello,

    It looks like to me that the mmc driver does not implement ACMD41 correctly for SD initialization. The SD spec says that if response of ACMD41 returns busy state, the host shall re-issue ACMD41 until 1) card is ready or 2) one second is over.

    Below shows the function "mmc_send_app_op" which issues ACMD41. If response of first ACMD41 command returns busy state, it will exit the outer "for" loop immediately (see my comment).

    This obviously does not follow the SD spec. Right?


    int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
    {
    struct mmc_command cmd = {0};
    int i, err = 0;

    ....
    ....
    for (i = 100; i; i--) {
    err = mmc_wait_for_app_cmd(host, NULL, &cmd, MMC_CMD_RETRIES);
    if (err)
    break;

    /* if we're just probing, do a single pass */
    if (ocr == 0)
    break;

    /* otherwise wait until reset completes */
    if (mmc_host_is_spi(host)) {
    if (!(cmd.resp[0] & R1_SPI_IDLE))
    break;
    } else {
    if (cmd.resp[0] & MMC_CARD_BUSY)
    break;
    }

    err = -ETIMEDOUT;
    mmc_delay(10);
    }
    /* we already reach here if cmd.resp[0]=MMC_CARD_BUSY
    for the first ACMD41! */
    ....
    ....
    }

    Fix typo in the comment ...

    /* we already reach here if (cmd.resp[0] & MMC_CARD_BUSY) is nonzero
    for the first ACMD41! */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From manuscheung@gmail.com@21:1/5 to All on Fri Jun 23 03:56:32 2017
    Hello,

    It looks like to me that the mmc driver does not implement ACMD41 correctly for SD initialization. The SD spec says that if response of ACMD41 returns busy state, the host shall re-issue ACMD41 until 1) card is ready or 2) one second is over.

    Below shows the function "mmc_send_app_op" which issues ACMD41. If response of first ACMD41 command returns busy state, it will exit the outer "for" loop immediately (see my comment). Then "mmc_send_app_op".

    This obviously does not follow the SD spec. Right?


    int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
    {
    struct mmc_command cmd = {0};
    int i, err = 0;

    ....
    ....
    for (i = 100; i; i--) {
    err = mmc_wait_for_app_cmd(host, NULL, &cmd, MMC_CMD_RETRIES);
    if (err)
    break;

    /* if we're just probing, do a single pass */
    if (ocr == 0)
    break;

    /* otherwise wait until reset completes */
    if (mmc_host_is_spi(host)) {
    if (!(cmd.resp[0] & R1_SPI_IDLE))
    break;
    } else {
    if (cmd.resp[0] & MMC_CARD_BUSY)
    break;
    }

    err = -ETIMEDOUT;
    mmc_delay(10);
    }
    /* we already reach here if cmd.resp[0]=MMC_CARD_BUSY
    for the first ACMD41! */
    ....
    ....
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)