OSDN Git Service
Subhash Jadavani [Tue, 4 Nov 2014 04:29:23 +0000 (20:29 -0800)]
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>
Gilad Broner [Sun, 26 Oct 2014 20:18:43 +0000 (22:18 +0200)]
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>
Subhash Jadavani [Thu, 23 Oct 2014 02:15:49 +0000 (19:15 -0700)]
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>
Subhash Jadavani [Thu, 23 Oct 2014 01:18:19 +0000 (18:18 -0700)]
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>
Maya Erez [Mon, 27 Oct 2014 19:57:45 +0000 (21:57 +0200)]
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>
Subhash Jadavani [Sun, 19 Oct 2014 08:35:36 +0000 (01:35 -0700)]
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>
Subhash Jadavani [Sat, 18 Oct 2014 00:35:06 +0000 (17:35 -0700)]
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>
Subhash Jadavani [Thu, 16 Oct 2014 19:44:01 +0000 (12:44 -0700)]
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>
Subhash Jadavani [Thu, 16 Oct 2014 02:11:03 +0000 (19:11 -0700)]
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>
Gilad Broner [Sun, 12 Oct 2014 16:13:50 +0000 (19:13 +0300)]
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>
Subhash Jadavani [Thu, 9 Oct 2014 10:00:27 +0000 (03:00 -0700)]
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>
Subhash Jadavani [Thu, 9 Oct 2014 09:54:41 +0000 (02:54 -0700)]
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>
Subhash Jadavani [Thu, 9 Oct 2014 02:08:10 +0000 (19:08 -0700)]
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>
Noa Rubens [Tue, 7 Oct 2014 16:52:57 +0000 (19:52 +0300)]
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>
Maya Erez [Thu, 2 Oct 2014 10:50:42 +0000 (13:50 +0300)]
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>
Gilad Broner [Wed, 1 Oct 2014 11:18:35 +0000 (14:18 +0300)]
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>
Subhash Jadavani [Fri, 26 Sep 2014 00:55:26 +0000 (17:55 -0700)]
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>
Subhash Jadavani [Thu, 25 Sep 2014 21:23:18 +0000 (14:23 -0700)]
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>
Subhash Jadavani [Thu, 25 Sep 2014 00:15:17 +0000 (17:15 -0700)]
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>
Subhash Jadavani [Thu, 25 Sep 2014 00:11:50 +0000 (17:11 -0700)]
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>
Subhash Jadavani [Sun, 21 Sep 2014 07:00:27 +0000 (00:00 -0700)]
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>
Subhash Jadavani [Fri, 19 Sep 2014 23:46:31 +0000 (16:46 -0700)]
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>
Subhash Jadavani [Sat, 13 Sep 2014 19:17:59 +0000 (12:17 -0700)]
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>
Yaniv Gardi [Fri, 12 Sep 2014 07:28:43 +0000 (10:28 +0300)]
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>
Subhash Jadavani [Thu, 11 Sep 2014 01:25:33 +0000 (18:25 -0700)]
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>
Subhash Jadavani [Wed, 10 Sep 2014 01:15:37 +0000 (18:15 -0700)]
scsi: ufs-qcom: enable hibern8 during clock gating
By default UFS link operates in FAST mode which would keep the link active
until host puts the link in hibern8. Power consumption during link active
state is huge hence it's recommended to put the link in hibern8 as soon
as possible. Clock gating mechanism kicks in after pre-defined idle timeout
(150ms at this time) shorter than the runtime suspend timeout hence it
would be idle to put the UFS link in hibern8 along with clock gating.
Note that this aggressive power management approach doesn't affect the
normal storage benchmark performance numbers as clock gating idle timeout
has been choosen to not affect storage performance benchmarks.
Change-Id: I5b88a7ea2d918750a3cc9150511e25caa1e57284
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Sat, 6 Sep 2014 01:13:41 +0000 (18:13 -0700)]
scsi: ufs: debugfs: add option to read local DME attribute
This patch adds the debugfs capability to read the DME attribute of
local UniPro/M-PHY. This should help for debugging.
Change-Id: I2dea471f6bcf591a69206e127d3c9e3febbbc68f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Sat, 6 Sep 2014 01:12:09 +0000 (18:12 -0700)]
scsi: ufs: remove unwanted checks from hibern8 sequence
We are unnecessarily checking for the request/task doorbell status
during hibern8 enter/exit path but it's very important to have the
minimal latencies for hibern8 enter/exit in order to achieve agressive
power management strategies for UFS. So these unecessary checks are moved
out of this hot path.
Change-Id: Ibaeddca7bd516d71eb03b02a1fc1a86f05038f08
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Yaniv Gardi [Wed, 3 Sep 2014 12:31:52 +0000 (15:31 +0300)]
phy: relocate and rename phy ufs files
This change contains:
1. Relocating the phy ufs files to reside under the phy driver since
this is the location of any file that implements the APIs presented in
the generic phy framework
2. Renaming ufs-msm-phy*.* files to be phy-qcom-ufs*.* files.
Since UFS is not used strictly in a specific set of targets but rather
its code is applicable to MSM, APQ, IPQ etc, any mentioning of "msm" in
the file name should be changed to "qcom".
Also, prefix of "phy-" is the naming convention of platform driver files
that reside in the phy driver.
3. As a result of the relocation of files into the phy driver,
a new path is created (include/linux/scsi/ufs) and there we expose ufs
header files that are being used also from the drivers/scsi/ufs
and from drivers/phy as well.
Change-Id: Ie5cb47718911ff711d9401a389f56fa508fcddf3
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: resolved merge conflicts by keeping
upstream version]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Yaniv Gardi [Tue, 2 Sep 2014 12:54:37 +0000 (15:54 +0300)]
ARM: dts: msm: rename attributes to more generic names
In this change the "compatible" attribute in dts files of ufsphy node
and the "phy-names" attribute in ufs node are changed to a more generic
name.
This is done for apq8084 and for msm8994 targets.
Change-Id: I46176459e9bc877456489e4728b86eecb2c16261
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts & dropped changes to
apq8084.dtsi & msm8994.dtsi]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Mon, 1 Sep 2014 14:40:41 +0000 (17:40 +0300)]
defconfig: change SCSI_UFS_MSM to SCSI_UFS_QCOM
Since UFS is not used strictly in a specific set of targets but rather
its code is applicable to MSM, APQ, IPQ etc, "SCSI_UFS_MSM" should be
changed to "SCSI_UFS_QCOM".
Change-Id: I8851907f86055bb5012cb4a00f81511529ba4e03
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts, dropped changes to
apq8084_defconfig & msm8994_defconfig files]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Yaniv Gardi [Mon, 1 Sep 2014 14:31:46 +0000 (17:31 +0300)]
scsi: ufs-msm: rename all entities from "msm" to "qcom"
Since UFS is not used strictly in a specific set of targets but rather
its code is applicable to MSM, APQ, IPQ etc, everywhere where
there is a use of "msm" should be replaced with "qcom".
Change-Id: Ib96259bab6de506a40876c1c121a12bb75b655c1
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>
Vikram Mulukutla [Sat, 23 Aug 2014 02:26:33 +0000 (19:26 -0700)]
scsi: ufs-msm: Add support for the new scm_call2 API
The scm library has added support for a new secure world
interface that is more aligned to the ARMv8 SMC calling
convention. Use the new API while maintaining backward
compatibility.
Change-Id: I19b523edb7a849f50916dbbd426c92cc4c459799
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Yaniv Gardi [Sun, 24 Aug 2014 13:09:38 +0000 (16:09 +0300)]
scsi: ufs-msm: remove redundant dependencies in header files
In this change we simply remove dependencies in header files as they are
not required.
Change-Id: I73298a603f205fc102e9a39711263a10ace489e9
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Yaniv Gardi [Thu, 21 Aug 2014 11:51:54 +0000 (14:51 +0300)]
scsi: ufs-msm: remove global variable that is not in use
In this change a global variable which is never referenced is being
removed.
Change-Id: I2eda5157cf5e77e61d776d450cb036ca51027a08
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Subhash Jadavani [Tue, 19 Aug 2014 01:34:36 +0000 (18:34 -0700)]
scsi: ufs-msm: request UFS register space access after power collapse
Following UFS core power collapse, all the TZ programmed xPU protection
settings would be lost and default protection settings won't allow access
to even UFS host controller register address space from non-secure world.
Hence we have to explicitly call into TZ to open up atleast UFS host
controller & UFS PHY register address space access to non-secure world.
Change-Id: Ic05c88e418484a10ad0d651fe2295916117c085e
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts]
Signed-off-by: Gilad Broner <gbroner@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>
Yaniv Gardi [Tue, 19 Aug 2014 21:12:01 +0000 (00:12 +0300)]
scsi: ufs: null terminate buffer that is sent to strlcpy
strlcpy() must get null-terminated buffer as a second argument because
inside strlcpy(), strlen() is invoked on that argument, and unterminated
buffer will result incorrect value.
In this case, str_desc_buf is a buffer that might return from
ufshcd_read_string_desc() when it is no longer null-terminated.
Therefor we must null-terminate it before sending it to strlcpy().
This change also fixes the type of the vendor variable that is read
from the device descriptor. According to UFS device specification this
field is 2 bytes wide. Its name is also changed to be compatible
with UFS device specification.
Change-Id: I3b1ba0311846881a1f3f1c984cc6f9d7109821b3
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Subhash Jadavani [Fri, 15 Aug 2014 00:54:02 +0000 (17:54 -0700)]
scsi: ufs: fix deadlock when attempting hibern8 during clock gating
If UFSHCD_CAP_HIBERN8_WITH_CLK_GATING capability is enabled then UFS
driver should put the link in hibern8 along with gating of UFS related
clocks but we are hitting the deadlock in this case. UFS gating work
calls the ufshcd_uic_hibern8_enter() which would call the helper function
ufshcd_uic_pwr_ctrl(). ufshcd_uic_pwr_ctrl() calls ufshcd_hold() to make
sure that clocks are ungated which means clock ungate work would end up
waiting for the gate work to finish which causes the deadlock (as gate
work is waiting for ufshcd_uic_pwer_ctrl() to finish).
Fix this issue by letting the callers of ufshcd_uic_pwr_ctrl() to decide
if they really need to vote for the UFS clocks or not.
Change-Id: I5b9d1a1c75bbc5a7097e6cc71cd9ec6885cd271a
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Fri, 15 Aug 2014 00:56:47 +0000 (17:56 -0700)]
scsi: ufs: avoid spurious UFS host controller interrupts
When control reaches to Linux UFS driver during UFS boot mode, UFS host
controller interrupt status/enable registers may have left over settings.
In order to avoid any spurious interrupts due to these left overs, it's
important to clear these interrupt status/enable registers before enabling
UFS interrupt handling.
CRs-Fixed: 709250
Change-Id: Ibb554ca6e1bd2f69663a741f15948f80c52ce75c
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Wed, 6 Aug 2014 21:10:25 +0000 (14:10 -0700)]
scsi: ufs: fix suspend/resume tracing message
Tracing message for suspend/resume events is wrongly printing the device
state as link state and link state as device state. This change fixes the
same and while we are here, fix the device and link state string to be more
readable.
Change-Id: Ifc878b84345bf4f7be56102d4972cbac039b78ed
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Wed, 6 Aug 2014 15:11:52 +0000 (18:11 +0300)]
scsi: ufs-msm: remove unnecessary callbacks of generic PHY framework
In this change unnecessary callbacks of the generic PHY framework
are removed and instead we call the required operations directly in
the driver.
The callbacks that were removed are:
phy_suspend(), phy_resume() and advertise_quirks()
In addition, one specific callback of the generic PHY is added:
restore_configuration() as complementary callback of save_configuration().
Change-Id: Iaf2be3ebff7a9978adae50c3f2617714106c40ac
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Yaniv Gardi [Thu, 31 Jul 2014 21:54:26 +0000 (00:54 +0300)]
scsi: ufs: fix a possible kernel info leak to userspace
This change fixes a possible info leak from kernel into userspace, since
two buffers were allocated with kmalloc() and never set their memory
region to 0.
Now, they are being allocated with kzalloc that fixes this issue
Change-Id: I23012ae8d3611c561511775362c3014b9a8be522
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Yaniv Gardi [Wed, 30 Jul 2014 16:36:34 +0000 (19:36 +0300)]
scsi: ufs: fix bugs related to null pointer access and array size
In this change there are a few fixes of possible NULL pointer access
and possible access to index that exceeds array boundaries.
Change-Id: I4a2dbc417d53931e012925978cd52e3397356ec2
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Mon, 28 Jul 2014 20:06:11 +0000 (23:06 +0300)]
scsi: ufs: enable ufs driver to support generic PHY framework
In this change, ufs driver is using the generic PHY framework,
by calling the API "devm_phy_get" that returns handle to a generic
PHY driver.
In this change "__maybe_unused" flag of a few callbacks is removed
since those callbacks are now hooked to generic PHY driver APIs that
were added.
This change also includes the required DT changes as in this case,
the driver changes derived from the DT changes and therefor must
be placed within the same change.
Change-Id: I10e15e25d050bedca55a058b79240360564aebcd
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflict]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Yaniv Gardi [Mon, 28 Jul 2014 19:25:34 +0000 (22:25 +0300)]
scsi: ufs-msm: disable using generic PHY framework
This change disables the use of the generic PHY framework API and
callbacks.
This change is only temporary and eventually UFS will use the
updated generic PHY framework API.
The reason for temporary disabling the use of the generic PHY framework,
is due to generic PHY changes in the upstream that are required to be
merged and would result into many conflicts.
In this change, calling to devm_phy_get_by_index() is removed.
Following, the API itself will be removed from the generic PHY framework,
and changes from the upstream will be cherry-picked.
Also, hooking resume, suspend and advertise_quirks is temporary removed
to avoid compilation errors.
After merging all generic PHY framework changes from the upstream,
the UFS driver will call the updated API in order to get its correct
generic PHY and will hook the local implementation of resume, suspend
and advertise_quirks into the correct hooks.
Change-Id: I2bf1007ecf079bc82f472a17538a17dc452ea447
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Subhash Jadavani [Tue, 25 Feb 2014 08:55:10 +0000 (00:55 -0800)]
scsi: ufs-msm: probe UFS only if it is the boot device
Boot device can be either UFS or eMMC which means if eMMC is the boot
device, probing UFS device is not desirable as it's not going to be
used after probing. Kernel command line parameter "android.bootdevice"
tells the kernel about the boot device so look at this boot device
parameter to know whether to probe UFS device or not.
Change-Id: I053b9611088263cd8de64085754c00d082aec3ed
[subhashj@codeaurora.org: resolved merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Mon, 21 Jul 2014 22:26:10 +0000 (01:26 +0300)]
scsi: ufs-msm-phy: fix false error message
This change fixes error message that falsely was printed out
unconditionally.
A fix condition is now added.
Change-Id: I8d70d7f27c7dc122ecda64bea1a51f0044047e5b
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Subhash Jadavani [Fri, 18 Jul 2014 18:39:16 +0000 (11:39 -0700)]
scsi: ufs-msm-phy-qmp-20nm: fix hibern8 exit failure
If UFS link is put into Hibern8 and if UFS PHY analog hardware is power
collapsed (by clearing UFS_PHY_POWER_DOWN_CONTROL), Hibern8 exit might fail
even after powering on UFS PHY analog hardware. This change provides
workaround to solve above issue by doing custom PHY settings just before
PHY analog power collapse.
Change-Id: I63d43329798c5475e07511248ac35450b8fe208d
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Wed, 16 Jul 2014 20:46:05 +0000 (23:46 +0300)]
scsi: ufs: remove code duplication from ufs specific phy
In this change, code that is duplicated in specific ufs msm PHYs
modules is removed, and helper functions that contain the common
code are added to ufs-msm-phy.c.
Change-Id: I30ca8b4d4b452450a155671da94f03d7b965160a
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: fixed compilation errors]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Wed, 16 Jul 2014 22:41:59 +0000 (01:41 +0300)]
scsi: ufs-msm: re-factoring the ufs phy to support various phys
This re-factor is required in order to provide a robust way to support
multiple ufs phys. It also creates a better separation between
ufs-msm block, ufs-msm-phy block and the specific phy blocks.
In this change a generic phy handle is created, using the phy driver
framework.
Two ufs phys are currently supported: 28nm and 20nm
This change also includes the required DT changes as in this case,
the driver changes and the DT changes must be placed within the same
change.
Change-Id: I3aa7ed942ed7b54f3a29c9b9dbdeff1861079066
Signed-off-by: Noa Rubens <noag@codeaurora.org>
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts in apq8084 and msm8994
device tree files]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts, dropped changes to
msm8994.dtsi and fixed compilation errors]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Stepan Moskovchenko [Sat, 14 Jun 2014 02:12:25 +0000 (19:12 -0700)]
drivers: msm: Fix a handful of compiler warnings
Compiling the kernel with the -O2 GCC flag reveals a number
of warnings relating to potentially uninitialized variables
and other edge cases.
Change-Id: I3758dbe1af276d79f55188b9f2db850c730acb80
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
[gbroner@codeaurora.org: drop changes to all file besides
ufs-msm.c and ufshcd.c]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Yaniv Gardi [Tue, 10 Jun 2014 01:03:46 +0000 (18:03 -0700)]
scsi: ufs: add quirks for a new UFS host controller version
This change adds a new set of UFS host controllers quirks as there
is a new version of UFS controllers.
Change-Id: Ie0f96f7fbc8928d29cd760c14258d8497a979a99
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Subhash Jadavani [Sat, 10 May 2014 00:44:00 +0000 (17:44 -0700)]
scsi: ufs: fix deadlock during runtime resume
Commit
e21cdd59b6fbaeaf3ab0043fc49287f554fa8696 (scsi: ufs: Change power
mode at run-time via debug-fs) has introduced bug where
pm_runtime_get_sync() might get called in UFS driver's runtime resume
callback context which will cause the deadlock as pm_runtime_get_sync()
waits for the runtime resume callback to finish.
This change fixes the above bug by moving pm_runtime_get_sync() call out
of runtime resume callback context.
Change-Id: I1efa68510eb2545fc043dfa4d8bfe6f6c36ef6a8
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Thu, 1 May 2014 01:23:07 +0000 (18:23 -0700)]
scsi: ufs: provide sysfs attribute to select the PM level
This patch provides the sysfs attribute to choose the power management
level for UFS runtime and system suspend.
Change-Id: I5beedadff1ac3a1ac1f8d36ab88fc3b2ecb75e88
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Thu, 1 May 2014 00:37:18 +0000 (17:37 -0700)]
scsi: ufs-msm: disable the sigdet before power collapsing PHY
If UFS PHY power down is deasserted and power is restored to analog
circuits, the rx_sigdet can glitch. If the glitch is wide enough,
it can trigger the PHY digital logic to think it saw a DIF-N and
cause it to exit Hibern8. Disabling the rx_sigdet during power-up
will mask the glitch.
Change-Id: I20d93d2f5b479bb9e1d9626cfb9939d280b172a5
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Gilad Broner [Tue, 4 Mar 2014 15:40:54 +0000 (17:40 +0200)]
scsi: ufs: Change power mode at run-time via debug-fs
Add 'power_mode' entry to UFS debug-fs to allow query of current
power mode status and changing the power mode by writing to the
entry a string in the format 'GGLLMM' where:
G - selected gear
L - number of lanes
M - power mode
(1=fast mode, 2=slow mode, 4=fast-auto mode, 5=slow-auto mode)
First letter is for RX, second is for TX.
Change-Id: Ia48cb2719bb11e66bca923c5f4647a33cbd6c43e
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts]
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>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Sahitya Tummala [Thu, 27 Mar 2014 10:21:56 +0000 (15:51 +0530)]
scsi: ufs: Add sysfs node to dynamically control clock scaling
Provide an option to enable/disable clock scaling during runtime.
Write 1/0 to "clkscale_enable" sysfs node to enable/disable clock
scaling.
Change-Id: I67a6cd317d3dca97a992e240c970719f85067cd8
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Tue, 15 Apr 2014 19:50:44 +0000 (22:50 +0300)]
scsi: ufs: add debug counters for recoverable errors during runtime
There is no way to know how many times various UFS errors happened
while system is running if we have successfully recovered from those
errors. Those failures should be counted and inspected as they might be
anomaly behavior of the driver and can impact performance.
This change adds support to capture these failures statistics like how
many times we have seen errors, and which type of errors.
To reset the counters:
echo 1 > /sys/kernel/debug/ufs/err_stats
To print them out:
cat /sys/kernel/debug/ufs/err_stats
Note: There is no need to enable them as they are never disabled.
This error counters are something that we always would like to have.
Change-Id: I559c729b998f79c6bdda2da54c0f0ec7531696d7
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Sun, 6 Apr 2014 07:46:44 +0000 (10:46 +0300)]
scsi: ufs: cleanup unused quirks
We had added many host and device quirks support non commercial UFS device
and UFS controller. As these quirks are not required in commercially
available UFS devices and UFS controller, we should offload driver from
maintaining these unused quirks.
Change-Id: If721d71b41e19e6c68af49403a0043bf40266ffa
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Raviv Shvili <rshvili@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>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Sahitya Tummala [Fri, 28 Mar 2014 04:12:09 +0000 (09:42 +0530)]
scsi: ufs: Add sysfs node to dynamically control clock gating
Provide an option to enable/disable clock gating during runtime.
Write 1 or 0 to "clkgate_enable" sysfs node to enable/disable
clock gating.
Change-Id: I69a20e66cf91bb889ac3942eb2d20d5adc289d03
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Raviv Shvili [Tue, 1 Apr 2014 19:20:15 +0000 (22:20 +0300)]
scsi: ufs: seperate device and host quirks
Currently we use the host quirks mechanism in order to
handle both device and host controller quirks.
In order to support many UFS devices we should separate
handling the device quirks from the host controller's.
Change-Id: I6c23be42ff78689f9aad4d5c0c9f0a678bfb5c14
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Raviv Shvili [Sun, 30 Mar 2014 10:36:05 +0000 (13:36 +0300)]
scsi: ufs: add read string descriptor api
The string descriptor may consist of up to 126 UNICODE characters.
The number of UNICODE characters is calculated
by (descriptor's length - 2)/2.
In addition the api allows to get the result in an ascii format.
Change-Id: If43453bf5f9a826900c0acc064e8def275c0f7d1
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
Raviv Shvili [Thu, 20 Mar 2014 19:33:04 +0000 (21:33 +0200)]
scsi: ufs: add descriptor read support
Allow reading descriptors with length which is different
than the descriptors max size.
Change-Id: Ia0685ae147883f33466865d2348d71473e0d5173
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
Subhash Jadavani [Thu, 20 Mar 2014 22:52:09 +0000 (15:52 -0700)]
scsi: ufs: add additional tracing messages
This patch adds following tracing messages:
- Add support to trace the automatic background operations enable/disable
events.
- Add addition logs to trace the UFS device and UFS link state during
suspend/resume and initialization.
Change-Id: I732b255296042442e50278c2700c52bd166e1d8b
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Thu, 20 Mar 2014 19:46:14 +0000 (12:46 -0700)]
scsi: ufs-msm: remove UFSHCD_BROKEN_LCC_PROCESSING_ON_DEVICE quirk
New commercial UFS devices don't have the issues with LCC processing
but UFS host controller might still have the issue with LCC processing
hence keep the UFSHCD_BROKEN_LCC_PROCESSING_ON_HOST quirk enabled but
disable the UFSHCD_BROKEN_LCC_PROCESSING_ON_DEVICE quirk.
Change-Id: Ib3d563553878eec39c677f38af1545f470e8ee9b
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Thu, 20 Mar 2014 19:41:53 +0000 (12:41 -0700)]
scsi: ufs: split broken LCC quirk
Currently when UFSHCD_BROKEN_LCC quirk is defined, LCC is getting
disabled on both host and device side but there could be a need
where we don't want to disable the LCC on both side hence this change
splits the quirk in 2 parts one for host and one for device.
Change-Id: I906a24a428665e3ee67a4c2ec3fc31f47e5c7e3c
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Subhash Jadavani [Thu, 20 Mar 2014 22:42:42 +0000 (15:42 -0700)]
scsi: ufs-msm: allow background operations during runtime suspend
Allow the card to perform background operations during runtime suspend.
Change-Id: Ie93b4ad795f7afb05addb551f73fca853ecd4769
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Dolev Raviv [Thu, 20 Mar 2014 09:21:56 +0000 (11:21 +0200)]
Revert "scsi: ufs: try read capacity (10) first"
This reverts commit
7d76a33cac7040f3e05c1a49fc312e53dc3b2f1c.
Read capacity (16) is used, in addition to reading capacity, for
reading unmap command parameters. In UFS spec since v2.0 read
capacity (16) command is mandatory for embedded devices.
If read capacity (16) is not supported by the device then it simply
rejects the scsi command with ILLEGAL_REQUEST in sense key. The sd
driver then retries with read capacity (10), thus keeping backward
compatibility.
Change-Id: Iaa2acdfab0d7f0f6e1ef20e370195a3b64068216
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Subhash Jadavani [Sat, 1 Mar 2014 09:18:22 +0000 (01:18 -0800)]
scsi: ufshcd: fix one of the argument type for ufshcd_query_descriptor
ufshcd_query_descriptor() function should take the descriptor id as one of
its argument but type of this argument is incorrect, hence fix it here.
Change-Id: If83b551b2bc4da644d03a0ae37b2e83dc7909b43
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts and add missing
function signatures]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Tue, 25 Feb 2014 08:55:10 +0000 (00:55 -0800)]
scsi: ufs-msm: probe UFS only if it is the boot device
Boot device can be either UFS or eMMC which means if eMMC is the boot
device, probing UFS device is not desirable as it's not going to be
used after probing. Kernel command line parameter "android.bootdevice"
tells the kernel about the boot device so look at this boot device
parameter to know whether to probe UFS device or not.
Change-Id: I053b9611088263cd8de64085754c00d082aec3ed
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Wed, 26 Feb 2014 05:43:07 +0000 (21:43 -0800)]
scsi: ufshcd: release resources if probe fails
If ufshcd pltfrm/pci driver's probe fails for some reason then ensure that
scsi host is released to avoid memory leak but managed memory allocations
(via devm_* calls) need not to be freed explicitly on probe failure as
memory allocated with these functions is automatically freed on driver
detach.
Change-Id: Ic88c3e1d29a6b03e9a79201d3790f26bc4ccae61
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[gbroner@codeaurora.org: fix minor merge conflicts]
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>
Subhash Jadavani [Fri, 14 Feb 2014 01:39:28 +0000 (17:39 -0800)]
scsi: ufs-msm: enable power management
Until now due to issues with UFS host controller (especially with version
1.1.0) and UFS device, UFS power management was not enabled but now as UFS
link hibernate and UFS device sleep functionalities are stable, we are
enabling the level 3 power management which puts UFS link in hibernate and
UFS device in sleep state during suspend.
Change-Id: I0376bb3bfa47f4fa13527f496258862f10ffe07a
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Thu, 13 Feb 2014 19:50:37 +0000 (11:50 -0800)]
scsi: ufs-msm: avoid full UFS initialization on system resume
As part of UFS power management, UFS link would be put in hibernate and
UFS device would be put in SLEEP mode as part of runtime/system suspend
callback. But when system goes into suspend with VDD minimization, UFS
PHY states are being reset which means UFS link hibernate exit command on
system resume would fail. There are 2 ways to workaround this issue, one
is to reinitialize the entire UFS link on system resume but it has very
high latency of ~150ms whereas other acceptable workaround is to save
the UFS PHY state information before system goes into suspend and restore
this state information during system resume but before executing the
hibernate exit command. This change implements the 2nd workaround.
Change-Id: I061871321b9c0e6386188355858217dcedd4f20a
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts, dropped changes to
ufshcd.c & unipro.h]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Thu, 23 Jan 2014 01:54:12 +0000 (17:54 -0800)]
scsi: ufs: increase the query request timeout
Some of the query requests like reading the fDeviceInit flag
and reading the ref_clk attribute could take more than current
timeout value of 30ms and hence we might see error messages
printed in kernel logs even though next retries are going to
succeed. Hence its better to increase the query request timeout
to 100ms which seems good enough for all query requests to be
completed.
Change-Id: I57ed50e25131677ee6cab6b63ccacf7020f2b501
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Fri, 10 Jan 2014 22:23:52 +0000 (14:23 -0800)]
scsi: ufs-msm: inform PHY about analog rails power down
UFS PHY analog rails (VDDA_PHY_0P9 & VDDA_PLL_1P8) can be power collapsed
while the UFS link is in hibern8 state but PHY needs to be informed about
the power collapse by writing 0 to its power down control register. If PHY
is not informed about it, hibern8 exit might fail. This fixes this problem.
Change-Id: If897681569ca0073f2075acf8a9014da8d762827
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Wed, 12 Feb 2014 05:44:43 +0000 (21:44 -0800)]
scsi: ufs-msm: enable quirk to fix gear change to HS
With the G3 UFS devices, changing gear into HS is failing.
The quirk solves the problem of changing gear into HS by enabling
the attribute that specifies whether or not the inbound Link supports
unterminated line in HS mode.
This change enables the quirk.
Change-Id: I2a2fcb9dd0233e4dee7cc2443b6a60808e62da7c
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Dolev Raviv [Wed, 12 Feb 2014 08:25:13 +0000 (10:25 +0200)]
scsi: ufs: fix multiple ufs spec violation
When a command to a W-LU is timed out via scsi, error handling
will treat it as any other LU and send commands such as
START_STOP with wrong format or task abort. Those commands are
illegal for W-LU according to the UFS spec.
To solve it, when an error is recognized those steps are skipped
and the last step, reset and restore process, is initiated.
Change-Id: I7ff2a8d3c816adf5e1bf3762c0a6c342be7e83ea
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Yaniv Gardi [Wed, 12 Feb 2014 01:13:33 +0000 (17:13 -0800)]
scsi: ufs-msm: change default working mode in HS to rate A
So far, we used to work in the maximum HS (High Speed) rate available
by the UFS device (and supported by the controller) which is rate B.
This change changes the default working rate from rate B to rate A,
in order to gain more stability.
Change-Id: I797485b9699c5dab2a294b524f27c8e327b1e62d
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Yaniv Gardi [Wed, 15 Jan 2014 21:34:34 +0000 (23:34 +0200)]
scsi: ufs-msm: add PHY calibration values for UFS controller 1.1.1
The PHY should be calibrated with set of values based on the UFS
controller revision.
In this patch the UFS controller revision is read, and based on it,
it is decided which set of values to use in order to calibrate the PHY.
Change-Id: I369f9332df95364ee9e2ed83c8ce1bf5a28565c0
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Yaniv Gardi [Wed, 15 Jan 2014 21:57:53 +0000 (23:57 +0200)]
scsi: ufs: disable LCC configuration in the UFS device
LCC configuration that is needed for optical connections, is not needed
when working with UFS devices. As this values is already disabled
in the host, it should also be disabled in the device.
Change-Id: I81a6ac7310ff9dbf2d6c571431e62beab107fdf2
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Subhash Jadavani [Fri, 10 Jan 2014 22:12:48 +0000 (14:12 -0800)]
scsi: ufs-msm: enable UFSHCD_BROKEN_LCC
LCC (Line Control Command) are being used for communication between
UFS host and UFS device. But UFS host controller on our MSM have the issue
with issuing the LCC commands to UFS device and hence disable LCC from
host side.
Change-Id: I155b6a4a1adb77c40c5b5e642b3a034ee24659f3
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Fri, 10 Jan 2014 22:07:26 +0000 (14:07 -0800)]
scsi: ufs: provide the quirk to disable the LCC
LCC (Line Control Command) are being used for communication between
UFS host and UFS device. But some hosts might have the issue with
issuing the LCC commands to UFS device and in this case LCC could be
explicitly disabled from the host side.
Change-Id: I7b4d4a46d8d4e70bde088a5652decc7ba86a5617
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Fri, 10 Jan 2014 19:14:16 +0000 (11:14 -0800)]
scsi: ufs-msm: don't enable interrupt aggregation
Current versions of UFS host controllers on our MSMs have interrupt
aggregation logic broken. Interrupt aggregation may not work if both
threshold count and timeout is enabled. Hence disable interrupt
aggregation by enabling UFSHCD_QUIRK_BROKEN_INTR_AGGR quirk until
its fixed in the newer UFS host controller revisions.
Change-Id: I063c6d577c370bfcf5648b4b0df9292c30984c63
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Noag [Wed, 15 Jan 2014 08:52:53 +0000 (10:52 +0200)]
scsi: ufs: read ref clk and icc level during init only
In order to minimize resume latency, pre-fetch
icc levels and reference clock during initialization
and avoid reading them each link startup
during resume.
Change-Id: Iab705068e46114eb3caa00c6e1b88a7862385d08
Signed-off-by: Noag <noag@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Sahitya Tummala [Mon, 13 Jan 2014 09:54:18 +0000 (15:24 +0530)]
scsi: ufs-msm: Add hba->vops->clk_scale_notify()
Add hba->vops->clk_scale_notify() to get notified about clock
scaling and thus to configure phy timers and to update the
bus bandwidth vote accordingly.
Change-Id: I2f0cae8e787d0b4e764dc210db035add880428ce
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Sahitya Tummala [Thu, 2 Jan 2014 07:57:14 +0000 (13:27 +0530)]
scsi: ufs: Add support for clock scaling using devfreq framework
The clocks for UFS device will be managed by generic DVFS (Dynamic
Voltage and Frequency Scaling) framework within kernel. This devfreq
framework works with different governors to scale the clocks. By default,
UFS devices uses simple_ondemand governor which scales the clocks up if
the load is more than upthreshold and scales down if the load is less than
downthreshold.
Change-Id: I1c3944a5b1771b967c1df3e441a75fd584d6e2a5
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[gbroner@codeaurora.org: fix usage of devfreq governor data]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts, dropped most of the
changes as they are already present on baseline]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Dolev Raviv [Sun, 12 Jan 2014 11:51:23 +0000 (13:51 +0200)]
scsi: ufs: add queue fullness statistics
Add more statistics to allow tracking of tags occupancy
upon sending a new request. The statistics is kept separately
for 4 types of requests: read, write, urgent and flush.
All will consist only of data requests (eg. read, write, urgent).
This statistic is an enhancement of current tag statistic and
uses same infrastructure.
Change-Id: If5cea4aec4e94081d568a3661584b31665becfc6
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Thu, 9 Jan 2014 11:18:55 +0000 (13:18 +0200)]
scsi: ufs-msm: fix a wrong condition when checking array size
This change fixes a wrong condition that results a false error message
Change-Id: Iacb9224eaa908c0eec612fe3570b38ada3f90b37
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Raviv Shvili [Thu, 9 Jan 2014 08:22:16 +0000 (10:22 +0200)]
scsi: ufs: fix crash upon reading host_regs debugfs entry
While reading host_regs debugfs entry, UFS controller
might be in low power mode. While in UFS runtime suspend mode the host
controller is being unclocked.
Reading the unclocked host controller registers, may cause a system crash.
In order to avoid that, UFS runtime suspend should be
held and released when done.
CRs-fixed: 594618
Change-Id: I4b850806352b59192340bc5b0bb480b4dd6553f1
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Subhash Jadavani [Fri, 3 Jan 2014 19:08:35 +0000 (11:08 -0800)]
scsi: ufs-msm: enable workarounds for APQ8084 v1.1
Some of the workarounds (like skipping the suspend and giving 1ms delay
before every UIC DME commands) are still needed to enable the booting
from UFS device on APQ8084 v1.1 as well. This patch enables those
workarounds.
Change-Id: I6023403130e3ff87f918e1ab7eaf5a145935bfab
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Noag [Mon, 30 Dec 2013 08:58:58 +0000 (10:58 +0200)]
scsi: ufs: remove redundant "Illegal ufs-IOCTL" log for BLKROSET command
This patch prevents the "ufshcd_ioctl: Illegal ufs-IOCTL cmd 4701" log
message from being printed during boot time.
4701(BLKROSET) is not supported but not an Illegal command to UFS.
CRs-fixed: 580449
Change-Id: I20d54b23c09bd8b72b671b979103424e2050e15f
Signed-off-by: Noa Rubens <noag@codeaurora.org>
Sahitya Tummala [Tue, 17 Dec 2013 06:17:32 +0000 (11:47 +0530)]
scsi: ufs-msm: Enable clock gating
Enable relevant PHY clocks to be turned off as part of ufshcd
clock gating. Also, enable clock gating by setting necessary
capabilities.
The clock gating delay is currently set to 150ms by default. It can
be changed if required via sysfs -
echo xx > /sys/bus/platform/devices/msm_ufs.1/clkgate_delay_ms
Change-Id: I41c0b4c560711540cc0630e752d7843fca3fb26c
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Sahitya Tummala [Tue, 17 Dec 2013 06:16:13 +0000 (11:46 +0530)]
scsi: ufs: Add support for clock gating
The UFS controller clocks can be gated after certain period of
inactivity, which is typically less than runtime suspend timeout.
In addition to clocks the link will also be put into Hibern8 mode
to save more power.
The clock gating can be turned on by enabling the capability
UFSHCD_CAP_CLK_GATING. To enable entering into Hibern8 mode as part of
clock gating, set the capability UFSHCD_CAP_HIBERN8_WITH_CLK_GATING.
The tracing events for clock gating can be enabled through debugfs as:
echo 1 > /sys/kernel/debug/tracing/events/ufs/ufshcd_clk_gating/enable
cat /sys/kernel/debug/tracing/trace_pipe
Change-Id: I3e5e7e78130941ad7109fc05a46d7c3720245a1a
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts, dropped most of the
changes as they are already present on baseline]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Sahitya Tummala [Wed, 18 Dec 2013 08:19:27 +0000 (13:49 +0530)]
scsi: ufs-msm: Fix hba variant host op init and setup_clocks
Handle the case where vops->setup_clocks is called before vops->init()
from ufshcd driver.
Change-Id: I4754b658c1f37db6418560321f5dfe7a4650692b
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Yaniv Gardi [Sun, 22 Dec 2013 19:07:09 +0000 (21:07 +0200)]
scsi: ufs: save and print current power info in the driver
There is no way to know the current working power info of the
driver, so in this patch, we save the power parameters, and we
print them to console.
This printing is necessary, since in case of crash, we can use those
logs to debug and investigate.
Change-Id: If0dc7a695c9b14a369e033e4c31787dcc2254ac3
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Thu, 26 Dec 2013 08:57:31 +0000 (10:57 +0200)]
scsi: ufs-msm: add clock frequency table for Rate B
The UFS driver is now supporting working in HS (High Speed), Rate B.
Hence, we need to add a static table of clock frequency for rate B gears.
Also, this change fixes array access to index -1, in certain corner
cases, and report illegal values that are returned from
msm_ufs_cfg_timers() routine
Change-Id: Id05321c4fd3ebcc509c6b53f3722c3acfb48cad3
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: fixed compilation errors]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Wed, 25 Dec 2013 09:57:28 +0000 (11:57 +0200)]
scsi: ufs-msm: enable quirk for broken mode of TX 2 lanes
The default working mode should be TX 2 lanes, but
as this mode is not stable on the current controller, this quirk is
required so the unique mode will be TX 1 lane.
Change-Id: Iac8ed83207d66b8bd6a50cf1983f89df85525904
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Yaniv Gardi [Wed, 25 Dec 2013 09:51:59 +0000 (11:51 +0200)]
scsi: ufs: add a quirk for broken mode of TX 2 lanes
The default working mode should be TX 2 lanes, but
as this mode is not stable on the current controller, this quirk is
required so the unique mode will be TX 1 lane.
Change-Id: Id2dc9e2a1b481007a894f0828d15d8f8ad61215c
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Yaniv Gardi [Sun, 8 Dec 2013 13:56:38 +0000 (15:56 +0200)]
scsi: ufs-msm: change default working mode to rate B
Working throughput in UFS is affected by Gear, Number of lanes, and Mode
(PWM: Slow / SlowAuto,
or
HS: Fast /FastAuto).
When working in HS, throughput is affected by additional parameter -
Rate (A / B).
Here, we change the default working rate in HS to Rate B.
Change-Id: I35f63d5fc90ad1be19d886dda0bdcd4e54fe9c4c
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Subhash Jadavani [Fri, 4 Oct 2013 10:53:14 +0000 (16:23 +0530)]
scsi: ufs-msm: switch off PHY PLL power rail during hibern8
If UniPro link is in Hibern8 state, low noise analog power rail for PLL
can be switched off along with main PHY analog power.
Change-Id: I20b113e5f004c824c330f72dc7649dac961bfe3e
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>