Commit graph

79582 commits

Author SHA1 Message Date
Dolev Raviv
5904916689 block: blk-flush: Add support for Barrier flag
A barrier request is used to control ordering of write requests without
clearing the device's cache. LLD support for barrier is optional. If LLD
doesn't support barrier, flush will be issued instead to insure logical
correctness.
To maintain this fallback flush s/w path and flags are appended.
This patch implements the necessary requests marking in order to support
the barrier feature in the block layer.

This patch implements two major changes required for the barrier support.
(1) A new flush execution-policy is added to support "ordered" requests
    and a fallback , in case barrier is not supported by LLD.
(2) If there is a flush pending in the flush-queue, the received barrier
    is ignored, in order not to miss a demand for an actual flush.

Change-Id: I6072d759e5c3bd983105852d81732e949da3d448
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
2016-03-22 11:01:36 -07:00
Dolev Raviv
7472ef2e31 block: Definition for barrier requests flag
A barrier request is a type of flush request used to control ordering of
write requests without clearing the device's cache. LLD support for
barrier is optional. To maintain backward compatibility, barrier request
has to maintain flush s/w path and flags.
This patch introduces those flags to define interface between the block
layer and the LLD.

Change-Id: Iefa8e9a5c1b5e8256eaeb0322c435becd4669de9
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[imaund@codeaurora.org: Resolved context conflicts]
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2016-03-22 11:01:35 -07:00
Sahitya Tummala
c1877ca741 PM / devfreq: Add new flag to do simple clock scaling
Add new flag "simple_scaling" to on demand governor so that
the clocks can be scaled up only when the load is more than
up threshold and can be scaled down only when the load is less
than down differential data as provided within
struct devfreq_simple_ondemand_data.

Change-Id: Ibc6ab6297c1b64b6e6eaaa76d735d0b9ae0f6477
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[venkatg@codeaurora.org: dereference stat variables]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 11:01:34 -07:00
Tatyana Brokhman
f87c25862f block: add REQ_URGENT to request flags
This patch adds a new flag to be used in cmd_flags field of struct request
for marking request as urgent.
Urgent request is the one that should be given priority currently handled
(regular) request by the device driver. The decision of a request urgency
is taken by the scheduler.

Change-Id: Ic20470987ef23410f1d0324f96f00578f7df8717
Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 11:01:33 -07:00
Matt Wagantall
914f992d79 scsi: include device.h in scsi.h
scsi.h reference 'struct device', the definition for which is not
included. Most users of this header compile because struct device
happens to be defined before scsi.h is included. Less-fortunate
drivers encounter:

 linux/include/scsi/scsi.h:565:49: warning: 'struct device'
 declared inside parameter list

Change-Id: I6352b0fc1d1ab296e500f6007b0b20be3b85a1f9
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 11:01:03 -07:00
Abhimanyu Kapur
ccca370b3b UAPI: scsi: move ioctl related information
The ioctl information should be in header files that expose it
to userspace.

Change-Id: Iabf1e53a1357c2ce22ecdc8dc0270377759effc8
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 11:01:02 -07:00
Abhimanyu Kapur
afa03abaad UAPI: scsi: move the scsi ioctl related files
The scsi ioctl related files are meant to be used from
userspace and hence should be in the appropriate include/uapi
directory.

Change-Id: Id6b14f353284a9ddac0d58b6b90e17561e2645aa
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
2016-03-22 11:01:01 -07:00
Sujit Reddy Thumma
c6b82e8bca scsi: Allow auto suspend override by low-level driver
Until now the scsi mid-layer forbids runtime suspend till userspace
enables it. This is mainly to quarantine some disks with broken
runtime power management or have high latencies executing suspend
resume callbacks. If the userspace doesn't enable the runtime suspend
the underlying hardware will be always on even when it is not doing
any useful work and thus wasting power.

Some low-level drivers for the controllers can efficiently use runtime
power management to reduce power consumption and improve battery life.
Allow runtime suspend parameters override within the LLD itself
instead of waiting for userspace to control the power management.

Change-Id: I03e96a89d19c174deeb5bd4f94136c77073eb009
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 11:00:55 -07:00
Maya Erez
36c183b743 scsi: Adjust DBD setting in mode sense for caching mode page per LLD
Host sends MODE_SENSE_10 with caching mode page, to check if the device
supports the cache feature.
Some LLD standards requires DBD field to be set to 1.

This patch allows LLD to define the setting of DBD if required.

Change-Id: I7f6c0ff6613516c3ef49aacc0679b96b8bd9ccc8
Signed-off-by: Maya Erez <merez@codeaurora.org>
[mattw@codeaurora.org: resolved a trivial context conflict in
Scsi_Host struct definition]
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 11:00:53 -07:00
Venkat Gopalakrishnan
3abbdb57e3 scsi/phy: Remove orphaned files after renaming
Delete renamed orphan files after rebasing 3.18 ufs driver changes
onto 4.4 ufs driver.

