Commit Graph

297 Commits

Author SHA1 Message Date
Luca Stefani ff1ebfd98d This is the 3.10.102 stable release
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJXXS5iAAoJEE44bZycYXAvDj8P/jbhmGAgW6tw2cnS90QIZDqG
 M/nclEId61jICNvbfP6zsioKeWyrmzr5G7NjqTThsSNhCo/DXs3ddMqLy3pOaFdq
 mytXtHIUpwZoplEib+ODinW40CMqnu11XSWEcee2nrsPuGNsnc7BY0wmFBa6UVCV
 rOZef9SN9lJcZSYY/auvgLDXOXdQ+NMxp5hau30aF5HBO8hTDXStjPRcUwCvz7aR
 govTQJHlS4HzLH3JOYS3Dt8IYFDOrKhQIby2nFdw7eiUxHCRy2F0asabTh3DzCw1
 iLvFroozjyVXwozfWMqLCvMa+514MXJy8Nkva6xiAHraC8UrgfPtcNsTdgtkdH9T
 V2Am9b0L7yiBdG6hsZLxkU3akk7vU/0dtppwzvudANT6i2tGcDSBeaZq3T2pAv7B
 7coY53GzHZdQnbdTZbYeS1fxebxyXw50D5OJkF8DyLhoL7Uj2Dvv0QdjKv+U/e5D
 VQ+ZyGcBdCLuOzflXysI10E01y0/M3FrkubgGBM4Oh0eYKCHJaHG/NCZy5JY/qxy
 S0phem8RbeZPbcL14z+5buWIi1lUkTiCIMG8c32ZEmDh84drnICqABA0RzKmqdkj
 ucQa+PzkMQ1DyhAMUl/CwpBfSqf1Zs3agLo78Kp5MTGfeAA90m0SeVqhmDgWhwqG
 HhSlsPFfMfmJl5S0uJpQ
 =UhFl
 -----END PGP SIGNATURE-----

Merge tag 'v3.10.102' into HEAD

This is the 3.10.102 stable release

Change-Id: Ic7d338fb190966b26aa151361fc37414f701d8b2
2017-04-18 17:22:08 +02:00
LuK1337 fc9499e55a Import latest Samsung release
* Package version: T713XXU2BQCO

Change-Id: I293d9e7f2df458c512d59b7a06f8ca6add610c99
2017-04-18 03:43:52 +02:00
Veerabhadrarao Badiganti dbceeaf8ea mmc: block: Fix issue with deferred resume when CQ is enabled
In CQ mode, the legacy commands will be sent after CQ is put in
halt state. But when deferred resume is enabled, the resume
happens in mmc_wait_for_req(), which will enable CQ again
overiding the caller's state. This causes legacy commands to fail.

Fix this by moving the deferred resume from all the places to
mmc_rpm_hold() which is always the first step done in both
CQ/legacy commands and thus avoids the above issue scneario.

Fix: fbb7cbf8ea (mmc: core: Add deferred resume for command queue mode)
Change-Id: I97fb9d654968b294dc1fb6986b8b9431e22233c0
Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
2016-12-07 21:53:08 -08:00
Ritesh Harjani e4e5ea9e1e mmc: core: Remove flag MMC_PM_WAKE_SDIO_IRQ in mmc_resume_host
MMC_PM_WAKE_SDIO_IRQ flag is used by platform driver(sdhci-msm
here) to determine if SDIO wakeup IRQ needs to be enabled
or not. If this flag is not removed in every mmc_resume_host,
then while suspend, platform driver will configure the sdio
wakeup IRQ even though wlan is disabled from UI.
This flag can be enabled by wlan driver before entring into suspend.

In this case since Wlan is not enable and thus not entering WoW mode,
pull up present on this SDIO GPIO line will pull the line high (which
otherwise is pulled low by wlan firmware in WoW mode and triggers
interrupt by pulling it high in WoW mode) which eventually will
trigger a false SDIO wakeup interrupt thus breaking the suspend
everytime.

Hence disable the flag everytime in mmc_resume_host and let
wlan driver enables it (-by sdio_set_host_pm_flags)
before entering into suspend if needed
for sdio wakeup part.

