Ensure the task descriptor list memory is flushed before ringing
the doorbell by adding a memory barrier. Also commit the doorbell
write immediately to help improve performance.
Change-Id: I321d5bed95b802d4bcc00836ce9cdede316b29f5
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
If mmc/sd shutdown callback suspends the card when card's runtime PM status
is still set to "runtime active" then any request issued after mmc/sd
shutdown will not resume the card hence we will end up issuing the request
to host driver while card isn't in a state to handle it.
Right way to fix this issue is not to allow any requests to flow in after
the shutdown callback has executed. Until it is fixed in the right way, we
are disabling the shutdown handling as it anyways doesn't do real useful
things.
Change-Id: I44681f3c2fd0435bffa393abbbd1e8eacc5a07da
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This is needed to scale up/down the ICE clock during runtime
as per the load on eMMC.
Change-Id: I60d06458767c817298783219caf767866e7bf12f
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Switch to using pr_err_ratelimited in order to avoid
flooding the logs in case of error function gets
called repeatedly.
CRs-Fixed: 837631
Change-Id: I08fffb7e77584ac7fe7ba7152677cc12293e1655
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
Signed-off-by: Pavan Anamula <pavana@codeaurora.org>
After issuing a request the usage_count is decremented. After idle time
controller irq is disabled by platform device runtime pm and request
complete irq is not handled.
This change moves decrement of usage_count from the end of issuing request
to the end of request completion.
Change-Id: I1322e0d1ab4ffbf50956fec2921c778e0dcddf36
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
Block layer queue on suspend flow gives up if there are active requests,
while shutdown flow stops issuing thread and waits for completion of
outstanding requests and never give up.
This change propagates additional parameter to differentiate between
suspend and shutdown flows
Change-Id: I35a036c1a5585e3088301c07ade7d09ebd2cfc1b
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
[subhashj@codeaurora.org: fixed merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Some devices do not honor the max switch timeout exposed via
ext_csd, they take longer than that to complete the switch.
Hence add a retry mechanism to wait longer for the card to
get out of programming state before timing out.
Change-Id: Ica46e30df24b4f95f457271087e1e03823ed2959
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[subhashj@codeaurora.org: fixed merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
In 3.18 kernel mmc_gpiod_request_cd_irq() is not called as part of
call to mmc_gpio_request_cd(). During probe this is taken care of
by calling mmc_gpiod_request_cd_irq() from mmc_start_host(), but if
mmc_gpio_request_cd() followed by a mmc_gpio_free_cd() is invoked
after mmc_start_host() (such as in system suspend/resume path) then
mmc_gpiod_request_cd_irq() needs to be called explicitly.
Instead of free/request the card detect irq, just disable/enable
the irq in system suspend/resume path.
CRs-fixed: 876453
Change-Id: I976cd5061c2a7d8321e48ee23a44acfd552a37fc
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
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>
[subhashj@codeaurora.org: fixed merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
CMDQ spec defines periodic SEND_STATUS mechanism to poll
on READY tasks in the device. When DAT lines are in IDLE
the counter counts from its reset value to '0' and then
triggers SEND_STATUS command. When CMD13 is completed and
also the syncing of the device status to HCLK domain is done
there is a 1 cycle pulse to reload the counter with timer
reset value so that the counting can start over.
In rare cases, when the 'done' pulse for reloading the
counter happens in parallel to a BUSY state of direct
command - the IDLE counter is not reloaded and can't
trigger another CMD13. If this scenario happens when
there are pending tasks which are not 'READY' yet - it
can lead to a deadlock, since there is no other mechainsm to
send CMD13, and CQE will never get READY on the pending tasks.
Hence, trigger a send status command after DCMD is completed
as a work-around to the above issue.
Change-Id: I4e8530e72c8bf581ffaeed7d35d8b8c61d282ffa
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
The cmdqd thread was marked as uninterruptible. This did not
allow the cmdqd thread to sleep when there is no traffic.
Added interruptible attributes to the thread.
Change-Id: I658eecabfff074044b23c7c270c9101a34d37a45
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Right now only certain amount of delay (146 MCLK cycles as per spec)
is given for card to return back to transfer state upon any CMD error
that host controller may receive. This delay seems to be insufficient
for certain eMMC cards like Hynix. This patch tries to send CMD13 and
also retry it with the same delay to make sure the card is back to
transfer state before sending next command. Otherwise we may see auto
cmd or illegal command failures to the read command sent right after
tuning, especially if the last tuning phase has failed.
Change-Id: I3ec2da150dc5ee656b8156040bf539812b0e4d2b
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Pavan Anamula <pavana@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
System suspend executed on kernel PM core context. When there are active
requests system suspend is rejected. Semaphore used to resolve race
between mmc_cmdq_thread() and mmc_queue_suspend().
Change-Id: I88f668d7a6dd6403407ac8208265e4439b35173c
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
Changing the test of whether auto_bkops is configured
allows for a case where the host tried to configure
auto_bkops yet the CMD6 failed in configuring the
device. This allows a case where manual bkops is configured
on a eMMC 5.1 device
Change-Id: Ia6c411f516bf27b8a5865109dcf4b290eb3d8e46
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts &
fixed compilation error]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Certain Hynix eMMC 5.0 cards might reach a fast EOL if
the card's power is disabled between CMD5 and CMD0
(power off during reset).
This patch sets the MMC_PM_KEEP_POWER flag to indicate
that the card's power should be retained for suspend/resume
sequences.
Change-Id: I4bcc0f4bfd608745626816ca261369b432602c45
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
There are eMMC cards that should not be powered off
during suspend/resume cycles.
This patch adds support for such cards and avoids powering
the card off during suspend or powering it back on
during resume when MMC_PM_KEEP_POWER is set.
Change-Id: Iec1a0aac80ee41dff56f192e7253c2bd00c15694
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
Add MMC_PM_KEEP_POWER specifically when connected to
SDIO cards, rather than in general for the host.
Change-Id: Idb666680f99277ae509c642595821448c21b6c90
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
Add call from sdio to host_ops to sdhci_ops
in order to indicate when a sdio card is detected.
This will be used by hosts that require special
handling for card detection.
Change-Id: I65ec6ee464d658cd938d9254a0a748e6137f9223
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This change fixes an issue that can happen for clock scaling
sequence during command-queue.
This is the sequence for scaling the clocks in case of
command queuing:
1) Halt queue
2) Check if state invalid
3) Scale clocks
4) Un-halt scale
In case step 2 fails (e.g. device state is different
than R1_STATE_TRAN), we should avoid scaling the clocks and
un-halt the queue. The issue was that step 4 was not
happening in case of invalid state, this change fixes it.
Change-Id: I308b0d6406631febe364d14de7551eb7f628cb40
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
The bkops exception handling will ignore cases when
auto bkops is enabled. As such, limiting the enablement
of the exception in cmdq mode to when manual bkops is
enabled yet auto bkops is not.
Change-Id: Icc158cf2c7a2dda6e8b9f1eee8a5924e14330d1f
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
The change in pull configs might not take into effect immediately
and any value read before it is stabilized will mark incorrect
card status. This causes SD card detection to fail when inserted
for the first time. Fix this by adding enough delay after
configuring the GPIO and before reading its value.
Change-Id: I3a8455ce404988ab5eb3ed04c0f90ab6edf76d86
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Pavan Anamula <pavana@codeaurora.org>
The shutdown handler waits for in-flight requests only.
It stops the block queue, but doesn't issue the already
queued requests to the LLD. Furthermore, a request which
is in the process of being queued will timeout eventually
because CQE would be halted by shutdown handler.
mmc_cmdq_thread(mct) -> pulls request (r1)
shutdown invoked
stops block queue
halts cqe
(mct) -> issues r1 to LLD
- pulls already issued requests
- CQE halted -> requeues request
- issued request (r1) times out
Hence, in shutdown handler
- stop the block layer queue
- set a state indicating shutdown
- wake up mmc_cmdqd
- mmc_cmdqd:
- pull requests and issue to LLD
- complete the issuing of already queued requests
- wake up shutdown handler
- wait for completion from mmc_cmdqd
- wait for all issued request to complete
- proceed with shutdown
Change-Id: I30a9664d8ba2f4b4f580c2cf71c5d01b735c9491
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
When sending CMD during data in HS400 Enhanced Strobe mode,
the command that is being sent is also sampled internally on
CMDIN line by the RCLK that is toggling due to the data traffic.
To mask this <false> CMDIN a new mask is introduced throughout
the CMD transmission time. This mask is controlled by
HC_VENDOR_SPECIFIC_FUNC3.CMDEN_HS400_INPUT_MASK_CNT register.
The default reset value of this register is 2.
Before running CMDQ transfers in HS400 Enhanced Strobe mode,
SW should write 3 to
HC_VENDOR_SPECIFIC_FUNC3.CMDEN_HS400_INPUT_MASK_CNT register.
Change-Id: If0467855e23cb93e57a4581b375885136902835d
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Provide sdhci host ops of enhanced strobe to notify
sdhci-msm on enabling/disabling cmdq. This is needed
because of following:
Before running CMDQ transfers in HS400 Enhanced Strobe mode,
SW should write 3 to
HC_VENDOR_SPECIFIC_FUNC3.CMDEN_HS400_INPUT_MASK_CNT register.
Default reset value of this register is 2.
Change-Id: I987605cd21f137dea49ddf3e8db3f1f41b5b501f
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Provide cmdq_host ops of enhanced strobe to notify
sdhci on enabling/disabling cmdq. This is needed
because of following:
Before running CMDQ transfers in HS400 Enhanced Strobe mode,
SW should write 3 to
HC_VENDOR_SPECIFIC_FUNC3.CMDEN_HS400_INPUT_MASK_CNT register.
Default reset value of this register is 2.
Change-Id: I36ead91ca8c9aeed967f120f8bdc3d2180af7746
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
After halting CQE, if other commands are sent in legacy mode,
the timeout would be modified as per the requirements of the
command. Upon unhalting, this timeout would still persist for
CQE too, which in some cases may lead to timeout.
Hence, change the timeout to 0xf i.e. max during unhalt.
Change-Id: Ifb0a1f4b9508c5884d381401216ae6c1373bb7de
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
This change adds usage for runtime PM for devfreq
context.
In case clock scaling is done from devfreq context its
best to vote for runtime PM to avoid race between
scaling and PM.
Change-Id: I6fc7e2236b44b1f3a322da36552a7f9237c4dac6
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
This change removes the error value (-EAGAIN) that
is returned in case of invalid state for clock scaling.
Invalid state for clock scaling doesn't mean its an error,
it merely means that at the current time we won't scale.
Devfreq will invoke scaling in next interval.
Change-Id: Idbd785da83e6ed00ede2b1b09529f7c81714ccf8
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
This change disables clock scaling in PM notification
for "prepare for system suspend".
This is needed because devfreq creates a dependency
between it and mmc which causes an issue for system suspend.
In this change we break this dependency in earlier stage.
Change-Id: I86dad94c77607b4e8f8fa67035323716f5eb197d
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
If eMMC is not a primary bootdevice, there isn't any point of probing
eMMC device hence disable the probing in such case.
Change-Id: I92fa8c2ef373fd8a9140dbfb41356684aaa28e4e
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Treat bus speed switch failures as error and don't fall back on
default speed. The card status could indicate that the current
function is busy and cannot be switched. Attempt to reinit the
bus speed switch again instead of falling back to default speed.
Silently falling back to lower speed could cause performance issues.
CRs-Fixed: 849567
Change-Id: I4fcd51b82e41746620a68a0a0eb5a18d630ccbea
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
This reverts commit 9cc95fde7c2c ("mmc: sdhci-msm: enable
clock scaling capability").
Clock scaling is breaking XO shutdown, keep the clock scaling
disabled till that issue is addressed.
Change-Id: Id4c530f8e2a8f565f9b957f46e5086078f808c96
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
As per eMMC specification, the PON (Power Off Notification)
must be sent by host to the card before turning off the power.
This will allow card to prepare itself for the power off and
may even reduce the initialization of eMMC upon next boot-up.
Send long PON during system power off and send short PON during
system reboot to reduce the reboot latency.
Change-Id: If4188b8b80aaa0e6c4e00e1807aa9589d5e7efdb
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Add support for handling both manual and auto
bkops when command queuing is running.
Change-Id: Ib967ca3c0420f4e54b3e93c497eb538d7347199a
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Following eMMC JEDEC JESD84-B51 standard, an ehannced form of
rpmb is supported. What this enhanced mode supports is in
addition to be able to write one rpmb or two rpmb frames at a
time, 32 frames can be written at a time.
Expose this information present in ext csd field so that the
user space application that wants to make use of this can do
so.
Change-Id: I53fd962fd7e04b5d2d7804c289d7865c2c5618d5
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
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>
Change ID I1333e1d4330393e446ba48a9474c83295744c050
added a call to the bus specific runtime_idle
callback. This callback is only implemented for mmc
thereby causing a crash when other types of memory
(e.g. sd card) are used.
This patch only calls the callback if it is implemented.
Change-Id: Ie26b1b52fdcc0f4d5e3638801e28e965fae0cbeb
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
It is needed to initialize auto bkops before enabling
command queueing since the initialization uses CMD6 which
may not be called when cmdq is enabled.
Change-Id: Idecff761754fe394c01425e7fd4dd5f6a083135d
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Qualcomm SDCC doesn't need NOP descriptor for End of
transfer (EOT).
This change insure that no NOP descriptor will be sent
in order to notify EOT, instead, the EOT will be marked for
the last descriptor.
Change-Id: Ia670bc901af2196a415c2aa54357704949a7b112
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
During halted CMDQ mode, HW expects descriptors sizes
same as used in CMDQ mode.
Our SW uses the legacy path (SDHCI) in case CMDQ is halted,
thus, we need to update legacy path of the fact that we
are in Halted CMDQ state so it can adjust the descriptors
size accordingly.
This change adds a notification mechanism for that purpose.
Change-Id: Iabb473696fb11827dfcce9b137c26b2c5a5a879d
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts & compilation
errors]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This change adds clock scaling ability to command-queueing
mode, it does so by adding next logic:
* Statistics collection for CMDQ data path
* Empty the queue and Halt it before frequency change
* Scale from data path in case host claiming is not possible
Change-Id: I53a323b55df4d7c27e3ee3426ee4e856e533522c
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
The BKOPS statistics are used for BKOPS unit tests and APT tests
to determine test success or failure.
The BKOPS statstics provide the following information:
The number of times BKOPS were issued according to its severity level
The number of times manual BKOPS was started/stopped (HPI)
The number of times auto BKOPS was enabled/disabled
In order to enable and reset the statistics:
echo 1 > /sys/kernel/debug/mmc0/mmc0:0001/bkops_stats
In order to disable the statistics:
echo 0 > /sys/kernel/debug/mmc0/mmc0:0001/bkops_stats
In order to view the statistics:
cat /sys/kernel/debug/mmc0/mmc0:0001/bkops_stats
Change-Id: Ib84319aedfb49dc022bc27efbda842a5db38c7e9
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
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>
Compatible list should be terminated with NULL entry, fix it.
Change-Id: Id9be4fa95fd1cbbbe28a3c63b63bbd6c8c29fa85
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Add support for manual and auto bkops for
legacy (not command-queue) mode.
Change-Id: I1333e1d4330393e446ba48a9474c83295744c050
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[subhashj@codeaurora.org: fixed merge conflicts and compilation
errors]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This commit changes the spinlock used by clock scaling
logic to use the bh flavor instead of irqsave.
This is done in order to avoid the unnecessary irq
disable while going into clock scaling critical sections.
Change-Id: Id660db89dc531336621f40908fd3a4ad4777a12d
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>