linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Seungwon Jeon <tgih.jun@samsung.com>
To: 'Ulf Hansson' <ulf.hansson@linaro.org>
Cc: 'linux-mmc' <linux-mmc@vger.kernel.org>,
	'Chris Ball' <chris@printf.net>,
	'Jaehoon Chung' <jh80.chung@samsung.com>,
	'Jackey Shen' <jackey.shen@amd.com>,
	'Alim Akhtar' <alim.akhtar@samsung.com>
Subject: RE: [PATCH v3 4/5] mmc: rework selection of bus speed mode
Date: Sat, 22 Mar 2014 21:04:09 +0900	[thread overview]
Message-ID: <003301cf45c6$d4d42db0$7e7c8910$%jun@samsung.com> (raw)
In-Reply-To: <CAPDyKFoHR1Re6a3fpc0rCvx2jiXDQotU2wA7wSHiTQeWEguoxA@mail.gmail.com>

On Fri, March 21, 2014, Ulf Hansson wrote:
> On 14 March 2014 13:16, Seungwon Jeon <tgih.jun@samsung.com> wrote:
> > Current implementation for bus speed mode selection is too
> > complicated. This patch is to simplify the codes and remove
> > some duplicate parts.
> 
> Really appreciate you taking on this task!
> 
> >
> > The following changes are including:
> > * Adds functions for each mode selection(HS, HS-DDR, HS200 and etc)
> > * Rearranged the mode selection sequence with supported device type
> > * Adds maximum speed for HS200 mode(hs200_max_dtr)
> > * Adds field definition for HS_TIMING of EXT_CSD
> >
> > Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> > Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
> > Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
> > ---
> >  drivers/mmc/core/debugfs.c |    2 +-
> >  drivers/mmc/core/mmc.c     |  431 ++++++++++++++++++++++++--------------------
> >  include/linux/mmc/card.h   |    1 +
> >  include/linux/mmc/mmc.h    |    4 +
> >  4 files changed, 238 insertions(+), 200 deletions(-)
> >
> > diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> > index 509229b..1f730db 100644
> > --- a/drivers/mmc/core/debugfs.c
> > +++ b/drivers/mmc/core/debugfs.c
> > @@ -139,7 +139,7 @@ static int mmc_ios_show(struct seq_file *s, void *data)
> >                 str = "mmc DDR52";
> >                 break;
> >         case MMC_TIMING_MMC_HS200:
> > -               str = "mmc high-speed SDR200";
> > +               str = "mmc HS200";
> >                 break;
> >         default:
> >                 str = "invalid";
> > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> > index 480c100..6dd68e6 100644
> > --- a/drivers/mmc/core/mmc.c
> > +++ b/drivers/mmc/core/mmc.c
> > @@ -242,7 +242,7 @@ static void mmc_select_card_type(struct mmc_card *card)
> >         struct mmc_host *host = card->host;
> >         u8 card_type = card->ext_csd.raw_card_type & EXT_CSD_CARD_TYPE_MASK;
> >         u32 caps = host->caps, caps2 = host->caps2;
> > -       unsigned int hs_max_dtr = 0;
> > +       unsigned int hs_max_dtr = 0, hs200_max_dtr = 0;
> >         unsigned int avail_type = 0;
> >
> >         if (caps & MMC_CAP_MMC_HIGHSPEED &&
> > @@ -271,17 +271,18 @@ static void mmc_select_card_type(struct mmc_card *card)
> >
> >         if (caps2 & MMC_CAP2_HS200_1_8V_SDR &&
> >             card_type & EXT_CSD_CARD_TYPE_HS200_1_8V) {
> > -               hs_max_dtr = MMC_HS200_MAX_DTR;
> > +               hs200_max_dtr = MMC_HS200_MAX_DTR;
> >                 avail_type |= EXT_CSD_CARD_TYPE_HS200_1_8V;
> >         }
> >
> >         if (caps2 & MMC_CAP2_HS200_1_2V_SDR &&
> >             card_type & EXT_CSD_CARD_TYPE_HS200_1_2V) {
> > -               hs_max_dtr = MMC_HS200_MAX_DTR;
> > +               hs200_max_dtr = MMC_HS200_MAX_DTR;
> >                 avail_type |= EXT_CSD_CARD_TYPE_HS200_1_2V;
> >         }
> >
> >         card->ext_csd.hs_max_dtr = hs_max_dtr;
> > +       card->ext_csd.hs200_max_dtr = hs200_max_dtr;
> >         card->mmc_avail_type = avail_type;
> >  }
> >
> > @@ -833,37 +834,46 @@ static int mmc_select_powerclass(struct mmc_card *card)
> >  }
> >
> >  /*
> > - * Selects the desired buswidth and switch to the HS200 mode
> > - * if bus width set without error
> > + * Set the bus speed for the selected speed mode.
> >   */
> > -static int mmc_select_hs200(struct mmc_card *card)
> > +static void mmc_set_bus_speed(struct mmc_card *card)
> > +{
> > +       unsigned int max_dtr = (unsigned int)-1;
> 
> I guess this is to silence compile warnings? Why not just:
> unsigned int max_dtr = 0;
Basically, I made an effort to keep the previous codes if it's not a problem.
If you found something wrong, please let me know.

> 
> > +
> > +       if (mmc_card_hs200(card) && max_dtr > card->ext_csd.hs200_max_dtr)
> > +               max_dtr = card->ext_csd.hs200_max_dtr;
> > +       else if (mmc_card_hs(card) && max_dtr > card->ext_csd.hs_max_dtr)
> > +               max_dtr = card->ext_csd.hs_max_dtr;
> > +       else if (max_dtr > card->csd.max_dtr)
> > +               max_dtr = card->csd.max_dtr;
> > +
> > +       mmc_set_clock(card->host, max_dtr);
> > +}
> > +
> > +/*
> > + * Select the bus width amoung 4-bit and 8-bit(SDR).
> > + * If the bus width is changed successfully, return the slected width value.
> > + * Zero is returned instead of error value if the wide width is not supported.
> > + */
> > +static int mmc_select_bus_width(struct mmc_card *card)
> >  {
> > -       int idx, err = -EINVAL;
> > -       struct mmc_host *host;
> >         static unsigned ext_csd_bits[] = {
> > -               EXT_CSD_BUS_WIDTH_4,
> >                 EXT_CSD_BUS_WIDTH_8,
> > +               EXT_CSD_BUS_WIDTH_4,
> >         };
> >         static unsigned bus_widths[] = {
> > -               MMC_BUS_WIDTH_4,
> >                 MMC_BUS_WIDTH_8,
> > +               MMC_BUS_WIDTH_4,
> >         };
> 
> Do we really need to keep these arrays? The only contain only two values.
> 
> Can't we just try with 8-bit, if supported, and if it fails try with
> 4-bit. Would that further simplify the code?
Yes, current implementation does that.
First,  it tries with 8-bit if supported, and if failed, it will be tried with 4-bit.
And I think using array can make simple retry coding if considering failure case.
I intended to keep original way.

> 
> Overall looks good to me, besides the minor comments above.
> 
> Since this kind of touches quite old code, I would appreciate if it
> could go though some more testing in linux next, thus it's material
> for early queueing to 3.16.
> 
> But before we go on, I would like to know if you managed to test all
> the different variants of buswidth/speedmode and the bus width test?
> If there is any specific test would like to get help to run, just tell
> me.
> 
> Nice work!
It would be nice if it's picked for 3.15.
As I mentioned above, I basically kept the original flow and way.

This change applies only to eMMC type and participates only in card initialization's process.
I tested on the following various mode and detection is performed successfully.

- HS400	w/ 8-bit
- HS400	w/ 4-bit	: HS200 mode is selected(Because HS400 is possible with 8-bit)
- HS200	w/ 4-bit or 8-bit 
- DDR52	w/ 4-bit or 8-bit
- High speed	w/ 1-bit, 4-bit or 8-bit
- Backwards	w/ 1-bit, 4-bit or 8-bit

I really appreciate your deep reviews.

Thanks,
Seungwon Jeon


  reply	other threads:[~2014-03-22 12:04 UTC|newest]

Thread overview: 181+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05 12:10 [PATCH 0/3] mmc: tmio: Use modern PM ops Ulf Hansson
2013-11-05 12:10 ` [PATCH 1/3] mmc: sh_mobile_sdhi: Use modern PM macros to define pm callbacks Ulf Hansson
2013-11-05 22:29   ` Guennadi Liakhovetski
2013-11-05 12:10 ` [PATCH 2/3] mmc: tmio_mmc: Convert from legacy to modern PM ops Ulf Hansson
2013-11-05 22:24   ` Guennadi Liakhovetski
2013-11-05 12:10 ` [PATCH 3/3] mmc: tmio: Adapt to proper PM configs for exported functions Ulf Hansson
2013-11-05 22:29   ` Guennadi Liakhovetski
2013-11-05 13:26 ` [PATCH] mmc: trivial: fix the compiling warning Seungwon Jeon
2013-11-06  3:20   ` Jaehoon Chung
2013-11-06  9:42     ` Seungwon Jeon
2013-11-05 13:27 ` [PATCH 0/3] mmc: update bus speed mode Seungwon Jeon
2013-11-05 13:27 ` [PATCH 1/3] mmc: rework selection of " Seungwon Jeon
2013-11-05 14:06   ` Ulf Hansson
2013-11-06  9:09     ` Seungwon Jeon
2013-11-06 10:46       ` Ulf Hansson
2013-11-05 13:27 ` [PATCH 2/3] mmc: correct some exclusive card state to clear Seungwon Jeon
2013-11-05 14:33   ` Ulf Hansson
2013-11-06  9:35     ` Seungwon Jeon
2013-11-06 10:38       ` Ulf Hansson
2013-11-07  3:51         ` Seungwon Jeon
2013-11-05 13:28 ` [PATCH 3/3] mmc: add support for hs400 mode of eMMC5.0 Seungwon Jeon
2013-11-07  7:38   ` Shen, Jackey
2013-11-07 11:38     ` Seungwon Jeon
2013-11-08  9:05       ` Jackey Shen
2013-11-11 12:51         ` Seungwon Jeon
2013-11-25  7:32           ` Jackey Shen
2013-11-08 12:16 ` [PATCH 0/3] mmc: tmio: Use modern PM ops Guennadi Liakhovetski
2013-11-11  9:24   ` Ulf Hansson
2014-01-15 14:10 ` [PATCH 0/7] mmc: distinguish DDR timing mode for eMMC/UHS Seungwon Jeon
2014-01-15 14:10 ` [PATCH 1/7] mmc: clarify DDR timing mode between SD-UHS and eMMC Seungwon Jeon
2014-01-16 10:50   ` Ulf Hansson
2014-01-17 21:22     ` Ulf Hansson
2014-01-20  3:55       ` Seungwon Jeon
2014-01-23  9:06         ` Ulf Hansson
2014-01-15 14:11 ` [PATCH 2/7] mmc: mmci: " Seungwon Jeon
2014-01-16 10:20   ` Ulf Hansson
2014-01-17 14:05     ` Seungwon Jeon
2014-01-17 14:50     ` [PATCH v2 " Seungwon Jeon
2014-01-15 14:11 ` [PATCH 3/7] mmc: omap: " Seungwon Jeon
2014-01-16 10:49   ` Ulf Hansson
2014-01-16 11:07     ` Balaji T K
2014-01-16 11:01   ` Balaji T K
2014-01-15 14:12 ` [PATCH 4/7] mmc: sh_mmcif: " Seungwon Jeon
2014-01-16 10:22   ` Ulf Hansson
2014-01-17 14:36     ` Seungwon Jeon
2014-01-28 13:08     ` Seungwon Jeon
2014-01-15 14:12 ` [PATCH 5/7] mmc: rtsx: " Seungwon Jeon
2014-01-16 10:51   ` Ulf Hansson
2014-01-15 14:12 ` [PATCH 6/7] mmc: dw_mmc: " Seungwon Jeon
2014-01-16 10:37   ` Ulf Hansson
2014-01-15 14:12 ` [PATCH 7/7] mmc: sdhci: " Seungwon Jeon
2014-01-16 10:25   ` Ulf Hansson
2014-01-15 14:13 ` [PATCH 0/5] update selection of bus speed mode for eMMC Seungwon Jeon
2014-01-15 14:14 ` [PATCH 1/5] mmc: drop the speed mode of card's state Seungwon Jeon
2014-01-15 14:14 ` [PATCH 2/5] mmc: identify available device type to select Seungwon Jeon
2014-01-15 14:14 ` [PATCH 3/5] mmc: step power class after final selection of bus mode Seungwon Jeon
2014-01-15 14:15 ` [PATCH 4/5] mmc: rework selection of bus speed mode Seungwon Jeon
2014-01-15 14:19 ` [PATCH 5/5] mmc: add support for HS400 mode of eMMC5.0 Seungwon Jeon
2014-02-18 10:24   ` Jackey Shen
2014-02-18 13:31     ` Seungwon Jeon
2014-02-15 14:08 ` [PATCH v2 0/7] mmc: distinguish DDR timing mode for eMMC/UHS Seungwon Jeon
2014-03-07 13:30   ` [PATCH v3 " Seungwon Jeon
2014-03-14 12:11   ` [PATCH RESEND " Seungwon Jeon
2014-04-02 11:50     ` Ulf Hansson
2014-04-03 11:56       ` Seungwon Jeon
2014-02-15 14:08 ` [PATCH v2 1/7] mmc: clarify DDR timing mode between SD-UHS and eMMC Seungwon Jeon
2014-03-07 13:30   ` [PATCH v3 " Seungwon Jeon
2014-03-07 13:42     ` Jaehoon Chung
2014-03-14 12:11   ` [PATCH RESEND " Seungwon Jeon
2014-02-15 14:08 ` [PATCH v2 2/7] mmc: mmci: " Seungwon Jeon
2014-02-17 14:08   ` Ulf Hansson
2014-02-18 13:34     ` Seungwon Jeon
2014-03-07 13:30   ` [PATCH v3 " Seungwon Jeon
2014-03-14 12:12   ` [PATCH RESEND " Seungwon Jeon
2014-02-15 14:09 ` [PATCH v2 3/7] mmc: omap: " Seungwon Jeon
2014-03-07 13:30   ` [PATCH v3 " Seungwon Jeon
2014-03-14 12:12   ` [PATCH RESEND " Seungwon Jeon
2014-02-15 14:09 ` [PATCH v2 4/7] mmc: sh_mmcif: " Seungwon Jeon
2014-03-07 13:30   ` [PATCH v3 " Seungwon Jeon
2014-03-14 12:12   ` [PATCH RESEND " Seungwon Jeon
2014-02-15 14:09 ` [PATCH v2 5/7] mmc: rtsx: " Seungwon Jeon
2014-03-07 13:31   ` [PATCH v3 " Seungwon Jeon
2014-03-14 12:12   ` [PATCH RESEND " Seungwon Jeon
2014-02-15 14:09 ` [PATCH v2 6/7] mmc: dw_mmc: " Seungwon Jeon
2014-03-07 13:31   ` [PATCH v3 " Seungwon Jeon
2014-03-07 13:43     ` Jaehoon Chung
2014-03-14 12:12   ` [PATCH RESEMD " Seungwon Jeon
2014-02-15 14:09 ` [PATCH v2 7/7] mmc: sdhci: " Seungwon Jeon
2014-03-07 13:31   ` [PATCH v3 " Seungwon Jeon
2014-03-14 12:12   ` [PATCH RESEND " Seungwon Jeon
2014-02-15 14:18 ` [PATCH RESEND 0/5] update selection of bus speed mode for eMMC Seungwon Jeon
2014-03-07 14:35   ` [PATCH v2 " Seungwon Jeon
2014-03-13 14:41     ` Ulf Hansson
2014-03-13  9:52   ` [PATCH RESEND " Jaehoon Chung
2014-03-14 12:16   ` [PATCH v3 " Seungwon Jeon
2014-03-17  8:47     ` Ulf Hansson
2014-03-18  1:43       ` Seungwon Jeon
2014-03-18  4:20         ` Jaehoon Chung
2014-03-18  8:01           ` Ulf Hansson
2014-03-26 10:59   ` [PATCH v4 " Seungwon Jeon
2014-03-26 11:00   ` [PATCH v4 1/5] mmc: drop the speed mode of card's state Seungwon Jeon
2014-03-26 11:00   ` [PATCH v4 2/5] mmc: identify available device type to select Seungwon Jeon
2014-03-26 11:00   ` [PATCH v4 3/5] mmc: step power class after final selection of bus mode Seungwon Jeon
2014-03-28  8:43     ` Ulf Hansson
2014-03-26 11:00   ` [PATCH v4 4/5] mmc: rework selection of bus speed mode Seungwon Jeon
2014-03-26 11:00   ` [PATCH v4 5/5] mmc: add support for HS400 mode of eMMC5.0 Seungwon Jeon
2014-04-11 11:33   ` [PATCH v5 0/5] update selection of bus speed mode for eMMC Seungwon Jeon
2014-04-11 11:34   ` [PATCH v5 1/5] mmc: drop the speed mode of card's state Seungwon Jeon
2014-04-11 11:34   ` [PATCH v5 2/5] mmc: identify available device type to select Seungwon Jeon
2014-04-11 11:47     ` Ulf Hansson
2014-04-11 11:34   ` [PATCH v5 3/5] mmc: step power class after final selection of bus mode Seungwon Jeon
2014-04-11 11:34   ` [PATCH v5 4/5] mmc: rework selection of bus speed mode Seungwon Jeon
2014-04-11 11:34   ` [PATCH v5 5/5] mmc: add support for HS400 mode of eMMC5.0 Seungwon Jeon
2014-04-11 12:06     ` Ulf Hansson
2014-04-18 13:36   ` [PATCH v6 0/6] update selection of bus speed mode for eMMC Seungwon Jeon
2014-04-20  7:18     ` Ulf Hansson
2014-04-21  3:55       ` Seungwon Jeon
2014-04-18 13:36   ` [PATCH v6 1/6] mmc: drop the speed mode of card's state Seungwon Jeon
2014-04-18 13:36   ` [PATCH v6 2/6] mmc: identify available device type to select Seungwon Jeon
2014-04-18 13:36   ` [PATCH v6 3/6] mmc: step power class after final selection of bus mode Seungwon Jeon
2014-04-18 13:36   ` [PATCH v6 4/6] mmc: rework selection of bus speed mode Seungwon Jeon
2014-04-18 13:37   ` [PATCH v6 5/6] mmc: add support for HS400 mode of eMMC5.0 Seungwon Jeon
2014-04-18 13:37   ` [PATCH v6 6/6] mmc: core: add DT bindings for eMMC HS400 1.8/1.2V Seungwon Jeon
2014-04-23  8:30     ` Ulf Hansson
2014-04-23  8:07   ` [PATCH 0/6] update selection of bus speed mode for eMMC Seungwon Jeon
2014-04-23  8:07   ` [PATCH 1/6] mmc: drop the speed mode of card's state Seungwon Jeon
2014-05-05  8:02     ` Ulf Hansson
2014-04-23  8:07   ` [PATCH 2/6] mmc: identify available device type to select Seungwon Jeon
2014-04-23  8:08   ` [PATCH 3/6] mmc: step power class after final selection of bus mode Seungwon Jeon
2014-04-23  8:08   ` [PATCH 4/6] mmc: rework selection of bus speed mode Seungwon Jeon
2014-04-23  8:14   ` [PATCH 5/6] mmc: add support for HS400 mode of eMMC5.0 Seungwon Jeon
2014-04-23  8:15   ` [PATCH 6/6] mmc: core: add DT bindings for eMMC HS400 1.8/1.2V Seungwon Jeon
2014-02-15 14:18 ` [PATCH RESEND 1/5] mmc: drop the speed mode of card's state Seungwon Jeon
2014-02-17 14:38   ` Ulf Hansson
2014-02-18 13:43     ` Seungwon Jeon
2014-02-18 16:40       ` Ulf Hansson
2014-03-07 14:36   ` [PATCH v2 " Seungwon Jeon
2014-03-14 12:16   ` [PATCH v3 " Seungwon Jeon
2014-02-15 14:18 ` [PATCH RESEND 2/5] mmc: identify available device type to select Seungwon Jeon
2014-03-07 14:36   ` [PATCH v2 " Seungwon Jeon
2014-03-10 10:14     ` Jaehoon Chung
2014-03-10 11:59       ` Seungwon Jeon
2014-03-13  5:37         ` Jaehoon Chung
2014-03-13  8:37           ` Seungwon Jeon
2014-03-13  9:51             ` Jaehoon Chung
2014-03-13 14:02     ` Ulf Hansson
2014-03-14  2:49       ` Seungwon Jeon
2014-03-14  7:34         ` Ulf Hansson
2014-03-14 10:24           ` Seungwon Jeon
2014-03-28  8:31         ` Ulf Hansson
2014-03-28 12:27           ` Seungwon Jeon
2014-03-14 12:16   ` [PATCH v3 " Seungwon Jeon
2014-02-15 14:23 ` [PATCH RESEND 3/5] mmc: step power class after final selection of bus mode Seungwon Jeon
2014-03-07 14:36   ` [PATCH v2 " Seungwon Jeon
2014-03-13 14:28     ` Ulf Hansson
2014-03-14  2:49       ` Seungwon Jeon
2014-03-14  7:31         ` Ulf Hansson
2014-03-14 12:16   ` [PATCH v3 " Seungwon Jeon
2014-02-15 14:24 ` [PATCH RESEND 4/5] mmc: rework selection of bus speed mode Seungwon Jeon
2014-03-07 14:36   ` [PATCH v2 " Seungwon Jeon
2014-03-14 12:16   ` [PATCH v3 " Seungwon Jeon
2014-03-21 13:01     ` Ulf Hansson
2014-03-22 12:04       ` Seungwon Jeon [this message]
2014-03-24 13:11         ` Ulf Hansson
2014-02-15 14:24 ` [PATCH RESEND 5/5] mmc: add support for HS400 mode of eMMC5.0 Seungwon Jeon
2014-03-07 14:36   ` [PATCH v2 " Seungwon Jeon
2014-03-11  0:45     ` Jackey Shen
2014-03-14 11:34       ` Seungwon Jeon
2014-03-14 12:16   ` [PATCH v3 " Seungwon Jeon
2014-03-24 15:41     ` Ulf Hansson
2014-03-25  9:23       ` Seungwon Jeon
2014-03-28  9:57         ` Ulf Hansson
2014-03-28 12:18           ` Seungwon Jeon
2014-03-28 13:33             ` Ulf Hansson
2014-04-02  1:15               ` Seungwon Jeon
2014-04-02  9:39                 ` Ulf Hansson
2014-04-03 11:53                   ` Seungwon Jeon
2014-04-03 13:14                     ` Ulf Hansson
2014-04-04 10:46                       ` Seungwon Jeon
2014-04-04 11:58                         ` Ulf Hansson
2014-04-05 14:36                           ` Seungwon Jeon

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='003301cf45c6$d4d42db0$7e7c8910$%jun@samsung.com' \
    --to=tgih.jun@samsung.com \
    --cc=alim.akhtar@samsung.com \
    --cc=chris@printf.net \
    --cc=jackey.shen@amd.com \
    --cc=jh80.chung@samsung.com \
    --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).