Change-Id: Iecf9eef4d91a741116bc8b8bb59c49ae7f2891fd
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2016-07-29 21:12:20 -07:00
Ritesh Harjani 226b74c3d2 mmc: sdio: Add MMC_CAP2_BROKEN_PWR_CYCLE & fix mmc_sdio_init_card
Power supply to card QCA9377 & QCA6574 is used for wlan and
bluetooth as well.

Now if SDIO card is switched to 1.8V signaling voltage, it will not
switch back to 3.3V without a power cycle. CMD0 will not make SD (SDIO)
card enter 3.3V signalling voltage. Since the power supply
for mentioned card is also used to power bluetooth along with
wlan, so card cannot be power cycled for wlan alone from such mmc
host

This patch adds a capability for such host which cannot power cycle
the card. Thus during resume of sdio (mmc_sdio_resume), it checks
if host has MMC_CAP2_BROKEN_PWR_CYCLE capability set. In case if this
capability is set we do mmc_sdio_power_restore.

This patch also fixes the resume path that if there is an oldcard
present and it's an UHS card then CMD11 may give no response. In that
case we need to switch only host signal voltage to 1.8V as card is
already in 1.8V.

Without this patch software assumes that card is switched to 3.3V on
power cycle and tries voltage switch sequence which fails
(because host driver will not control this power supply and thus
card will never enter into 3.3V supply). Thus UHS mode is not entered.

Change-Id: I1fae116fd3c5b3854761ac09da1ffec7f6ddfec9
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-07-29 15:12:08 -07:00
Matt Gumbel e9e0c8aded mmc: longer timeout for long read time quirk
commit 32ecd320db39bcb007679ed42f283740641b81ea upstream.

008GE0 Toshiba mmc in some Intel Baytrail tablets responds to
MMC_SEND_EXT_CSD in 450-600ms.

This patch will...

() Increase the long read time quirk timeout from 300ms to 600ms. Original
   author of that quirk says 300ms was only a guess and that the number
   may need to be raised in the future.

() Add this specific MMC to the quirk

Signed-off-by: Matt Gumbel <matthew.k.gumbel@intel.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2016-06-07 10:42:55 +02:00
Asutosh Das 356dd17120 mmc: core: Add deferred resume for command queue mode
Do not resume the eMMC device as part of the system resume.
Only resume it when there's a request to be processed.

CRs-fixed: 972118
Change-Id: Ia4b3fcafb3fb5eabaad9d32bd776a03f45d4ab40
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Pavan Anamula <pavana@codeaurora.org>
2016-03-18 16:36:16 +05:30
Sayali Lokhande ce58571b65 mmc: core: Remove bus vote after resume/suspend if no card is present
To remove bus vote we expect clk-gating to kick in. But when SDcard is not
inserted, we are never turning the clocks on and hence gating will never
kick in. Thus bus voting will be always put to true.

Fix this by notifying the sdhci_msm about the pm_status only when card
is present(if host->bus_ops is NOT NULL) and remove bus vote in case of
error in mmc_suspend_host/mmc_resume_host.

Change-Id: I1f244e312f0716f99cdc53c991d37b102d40b8bc
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2016-01-19 21:47:06 +05:30
Linux Build Service Account 8bdc809e8d Merge "mmc: core: disable clock scaling before mmc suspend" 2015-12-04 12:43:58 -08:00
Ritesh Harjani 02a34eb670 mmc: core: cmdq helper for reset and claim host context
This patch does following-

This adds an API(mmc_cmdq_hw_reset), for RESET_ALL
of SDHCI, power cycle mmc card and
reintialize it, which enables cmdq as well(if supported).

This acquires claim_host before calling mmc_power_restore.
mmc_power_restore should be called with claim_host acquired,
since this function is required from non-claim-host context in
cmdq error handling.

Change-Id: I31c4449dead1d4ad4e10a4822cce2298ec5fb4b6
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2015-12-01 11:40:53 +05:30
Ritesh Harjani f9fd6cae32 mmc: core: Call cmdq_post_req with tag info instead of mrq
Call mmc_/cmdq_post_req with tag number instead of
mrq. This is needed in error handling as part of multiple
request error handling.

