Commit graph

563252 commits

Author SHA1 Message Date
Dolev Raviv
e6628ef0a2 scsi: ufs: rework unit test infrastructure
Upgrade the APIs used.
Encapsulate test ops (read/write/open functions) and dentry creation
in macros.
Fix naming collisions with mmc tests.

Change-Id: I5c48b369beaf902f8187ced9d884a2149a8644f0
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
2016-03-22 10:59:09 -07:00
Lee Susman
29cfc516b3 scsi: ufs: long sequential read/write tests
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>
2016-03-22 10:59:08 -07:00
Subhash Jadavani
c004818cad scsi: ufs-qcom: disable clock scaling
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>
2016-03-22 10:59:07 -07:00
Gilad Broner
80cb9e5fe7 scsi: ufs: fix static code analysis issues
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>
2016-03-22 10:59:06 -07:00
Gilad Broner
57ef59d9b2 scsi: ufs: implement scsi host timeout handler
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>
2016-03-22 10:59:06 -07:00
Gilad Broner
c5c33e40b8 scsi: ufs: retry failed query flag requests
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>
2016-03-22 10:59:05 -07:00
Krishna Konda
dc20c1b847 scsi: ufs-qcom: update the bio data stcuture
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>
2016-03-22 10:59:04 -07:00
Subhash Jadavani
295bcc19e7 scsi: ufs-qcom-ice: add support for register interface changes
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>
2016-03-22 10:59:03 -07:00
Gilad Broner
cd64baf8a1 scsi: ufs: convert statistics macros to functions
Kernel coding style requires to use actual functions for
function-like or lengthy macros.
The statistics macros are such, so replace them with functions.

Change-Id: I464768ccb7ba5bba4149dc45adacd777c08a2413
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:59:02 -07:00
Gilad Broner
1478bf7fa3 scsi: ufs: verify command tag validity
A race condition appear to exist between request completion when
scsi_done() is called to end the request and set the tag back to
-1 (at blk_queue_end_tag() scsi_end_request), and scsi layer error
handling which aborts the command and reuses it to request sense
data. Sending the request sense is done with tag which was set to -1
and so it is invalid.
Assert command tag passed from scsi layer is valid.

Change-Id: I71b82e1e6aca4bbf316a2a732a42c564ab0d2248
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:59:01 -07:00
Gilad Broner
2d109dcf97 scsi: ufs: remove debugfs entries on driver unloading
debugfs entries that were set up on driver initialization
were not removed in the driver unloading path.
Added removal of the debugfs entries.
Also, cleaned up the unnecessary macro wrapping those functions.

Change-Id: I656b1f76713684547d1f9ca3aa75430b47bd5eff
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:59:00 -07:00
Subhash Jadavani
43b632cb97 scsi: ufshcd: fix possible unclocked register access
vendor specific setup_clocks ops may depend on clocks managed by ufshcd
driver so if the vendor specific setup_clocks callback is called when
the required clocks are turned off, it results into unclocked register
access.

This change make sure that required clocks are enabled before vendor
specific setup_clocks callback is called.

Change-Id: I670c6b69aa361eb5023ef7d945ff45c3fa986fd7
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:59 -07:00
Gilad Broner
25245a746c scsi: ufs: add missing memory barriers
Performing several writes to UFS host controller registers has
no gurrantee of ordering, so we must make sure register writes
to setup request list base address etc. are performed before the
run/stop register is enabled.
In addition, when setting up a task request, we must make sure
the updating of descriptors takes places before ringing the
doorbell, similarly to setting up a transfer request.

Change-Id: I740331fe94da3cf8a8e7faee9020c88889aadea3
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:58:59 -07:00
Gilad Broner
d791fc7234 scsi: ufs: add host state prints in failure cases
Whenever some UFS failure occurs the driver prints the UFS
registers in order to help with analysis of the failure.
However this may not be sufficient in some cases, so having
the host controller state as it is represented and managed in
the driver will contribute to analysis efforts.
Added prints of various fields in the hba struct which may be
of interest.

