All of lore.kernel.org
 help / color / mirror / Atom feed
From: "andriy.shevchenko@linux.intel.com"  <andriy.shevchenko@linux.intel.com>
To: "Christian Löhle" <CLoehle@hyperstone.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: [PATCHv4] mmc: block: Check for errors after write on SPI
Date: Thu, 24 Mar 2022 15:53:38 +0200	[thread overview]
Message-ID: <Yjx34sDWl4bMSCg3@smile.fi.intel.com> (raw)
In-Reply-To: <8052f30adc3747e2beab0e52db26837d@hyperstone.com>

On Thu, Mar 24, 2022 at 01:27:51PM +0000, Christian Löhle wrote:

...

> v4:
>   - Move block layer handling out of the spi-specific function

In this case some optimizations are possible. See below.

...

> +static int mmc_spi_err_check(struct mmc_card *card)
> +{
> +	u32 status = 0;
> +	int err;
> +
> +	/*
> +	 * SPI does not have a TRAN state we have to wait on, instead the
> +	 * card is ready again when it no longer holds the line LOW.
> +	 * We still have to ensure two things here before we know the write
> +	 * was successful:
> +	 * 1. The card has not disconnected during busy and we actually read our
> +	 * own pull-up, thinking it was still connected, so ensure it
> +	 * still responds.
> +	 * 2. Check for any error bits, in particular R1_SPI_IDLE to catch a
> +	 * just reconnected card after being disconnected during busy.
> +	 */
> +	err = __mmc_send_status(card, &status, 0);

> +	/* All R1 and R2 bits of SPI are errors in our case */
> +	if (err || status) {
> +		if (err)
> +			return err;
> +		return -EIO;
> +	}

	if (err)
		return err;

	/* All R1 and R2 bits of SPI are errors in our case */
	if (status)
		return -EIO;

> +	return 0;
> +}

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2022-03-24 13:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24 13:27 [PATCHv4] mmc: block: Check for errors after write on SPI Christian Löhle
2022-03-24 13:53 ` andriy.shevchenko [this message]

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=Yjx34sDWl4bMSCg3@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=CLoehle@hyperstone.com \
    --cc=adrian.hunter@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.