Change-Id: I175432639d28378ec74669e31deb4d1667c49bb8
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2015-12-01 11:40:53 +05:30
Sahitya Tummala 74ab5d4642 mmc: core: disable clock scaling before mmc suspend
This is to ensure that clock scaling work is either cancelled
or completely done if it is already running before the MMC/SD
suspend is started. Otherwise, the system suspend may fail
unnecessarily if it cannot claim the host due to pending
clock scaling work.

Change-Id: Icc465a607451b29d51e27b733e506060ca9f9dc0
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2015-11-27 01:55:46 -08:00
Jialing Fu ab7a4b4b9d mmc: core: fix race condition in mmc_wait_data_done
commit 71f8a4b81d040b3d094424197ca2f1bf811b1245 upstream.

The following panic is captured in ker3.14, but the issue still exists
in latest kernel.
---------------------------------------------------------------------
[   20.738217] c0 3136 (Compiler) Unable to handle kernel NULL pointer dereference
at virtual address 00000578
......
[   20.738499] c0 3136 (Compiler) PC is at _raw_spin_lock_irqsave+0x24/0x60
[   20.738527] c0 3136 (Compiler) LR is at _raw_spin_lock_irqsave+0x20/0x60
[   20.740134] c0 3136 (Compiler) Call trace:
[   20.740165] c0 3136 (Compiler) [<ffffffc0008ee900>] _raw_spin_lock_irqsave+0x24/0x60
[   20.740200] c0 3136 (Compiler) [<ffffffc0000dd024>] __wake_up+0x1c/0x54
[   20.740230] c0 3136 (Compiler) [<ffffffc000639414>] mmc_wait_data_done+0x28/0x34
[   20.740262] c0 3136 (Compiler) [<ffffffc0006391a0>] mmc_request_done+0xa4/0x220
[   20.740314] c0 3136 (Compiler) [<ffffffc000656894>] sdhci_tasklet_finish+0xac/0x264
[   20.740352] c0 3136 (Compiler) [<ffffffc0000a2b58>] tasklet_action+0xa0/0x158
[   20.740382] c0 3136 (Compiler) [<ffffffc0000a2078>] __do_softirq+0x10c/0x2e4
[   20.740411] c0 3136 (Compiler) [<ffffffc0000a24bc>] irq_exit+0x8c/0xc0
[   20.740439] c0 3136 (Compiler) [<ffffffc00008489c>] handle_IRQ+0x48/0xac
[   20.740469] c0 3136 (Compiler) [<ffffffc000081428>] gic_handle_irq+0x38/0x7c
----------------------------------------------------------------------
Because in SMP, "mrq" has race condition between below two paths:
path1: CPU0: <tasklet context>
  static void mmc_wait_data_done(struct mmc_request *mrq)
  {
     mrq->host->context_info.is_done_rcv = true;
     //
     // If CPU0 has just finished "is_done_rcv = true" in path1, and at
     // this moment, IRQ or ICache line missing happens in CPU0.
     // What happens in CPU1 (path2)?
     //
     // If the mmcqd thread in CPU1(path2) hasn't entered to sleep mode:
     // path2 would have chance to break from wait_event_interruptible
     // in mmc_wait_for_data_req_done and continue to run for next
     // mmc_request (mmc_blk_rw_rq_prep).
     //
     // Within mmc_blk_rq_prep, mrq is cleared to 0.
     // If below line still gets host from "mrq" as the result of
     // compiler, the panic happens as we traced.
     wake_up_interruptible(&mrq->host->context_info.wait);
  }