Change-Id: Id241ad01bbb0fa74e209c66f8a2d97c05088e33b
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 11:00:52 -07:00
Subhash Jadavani
be361c995c scsi: ufs: allow updating bBootLunEn via ioctl
"bBootLunEn" attribute value decides the active Boot LUN but there could
be a case where userspace may want to change it during image update.
This change allows writing to this parameter.

Change-Id: I6e8d630606d8caf6197ef662003ec1ee646afe81
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 11:00:42 -07:00
Yaniv Gardi
966284567f scsi: ufs-debug: add debugfs capability to collect query statistics
This patch adds a new debugfs capability to collect query statistics.
It counts how many times each IDN (index) was sent to device for each
query opcode.

A usage example:
1. to clean current query statistics:
   echo 1 > /d/ufshcd0/stats/query_stats

2. to dump the current query statistics:
   cat /d/ufshcd0/stats/query_stats

This capability is always on, and can not be turned off.

Change-Id: I46ec405aae480c0dc161dca015b407bde6335cf7
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2016-03-22 10:59:56 -07:00
Gilad Broner
8c62c80743 scsi: ufs: use symbolic print for tracing
Passing strings instead of enums for tracing events uses more of
the tracing buffer. Instead, pass the enum integer value and
convert to string when tracing event is formated using the
__print_symbolic() macro.

Change-Id: I91c4374fd079c6ea150373548975f2b259eb2d59
Signed-off-by: Gilad Broner <gbroner@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:59:48 -07:00
Gilad Broner
d44985ce84 tracing: ufs: create a trace event class template for common events
The following three trace events:
ufshcd_clk_gating, ufshcd_hibern8_on_idle and ufshcd_auto_bkops_state
share the same arguments and meaning - logging some state change
in the UFS driver.
Defining those as template instances takes up less memory compared
to be defined as separate trace events.

Change-Id: I92c2bf3eada6f876b8c9e8a7bfc4568c7886548f
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:59:48 -07:00
Dolev Raviv
279fdf9c3a test-iosched: ufs_test: fix gendisk usage in test
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>
2016-03-22 10:59:20 -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
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
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
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
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
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
Dov Levenglick
f6786d1fec scsi: ufs: add print suppressing debugfs mechanism
Provides a mechanism for the userspace to suppress specific
debug prints via the debugfs. This is useful in order to avoid
cases where too much printing would cause watchdog timers to expire.

Change-Id: I1ab068cd616ddac767ec5f30ab130e3b1ac34e15
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[imaund@codeaurora.org: Resolved context conflicts]
Signed-off-by: Ian Maund <imaund@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:25 -07:00
Maya Erez
1fd1c6a697 scsi: ufs: perform ice_init as part of UFS initialization
ice_init may need UFS clocks to be enabled in order to allow
enabling ICE as part of its initialization. To allow that,
ice_init should be done as part of UFS initialization sequence.
In such a case ice_reset is no longer needed to be called as part of
UFS initialization and should be moved to host reset scenarios.

Change-Id: Iaa851083a9f73045c7ca02d69dd65b3a00b85bff
Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-03-22 10:58:24 -07:00
Subhash Jadavani
e0c0dd6ba0 scsi: ufs: set right GenSelectorIndex for M-PHY attributes
DME attributes read/write commands need GenSelectorIndex argument and
according to UFS host controller specification, it should specify the
targeted M-PHY data lane.
This is the valid range of GenSelectorIndex for M-PHY attributes:
	0 to (2 * PA_MaxDataLanes - 1)

Example (Note: PA_MaxDataLanes is UniPro protocol constant set to 4):
  ---------------------------------------
  MPHY Access target |	 GenSelectorIndex
  ---------------------------------------
    TX Lane0         |          0
    TX Lane1         |          1
    RX Lane0         |          4
    RX Lane1         |          5
  ---------------------------------------

This change make sure that correct GenSelectorIndex is passed for M-PHY
attributes

Change-Id: I38c14b5801ece7fce7a7970385756859618efd32
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:21 -07:00
Subhash Jadavani
a7578e830e scsi: ufs-qcom: add QUniPro hardware support
New revisions of UFS host controller supports the new UniPro
hardware controller (referred as QUniPro). This patch adds
the support to enable this new UniPro controller hardware.

Change-Id: Iccbcc38c36e6d9b9fcbb5c7fd7a3e3326c1c4ce0
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:20 -07:00
Yaniv Gardi
ce7e8d0894 scsi: ufs-qcom: remove support for save/restore phy configuration
Since support for 28nm phy removed in kernel 3.14, all related code
that is specific to phy 28nm is also removed.
Specifically the quirk that enables save/restore phy configuration
is removed (and all its relevant callbacks) as it's unique to 28nm
ufs phy.

