Commit graph

12975 commits

Author SHA1 Message Date
Yaniv Gardi
8c9b78c1e6 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>
2016-03-22 10:57:19 -07:00
Vikram Mulukutla
daf2901cea 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>
2016-03-22 10:57:18 -07:00
Yaniv Gardi
286a95d6e4 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>
2016-03-22 10:57:17 -07:00
Yaniv Gardi
5c6863a9fe 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>
2016-03-22 10:57:16 -07:00
Subhash Jadavani
ffbed02d43 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>
2016-03-22 10:57:15 -07:00
Yaniv Gardi
e740ae3bbe 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>
2016-03-22 10:57:14 -07:00
Subhash Jadavani
155737fa4e 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>
2016-03-22 10:57:13 -07:00
Subhash Jadavani
2fcdc6a234 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>
2016-03-22 10:57:12 -07:00
Subhash Jadavani
39585f2c5d 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>
2016-03-22 10:57:12 -07:00
Yaniv Gardi
8a18d53c38 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>
2016-03-22 10:57:11 -07:00
Yaniv Gardi
6b3f3f257a 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>
2016-03-22 10:57:10 -07:00
Yaniv Gardi
3281c7b77e 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>
2016-03-22 10:57:09 -07:00
Yaniv Gardi
50d8c77160 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>
2016-03-22 10:57:08 -07:00
Yaniv Gardi
1a66630ba5 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>
2016-03-22 10:57:07 -07:00
Subhash Jadavani
ad23ac52aa 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>
2016-03-22 10:57:06 -07:00
Yaniv Gardi
6e0c7d723b 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>
2016-03-22 10:57:05 -07:00
Subhash Jadavani
6063aa8a3d 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>
2016-03-22 10:57:04 -07:00
Yaniv Gardi
f6ffbc88ef 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>
2016-03-22 10:57:04 -07:00
Yaniv Gardi
b06e5004fb 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>
2016-03-22 10:57:03 -07:00
Stepan Moskovchenko
47bce9e8ba 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>
2016-03-22 10:57:02 -07:00
Yaniv Gardi
892a7155cd 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>
2016-03-22 10:57:01 -07:00
Subhash Jadavani
f0e61863c7 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>
2016-03-22 10:57:00 -07:00
Subhash Jadavani
59ba60c7e4 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>
2016-03-22 10:56:59 -07:00
Subhash Jadavani
e318d1fa2c 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>
2016-03-22 10:56:58 -07:00
Gilad Broner
0531f43f34 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>
2016-03-22 10:56:57 -07:00
Sahitya Tummala
63078101ef 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>
2016-03-22 10:56:56 -07:00
Yaniv Gardi
9e50710114 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>
2016-03-22 10:56:56 -07:00
Subhash Jadavani
9f27005027 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>
2016-03-22 10:56:55 -07:00
Sahitya Tummala
36d8e79c02 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>
2016-03-22 10:56:54 -07:00
Raviv Shvili
61df89e001 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>
2016-03-22 10:56:53 -07:00
Raviv Shvili
125fc97a4f 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>
2016-03-22 10:56:52 -07:00
Raviv Shvili
a7da3b2959 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>
2016-03-22 10:56:51 -07:00
Subhash Jadavani
facadbc754 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>
2016-03-22 10:56:50 -07:00
Subhash Jadavani
4a1e05b446 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>
2016-03-22 10:56:49 -07:00
Subhash Jadavani
99d281b5c0 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>
2016-03-22 10:56:48 -07:00
Subhash Jadavani
8a6fc0c67d 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>
2016-03-22 10:56:47 -07:00
Dolev Raviv
cf5c66a278 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>
2016-03-22 10:56:47 -07:00
Subhash Jadavani
6a33acef6d 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>
2016-03-22 10:56:46 -07:00
Subhash Jadavani
2413f44c0e 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>
2016-03-22 10:56:45 -07:00
Subhash Jadavani
67afad8950 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>
2016-03-22 10:56:44 -07:00
Subhash Jadavani
eea9974ddf 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>
2016-03-22 10:56:43 -07:00
Subhash Jadavani
6f2397a1ad 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>
2016-03-22 10:56:42 -07:00
Subhash Jadavani
5b0bdd634a 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>
2016-03-22 10:56:41 -07:00
Subhash Jadavani
26c2a47e5c 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>
2016-03-22 10:56:40 -07:00
Yaniv Gardi
601d661911 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>
2016-03-22 10:56:39 -07:00
Dolev Raviv
c2e17b8952 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>
2016-03-22 10:56:39 -07:00
Yaniv Gardi
626cfcfb32 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>
2016-03-22 10:56:38 -07:00
Yaniv Gardi
68e23b443a 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>
2016-03-22 10:56:37 -07:00
Yaniv Gardi
241e1f8a50 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>
2016-03-22 10:56:36 -07:00
Subhash Jadavani
accd4ac14f 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>
2016-03-22 10:56:35 -07:00