Commit graph

563185 commits

Author SHA1 Message Date
Subhash Jadavani
c991cc0db0 scsi: ufs: fix possible unclocked register access during hibern8 exit
ufshcd_queuecommand() function calls ufshcd_hibern8_hold() to bring the
link out of hibern8 asynchronously. If the link was in hibern8 state then
it schedules a work to execute the hibern8 without any timeout and returns
error back to ufshcd_queuecommand(). ufshcd_queuecommand() calls
ufshcd_release() which schedules the clock gating work to be executed
after clock gating timeout (50ms at this moment). Ideally hibern8 exit
work should have finished much before clock gating work starts execution
but it may not be true on heavily loaded system. To protect this race,
hibern8 exit work should make sure that clocks are running (by calling
ufshcd_hold()) before executing hibern8 exit.

Change-Id: I572b26881277886f5ec17b0eed96ee9e59ca1fbf
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
2fe969df93 scsi: ufs: suspend clock scaling for failed runtime_resume
During runtime resume operation, clock scaling may get indirectly
resumed via call to ufshcd_set_dev_pwr_mode(): Start/Stop Unit command
times out and SCSI error handling ultimately calls the host reset handler
to recover, during which clock scaling is resumed.
Error case exit path of runtime resume will disable clocks.
As clock scaling was already resumed, it will get scheduled later on and
try to access UFS registers while clocks are disabled, resulting in NOC
error.

Change-Id: I3faf46109420ac54404c18b209b4d42982e963b2
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:58:08 -07:00
Gilad Broner
48ef425125 scsi: ufs: set REQUEST_SENSE command size to 18 bytes
According to UFS device specification REQUEST_SENSE command can
only report back up to 18 bytes of data.

Change-Id: I1121b016ddabfa0e7182a1b6c9b30c27061694d2
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:58:07 -07:00
Subhash Jadavani
2df0831a9f scsi: ufs_quirks: remove no link off quirk for Toshiba
UFS_DEVICE_QUIRK_NO_LINK_OFF quirk was enabled for Toshiba devices as
these device may stop resonding back on resume after the link
initialization. But we now have proper workaround in place to allow link
off for these UFS devices hence this patch disables the
UFS_DEVICE_QUIRK_NO_LINK_OFF.

Change-Id: I52af7c2088d4d85cb517ee1bd76c0238db80a2d0
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:06 -07:00
Subhash Jadavani
d5a765b27b scsi: ufs: send request sense after the link reinitialization
After link reintialization, device would set the UNIT ATTENTION condition
for each logical units. UNIT ATTENTION condition gets automatically
cleared on either receiving explicit REQUEST SENSE command or data commands
to LUs. Although some devices may stop responding to data commands if we do
UFS link hibern8 enter/exit after link reinitialization but before any data
commands. This change works around above mentioned issue by sending
the explicit REQUEST SENSE command to all LUs after the link
reinitialization.

Change-Id: Ia191b8f05f9521bf587a713924b71bf19c801c31
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:05 -07:00
Maya Erez
e2834bc665 scsi: ufs: Set DBD setting in mode sense for caching mode page
Host sends MODE_SENSE_10 with caching mode page, to check if the device
supports the cache feature.
UFS standards requires DBD field to be set to 1.

Some card vendors are more strict and check the DBD field, hence
respond with CHECK_CONDITION (Sense key set to ILLEGAL_REQUEST and
ASC set to INVALID FIELD IN CDB).
As a result of the CHECK_CONDITION response, host assumes that the
device doesn't support the cache feature and doesn't send
SYNCHORONIZE_CACHE commands to flush the device cache.
This can result in data corruption in case of sudden power down, when
there is data stored in the device cache.

This patch fixes the DBD field setting in case of caching mode page.