Change-Id: Ie723885bacb52548573fc1140d09b0ea5f067382
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[venkatg@codeaurora.org: drop changes to
include/linux/phy/phy-qcom-ufs.h]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:58:19 -07:00
Gilad Broner
b030bfae53 scsi: ufs-qcom: add number of lanes per direction
Different platform may have different number of lanes
for the UFS link.
Add parameter to device tree specifying how many lanes
should be configured for the UFS link.

Change-Id: Ida8b13b916f76b3cc7afd3da3d04219e95627678
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:16 -07:00
Subhash Jadavani
7248753f68 scsi: ufs: optimize clock, pm_qos, hibern8 handling in queuecommand
ufshcd_queuecommand() vote for the resources in this order: clocks,
pm_qos latency, hibern8 exit. If any of these votes are not already
applied, each one has to be applied asynchronously and in that case we are
releasing all the previously applied resource votes (for example, if
hibern8 exit has to be completed asynchronously, we release the votes for
pm_qos and clocks as well). This is not a optimal solution instead we
should skip scheduling the unvoting work for already voted resources.

Change-Id: Ie700d9b3bf64370a5885787f7313d41adb5b3566
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:10 -07:00
Gilad Broner
b19709a5c3 scsi: ufs: reduce printout for aborted requests
Details printed for each request that is aborted can overload the
target as there can be several requests that are aborted at once.
This change will print full request details only for the first
aborted request since the last link reset, and minimal details
for other subsequent requests.

Change-Id: I2868262e0b687c9ddd771a52708428b7de14bea2
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:09 -07:00
Gilad Broner
7223077cfd scsi: ufs-qcom: save ufs_qcom_host object pointers
Analyzing crash logs is made easier when the different UFS objects
state is accessible. Save a pointer to the main ufs_qcom_host
object when it is allocated.

Change-Id: I8eb909729dee7209e5d9b1af2652fe76ccd3c0ca
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:58:03 -07:00
Gilad Broner
f3fdd87f21 scsi: ufs: skip request abort task when previous aborts failed
On certain error conditions request abort task itself might fail
when aborting a request. In such case, subsequent request aborts
should skip issuing the abort task as it is expected to fail as well,
and device reset handler will be called next.

Change-Id: I28c111c58e8c7fd54b836c6933d5fc56682c28b9
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:58:02 -07:00
Subhash Jadavani
9226d74e2c scsi: ufs: add error recovery after DL NAC error
Some vendor's UFS device sends back to back NACs for the DL data frames
causing the host controller to raise the DFES error status. Sometimes
such UFS devices send back to back NAC without waiting for new
retransmitted DL frame from the host and in such cases it might be possible
the Host UniPro goes into bad state without raising the DFES error
interrupt. If this happens then all the pending commands would timeout
only after respective SW command (which is generally too large).

This change workarounds such device behaviour like this:
- As soon as SW sees the DL NAC error, it would schedule the error handler
- Error handler would sleep for 50ms to see if there any fatal errors
  raised by UFS controller.
   - If there are fatal errors then SW does normal error recovery.
   - If there are no fatal errors then SW sends the NOP command to device
     to check if link is alive.
       - If NOP command times out, SW does normal error recovery
       - If NOP command succeed, skip the error handling.

If DL NAC error is seen multiple times with some vendor's UFS devices then
enable this quirk to initiate quick error recovery and also silence related
error logs to reduce spamming of kernel logs.

Change-Id: Id2f0c05c414d700ba923513f8c9e3d1e6a8a749a
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:59 -07:00
Dolev Raviv
2ea3c6c0fa scsi: ufs-qcom: implement ufs dbg_register_dump cb
Errors such as UIC errors, illegal OCS values, and others may require
information kept in non standard UFS registers but controller debug
registers.
Implementing dbg_register_dump cb gives access to such register while
debugging those issues.

Change-Id: I259c3d691b95f72ea62ed162492f9081d472de80
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:55 -07:00
Dolev Raviv
3c0960d0f1 scsi: ufs: Improve fatal error logs
Errors such as UIC error, illegal OCS values, and others may require
more information for debugging. Such information could be hibern8 events,
events sequences, recoverable errors, error history, and more.
This patch improves tracking of important errors and events in debug level
to be enabled when debugging a such issues. It includes:
* UIC error history
* Successful hibern8 events
* Successful command after hibern8 exit
* Clk-freq info
* Failed device command
* Infrastructure for dumping host controller debug information

