1. 05 12月, 2016 1 次提交
  2. 29 11月, 2016 4 次提交
    • L
      mmc: block: delete packed command support · 03d640ae
      Linus Walleij 提交于
      I've had it with this code now.
      
      The packed command support is a complex hurdle in the MMC/SD block
      layer, around 500+ lines of code which was introduced in 2013 in
      
      commit ce39f9d1 ("mmc: support packed write command for eMMC4.5
      devices")
      commit abd9ac14 ("mmc: add packed command feature of eMMC4.5")
      
      ...and since then it has been rotting. The original author of the
      code has disappeared from the community and the mail address is
      bouncing.
      
      For the code to be exercised the host must flag that it supports
      packed commands, so in mmc_blk_prep_packed_list() which is called for
      every single request, the following construction appears:
      
      u8 max_packed_rw = 0;
      
      if ((rq_data_dir(cur) == WRITE) &&
          mmc_host_packed_wr(card->host))
              max_packed_rw = card->ext_csd.max_packed_writes;
      
      if (max_packed_rw == 0)
          goto no_packed;
      
      This has the following logical deductions:
      
      - Only WRITE commands can really be packed, so the solution is
        only half-done: we support packed WRITE but not packed READ.
        The packed command support has not been finalized by supporting
        reads in three years!
      
      - mmc_host_packed_wr() is just a static inline that checks
        host->caps2 & MMC_CAP2_PACKED_WR. The problem with this is
        that NO upstream host sets this capability flag! No driver
        in the kernel is using it, and we can't test it. Packed
        command may be supported in out-of-tree code, but I doubt
        it. I doubt that the code is even working anymore due to
        other refactorings in the MMC block layer, who would
        notice if patches affecting it broke packed commands?
        No one.
      
      - There is no Device Tree binding or code to mark a host as
        supporting packed read or write commands, just this flag
        in caps2, so for sure there are not any DT systems using
        it either.
      
      It has other problems as well: mmc_blk_prep_packed_list() is
      speculatively picking requests out of the request queue with
      blk_fetch_request() making the MMC/SD stack harder to convert
      to the multiqueue block layer. By this we get rid of an
      obstacle.
      
      The way I see it this is just cruft littering the MMC/SD
      stack.
      
      Cc: Namjae Jeon <namjae.jeon@samsung.com>
      Cc: Maya Erez <qca_merez@qca.qualcomm.com>
      Acked-by: NJaehoon Chung <jh80.chung@samsung.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      03d640ae
    • 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
    • S
      mmc: core: Add helper to see if a host can be retuned · c820af5f
      Simon Horman 提交于
      This is in preparation for restoring saved tuning parameters
      when resuming the TMIO driver.
      Signed-off-by: NSimon Horman <horms+renesas@verge.net.au>
      Acked-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Tested-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      c820af5f
    • 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
  3. 27 9月, 2016 1 次提交
    • 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
  4. 25 7月, 2016 4 次提交
  5. 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
  6. 02 5月, 2016 1 次提交
  7. 22 12月, 2015 3 次提交
  8. 26 10月, 2015 2 次提交
    • 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
    • U
      mmc: core: Remove MMC_CLKGATE · 9eadcc05
      Ulf Hansson 提交于
      MMC_CLKGATE was once invented to save power by gating the bus clock at
      request inactivity. At that time it served its purpose. The modern way to
      deal with power saving for these scenarios, is by using runtime PM.
      
      Nowadays, several host drivers have deployed runtime PM, but for those
      that haven't and which still cares power saving at request inactivity,
      it's certainly time to deploy runtime PM as it has been around for several
      years now.
      
      To simplify code to mmc core and thus decrease maintenance efforts, this
      patch removes all code related to MMC_CLKGATE.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      9eadcc05
  9. 17 8月, 2015 1 次提交
  10. 01 6月, 2015 4 次提交
    • A
      mmc: core: Add 'card' to drive strength selection callback · f168359e
      Adrian Hunter 提交于
      In preparation for supporting also eMMC drive strength,
      add the 'card' as a parameter so that the callback can
      distinguish different types of cards if necessary.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      f168359e
    • A
      mmc: core: Allow card drive strength to be different to host · b4f30a17
      Adrian Hunter 提交于
      Initialization of UHS-I modes for SD and SDIO cards
      employs a callback to allow the host driver to
      choose a drive strength value. Currently that
      assumes the card drive strength and host driver
      type must be the same value. Change to let the
      callback make that decision and return both the
      card drive strength and host driver type.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      b4f30a17
    • L
      mmc: Add support for disabling write-protect detection · 9f6e0bff
      Lars-Peter Clausen 提交于
      It is not uncommon to see systems where there is no physical write-protect
      signal (e.g. when using eMMC or microSD card slots). For some controllers,
      which have a dedicated write-protection detection logic (like SDHCI
      controllers), the get_ro() callback can return bogus data in such a case.
      
      Instead of handling this on a per controller basis this patch adds a new
      capability flag to the MMC core that can be set to specify that the result
      of get_ro() is invalid. When the flag is set the core will not call
      get_ro() and assume that the card is always read-write.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      9f6e0bff
    • A
      mmc: host: Add facility to support re-tuning · dfa13ebb
      Adrian Hunter 提交于
      Currently, there is core support for tuning during
      initialization. There can also be a need to re-tune
      periodically (e.g. sdhci) or to re-tune after the
      host controller is powered off (e.g. after PM
      runtime suspend / resume) or to re-tune in response
      to CRC errors.
      
      The main requirements for re-tuning are:
        - ability to enable / disable re-tuning
        - ability to flag that re-tuning is needed
        - ability to re-tune before any request
        - ability to hold off re-tuning if the card is busy
        - ability to hold off re-tuning if re-tuning is in
        progress
        - ability to run a re-tuning timer
      
      To support those requirements 7 members are added to struct
      mmc_host:
      
        unsigned int		can_retune:1;	/* re-tuning can be used */
        unsigned int		doing_retune:1;	/* re-tuning in progress */
        unsigned int		retune_now:1;   /* do re-tuning at next req */
        int			need_retune;	/* re-tuning is needed */
        int			hold_retune;	/* hold off re-tuning */
        unsigned int		retune_period;  /* re-tuning period in secs */
        struct timer_list	retune_timer;	/* for periodic re-tuning */
      
      need_retune is an integer so it can be set without needing
      synchronization. hold_retune is a integer to allow nesting.
      
      Various simple functions are provided to set / clear those
      variables.
      
      Subsequent patches take those functions into use.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      dfa13ebb
  11. 27 3月, 2015 1 次提交
  12. 28 1月, 2015 1 次提交
    • U
      mmc: core: Initial support for MMC power sequences · 3aa8793f
      Ulf Hansson 提交于
      System on chip designs may specify a specific MMC power sequence. To
      successfully detect an (e)MMC/SD/SDIO card, that power sequence must
      be followed while initializing the card.
      
      To be able to handle these SOC specific power sequences, let's add a
      MMC power sequence interface. It provides the following functions to
      help the mmc core to deal with these power sequences.
      
      mmc_pwrseq_alloc() - Invoked from mmc_of_parse(), to initialize data.
      mmc_pwrseq_pre_power_on()- Invoked in the beginning of mmc_power_up().
      mmc_pwrseq_post_power_on()- Invoked at the end in mmc_power_up().
      mmc_pwrseq_power_off()- Invoked from mmc_power_off().
      mmc_pwrseq_free() - Invoked from mmc_free_host(), to free data.
      
      Each MMC power sequence provider will be responsible to implement a set
      of callbacks. These callbacks mirrors the functions above.
      
      This patch adds the skeleton, following patches will extend the core of
      the MMC power sequence and add support for a specific simple MMC power
      sequence.
      
      Do note, since the mmc_pwrseq_alloc() is invoked from mmc_of_parse(),
      host drivers needs to make use of this API to enable the support for
      MMC power sequences. Moreover the MMC power sequence support depends on
      CONFIG_OF.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Tested-by: NJavier Martinez Canillas <javier.martinez@collabora.co.uk>
      Reviewed-by: NJavier Martinez Canillas <javier.martinez@collabora.co.uk>
      3aa8793f
  13. 19 1月, 2015 1 次提交
  14. 26 11月, 2014 1 次提交
  15. 24 9月, 2014 1 次提交
  16. 09 9月, 2014 3 次提交
  17. 22 5月, 2014 1 次提交
  18. 13 5月, 2014 4 次提交
  19. 22 4月, 2014 1 次提交
  20. 21 4月, 2014 1 次提交
  21. 23 2月, 2014 1 次提交
    • U
      mmc: core: Rename max_discard_to to max_busy_timeout · 68eb80e0
      Ulf Hansson 提交于
      Rename host->max_discard_to to host->max_busy_timeout, to reflect that
      it tells the mmc core layer about the maximum supported busy detection
      timeout by the host.
      
      This timeout is at the moment only applicable to erase/trim/discard
      commands. By the renaming we provide the option of make use of it for
      other commands that cares about busy detection. In other words, those
      commands that wants an R1B response, like for example the mmc switch
      command.
      
      Do note that the max_busy_timeout is supposed to be specified only by
      hosts supporting MMC_CAP_WAIT_WHILE_BUSY.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NChris Ball <chris@printf.net>
      68eb80e0
  22. 14 2月, 2014 2 次提交