When attempting to clear ufs tag stats, memset 0 is called with size
of multiples of unsigned int.
This is wrong since each cell in the stats array is of type (u64).
Fix the memset to sizeof(*tag_stats).
Change-Id: Iaeb70616a2160ee9cba4605e7251dc45868d1951
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
So far the command queue for the whole UFS device was depend on the
UFSHCD_QUIRK_BROKEN_DEVICE_Q_CMND quirk due to stability issues.
Now, that we gained stability, with new UFS devices FW, we can
remove the UFSHCD_QUIRK_BROKEN_DEVICE_Q_CMND quirk
Change-Id: I7aef145e226e5b207d0146f58b5cd9c87ed5bb91
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
The PHY_ADAPTER_ERROR status register indicates PHY lane errors
reported by the M-PHY layer. In some occasions the controller
can recover from such errors. When the error is not recoverable,
a stuck DB error will occur. Since the stuck DB error is spotted
separately, no action other than clearing the register is necessary.
Change-Id: I4b9e8ab15018fe74da34264eac71f8110e94928a
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
At the current implementation all the enums structs and defintions
defined at the ufs-msm.c. In order to share those definitions with
other files, we expose them at ufs-msm.h
Change-Id: I12fe3b9a51c86b5bf6584c2de65de40749ef5693
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
As working with new UFS devices, and new version of FW,
we were able to work in a higher gear, and to maintain stability.
In this change the preferable values of the vendor power modes are
set to be HS-G2.
Also, a few minor indentation fixes are added.
Change-Id: I34d4836894b9d48085bbe2aa31a6f2d92661fb3d
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Adds the scsi interpretation of the aborted command,
in addition to the transfer dump. This change improves
crashes debugging.
Change-Id: I1b983042d90b8d0434260bb78e09807dd933a03a
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
The bug was a wrong parameter passed to print_hex_dump() function.
Change-Id: I962e08b8c1c8c546f0bc625da3bff292965da8a5
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
The UFS host controller on MSM chipsets transfer data over
System NoC to the DDR memory. Add bus bandwidth voting support
based on the speed modes the host communicates with the device
so as to provide optimum throughput while transferring data over
the bus.
Change-Id: I1b407975984985fa108aa9373e2eab08b9027df4
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts - apq8084.dtsi file
location has been previously changed and is already up to date]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts and also fixed
compilation error]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Uni-pro lane management provides flexibility for tx/rx to work with
different number of lanes.
This change supports different number of lanes for TX and for RX.
The configured number of lanes for TX will be now the minimum between
the device capability and the vendor preferences.
Same logic applies when configuring RX number of lanes.
Change-Id: I9387a4489d910f89a0741c6349084051d7d94549
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
When sending query to the device, the index of the failure
is additional useful information that should be printed out as it
might specify the logical unit (LU) where the error occurred.
Change-Id: I15dd74545842bde7bbfb5bda56c20b5a28d54e75
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
This change is required according to HW team, in order to support
UFS device working with HS-G2
Change-Id: Id76a36870103d93b9f602911412e999cce64cec1
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Device reference clock is a crucial parameter, as
it would fail to work in HS, if its value is different than 19.2 MHz.
This is why we should read its value upon start-up and notify
its value as a debug message.
We don't want to "blindly" configure this attribute as well, as this is
a one-time-programmable parameter and should be considered carefully
before setting it.
Change-Id: Ia2cc0f18fae1189949c30b5b2a65b763c1c46fb1
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Use fault-injection framework to simulate error conditions
in the controller and verify error handling mechanisms
implemented in UFS host controller driver.
This is used only during development and hence
guarded by CONFIG_UFS_FAULT_INJECTION debug config option.
Change-Id: Ia63c276c5e56d677a92332b42b670300ad82af7a
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
So far we have disabled the LCC configuration in device and also in the
controller.
However, in some UFS devices, disabling the LCC configuration might fail
so we can remove this command. It was presented at first, just that the
controller and device will be configured identically (both with
TX_LCC_ENABLE disabled), but it shouldn't have any impact on the UFS
device behavior when removing this configuration command from the device.
Change-Id: I87342a63c75d28a91f0d1ab8edd819d13b3a21a1
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Sometimes due to hw issues it takes some time to the
host controller register to update. In order to verify the register
has updated, a polling is done until its value is set.
In addition the functions ufshcd_hba_stop() and
ufshcd_wait_for_register() was updated with an additional input
parameter, indicating the timeout between reads will
be done by sleeping or spinning the cpu.
Change-Id: Id79d92a4a0bc05d385eb47c027fe19a765f71851
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
[subhashj@codeaurora.org: resolved merge conflicts, dropped the changes
in drivers/scsi/ufs/ufshcd-pci.c]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Some of the queries might fail during init. To avoid
system failure, we add retry mechanism to issue queries
several times.
Change-Id: Ibab1d1dbfbaab763baad63c24218289b61da7b28
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Before each dme command (get, set), delay is required for
stability purposes.
This change enables that quirk.
Change-Id: I8ef88f08562de444cb81e767c4d8aeb35b6bb0ea
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
LCC configuration that is needed for optical connections, is not needed
when working with UFS devices. This values can be disable in all tx
connected lanes and in both: unipro and the device
Change-Id: I3c94600dad0aaade87eb976b6296a284d10aff93
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
A variable named ioct_data should have named ioctl_data. This change is
important for synchronizing the original change with mailing list version.
Change-Id: I224989d3caf2ee0faad6b99cd6774983438c5464
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Using a mutex is problematic if the code can run in interrupt context.
In this patch we replace the ufs debugfs synchronization mechanism
from mutex to spinlock, which doesn't go to sleep.
Change-Id: I4e258898ed0ddf5b84d955fabd4354c2d2891c3d
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
WRITE_SAME command is not supported by UFS. Enable a quirk for
the upper level drivers to not send WRITE SAME command.
Change-Id: If3108134ceefbcb9c8585c1b489b4124ffa6b1ad
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
High Speed rate series might always be set to rate "A" if the
vendor doesn't specify any rate during pre-power change notify.
Change-Id: Ied7ce3eba98ffbece97ec06eb6cab8df1d104f52
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
This patch exposes the ioctl interface for UFS driver via SCSI device
ioctl interface. As of now UFS driver would provide the ioctl for query
interface to connected UFS device.
Change-Id: I7a5cea8de925dc0ecb6643774321e2c3690c504e
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[gbroner@codeaurora.org: dropping changes to the following files:
include/uapi/scsi/Kbuild
include/uapi/scsi/ufs/Kbuild
include/uapi/scsi/ufs/ioctl.h
include/uapi/scsi/ufs/ufs.h
which are already included in previous change titled:
'uapi: scsi: ufs: add ioctl interface for query request']
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts and compilation
errors]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This patch exposes the ioctl interface for UFS
driver via SCSI device ioctl interface. As of
now UFS driver would provide the ioctl for query
interface to connected UFS device.
Change-Id: Ib8301a69550408bfcb5fc85bb9c0498450c8cc31
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Assign a value to 'ret' in order to prevent a compilation warning of:
'ret' may be used uninitialized in this function.
Change-Id: Id10d0e5e8204d233cf4906bc33709d3c012d964f
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
In this change the default preferences of the UFS vendor
are set to work in HS-G1- 1 Lane, as the enviroment became stable.
Change-Id: I340190d5c6cf4f848f9def7eba8831fb299adadb
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
since two different routines implement almost the same logic of
scanning the ufs clocks, getting the rate of "core_clk" and
setting a vendor timer register with a calculated value,
we should use only one routine to do that in order to minimize
potential errors
Change-Id: I22728295074acfbe4d421996ea9eaa1f29cb3a32
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Sometimes, the device shall report its maximum power and speed
capabilities, but we might not wish to configure it to use those
maximum capabilities.
In this change we implement the vendor specific callback that should
determines what parameters we should use in power change.
It takes into account the maximum capabilities of the device, and
also the pre-defined vendor preferences.
According to both set of parameters, it calculates the maximum power
and speed that are still acceptable by both: the vendor preferences
and the devices capabilities.
Change-Id: I3ef468d3882f3ed9d49a99aa285af4a1f58063a0
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: fixed compilation errors]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
fix fall through in msm_ufs_link_startup_notify() during PRE_CHANGE,
since we would like msm_ufs_enable_tx_lanes(hba) to happen only in
POST_CHANGE
Change-Id: I91b1134ef7060ee8b8189335d0ef7b5a4f546534
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Fix missing update of ref_clk enable reference count when the
clocks are enabled and also enable shutting down the phy and
device during system suspend.
Change-Id: I7772cd87e0d0528ab5dbe6ea9f09e6d02c86f96c
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
This change adds a few more options to a user to get a complete
status and statistics regarding the UFS driver, via debugfs
This information includes:
1. UFS Host Controller registers (cat /sys/kernel/debug/ufs/host_regs)
2. hba values (cat /sys/kernel/debug/ufs/show_hba)
Change-Id: Iac60de81a56ed42de72c3a7946a0d2bb5fab2903
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
This patch adds the vendor specific UFS power management support for MSM
platform.
If UFS link hibernate operation is broken in HW, make sure that link
remains active and device in sleep state during the runtime suspend.
During system suspend, keep both link and device in power off state.
If UFS link hibernate operation is working properly in HW, keep the link
in hibernate state and device in sleep state during both runtime and
system suspend.
Change-Id: Ibc5be00eb9d5fd72ed116b887d835a12ed97ae78
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Due to M-PHY issues, moving from HS to any other mode or gear or
even Hibern8 causes some un-predicted behavior of the device.
This patch fixes this issues.
Change-Id: I4540e30703aa1212099b2316e158b09e311c7420
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
UFS devices on msm ufs v1.1 controller fail to change power mode
during initialization. Enable the UFSHCD_QUIRK_BROKEN_PWR_MODE_CHANGE
quirk to make sure the power mode is not switched.
Change-Id: Ie02ae5a2da3604a83828325719eb5edb167ca82e
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Some devices, even though advertises command queuing capability,
may not behave well when multiple commands are queued concurrently.
Disable command queuing for the device to avoid command hangs when
multiple commands are sent.
Change-Id: I7458c081976e96d2a97c8c9544acfd29163d9e1f
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Reference clock is propogated from source to PHY with various
LDO gating logic in between. Add support for enabling these
LDOs and also source reference clock.
Change-Id: I0de6d5d47aff175cd5526b6de2f8e4078cb08316
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
UFS 1.1 specification defines READ_CAPACTIY(16) as an optional
command. Hence, try READ_CAPACITY(10) first, if the device returns
0xFFFF_FFFF as returned logical block address then send
READ_CAPACITY(16) to read the actual device capacity.
Change-Id: I2690d26be967e6be4debdc773100c55ba751aa1f
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Modify the PHY power up calibration values according to the
latest hardware specification.
Change-Id: I145dc8d5644c1914bb0fcb9c9b5790cf2b8de367
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
MSM UFS host controller advertises CAP.64AS bit as zero
even though it can adress upto 36 bits.
Change-Id: Ia8edd9ede3cc5e8358775d1efca5451cc3559773
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Some UFS host controllers might advertise that 64-bit
addressing is not supported even though it supports >32-bit
addressing. Add a quirk so that 64-bit is enabled and dma mask
is set accordingly.
Change-Id: Ie17662f55dda1da7d508efb881ac8fb8fa95f15a
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
The device-tree probed device for ARM doesn't have dev->dma_mask.
So dma_set_mask() for the device doesn't succeed. The popular trick
for this is - dev->dma_mask = &dev->coherent_dma_mask;
Currently there is no dma_set_mask() call in ufs-pltfrm, but the
forthcoming fix needs proper DMA mask setting in ufs core driver. So
initializing dev->dma_mask as described above is required.
Change-Id: I8428f106ca2d97badb7bf57cbb1d3ee14dddaf7f
Signed-off-by: Akinobu Mita <mita@fixstars.com>
Cc: Sujit Reddy Thumma <sthumma@codeaurora.org>
Cc: Vinayak Holikatti <vinholikatti@gmail.com>
Cc: Santosh Y <santoshsy@gmail.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
Patch-mainline: linux-scsi@vger.kernel.org @ 2013/08/19 19:26
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
In msm_ufs_check_hibern8(), the loop never breaks until
timeout even if the tx_fsm_val is equal to expected value.
Change-Id: I6f5ee6aea2e50ff6c88547d5e651d6cccfd25212
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Qualcomm MSM UFS controller version register (VER) wrongly advertise the
version as v1.0 though controller implementation is as per UFSHCI v1.1
specification. This patch corrects this HW behaviour with appropriate
quirk handling.
Change-Id: Idc99e8504617e7828043e06afdaecb7ddc4218f8
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Some implementation of UFS host controller HW might have some non-standard
behaviours (quirks) when compared to behaviour specified by UFSHCI
specification. This patch add support to allow specifying all such quirks
to standard UFS host controller driver so standard driver takes them into
account. Currently only couple of quirks (UFSHCD_QUIRK_BROKEN_HIBERN8 &
UFSHCD_QUIRK_BROKEN_INTR_AGGR) are added but new quirks can be added as
and when other non standard behaviours are found.
Change-Id: Ie8e686bb59e7933a281a4ff189a35c71036b1e92
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
After link startup the phy adapter (PA) layer in Uni-Pro
automatically detects the number of available lanes for
communication with the device. Since it is choice of s/w
to use all the available lanes or a partial of them, it is
necessary to communicate to MSM PHY about the lanes not being
used so that PHY can stop driving them.
Change-Id: I6f005e67a4c0a35dcba0ff186de5817af1b0439d
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Add MSM UFS host PHY driver which binds with UFSHCD platform
driver exposing vendor specific operations to initialize the
PHY. Since the controller and PHY are tightly coupled in the
system, some of the MSM specific controller register
configuration is also applied inline while initializing PHY.
Add a new compatible property "qcom,ufshc" which specifies the
UFS host controller on MSM platforms. The UFS controller driver
binds with UFS PHY driver using the phandle reference of PHY
devicetree node.
Change-Id: If695a844d03268151c6c846bdfa6cee8ff84491b
Signed-off-by: Sujit Reddy Thumma <sthumma@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>