Change-Id: I8385a6b40f6937f07d8f0f0c51f5cf36babf7515
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:58 -07:00
Subhash Jadavani
04825be019 scsi: ufs-qcom: disable lane symbol clocks if link is not active
UFS lane symbol clocks can be disabled if the UFS link is not active,
this change adds support to vote these clocks off when link is inactive.

Change-Id: Id441d34b0b8ad4f3a3f3e0dacb8c9797b1de64b6
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:57 -07:00
Subhash Jadavani
01955a9ec9 scsi: ufs-qcom: enable power management features
UFS power management features (clock gating & scaling, Hibern8 on Idle)
are kept disabled until they are verified on latest UFS host controller.
Now that they are verified on newer host controller, this change enables
them.

Change-Id: I9fb94ee58ab5fbbd5d22a0190624e1a8839060f0
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:56 -07:00
Subhash Jadavani
978703baab scsi: ufs-qcom: skip update secure configuration
On latest UFS PHY HW revisions, UFS host controller secure configuration
is retained even during UFS host controller power collapse so we can
skip restoring the secure configuration after coming out of power collapse.

Change-Id: I6cb882c99bd621622286c0f045cbefd9c1b1a0b7
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:55 -07:00
Gilad Broner
65b6feb781 scsi: ufs: add instance number to UFS debug-fs entry
UFS exposes a debug-fs directory with various information under
the name "ufs", which will not scale in case more than one UFS
controller is available in the system.
Add the instance number (inherited from the scsi host number) to
the debug-fs entry name.

Change-Id: I1a31be72b90c26cc840219d7ba2944ec4c0bc8f8
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:54 -07:00
Gilad Broner
2aa36bf1f9 scsi: ufs: add request completion time statistics
When running benchmarks on a system and inspecting the effect of
performance related changes it can be useful to know in a
simple way how long it takes for UFS requests to complete.
Add statistics for UFS requests completion times and measure
minimum, maximum and average completion times for all requests
and also according to request type: read, write and flush.

Change-Id: I85639d629939e3ae3bba6de065ceadae0da3dc99
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:53 -07:00
Gilad Broner
9eccb6a00d scsi: ufs: fix tag statistics for flush requests
rq_data_dir(rq) will always be either READ or WRITE so conditional
logic could never classify a request as a flush request causing
flush statistics to always be zero.
In addition it is neccesary to check the request type is FS in
order not to count other request type as read/write.

Change-Id: I678203ba47f8296caefa3f197566f2c65abdf059
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:58:52 -07:00
Yaniv Gardi
741bd793f5 scsi: ufs: minimize exposure of ufs header files
Until now, the phy-qcom-ufs-*.* files used ufs data structures and
macros and thus, we had to expose most of them in include/linux/scsi/ufs
path. But now, after removing support for phy 28nm in apq8084 under
kernel 3.14, we can minimize the exposure of code to essential minimum.
To do that, we relocate the ufs.h, unipro.h, ufshcd.h and ufs-qcom.h
files back to reside internally in the driver.

Also this patch contains some very minor changes suggested by the
upstream checkpatch script.

Change-Id: Id2a923a6a0b1c76565c25f2797a666f3a0d1315f
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: fixed header includes and other
trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:52 -07:00
Devesh Jhunjhunwala
832a53931e soc: qcom: Include the kryo-l2-accessors driver in build
Add the kryo-l2-accessors driver to the build.

Signed-off-by: Devesh Jhunjhunwala <deveshj@codeaurora.org>
2016-03-22 10:58:51 -07:00
Devesh Jhunjhunwala
f910a321bd clk: msm: Add documentation for gdsc regulator driver
This is a snapshot of gdsc-regulator documentation as of
msm-3.18 commit:

e70ad0cd5efdd9dc91a77dcdac31d6132e1315c1 (Promotion of
kernel.lnx.3.18-151201.)

Signed-off-by: Devesh Jhunjhunwala <deveshj@codeaurora.org>
2016-03-22 10:58:50 -07:00
Maya Erez
de8b5072ec scsi; ufs: compile UFS unit tests as module
UFS Unit tests are used by test teams to test stability
and performance of the UFS driver.
They are inactive unless manually activated and do not impact the
functionality of the UFS driver.