Change-Id: I4d63cba26331f04c34e87b99dbdf17c05ab96839
Signed-off-by: Maya Erez <merez@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:04 -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
350f0a1398 scsi: ufs: set the hibern8 on idle state at missing places
Hibern8 on idle state should be set to HIBERN8_EXITED during
initialization and also during resume if the link is reinitialized but
its missing as of now, this change takes care of it.

Change-Id: I9f3b25df3904a666f0efe9bc23f75c0c4116e960
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:01 -07:00
Subhash Jadavani
a5a277f863 scsi: ufs: add quirk for not allowing link off
Some UFS devices may not work properly after resume if the link was
kept in off state during suspend. This change adds a quirk which
will not allow the link to be kept in off state for such devices.

Change-Id: I72c4baebccbe79ff731282f76c3b22782e1edf3e
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:58:00 -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
Subhash Jadavani
3c2eebd16d scsi: ufs: make error handling bit faster
UFS driver's error handler forcefully tries to clear all the pending
requests. For each pending request in the queue, it waits 1 sec for it
to get cleared. If we have multiple requests in the queue then it's
possible that we might end up waiting for those many seconds before
resetting the host. But note that resetting host would any way clear all
the pending requests from the hardware. Hence this change skips the
forceful clear of the pending requests if we are anyway going to
reset the host (for fatal errors).

Change-Id: I1ce761a140d84b6e1ed53aa215fc8141e336ff64
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflict]
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:57:58 -07:00
Subhash Jadavani
6666b25de7 scsi: ufs: fix the downdifferntial value for clock scaling
"downdifferntial" parameter of devfreq ondemand governor should
be set to value such that if the load is under upthreshold minus
downdifferential, the governor may consider slowing the frequency down.

As the devfreq ondemand governor is now fixed to handle the
downdifferential correctly, update the downdifferential parameter for
UFS clock scaling (which uses the devfreq ondemand governor).

Change-Id: I14efbe5706a56af00d72fad08392b3db13cbbca9
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:58 -07:00
Subhash Jadavani
3b2cafba36 scsi: ufs: add retries for hibern8 enter
If hibern8 enter command fails then UFS link state may be unknown which
may result into timeout of all the commands issued after failure.

This change does 2 things (for pre-defined number of retry counts) after
hibern8 enter failure:
1. Recovers the UFS link to active state
2. If link is recovered to active state, tries to put the UFS link in
   hibern8 enter again until retry count expires.

Change-Id: I6ae6d1371126b3b71ba2154182d6b9920e8996f5
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:57 -07:00
Subhash Jadavani
ed86dcf563 scsi: ufs: fix error recovery after the hibern8 exit failure
Hibern8 exit can be called from 3 different context:
	- ufshcd_hibern8_exit_work
	- ufshcd_ungate_work
	- runtime/system resume.

If hibern8 exit fails for some reason then we try to bring the link to
active state by link startup but this recovery mechanism results into
deadlock or errors from first 2 context listed above. This change fixes
the recovery by adding proper error handling mechanism.

Change-Id: I4d46e53eb052bddae29797cd9780fc5cf33b09ba
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:56 -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
134fbea94b scsi: ufs: clear fields UTRD, UPIU req and rsp before new transfers
Some of the data structures (like response UPIU) and/or its elements
(unused fields) should be cleared before sending out the respective
command to UFS device.

This change clears the UPIU response data structure for query commands
and NOP command before sending out the command. We also initialize the
PRDT table length to zero which should take care of commands which doesn't
have any data associated with it. We are also clearing the unused fields in
request UPIU for NOP command.

Change-Id: Iac02618cd5e9d97883652e134c5365884f3d0b44
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:52 -07:00
Subhash Jadavani
81be613925 scsi: ufs: increase fDeviceInit query response timeout
fDeviceInit query response time for some devices is too long that default
query request timeout of 100ms may not be enough. Experiments show that
fDeviceInit response sometimes takes 500ms so to be on safer side this
change sets the timeout to 600ms. Without this change, we might
unnecessarily have to retry fDeviceInit query requests multiple times and
each query request timeout prints one error message.

