summaryrefslogtreecommitdiff
path: root/drivers
AgeCommit message (Collapse)Author
2016-05-31mmc: core: claim mmc host while enabling clock scaling from userspaceSujit Reddy Thumma
A race condition can occur while enabling clock scaling and removal of the card. If the card is removed just after the host->card check is successful then there could be NULL pointer dereference later. Claim mmc host before card availability check to avoid this race condition. Change-Id: I6339cad5857732ec6b66280940cd6b8b7ed30614 Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-31mmc: core: Add sysfs entries for dynamic control of clock scalingSujit Reddy Thumma
Add sysfs attributes to allow dynamic control of clock scaling parameters. These attributes are used to enable/disable clock scaling at runtime and change the up_threshold, down_threshold, and polling_interval values. Complete documentation for these sysfs entries are provided at "Documentation/mmc/mmc-dev-attrs.txt". Change-Id: I4753c75c3b3eeea91e93bceba7af2535b793612e Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org> Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: card: activate packing control only for eMMC4.5 cardsMaya Erez
Since the write packing is an eMMc4.5 feature, packing control should also be activated only for eMMc4.5 cards. Change-Id: If094658943a536f39afc814f6684c0dbb0806778 Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-31mmc: core: Add load based clock scaling supportSujit Reddy Thumma
The SD3.0/eMMC4.5/SDIO3.0 cards can support clock rates upto 200MHz (SDR104 or HS200 bus speed modes). For some workloads like video playback it isn't necessary for these cards to run at such high speed. Running at lower frequency, say 50MHz, in such cases can still meet the deadlines for data transfers. Scaling down the clock frequency dynamically has huge power savings not only because the bus is running at lower frequency but also has an advantage of scaling down the system core voltage, if supported. Provide an ondemand clock scaling support similar to cpufreq ondemand governor having two thresholds, up_threshold and down_threshold to decide whether to increase the frequency or scale it down respectively. The sampling interval is in the order of milliseconds and should be chosen by host drivers that enable MMC_CAP2_CLK_SCALE capability to take advantage of clock scaling. The sampling interval mainly depends on the the clock switching delays and hence a host driver decision. If sampling interval is too low frequent switching of frequencies can lead to high power consumption and if sampling interval is too high, the clock scaling logic would take long time to realize that the underlying hardware (controller and card) is busy and scale up the clocks. Change-Id: I22a5054beec41b0b66b3bf030ddfcf284de448b3 Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org> [merez@codeaurora.org: fixed conflicts due to changes in 3.14] Signed-off-by: Maya Erez <merez@codeaurora.org> [venkatg@codeaurora.org: runtime pm related changes to accommodate pm framework from 3.14 kernel] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org> [subhashj@codeaurora.org: fixed merge conflicts and fixed compilation errors] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: sdio: fix sdio_reset_comm() to take care of UHS card resetMaya Erez
sdio_reset_comm() function may be invoked by the SDIO card function driver to execute soft reset of the card but this function currently fails to reset the UHS SDIO cards. This change fixes this issue by simply invoking SDIO power restore function which is capable of resetting both UHS and non-UHS SDIO cards. CRs-Fixed: 424685 Change-Id: I4f1d76a6bfc4bfec16661aedba85c45b601f24ac Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [merez@codeaurora.org: fix trivial conflicts] Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-31mmc: card: re-run test because of timing issuesYaniv Gardi
Due to timing issues, the BKOPS test: Level 1 with HPI, might not yield the expected scenario. In this case we wouldn't like to have a FAILURE but to mark the test as a test that should be re-run. Change-Id: If47d7f9ce250c46249c5ddc061d8b808100d2f94 Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org> [merez@codeaurora.org: fix conflicts due to removal of BKOPS] Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-31mmc: relocation of print_mmc_packed_statsLee Susman
This function belongs to the file mmc_block_test.c since it is used only in this file. Change-Id: Ia832da6341b3053f0e4825d711668a3642482221 Signed-off-by: Lee Susman <lsusman@codeaurora.org>
2016-05-31mmc: block: Fix error handling of device attributes creationMaya Erez
When a failure occurs while creating a device attribute, we need to remove previously created attributes prior to deleting the disk. Change-Id: I01a8d4437f372abdf33230c34a73b5806e97188b Signed-off-by: Maya Erez <merez@codeaurora.org> [merez@codeaurora.org: fixed conflicts as BKOPS is not taken] Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-31mmc: card: Add eMMC4.5 packing control unit-testsTatyana Brokhman
Expose the packing control test. Test the packing control feature under these scenarios: - Packing expected: entering write packing state, staying in write packing state. - Packing not expected: not entering write packing state when not supposed to. - Mixed states: test the ability to shift from packing to no-packing and back, and the opposite. Change-Id: I5a93df8b5b7c48d355c3cc881699a3f9592914e6 Signed-off-by: Lee Susman <lsusman@codeaurora.org> Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
2016-05-31mmc: card: Add eMMC4.5 write packed commands unit-testsTatyana Brokhman
Expose the following packed commands tests: - Test the write packed commands list preparation - Simulate a returned error code - Send an invalid packed command to the card Change-Id: I23a15f94571da3ff9553a342dc37e1a8de6827c6 Signed-off-by: Lee Susman <lsusman@codeaurora.org> Signed-off-by: Maya Erez <merez@codeaurora.org> Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
2016-05-31mmc: card: Fix packing control enabling algorithmTatyana Brokhman
When hitting a stop potential packing event, we should zero num_of_potential_packed_wr_reqs, so that the packing won't be enabled too early. Change-Id: I91d36765c4a50be0e2805cd07c58962fb87153c6 Signed-off-by: Maya Erez <merez@codeaurora.org> Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
2016-05-31mmc: block: Add MMC write packing statisticsTatyana Brokhman
The write packing statistics are used for the packed commands unit tests in order to determine test success or failure Change-Id: I5eea513991c794543fbb3d009d8b7db0b0912fc5 Signed-off-by: Maya Erez <merez@codeaurora.org> Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: block: Add write packing controlTatyana Brokhman
The write packing control will ensure that read requests latency is not increased due to long write packed commands. The trigger for enabling the write packing is managing to pack several write requests. The number of potential packed requests that will trigger the packing can be configured via sysfs by writing the required value to: /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing. The trigger for disabling the write packing is fetching a read request. Change-Id: I22e8ab04cd9aca220678784c39306068a0996790 Signed-off-by: Maya Erez <merez@codeaurora.org> Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org> [merez@codeaurora.org: fixed trivial conflicts] Signed-off-by: Maya Erez <merez@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: block: do not query the sd card if a fault is injectedAsutosh Das
When the fault injection framework introduces an error to the data block, the current code queries the SD card to find the number of blocks actually programmed. This value would be as requested by the generic block layer. So the entire request would be completed. Say, request 0 is pulled from queue and submitted. When this is being processed, request 1 is pulled from queue and prepared. Request 0 though is successful, fault-injection framework injects an error and modifies the bytes_xferred variable to a random value less than requested transfer. Request 1 is not processed and during the handling of error, the SD card is queried for the actual bytes programmed. This would be the correct value. Thus blk_end_request would complete this request and the control would return to fetch request 2. In this process, request 1 is not processed at all and the application waits indefinitely for request 1 to be processed. No further requests are issued to the queue. This patch identifies, if the fault injection-framework has inserted an error to this request and doesn't query the card and uses bytes_xferred to complete the request. Change-Id: I496802e244745bc7550402027a594d967cf7b756 Signed-off-by: Asutosh Das <asutoshd@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31revert "mmc: core: Set correct bus mode before card init"Author: Stephen Boyd
This reverts the if/else part of 44669034815a7ad263542ac605c581a10b22d146. We don't know why it was done though and this should probably be dropped after testing. Change-Id: Ie453df2f62b6716c6c0aa83dd4822b8555c4e555 Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> [merez@codeaurora.org: fix conflicts] Signed-off-by: Maya Erez <merez@codeaurora.org> [subhashj@codeaurora.org: fixed merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: core: sdio: Ensure clocks are always enabled before host interactionSujit Reddy Thumma
Ensure clocks are always enabled before any interaction with the host controller driver. This makes sure that there is no race between host execution and the core layer turning off clocks in different context with clock gating framework. Change-Id: Ib47d0641f02c4390d26567102ee178beaf63516c Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Per Forlin <per.forlin@stericsson.com> Signed-off-by: Chris Ball <cjb@laptop.org> [sboyd: Keep non-upstreamed bits for sdio.c] Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
2016-05-31mmc: host: remove mmcq performance numbers statisticsSubhash Jadavani
mmcq performance numbers are not captured since asynchronous MMC request support got added in MMC block driver. So printing out these numbers (which are all zeros) just adds confusion. This patch removes the printing of mmcq performance numbers statistics. CRs-Fixed: 364206 Change-Id: I7213b11c8e9e055894c9902af7e975de3be1c519 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: core: Remove BROKEN_CLK_GATING quirk for AR6003 cardsKrishna Konda
MMC_CLKGATE feature can be enabled for Atheros AR6003 cards as the host supports asynchronous acitivity notification when the clocks are off. Change-Id: Ieff00382894a0841496776dc6a6b1db53e204d6d Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
2016-05-31mmc: quirks: Fix data timeout values for certain SanDisk eMMC cardsPratibhasagar V
Some INAND MCP devices advertise incorrect data timeout values. This leads to data timeout errors on the platform. So, add a quirk for such devices to facilitate proper functionality. CRs-Fixed: 355347 Change-Id: If4fdd2724dc407450da8529222efca7ee94f50df Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org> [merez@codeaurora.org: fix num of quirk to an additional quirk on 3.14] Signed-off-by: Maya Erez <merez@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: mmc_test: Fix possible NULL pointer dereferenceSujit Reddy Thumma
test->highmem can be NULL if no page can be allocated. In this case don't try to free it which can cause NULL pointer dereference crash. Change-Id: I6c31a265fd801dfc4169530e3f39ffcf6590f5a8 Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-31mmc: core: capture performance numbers only when askedSubhash Jadavani
Currently performance numbers are captured for each SDCC transfers unconditionally which may add the overhead and could reduce the SDCC read/write throughput numbers. This change adds additional control for enabling/disabling the capturing of performance numbers at runtime. We already have sysfs entry named "perf" for msm sdcc devices. Currently setting this entry to 0 clears the performance statistics. But now we are changing the definition of this entry as mentioned below: Disable performance capturing and clear the performance statistics: "echo 0 > /sys/devices/platform/msm_sdcc.<n>/perf" Enable performance capturing: "echo 1 > /sys/devices/platform/msm_sdcc.<n>/perf" CRs-fixed: 345170 Change-Id: I3ab9288fd87cc8a8ada6c0c3d066cac4f68d79b7 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: Add profiling code to measure performance at MMC layers.Aparna Mallavarapu
Profiling code is added to measure read, write times for the MMC requests at various MMC layers. Profiling is done at the MMC queue and at the driver level. This information can be viewed through a sysfs entry called perf. Change-Id: I7c65bfe25a1f7774e3a9abf1f9539e690b3718ec Signed-off-by: Aparna Mallavarapu <aparnam@codeaurora.org> Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflict] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: core: Remove BROKEN_CLK_GATING quirk for WCN1314 cardsSujit Reddy Thumma
MMC_CLKGATE feature can be enabled for Volans cards as the host supports asynchronous acitivity notification when the clocks are off. Change-Id: Ic6cfa7fb2e713dcf1d2c6b2ae9df9cf0394f8c4a Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org> [merez@codeaurora.org: fix trivial conflicts] Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-31mmc: core: Export mmc_set_ios so that host drivers can use itSujit Reddy Thumma
mmc_set_ios() is used by host drivers during suspend/resume routines in indirect way i.e., by calling host->ops->set_ios(). But now with MMC_CLKGATE enabled, mmc_set_ios() also updates host->clk_gated flag. So export this API so that host controller drivers can use it. Change-Id: Ib0c177635bb8d87ba68c98e08b8d940c73f2b80c Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org> [merez@codeaurora.org: fix trivial conflicts] Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-31mmc: sd: fix the issue with paranoid SD card init retrySubhash Jadavani
mmc_resume_host() is called during resume (runtime or system) which calls 1. mmc_power_up 2. mmc_select_voltage 3. host->bus_ops->resume() (mmc_sd_resume()) mmc_sd_resume() ultimately calls mmc_sd_init_card() to initialize the SD card. But let's say if mmc_sd_init_card() fails during the execute_tuning(). At this point, host controller timing is changed to SDR104/SDR50 mode and host clock will also be > 100 MHz. If there is an error returned by mmc_sd_init_card() and if CONFIG_MMC_PARANOID_SD_INIT defined, it retries by calling mmc_sd_init_card() without making sure that host controller timing and clock be initialized again. This may cause the further mmc_sd_init_card() also to fail. To fix this, mmc_sd_resume() should call mmc_power_up() and mmc_select_voltage() before retrying. Change-Id: I8de39ea547fa0d5eca478719a4cf9255b6652503 [merez@codeaurora.org: changes already present in core.h and core.c] Signed-off-by: Maya Erez <merez@codeaurora.org> [venkatg@codeaurora.org: Fix args for mmc_power_up and mmc_select_voltage as used in 3.14 kernel] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org> [subhashj@codeaurora.org: fixed merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: msm_sdcc: Fix deadlock in mmc_suspend_host and mmc_rescanSujit Reddy Thumma
SDCC runtime suspend can race with mmc_rescan causing deadlock. The call flow would be this: 1) When runtime suspend is triggered: msmsdcc_runtime_suspend() -> mmc_suspend_host() -> mmc_flush_scheduled_work() 2) mmc_flush_schedule_work() waits for mmc_rescan() work to be completed if it is already in runqueue. 3) When mmc_rescan() is scheduled to run: mmc_claim_host() -> msmsdcc_enable() ->pm_runtime_get_sync() 4) pm_runtime_get_sync() waits for runtime_suspend to complete, and hence cause two threads to wait upon each other. Fix this deadlock by aborting runtime suspend when mmc_rescan is scheduled. CRs-Fixed: 326610 Change-Id: I4ca88651f80f5a1bfccb6e0c07e3ea83fadcdc57 Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-31mmc: core: Use usleep_range for delays less than 20msSujit Reddy Thumma
msleep of any delay less than 20ms (or 2 jiffies) would give an unpredictable delay (most of the times as ~20ms). Use usleep_range in mmc_delay() for delays less than two jiffies. Change-Id: I7cf22532af2b4048afccf07a5aeba89d808799f0 Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-31mmc: Fixing few warning messages.Pratibhasagar V
CRs-Fixed: 313388 Change-Id: Ibf8ec6bc9eb7adff9bb6ac6af2a2f1af33a76bb8 Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>
2016-05-31mmc: core: Skip frequency retries for SDCC slotsSujith Reddy Thumma
Qualcomm SDCC controller supports minimum SD clock frequency which is required for card initialization. This information is exported through platform data for each SDCC controller. There is no need of retrying higher frequencies than the minimum supported by controller for Qualcomm chipsets which inturn add delay in detection process if there is no card during suspend/resume cycles. Hence, skip multiple frequency retries. Change-Id: If1532213aaf265bdb4f5ddf68d9f70005ed97037 Signed-off-by: Sujith Reddy Thumma <sthumma@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflicts and compilation error] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: core: Claim host while freeing cardSujith Reddy Thumma
When SD/MMC card is removed without unmounting and then reinserted again while gendisk is freed. Partition invalidation and deletion may take more than 10secs during which SDCC controller can suspend due to runtime pm functionality. Once the block layer activity is done it claims host to detach card from MMC bus which triggers SDCC resume. As the host->card is NULL already there is a BUG_ON hit in mmc_sd_resume(). Fix this by claiming host even before we free host->card. CRs-Fixed: 284262 Signed-off-by: Sujith Reddy Thumma <sthumma@codeaurora.org> (cherry picked from commit 5eed6a9778440ef512f597b43368337a7ef9438b) Change-Id: I6b58aab1865a93a025fd9912200ab0beea21be92 Signed-off-by: Shruthi Krishna <skrish@codeaurora.org> Signed-off-by: David Brown <davidb@codeaurora.org>
2016-05-31mmc: core: Determine correct access mode for eMMC cards by reading OCRSujith Reddy Thumma
MMC core reads SEC_COUNT information from EXT_CSD register and assumes that the card supports sector access mode. Some eMMC cards (<=2GB) do not support this mode even though they have SEC_COUNT value defined, causing failure while populating extended partitions. Sector/Byte access mode information is stored in OCR register. Hence, read OCR bit 30 and then confirm it with SEC_COUNT value to know whether the card supports sector access mode or byte access mode. Change-Id: Ifdfff35309e8667cd2c2ac2761b9a708d5b785d3 Signed-off-by: Sujith Reddy Thumma <sthumma@codeaurora.org>
2016-05-31mmc: core: Add 8-bit support for SDIOSahitya Tummala
Depending on the host and card's capability SDIO cards can operate at 8-bit buswidth. Change-Id: I2ed1c5ecaff521db693db47928b0958ed0289645 Signed-off-by: Sahitya Tummala <stummala@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: sdio: Fix sdio_disable_wide to properly handle 8 bit bus width.Murali Palnati
Change-Id: I2e712f5d8f6ff8da9fdabe8cf30e378c560e067f Signed-off-by: Murali Palnati <palnatim@codeaurora.org>
2016-05-31mmc: core: Workaround to fix a hardware bug in Qualcomm-SDIO client on MDMMaya Erez
Qualcomm-SDIO client on MDM contains NULL tuple for all SDIO functions 1 to 7 and doesn't contain any valid data. This patch is a temporary software workaround (not to read CIS if it is NULL tuple) until the hardware bug is resolved. The device ID 0x23F0 is for the SDIO client core on MDM8220. The device ID 0x23F1 is used for msm8660_charm. Change-Id: I82f44d313b3d499462977a0a9bbc0759f489ae95 Signed-off-by: Maya Erez <merez@codeaurora.org> Signed-off-by: Murali Palnati <palnatim@codeaurora.org> Signed-off-by: Raj Kushwaha <rajk@codeaurora.org> [sboyd: Squash in two other device id patches] Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
2016-05-31mmc: core: Fix race between runtime PM suspend and block requestsSujith Reddy Thumma
There is a possible race with mmc_claim_host() in mmc_sd_suspend()/ mmc_suspend() and mmc_claim_host() in mmc_blk_issue_rq() when runtime pm is enabled. Fix this by blocking processing of requests until the previous runtime suspend is processed and then resume as part of msmsdcc_enable(). Previous fix has card detection failure as a side effect during resume. Change-Id: I9cb31269638d9db4e630eb22b973a5335af1bda4 Signed-off-by: Sujith Reddy Thumma <sthumma@codeaurora.org> [sboyd: Dropped msm driver change] Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflict] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: core: Fix bustest timeout valueSahitya Tummala
The current code doesn't set any timeout value for bus test commands CMD19 and CMD14. This fails bus test because the controller returns DATATIMEOUT error for these commands. Fix the bus test timeout value to 1ms for all cards. Change-Id: I12446e094302f51853cc0c56a5c13b4a6a46d8cb Signed-off-by: Sahitya Tummala <stummala@codeaurora.org> [merez@codeaurora.org: fix conflict due to change of code] Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-31mmc: core: Fix MMC clock scaling in case of tuning failureSahitya Tummala
When the clock scaling state is changed from MMC_LOAD_LOW to MMC_LOAD_HIGH, the clocks are first scaled up and then tuning is performed. But in case of tuning failure, the current code does nothing but still retain the previous clock scale stats (state and curr_freq within struct clk_scaling). Hence, correct it to scale down the clocks in case of tuning failure so that clock scaling stats reflect the correct status. This also helps proceed with data transfers at lower clock rate in such cases. Change-Id: I7e9379d1e3ddc863132af31019604c22a42f8d59 Signed-off-by: Sahitya Tummala <stummala@codeaurora.org> [subhashj@codeaurora.org: fixed compilation error] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31mmc: core: hpi in TRAN state error handlingKonstantin Dorfman
There could be a race condition in the stop transmission request. 1. Urgent read request comes in. 2. Stop the ongoing write request by calling stop_request MMC host op. 3. Send the stop command (CMD12) to move the card from the receive state to programming state. 4. Send the status command (CMD13) to know if the card is in programming state or not. If yes, then go to step.5 or else go to step.6. 5. Send the HPI command to bring the card out of programming state. 6. Now send the urgent read request. In above sequence in step.4, we check if the card is in programming or not and if it is then we go ahead and send the HPI in step.5 but what if after step.4 is completed and before the step.5, card moves out of the programming state so in that case HPI command would timeout as we are sending it in the wrong state. In that case no command response (by eMMC protocol) causes mmc_send_hpi_cmd to fail (with -ETIMEOUT error). In case the card indeed in TRAN state, no error is reported. Change-Id: Ia6f81f6cc4ec933f2e8423029f7236401aea04df Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2016-05-31mmc: core: fix issue with HPI polling timeoutKonstantin Dorfman
Out of CPU time for the MMC context included into measured timeout. System under heavy load will easily exceed out_of_int_time (typically 20 ms), because the MMC context is not running and when it is back to running, timeout already elapsed. In this case real card status checked again and error reported for wrong card state only. Change-Id: I0da3bd2e7d41e4933ad3b1333d7135705a1eafec Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org> Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-31mmc: core: export mmc_host_may_gate_card functionSubhash Jadavani
MMC Host driver might want to use the mmc_host_may_gate_card() API to know whether the clock can be gated to the card or not hence export this function for usage outside its current scope. Change-Id: I9ec4173063e2505eca179161cdf8cda033a3fd4b Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [merez@codeaurora.org: fix trivial conflicts] Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-31mmc: sd: Set the card removed if card detect failsAsutosh Das
Currently, the card state is not being set as removed, even when the card is actually removed. We still wait for the next request to fail and then check the error and set the card to be removed. With the new runtime-pm in place, the card device would be removed on physical removal of card and the corresponding parent would be suspended as well. Hence, when the queue is flushed during clean-up, mmc_rpm_hold would be invoked, which would fail, since the runtime-pm was disabled when the card device was removed. Thus, it won't resume the card/host/ platform device. The request would continue and since the controller is in suspended state nasty things would happen. This patch sets the card as removed during mmc_sd_detect itself, so that when a clean-up of queue happens during card removal, it is known that the card has been removed and the request is errored out there itself. Change-Id: Id5022f8d7db43750edf137d4293796615b56ae36 Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-05-31mmc: card: abort the suspend if the card is busySubhash Jadavani
mmc_blk_suspend() is triggered when system is going into suspend which then waits for the mmcqd thread (which processes active MMC transfer requests) to complete all queued transfer requests but if mmcqd has multiple requests to be processed at this point, mmc_blk_suspend() may very well sleep for duration longer than DPM (Device Power Management) timeout (currently 12 sec) causing the DPM timeout bug. To fix this issue, mmc_blk_suspend() checks if there are any more pending MMC requests in progress or not and if there are any, it returns error which should abort the ongoing system suspend. CRs-Fixed: 439192 Change-Id: Ic7ba2f013d10a1952c30ea2ed93f74b831fcc27d [subhashj@codeaurora.org: fixed trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27mmc: core: Add a debugfs entry to set max clock rateSujit Reddy Thumma
Limiting the max frequency supported by host controller to a certain value can be useful for testing power consumption at various frequencies that are supported by the host. Note: If the card supports less than desired value then the frequency of operation would be limited to that frequency. Usage: mount -t debugfs none /sys/kernel/debug echo <desired_frequency> > /sys/kernel/debug/mmcX/max_clock cat /sys/kernel/debug/mmcX/max_clock Change-Id: I9e9a7e368f56d8e16548780288211bd8775fd048 Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-27mmc: core: Allow changing bus frequency for SD/eMMC cards in runtimeSujit Reddy Thumma
Currently, bus frequency is set during the card initialization and never changed until a new card is inserted. In some low power use cases, scaling the clock frequencies while the card is in transfer state would allow power savings. This change allows bus frequency to be changed after the card initialization. Change-Id: Iac064221199f69d162d91f5311becd735c15700a Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org> [merez@codeaurora.org: remove mmc and sd ops_unsafe settings as they are not in 3.14] Signed-off-by: Maya Erez <merez@codeaurora.org> [venkatg@codeaurora.org: Fix refactor of mmc_card_* functions as used in 3.14 kernel] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflicts & fixed compilation error] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27mmc: core: Attribute the IO wait time properly in mmc_wait_for_req_done()Subhash Jadavani
In mmc_wait_for_req_done() function, change the call wait_for_completion() to wait_for_compltion_io(). This change makes the kernel account for wait time as I/O wait and through another configuration, this io wait is treated as busy which makes the acpu clock to scale up. Change-Id: Iebdc7b1b22871bf845f10a55e2272816c72d9964 Signed-off-by: Murali Palnati <palnatim@codeaurora.org> Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27mmc: sdhci: rate limit sdhci_dumpregs() printsSahitya Tummala
Rate limit sdhci_dumpregs() prints to avoid unnecessary and exessive logging which can sometimes lead to watchdog timeouts (especially due to bad cards). Change-Id: Ib6be6d563e47c2d2e9e1b6b0410c2c45712a9b17 Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27mmc: host: sdhci: allow definition of pm QoS via dts fileMaya Erez
Add a new dts entry to define the CPU affinity in order to maintain the IRQ pm_qos (Quality of Service) for targets that don't have little cluster and allow setting the pm_qos to the little cluster, to improve its performance. Change-Id: Icf6125066d96331392d98a387974e54c96553306 Signed-off-by: Vince Leung <vincentl@codeaurora.org> Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-27mmc: sdhci-msm: force 32bit ADMA descriptorsGilad Broner
SDCC AXI master uses 32-bit addressing so there's no need to use 64-bit descriptors. Using 32-bit descriptors instead will reduce the memory footprint. This change masks the 64-bit capability to force 32-bit ADMA descriptors. CRs-Fixed: 719303 Change-Id: Ifb8095763136bbc795227bdfcb346d1e1fae42c7 Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-05-27mmc: sdhci-msm: Add dual voltage capabilityVenkat Gopalakrishnan
SDCC5 controller doesn't advertise 1.8v capability by default. Dual voltage capability is required for SD3.0 support. Add this capability for controllers that support this based on device tree configuration. Change-Id: Ie4cd6db2e7230bc22cd393c8e37d99f49c777cd0 Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-05-27mmc: sdhci-msm: add nonhotplug supportGuoping Yu
With some devices like QRD SKUK, SD card could not support hotplug as there is no cd-gpio, and also could not use polling way due to power comsumption. So add nonhotplug to meet such requirement and when SD card lost or removed manually, device will not crash until next reboot process to detect SD card. Change-Id: I318d3db72fc09248c5dada2fb6d69ade1bbf85cb Signed-off-by: Guoping Yu <guopingy@codeaurora.org>