linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang7@gmail.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	Orson Zhai <orsonzhai@gmail.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-mmc <linux-mmc@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 3/4] mmc: host: hsq: Handle an unusual case of returing busy
Date: Fri, 3 Apr 2020 09:21:19 +0800	[thread overview]
Message-ID: <CADBw62r5FxFv42=BZz2ZmF408rkYD18DkxkJpMpy_Z+6mF6eDg@mail.gmail.com> (raw)
In-Reply-To: <3e048723-2edb-cc5b-a8f1-8ab8554e077f@intel.com>

Hi Adrian,

On Thu, Apr 2, 2020 at 6:45 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 19/03/20 12:54 pm, Baolin Wang wrote:
> > There is an unusual case that the card is busy when trying to send a
> > command, and we can not polling the card status in interrupt context
> > by using request_atomic() to dispatch requests.
> >
> > Thus we should queue a work to try again in the non-atomic context
> > in case the host releases the busy signal later.
>
> I think this should be part of patch 1

OK. Will move these changes into patch 1.

>
> >
> > Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
>
> Sorry for the slow reply.
>
> > ---
> >  drivers/mmc/host/mmc_hsq.c | 37 ++++++++++++++++++++++++++++++++++++-
> >  drivers/mmc/host/mmc_hsq.h |  1 +
> >  2 files changed, 37 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/mmc_hsq.c b/drivers/mmc/host/mmc_hsq.c
> > index fdbaa98..3edad11 100644
> > --- a/drivers/mmc/host/mmc_hsq.c
> > +++ b/drivers/mmc/host/mmc_hsq.c
> > @@ -15,11 +15,33 @@
> >  #define HSQ_NUM_SLOTS        64
> >  #define HSQ_INVALID_TAG      HSQ_NUM_SLOTS
> >
> > +static void mmc_hsq_retry_handler(struct work_struct *work)
> > +{
> > +     struct mmc_hsq *hsq = container_of(work, struct mmc_hsq, retry_work);
> > +     struct mmc_host *mmc = hsq->mmc;
> > +     struct mmc_request *mrq = hsq->mrq;
> > +     struct mmc_data *data = mrq->data;
> > +
> > +     if (mmc->ops->request) {
>
> ->request() is not an optional mmc operation so checking it is not necessary.

Yes, will remove the checking.

>
> > +             mmc->ops->request(mmc, mrq);
> > +             return;
> > +     }
> > +
> > +     /*
> > +      * If host does not supply the callback in normal context to
> > +      * handle request, just finish this request.
> > +      */
> > +     data->error = -EBUSY;
> > +     data->bytes_xfered = 0;
> > +     mmc_hsq_finalize_request(mmc, mrq);
> > +}
> > +
> >  static void mmc_hsq_pump_requests(struct mmc_hsq *hsq)
> >  {
> >       struct mmc_host *mmc = hsq->mmc;
> >       struct hsq_slot *slot;
> >       unsigned long flags;
> > +     int ret = 0;
> >
> >       spin_lock_irqsave(&hsq->lock, flags);
> >
> > @@ -42,9 +64,21 @@ static void mmc_hsq_pump_requests(struct mmc_hsq *hsq)
> >       spin_unlock_irqrestore(&hsq->lock, flags);
> >
> >       if (mmc->ops->request_atomic)
> > -             mmc->ops->request_atomic(mmc, hsq->mrq);
> > +             ret = mmc->ops->request_atomic(mmc, hsq->mrq);
> >       else
> >               mmc->ops->request(mmc, hsq->mrq);
> > +
> > +     /*
> > +      * If returning BUSY from request_atomic(), which means the card
> > +      * may be busy now, and we should change to non-atomic context to
> > +      * try again for this unusual case, to avoid time-consuming operations
> > +      * in the atomic context.
> > +      *
> > +      * Note: we can ignore other error cases, since the host driver
> > +      * will handle them.
> > +      */
> > +     if (ret == -EBUSY)
> > +             schedule_work(&hsq->retry_work);
>
> Let's add a warning for unexpected return values i.e.
>
>         WARN_ON_ONCE(ret && ret != -EBUSY);

Sure. Thanks for your comments.

>
>
> >  }
> >
> >  static void mmc_hsq_update_next_tag(struct mmc_hsq *hsq, int remains)
> > @@ -327,6 +361,7 @@ int mmc_hsq_init(struct mmc_hsq *hsq, struct mmc_host *mmc)
> >       hsq->mmc->cqe_private = hsq;
> >       mmc->cqe_ops = &mmc_hsq_ops;
> >
> > +     INIT_WORK(&hsq->retry_work, mmc_hsq_retry_handler);
> >       spin_lock_init(&hsq->lock);
> >       init_waitqueue_head(&hsq->wait_queue);
> >
> > diff --git a/drivers/mmc/host/mmc_hsq.h b/drivers/mmc/host/mmc_hsq.h
> > index d51beb7..81f6c4f 100644
> > --- a/drivers/mmc/host/mmc_hsq.h
> > +++ b/drivers/mmc/host/mmc_hsq.h
> > @@ -12,6 +12,7 @@ struct mmc_hsq {
> >       wait_queue_head_t wait_queue;
> >       struct hsq_slot *slot;
> >       spinlock_t lock;
> > +     struct work_struct retry_work;
> >
> >       int next_tag;
> >       int num_slots;
> >
>


-- 
Baolin Wang

  reply	other threads:[~2020-04-03  1:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 10:54 [PATCH v3 0/4] Introduce the request_atomic() for the host Baolin Wang
2020-03-19 10:54 ` [PATCH v3 1/4] mmc: host: " Baolin Wang
2020-03-19 10:54 ` [PATCH v3 2/4] mmc: host: sdhci: Implement the request_atomic() API Baolin Wang
2020-03-19 10:54 ` [PATCH v3 3/4] mmc: host: hsq: Handle an unusual case of returing busy Baolin Wang
2020-04-02 10:45   ` Adrian Hunter
2020-04-03  1:21     ` Baolin Wang [this message]
2020-03-19 10:54 ` [PATCH v3 4/4] mmc: host: sdhci-sprd: Implement the request_atomic() API Baolin Wang

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='CADBw62r5FxFv42=BZz2ZmF408rkYD18DkxkJpMpy_Z+6mF6eDg@mail.gmail.com' \
    --to=baolin.wang7@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=ulf.hansson@linaro.org \
    --cc=zhang.lyra@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).