In case error is actually being injected by the error injecting framework,
we would like to be able to tell the error code index as well as the
error code value.
So inspecting the debug messages and see error index would help
isolating a desired error code (via debugfs command) and testing
it specifically.
Change-Id: I624fd5ca55f21fe7c31a80e8ec2e4f8982b7f909
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
This change adds a debugfs capability to initiate a reset and restore
procedure to the UFS controller by executing:
echo 1 > /sys/kernel/debug/ufshcd0/reset_controller
This capability is necessary for testing purposes of the the reset
and restore procedure.
Change-Id: I126e2d80d2ac63be6107aee29fa03dce4f56e83a
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
This change adds interrupt error injection.
It also modifies the logic of interrupt error injection scenario
to support the UFS fault injection generic framework.
Change-Id: Ibdcd4f875fccbc359a92c71d088a06440fe22082
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
This change adds a few debugfs options for the UFS fault injection
framework.
"err_inj_scenario" entry - to enable/disable error scenarios.
"err_inj_codes" entry - to control specific error codes for a specific
error scenario.
usage:
echo 0x5 > /sys/kernel/debug/ufshcd0/err_inj_scenario
as 0x5 is b0101, it sets bits #0 and #2 of err_inj_scenario_mask.
echo "2, 0x7" > /sys/kernel/debug/ufshcd0/err_inj_codes
sets error codes b0111 for error scenario #2
Change-Id: I0c58886a1ffac4dc85d8827bf69d650082a03fc5
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
If both host and device support UniPro Specification v1.6 then many of the
important UniPro timing parameters are auto tuned after the link start up.
But due to SW bug these auto tuned parameters might get overwritten, this
change fixes the issue by properly checking the UniPro specifcation
version.
Change-Id: I152d5dcfac0bc0f8a5dc6b1e7267e254ec0d5d80
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Few Toshiba UFS device models advertise RX_MIN_ACTIVATETIME_CAPABILITY as
600us which may not be enough for reliable hibern8 exit hardware sequence
from UFS device.
To workaround this issue, host should set its PA_TACTIVATE time to 1ms even
if device advertises RX_MIN_ACTIVATETIME_CAPABILITY less than 1ms.
Change-Id: I91d0fcdecbcd3294a6a67556b5bf1c7d2636cff1
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Perform PHY and controller hard reset to recover from
hibern8 exit failure.
This requires full initialization of the PHY and the controller
before issuing link start-up.
Change-Id: I93c5f896d86eb74a1ef490e3e14ae796082888cf
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This change fixes the compilation errors seen when DEBUG_FS is disabled.
Change-Id: I15ba780ddfd3f6238bdd0434f1769c2986ec832f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
We are seeing that some devices are raising the urgent bkops exception
events even when BKOPS status doesn't indicate performace impacted or
critical. Handle these device by determining their urgent bkops status
at runtime.
Change-Id: I0392c6d1f1ca820026906dac91beba7c8719edc8
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Add range check on tag statistics array index to avoid a potential
situation where the array index is out-of-bounds in case
TS_NOT_SUPPORTED is returned as the index.
Change-Id: Ib35fd0abe9553f6ea259efd2f98c7a4ef490d6ed
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
When ufshcd_host_reset_and_restore() is called, it is possible
that ufshcd_probe_hba() fails and return an error value.
However, the later call to crypto_engine_reset() might succeed
and override the previous error value.
This will result in ufshcd_host_reset_and_restore() returning
success while in fact a serious error may have occured which
should prevent us from continuing in the normal sequence.
Instead, call crypto_engine_reset() only if ufshcd_probe_hba()
was successfull.
Change-Id: I0462f674b8750bfb9e0657cb37833aa2bd2aa4f0
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
Commit 4f98a9564b745f3b0b1bea02d351c9f8f2f17d39 (scsi: ufs: fix race
between clock gating and scaling work) tried to fix the race condition
between clock gating and scaling work but it didn't fixed the race in
all possible states. This change fixes the race condition by making
sure that we hold the clock reference even if clocks are ON when we
entered into clock scaling work.
Change-Id: Ic3cf9224f5afb2900fe2553ce8c302cc8b20e623
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
We print the ERROR level log message for every gear switch which would
generally end up in serial console but clock scaling also does gear
switch and these gear switch log messages might clutter the kernel logs
unnecessarily hence this change avoids printing gear switch log messages
during clock scaling.
Change-Id: If1079bbff633c3270ddae8579801d1f265707254
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This reverts commit a08f72e5e1453acac1d3fd50a4ed314ea5ff643c. This
commit was added to workaround the issue seen with particular UFS device
vendor. As this issue is already fixed by UFS device vendor, we no longer
needs this workaround hence reverting the original patch.
Change-Id: Ib2fd45a893042053eee18fe93554e7b02c4732c6
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Clock scaling polling time window is currently 100ms which is more than
the clock gating time which is 50ms and during clock gating, clock scaling
logic would be disabled. This may make the clocks to remain scaled down
for longer period of time, fix this by reducing the clock scaling polling
window less than clock gating timeout.
Change-Id: I8365470c7a6bd4950c1decbd418272359475c366
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This reverts commit 5f84d7bb3056bd62e6bcc7b6b9801436a49d9a52.
There was possible race condition between clock scaling and clock gating
work hence clock scaling was disabled until proper fix for the race
condition is found. Now that race condition is properly fixed, this commit
is reverted back.
Change-Id: I1d2e7be89cd5bb36c37ffe26a1f2606c0800c434
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
UFS Clock scaling work may change the UFS gear mode as well which requires
holding the vote for UFS clocks but if UFS clock gating work is running
at the same time, it may end up waiting for UFS clock scaling work to
finish hence enters into deadlock state. Here is the call stack for this
deadlock state:
Clock scaling work:
__schedule()
schedule()
schedule_timeout()
do_wait_for_common(inline)
__wait_for_common(inline)
wait_for_common()
wait_for_completion()
flush_work()
ufshcd_hold()
ufshcd_pm_qos_hold(inline)
ufshcd_hold_all()
ufshcd_wait_for_doorbell_clr()
ufshcd_scale_gear()
ufshcd_devfreq_scale(inline)
ufshcd_devfreq_target()
update_devfreq()
devfreq_monitor()
static_key_false(inline)
trace_workqueue_execute_end(inline)
process_one_work()
worker_thread()
kthread()
Clock gating work:
__schedule()
schedule()
schedule_preempt_disabled()
__mutex_lock_common(inline)
__mutex_lock_slowpath()
current_thread_info(inline)
mutex_set_owner(inline)
mutex_lock()
devfreq_monitor_resume()
devfreq_simple_ondemand_handler()
devfreq_resume_device()
ufshcd_ungate_work()
static_key_false(inline)
trace_workqueue_execute_end(inline)
process_one_work()
process_scheduled_works(inline)
worker_thread()
kthread()
This change avoids this deadlock by cancelling the clock gating work before
voting for clocks in clock scaling work.
Change-Id: Icae8762282fc10032ae9bb823ab9f5de9912b2e5
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
spin_lock_irq() / spin_unlock_irq() is used so interrupts are
enabled after unlocking the spinlock. However, it is not guaranteed
they were enabled before.
This change uses the proper irqsave / irqrestore variants instead.
Without it, a spinlock recursion on the scsi request completion path
is possible if completion interrupt occurs.
Change-Id: If5a001f195466f85e50df6ce23fd1e10851c5e2b
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Since "major", "minor" and "step" are now being saved in
struct ufs_qcom_host, there is no need to call
ufs_qcom_get_controller_revision() here. In addition, those local
variables are not in use in this routine.
Change-Id: I2606f87fc5e54b45a86240c1bccdd8c47009e11a
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Instead of assigning a value to the variable pointed to by
ice_status, the ice_status pointer is changed to NULL. This
is incorrect and this change fixes that error.
Change-Id: I10516635c73cd459341991a4c6f11c0ed6bda71f
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
This change extends the UFS fault injection framework.
It defines multiple fault injection scenarios, and data structures
that hold optional error codes for each error scenario.
When error is being injected, an error code is being randomly chosen
from the enabled error codes.
Change-Id: Id844c765f9fd3590f86f9ae0efdb43d275bdb646
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Use the user-defined sector_range instead of the previously hard-coded
TEST_MAX_SECTOR_RANGE. If the user does not supply a sector_range, this
variable will default to 512MiB.
For the long sequential tests, sector_range will define the size of the
sequential I/O to submit. For the long random tests, sector_range will
define the range in which to submit random I/O as well as the total size
of the random I/O which is defined by the combination of sector_range and
LONG_RAND_TEST_REQ_RATIO.
Change-Id: Ifc7332e6def75c49448aadbebd35b7b9b3903447
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Unit tests submit large requests of 512KB made of 128 bios.
Current allocation was done via kmalloc which may not be able
to allocate such a large buffer which is also physically contiguous.
Using kmalloc to allocate each bio separately is also problematic as
it might not be page aligned. Some bio may end up using more than a
single memory segment which will fail the mapping of the bios to
the request which supports up to 128 physical segments.
To avoid such failure, allocate a separate page for each bio
(bio size is single page size).
Change-Id: Id0da394d458942e093d924bc7aa23aa3231cdca7
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: dropped block/test-iosched and mmc_test
related changes]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Current test-iosched design enables running only a single test
for a single block device.
This change modifies the test-iosched framework to allow running
several tests on several block devices.
Change-Id: I051d842733873488b64e89053d9c4e30e1249870
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[merez@codeaurora.org: fix conflicts due to removal of BKOPs UT]
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[venkatg@codeaurora.org: dropped block/test-iosched and mmc_test
related changes]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Multi-query test fails on write descriptor requests becuase it
tries to write to the unit descriptor which is read-only according
to the spec.
The only writeable descriptors are the configuration and OEM ID
string descriptors which will be non-trivial to use.
Avoid sending write descriptor query for the time being, and replace
it with a read descriptor operation.
Change-Id: Ic121d9ff20f144e724df5436f9dbd44cde72e97d
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
It was found that the UFS unit tests fail when they are run on an external
UFS device. This happens when the external UFS device is suspended while
running the unit-tests, and the un-natural flow of test-iosched does
not resume the UFS driver and device in the correct manner.
We solve this by using the block layer power management API for running
the request queue, as well as explicitly resuming the device before
running the unit-tests.
Change-Id: I8273d4dd4f32e91bad28c019c159696cf8fabb42
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
This testcase checks data integrity in a random I/O usecase.
The test writes QUEUE_MAX_REQUESTS (usually 118) requests of size 4KB
to randomly and uniquely chosen LBAs. A different pattern is written
to each LBA (pattern written is index of LBA). After successfully writing,
the test reads from the above LBAs and verifies the pattern.
Change-Id: I09c6dda12834f06ae393411501f443bfd058dea4
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
The UFS tests are used for testing the functionality and performance
of the UFS driver. In some of the tests ufs_test uses several scsi
and UFS APIs for getting the disc information and sending UFS
specific commands.
The used APIs should be exposed in order to allow compilation
of ufs_test as a module.
Change-Id: I1263429bd3d5172af3b5552f0b8b503e32a04e51
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Adding a new access api for gendisk without using scsi private
headers.
This patch fixes multiple errors:
1. Relative include path in ufs_test.c to <../sd.h>
2. Allowing suspend after first test run.
Change-Id: I152d34667ab63790b643abb55111fc5b67c90ac9
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[merez@codeaurora.org: fix trivial conflicts in ufs_test.c]
Signed-off-by: Maya Erez <merez@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts,
use scsi_disk_get instead of __scsi_disk_get]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Add missing test name strings to long random tests.
These test names are used to distinguish between test case when running
automatic tests.
Change-Id: I1d375eb3cfdd2ae645ba086b7e3121026f3652ae
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
Currently, request sector is incremented in the long sequential test
using a calculation which assumes the device logical block size is
512B (equal to sector size) but this is not the case.
This patch changes the calculation to be correct, using the test bio size,
and assuming sector size is 512B.
Change-Id: I807be243b65834edf9201488a849777e43bb658a
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Generalize the long_sequential_test framework to execute long random read
and long random write tests as well.
The random tests submit a large number of 4KB requests to randomly chosen
LBAs. Currently the tests are defined to read/write 64MB.
Change-Id: I9d797c0d61d863b2a9fbcd593a1be9065202ef76
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
[merez@codeaurora.org: fix trivial conflicts]
Signed-off-by: Maya Erez <merez@codeaurora.org>
This patch adds a completion condition to the long sequential unit test.
The condition is the completion of ALL the requests that where created.
Before this condition, the calculated test throughput was not accurate
since the transfered size was not constant.
This patch also increases the request size to the maximum - 128 bios.
In addition, the calculated throughput is always printed to the log.
Change-Id: Ibc16dc60486ff2b58cbc8ce02aee2ad87fea7ba1
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
This patch fixes the ufs unit test case "lun_depth" to work properly.
In cases where nutrs == lun_qdepth, 0 was an argument for the random
number generating function, which returned bogus numbers as a result.
In this patch we distinguish between equality and inequality cases, where
in the equality case we remove the irrelevant test cases.
Change-Id: Id7967e894e9d4d0fa1e250852895debcefcbf818
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
This patch fixes the ufs unit test case "parallel_read_write_test"
to work properly. Changes are mainly in the logic deciding on the toggle
of request direction.
Change-Id: I3ba60421de1afb05dca780d82fcf10b9910a0bc1
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
Match new unit descriptor size definition.
Update logging with:
- prefix with module name
- add '\n' in the end
- test_pr_* removed
Change-Id: Ic086f9b62c5431ba85a667b771e930ea96d253e0
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
This test is trying to stress the edge cases of the UFS device queue.
This queue has two such edges, the total queue depth and the command per
LU. To test those edges properly, two deviations from the edge in addition
to the edge are tested as well. One deviation will be fixed (1), and the
second will be picked randomly.
The test will fill a request queue with random read requests. The amount
of request will vary each iteration and will be either the one of the
edges or the sum of this edge with one deviations.
Only reads or only writes will be tested within each iteration.
Change-Id: Ib02a63b2c8d6898f01e418a617ccc79eba67dab5
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Tests stability on scenarios of multiple threads running random reads
and random writes.
The test introduces the infrastructure for more complex multi-threaded
tests.
Change-Id: I3775f61c65d90d093e4a5b9a9a3e6724f68b5185
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Sends parallel queries with a pseudo random command. The test sends 33
queries, to make sure at least the queue depth is reached.
It tests stability in case of multiple queries.
Change-Id: I00f5992b495d17696d2ae50b510253a96ce5c979
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[merez@codeaurora.org: fix conflicts due to exiting changes in 3.14]
Signed-off-by: Maya Erez <merez@codeaurora.org>
The test will verify correctness of sequential data pattern
written to the device while new data (with same pattern) is
written simultaneously.
First this test will run a long sequential write scenario.
This first stage will write the pattern that will be read
later. Second, sequential read requests will read and
compare the same data. The second stage reads, will issue in
Parallel to write requests with the same LBA and size.
NOTE: The test requires a long timeout.
The purpose of this test is to mix read and write requests on the same
LBA while checking for the read data correctness.
Change-Id: I6a437ce689b66233af3055d07a7f62f1e7b40765
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[venkatg@codeaurora.org: dropped block/test-iosched changes]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Introduce a new callback 'check_test_completion_fn' to test-iosched
framework. This callback is necessary to determine if a test has
completed or not in situation where the request queue is empty, but the
test was not completed.
Change-Id: I60bd8cccffacab11a5a7cba78caccf53fea3e1d8
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[venkatg@codeaurora.org: dropped block/test-iosched changes]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
This test adds the ability to test the UFS task management feature
in the driver. It loads the queue with requests in order to allow
the task management to operate in full capacity.
Modify test-iosched infrastructure to support the new tests:
- expose check_test_completion()
Note: we submit 16-bio requests since the current HW is very slow
and we don't want to exceed the timeout duration.
Change-Id: I8ee752cba3c6838d8edc05747fa0288c4b347ef6
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
[merez@codeaurora.org: fix trivial conflicts in ufs_test.c]
Signed-off-by: Maya Erez <merez@codeaurora.org>
[venkatg@codeaurora.org: dropped test-iosched changes]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
There is possible race condition between clock scaling and clock gating
work, disabling clock scaling until proper fix for the race condition is
found.
Change-Id: Id5c65ac3454f51164d84c033c1e0a56dee951120
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Running static code analysis tools on the UFS driver code reported
a few issues: non-static functions, usage of pointer after is it freed
and non-initialized variable.
This change fixes these issues.
Change-Id: I0bcc11b057033866fff07a70754fa1751dbc729c
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts, skipped changes
to ufs_test.c]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
A race condition exists between request requeueing and scsi layer
error handling:
When UFS driver queuecommand returns a busy status for a request,
it will be requeued and its tag will be freed and set to -1.
At the same time it is possible that the request will timeout and
scsi layer will start error handling for it. The scsi layer reuses
the request and its tag to send error related commands to the device,
however its tag is no longer valid.
As this request was never really sent to the device, there is no
point to start error handling with the device.
Implement the scsi error handling timeout callback and bypass SCSI
error handling for request that were not actually sent to the device.
For such requests simply reset the block layer timer. Otherwise, let
SCSI layer perform the usual error handling.
Change-Id: Iebed05c95a61f7dcf0a177e5c371b6575ead54d8
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
UFS flag query requests may fail sometimes due to timeouts etc.
Add a wrapper function to retry up to 10 times in case of such
failure, similar to retries being made for attribute queries.
Change-Id: Ie3ea4b3c516481e9ec176ab9db884a8a75cd33f9
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
The 3.14 kernel has changed the members of the bio data structure. This
change updates those data structures referenced in the ufs qcom ice
driver.
Change-Id: I60e982bce8f59b87c30e0f63999914ee5c401f0a
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
This change adds support for following changes in register interface for
newer UFS controllers:
The register UFS_ICE_CTRL_INFO_n_1 contains 32-bit LSB of crypto data-unit
base number. The register UFS_ICE_CTRL_INFO_n_2 contains 32-bit MSB of the
crypto data-unit base number. The register UFS_ICE_CTRL_INFO_n_3 contains
bitfields BYPASS, CNFG_KEY_INDX, and CDU_SIZE.
Change-Id: I2a9b0b87e912a876e46746431c75e32a0e21a1c6
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>