Skip to content

blk: Make the i.MX8 mmc driver more robust to errors#206

Merged
Ivan-Velickovic merged 2 commits into
mainfrom
julia/mmc-usdhc-reliability
Sep 2, 2024
Merged

blk: Make the i.MX8 mmc driver more robust to errors#206
Ivan-Velickovic merged 2 commits into
mainfrom
julia/mmc-usdhc-reliability

Conversation

@midnightveil

@midnightveil midnightveil commented Aug 9, 2024

Copy link
Copy Markdown
Contributor
  • The in-tree code relied on a lot of assertions and would crash in
    the presence of any sort of errors, e.g. card removal.

  • This new implementation handles command errors uniformly in a new
    handle_interrupt_status() function, and returns varying error types
    up the call stack and to the block queues.

Further/more detailed changes are:

  • The INT_STATUS register is now only read once on an interrupt, to
    prevent subtle race conditions.

  • Soft failures from:

    • Card not expecting an APP_CMD following CMD55
    • Incompatible voltage ranges, or unsupported card types
    • Incorrect card check commands from CMD8
  • sDDF Block queues are only ever initialised once

  • Indefinite busy-wait loops on Command Inhibit fields are replaced
    with an error return, as they never happen in usual operation.
    Similarly, busy wait on DAT[0] following R1b commands are handled
    by the IP, so it never happens.

  • On failed initialisation, reset (most) of the driver state, so we can
    try again in future. This is prep work for hotplugging support.

  • Add a stub card_detected() function which currently always returns
    true, but if implemented will correctly send "Gone" errors responses.

  • Add BLK_RESP_DEV_GONE error to the block queue
    This handles the case where the block device has been unplugged
    or is otherwise unavailable.

  • Add -MD to the example CFLAGS to track header-file dependencies

Split out the error-handling code from #180 to make my life easier.

@midnightveil midnightveil force-pushed the julia/mmc-usdhc-reliability branch from adbaabd to 849b1d3 Compare August 9, 2024 03:06
Comment thread examples/blk/mmc/client.c Outdated
Comment thread examples/blk/mmc/client.c Outdated
Comment thread drivers/blk/mmc/imx/usdhc.c Outdated
Comment thread drivers/blk/mmc/imx/usdhc.c Outdated
@midnightveil midnightveil force-pushed the julia/mmc-usdhc-reliability branch 8 times, most recently from 69d1d63 to 8f9e561 Compare August 14, 2024 04:08
@midnightveil midnightveil force-pushed the julia/mmc-usdhc-reliability branch 5 times, most recently from e8bd2c3 to 870d82c Compare August 30, 2024 01:07
@midnightveil midnightveil force-pushed the julia/mmc-usdhc-reliability branch from 870d82c to 22aa5a6 Compare August 30, 2024 01:50
@midnightveil midnightveil mentioned this pull request Aug 30, 2024
3 tasks
Comment thread include/sddf/blk/queue.h Outdated
*  The in-tree code relied on a lot of assertions and would crash in
   the presence of any sort of errors, e.g. card removal.

*  This new implementation handles command errors uniformly in a new
   `handle_interrupt_status()` function, and returns varying error types
   up the call stack and to the block queues.

Further/more detailed changes are:

*  The INT_STATUS register is now only read once on an interrupt, to
   prevent subtle race conditions.

*  Soft failures from:
   -  Card not expecting an APP_CMD following CMD55 (incompatible)
   -  Incompatible voltage ranges, or unsupported card types
   -  Incorrect card check commands from CMD8

*  sDDF Block queues are only ever initialised once

*  Indefinite busy-wait loops on Command Inhibit fields are replaced
   with an error return, as they never happen in usual operation.
   Similarly, busy wait on DAT[0] following R1b commands are handled
   by the IP, so it never happens.

*  On failed initialisation, reset (most) of the driver state, so we can
   try again in future. This is prep work for hotplugging support.

*  Add a stub `card_detected()` function which currently always returns
   `true`, but if implemented will correctly send "Gone" errors responses.

*  Add BLK_RESP_DEV_GONE error to the block queue
   This handles the case where the block device has been unplugged
   or is otherwise unavailable.

*  Add -MD to the example CFLAGS to track header-file dependencies

Signed-off-by: julia <git.ts@trainwit.ch>
Signed-off-by: julia <git.ts@trainwit.ch>
@Ivan-Velickovic Ivan-Velickovic merged commit 0f7d630 into main Sep 2, 2024
@Ivan-Velickovic Ivan-Velickovic deleted the julia/mmc-usdhc-reliability branch September 2, 2024 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants