linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Collingbourne <pcc@google.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Christoph Hellwig <hch@lst.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	linux-mmc@vger.kernel.org, Damien Le Moal <damien.lemoal@wdc.com>
Subject: Re: [PATCH] mmc: core: don't initialize block size from ext_csd if not present
Date: Wed, 13 Jan 2021 11:46:24 -0800	[thread overview]
Message-ID: <CAMn1gO5Yuy3c48Rscny6mnQAycZeUy-aCwex_r=h_XTMF6Lh-g@mail.gmail.com> (raw)
In-Reply-To: <34278e68-d69f-0440-858e-b2079b8ac7bb@intel.com>

On Wed, Jan 13, 2021 at 2:43 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 12/01/21 11:09 pm, Peter Collingbourne wrote:
> > If extended CSD was not available, the eMMC driver would incorrectly
> > set the block size to 0, as the data_sector_size field of ext_csd
> > was never initialized. This issue was exposed by commit 817046ecddbc
> > ("block: Align max_hw_sectors to logical blocksize") which caused
> > max_sectors and max_hw_sectors to be set to 0 after setting the block
> > size to 0, resulting in a kernel panic in bio_split when attempting
> > to read from the device. Fix it by only reading the block size from
> > ext_csd if it is available.
> >
> > Fixes: 817046ecddbc ("block: Align max_hw_sectors to logical blocksize")
>
> I would go with the original commit i.e.
>
> Fixes: a5075eb94837 ("mmc: block: Allow disabling 512B sector size emulation")

Sure, makes sense.

> > Signed-off-by: Peter Collingbourne <pcc@google.com>
> > Link: https://linux-review.googlesource.com/id/If244d178da4d86b52034459438fec295b02d6e60
> > ---
> >  drivers/mmc/core/queue.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
> > index de7cb0369c30..735cdbf1145c 100644
> > --- a/drivers/mmc/core/queue.c
> > +++ b/drivers/mmc/core/queue.c
> > @@ -20,6 +20,7 @@
> >  #include "core.h"
> >  #include "card.h"
> >  #include "host.h"
> > +#include "mmc_ops.h"
> >
> >  #define MMC_DMA_MAP_MERGE_SEGMENTS   512
> >
> > @@ -384,7 +385,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
> >                    "merging was advertised but not possible");
> >       blk_queue_max_segments(mq->queue, mmc_get_max_segments(host));
> >
> > -     if (mmc_card_mmc(card))
> > +     if (mmc_card_mmc(card) && mmc_can_ext_csd(card))
> >               block_size = card->ext_csd.data_sector_size;
>
> Might as well be:
>
>         if (mmc_card_mmc(card) && card->ext_csd.data_sector_size)
>                 block_size = card->ext_csd.data_sector_size;

Can we rely on this data structure to be zero initialized? I suppose
so, provided that it was allocated with mmc_alloc_card which uses
kzalloc. But it isn't entirely obvious and I figure it may be a little
better to be explicit in our intent here. But either way works for me.

Peter

  reply	other threads:[~2021-01-13 19:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 21:09 [PATCH] mmc: core: don't initialize block size from ext_csd if not present Peter Collingbourne
2021-01-12 23:29 ` Damien Le Moal
2021-01-13  9:16 ` kernel test robot
2021-01-13 10:43 ` Adrian Hunter
2021-01-13 19:46   ` Peter Collingbourne [this message]
2021-01-14  6:10     ` Adrian Hunter
2021-01-14 20:14       ` Peter Collingbourne

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='CAMn1gO5Yuy3c48Rscny6mnQAycZeUy-aCwex_r=h_XTMF6Lh-g@mail.gmail.com' \
    --to=pcc@google.com \
    --cc=adrian.hunter@intel.com \
    --cc=damien.lemoal@wdc.com \
    --cc=hch@lst.de \
    --cc=linus.walleij@linaro.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;
as well as URLs for NNTP newsgroup(s).