Change-Id: I41ae523dce60b05bb57554f9f8f38c42dbdea4a7
Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-03-22 10:58:49 -07:00
Subhash Jadavani
465485894a scsi: ufs-qcom: allow HS-G3 on newer host controllers.
HS-G3 mode is working as expected with newer host controller revisions
hence this change removes the restriction of only running in PWM gears.

Change-Id: I4df0b6875455730e990a20a2810784f1c32d949f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:48 -07:00
Yaniv Gardi
0fe711f7ea scsi: ufs: renaming "debugfs" files with correct prefix
The old names doesn't include the driver name (as prefix or at all).
This change adds the "ufs" and the "ufs-qcom" prefix to file names
and by that creates uniform naming convention in the driver.

Change-Id: I221b489cc4237882d7e62a9d80bc1ee3f2bcf4a6
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2016-03-22 10:58:47 -07:00
Gilad Broner
3a18ae55d2 scsi: ufs: don't use FTRACE_EVENT_ENABLED macro
Trace events have their own trace_<name>_enabled() function
that can be called in order to check if its enabled or not.
FTRACE_EVENT_ENABLED is redundant and will be dropped so
use the trace event function instead.

Change-Id: I4d2cc031ebbd5250bcff9526eaa916d6d691dbfc
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts]
2016-03-22 10:58:46 -07:00
Yaniv Gardi
fac1cf559d phy: qcom-ufs: move decision of rate B calibration to ufs driver
Until now, the decision if phy calibration is according to rate A or
rate B values, was done in the phy driver. It made the phy dependent on
the ufs unipro which is unnecessary binding.
This change moves the decision into the ufs driver, and pass it through
a function parameter to the calibration routine in the phy driver.

Change-Id: I7a51d84142c31da57ba5de6ec98526e5c7d1b544
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:45 -07:00
Gilad Broner
da7f098c89 scsi: ufs: enable runtime pm only after ufshcd init
Previous code enables runtime pm before ufshcd_init() is completed,
and before the hba struct is stored in the platform device private
data. This means that pm runtime calls will have null hba pointer
as well as partially initialized driver.
Instead, enable pm runtime only after ufshcd_init() is done and
after hba struct is stored in the platform device private data.

Change-Id: I8225736916a9eda3d9f58d2b0e2566065766b914
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:58:45 -07:00
Subhash Jadavani
413d97dd2a scsi: ufs-qcom: implement pre and post notification for clock scaling
QUniPro controller requires additional configuration before and after
clock scaling, this change adds the support for it.

Change-Id: I0add27ff3ab54f72b8b79e1e554541c2e492a4c8
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:43 -07:00
Subhash Jadavani
1811e9b0bb scsi: ufs: add pre & post status change to clk_scale_notify ops
Some UFS host controller implementation may require vendor specific
configurations before and after changing the UFS controller
clock frequencies. This change adds the support for this.

Change-Id: Id4171ef8786fa6883d9af914dc2a675cb62c6a72
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:43 -07:00
Subhash Jadavani
8ef05b55a0 scsi: ufs-qcom: disable low power modes and run slow on newer controller
Newer UFS controllers (revision 2) still need to be validated properly
hence disable the low power modes for it until they are validated
thoroughly.
Also run the UFS interface in PWM gear until High Speed Gear operation
is stabililized.

Change-Id: I310b49030d084557f487f3095fc7e1cfa68335e6
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:42 -07:00
Subhash Jadavani
061c93d4f1 scsi: ufs-qcom: fix device reference clock control handling
UFS device reference clock control has moved inside UFS controller register
address space for newer Qualcomm chipsets and if we try to do ioremp on the
corresponding memory address then it would fail as the same memory address
space is already ioremapped.
This issue is fixed by removing the requirement of passing reference clock
control register address space resource via device tree node for newer
chipsets.