path2: CPU1: <The mmcqd thread runs mmc_queue_thread>
  static int mmc_wait_for_data_req_done(...
  {
     ...
     while (1) {
           wait_event_interruptible(context_info->wait,
                   (context_info->is_done_rcv ||
                    context_info->is_new_req));
     	   static void mmc_blk_rw_rq_prep(...
           {
           ...
           memset(brq, 0, sizeof(struct mmc_blk_request));

This issue happens very coincidentally; however adding mdelay(1) in
mmc_wait_data_done as below could duplicate it easily.

   static void mmc_wait_data_done(struct mmc_request *mrq)
   {
     mrq->host->context_info.is_done_rcv = true;
+    mdelay(1);
     wake_up_interruptible(&mrq->host->context_info.wait);
    }

At runtime, IRQ or ICache line missing may just happen at the same place
of the mdelay(1).

This patch gets the mmc_context_info at the beginning of function, it can
avoid this race condition.

Signed-off-by: Jialing Fu <jlfu@marvell.com>
Tested-by: Shawn Lin <shawn.lin@rock-chips.com>
Fixes: 2220eedfd7 ("mmc: fix async request mechanism ....")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-01 12:07:32 +02:00
Ulf Hansson 107cd6cb6c mmc: core: Use mmc_flush_cache() during mmc suspend
Earlier we disabled the cache during suspend, which meant a flush was
internally at the eMMC performed as well.

To simplify code we can make use of the mmc_flush_cache(), during mmc
suspend, which makes the mmc_cache_ctrl() redundant so then we can
remove it.

Change-Id: I80c6cbf9ad3e81943aee4b844c267c8e4f360257
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Seungwon Jeon <tgih.jun@samsung.com>
Signed-off-by: Chris Ball <chris@printf.net>
Git-commit: 1a6fd1533dfa409e48f377db1d92ef1cc6b0c4ce
Git-repo: https://android.googlesource.com/kernel/common.git
[kaushalk@codeaurora.org: Resolved context conflicts]
Signed-off-by: Kaushal Kumar <kaushalk@codeaurora.org>
2015-09-16 18:20:22 +05:30
Konstantin Dorfman 1f22862005 mmc: block: fix dump cmdq registers on request timeout
Timeout handler executed on softirq context. cmdq dumpstate() api resumes
platform device and it can't be executed on softirq context. Request
completion callback schedules error handler work in case of timeout error.
This change moves CQE registers dump to the error handler callback.

Change-Id: Iea26ca5240f6031218dcf374cafcf2708df1f125
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2015-07-31 13:43:05 +05:30
Ritesh Harjani 0f9d90b9e0 mmc: core: Fix debugfs and IOCTL calls in cmdq mode
Currently getting status/ext_csd using debugfs or IOCTL
calls in cmdq mode is not working.
Fix it by halting the cmdq engine and making sure that
card queue is empty before issuing these cmds.

Change-Id: Idb89def9ff5c2fee6866759b9a8c652049552933
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2015-07-01 01:02:23 -07:00
xiaonian e49c44be42 mmc: core: detect removal of suspended SD card
When CONFIG_MMC_BLOCK_DEFERRED_RESUME was enabled,
if sleep and wake up the phone, then remove SD card,
the removal event will not be detected. This change
will ensure removal detection of SD card even if it
has not been resumed if the card is removed after
waking up the phone.

Change-Id: Ib99d1915b6fc150979c77dc3fbf6af79e5558db6
Signed-off-by: xiaonian <xiaonian@codeaurora.org>
2015-06-29 10:42:13 +08:00
Konstantin Dorfman 026fb6d834 mmc: core: ignore cmdq halt failure when no change is needed
During system suspend CQE halted by queue suspend even before mmc host
suspend. When mmc host suspend calls halt helper, CQE is already halted.

This change ignores error value of halt helper.

Change-Id: I2d1456333f1d04f0e7a77485443b80a0ccaa3b4e
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2015-06-24 19:01:11 +03:00
Linux Build Service Account 8de2bd8526 Merge "mmc: core: fix disable clock scaling" 2015-06-04 04:37:47 -07:00
Linux Build Service Account f6277afe48 Merge "mmc: Enable clock gating for cmdq" 2015-06-03 18:27:48 -07:00
Konstantin Dorfman d86bd26152 mmc: core: fix disable clock scaling
Need to cancel clock scaling work only when scaling was enabled and
the card is in the legacy (non-cq mode).

Change-Id: Ibfe00e54c495e249d0937345ffc6e6335940d21e
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2015-06-03 14:34:02 +03:00
Konstantin Dorfman 76de21c838 mmc: core: use asynchronous runtime suspend pm core api
This change is needed bacause mmc_rpm_release() api is used in softirq
context, when usage counter goes to zero, it will trigger pm core runtime
suspend callback.

Change-Id: I18b1d193952a83336d6539c495509091c24e7d41
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2015-06-03 14:34:00 +03:00
Linux Build Service Account 931faaad60 Merge "mmc: check if clk_scaling is enabled before resetting the statistics" 2015-06-02 17:38:41 -07:00
Maya Erez cb5bda7c42 mmc: check if clk_scaling is enabled before resetting the statistics
Add a check to mmc_reset_clk_scale_stats to check if clk_scaling
is enabled before resetting the statistics.

Change-Id: I025a150f68ab19733d3184b1573428cf788f6605
Signed-off-by: Maya Erez <merez@codeaurora.org>
2015-06-01 21:11:22 +03:00
Ritesh Harjani ea568494cf mmc: Enable clock gating for cmdq
Enable clock gating for cmdq by adding respective
API to clk hold/release. CMDQ also uses the same
legacy clock gating API.

Change-Id: I3d4f28cedb24ff2292ab08bdd7470358cf134dd5
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2015-06-01 20:06:49 +05:30
Maya Erez 1fcf6a0def mmc: cmdq: add clock scaling support for CQ mode
Add clock scaling support for command queuing mode.
In CQ mode we count busy time from sending the first data request
until the completion of all the pending data requests.
This is done by starting the busy time on the first data request,
stopping it at the end of each data request and restarting it as
long as there are pending data requests.

The need to scale up/down the clocks is checked before sending each
request. Scaling the clocks up and down is done immediately in the
cmdqd context.
Before scaling the clocks the queue has to be drained and halted,
to allow sending the switch and tuning commands.

Change-Id: Ie856284261afc9a7f02489d2c9ab6a438e609f57
Signed-off-by: Maya Erez <merez@codeaurora.org>
2015-06-01 17:31:58 +03:00
Sahitya Tummala 8823dc4682 mmc: block: add discard and secdiscard support for CMDQ mode
Discard is supported in CMDQ mode only when device queue is empty.
Hence, discard commands should be sent using DCMD slot with
QBR (Queue Barrier) flag set.

Change-Id: I630091cbd94ffcdcec71626257f912c15fd2e21e
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2015-05-29 17:28:06 +05:30
Asutosh Das c1e7b19811 mmc: block: Add error handling to command queue host
On error, the CMDQ engine stops processing requests. It is then
halted and error handled.
The error have been categorized as below:
1. Command error
	a. time-out
		- invalidate all pending tags & requeue
		- reset both card & controller
	b. crc
		- end the error mrq
		- tune
		- unhalt
2. Data error
	a. time-out
		- invalidate all pending tags & requeue
		- reset both card and controller
	b. crc
		- end the error mrq
		- tune
		- unhalt
3. RED error
	This is device specific error and is not recoverable.
	The card and controller are reset in this case and all
	pending tags are invalidated and requeued.

Change-Id: I791d05f6b31d8f9b35a56fe85007b320c14e8b46
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2015-05-27 14:40:59 -07:00
Asutosh Das 58e91e920d mmc: core: Add halt support
Halt is a controller feature that can change the controller mode
from command-queue to legacy. This feature is very helpful in
error cases.

Change-Id: I7f1465b609afed68886256bd605d4019716964f4
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2015-05-27 14:40:35 -07:00
Asutosh Das eba093a9b4 mmc: core: add flush request support to command queue
Adds flush request support to command-queue. This uses DCMD
feature of the controller for sending commands in
command-queue mode. DCMD is a direct command feature that uses
a pre-configured slot for sending commands other than Class 11.

Change-Id: Iebf6b74173dc91b0dc7230d1e87c65983d15148e
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2015-05-27 14:40:22 -07:00
Asutosh Das ecef614329 mmc: card: add read/write support in command queue mode
Command queueing is defined in eMMC-5.1. It is designed for
higher performance by ensuring upto 32 requests to be serviced
at a time.

Adds read/write support for CMDQ enabled devices.

Change-Id: I136ddea8e5ca57eb4f85ca6e72c60001a7e24f78
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2015-05-27 14:39:34 -07:00
Ritesh Harjani fcd01234f0 mmc: core: Fix mmc clk scale down during writes.
No need to check for valid state when we want to
scale down the clocks. As this state validity
check is to only address that clk scaling
doesnt scale up (which will send tuning
cmds) during definite cmds sequences (like
erase operation).

CRs-Fixed: 800478
Change-Id: Ia7a578434d7db8983493788ab2d7f9383d703169
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2015-03-31 21:03:29 -07:00
Sahitya Tummala 40a3105340 mmc: core: fix race between mmc_power_off and mmc_power_up
In case card detect IRQ is triggered before mmc_add_host(), then
there could be a potential race between mmc_power_off() which gets
called from mmc_rescan() of card detect IRQ handler and
mmc_start_host() which gets called from mmc_add_host(). This may
turn off the clocks while mmc_start_host() is still running and thus
may result in an un-clocked register access.

Change-Id: I522df75ba0ad23f065127e015ad825075be94596
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2015-02-25 12:23:36 +05:30
Talel Shenhar 2b007503ff mmc: block: fix flush timeout error handling
The eMMC card can go into "reset state" due to several
reasons and without host involvement,
e.g. low voltage detection.
This kind of eMMC card reset requires eMMC host to
re-initialize the eMMC card.
In case of eMMC card reset, eMMC card firmware sets its
state to "reset state" which allows CMD0 only.
In case the eMMC host is in the middle of FLUSH request it will
get timeout which will cause the driver to requeue the flush
request and try it later on.
The problem with this is that no one is going to initialize
the eMMC card to move out of "reset state", hence, the flush
request will keep on failing over and over again.
This commit adds a device reset for the case where flush request
fails due to timeout.

Change-Id: Ic268e13cb19d0cdce0070174bf7847e6253e4513
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
2015-01-18 15:34:18 +02:00
Talel Shenhar 18a5a61a84 mmc: core: enable BKOPS by read-modify-write instead of override
This change adds a read-modify-write logic to BKOPS feature enable.
It is required in order to avoid overriding other fields defined
in BKOPS_EN register.

Change-Id: I689f5cd14d9ec1bb881f503a0418026a59e6c197
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
2015-01-04 15:56:31 +02:00
Ritesh Harjani 48eb10dafe mmc: core: Include one more state for mmc_load during init
Include one more state of MMC_LOAD_INIT when resume (which
calls for mmc clk init algorithm) is called
to notify sdhci with SDHCI_PERMORMANCE_MODE_INIT.

Change-Id: I80661d7c9a927ed16925c0b9c00ac7abec608cee
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2014-12-16 22:55:14 +05:30
Linux Build Service Account 5e3a69fdaf Merge "mmc: core: resolve divded by zero panic" 2014-11-10 03:57:55 -08:00
Chuanxiao Dong 4ed3f695f8 mmc: core: resolve divded by zero panic
With one special SD card, below divide by zero error observed:
...
[    2.144300] divide error: 0000 [#1] PREEMPT SMP
[    2.148860] Modules linked in:
[    2.151898]
[    2.152685] Set up 4031 stolen pages starting at 0x0001f000, GTT offset 0K
[    2.157330] Set up 0 CI stolen pages starting at 0x00000000, GTT offset 131072K
[    2.167581] Pid: 5, comm: kworker/u:0 Not tainted 3.0.8-138216-g974a2ab #1
[    2.169506] [drm] PSB GTT mem manager ready, tt_start 4031, tt_size 28737 pages
[    2.169906] [drm] SGX core id = 0x00000000
[    2.169920] [drm] SGX core rev major = 0x00, minor = 0x00
[    2.169934] [drm] SGX core rev maintenance = 0x00, designer = 0x00
[    2.197370]  Intel Corporation Medfield/iCDKB
[    2.201716] EIP: 0060:[<c1697ca6>] EFLAGS: 00010246 CPU: 1
[    2.207198] EIP is at mmc_init_erase+0x76/0x150
[    2.211704] EAX: 00002000 EBX: dcd1b400 ECX: 00002000 EDX: 00000000
[    2.217957] ESI: 00000000 EDI: dcd5c800 EBP: dd867e84 ESP: dd867e7c
[    2.224214]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
[    2.229605] Process kworker/u:0 (pid: 5, ti=dd866000 task=dd868000 task.ti=dd866000)
[    2.237325] Stack:
[    2.239322]  dcd1b400 00000000 dd867eb0 c16a06da c1ab7c44 dd995aa8 00000003 00000000
[    2.247054]  00000000 00000000 dcd5c800 00000000 dcd1b400 dd867ef8 c16a1012 c1698b00
[    2.254785]  00000029 00000001 c194eb80 dcd5c9ec dd867e00 c1239b00 00000000 00000000
[    2.262519] Call Trace:
[    2.264975]  [<c16a06da>] mmc_sd_setup_card+0x1da/0x4f0
[    2.270183]  [<c16a1012>] mmc_sd_init_card+0x192/0xc40
[    2.275304]  [<c1698b00>] ? __mmc_claim_host+0x160/0x160
[    2.280610]  [<c1239b00>] ? __schedule_bug+0x50/0x80
[    2.285556]  [<c16a1b89>] mmc_attach_sd+0xc9/0x230
[    2.290333]  [<c169b6ef>] mmc_rescan+0x25f/0x2c0
[    2.294943]  [<c1274223>] process_one_work+0x103/0x400
[    2.300065]  [<c12670fd>] ? mod_timer+0x1ad/0x3c0
[    2.304756]  [<c169b490>] ? mmc_suspend_host+0x1a0/0x1a0
[    2.310056]  [<c127502d>] worker_thread+0x12d/0x4a0
[    2.314921]  [<c18fcfbd>] ? preempt_schedule+0x2d/0x50
[    2.320047]  [<c1274f00[    2.323976] ---[ end trace 5398ec2720494438 ]---
...

So, seems this bad SD card does not set valid value in related SSR / CSD register fields.
And then the driver will set card->erase_size to 0.
Then it triggered this divided by zero error when calculate card->pref_erase.

Submit this patch to fix the issue.

Signed-off-by: Yunpeng Gao <yunpeng.gao@intel.com>
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Git commit: cc8aa7de48277f62fe3fced762d75f01ce57e909
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Change-Id: Icd28093ab823e20456fac9c2cb0c51475b389e1d
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-10-31 15:39:30 +05:30
Sahitya Tummala 2d3196585d mmc: core: Fix unclocked access in get_xfer_remain/stop_request
The unclocked access could happen in the following scenario -

1. mmcqd thread is waiting for previously submitted io to be done
2. before this io is done, it is woken up due to is_urgent event
3. mmcqd thread is running and is processing the is_urgent event
4. Just about the same time the previously submitted io is done and
it sets is_done_rcv flag, tries to wake up mmcqd thread and release
host clock so as to gate the clocks.

If step 3 and 4 happen at the same time, then clocks will be gated off
before is_urgent is completely handled. Hence, make sure to hold the
clock before invoking get_xfer_remain and stop_request host->op.

Change-Id: If03177bf5e28cc217cc8e86b10d81d4adbab78b9
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-10-17 09:07:41 +05:30
Linux Build Service Account 6e3436ea55 Merge "Revert "mmc: core: increase delay between power-up and power-on"" 2014-10-14 08:50:04 -07:00
Guoping Yu 02a9497a17 Revert "mmc: core: increase delay between power-up and power-on"
This reverts commit 3ec1ed2a8d.

The original 10ms delay is enough to reach power on from power
up. Increase delay is workaround to resovle resume Re-init
retries time out error. The root cause is additional QDSD block
would impact SD fucntionality as they are multiplex with SD
interface. If cd-gpio is HW floating and has a pulse, QDSD 100ms
search process would be triggerred is prior to SD block and SD
interface work as QDSD instead of SD.

The fix is merged, so revert the workaround.

Change-Id: I647be754de4a6a13678cbb1456a9db88c2714f94
Signed-off-by: Guoping Yu <guopingy@codeaurora.org>
2014-10-14 14:45:41 +08:00
Konstantin Dorfman ac28baee40 mmc: core: use cache flush timeout as cache disable timeout
When eMMC cache is disabled, the card has to flush all the data in its
cache.
This change increases the timeout for cache flush operation and also uses
the cache flush timeout in cache disable operation.

Change-Id: I373050a99816c95e784a957de4271955a511b9f9
CRs-Fixed: 723701
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2014-09-23 12:26:42 +03:00
Guoping Yu 3ec1ed2a8d mmc: core: increase delay between power-up and power-on
Add a capability to selectively increase the delay between
power_up and power_on. This delay was arrived at after performing
a series of experiments to find the minimum value. It is required
in some scenarios to avoid command timeouts during resume.

Change-Id: I857e740aa20a33e08515d054e5c9bf128db229c6
Signed-off-by: Guoping Yu <guopingy@codeaurora.org>
2014-09-08 22:15:50 -07:00
Linux Build Service Account 46199631f4 Merge "mmc: core: assert in case NULL pointer dereference" 2014-08-08 22:59:27 -07:00
Asutosh Das 2ffe104c02 mmc: core: remove duplicate code in mmc_rescan
If the card is removed, the wakelock has to be held for
an extended period of time to enable the user-space to
respond. The code to extend the wakelock has been
duplicated. This patch removes this duplicate code.

CRs-fixed: 684724
Change-Id: I96e4e9dec46ada7853724c36f0c2c6329f696e5d
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2014-08-04 09:56:31 +05:30
Konstantin Dorfman 0ffedec59f mmc: core: assert in case NULL pointer dereference
This changes ensures that pointer to card struct is valid.

Change-Id: I11405cd7dd3a1a43fdb3010152a07c1c7944fc9d
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2014-08-03 17:39:53 +03:00
Konstantin Dorfman 8574fa8955 mmc: core: Change stop_request() print to debug log level
The only error returned by stop_request(), is returned when there is
no current request to stop. This case is handled by mmc_stop_request()
caller.

Change-Id: I09bb30593d6accefef5d550881d87b6bf603296c
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2014-06-16 14:17:04 +03:00
Sujit Reddy Thumma 65cb1e5099 mmc: core: Fix null pointer dereference due to illegal mmc request
Fix a race condition that can lead to null pointer dereference
while the MMC transfers are going on.

1) mmc_request_done() -> mmc_wait_for_data_done ->
	step1: update is_done_rcv
	step2: wake_up sleeping thread (mmcqd) waiting for is_done_rcv

2) mmcqd -> mmc_wait_for_data_req_done
	step4: wait for is_done_rcv or is_new_req
	step5: is_new_req set from block layer context and mmcqd
	       is woken up
	step6: let's say step1 is done, so complete the current request
	step7: fetch new request and issue to host layer
	step8: fetch one more request and wait for previous request to
	       complete

In the above execution contexts, if step4-step8 happens between step1 and
step2 a null pointer dereference is observed -

[   29.483302] Unable to handle kernel NULL pointer dereference
		at virtual address 00000488
[   29.490366] pgd = c0004000
[   29.493054] [00000488] *pgd=00000000
[   29.518937] PC is at do_raw_spin_lock+0x8/0x13c
[   29.523445] LR is at _raw_spin_lock_irqsave+0x20/0x28
[   30.108789] [<c0339cd4>] (do_raw_spin_lock+0x8/0x13c) from
[   30.118418] [<c095d178>] (_raw_spin_lock_irqsave+0x20/0x28) from
[   30.127445] [<c0142ef4>] (__wake_up+0x20/0x50) from
[   30.136124] [<c0663f70>] (mmc_request_done+0x30c/0x368) from
[   30.145932] [<c067bd98>] (sdhci_tasklet_finish+0x130/0x13c) from

Change-Id: I9a21431b5fd9bb9bbcb5c18a9895096fe845e64b
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2014-06-11 13:44:26 +05:30
Linux Build Service Account 2e5d431111 Merge "mmc: core: continue to wait, when unblocked by signal" 2014-05-26 09:45:22 -07:00
Asutosh Das c865639f10 mmc: core: abort rescan if suspend is triggered
There could be a race between suspend and mmc_rescan as follows:
At resume:
-> mmc_pm_notify
  -> mmc_rescan is scheduled

Suspend is triggered:
-> mmc_pm_notify
   -> wait for mmc_rescan/cancel it
      -> rescan acquires wakelock if card is detected
         so as to give user-space a chance to respond
-> PM framework cancels suspend since wakelock is active

Hence, release the wake-lock if its active in suspend prepare
and check for rescan_disable before acquiring wake-lock.
This prefers suspend over notifying the user-space of the status
of the card, which is fine since with suspend user-space is frozen
too.

CRs-fixed: 655281
Change-Id: I83783589f9b541d3af73931e9a7b0b144a25538e
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2014-05-20 12:06:14 +05:30