Change-Id: If3b38b86caeec4ffc669d001b452050a4a6b5173
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:54 -07:00
Lee Susman
b0c1404cb0 scsi: ufs: add trace event for ufs commands
Use the ftrace infrastructure to conditionally trace ufs command events.
New trace event is created, which samples the following ufs command data:
- device name
- optional identification string
- task tag
- doorbell register
- number of transfer bytes
- interrupt status register
- request start LBA
- command opcode

Currently we only fully trace read(10) and write(10) commands.
All other commands which pass through ufshcd_send_command() will be
printed with "-1" in the lba and transfer_len fields.

Usage:
	echo 1 > /sys/kernel/debug/tracing/events/ufs/enable
	cat /sys/kernel/debug/tracing/trace_pipe

Change-Id: Id6e16a8c0b2a833c5453ed9923384f641e374a71
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflict]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts and compilation error]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:53 -07:00
Subhash Jadavani
56d144a7a0 scsi: ufs: disable vccq if it's not needed by UFS device
Some UFS devices don't require VCCQ rail for device operations hence
this change adds support to recognize such devices and remove vote for
the unused VCCQ rail.

Change-Id: I7f0ffb9141bf9f13ce457c8c5eba7705ae288872
[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:57:49 -07:00
Gilad Broner
695e85590b scsi: ufs: add cpu-dma latency PM QOS request
Add PM QOS cpu-dma latency request to the driver.
Latency parameter value is taken from the device tree node
using an optional parameter 'qcom,cpu-dma-latency-us'.
Unless specified, a default of 200us is used.

Change-Id: I3e10da9e65fc7324897c866b0c2a40cc5e6ca070
Signed-off-by: Gilad Broner <gbroner@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:57:46 -07:00
Maya Erez
89dc95d277 scsi: ufs: add Inline Crypto Engine (ICE) support to UFS
In-order to enhance storage encryption performance,
an Inline Cryptographic Engine is introduced to UFS.
This patch adds in-line encryption capabilities to the UFS
driver.

Change-Id: Id3cb913498809b32e1f7eba96395b05a9bf3219f
Signed-off-by: Noa Rubens <noag@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Maya Erez <merez@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:57:43 -07:00
Subhash Jadavani
1eabea8b95 scsi: ufs: add time profiling support
This patch adds the profiling support for some of the time critical
operations like hibern8 enter/exit, clock gating & clock scaling.

Change-Id: I4dde1078dcd2af47f051639b03c44c423ee344fa
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:42 -07:00
Subhash Jadavani
9f06dddf5b scsi: ufs: add capability to keep auto bkops always enabled
UFS device requires to perform bkops (back ground operations) periodically
but host can control (via auto-bkops parameter of device) when device can
perform bkops based on its performance requirements. In general, host
would like to enable the device's auto-bkops only when it's not doing any
regular data transfer but sometimes device may not behave properly if host
keeps the auto-bkops disabled. This change adds the capability to let the
device auto-bkops always enabled except suspend.

Change-Id: I92c4531f88cb75a563568270584926eb73b53c98
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:40 -07:00
Subhash Jadavani
a4ef3c82e8 scsi: ufs: Add sysfs node to dynamically control hibern8 on idle
Provide an option to enable/disable hibern8 on idle functionality during
runtime. Write 1 or 0 to "hibern8_on_idle_enable" sysfs node to
enable/disable hibern8 on idle functionality.

Change-Id: Id4b6253c3c53ed71575c05596abbd4dd99821eff
[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:57:37 -07:00
Subhash Jadavani
ab18ee44ce scsi: ufs: add support for hibern8 on idle
In order to save power we should put the UFS link into hibern8 as soon as
UFS link is idle and power measurement of active usecases (like audio/video
playback/recording) show that putting UFS link in hibern8 @ 10ms of idle
(if not earlier) would save significant power.

Our current available solution is to do hibern8 with clock gating @idle
timeout of 150ms. As clock gating has huge latencies (7ms each in enter and
exit), we cannot bring down the idle timeout to <=10ms without degrading
UFS throughput. Hence this change has added support to enter into hibern8
with another idle timer.

Change-Id: I5a31f18fc21015d4a68236da9fd94f3f016e1d44
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:36 -07:00
Subhash Jadavani
8c30670fd8 scsi: ufs: tune UniPro parameters to optimize hibern8 exit time
Optimal values of local UniPro parameters like PA_Hibern8Time &
PA_TActivate can help reduce the hibern8 exit latency. If both host and
device supports UniPro ver1.6 or later, these parameters will be
automatically tuned during link startup itself. But if either host or
device doesn't support UniPro ver 1.6 or later, we have to manually tune
them. But to keep manual tuning logic simple, we will only do manual
tuning if local unipro version doesn't support ver1.6 or later.

Change-Id: I533afe9b62a35602e4e766d76912db7ac9a480b6
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:57:32 -07:00