Commit graph

3350 commits

Author SHA1 Message Date
Linux Build Service Account
eae662b871 Merge "mmc: card: fix errors for NULL pointer deference" 2014-08-10 08:47:28 -07:00
Linux Build Service Account
c3f4be32f6 Merge "mmc: sdhci-msm: fix possible NULL pointer dereference" 2014-08-09 14:58:11 -07:00
Linux Build Service Account
9ca336b95c Merge "mmc: sdhci-msm: Reduce the max descriptors" 2014-08-08 23:00:00 -07:00
Linux Build Service Account
e6523d3bba Merge "mmc: sdhci: convert align buffer to a coherent allocation" 2014-08-08 22:59:58 -07:00
Linux Build Service Account
bc1098b352 Merge "mmc: sdhci: Enumerate sglist only on read" 2014-08-08 22:59:57 -07:00
Linux Build Service Account
e83379fced Merge "mmc: sdhci: avoid sync'ing the SG if there's no misalignment" 2014-08-08 22:59:55 -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
d97d2762a4 mmc: sdhci-msm: fix possible NULL pointer dereference
The platform_get_resource API may return NULL, hence check
the return value before using the mapped memory.

Change-Id: I28741554f8e1b5843671ee0d6b08bdcf8e4469c9
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2014-08-08 23:15:10 +05:30
Konstantin Dorfman
54c7580744 mmc: card: fix errors for NULL pointer deference
This change fixes pointer de-references without NULL check before.

Change-Id: I624e56513c09a2d5919cb91f650f4e2982eb3d71
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2014-08-07 16:09:42 +03:00
Guoping Yu
35e0143842 mmc: core: add long read time fixup for certain Samsung eMMC
Certain Samsung eMMC meet multi read timeout, and could not
reponse status CMD anymore after that. Add long read timeout
fixup to resolve it.

Change-Id: Ibeb0e6ab3d889d48fdee91244bec720a6994b907
Signed-off-by: Guoping Yu <guopingy@codeaurora.org>
2014-08-07 00:54:18 -07:00
Venkat Gopalakrishnan
c69a15f2bb mmc: sdhci-msm: Reduce the max descriptors
8K is the max descriptors supported by the hardware per transfer.
On normal use cases we never use that many descriptors even if
the memory is extremely fragmented. The memory allocated for these
descriptors are never freed hence wasting memory otherwise
available for the system. Reduce the max descriptors to 512 to save
memory (128K with 8K descriptors vs 8K with 512 descriptors) and
still support maximum performance.

CRs-fixed: 684185
Change-Id: Ib57ce03834d741c0fda4195a58d6b287ee9fb0a0
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2014-08-05 09:52:48 -07:00
Venkat Gopalakrishnan
7a1765dc67 mmc: sdhci: convert align buffer to a coherent allocation
Rather than using the streaming API, use the coherent allocator to
provide this memory, thereby eliminating cache flushing of it each
time we map and unmap it.

CRs-fixed: 684185
Change-Id: I615133da06a04fa23c6bca4078e484299147eb34
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2014-08-05 09:52:27 -07:00
Venkat Gopalakrishnan
72791ad237 mmc: sdhci: Enumerate sglist only on read
Save sglist enumeration for write since identifying misalignment is only
required on read use cases.

CRs-fixed: 684185
Change-Id: Iacb362e8a9cd68d487ea6bd8ce8e56eef49f471e
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2014-08-05 09:51:52 -07:00
Russell King
2a6b494ca9 mmc: sdhci: avoid sync'ing the SG if there's no misalignment
On read, we don't need to sync the whole scatterlist and then check
whether any segments need copying - if we check first, we avoid
potentially expensive cache handling.

