Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: "andriy.shevchenko@linux.intel.com"  <andriy.shevchenko@linux.intel.com>
To: "Christian Löhle" <CLoehle@hyperstone.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Avri Altman <Avri.Altman@wdc.com>,
	"david-b@pacbell.net" <david-b@pacbell.net>
Subject: Re: [PATCH] mmc: block: Check for errors after write on SPI
Date: Tue, 22 Mar 2022 20:44:09 +0200	[thread overview]
Message-ID: <YjoY+Z/iuIoNDhch@smile.fi.intel.com> (raw)
In-Reply-To: <9d1ea819e4bb4222a227a02d5f6ad97c@hyperstone.com>

On Tue, Mar 22, 2022 at 04:21:34PM +0000, Christian Löhle wrote:
> Introduce a SEND_STATUS check for writes through SPI to not mark
> an unsuccessful write as successful.
> 
> Since SPI SD/MMC does not have states, after a write, the card will
> just hold the line LOW until it is ready again. The driver marks the
> write therefore as completed as soon as it reads something other than
> all zeroes.
> The driver does not distinguish from a card no longer signalling busy
> and it being disconnected (and the line being pulled-up by the host).
> This lead to writes being marked as successful when disconnecting
> a busy card.
> Now the card is ensured to be still connected by an additional CMD13,
> just like non-SPI is ensured to go back to TRAN state.
> 
> While at it and since we already poll for the post-write status anyway,
> we might as well check for SPIs error bits (any of them).
> 
> The disconnecting card problem is reproducable for me after continuous
> write activity and randomly disconnecting, around every 20-50 tries
> on SPI DS for some card.

...

> +	if (mmc_host_is_spi(card->host)) {
> +		u32 status = 0;

> +		err = __mmc_send_status(card, &status, 0);

> +		/* All R1 and R2 bits of SPI are errors in our case */
> +		if (status)
> +			err = err ? err : -EIO;

I would use either this:

		if (err || status) {
			mqrq->brq.data.bytes_xfered = 0;

			if (err)
				return err;
			return -EIO;
		}

		return 0;

or at least this:

			err = err ?: -EIO;

or even this:

		if (!err && status)
			err = -EIO;

(Personally I would choose the first option)


> +		if (err)
> +			mqrq->brq.data.bytes_xfered = 0;
> +		return err;
> +	}

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2022-03-22 18:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22 16:21 [PATCH] mmc: block: Check for errors after write on SPI Christian Löhle
2022-03-22 18:44 ` andriy.shevchenko [this message]
2022-03-23 14:12 ` [PATCHv2] " Christian Löhle
2022-03-23 14:37   ` Andy Shevchenko
2022-03-24 11:34   ` Ulf Hansson

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=YjoY+Z/iuIoNDhch@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Avri.Altman@wdc.com \
    --cc=CLoehle@hyperstone.com \
    --cc=adrian.hunter@intel.com \
    --cc=david-b@pacbell.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /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