1. 13 2月, 2017 7 次提交
  2. 20 12月, 2016 1 次提交
    • A
      mmc: core: Further fix thread wake-up · 15520111
      Adrian Hunter 提交于
      Commit e0097cf5 ("mmc: queue: Fix queue thread wake-up") did not go far
      enough. mmc_wait_for_data_req_done() still contains some problems and can
      be further simplified.  First it should not touch
      context_info->is_waiting_last_req because that is a wake-up control used by
      the owner of the context. Secondly, it should always return when one of its
      wake-up conditions is met because, again, that is contolled by the owner of
      the context.
      
      While the current block driver does not have an issue, these problems were
      exposed during testing of the Software Command Queue patches.
      
      Fixes: e0097cf5 ("mmc: queue: Fix queue thread wake-up")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NHarjani Ritesh <riteshh@codeaurora.org>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      15520111
  3. 05 12月, 2016 2 次提交
  4. 29 11月, 2016 4 次提交
    • L
      mmc: delete is_first_req parameter from pre-request callback · d3c6aac3
      Linus Walleij 提交于
      The void (*pre_req) callback in the struct mmc_host_ops vtable
      is passing an argument "is_first_req" indicating whether this is
      the first request or not.
      
      None of the in-kernel users use this parameter: instead, since
      they all just do variants of dma_map* they use the DMA cookie
      to indicate whether a pre* callback has already been done for
      a request when they decide how to handle it.
      
      Delete the parameter from the callback and all users, as it is
      just pointless cruft.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Acked-by: NJaehoon Chung <jh80.chung@samsung.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      d3c6aac3
    • 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
    • L
      mmc: core: use enum mmc_blk_status properly · 8e8b3f51
      Linus Walleij 提交于
      There were several instances of code using the
      enum mmc_blk_status by arbitrarily converting it to an int and
      throwing it around to different functions. This makes the code
      hard to understand to may give rise to strange errors.
      
      Especially the function prototype mmc_start_req() had to be
      modified to take a pointer to an enum mmc_blk_status and the
      function pointer .err_check() inside struct mmc_async_req
      needed to return an enum mmc_blk_status.
      
      In every case: instead of assigning the block layer error code
      to an int, use the enum, also change the signature of all
      functions actually passing this enum to use the enum.
      
      To make it possible to use the enum everywhere applicable, move
      it to <linux/mmc/core.h> so that all code actually using it can
      also see it.
      
      An interesting case was encountered in the MMC test code which
      did not return a enum mmc_blk_status at all in the .err_check
      function supposed to check whether asynchronous requests worked
      or not: instead it returned a normal -ERROR or even the test
      frameworks internal error codes.
      
      The test code would also pass on enum mmc_blk_status codes as
      error codes inside the test code instead of converting them
      to the local RESULT_* codes.
      
      I have tried to fix all instances properly and run some tests
      on the result.
      
      Cc: Chunyan Zhang <zhang.chunyan@linaro.org>
      Cc: Baolin Wang <baolin.wang@linaro.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      8e8b3f51
    • U
      mmc: core: Don't power off the card when starting the host · c2c24819
      Ulf Hansson 提交于
      The MMC_CAP2_NO_PRESCAN_POWERUP was invented to avoid running the power up
      sequence, mmc_power_up(), during ->probe() of the mmc host driver, but
      instead defer this to the mmc detect work. This is especially useful for
      those hosts that suffers from a long initialization time, as this time
      would otherwise add up to the total boot time.
      
      However, due to the introduction of runtime PM of mmc host devices in the
      mmc core, this behaviour changed a bit. More precisely, it caused the mmc
      core to runtime resume the host device during ->probe() of the host driver.
      In cases like the rtsx_usb_sdmmc, runtime resuming the device may be costly
      and thus affecting the total boot time.
      
      To improve this behaviour when using MMC_CAP2_NO_PRESCAN_POWERUP, let's
      postpone also calling mmc_power_off() when starting the host. This change
      allows the mmc core to avoid runtime resuming the device, as it don't need
      to claim the host for that execution path.
      
      Cc: Ritesh Raj Sarraf <rrs@researchut.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      c2c24819
  5. 27 9月, 2016 5 次提交
    • 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
  6. 25 7月, 2016 5 次提交
  7. 23 5月, 2016 1 次提交
  8. 02 5月, 2016 2 次提交
  9. 29 2月, 2016 5 次提交
  10. 28 12月, 2015 1 次提交
    • U
      mmc: core: Optimize boot time by detecting cards simultaneously · 520bd7a8
      Ulf Hansson 提交于
      The mmc workqueue is an ordered workqueue, allowing only one work to
      execute per given time. As this workqueue is used for card detection, the
      conseqeunce is that cards will be detected one by one waiting for each
      other.
      
      Moreover, most of the time spent during card initialization is waiting for
      the card's internal firmware to be ready. From a CPU perspective this
      typically means waiting for a completion variable to be kicked via an
      IRQ-handler or waiting for a sleep timer to finish.
      
      This behaviour of detecting/initializing cards is sub-optimal, especially
      for SOCs having several controllers/cards.
      
      Let's convert to use the system_freezable_wq for the mmc detect works.
      This enables several works to be executed simultaneously and thus also
      cards to be detected like so.
      
      Tests on UX500, which holds two eMMC cards and an SD-card (actually also
      an SDIO card, currently not detected), shows a significant improved
      behaviour due to this change.
      
      Before this change, both the eMMC cards waited for the SD card to be
      initialized as its detect work entered the workqueue first. In some cases,
      depending on the characteristic of the SD-card, they got delayed 1-1.5 s.
      
      Additionally for the second eMMC, it needed to wait for the first eMMC to
      be initialized which added another 120-190 ms.
      
      Converting to the system_freezable_wq, removed these delays and made both
      the eMMC cards available far earlier in the boot sequence.
      
      Selecting the system_freezable_wq, in favour of for example the system_wq,
      is because we need card detection mechanism to be disabled once userspace
      are frozen during system PM. Currently the mmc core deal with this via PM
      notifiers, but following patches may utilize the behaviour of the
      system_freezable_wq, to simplify the use of the PM notifiers.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Tested-by: NAlan Cooper <alcooperx@gmail.com>
      Tested-by: NShawn Lin <shawn.lin@rock-chips.com>
      520bd7a8
  11. 22 12月, 2015 6 次提交
  12. 26 10月, 2015 1 次提交
    • D
      mmc: core: Add mmc_regulator_set_vqmmc() · 2086f801
      Douglas Anderson 提交于
      This adds logic to the MMC core to set VQMMC.  This is expected to be
      called by MMC drivers like dw_mmc as part of (or instead of) their
      start_signal_voltage_switch() callback.
      
      A few notes:
      
      * When setting the signal voltage to 3.3V we do our best to make VQMMC
        and VMMC match.  It's been reported that this makes some old cards
        happy since they were tested back in the day before UHS when VQMMC
        and VMMC were provided by the same regulator.  A nice side effect of
        this is that we don't end up on the hairy edge of VQMMC (2.7V),
        which some EEs claim is a little too close to the minimum for
        comfort.
        This is done in two steps. At first we try to find a VQMMC within
        a 0.3V tolerance of VMMC and if this is not supported by the
        supplying regulator we try to find a suitable voltage within the
        whole 2.7V-3.6V area of the spec.
      
      * The two step approach is currently necessary, as the used
        regulator_set_voltage_triplet(min, target, max) uses a simple
        implementation that just tries two basic steps:
      	regulator_set_voltage(target, max);
      	regulator_set_voltage(min, target);
        So with only one step with 2.7-3.6V borders, if a suitable voltage
        is a bit below VMMC, we would directly get the lowest 2.7V
        which some boards (like Rockchips) don't like at all.
      
      * When setting the signal voltage to 1.8V or 1.2V we aim for that
        specific voltage instead of picking the lowest one in the range.
      
      * We very purposely don't print errors in mmc_regulator_set_vqmmc().
        There are cases where the MMC core will try several different
        voltages and we don't want to pollute the logs.
      Signed-off-by: NDouglas Anderson <dianders@chromium.org>
      Signed-off-by: NHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      2086f801