CRs-fixed: 684185
Change-Id: I9a07b1b1e83d0299765f80adc14bbff44f7ed114
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Markus Pargmann <mpa@pengutronix.de>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
Git-commit: de0b65a786ae83c8f6dfb712f65b9a36af70a981
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[venkatg@codeaurora.org: use align_bytes - 1 for alignment check]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2014-08-05 09:51:36 -07:00
Linux Build Service Account
6cb73e412b Merge "mmc: sdhci: convert ADMA descriptors to a coherent allocation" 2014-08-05 00:14:00 -07:00
Linux Build Service Account
7dd146b7f3 Merge "mmc: core: remove duplicate code in mmc_rescan" 2014-08-04 08:30:50 -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
Venkat Gopalakrishnan
7fe6d9abe5 mmc: sdhci: Add tracepoints to enhance debugging
Instrument the sdhci driver with tracepoints to aid in
debugging issues and identifying latencies in the following
path:
* CMD completion
* DATA completion
* DMA preparation
* Post DMA cleanup

Change-Id: Ie8cd0c2fb6c1bd6ab13883123be021081f8b8f78
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2014-08-01 17:29:25 -07:00
Linux Build Service Account
5141eb2ed6 Merge "mmc: block: fix race in deferred resume" 2014-07-31 06:00:03 -07:00
Venkat Gopalakrishnan
7a7528c0f8 mmc: core: Fix power class config for HS400
Use the correct power class field from the extended CSD register
for HS400 mode as defined in the eMMC5.0 specification.

CRs-fixed: 690341
Change-Id: Ie10e35941fd3c6ee49c686f721bf5af6fcd74862
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2014-07-28 14:26:56 -07:00
Russell King
9c21b8ee94 mmc: sdhci: convert ADMA descriptors to a coherent allocation
Rather than using the streaming API, use the coherent allocator to
provide this memory, thereby eliminating cache flushing of it each
time we map and unmap it.  This results in a 7.5% increase in
transfer speed with a UHS-1 card operating in 3.3v mode at a clock
of 49.5MHz.

CRs-fixed: 684185
Change-Id: I82aae6264db1ebfb87badbb223893b066ad53652
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Markus Pargmann <mpa@pengutronix.de>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
Git-commit: d1e49f77d7c7b75fdc022e1d46c1549bbc91c5b7
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[venkatg@codeaurora.org: use adma_desc_sz for ADMA_SIZE & align_bytes - 1
for alignment check]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2014-07-25 15:11:11 -07:00
Asutosh Das
33ab6ff829 mmc: block: fix race in deferred resume
The actual resume takes place when a request is received. In a
situation when mmcqd and qseecomd(rpmb) both try to resume the
device, a race is ensued. This is because mmcqd first resumes
the device and then claims the host. Ideally, if resume is in
progress in one context the resume in the other context should
be cancelled.
Claim the host before resuming the device in mmcqd context.

CRs-fixed: 697018
Change-Id: I11d33e642a9b2022f77277196de128c9ac78d334
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2014-07-22 16:47:46 +05:30
Linux Build Service Account
2049a6cf40 Merge "mmc: sdhci: Vote for new IRQ specific QoS request" 2014-07-09 10:46:25 -07:00
Sahitya Tummala
c32a649805 mmc: sdhci: Vote for new IRQ specific QoS request
The current vote applies to all CPUs and hence may have power
impact, especially when there are more number of CPUs. The new
IRQ specific QoS request shall update the vote only for one
CPU to which the IRQ's smp_affinity attribute is set to.

Change-Id: I55298f729949c39ebfa3eecd4746d77e40cb2e5c
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-07-08 11:12:00 +05:30
Sujit Reddy Thumma
8f5be087c3 mmc: core: Avoid infinite retries of failed mmc command
With some bad SD cards, it is possible that the error recovery
procedure goes into a state where it retries the failed command
infinitely leading to CPU hog.

Fix inifinite retries when the bad SD card isn't responding to
a command even when the SD card reset mechanism is successful.

