1. 29 11月, 2016 5 次提交
  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 9 次提交
    • Z
      mmc: core: don't try to switch block size for dual rate mode · 1712c937
      Ziyuan Xu 提交于
      Per spec, block size should always be 512 bytes for dual rate mode,
      so any attempts to switch the block size under dual rate mode should
      be neglected.
      Signed-off-by: NZiyuan Xu <xzy.xu@rock-chips.com>
      Signed-off-by: NShawn Lin <shawn.lin@rock-chips.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      1712c937
    • A
      mmc: core: Add support for sending commands during data transfer · 5163af5a
      Adrian Hunter 提交于
      A host controller driver exposes its capability using caps flag
      MMC_CAP_CMD_DURING_TFR. A driver with that capability can accept requests
      that are marked mrq->cap_cmd_during_tfr = true. Then the driver informs the
      upper layers when the command line is available for further commands by
      calling mmc_command_done(). Because of that, the driver will not then
      automatically send STOP commands, and it is the responsibility of the upper
      layer to send a STOP command if it is required.
      
      For requests submitted through the mmc_wait_for_req() interface, the caller
      sets mrq->cap_cmd_during_tfr = true which causes mmc_wait_for_req() in fact
      not to wait. The caller can then send commands that do not use the data
      lines. Finally the caller can wait for the transfer to complete by calling
      mmc_wait_for_req_done() which is now exported.
      
      For requests submitted through the mmc_start_req() interface, the caller
      again sets mrq->cap_cmd_during_tfr = true, but mmc_start_req() anyway does
      not wait. The caller can then send commands that do not use the data
      lines. Finally the caller can wait for the transfer to complete in the
      normal way i.e. calling mmc_start_req() again.
      
      Irrespective of how a cap_cmd_during_tfr request is started,
      mmc_is_req_done() can be called if the upper layer needs to determine if
      the request is done. However the appropriate waiting function (either
      mmc_wait_for_req_done() or mmc_start_req()) must still be called.
      
      The implementation consists primarily of a new completion
      mrq->cmd_completion which notifies when the command line is available for
      further commands. That completion is completed by mmc_command_done().
      When there is an ongoing data transfer, calls to mmc_wait_for_req() will
      automatically wait on that completion, so the caller does not have to do
      anything special.
      
      Note, in the case of errors, the driver may call mmc_request_done() without
      calling mmc_command_done() because mmc_request_done() always calls
      mmc_command_done().
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      5163af5a
    • B
      mmc: core: Optimize the mmc erase size alignment · 6c689886
      Baolin Wang 提交于
      In most cases the 'card->erase_size' is power of 2, then the round_up/down()
      function is more efficient than '%' operation when the 'card->erase_size' is
      power of 2.
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      Tested-by: NShawn Lin <shawn.lin@rock-chips.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      6c689886
    • B
      mmc: core: Factor out the alignment of erase size · 71085123
      Baolin Wang 提交于
      In order to clean up the mmc_erase() function and do some optimization
      for erase size alignment, factor out the guts of erase size alignment
      into mmc_align_erase_size() function.
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      Tested-by: NShawn Lin <shawn.lin@rock-chips.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      71085123
    • U
      mmc: core: Use a default maximum erase timeout · 12182aff
      Ulf Hansson 提交于
      In cases when the host->max_busy_timeout isn't specified, the calculated
      number of maximum discard sectors defaults to UINT_MAX. This may cause a
      too long timeout for a discard request.
      
      Avoid this by using a default maximum erase timeout of 60s, used when we
      calculate the maximum number of sectors that are allowed to be discarded
      per request.
      
      Do note that the minimum number of sectors to be discarded is still at
      least one "preferred erase size".
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NShawn Lin <shawn.lin@rock-chips.com>
      12182aff
    • S
      mmc: sdio: deploy error handling instead of triggering BUG_ON · 923dff87
      Shawn Lin 提交于
      When using mmc_io_rw_extended, it's intent to avoid null
      pointer of card and invalid func number. But actually it
      didn't prevent that as the seg_size already use the card.
      Currently the wrapper function sdio_io_rw_ext_helper already
      use card before calling mmc_io_rw_extended, so we should move
      this check to there. As to the func number, it was token from
      '(ocr & 0x70000000) >> 28' which should be enough to guarantee
      that it won't be larger than 7. But we should prevent the
      caller like wifi drivers modify this value. So let's move this
      check into sdio_io_rw_ext_helper either.
      
      Also we remove the BUG_ON for mmc_send_io_op_cond since all
      possible paths calling this function are protected by checking
      the arguments in advance. After deploying these changes, we
      could not see any panic within SDIO API even if func drivers
      abuse the SDIO func APIs.
      Signed-off-by: NShawn Lin <shawn.lin@rock-chips.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      923dff87
    • J
      mmc: core: Add error message when switching fails in mmc_select_hs() · 67d35960
      Jungseung Lee 提交于
      The switch failure message in mmc_select_timing() had been removed
      since that is invalid: commit 0400ed0a ("mmc: core: remove the
      invalid message in mmc_select_timing")
      
      Now, in the case when mmc_select_hs() return error in mmc_select_timing(),
      there is nothing to print failure message.
      Let's make for mmc_select_hs() print message itself in the failure case.
      Signed-off-by: NJungseung Lee <js07.lee@samsung.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      67d35960
    • U
      mmc: sd: Export SD Status via “ssr” device attribute · 5275a652
      Uri Yanai 提交于
      The SD Status register contains several important fields related to the
      SD Card proprietary features.
      Those fields may be used by user space applications for vendor specific
      usage.
      None of those fields are exported today by the driver to user space.
      In this patch, we are reading the SD Status register and exporting
      (using MMC_DEV_ATTR) the SD Status register to the user space.
      Signed-off-by: NUri Yanai <uri.yanai@sandisk.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      5275a652
    • H
      mmc: pwrseq-simple: Add an optional post-power-on-delay · 721e0497
      Hans de Goede 提交于
      Some devices need a while to boot their firmware after providing clks /
      de-asserting resets before they are ready to receive sdio commands.
      
      This commits adds a post-power-on-delay-ms devicetree property to
      mmc-pwrseq-simple for use with such devices.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Acked-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      721e0497
  5. 25 7月, 2016 16 次提交
  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. 23 5月, 2016 1 次提交
  9. 17 5月, 2016 1 次提交
    • A
      mmc: core: Add a facility to "pause" re-tuning · 7ff27609
      Adrian Hunter 提交于
      Re-tuning is not possible when switched to the RPMB
      partition.  However re-tuning should not be needed
      if re-tuning is done immediately before switching,
      a small set of operations is done, and then we
      immediately switch back to the main partition.
      
      To ensure that re-tuning can't be done for a short
      while, add a facility to "pause" re-tuning.
      
      The existing facility to hold / release re-tuning
      is used but it also flags re-tuning as needed to cause
      re-tuning before the next command (which will be the
      switch to RPMB).
      
      We also need to "unpause" in the recovery path, which
      is catered for by adding it to mmc_retune_disable().
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      7ff27609
  10. 16 5月, 2016 2 次提交
    • 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
    • W
      mmc: sdio: fall back to SDIO 1.0 for broken 1.1 cards · 88ea46bc
      Wolfram Sang 提交于
      I have two SDIO WLAN cards which specify being SDIO Rev. 1.1 cards but
      their FUNCE tuple reports the smaller size of a Rev 1.0 card. So,
      enforce 1.0 on these cards to avoid reading the not present registers.
      They are not really used anyhow. My cards initialize properly after this
      patch.
      Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      88ea46bc
  11. 10 5月, 2016 1 次提交
    • D
      mmc: core: remove the invalid message in mmc_select_timing · 0400ed0a
      Dong Aisheng 提交于
      mmc_select_hs200() and mmc_select_hs() will keep the timing
      as before if switch fails. So it's meaningless to print the
      failed switched mode outside based on the current host timing.
      
      Furthermore, the original print is wrong, it should be:
      pr_warn("%s: switch to %s failed\n",
      	mmc_hostname(card->host),
      	mmc_card_hs(card) ? "high-speed" :
      	(mmc_card_hs200(card) ? "hs200" : ""));
      
      Since we already have error message in mmc_select_hs200(),
      simply remove it outside.
      Signed-off-by: NDong Aisheng <aisheng.dong@nxp.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      0400ed0a