From: Luis Henriques <luis.henriques@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
kernel-team@lists.ubuntu.com
Cc: KOBAYASHI Yoshitake <yoshitake.kobayashi@toshiba.co.jp>,
Chris Ball <cjb@laptop.org>,
Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 3.5 026/103] mmc: block: fix a bug of error handling in MMC driver
Date: Tue, 17 Dec 2013 18:12:15 +0000 [thread overview]
Message-ID: <1387304012-23805-27-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1387304012-23805-1-git-send-email-luis.henriques@canonical.com>
3.5.7.28 -stable review patch. If anyone has any objections, please let me know.
------------------
From: KOBAYASHI Yoshitake <yoshitake.kobayashi@toshiba.co.jp>
commit c8760069627ad3b0dbbea170f0c4c58b16e18d3d upstream.
Current MMC driver doesn't handle generic error (bit19 of device
status) in write sequence. As a result, write data gets lost when
generic error occurs. For example, a generic error when updating a
filesystem management information causes a loss of write data and
corrupts the filesystem. In the worst case, the system will never
boot.
This patch includes the following functionality:
1. To enable error checking for the response of CMD12 and CMD13
in write command sequence
2. To retry write sequence when a generic error occurs
Messages are added for v2 to show what occurs.
Signed-off-by: KOBAYASHI Yoshitake <yoshitake.kobayashi@toshiba.co.jp>
Signed-off-by: Chris Ball <cjb@laptop.org>
[ luis: backported to 3.5: based on yoshitake's backport to 3.4 ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
drivers/mmc/card/block.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 44 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 7b66292..4c0ce56 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -690,7 +690,7 @@ static int mmc_blk_cmd_error(struct request *req, const char *name, int error,
* Otherwise we don't understand what happened, so abort.
*/
static int mmc_blk_cmd_recovery(struct mmc_card *card, struct request *req,
- struct mmc_blk_request *brq, int *ecc_err)
+ struct mmc_blk_request *brq, int *ecc_err, int *gen_err)
{
bool prev_cmd_status_valid = true;
u32 status, stop_status = 0;
@@ -728,6 +728,16 @@ static int mmc_blk_cmd_recovery(struct mmc_card *card, struct request *req,
(brq->cmd.resp[0] & R1_CARD_ECC_FAILED))
*ecc_err = 1;
+ /* Flag General errors */
+ if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ)
+ if ((status & R1_ERROR) ||
+ (brq->stop.resp[0] & R1_ERROR)) {
+ pr_err("%s: %s: general error sending stop or status command, stop cmd response %#x, card status %#x\n",
+ req->rq_disk->disk_name, __func__,
+ brq->stop.resp[0], status);
+ *gen_err = 1;
+ }
+
/*
* Check the current card state. If it is in some data transfer
* mode, tell it to stop (and hopefully transition back to TRAN.)
@@ -747,6 +757,13 @@ static int mmc_blk_cmd_recovery(struct mmc_card *card, struct request *req,
return ERR_ABORT;
if (stop_status & R1_CARD_ECC_FAILED)
*ecc_err = 1;
+ if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ)
+ if (stop_status & R1_ERROR) {
+ pr_err("%s: %s: general error sending stop command, stop cmd response %#x\n",
+ req->rq_disk->disk_name, __func__,
+ stop_status);
+ *gen_err = 1;
+ }
}
/* Check for set block count errors */
@@ -996,7 +1013,7 @@ static int mmc_blk_err_check(struct mmc_card *card,
mmc_active);
struct mmc_blk_request *brq = &mq_mrq->brq;
struct request *req = mq_mrq->req;
- int ecc_err = 0;
+ int ecc_err = 0, gen_err = 0;
/*
* sbc.error indicates a problem with the set block count
@@ -1010,7 +1027,7 @@ static int mmc_blk_err_check(struct mmc_card *card,
*/
if (brq->sbc.error || brq->cmd.error || brq->stop.error ||
brq->data.error) {
- switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err)) {
+ switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) {
case ERR_RETRY:
return MMC_BLK_RETRY;
case ERR_ABORT:
@@ -1040,6 +1057,15 @@ static int mmc_blk_err_check(struct mmc_card *card,
*/
if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
u32 status;
+
+ /* Check stop command response */
+ if (brq->stop.resp[0] & R1_ERROR) {
+ pr_err("%s: %s: general error sending stop command, stop cmd response %#x\n",
+ req->rq_disk->disk_name, __func__,
+ brq->stop.resp[0]);
+ gen_err = 1;
+ }
+
do {
int err = get_card_status(card, &status, 5);
if (err) {
@@ -1047,6 +1073,14 @@ static int mmc_blk_err_check(struct mmc_card *card,
req->rq_disk->disk_name, err);
return MMC_BLK_CMD_ERR;
}
+
+ if (status & R1_ERROR) {
+ pr_err("%s: %s: general error sending status command, card status %#x\n",
+ req->rq_disk->disk_name, __func__,
+ status);
+ gen_err = 1;
+ }
+
/*
* Some cards mishandle the status bits,
* so make sure to check both the busy
@@ -1056,6 +1090,13 @@ static int mmc_blk_err_check(struct mmc_card *card,
(R1_CURRENT_STATE(status) == R1_STATE_PRG));
}
+ /* if general error occurs, retry the write operation. */
+ if (gen_err) {
+ pr_warning("%s: retrying write for general error\n",
+ req->rq_disk->disk_name);
+ return MMC_BLK_RETRY;
+ }
+
if (brq->data.error) {
pr_err("%s: error %d transferring data, sector %u, nr %u, cmd response %#x, card status %#x\n",
req->rq_disk->disk_name, brq->data.error,
--
1.8.3.2
next prev parent reply other threads:[~2013-12-17 18:14 UTC|newest]
Thread overview: 109+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-17 18:11 [3.5.y.z extended stable] Linux 3.5.7.28 stable review Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 001/103] [media] lirc_zilog: Don't use dynamic static allocation Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 002/103] net: Fix "ip rule delete table 256" Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 003/103] ipv6: use rt6_get_dflt_router to get default router in rt6_route_rcv Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 004/103] random32: fix off-by-one in seeding requirement Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 005/103] bonding: don't permit to use ARP monitoring in 802.3ad mode Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 006/103] 6lowpan: Uncompression of traffic class field was incorrect Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 007/103] bonding: fix two race conditions in bond_store_updelay/downdelay Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 008/103] isdnloop: use strlcpy() instead of strcpy() Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 009/103] connector: improved unaligned access error fix Luis Henriques
2013-12-17 18:11 ` [PATCH 3.5 010/103] ipv4: fix possible seqlock deadlock Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 011/103] inet: prevent leakage of uninitialized memory to user in recv syscalls Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 012/103] atm: idt77252: fix dev refcnt leak Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 013/103] net: core: Always propagate flag changes to interfaces Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 014/103] net: rework recvmsg handler msg_name and msg_namelen logic Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 015/103] net: add BUG_ON if kernel advertises msg_namelen > sizeof(struct sockaddr_storage) Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 016/103] packet: fix use after free race in send path when dev is released Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 017/103] inet: fix addr_len/msg->msg_namelen assignment in recv_error and rxpmtu functions Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 018/103] ipv6: fix leaking uninitialized port number of offender sockaddr Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 019/103] net: update consumers of MSG_MORE to recognize MSG_SENDPAGE_NOTLAST Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 020/103] net: clamp ->msg_namelen instead of returning an error Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 021/103] inet: fix possible seqlock deadlocks Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 022/103] ipv6: fix possible seqlock deadlock in ip6_finish_output2 Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 023/103] af_packet: block BH in prb_shutdown_retire_blk_timer() Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 024/103] {pktgen, xfrm} Update IPv4 header total len and checksum after tranformation Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 025/103] bridge: flush br's address entry in fdb when remove the Luis Henriques
2013-12-17 18:12 ` Luis Henriques [this message]
2013-12-17 18:12 ` [PATCH 3.5 027/103] NFSv4: Update list of irrecoverable errors on DELEGRETURN Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 028/103] Update of blkg_stat and blkg_rwstat may happen in bh context. While u64_stats_fetch_retry is only preempt_disable on 32bit UP system. This is not enough to avoid preemption by bh and may read strange 64 bit value Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 029/103] ASoC: wm8990: Mark the register map as dirty when powering down Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 030/103] irq: Enable all irqs unconditionally in irq_resume Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 031/103] xen/gnttab: leave lazy MMU mode in the case of a m2p override failure Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 032/103] [SCSI] libsas: fix usage of ata_tf_to_fis Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 033/103] crypto: authenc - Find proper IV address in ablkcipher callback Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 034/103] s390/crypto: Don't panic after crypto instruction failures Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 035/103] crypto: s390 - Fix aes-xts parameter corruption Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 036/103] crypto: ccm - Fix handling of zero plaintext when computing mac Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 037/103] [SCSI] Disable WRITE SAME for RAID and virtual host adapter drivers Luis Henriques
2013-12-17 22:13 ` Martin K. Petersen
2013-12-18 9:43 ` Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 038/103] ALSA: hda - Fix silent output on ASUS W7J laptop Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 039/103] net: smc91: fix crash regression on the versatile Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 040/103] ARM: footbridge: fix VGA initialisation Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 041/103] [SCSI] hpsa: do not discard scsi status on aborted commands Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 042/103] [SCSI] hpsa: return 0 from driver probe function on success, not 1 Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 043/103] ALSA: hda - Another fixup for ASUS laptop with ALC660 codec Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 044/103] [SCSI] enclosure: fix WARN_ON in dual path device removing Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 045/103] powerpc/gpio: Fix the wrong GPIO input data on MPC8572/MPC8536 Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 046/103] ASoC: wm8731: fix dsp mode configuration Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 047/103] cpuidle: Check for dev before deregistering it Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 048/103] iwlwifi: dvm: don't override mac80211's queue setting Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 049/103] um: add missing declaration of 'getrlimit()' and friends Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 050/103] dm: fix truncated status strings Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 051/103] elevator: acquire q->sysfs_lock in elevator_change() Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 052/103] iommu/vt-d: Fixed interaction of VFIO_IOMMU_MAP_DMA with IOMMU address limits Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 053/103] video: kyro: fix incorrect sizes when copying to userspace Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 054/103] Input: allow deselecting serio drivers even without CONFIG_EXPERT Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 055/103] Input: mousedev - allow disabling " Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 056/103] i2c: i801: SMBus patch for Intel Avoton DeviceIDs Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 057/103] HID: add quirk for Freescale i.MX23 ROM recovery Luis Henriques
2013-12-17 19:39 ` Marek Vasut
2013-12-18 16:16 ` Luis Henriques
2013-12-18 17:13 ` Marek Vasut
2013-12-17 18:12 ` [PATCH 3.5 058/103] HID: hid-multitouch: add support for SiS panels Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 059/103] HID: roccat: fix Coverity CID 141438 Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 060/103] HID: apple: option to swap the 'Option' ("Alt") and 'Command' ("Flag") keys Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 061/103] 9p: send uevent after adding/removing mount_tag attribute Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 062/103] NFSv4 wait on recovery for async session errors Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 063/103] sched: Avoid throttle_cfs_rq() racing with period_timer stopping Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 064/103] nfs: fix do_div() warning by instead using sector_div() Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 065/103] dm delay: fix a possible deadlock due to shared workqueue Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 066/103] mac80211: don't attempt to reorder multicast frames Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 067/103] USB: serial: fix race in generic write Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 068/103] usb: gadget: composite: reset delayed_status on reset_config Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 069/103] usb: dwc3: fix implementation of endpoint wedge Luis Henriques
2013-12-17 18:12 ` [PATCH 3.5 070/103] [media] saa7164: fix return value check in saa7164_initdev() Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 071/103] USB: serial: option: blacklist interface 1 for Huawei E173s-6 Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 072/103] USB: option: support new huawei devices Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 073/103] USB: spcp8x5: correct handling of CS5 setting Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 074/103] USB: mos7840: " Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 075/103] USB: ftdi_sio: fixed handling of unsupported CSIZE setting Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 076/103] USB: pl2303: fixed handling of CS5 setting Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 077/103] USB: cdc-acm: Added support for the Lenovo RD02-D400 USB Modem Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 078/103] drm/radeon: fixup bad vram size on SI Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 079/103] usb: hub: Use correct reset for wedged USB3 devices that are NOTATTACHED Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 080/103] drivers/char/i8k.c: add Dell XPLS L421X Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 081/103] crypto: scatterwalk - Set the chain pointer indication bit Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 082/103] crypto: scatterwalk - Use sg_chain_ptr on chain entries Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 083/103] ARM: 7912/1: check stack pointer in get_wchan Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 084/103] ARM: 7913/1: fix framepointer check in unwind_frame Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 085/103] ALSA: memalloc.h - fix wrong truncation of dma_addr_t Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 086/103] dm snapshot: avoid snapshot space leak on crash Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 087/103] dm table: fail dm_table_create on dm_round_up overflow Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 088/103] x86, build, icc: Remove uninitialized_var() from compiler-intel.h Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 089/103] x86, efi: Don't use (U)EFI time services on 32 bit Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 090/103] dm bufio: initialize read-only module parameters Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 091/103] ARM: pxa: tosa: fix keys mapping Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 092/103] hwmon: (w83l786ng) Fix fan speed control mode setting and reporting Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 093/103] hwmon: (w83l768ng) Fix fan speed control range Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 094/103] hwmon: Prevent some divide by zeros in FAN_TO_REG() Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 095/103] futex: fix handling of read-only-mapped hugepages Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 096/103] KVM: Improve create VCPU parameter (CVE-2013-4587) Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 097/103] KVM: x86: Fix potential divide by 0 in lapic (CVE-2013-6367) Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 098/103] KVM: x86: Convert vapic synchronization to _cached functions (CVE-2013-6368) Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 099/103] selinux: handle TCP SYN-ACK packets correctly in selinux_ip_output() Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 100/103] selinux: handle TCP SYN-ACK packets correctly in selinux_ip_postroute() Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 101/103] drivers/rtc/rtc-at91rm9200.c: correct alarm over day/month wrap Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 102/103] MIPS: DMA: For BMIPS5000 cores flush region just like non-coherent R10000 Luis Henriques
2013-12-17 18:13 ` [PATCH 3.5 103/103] xfs: underflow bug in xfs_attrlist_by_handle() Luis Henriques
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387304012-23805-27-git-send-email-luis.henriques@canonical.com \
--to=luis.henriques@canonical.com \
--cc=cjb@laptop.org \
--cc=kernel-team@lists.ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=yoshitake.kobayashi@toshiba.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®