@@ -1911,7 +1911,11 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
1911
1911
case MMC_BLK_SUCCESS :
1912
1912
case MMC_BLK_PARTIAL :
1913
1913
/*
1914
- * A block was successfully transferred.
1914
+ * Reset success, and accept bytes_xfered. For
1915
+ * MMC_BLK_PARTIAL re-submit the remaining request. For
1916
+ * MMC_BLK_SUCCESS error out the remaining request (it
1917
+ * could not be re-submitted anyway if a next request
1918
+ * had already begun).
1915
1919
*/
1916
1920
mmc_blk_reset_success (md , type );
1917
1921
@@ -1931,6 +1935,14 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
1931
1935
}
1932
1936
break ;
1933
1937
case MMC_BLK_CMD_ERR :
1938
+ /*
1939
+ * For SD cards, get bytes written, but do not accept
1940
+ * bytes_xfered if that fails. For MMC cards accept
1941
+ * bytes_xfered. Then try to reset. If reset fails then
1942
+ * error out the remaining request, otherwise retry
1943
+ * once (N.B mmc_blk_reset() will not succeed twice in a
1944
+ * row).
1945
+ */
1934
1946
req_pending = mmc_blk_rw_cmd_err (md , card , brq , old_req , req_pending );
1935
1947
if (mmc_blk_reset (md , card -> host , type )) {
1936
1948
if (req_pending )
@@ -1947,11 +1959,20 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
1947
1959
}
1948
1960
break ;
1949
1961
case MMC_BLK_RETRY :
1962
+ /*
1963
+ * Do not accept bytes_xfered, but retry up to 5 times,
1964
+ * otherwise same as abort.
1965
+ */
1950
1966
retune_retry_done = brq -> retune_retry_done ;
1951
1967
if (retry ++ < 5 )
1952
1968
break ;
1953
1969
/* Fall through */
1954
1970
case MMC_BLK_ABORT :
1971
+ /*
1972
+ * Do not accept bytes_xfered, but try to reset. If
1973
+ * reset succeeds, try once more, otherwise error out
1974
+ * the request.
1975
+ */
1955
1976
if (!mmc_blk_reset (md , card -> host , type ))
1956
1977
break ;
1957
1978
mmc_blk_rw_cmd_abort (mq , card , old_req , mq_rq );
@@ -1960,6 +1981,13 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
1960
1981
case MMC_BLK_DATA_ERR : {
1961
1982
int err ;
1962
1983
1984
+ /*
1985
+ * Do not accept bytes_xfered, but try to reset. If
1986
+ * reset succeeds, try once more. If reset fails with
1987
+ * ENODEV which means the partition is wrong, then error
1988
+ * out the request. Otherwise attempt to read one sector
1989
+ * at a time.
1990
+ */
1963
1991
err = mmc_blk_reset (md , card -> host , type );
1964
1992
if (!err )
1965
1993
break ;
@@ -1971,6 +1999,10 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
1971
1999
/* Fall through */
1972
2000
}
1973
2001
case MMC_BLK_ECC_ERR :
2002
+ /*
2003
+ * Do not accept bytes_xfered. If reading more than one
2004
+ * sector, try reading one sector at a time.
2005
+ */
1974
2006
if (brq -> data .blocks > 1 ) {
1975
2007
/* Redo read one sector at a time */
1976
2008
pr_warn ("%s: retrying using single block read\n" ,
@@ -1992,10 +2024,12 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
1992
2024
}
1993
2025
break ;
1994
2026
case MMC_BLK_NOMEDIUM :
2027
+ /* Do not accept bytes_xfered. Error out the request */
1995
2028
mmc_blk_rw_cmd_abort (mq , card , old_req , mq_rq );
1996
2029
mmc_blk_rw_try_restart (mq , new_req , mqrq_cur );
1997
2030
return ;
1998
2031
default :
2032
+ /* Do not accept bytes_xfered. Error out the request */
1999
2033
pr_err ("%s: Unhandled return value (%d)" ,
2000
2034
old_req -> rq_disk -> disk_name , status );
2001
2035
mmc_blk_rw_cmd_abort (mq , card , old_req , mq_rq );
0 commit comments