Change-Id: Ib44fef65c9e408201eb6e0ff9e02d0703d4bf5d9
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:51 -07:00
Subhash Jadavani
f6418ef28c scsi: ufs: reduce the delay before DME access commands
If UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS quirk is enabled then we are always
adding 1ms delay before issuing DME commands but after experiments show
that 700us delay is more than enough. As we have atleast 20 different DME
commands issued during link initialization phase (as part of UFS device
detection), this change should help reduce the total UFS device detection
time by atleast 6ms.

Change-Id: I495cec3916dbaa974d204d790f0dbc3d6753ba6f
[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:50 -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
Subhash Jadavani
e619407129 scsi: ufs-qcom: put the UFS phy in reset state when link is off
When UFS link is in off, put the UFS phy in reset state to reduce the
leakage from PHY.

Change-Id: I27473cbb5be19b331e0a0258c5a20546317d064c
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:48 -07:00
Subhash Jadavani
695a467503 scsi: ufs: fix leakage during link off state
Currently when we try to put the link in off/disabled state during suspend,
it seems link is not being kept in low power mode. This patch fixes the
issue by putting the link in hibern8 first (so device also puts the link in
low power mode) and then stop the host controller.

Change-Id: I157c0c0c246fb83692b57a3d8f5a7868c0703cf0
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:47 -07:00
Subhash Jadavani
aa484ff4b6 scsi: ufs: stub UFS shutdown handler
Currently it seems possible that UFS shutdown handler may race with some
other UFS transfer requests and it may disable the clocks while normal UFS
requests are in progress. Until we fix this race properly, this change
stubs out the UFS shutdown handler. Stubbing out UFS shutdown handler
shouldn't have any functional side effects as UFS device's cache should
anyway be synced by the SCSI shutdown handler. UFS shutdown handler's
main purpose was to send power down notification to UFS device but it
should work even without this explicit notification.

Change-Id: I557891c71defbde722bba1a884f608f4ba3c7da3
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:47 -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
Subhash Jadavani
851c8c3971 scsi: ufs-qcom: add support to control the device ref_clk
On Qualcomm platforms, there will be many consumers of the source clock
which also supply ref_clk to UFS Device. So even if generic UFS
driver (ufshcd) vote to turn off the source ref_clk, it's very likely that
device ref_clk is still running. Hence some of the qualcomm chipsets have
separate control bit to gate & ungate the UFS ref_clk to device. This
control bit is part of the TLMM register adddress space so it can't be
simulated at clock control bit which means UFS qcom driver has to manually
control this bit to gate or ungate the device ref_clk. This change adds
support for the same.

Change-Id: I3ee1187292eaadfdb552d33c2bb6f58922c9e501
[subhashj@codeaurora.org: resolved merge conflicts, dropped changes to
msm8994.dtsi]
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:57:45 -07:00
Subhash Jadavani
f1a31bcee0 scsi: ufs-qcom: disable the UFS PHY reference clock during clock gating
If UFS link is inactive then UFS PHY reference clock can be switched off
to save power. As of now, this clock is turned off only during the suspend
(runtime and system). This change extend support to turn off the PHY
reference clock during clock gating (after pre-defined idle timeout) as
well.

Change-Id: Id1f83a003e228abedf222157691998470c3f7932
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:44 -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
d4f8a9304b scsi: ufs: print the correct error state
UFS driver's error handler is not printing the saved error state
information, this change fixes it.

Change-Id: I02b06a8c49a32e8ce19a5523d7ccda8cd0b9a8ac
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:41 -07:00
Subhash Jadavani
952cb54f1f scsi: ufs: fix setting init power mode
Immediately after successful UFS link startup, UFS link power mode would
be in PWM-G1, 1-lane, SLOW-AUTO mode. But currently we are doing few
of the DME local/peer attributes access before setting the "hba->pwr_info"
to default power mode. If we are doing link startup as part of error
recovery then old power mode might be set to FAST mode and doing DME peer
access (after link startup but before updating "hba->pwr_info" to default
power mode) unintentionally tries to switch from FAST to FAST_AUTO mode (if
UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE quirk is enabled).

Above issue is fixed by setting the default power mode immediately after
successful link startup.

Change-Id: Ica332298114c9d24ecf67c7e452cebc07656415c
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:40 -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
Gilad Broner
500f7e1f33 scsi: ufs: commit descriptors before setting the doorbell
Add a write memory barrier to make sure descriptors prepared are actually
written to memory before ringing the doorbell. We have also added the
write memory barrier after ringing the doorbell register so that
controller sees the new request immediately.

Change-Id: Ifb3fb294eda81a5bccddb05227eade1b7453921a
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflict]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:57:39 -07:00
Subhash Jadavani
192ad80d14 scsi: ufs: change clock gating timeout to 50ms
Clock gating timeout is generally choosen such a way that it doesn't
impact storage benchmark performance numbers. Although current timeout
value of 150ms seems high hence this change reduces it to 50ms to save
power clock gating timeout. Reducing it to 50ms doesn't affect the
storage performance benchmark numbers.