CRs-Fixed: 671153
Change-Id: Ic6db66b571aa425aec32c82d52789c68fe0cb0e9
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2014-06-30 22:07:52 -07:00
Linux Build Service Account
b2dbd15d30 Merge "mmc: block: Fix an invalid use of req->cmd_flag in DISCARD operation" 2014-06-30 12:18:37 -07:00
Linux Build Service Account
c7a4509312 Merge "mmc: card: Increase sanitize command timeout" 2014-06-30 04:41:39 -07:00
Maya Erez
710b119d7e mmc: block: Fix an invalid use of req->cmd_flag in DISCARD operation
When handling a DISCARD operation, the MMC request data structure may be
freed in memory. Therefore, it can't be used to retrieve the cmd_flags
for checking if MMC_REQ_NOREINSERT_MASK is set:
(!(mq->mqrq_cur->req->cmd_flags & MMC_REQ_NOREINSERT_MASK)))).

To prevent the issue we should use the local variable of cmd_flags.

Change-Id: Idef53d5bd66fa6f1faaf79644c8efb5177c75e89
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2014-06-30 14:35:37 +03:00
Subhash Jadavani
1b18cd6a0d mmc: sdhci-msm: configure CORE_CSR_CDC_DELAY_CFG to recommended value
Program CORE_CSR_CDC_DELAY_CFG for hardware recommended 1.25ns delay.
We may see data CRC errors if it's programmed for any other delay
value.

CRs-Fixed: 683894
Change-Id: Id7de28b7b9222c35e6b419e416f72bd8f98cbaf8
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-06-27 10:16:54 -07:00
Sahitya Tummala
943729fdd8 mmc: card: Increase sanitize command timeout
The current timeout value is 30 sec and with this busy timeouts
are observed on few eMMC cards. Hence, increase it to 240 sec
which is already being used in IOCTL variant of sanitize command.
It helped resolve such busy timeout issues.

Change-Id: I08993ac9fb02520267b58bddee51f9c166f129ff
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-06-27 11:10:02 +05:30
Krishna Konda
1857c7825d sdhci: sdhci-msm: fix issue with hs400 mode
In HS400 mode, command line is still operated in SDR mode and not
DDR mode like data lines. So in order to correctly process command
responses, the hardware needs to be set appropriately or else there
will command crc or similar errors due to incorrect sampling of the
response.

Change-Id: I426ff4fc4798afae254d11a608c800dc0b7bf765
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
2014-06-23 14:50:38 -07:00
Krishna Konda
807d60f8d2 sdhci: sdhci-msm: update dll configuration
The newer msm sdhci's cores use a different DLL hardware for HS400.
Update the configuration and calibration of the newer DLL block.

The HS400 DLL block used previously is CDC LP 533 and requires
programming multiple registers and waiting for configuration to
complete and then enable it. It has about 18 register writes and
two register reads.

The newer HS400 DLL block is SDC4 DLL and requires two register
writes for configuration and one register read to confirm that it
is initialized. There is an additional register write to enable
the power save mode for SDC4 DLL block.

Change-Id: I20ddeaee9309c43cd51bebdfc02d70553c9d2a87
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
2014-06-20 17:17:34 -07:00
Linux Build Service Account
33880fc49a Merge "mmc: core: Change stop_request() print to debug log level" 2014-06-16 23:36:58 -07:00
Linux Build Service Account
5c4e65d31e Merge "mmc: core: Add retry mechanism for MMC resume failure" 2014-06-16 15:04:47 -07: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
Sahitya Tummala
17febdf753 mmc: core: Add retry mechanism for MMC resume failure
Enhance the error handling/recovery path during eMMC resume by
adding retry mechanism and by adding additional error messages
to failure cases. This may help some of the bad parts which fail
to resume sporadically.

Change-Id: I895068edb487e6a44205e0769342b2ec2c89c876
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-06-12 16:48:34 +05:30
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
Sujit Reddy Thumma
255159eba9 mmc: core: Fix null pointer dereference due to race conditions
Fix race condition between mmcqd thread and the mmc_queue_suspend
updating a shared variable mq->flags, which can lead to potential
null pointer dereference as following-