Change-Id: I8d93f9856d33d3b300bd7994d1dff1d1be84596d
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts, skipped changes to
msmthulium.dtsi]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:41 -07:00
Subhash Jadavani
ddc6e01269 scsi: ufs-qcom: enable UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION
Newer revisions of Qualcomm UFS host controller may not advertise
the correct version information in UFS HCI VER register. To handle
this, enable UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION to let UFS standard
host controller driver call into vendor specific operation to get
right UFS HCI VER register value.

Change-Id: Ibd50b8bb8a87003181ea306690e87728576d49fb
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:40 -07:00
Subhash Jadavani
e77d1e1a1d phy: ufs-qcom: disable RX LineCfg
Some UFS devices send incorrect LineCfg data as part of power mode change
sequence which may cause host PHY to go into bad state. Currently we
workaround this issue by disabling the device's TX LCC but disabling TX
LCC is much more complicated if both host and device supports UniPro 1.6
specification. To simplify the workaround, this change disables the host
PHY's RX LineCfg to skip processing incorrect LineCfg from device.

Change-Id: I1eac56c11dd001eb0c53ba8e16aa512a656ab9ea
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:39 -07:00
Subhash Jadavani
aa161ba54d scsi: ufs-qcom: allow HS-G3
Change the maximum high speed gear to HS-G3 so if both host and device
supports HS-G3, UFS link will be allowed to operate in HS-G3.

Change-Id: I1117990948f9c09ae103cd1e692716e0010362cb
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:38 -07:00
Subhash Jadavani
99a7595323 scsi: ufs-qcom: cap maximum gear to HS-G2 for legacy host controller
HS-G3 operations may not reliably work on legacy QCOM UFS host controller
hardware (major revision = 0x01) even though capability exchange during
link startup phase may end up negotiating maximum supported gear as G3.
This change downgrades the maximum supported gear to HS-G2 for legacy
host controllers.

Change-Id: Iad95ed4271f83db888940263ea6c6c804d56a422
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:37 -07:00
Subhash Jadavani
588cbce99c scsi: ufs: add load based scaling of UFS gear
UFS driver's load based clock scaling feature scales down the ufs related
clocks in order to allow low power modes of chipsets. UniPro 1.6 supports
maximum gear up to HS-G3 (High Speed Gear3) and some of the chipsets
low power modes may not be allowed in HS-G3 hence this change adds support
to scale gear between HS-G3 and HS-G2 based on same existing load based
clock scaling logic.

Change-Id: I25c70230a77321efd654af7c496c43936324ae40
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:37 -07:00
Subhash Jadavani
2d59afeff9 scsi: ufs: add UFS power collapse support during hibern8
UFS host controller hardware may allow the host controller
to be power collapsed when UFS link is hibern8 state, this
change allows the UFS host controller to be power collapsed
during hibern8.

Change-Id: I42f962484b9d6635be1139b1fc6447dd2ca2200c
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:36 -07:00
Gilad Broner
4ad04d8bc5 scsi: ufs-qcom: change device reference clock control
As of HW major version 2, bit 'UFS_DEV_REF_CLK_EN' which is used to
gate/ungate the ref_clk to external UFS device, was moved into the
UFS register space to UFS_CFG1 register. This change adds support
to appropriately control the device reference clock and it also
adds the missing documentation for the device reference clock control
register address space.

Change-Id: I66a6a75dc5a1cf130b1cee90ae20f9f950edfb3a
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:35 -07:00
Subhash Jadavani
7ae3423485 scsi: ufs: fix UFS HCI 2.0 version register value
It seems UFS version register (offset 08h) fields position has changed in
UFS HCI 2.0 specification when compared to 1.0/1.0 specification.
According to 2.0 spec, UFS version register value should be 0000_0200h
(version 2.0). This change fixes the expected version register value and
also added the error message if host controller advertises invalid
version.

Change-Id: I2dd399fd7e47ce99b60591f7eac75e7305758bde
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:34 -07:00
Subhash Jadavani
1008d1889d scsi: ufs: suspend clock scaling at the start of suspend
Currently clock scaling is suspended only after the host and device
are put in low power mode but we should avoid clock scaling running
after UFS link is put in low power mode (hibern8). This change
suspends clock scaling before putting host/device in low power mode.

