summaryrefslogtreecommitdiff
path: root/drivers/scsi (follow)
Commit message (Collapse)AuthorAge
...
* | scsi: ufs-qcom: allow HS-G3 on newer host controllers.Subhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | HS-G3 mode is working as expected with newer host controller revisions hence this change removes the restriction of only running in PWM gears. Change-Id: I4df0b6875455730e990a20a2810784f1c32d949f Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: renaming "debugfs" files with correct prefixYaniv Gardi2016-03-22
| | | | | | | | | | | | | | | | | | The old names doesn't include the driver name (as prefix or at all). This change adds the "ufs" and the "ufs-qcom" prefix to file names and by that creates uniform naming convention in the driver. Change-Id: I221b489cc4237882d7e62a9d80bc1ee3f2bcf4a6 Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
* | scsi: ufs: don't use FTRACE_EVENT_ENABLED macroGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | Trace events have their own trace_<name>_enabled() function that can be called in order to check if its enabled or not. FTRACE_EVENT_ENABLED is redundant and will be dropped so use the trace event function instead. Change-Id: I4d2cc031ebbd5250bcff9526eaa916d6d691dbfc Signed-off-by: Gilad Broner <gbroner@codeaurora.org> Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [subhashj@codeaurora.org: resolved merge conflicts]
* | phy: qcom-ufs: move decision of rate B calibration to ufs driverYaniv Gardi2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | Until now, the decision if phy calibration is according to rate A or rate B values, was done in the phy driver. It made the phy dependent on the ufs unipro which is unnecessary binding. This change moves the decision into the ufs driver, and pass it through a function parameter to the calibration routine in the phy driver. Change-Id: I7a51d84142c31da57ba5de6ec98526e5c7d1b544 Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org> [venkatg@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
* | scsi: ufs: enable runtime pm only after ufshcd initGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | Previous code enables runtime pm before ufshcd_init() is completed, and before the hba struct is stored in the platform device private data. This means that pm runtime calls will have null hba pointer as well as partially initialized driver. Instead, enable pm runtime only after ufshcd_init() is done and after hba struct is stored in the platform device private data. Change-Id: I8225736916a9eda3d9f58d2b0e2566065766b914 Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
* | scsi: ufs-qcom: implement pre and post notification for clock scalingSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | QUniPro controller requires additional configuration before and after clock scaling, this change adds the support for it. Change-Id: I0add27ff3ab54f72b8b79e1e554541c2e492a4c8 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: add pre & post status change to clk_scale_notify opsSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | Some UFS host controller implementation may require vendor specific configurations before and after changing the UFS controller clock frequencies. This change adds the support for this. Change-Id: Id4171ef8786fa6883d9af914dc2a675cb62c6a72 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [venkatg@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
* | scsi: ufs-qcom: disable low power modes and run slow on newer controllerSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | Newer UFS controllers (revision 2) still need to be validated properly hence disable the low power modes for it until they are validated thoroughly. Also run the UFS interface in PWM gear until High Speed Gear operation is stabililized. Change-Id: I310b49030d084557f487f3095fc7e1cfa68335e6 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs-qcom: fix device reference clock control handlingSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UFS device reference clock control has moved inside UFS controller register address space for newer Qualcomm chipsets and if we try to do ioremp on the corresponding memory address then it would fail as the same memory address space is already ioremapped. This issue is fixed by removing the requirement of passing reference clock control register address space resource via device tree node for newer chipsets. Change-Id: I8d93f9856d33d3b300bd7994d1dff1d1be84596d Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [subhashj@codeaurora.org: resolved merge conflicts, skipped changes to msmthulium.dtsi] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs-qcom: enable UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSIONSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | Newer revisions of Qualcomm UFS host controller may not advertise the correct version information in UFS HCI VER register. To handle this, enable UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION to let UFS standard host controller driver call into vendor specific operation to get right UFS HCI VER register value. Change-Id: Ibd50b8bb8a87003181ea306690e87728576d49fb Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | phy: ufs-qcom: disable RX LineCfgSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some UFS devices send incorrect LineCfg data as part of power mode change sequence which may cause host PHY to go into bad state. Currently we workaround this issue by disabling the device's TX LCC but disabling TX LCC is much more complicated if both host and device supports UniPro 1.6 specification. To simplify the workaround, this change disables the host PHY's RX LineCfg to skip processing incorrect LineCfg from device. Change-Id: I1eac56c11dd001eb0c53ba8e16aa512a656ab9ea Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [venkatg@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
* | scsi: ufs-qcom: allow HS-G3Subhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | Change the maximum high speed gear to HS-G3 so if both host and device supports HS-G3, UFS link will be allowed to operate in HS-G3. Change-Id: I1117990948f9c09ae103cd1e692716e0010362cb Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs-qcom: cap maximum gear to HS-G2 for legacy host controllerSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | HS-G3 operations may not reliably work on legacy QCOM UFS host controller hardware (major revision = 0x01) even though capability exchange during link startup phase may end up negotiating maximum supported gear as G3. This change downgrades the maximum supported gear to HS-G2 for legacy host controllers. Change-Id: Iad95ed4271f83db888940263ea6c6c804d56a422 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: add load based scaling of UFS gearSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UFS driver's load based clock scaling feature scales down the ufs related clocks in order to allow low power modes of chipsets. UniPro 1.6 supports maximum gear up to HS-G3 (High Speed Gear3) and some of the chipsets low power modes may not be allowed in HS-G3 hence this change adds support to scale gear between HS-G3 and HS-G2 based on same existing load based clock scaling logic. Change-Id: I25c70230a77321efd654af7c496c43936324ae40 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [subhashj@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [venkatg@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
* | scsi: ufs: add UFS power collapse support during hibern8Subhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | UFS host controller hardware may allow the host controller to be power collapsed when UFS link is hibern8 state, this change allows the UFS host controller to be power collapsed during hibern8. Change-Id: I42f962484b9d6635be1139b1fc6447dd2ca2200c Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [subhashj@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [venkatg@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
* | scsi: ufs-qcom: change device reference clock controlGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As of HW major version 2, bit 'UFS_DEV_REF_CLK_EN' which is used to gate/ungate the ref_clk to external UFS device, was moved into the UFS register space to UFS_CFG1 register. This change adds support to appropriately control the device reference clock and it also adds the missing documentation for the device reference clock control register address space. Change-Id: I66a6a75dc5a1cf130b1cee90ae20f9f950edfb3a Signed-off-by: Gilad Broner <gbroner@codeaurora.org> [subhashj@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: fix UFS HCI 2.0 version register valueSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It seems UFS version register (offset 08h) fields position has changed in UFS HCI 2.0 specification when compared to 1.0/1.0 specification. According to 2.0 spec, UFS version register value should be 0000_0200h (version 2.0). This change fixes the expected version register value and also added the error message if host controller advertises invalid version. Change-Id: I2dd399fd7e47ce99b60591f7eac75e7305758bde Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [venkatg@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
* | scsi: ufs: suspend clock scaling at the start of suspendSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | Currently clock scaling is suspended only after the host and device are put in low power mode but we should avoid clock scaling running after UFS link is put in low power mode (hibern8). This change suspends clock scaling before putting host/device in low power mode. Change-Id: Iff9846cee1345a3c0c8b1aaee0b4ad567f37ea79 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: avoid exception event handler racing with PM callbacksSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | If device raises the exception event in the response to the commands sent during the runtime/system PM callbacks, exception event handler might run in parallel with PM callbacks and may see unclocked register accesses. This change fixes this issue by not scheduling the exception event handler while PM callbacks are running. Change-Id: I8644f50366d5c87ba6a5048e48703b3723ab241b Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs-qcom: expose debug registers by debugfsDov Levenglick2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | Add support for exposing debug registers via debugfs. This can be used for runtime debugging of failures/errors without the need to add more prints to the console. In order to avoid unnecessary code duplication, the function for dumping registers to a file (in debugfs.c) has been slightly modified and exposed as an external function. Signed-off-by: Dov Levenglick <dovl@codeaurora.org> Change-Id: I77f9f3a6d041f805a93d095446f3e8077977036f
* | scsi: ufs-qcom: add debug prints for test busDov Levenglick2016-03-22
| | | | | | | | | | | | | | | | | | | | | | Adds support for configuring and reading the test bus and debug registers. The configuration is controlled by debugfs. Reading can be triggered either by debugfs or by the kernel code. Change-Id: I943e3c1b1e383a91a8abbb8dab9714434c56b6f5 Signed-off-by: Dov Levenglick <dovl@codeaurora.org> [imaund@codeaurora.org: Resolved context conflicts] Signed-off-by: Ian Maund <imaund@codeaurora.org>
* | scsi: ufs-qcom: add ICE debug printsDov Levenglick2016-03-22
| | | | | | | | | | | | | | | | | | Add ICE debug prints for debugging purposes. These prints will be shown as part of dumping registers during error handling. Enabling can be controlled by debugfs. Change-Id: I7d070cc8df099e6c526997d39973a3e1c161091b Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
* | scsi: ufs-qcom: add print suppressing debugfs mechanismDov Levenglick2016-03-22
| | | | | | | | | | | | | | | | | | | | Provide a mechanism for the userspace to suppress specific debug prints via debugfs. This is useful in order to avoid cases where too much printing would cause watchdog timers to expire. Change-Id: I2500b7621b631e260d98595ed8cfe7d5a496dc10 Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
* | scsi: ufs: wait for a longer time for fDeviceInit to clearDov Levenglick2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On some device, in some cases, the initialization time is uncharacteristically long. This is within the standard which states in section 13.4.6.1.2 (Dynamic Capacity Procedural Flow): "The device initialization may take a time longer than normal initialization..." Therefore, making the loop pending on fDeviceInit to clear longer. CRs-Fixed: 776748 Change-Id: Ida491467da63ac9630d3ecc9b8f5c3e9ac5187c2 Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
* | scsi: ufs: clear outstanding_request bit in case query timeoutYaniv Gardi2016-03-22
| | | | | | | | | | | | | | | | | | | | When sending a query to the device returns with a timeout error, we clear the corresponding bit in the DOORBELL register but we don't clear the outstanding_request field as we should. This patch fixes this bug. Change-Id: Ia7e0aa29b0d822742654ba206a5837b9091fdb4a Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
* | scsi: ufs-qcom: set device ref. clk bitGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of HW major version 2, a new bit 'UFS_DEV_REF_CLK_EN' was added to UFS_CFG1 register which needs to be set as part of hibernate enter/exit sequences during suspend/resume. Change-Id: I66a6a75dc5a1cf130b1cee90ae20f9f950edfb3a Signed-off-by: Gilad Broner <gbroner@codeaurora.org> [imaund@codeaurora.org: Resolved context conflicts and updated a conditional in ufs_qcom_advertise_quirks to use the ufs_qcom_host struct when querying major hw versions] Signed-off-by: Ian Maund <imaund@codeaurora.org> [subhashj@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [venkatg@codeaurora.org: resolved trivial merge conflicts, drop changes to include/linux/phy/phy-qcom-ufs.h] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
* | scsi: ufs: add print suppressing debugfs mechanismDov Levenglick2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | Provides a mechanism for the userspace to suppress specific debug prints via the debugfs. This is useful in order to avoid cases where too much printing would cause watchdog timers to expire. Change-Id: I1ab068cd616ddac767ec5f30ab130e3b1ac34e15 Signed-off-by: Dov Levenglick <dovl@codeaurora.org> [imaund@codeaurora.org: Resolved context conflicts] Signed-off-by: Ian Maund <imaund@codeaurora.org> [subhashj@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: perform ice_init as part of UFS initializationMaya Erez2016-03-22
| | | | | | | | | | | | | | | | | | | | | | ice_init may need UFS clocks to be enabled in order to allow enabling ICE as part of its initialization. To allow that, ice_init should be done as part of UFS initialization sequence. In such a case ice_reset is no longer needed to be called as part of UFS initialization and should be moved to host reset scenarios. Change-Id: Iaa851083a9f73045c7ca02d69dd65b3a00b85bff Signed-off-by: Maya Erez <merez@codeaurora.org>
* | scsi: ufs-qcom: write the clock registers only if there is a changeSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | If we write REG_UFS_SYS1CLK_1US & REG_UFS_TX_SYMBOL_CLK_NS_US registers multiple times (especially when UFS symbol clocks are not running) then it might make the HW to go back to default value of these registers. This change updates above registers only if there is a change in these registers value. Change-Id: I7c94c477e52b36b26a1624fa3ddfa75a49916d58 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [imaund@codeaurora.org: Resolved context conflicts] Signed-off-by: Ian Maund <imaund@codeaurora.org>
* | scsi: ufs-qcom: save controller revision before phy_init()Subhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | phy_init() calls "init" phy_ops and UFS phy driver might need to know the UFS controller revision in this "init" ops hence save the controller revision before calling phy_init(). Change-Id: I3e9d780dfa3da603b372b1fc4465dfd5f7cfb31a Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: set right GenSelectorIndex for M-PHY attributesSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DME attributes read/write commands need GenSelectorIndex argument and according to UFS host controller specification, it should specify the targeted M-PHY data lane. This is the valid range of GenSelectorIndex for M-PHY attributes: 0 to (2 * PA_MaxDataLanes - 1) Example (Note: PA_MaxDataLanes is UniPro protocol constant set to 4): --------------------------------------- MPHY Access target | GenSelectorIndex --------------------------------------- TX Lane0 | 0 TX Lane1 | 1 RX Lane0 | 4 RX Lane1 | 5 --------------------------------------- This change make sure that correct GenSelectorIndex is passed for M-PHY attributes Change-Id: I38c14b5801ece7fce7a7970385756859618efd32 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [venkatg@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
* | scsi: ufs-qcom: remove unnecessary quirks for QUniProSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | QUniPro doesn't require some of the quirks required for legacy UniPro controller hence this change disables those quirks. Change-Id: Ic97ec38d4a9ee7a51d8f336bcbc8fd9533db2f8d Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs-qcom: add QUniPro hardware supportSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | New revisions of UFS host controller supports the new UniPro hardware controller (referred as QUniPro). This patch adds the support to enable this new UniPro controller hardware. Change-Id: Iccbcc38c36e6d9b9fcbb5c7fd7a3e3326c1c4ce0 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [subhashj@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs-qcom: remove support for save/restore phy configurationYaniv Gardi2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since support for 28nm phy removed in kernel 3.14, all related code that is specific to phy 28nm is also removed. Specifically the quirk that enables save/restore phy configuration is removed (and all its relevant callbacks) as it's unique to 28nm ufs phy. Change-Id: Ie723885bacb52548573fc1140d09b0ea5f067382 Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org> [venkatg@codeaurora.org: drop changes to include/linux/phy/phy-qcom-ufs.h] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
* | scsi: ufs: fix spinlock recursion in ufshcd_queuecommand()Gilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | Before calling ufshcd_send_command() the host spinlock is taken. In case error is returned ufshcd_release_all() is called, which in turn attempts to lock the host spinlock again. Unlocked the host spinlock in case error was returned to prevent the spinlock recursion. Change-Id: I630ac8b901f03285a37547bfbcd49ec575e7545a Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
* | scsi: ufs: fail ufshcd_probe_hba() if power configuration failsDov Levenglick2016-03-22
| | | | | | | | | | | | | | | | | | | | | | In case the power configuration fails, skip further processing of the probing function and return immediately. This has 2 reasons: 1. Don't allow the UFS to continue running in PWM 2. Avoid multiple calls to pm_runtime_put_sync() when not in error handling or power management contexts Change-Id: I8d6faefadf42385aace903f90ab967c6ddcf7460 Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
* | scsi: ufs-qcom: add number of lanes per directionGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | Different platform may have different number of lanes for the UFS link. Add parameter to device tree specifying how many lanes should be configured for the UFS link. Change-Id: Ida8b13b916f76b3cc7afd3da3d04219e95627678 Signed-off-by: Gilad Broner <gbroner@codeaurora.org> [subhashj@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: Clear the aborted tag in case of ICE errorMaya Erez2016-03-22
| | | | | | | | | | | | | | | | | | | | | | ICE error is handled as a fatal error, hence all the outstanding requests are being aborted. This patch clears the tag in case of device management requests and fixes a bug where outstanding_tasks was cleared instead of outstanding_reqs. Change-Id: If160b6179edd4e36c541ed7f1b14dfc01de0842b Signed-off-by: Maya Erez <merez@codeaurora.org>
* | scsi: ufs: optimize system suspend handlingSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider following sequence of events: 1. UFS is runtime suspended, link_state = Hibern8, device_state = sleep 2. System goes into system suspend, ufshcd_system_suspend() brings both link and device to active state and then puts the device in Power_Down state and link in OFF state. 3. System resumes at some later point in time, ufshcd_system_resume() doesn't do anything as UFS state is runtime suspended. Note that link is still on OFF state and device is in Power_Down state. 4. Now system again goes into suspend without any UFS accesses before it. ufshcd_system_suspend() again brings both link and device to active state and then puts the device in Power_Down state and link if OFF state. But it's unnecessary to bring the link & device in active state as both link and device are already in desired low power states. This change fixes this issue by adding proper state checks in ufshcd_system_suspend(). Change-Id: I6ada697f5f844724e0da77fa960401d1d6a1288e Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [gbroner@codeaurora.org: fix compilation errors due to changes in kernel 3.14] Signed-off-by: Gilad Broner <gbroner@codeaurora.org> [subhashj@codeaurora.org: resolved merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: fix locking in __ufshcd_pm_qos_holdGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The function is called with locked spinlock and disabled interrupts which is done in a wrapper function ufshcd_pm_qos_hold(). Before flushing the PM QoS voting work spinlock must be released and interrupts must be restored. As the interrupts flags state is saved in the wrapper function, we cannot restore the state. Moving the locking to the internal function fixes this, which makes the wrapper function redundant so it is deleted. Change-Id: I167292305a25d2b8c3524dcddb51f5a7109444aa Signed-off-by: Gilad Broner <gbroner@codeaurora.org> Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: define cpu affinity mask for PM QoS votingGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | PM QoS request type PM_QOS_REQ_AFFINE_CORES specifies for which CPU cores the voting is applied to by the cpu affinity mask. This change defines the cpu mask to be used for the voting in the device tree node so it can be customized for each target. Change-Id: I004dea47b42eaf3cdf0489427b2bb894c9982f22 Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
* | scsi: ufs: adjust DME command delayGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | DME command delay is used to ensure a sufficient interval between subsequent commands. The hardware programming guide specified 1ms. Value of 700us was used as optimization, but it seems to be too short so DME commands would sometimes fail. Update the command delay to 1ms as recommended. Change-Id: I8960f8488c261013ec95ef8c49b58ceda9d065f6 Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
* | scsi: ufs: optimize clock, pm_qos, hibern8 handling in queuecommandSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | ufshcd_queuecommand() vote for the resources in this order: clocks, pm_qos latency, hibern8 exit. If any of these votes are not already applied, each one has to be applied asynchronously and in that case we are releasing all the previously applied resource votes (for example, if hibern8 exit has to be completed asynchronously, we release the votes for pm_qos and clocks as well). This is not a optimal solution instead we should skip scheduling the unvoting work for already voted resources. Change-Id: Ie700d9b3bf64370a5885787f7313d41adb5b3566 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: fix possible unclocked register access during hibern8 exitSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ufshcd_queuecommand() function calls ufshcd_hibern8_hold() to bring the link out of hibern8 asynchronously. If the link was in hibern8 state then it schedules a work to execute the hibern8 without any timeout and returns error back to ufshcd_queuecommand(). ufshcd_queuecommand() calls ufshcd_release() which schedules the clock gating work to be executed after clock gating timeout (50ms at this moment). Ideally hibern8 exit work should have finished much before clock gating work starts execution but it may not be true on heavily loaded system. To protect this race, hibern8 exit work should make sure that clocks are running (by calling ufshcd_hold()) before executing hibern8 exit. Change-Id: I572b26881277886f5ec17b0eed96ee9e59ca1fbf Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: reduce printout for aborted requestsGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | Details printed for each request that is aborted can overload the target as there can be several requests that are aborted at once. This change will print full request details only for the first aborted request since the last link reset, and minimal details for other subsequent requests. Change-Id: I2868262e0b687c9ddd771a52708428b7de14bea2 Signed-off-by: Gilad Broner <gbroner@codeaurora.org> [subhashj@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: suspend clock scaling for failed runtime_resumeGilad Broner2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During runtime resume operation, clock scaling may get indirectly resumed via call to ufshcd_set_dev_pwr_mode(): Start/Stop Unit command times out and SCSI error handling ultimately calls the host reset handler to recover, during which clock scaling is resumed. Error case exit path of runtime resume will disable clocks. As clock scaling was already resumed, it will get scheduled later on and try to access UFS registers while clocks are disabled, resulting in NOC error. Change-Id: I3faf46109420ac54404c18b209b4d42982e963b2 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
* | scsi: ufs: set REQUEST_SENSE command size to 18 bytesGilad Broner2016-03-22
| | | | | | | | | | | | | | | | According to UFS device specification REQUEST_SENSE command can only report back up to 18 bytes of data. Change-Id: I1121b016ddabfa0e7182a1b6c9b30c27061694d2 Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
* | scsi: ufs_quirks: remove no link off quirk for ToshibaSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | UFS_DEVICE_QUIRK_NO_LINK_OFF quirk was enabled for Toshiba devices as these device may stop resonding back on resume after the link initialization. But we now have proper workaround in place to allow link off for these UFS devices hence this patch disables the UFS_DEVICE_QUIRK_NO_LINK_OFF. Change-Id: I52af7c2088d4d85cb517ee1bd76c0238db80a2d0 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: send request sense after the link reinitializationSubhash Jadavani2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | After link reintialization, device would set the UNIT ATTENTION condition for each logical units. UNIT ATTENTION condition gets automatically cleared on either receiving explicit REQUEST SENSE command or data commands to LUs. Although some devices may stop responding to data commands if we do UFS link hibern8 enter/exit after link reinitialization but before any data commands. This change works around above mentioned issue by sending the explicit REQUEST SENSE command to all LUs after the link reinitialization. Change-Id: Ia191b8f05f9521bf587a713924b71bf19c801c31 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
* | scsi: ufs: Set DBD setting in mode sense for caching mode pageMaya Erez2016-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Host sends MODE_SENSE_10 with caching mode page, to check if the device supports the cache feature. UFS standards requires DBD field to be set to 1. Some card vendors are more strict and check the DBD field, hence respond with CHECK_CONDITION (Sense key set to ILLEGAL_REQUEST and ASC set to INVALID FIELD IN CDB). As a result of the CHECK_CONDITION response, host assumes that the device doesn't support the cache feature and doesn't send SYNCHORONIZE_CACHE commands to flush the device cache. This can result in data corruption in case of sudden power down, when there is data stored in the device cache. This patch fixes the DBD field setting in case of caching mode page. Change-Id: I4d63cba26331f04c34e87b99dbdf17c05ab96839 Signed-off-by: Maya Erez <merez@codeaurora.org> [subhashj@codeaurora.org: resolved trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>