Unable to handle kernel NULL pointer dereference at
virtual address 00000020
pgd = c0004000
[00000020] *pgd=00000000
mmcqd/0:  186] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
CPU: 0    Tainted: G        W     (3.4.0-1251694-eng #1)
PC is at mmc_blk_err_check+0x20c/0x3b8
LR is at mmc_start_req+0x198/0x718

cpu0		|	cpu1
x |= 1		|	x |= 2

final value of x can be x = 1 or x = 2

Change-Id: Ie0fff6d6dba5aebb3584cba9fb98de24515c4cd8
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2014-06-11 08:43:04 +05:30
Linux Build Service Account
e55e335ff7 Merge "mmc: sdhci-msm: Fix issue with SD card detect GPIO" 2014-06-07 02:35:08 -07:00
Linux Build Service Account
8630a48bb7 Merge "mmc: sdhci: Fix issue with SDHCI_NEEDS_RETUNING" 2014-06-05 23:58:54 -07:00
Sahitya Tummala
b22732141a mmc: sdhci-msm: Fix issue with SD card detect GPIO
Set up the card detect GPIO in active configuration before
configuring it as an IRQ. Otherwise, it can be in some
weird/inconsistent state resulting in flood of interrupts.

Change-Id: I8f2344a72acbd48df745cc9b2602fe4ac6f034d4
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-06-06 08:48:42 +05:30
Sahitya Tummala
ac9fd305bc mmc: sdhci: Fix issue with SDHCI_NEEDS_RETUNING
The following two issues are addressed with this change -

1. The current code sets SDHCI_NEEDS_RETUNING flag even for tuning
commands and it will unecessarily cause tuning to be done again
for the next read/write command. Hence, we must not set this flag
for any CRC failures to tuning commands.

2. If SDHCI_NEEDS_RETUNING flag is set and if all tuning phases
pass, then the driver attempts to change the driver type by sending
CMD6 which is a not a tuning command. The driver will thus attempt
to do re-tuning again before sending CMD6 and goes forever in a
recursive loop. Hence, clear SDHCI_NEEDS_RETUNING flag before
executing tuning.

Change-Id: Iaf3b24b93fdf655392fe02c973799e465960a495
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-06-02 15:42:09 +05:30
Sahitya Tummala
f3c8290ee9 mmc: core: Fix NULL pointer dereference issue with mmc_blk_reset()
If the mmc_hw_reset() fails, then host->card might be NULL in some
cases. Hence, check for reset errors and report it to the caller so
that the current request can be aborted and also check for host->card
before accessing it so as to prevent NULL pointer dereference issue.

Change-Id: Iba0f0be314474e607a40383bc0b28eef66a31d63
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-05-30 12:20:11 +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
Linux Build Service Account
50c3e2d9af Merge "mmc: core: sd: implement proper support for sd3.0 au sizes" 2014-05-25 22:23:05 -07:00
Linux Build Service Account
182931de1f Merge "mmc: sd: fix the maximum au_size for SD3.0" 2014-05-25 13:06:53 -07:00
Wolfram Sang
380b2b6530 mmc: core: sd: implement proper support for sd3.0 au sizes
This reverts and updates commit 77776fd0a4cc541b9 ("mmc: sd: fix the
maximum au_size for SD3.0"). The au_size for SD3.0 cannot be achieved
by a simple bit shift, so this needs to be implemented differently.
Also, don't print the warning in case of 0 since 'not defined' is
different from 'invalid'.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: stable <stable@vger.kernel.org> # [3.12, 3.13]
Signed-off-by: Chris Ball <chris@printf.net>
Git-commit: 9288cac05405a7da406097a44721aa4004609b4d
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Change-Id: Ia19e30f1b9d793e1757a3eb3126b994df6b7a72a
[stummala@codeaurora.org: resolved merge conflicts]
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-05-25 12:12:30 +05:30
Jaehoon Chung
5641e819a5 mmc: sd: fix the maximum au_size for SD3.0
Since SD Physical Layer specification V3.0, AU_SIZE is supported up
to 0xf.  So If SD-card is supported v3.0, then max_au should be 0xf.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Git-commit: 77776fd0a4cc541b9a528eacc1d31ca47eb1ae7a
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Change-Id: I140ad257098ab88ae8fab0a9cdb28130c3d4327b
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-05-25 12:12:13 +05:30
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