Change-Id: Ia131fc420995f44d8446f3800c19de40fedea504
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:38 -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
Noa Rubens
cfd27bd4b7 scsi: ufs: update bus vector name used for slow-auto mode
Set the bus vector name used for slow-auto mode to be "MIN".
For each power mode a specific bus vector name should be selected
from UFS DTS node. Slow-auto mode was missing this specification.

Change-Id: I48de8e70823b75ed3bb4eefe7828f841f2e775eb
Signed-off-by: Noa Rubens <noag@codeaurora.org>
2016-03-22 10:57:35 -07:00
Maya Erez
2ab0dfad40 scsi: ufs: fix exception event handling
The device can set the exception event bit in one of the response UPIU,
for example to notify the need for urgent BKOPs operation.
In such a case the host driver calls ufshcd_exception_event_handler to
handle this notification.
When trying to check the exception event status (for finding the cause for
the exception event), the device may be busy with additional SCSI commands
handling and may not respond within the 100ms timeout.

To prevent that, we need to block SCSI commands during handling of
exception events and allow retransmissions of the query requests,
in case of timeout.

CRs-Fixed: 725525
Change-Id: I67a55ad5f891a018f1dfff319233f875789805a1
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-03-22 10:57:34 -07:00
Gilad Broner
963b684359 scsi: ufs: reduce UFS dump prints for error case
When UFS controller reports an error a dump is printed to
aid debugging. In certain cases the print outs is too excesive
and not all the information is really needed. In addition, printing
is done from interrupt context so long prints might cause the target
to crash.
This change reduces the amount of data printed out and moves part of
the printing to the worker thread context.

Change-Id: If3e13000b8165479f2dac4d0c8e513eaa9a3e3c2
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-22 10:57:33 -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
Subhash Jadavani
0a81142619 scsi: ufs: move dme peer quirk handling to ufshcd_dme_get_attr()
Some UFS host controllers may only allow accessing the peer DME attribute
in AUTO mode (FAST AUTO or SLOW AUTO) hence we had added a quirk for
switching to AUTO power mode before accessing the peer DME attribute.
But this quirk handling was only done in UFS driver's debugfs handling
hence this patch moves it to main driver ufshcd.c so that this quirk
handling is applied to all the peer DME accesses.

As we are doing this, this patch fixes 2 more related problem:
1. Current quirk was only handling the switch from FAST to FAST AUTO hence
this change adds the handling for SLOW to SLOW AUTO mode change as well.
2. ufsdbg_dme_read() helper function was always reading the local DME
attribute hence this change fix the same.