Change-Id: Iff9846cee1345a3c0c8b1aaee0b4ad567f37ea79
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:33 -07:00
Subhash Jadavani
60455e93d1 scsi: ufs: avoid exception event handler racing with PM callbacks
If device raises the exception event in the response to the commands
sent during the runtime/system PM callbacks, exception event handler
might run in parallel with PM callbacks and may see unclocked register
accesses. This change fixes this issue by not scheduling the exception
event handler while PM callbacks are running.

Change-Id: I8644f50366d5c87ba6a5048e48703b3723ab241b
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:32 -07:00
Dov Levenglick
4229a8a3ed scsi: ufs-qcom: expose debug registers by debugfs
Add support for exposing debug registers via debugfs. This
can be used for runtime debugging of failures/errors without
the need to add more prints to the console.
In order to avoid unnecessary code duplication, the function
for dumping registers to a file (in debugfs.c) has been
slightly modified and exposed as an external function.

Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
Change-Id: I77f9f3a6d041f805a93d095446f3e8077977036f
2016-03-22 10:58:31 -07:00
Dov Levenglick
7d17fba879 scsi: ufs-qcom: add debug prints for test bus
Adds support for configuring and reading the test bus and debug
registers. The configuration is controlled by debugfs. Reading can
be triggered either by debugfs or by the kernel code.

Change-Id: I943e3c1b1e383a91a8abbb8dab9714434c56b6f5
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[imaund@codeaurora.org: Resolved context conflicts]
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2016-03-22 10:58:30 -07:00
Dov Levenglick
25531d6eea scsi: ufs-qcom: add ICE debug prints
Add ICE debug prints for debugging purposes. These prints
will be shown as part of dumping registers during error handling.
Enabling can be controlled by debugfs.

Change-Id: I7d070cc8df099e6c526997d39973a3e1c161091b
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
2016-03-22 10:58:30 -07:00
Dov Levenglick
6021822eca scsi: ufs-qcom: add print suppressing debugfs mechanism
Provide a mechanism for the userspace to suppress specific
debug prints via debugfs. This is useful in order to avoid
cases where too much printing would cause watchdog timers
to expire.

Change-Id: I2500b7621b631e260d98595ed8cfe7d5a496dc10
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
2016-03-22 10:58:29 -07:00
Dov Levenglick
a422990e68 scsi: ufs: wait for a longer time for fDeviceInit to clear
On some device, in some cases, the initialization time is
uncharacteristically long. This is within the standard which states
in section 13.4.6.1.2 (Dynamic Capacity Procedural Flow):
"The device initialization may take a time longer than normal
initialization..."
Therefore, making the loop pending on fDeviceInit to clear
longer.

CRs-Fixed: 776748
Change-Id: Ida491467da63ac9630d3ecc9b8f5c3e9ac5187c2
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
2016-03-22 10:58:28 -07:00
Yaniv Gardi
5e500d99d2 scsi: ufs: clear outstanding_request bit in case query timeout
When sending a query to the device returns with a timeout error,
we clear the corresponding bit in the DOORBELL register but
we don't clear the outstanding_request field as we should.
This patch fixes this bug.

Change-Id: Ia7e0aa29b0d822742654ba206a5837b9091fdb4a
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2016-03-22 10:58:27 -07:00
Gilad Broner
5cdbfe11ca scsi: ufs-qcom: set device ref. clk bit
As of HW major version 2, a new bit 'UFS_DEV_REF_CLK_EN' was added
to UFS_CFG1 register which needs to be set as part of hibernate
enter/exit sequences during suspend/resume.

Change-Id: I66a6a75dc5a1cf130b1cee90ae20f9f950edfb3a
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[imaund@codeaurora.org: Resolved context conflicts and updated a
  conditional in ufs_qcom_advertise_quirks to use the ufs_qcom_host
  struct when querying major hw versions]
Signed-off-by: Ian Maund <imaund@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts,
drop changes to include/linux/phy/phy-qcom-ufs.h]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:26 -07:00