1. 29 11月, 2016 4 次提交
    • U
      mmc: core: Update CMD13 polling policy when switch to HS DDR mode · e173f891
      Ulf Hansson 提交于
      According to the JEDEC specification, during bus timing change operations
      for mmc, sending a CMD13 could trigger CRC errors.
      
      As switching to HS DDR mode indeed causes a bus timing change, polling with
      CMD13 to detect card busy, may thus potentially trigger CRC errors.
      Currently these errors are treated as the switch to HS DDR mode failed.
      
      To improve this behaviour, let's instead tell __mmc_switch() to retry when
      it encounters CRC errors during polling.
      
      Moreover, when switching to HS DDR mode, let's make sure the CMD13 polling
      is done by having the mmc host and the mmc card, being configured to
      operate at the same selected bus speed timing. Fix this by providing
      MMC_TIMING_MMC_DDR52 as the timing parameter to __mmc_switch().
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Tested-by: NLinus Walleij <linus.walleij@linaro.org>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      e173f891
    • U
      mmc: core: Allow CMD13 polling when switching to HS mode for mmc · 53e60650
      Ulf Hansson 提交于
      In cases when the mmc host doesn't support HW busy detection, polling for a
      card being busy by using CMD13 is beneficial. That is because, instead of
      waiting a fixed amount of time, 500ms or the generic CMD6 time from
      EXT_CSD, we find out a lot sooner when the card stops signaling busy. This
      leads to a significant decreased total initialization time for the mmc
      card.
      
      However, to allow polling with CMD13 during a bus timing change operation,
      such as switching to HS mode, we first need to update the mmc host's bus
      timing before starting to poll. Deal with that, simply by providing
      MMC_TIMING_MMC_HS as the timing parameter to __mmc_switch() from
      mmc_select_hs().
      
      By telling __mmc_switch() to allow polling with CMD13, also makes it
      validate the CMD6 status, thus we can remove the corresponding checks.
      
      When switching to HS400ES, the mmc_select_hs() function is called in one of
      the intermediate steps. To still prevent CMD13 polling for HS400ES, let's
      call the __mmc_switch() function in this path as it enables us to keep
      using the existing method.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Tested-by: NLinus Walleij <linus.walleij@linaro.org>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      53e60650
    • U
      mmc: core: Enable __mmc_switch() to change bus speed timing for the host · aa33ce3c
      Ulf Hansson 提交于
      In cases when a speed mode change is requested for mmc cards, a CMD6 is
      sent by calling __mmc_switch() during the card initialization. The CMD6
      leads to the card entering a busy period. When that is completed, the host
      must parse the CMD6 status to find out whether the change of the speed mode
      succeeded.
      
      To enable the mmc core to poll the card by using CMD13 to find out when the
      busy period is completed, it's reasonable to make sure polling is done by
      having the mmc host and the mmc card, being configured to operate at the
      same selected bus speed timing.
      
      Therefore, let's extend __mmc_switch() to take yet another parameter, which
      allow its callers to update the bus speed timing of the mmc host. In this
      way, __mmc_switch() also becomes capable of reading and validating the CMD6
      status by sending a CMD13, in cases when that's desired.
      
      If __mmc_switch() encounters a failure, we make sure to restores the old
      bus speed timing for the mmc host, before propagating the error code.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Tested-by: NLinus Walleij <linus.walleij@linaro.org>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      aa33ce3c
    • U
      mmc: core: Make mmc_switch_status() available for mmc core · 20348d19
      Ulf Hansson 提交于
      Following changes needs mmc_switch_status() to be available both from mmc.c
      and mmc_ops.c. Allow that by moving its implementation to mmc_ops.c and
      make it available via mmc_ops.h.
      
      Moving mmc_switch_status() to mmc_ops.c, also enables us to turn
      mmc_switch_status_error() into static function. So let's take the
      opportunity to change this as well.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Acked-by: NJaehoon Chung <jh80.chung@samsung.com>
      Tested-by: NJaehoon Chung <jh80.chung@samsung.com>
      20348d19
  2. 07 11月, 2016 1 次提交
    • U
      mmc: mmc: Use 500ms as the default generic CMD6 timeout · fe1b5700
      Ulf Hansson 提交于
      In the eMMC 4.51 version of the spec, an EXT_CSD field called
      GENERIC_CMD6_TIME[248] was added. This allows cards to specify the maximum
      time it may need to move out from its busy state, when a CMD6 command has
      been sent.
      
      In cases when the card is compliant to versions < 4.51 of the eMMC spec,
      obviously the core needs to use a fall-back value for this timeout, which
      currently is set to 10 minutes. This value is completely in the wrong range
      and importantly in some cases it causes a card initialization to take more
      than 10 minute to complete.
      
      Earlier this scenario was avoided as the mmc core used CMD13 to poll the
      card, to find out when it stopped signaling busy. Commit 08573eaf
      ("mmc: mmc: do not use CMD13 to get status after speed mode switch")
      changed this behavior.
      
      Instead of reverting that commit, which would cause other issues, let's
      instead start by picking a simple solution for the problem, by using a
      500ms default generic CMD6 timeout.
      
      The reason for using exactly 500ms, comes from observations that shows it's
      quite common for cards to specify 250ms. 500ms is two times that value so
      likely it should be enough for most cards.
      
      Cc: <stable@vger.kernel.org> # v4.8+
      Fixes: 08573eaf ("mmc: mmc: do not use CMD13 to get status after speed
      mode switch")
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Tested-by: NStephen Boyd <sboyd@codeaurora.org>
      Tested-by: NLinus Walleij <linus.walleij@linaro.org>
      fe1b5700
  3. 10 10月, 2016 2 次提交
  4. 27 9月, 2016 1 次提交
  5. 25 7月, 2016 7 次提交
  6. 02 6月, 2016 1 次提交
  7. 28 5月, 2016 1 次提交
    • A
      remove lots of IS_ERR_VALUE abuses · 287980e4
      Arnd Bergmann 提交于
      Most users of IS_ERR_VALUE() in the kernel are wrong, as they
      pass an 'int' into a function that takes an 'unsigned long'
      argument. This happens to work because the type is sign-extended
      on 64-bit architectures before it gets converted into an
      unsigned type.
      
      However, anything that passes an 'unsigned short' or 'unsigned int'
      argument into IS_ERR_VALUE() is guaranteed to be broken, as are
      8-bit integers and types that are wider than 'unsigned long'.
      
      Andrzej Hajda has already fixed a lot of the worst abusers that
      were causing actual bugs, but it would be nice to prevent any
      users that are not passing 'unsigned long' arguments.
      
      This patch changes all users of IS_ERR_VALUE() that I could find
      on 32-bit ARM randconfig builds and x86 allmodconfig. For the
      moment, this doesn't change the definition of IS_ERR_VALUE()
      because there are probably still architecture specific users
      elsewhere.
      
      Almost all the warnings I got are for files that are better off
      using 'if (err)' or 'if (err < 0)'.
      The only legitimate user I could find that we get a warning for
      is the (32-bit only) freescale fman driver, so I did not remove
      the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
      For 9pfs, I just worked around one user whose calling conventions
      are so obscure that I did not dare change the behavior.
      
      I was using this definition for testing:
      
       #define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
             unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))
      
      which ends up making all 16-bit or wider types work correctly with
      the most plausible interpretation of what IS_ERR_VALUE() was supposed
      to return according to its users, but also causes a compile-time
      warning for any users that do not pass an 'unsigned long' argument.
      
      I suggested this approach earlier this year, but back then we ended
      up deciding to just fix the users that are obviously broken. After
      the initial warning that caused me to get involved in the discussion
      (fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
      asked me to send the whole thing again.
      
      [ Updated the 9p parts as per Al Viro  - Linus ]
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Link: https://lkml.org/lkml/2016/1/7/363
      Link: https://lkml.org/lkml/2016/5/27/486
      Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> # For nvmem part
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      287980e4
  8. 16 5月, 2016 1 次提交
    • A
      mmc: mmc: Fix partition switch timeout for some eMMCs · 1c447116
      Adrian Hunter 提交于
      Some eMMCs set the partition switch timeout too low.
      
      Now typically eMMCs are considered a critical component (e.g. because
      they store the root file system) and consequently are expected to be
      reliable.  Thus we can neglect the use case where eMMCs can't switch
      reliably and we might want a lower timeout to facilitate speedy
      recovery.
      
      Although we could employ a quirk for the cards that are affected (if
      we could identify them all), as described above, there is little
      benefit to having a low timeout, so instead simply set a minimum
      timeout.
      
      The minimum is set to 300ms somewhat arbitrarily - the examples that
      have been seen had a timeout of 10ms but were sometimes taking 60-70ms.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      1c447116
  9. 10 5月, 2016 2 次提交
  10. 04 5月, 2016 1 次提交
  11. 02 5月, 2016 2 次提交
  12. 29 2月, 2016 2 次提交
  13. 28 12月, 2015 1 次提交
  14. 22 12月, 2015 2 次提交
  15. 09 11月, 2015 4 次提交
    • A
      mmc: mmc: Improve reliability of mmc_select_hs400() · d2302933
      Adrian Hunter 提交于
      mmc_select_hs400() calls __mmc_switch() which checks the switch is
      successful using CMD13 (SEND_STATUS).  The problem is that it does that
      using the timing settings of the previous mode.  That is prone to error,
      especially when switching from HS to HS400 because the timing parameters
      for HS mode are tighter than the timing parameters for HS400 mode.
      
      In the case when CMD13 polling is used (i.e. not MMC_CAP_WAIT_WHILE_BUSY)
      with the switch command, it must be assumed that using different modes on
      the card and host must work.
      
      However in the case when CMD13 polling is not used
      (i.e. MMC_CAP_WAIT_WHILE_BUSY) mmc_select_hs400() can be made more
      reliable by setting the host to the correct timing before sending CMD13.
      
      This patch does that.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: <stable@vger.kernel.org> # 4.2+
      Tested-by: NAlim Akhtar <alim.akhtar@samsung.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      d2302933
    • A
      mmc: mmc: Move mmc_switch_status() · 974007aa
      Adrian Hunter 提交于
      Move the mmc_switch_status() function in preparation for calling it
      in mmc_select_hs400().
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: <stable@vger.kernel.org> # 4.2+
      Tested-by: NAlim Akhtar <alim.akhtar@samsung.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      974007aa
    • A
      mmc: mmc: Fix HS setting in mmc_select_hs400() · 51b12f77
      Adrian Hunter 提交于
      mmc_select_hs400() begins with the card and host in HS200 mode.
      Therefore, any commands sent to the card should use HS200 timing.
      It is incorrect to set the host to High Speed (HS) timing before
      sending the switch command.  Doing so is unreliable because
      the timing parameters for HS mode are tighter than the timing
      parameters for HS200 mode.  Thus the HS timings should be set
      only after the card has switched mode.
      
      However, it is not unreasonable first to reduce the frequency to
      the HS mode frequency, which should make the switch command and
      subsequent CMD13 commands more reliable.
      
      This patch does that.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: <stable@vger.kernel.org> # 4.2+
      Tested-by: NAlim Akhtar <alim.akhtar@samsung.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      51b12f77
    • A
      mmc: mmc: Improve reliability of mmc_select_hs200() · 1815e61b
      Adrian Hunter 提交于
      Currently mmc_select_hs200() uses __mmc_switch() which checks the
      success of the switch to HS200 mode using CMD13 (SEND_STATUS).
      The problem is that it does that using the timing settings of legacy
      mode.  That is prone to error, not least because the timing parameters
      for legacy mode are tighter than the timing parameters for HS200 mode.
      
      In the case when CMD13 polling is used (i.e. not MMC_CAP_WAIT_WHILE_BUSY)
      with the switch command, it must be assumed that using different modes on
      the card and host must work.
      
      However in the case when CMD13 polling is not used
      (i.e. MMC_CAP_WAIT_WHILE_BUSY) mmc_select_hs200() can be made more
      reliable by setting the host to the correct timing before sending CMD13.
      
      This patch does that.
      
      A complication is that the caller, mmc_select_timing(), will ignore a
      switch error (indicated by -EBADMSG), assume the old mode is valid
      and continue, so the old timing must be restored in that case.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: <stable@vger.kernel.org> # 4.2+
      Tested-by: NAlim Akhtar <alim.akhtar@samsung.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      1815e61b
  16. 26 10月, 2015 2 次提交
  17. 21 10月, 2015 1 次提交
  18. 04 6月, 2015 1 次提交
  19. 01 6月, 2015 4 次提交