Change-Id: I475375fb57cd27cdafe1573c14d09dc7f9a2791b
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:31 -07:00
Subhash Jadavani
084930e1e4 scsi: ufs_quirks: fix card model string copy
Product name string (referred as "model" string in driver) starts from
offset 02h in Product Name String Descriptor but currently we copy the
product name from 00h offset of the descriptor which is incorrect.
This change fixes the above problem by copying the product name from
the right offset of the Product Name String Descriptor.

Change-Id: I0ab2ecc19c7383d9782ba57af6441175d2ecda46
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:30 -07:00
Subhash Jadavani
878c98c005 scsi: ufs: fix failure to read the string descriptor
While reading variable size descriptors (like string descriptor), some UFS
devices may report the "LENGTH" (field in "Transaction Specific fields" of
Query Response UPIU) same as what was requested in Query Request UPIU
instead of reporting the actual size of the variable size descriptor.
Although it's safe to ignore the "LENGTH" field for variable size
descriptors as we can always derive the length of the descriptor from
the descriptor header fields. Hence this change impose the length match
check only for fixed size descriptors (for which we always request the
correct size as part of Query Request UPIU).

Change-Id: I6be74b3e139b876275c265524cb6ee8489f3737c
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:30 -07:00
Subhash Jadavani
9d89b6c4c8 scsi: ufs-qcom: enable host controller hardware clock gating
The UTP controller has a number of internal clock gating cells (CGCs).
Internal hardware sub-modules within the UTP controller control the CGCs.
Hardware CGCs disable the clock to inactivate UTP sub-modules not involved
in a specific operation, UTP controller CGCs are by default disabled and
this change enables them (after every UFS link startup) to save some power
leakage.

Change-Id: I47bba62436c5913eb6755e59c36a11fea2e9468f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:29 -07:00
Subhash Jadavani
8c17ea4d5b scsi: ufs-qcom: add support for new UFS controller revisions
MSM8994v2 will have UFS controller revision 1.3.0 (major.minor.step)
hence update the quirks check for this revision as well.

Here is the list of UFS revisions (for quick reference):
	8084 : 1.1.1
	8994v1 : 1.2.0
	8994v2 : 1.3.0
	Future revisions: x.y.z where x >= 2

Change-Id: Iabc4b9117cda9d685e5a4fbaa9cc1f1bd40a5a60
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-03-22 10:57:28 -07:00
Subhash Jadavani
04218a4f78 scsi: ufs: debugfs: add option to read peer DME attribute
This patch adds the debugfs capability to read the DME attribute of
peer UniPro/M-PHY. This should help for debugging.

Change-Id: I26d3675bdda8b9fdf0f9aa6b81a1ffafbd828fd0
[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:27 -07:00
Yaniv Gardi
3997870e3b scsi: ufs: fix bug when changing power mode via debugfs
So far when required to change UFS power mode via debugfs the final power
parameters to which the UFS device is configured were determined based on
comparison between the new required power (gear, lane, mode) and qcom
pre-defined power preferences, and the minimum between them was the
configured power which is incorrect.
This change fixes this issue so what is done is a comparison between
the new required power and the device maximum supported power
parameters. If the new required power parameters exceed the device
maximum supported power, then the UFS power mode is not changed.

This change also contains a few cosmetic changes that simplify
code that is related to the above power change.

Change-Id: If08d3ce50af2dc17a6f68583dd1e7973aeb3c33a
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: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-03-22 10:57:26 -07:00
Subhash Jadavani
a343f60a46 scsi: ufs: add option to change default UFS power management level
UFS device and link can be put in multiple different low power modes hence
UFS driver supports multiple different low power modes. By default UFS
driver selects the default (optimal) low power mode (which gives moderate
power savings and have relatively less enter and exit latencies) but
we might have to tune this default power mode for different chipset
platforms to meet the low power requirements/goals. Hence this patch
adds option to change default UFS low power mode (level).

Change-Id: I45aaae9f46beb3b5d38bcc6dcbd728e79677276c
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:25 -07:00