Commit Graph

10527 Commits

Author SHA1 Message Date
Linux Build Service Account c7b6ceb782 Merge "scsi: ufs: fix the downdifferntial value for clock scaling" 2014-11-06 05:24:15 -08:00
Linux Build Service Account ba7df9d0ce Merge "scsi: ufs: adapt UFS unit-tests for running also on external UFS card" 2014-11-06 05:24:10 -08:00
Gilad Broner 717a1ad6eb scsi: sd: separate timeout for discard command
discard command does not necessarily take the same time
as other commands. Distinguishing the timeout for discard
command allows better fine tuning.

Change-Id: Ibb049b9532c064f96d98aa8b8cacce1abe77c776
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2014-11-05 16:21:10 -08:00
Gilad Broner 6e34857588 scsi: ufs: reduce read-write requests timeout
Default request timeout of 30 seconds is too long for UFS
which has good performance sp that timeout can be reduced substantially.

Change-Id: I36f2c5d10d1195707fc8db32bcac624ae9705d2f
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2014-11-05 16:21:09 -08:00
Subhash Jadavani 5474a9f0c1 scsi: ufs: fix the downdifferntial value for clock scaling
"downdifferntial" parameter of devfreq ondemand governor should
be set to value such that if the load is under upthreshold minus
downdifferential, the governor may consider slowing the frequency down.

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

Change-Id: I14efbe5706a56af00d72fad08392b3db13cbbca9
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-11-05 16:21:09 -08:00
Lee Susman 923e385795 scsi: ufs: adapt UFS unit-tests for running also on external UFS card
It was found that the UFS unit tests fail when they are run on an external
UFS device. This happens when the external UFS device is suspended while
running the unit-tests, and the un-natural flow of test-iosched does
not resume the UFS driver and device in the correct manner.
We solve this by using the block layer power management API for running
the request queue, as well as explicitly resuming the device before
running the unit-tests.

Change-Id: I8273d4dd4f32e91bad28c019c159696cf8fabb42
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
2014-11-05 16:21:08 -08:00
Gilad Broner 1a729df225 scsi: ufs: add SCSI status error code print
To assist debugging, print the SCSI status code of response UPIU
in case it suggests error condition.

Change-Id: If01a80ee1004af2127b7639e0c43e1e6812864ee
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2014-11-05 11:54:49 -08:00
Subhash Jadavani 27475f8c52 scsi: ufs: add retries for hibern8 enter
If hibern8 enter command fails then UFS link state may be unknown which
may result into timeout of all the commands issued after failure.

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

Change-Id: I6ae6d1371126b3b71ba2154182d6b9920e8996f5
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-11-05 11:52:44 -08:00
Subhash Jadavani 792eb6a3a3 scsi: ufs: fix error recovery after the hibern8 exit failure
Hibern8 exit can be called from 3 different context:
	- ufshcd_hibern8_exit_work
	- ufshcd_ungate_work
	- runtime/system resume.

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

Change-Id: I4d46e53eb052bddae29797cd9780fc5cf33b09ba
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-11-05 11:52:08 -08:00
Dolev Raviv e7485f3708 scsi: ufs-qcom: implement ufs dbg_register_dump cb
Errors such as UIC errors, illegal OCS values, and others may require
information kept in non standard UFS registers but controller debug
registers.
Implementing dbg_register_dump cb gives access to such register while
debugging those issues.

Change-Id: I259c3d691b95f72ea62ed162492f9081d472de80
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-11-05 11:50:17 -08:00
Dolev Raviv 2af4169bcc scsi: ufs: Improve fatal error logs
Errors such as UIC error, illegal OCS values, and others may require
more information for debugging. Such information could be hibern8 events,
events sequences, recoverable errors, error history, and more.
This patch improves tracking of important errors and events in debug level
to be enabled when debugging a such issues. It includes:
* UIC error history
* Successful hibern8 events
* Successful command after hibern8 exit
* Clk-freq info
* Failed device command
* Infrastructure for dumping host controller debug information

Change-Id: If3b38b86caeec4ffc669d001b452050a4a6b5173
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-11-05 11:47:53 -08:00
Subhash Jadavani 3ef1af1469 scsi: ufs: clear fields UTRD, UPIU req and rsp before new transfers
Some of the data structures (like response UPIU) and/or its elements
(unused fields) should be cleared before sending out the respective
command to UFS device.

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

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

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

Change-Id: I495cec3916dbaa974d204d790f0dbc3d6753ba6f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-11-05 11:39:35 -08:00
Subhash Jadavani b1932bb37b scsi: ufs: disable vccq if it's not needed by UFS device
Some UFS devices don't require VCCQ rail for device operations hence
this change adds support to recognize such devices and remove vote for
the unused VCCQ rail.

Change-Id: I7f0ffb9141bf9f13ce457c8c5eba7705ae288872
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-11-05 11:39:35 -08:00
Subhash Jadavani 49ede900d5 scsi: ufs-qcom: put the UFS phy in reset state when link is off
When UFS link is in off, put the UFS phy in reset state to reduce the
leakage from PHY.

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

Change-Id: I157c0c0c246fb83692b57a3d8f5a7868c0703cf0
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-11-05 11:39:34 -08:00
Subhash Jadavani 7ae6b4b62a 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>
2014-11-05 11:36:44 -08:00
Linux Build Service Account dbd2b72e38 Merge "scsi: ufs: add Inline Crypto Engine (ICE) support to UFS" 2014-11-03 02:35:30 -08:00
Arun Easi e166c65c41 qla2xxx: Use correct offset to req-q-out for reserve calculation
commit 75554b68ac1e018bca00d68a430b92ada8ab52dd upstream.

Signed-off-by: Arun Easi <arun.easi@qlogic.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-30 09:35:10 -07:00
Mike Christie 39d6457473 be2iscsi: check ip buffer before copying
commit a41a9ad3bbf61fae0b6bfb232153da60d14fdbd9 upstream.

Dan Carpenter found a issue where be2iscsi would copy the ip
from userspace to the driver buffer before checking the len
of the data being copied:
http://marc.info/?l=linux-scsi&m=140982651504251&w=2

This patch just has us only copy what we the driver buffer
can support.

Tested-by: John Soni Jose <sony.john-n@emulex.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-30 09:35:10 -07:00
Gilad Broner bc46439f79 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>
2014-10-30 09:55:14 +02:00
Linux Build Service Account 0479e7879d Merge "scsi: ufs-qcom: add support to control the device ref_clk" 2014-10-29 13:08:52 -07:00
Linux Build Service Account 03e31afab7 Merge "scsi: ufs-qcom: disable the UFS PHY reference clock during clock gating" 2014-10-29 13:08:51 -07:00
Linux Build Service Account bf3e5e0bf5 Merge "scsi: ufs: add time profiling support" 2014-10-29 09:20:03 -07:00
Subhash Jadavani 25b2d8abda 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
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-10-28 00:00:20 -07:00
Subhash Jadavani 6d1dfe171c 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>
2014-10-28 00:00:13 -07:00
Maya Erez ff440b595e 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>
2014-10-27 21:57:45 +02:00
Subhash Jadavani 20b4b469ea 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>
2014-10-24 01:49:20 -07:00
Maya Erez d4878f6366 scsi: ufs: expose APIs to allow compiling ufs_test as a module
The UFS tests are used for testing the functionality and performance
of the UFS driver. In some of the tests ufs_test uses several scsi
and UFS APIs for getting the disc information and sending UFS
specific commands.
The used APIs should be exposed in order to allow compilation
of ufs_test as a module.

Change-Id: I1263429bd3d5172af3b5552f0b8b503e32a04e51
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
2014-10-23 15:18:35 +03:00
Linux Build Service Account 9736ad19c7 Merge "scsi: ufs: print the correct error state" 2014-10-20 00:36:32 -07:00
Linux Build Service Account eb78eaa5cb Merge "scsi: ufs: add capability to keep auto bkops always enabled" 2014-10-20 00:36:19 -07:00
Subhash Jadavani 80aa84aea1 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>
2014-10-17 17:37:06 -07:00
Subhash Jadavani 670eb6e844 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>
2014-10-16 16:33:28 -07:00
Subhash Jadavani ce2239ef96 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>
2014-10-16 13:00:53 -07:00
Linux Build Service Account da0bd5467a Merge "scsi: ufs: commit descriptors before setting the doorbell" 2014-10-14 18:32:05 -07:00
Linux Build Service Account 974ee3fb0d Merge "scsi: ufs: change clock gating timeout to 50ms" 2014-10-14 08:49:40 -07:00
Linux Build Service Account a335ba7640 Merge "scsi: ufs: Add sysfs node to dynamically control hibern8 on idle" 2014-10-14 08:49:39 -07:00
Linux Build Service Account 05e3251a9c Merge "scsi: ufs: add support for hibern8 on idle" 2014-10-14 08:49:38 -07:00
Gilad Broner 74c2d7b04e 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>
2014-10-13 16:23:05 -07:00
Linux Build Service Account d979f16ba3 Merge "scsi: ufs: update bus vector name used for slow-auto mode" 2014-10-13 13:32:00 -07:00
Subhash Jadavani b026bafcac 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>
2014-10-12 23:10:47 -07:00
Subhash Jadavani e1e5802c8f 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
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-10-12 23:10:46 -07:00
Subhash Jadavani c0bcee07e9 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>
2014-10-12 23:10:29 -07:00
Linux Build Service Account f75b4f525a Merge "scsi: ufs: clear UTRD, UPIU req and rsp before new transfers" 2014-10-12 11:50:45 -07:00
Linux Build Service Account b9221f6131 Merge "scsi: ufs: fix exception event handling" 2014-10-07 15:00:26 -07:00
Noa Rubens 2ae272e3ad 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>
2014-10-07 19:52:57 +03:00
Linux Build Service Account 49a50a9e9b Merge "scsi: ufs: reduce UFS dump prints for error case" 2014-10-06 22:52:43 -07:00
Mike Christie fe3ed8722e SCSI: libiscsi: fix potential buffer overrun in __iscsi_conn_send_pdu
commit db9bfd64b14a3a8f1868d2164518fdeab1b26ad1 upstream.

This patches fixes a potential buffer overrun in __iscsi_conn_send_pdu.
This function is used by iscsi drivers and userspace to send iscsi PDUs/
commands. For login commands, we have a set buffer size. For all other
commands we do not support data buffers.

This was reported by Dan Carpenter here:
http://www.spinics.net/lists/linux-scsi/msg66838.html

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-05 14:54:12 -07:00
Maya Erez b92a001a48 scsi: ufs: clear UTRD, UPIU req and rsp before new transfers
Clear the UFS data structures before sending new request.

The SCSI command is sent to the device within the UFS UPIU request.
As part of the transfer UPIU preparation, the SCSI command is copied
to the UPIU structure according to the SCSI command size.
As different SCSI commands differ in size from each other, we need
to clear the whole SCSI command field to prevent sending uninitialized
data to the device.

The UPIU response doesn't always include the sense data and can differ
in size.
Hence, the UPIU response should also be cleared before the transfer.

Change-Id: I9bba619dc884e973a05566e0f975bd8473612644
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
2014-10-05 23:06:23 +03:00
Maya Erez 2cbf325854 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>
2014-10-02 13:50:42 +03:00
Gilad Broner 10537cd041 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>
2014-10-02 13:47:49 +03:00
Linux Build Service Account 632ecc41d0 Merge "scsi: ufs: tune UniPro parameters to optimize hibern8 exit time" 2014-10-01 02:12:46 -07:00
Linux Build Service Account bc2aa73c3e Merge "scsi: ufs: move dme peer quirk handling to ufshcd_dme_get_attr()" 2014-09-29 07:55:43 -07:00
Linux Build Service Account fa79fab7b1 Merge "scsi: ufs: introduce the capability for interrupt aggregation" 2014-09-27 21:36:50 -07:00
Subhash Jadavani dd0b1193b4 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>
2014-09-26 19:15:24 -07:00
Subhash Jadavani 850cbe651f 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>
2014-09-26 19:14:48 -07:00
Subhash Jadavani 50af5a01ac 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>
2014-09-24 23:07:02 -07:00
Subhash Jadavani f910d9b200 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>
2014-09-24 22:58:09 -07:00
Subhash Jadavani d0090e173a scsi: ufs: introduce the capability for interrupt aggregation
UFS HCI (Host Controller Interface) allows the transfer requests
interrupts to be aggregated to generate the single interrupt but
this can impact the performance. Hence introduce the capability which
gives choice to use the interrupt aggregation capability or not.
By default interrupt aggregation capability is kept disabled.

Change-Id: I2a7e85a33f8208553576df327ddd2e183639af0a
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-09-23 09:35:27 -07:00
Linux Build Service Account 2af0d32cd6 Merge "scsi: ufs-qcom: enable host controller hardware clock gating" 2014-09-23 02:37:21 -07:00
Subhash Jadavani bd11274ff7 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>
2014-09-21 09:41:27 -07:00
Subhash Jadavani 01afb00443 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>
2014-09-19 16:54:10 -07:00
Subhash Jadavani 311f54ae2b 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
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-09-17 19:15:27 -07:00
Ben Hutchings db065663ad bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address
commit 03a6c3ff3282ee9fa893089304d951e0be93a144 upstream.

bfa_swap_words() shifts its argument (assumed to be 64-bit) by 32 bits
each way.  In two places the argument type is dma_addr_t, which may be
32-bit, in which case the effect of the bit shift is undefined:

drivers/scsi/bfa/bfa_fcpim.c: In function 'bfa_ioim_send_ioreq':
drivers/scsi/bfa/bfa_fcpim.c:2497:4: warning: left shift count >= width of type [enabled by default]
    addr = bfa_sgaddr_le(sg_dma_address(sg));
    ^
drivers/scsi/bfa/bfa_fcpim.c:2497:4: warning: right shift count >= width of type [enabled by default]
drivers/scsi/bfa/bfa_fcpim.c:2509:4: warning: left shift count >= width of type [enabled by default]
    addr = bfa_sgaddr_le(sg_dma_address(sg));
    ^
drivers/scsi/bfa/bfa_fcpim.c:2509:4: warning: right shift count >= width of type [enabled by default]

Avoid this by adding casts to u64 in bfa_swap_words().

Compile-tested only.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Fixes: f16a17507b ('[SCSI] bfa: remove all OS wrappers')
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-17 09:03:59 -07:00
K. Y. Srinivasan 8ce6d81a2d drivers: scsi: storvsc: Correctly handle TEST_UNIT_READY failure
commit 3533f8603d28b77c62d75ec899449a99bc6b77a1 upstream.

On some Windows hosts on FC SANs, TEST_UNIT_READY can return SRB_STATUS_ERROR.
Correctly handle this. Note that there is sufficient sense information to
support scsi error handling even in this case.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-17 09:03:58 -07:00
K. Y. Srinivasan 7afc3ac126 Drivers: scsi: storvsc: Implement a eh_timed_out handler
commit 56b26e69c8283121febedd12b3cc193384af46b9 upstream.

On Azure, we have seen instances of unbounded I/O latencies. To deal with
this issue, implement handler that can reset the timeout. Note that the
host gaurantees that it will respond to each command that has been issued.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
[hch: added a better comment explaining the issue]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-17 09:03:58 -07:00
Linux Build Service Account 3f2dd16592 Merge "scsi: ufs: fix bug when changing power mode via debugfs" 2014-09-14 17:29:01 -07:00
Yaniv Gardi 9765895962 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>
2014-09-12 10:28:43 +03:00
Subhash Jadavani e7367aae04 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>
2014-09-11 12:08:17 -07:00
Subhash Jadavani e808ab833b 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>
2014-09-09 18:15:37 -07:00
Subhash Jadavani 581d33b6d2 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>
2014-09-05 18:13:41 -07:00
Subhash Jadavani a74f9031fb 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>
2014-09-05 18:12:09 -07:00
Stephen M. Cameron 1c2cdf1f81 hpsa: fix bad -ENOMEM return value in hpsa_big_passthru_ioctl
commit 0758f4f732b08b6ef07f2e5f735655cf69fea477 upstream.

When copy_from_user fails, return -EFAULT, not -ENOMEM

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Reported-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Joe Handzik <joseph.t.handzik@hp.com>
Reviewed-by: Scott Teel <scott.teel@hp.com>
Reviewed by: Mike MIller <michael.miller@canonical.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-05 16:28:36 -07:00
Yaniv Gardi 3ba23ab306 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>
2014-09-03 15:31:52 +03:00
Yaniv Gardi 4fe56e46d8 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>
2014-09-03 15:24:57 +03:00
Yaniv Gardi 6662d79098 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>
2014-09-01 17:40:41 +03:00
Yaniv Gardi 35f5947282 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>
2014-09-01 17:31:46 +03:00
Linux Build Service Account 16ac86cdd2 Merge "scsi: ufs-msm: remove redundant dependencies in header files" 2014-08-30 22:37:01 -07:00
Vikram Mulukutla a59b27ed64 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>
2014-08-25 12:25:47 -07:00
Linux Build Service Account 2e1753aac3 Merge "scsi: ufs-msm: remove global variable that is not in use" 2014-08-25 08:22:36 -07:00
Linux Build Service Account ccd59794df Merge "Merge upstream tag 'v3.10.49' into msm-3.10" 2014-08-24 10:53:27 -07:00
Yaniv Gardi 8ebbffd060 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>
2014-08-24 06:19:12 -07:00
Linux Build Service Account d5ef52728a Merge "scsi: ufs-msm: request UFS register space access after power collapse" 2014-08-22 05:37:17 -07:00
Yaniv Gardi 498d758d3d 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>
2014-08-21 14:51:54 +03:00
Linux Build Service Account ea953b7026 Merge "scsi: ufs: null terminate buffer that is sent to strlcpy" 2014-08-20 22:58:29 -07:00
Subhash Jadavani 0bde81608c 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>
2014-08-20 18:18:47 -07:00
Ian Maund 6440f462f9 Merge upstream tag 'v3.10.49' into msm-3.10
* commit 'v3.10.49': (529 commits)
  Linux 3.10.49
  ACPI / battery: Retry to get battery information if failed during probing
  x86, ioremap: Speed up check for RAM pages
  Score: Modify the Makefile of Score, remove -mlong-calls for compiling
  Score: The commit is for compiling successfully.
  Score: Implement the function csum_ipv6_magic
  score: normalize global variables exported by vmlinux.lds
  rtmutex: Plug slow unlock race
  rtmutex: Handle deadlock detection smarter
  rtmutex: Detect changes in the pi lock chain
  rtmutex: Fix deadlock detector for real
  ring-buffer: Check if buffer exists before polling
  drm/radeon: stop poisoning the GART TLB
  drm/radeon: fix typo in golden register setup on evergreen
  ext4: disable synchronous transaction batching if max_batch_time==0
  ext4: clarify error count warning messages
  ext4: fix unjournalled bg descriptor while initializing inode bitmap
  dm io: fix a race condition in the wake up code for sync_io
  Drivers: hv: vmbus: Fix a bug in the channel callback dispatch code
  clk: spear3xx: Use proper control register offset
  ...

In addition to bringing in upstream commits, this merge also makes minor
changes to mainitain compatibility with upstream:

The definition of list_next_entry in qcrypto.c and ipa_dp.c has been
removed, as upstream has moved the definition to list.h. The implementation
of list_next_entry was identical between the two.

irq.c, for both arm and arm64 architecture, has had its calls to
__irq_set_affinity_locked updated to reflect changes to the API upstream.

Finally, as we have removed the sleep_length member variable of the
tick_sched struct, all changes made by upstream commit ec804bd do not
apply to our tree and have been removed from this merge. Only
kernel/time/tick-sched.c is impacted.

Change-Id: I63b7e0c1354812921c94804e1f3b33d1ad6ee3f1
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2014-08-20 13:23:09 -07:00
Yaniv Gardi fd070e2710 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>
2014-08-20 00:12:01 +03:00
Linux Build Service Account 61a807e407 Merge "scsi: ufs: fix a bug related to a null pointer access" 2014-08-19 02:08:40 -07:00
Linux Build Service Account 043aad2e86 Merge "Merge remote-tracking branch 'remotes/origin/tmp-e0de3bc' into msm-3.10" 2014-08-18 06:39:34 -07:00
Linux Build Service Account a5c9eff4f9 Merge "scsi: ufs: fix deadlock when attempting hibern8 during clock gating" 2014-08-18 01:58:53 -07:00
Yaniv Gardi c283e488d7 scsi: ufs: fix a bug related to a null pointer access
In this change there is a fix of a possible NULL pointer access.

Change-Id: Ibc5031f7ccb8b0efda65453b3899a23abfce94c5
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-08-18 10:16:21 +03:00
Peter Zijlstra c5ac12693f arch: Mass conversion of smp_mb__*()
Mostly scripted conversion of the smp_mb__* barriers.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/n/tip-55dhyhocezdw1dg7u19hmh1u@git.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Git-commit: 4e857c58efeb99393cba5a5d0d8ec7117183137c
[joonwoop@codeaurora.org: fixed trivial merge conflict.]
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
2014-08-15 11:45:28 -07:00
Subhash Jadavani 714133117c 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>
2014-08-14 19:01:15 -07:00
Subhash Jadavani 256ee38b8f 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>
2014-08-14 18:46:05 -07:00
Linux Build Service Account 179fd82ce5 Merge "scsi: ufs: fix a possible kernel info leak to userspace" 2014-08-12 17:38:21 -07:00
Linux Build Service Account 78d909d32a Merge "scsi: ufs: keep only urgent bkops enabled during suspend" 2014-08-08 11:59:42 -07:00
Linux Build Service Account d55969c6c6 Merge "scsi: ufs: fix suspend/resume tracing message" 2014-08-08 11:59:41 -07:00
Linux Build Service Account 92c2b26037 Merge "scsi: ufs: keep auto-bkops enabled after resume if urgent bkops needed" 2014-08-08 11:59:40 -07:00
James Bottomley 73e586351a scsi: handle flush errors properly
commit 89fb4cd1f717a871ef79fa7debbe840e3225cd54 upstream.

Flush commands don't transfer data and thus need to be special cased
in the I/O completion handler so that we can propagate errors to
the block layer and filesystem.

Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Reported-by: Steven Haber <steven@qumulo.com>
Tested-by: Steven Haber <steven@qumulo.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-08-07 14:30:25 -07:00
Subhash Jadavani a7ce91ec06 scsi: ufs: keep only urgent bkops enabled during suspend
During UFS runtime suspend, we currently allow the device to perform
background operations even when device bkops status shows that bkops
operations are required but non critical. But we don't want to keep the
device active to perform the non critical bkops, instead we should put
the UFS device in sleep state to save some power.

Change-Id: Ic8d06206cd9600874ed4fdc3b7991de167394ee7
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-08-07 11:23:00 -07:00
Subhash Jadavani d6732e89de 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
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-08-07 11:23:00 -07:00
Subhash Jadavani 074dba649e scsi: ufs: keep auto-bkops enabled after resume if urgent bkops needed
If device bkops status shows that its in critical need of executing
background operations, host should allow the device to continue doing
background operations. But UFS host driver's runtime/system resume
callbacks disable the auto-bkops irrespective of current bkops status
of device. This change fixes the above issue.

Change-Id: I9446ecc8e4016b6d93a2c620edb4512a91660ac7
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-08-07 11:23:00 -07:00
Yaniv Gardi 3094870b46 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>
2014-08-06 18:11:52 +03:00
Yaniv Gardi 1533b9db5d 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>
2014-08-05 16:07:35 +03:00
Linux Build Service Account b91851b5fb Merge "scsi: ufs: remove a redundant call of ufshcd_release()" 2014-08-04 02:30:59 -07:00
Yaniv Gardi 9203b57331 scsi: ufs: remove a redundant call of ufshcd_release()
In this patch a redundant call of ufshcd_release() is removed
after being called twice.

Change-Id: I28fc5b1525c3a598ec7402fdb8c698344bcb69a0
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-08-03 15:58:02 +03:00
Yaniv Gardi 1f565d863a scsi: ufs: fix a bug related to a null pointer access
In this change there is a fix of a possible NULL pointer access.

Change-Id: I4c6d4020d914a24b88153641db24519a2c36e4b0
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-30 21:27:06 +03:00
Yaniv Gardi de108b61fe 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>
2014-07-30 19:36:34 +03:00
Yaniv Gardi 41f158e58e 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>
2014-07-28 16:50:12 -07:00
Yaniv Gardi 5513df3b81 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>
2014-07-28 22:25:34 +03:00
Subhash Jadavani 9532a95508 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 "androidboot.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: I4f2b4ce56276658e4c72790b889d5a38ec78e518
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-07-24 10:37:56 -07:00
Linux Build Service Account 3a410b14a5 Merge "scsi: ufs-msm-phy-qmp-20nm: fix hibern8 exit failure" 2014-07-22 18:41:26 -07:00
Yaniv Gardi d52c4e89d4 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>
2014-07-22 01:26:39 +03:00
Subhash Jadavani 3d4dab853d 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>
2014-07-21 14:32:09 -07:00
Yaniv Gardi faff8cbf87 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>
2014-07-16 15:56:00 -07:00
Yaniv Gardi a819856e9a 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>
2014-07-17 01:41:59 +03:00
Mikulas Patocka c78d5ed42d sym53c8xx_2: Set DID_REQUEUE return code when aborting squeue
commit fd1232b214af43a973443aec6a2808f16ee5bf70 upstream.

This patch fixes I/O errors with the sym53c8xx_2 driver when the disk
returns QUEUE FULL status.

When the controller encounters an error (including QUEUE FULL or BUSY
status), it aborts all not yet submitted requests in the function
sym_dequeue_from_squeue.

This function aborts them with DID_SOFT_ERROR.

If the disk has full tag queue, the request that caused the overflow is
aborted with QUEUE FULL status (and the scsi midlayer properly retries
it until it is accepted by the disk), but the sym53c8xx_2 driver aborts
the following requests with DID_SOFT_ERROR --- for them, the midlayer
does just a few retries and then signals the error up to sd.

The result is that disk returning QUEUE FULL causes request failures.

The error was reproduced on 53c895 with COMPAQ BD03685A24 disk
(rebranded ST336607LC) with command queue 48 or 64 tags.  The disk has
64 tags, but under some access patterns it return QUEUE FULL when there
are less than 64 pending tags.  The SCSI specification allows returning
QUEUE FULL anytime and it is up to the host to retry.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-09 11:14:03 -07:00
Paolo Bonzini 58f550fa31 virtio-scsi: fix various bad behavior on aborted requests
commit 8faeb529b2dabb9df691d614dda18910a43d05c9 upstream.

Even though the virtio-scsi spec guarantees that all requests related
to the TMF will have been completed by the time the TMF itself completes,
the request queue's callback might not have run yet.  This causes requests
to be completed more than once, and as a result triggers a variety of
BUGs or oopses.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Venkatesh Srinivas <venkateshs@google.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-09 11:13:59 -07:00
Paolo Bonzini 3bf6608abb virtio-scsi: avoid cancelling uninitialized work items
commit cdda0e5acbb78f7b777049f8c27899e5c5bb368f upstream.

Calling the workqueue interface on uninitialized work items isn't a
good idea even if they're zeroed. It's not failing catastrophically only
through happy accidents.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-09 11:13:59 -07:00
Brian King c8e9b34fdc ibmvscsi: Add memory barriers for send / receive
commit 7114aae02742d6b5c5a0d39a41deb61d415d3717 upstream.

Add a memory barrier prior to sending a new command to the VIOS
to ensure the VIOS does not receive stale data in the command buffer.
Also add a memory barrier when processing the CRQ for completed commands.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Acked-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-09 11:13:59 -07:00
Brian King d383fcfd18 ibmvscsi: Abort init sequence during error recovery
commit 9ee755974bea2f9880e517ec985dc9dede1b3a36 upstream.

If a CRQ reset is triggered for some reason while in the middle
of performing VSCSI adapter initialization, we don't want to
call the done function for the initialization MAD commands as
this will only result in two threads attempting initialization
at the same time, resulting in failures.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Acked-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-09 11:13:59 -07:00
Linux Build Service Account 1cd6c521a5 Merge "test-iosched: ufs_test: fix gendisk usage in test" 2014-07-07 06:05:41 -07:00
Dolev Raviv eeea96cbba test-iosched: ufs_test: fix gendisk usage in test
Adding a new access api for gendisk without using scsi private
headers.
This patch fixes multiple errors:
1. Relative include path in ufs_test.c to <../sd.h>
2. Allowing suspend after first test run.

Change-Id: I152d34667ab63790b643abb55111fc5b67c90ac9
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
2014-07-07 11:41:32 +03:00
Eric W. Biederman 1141a45580 net: Use netlink_ns_capable to verify the permisions of netlink messages
[ Upstream commit 90f62cf30a78721641e08737bda787552428061e ]

It is possible by passing a netlink socket to a more privileged
executable and then to fool that executable into writing to the socket
data that happens to be valid netlink message to do something that
privileged executable did not intend to do.

To keep this from happening replace bare capable and ns_capable calls
with netlink_capable, netlink_net_calls and netlink_ns_capable calls.
Which act the same as the previous calls except they verify that the
opener of the socket had the desired permissions as well.

Reported-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-06-26 15:12:37 -04:00
Lee Susman 5021cdab66 scsi: ufs: add trace event for ufs commands
Use the ftrace infrastructure to conditionally trace ufs command events.
New trace event is created, which samples the following ufs command data:
- device name
- optional identification string
- task tag
- doorbell register
- number of transfer bytes
- interrupt status register
- request start LBA
- command opcode

Currently we only fully trace read(10) and write(10) commands.
All other commands which pass through ufshcd_send_command() will be
printed with "-1" in the lba and transfer_len fields.

Usage:
	echo 1 > /sys/kernel/debug/tracing/events/ufs/enable
	cat /sys/kernel/debug/tracing/trace_pipe

Change-Id: Id6e16a8c0b2a833c5453ed9923384f641e374a71
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
2014-06-24 17:28:50 +03:00
Linux Build Service Account 67a383249d Merge "Merge v3.10.40 and related reverts into msm-3.10" 2014-06-20 00:09:33 -07:00
Ian Maund 491fb5c232 Merge upstream tag 'v3.10.40' into msm-3.10
* commit 'v3.10.40': (203 commits)
  Linux 3.10.40
  ARC: !PREEMPT: Ensure Return to kernel mode is IRQ safe
  drm: cirrus: add power management support
  Input: synaptics - add min/max quirk for ThinkPad Edge E431
  Input: synaptics - add min/max quirk for ThinkPad T431s, L440, L540, S1 Yoga and X1
  lockd: ensure we tear down any live sockets when socket creation fails during lockd_up
  dm thin: fix dangling bio in process_deferred_bios error path
  dm transaction manager: fix corruption due to non-atomic transaction commit
  Skip intel_crt_init for Dell XPS 8700
  mtd: sm_ftl: heap corruption in sm_create_sysfs_attributes()
  mtd: nuc900_nand: NULL dereference in nuc900_nand_enable()
  mtd: atmel_nand: Disable subpage NAND write when using Atmel PMECC
  tgafb: fix data copying
  gpio: mxs: Allow for recursive enable_irq_wake() call
  rtlwifi: rtl8188ee: initialize packet_beacon
  rtlwifi: rtl8192se: Fix regression due to commit 1bf4bbb
  rtlwifi: rtl8192se: Fix too long disable of IRQs
  rtlwifi: rtl8192cu: Fix too long disable of IRQs
  rtlwifi: rtl8188ee: Fix too long disable of IRQs
  rtlwifi: rtl8723ae: Fix too long disable of IRQs
  ...

Change-Id: If5388cf980cb123e35e1b29275ba288c89c5aa18
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2014-06-18 13:10:54 -07:00
Ben Collins 2290f5a6ee SCSI: megaraid: Use resource_size_t for PCI resources, not long
commit 11f8a7b31f2140b0dc164bb484281235ffbe51d3 upstream.

The assumption that sizeof(long) >= sizeof(resource_size_t) can lead to
truncation of the PCI resource address, meaning this driver didn't work
on 32-bit systems with 64-bit PCI adressing ranges.

Signed-off-by: Ben Collins <ben.c@servergy.com>
Acked-by: Sumit Saxena <sumit.saxena@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-06-16 13:42:53 -07:00
Stepan Moskovchenko 75286e9a49 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>
2014-06-13 20:03:16 -07:00
Yaniv Gardi 04a2ce926f 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>
2014-06-09 18:03:46 -07:00
Dan Carpenter 8d6b283d97 SCSI: megaraid: missing bounds check in mimd_to_kioc()
commit 3de2260140417759c669d391613d583baf03b0cf upstream.

pthru32->dataxferlen comes from the user so we need to check that it's
not too large so we don't overflow the buffer.

Reported-by: Nico Golde <nico@ngolde.de>
Reported-by: Fabian Yamaguchi <fabs@goesec.de>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sumit Saxena <sumit.saxena@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-30 21:52:11 -07:00
James Bottomley e623c2cdb5 SCSI: dual scan thread bug fix
commit f2495e228fce9f9cec84367547813cbb0d6db15a upstream.

In the highly unusual case where two threads are running concurrently through
the scanning code scanning the same target, we run into the situation where
one may allocate the target while the other is still using it.  In this case,
because the reap checks for STARGET_CREATED and kills the target without
reference counting, the second thread will do the wrong thing on reap.

Fix this by reference counting even creates and doing the STARGET_CREATED
check in the final put.

Tested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-30 21:52:11 -07:00
James Bottomley c3c8d397fe scsi: fix our current target reap infrastructure
commit e63ed0d7a98014fdfc2cfeb3f6dada313dcabb59 upstream.

This patch eliminates the reap_ref and replaces it with a proper kref.
On last put of this kref, the target is removed from visibility in
sysfs.  The final call to scsi_target_reap() for the device is done from
__scsi_remove_device() and only if the device was made visible.  This
ensures that the target disappears as soon as the last device is gone
rather than waiting until final release of the device (which is often
too long).

Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-30 21:52:11 -07:00
Saravana Kannan c645cd4d8b PM / devfreq: Revert addition of devfreq_governor_data and related changes
This reverts commit 0e5b3352b5 and fixes
other code that resulted from it. The devfreq_governor_data field is not
needed since the governors can use other means (like container_of) to find
out device specific private data

Change-Id: Ib7e5db29b40d9676bbb5cf6057e0072665ace821
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-05-29 18:49:59 -07:00
Linux Build Service Account 83c1778356 Merge "scsi: ufs: provide sysfs attribute to select the PM level" 2014-05-25 05:43:51 -07:00
Tyler Stachecki 1ff13c4bf4 mpt2sas: Don't disable device twice at suspend.
commit af61e27c3f77c7623b5335590ae24b6a5c323e22 upstream.

On suspend, _scsih_suspend calls mpt2sas_base_free_resources, which
in turn calls pci_disable_device if the device is enabled prior to
suspending. However, _scsih_suspend also calls pci_disable_device
itself.

Thus, in the event that the device is enabled prior to suspending,
pci_disable_device will be called twice. This patch removes the
duplicate call to pci_disable_device in _scsi_suspend as it is both
unnecessary and results in a kernel oops.

Signed-off-by: Tyler Stachecki <tstache1@binghamton.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-13 13:59:41 +02:00
Fam Zheng abf9fb59f0 virtio-scsi: Skip setting affinity on uninitialized vq
commit 0c8482ac92db5ac15792caf23b7f7df9e4f48ae1 upstream.

virtscsi_init calls virtscsi_remove_vqs on err, even before initializing
the vqs. The latter calls virtscsi_set_affinity, so let's check the
pointer there before setting affinity on it.

This fixes a panic when setting device's num_queues=2 on RHEL 6.5:

qemu-system-x86_64 ... \
-device virtio-scsi-pci,id=scsi0,addr=0x13,...,num_queues=2 \
-drive file=/stor/vm/dummy.raw,id=drive-scsi-disk,... \
-device scsi-hd,drive=drive-scsi-disk,...

[    0.354734] scsi0 : Virtio SCSI HBA
[    0.379504] BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
[    0.380141] IP: [<ffffffff814741ef>] __virtscsi_set_affinity+0x4f/0x120
[    0.380141] PGD 0
[    0.380141] Oops: 0000 [#1] SMP
[    0.380141] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.14.0+ #5
[    0.380141] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2007
[    0.380141] task: ffff88003c9f0000 ti: ffff88003c9f8000 task.ti: ffff88003c9f8000
[    0.380141] RIP: 0010:[<ffffffff814741ef>]  [<ffffffff814741ef>] __virtscsi_set_affinity+0x4f/0x120
[    0.380141] RSP: 0000:ffff88003c9f9c08  EFLAGS: 00010256
[    0.380141] RAX: 0000000000000000 RBX: ffff88003c3a9d40 RCX: 0000000000001070
[    0.380141] RDX: 0000000000000002 RSI: 0000000000000000 RDI: 0000000000000000
[    0.380141] RBP: ffff88003c9f9c28 R08: 00000000000136c0 R09: ffff88003c801c00
[    0.380141] R10: ffffffff81475229 R11: 0000000000000008 R12: 0000000000000000
[    0.380141] R13: ffffffff81cc7ca8 R14: ffff88003cac3d40 R15: ffff88003cac37a0
[    0.380141] FS:  0000000000000000(0000) GS:ffff88003e400000(0000) knlGS:0000000000000000
[    0.380141] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[    0.380141] CR2: 0000000000000020 CR3: 0000000001c0e000 CR4: 00000000000006f0
[    0.380141] Stack:
[    0.380141]  ffff88003c3a9d40 0000000000000000 ffff88003cac3d80 ffff88003cac3d40
[    0.380141]  ffff88003c9f9c48 ffffffff814742e8 ffff88003c26d000 ffff88003c26d000
[    0.380141]  ffff88003c9f9c68 ffffffff81474321 ffff88003c26d000 ffff88003c3a9d40
[    0.380141] Call Trace:
[    0.380141]  [<ffffffff814742e8>] virtscsi_set_affinity+0x28/0x40
[    0.380141]  [<ffffffff81474321>] virtscsi_remove_vqs+0x21/0x50
[    0.380141]  [<ffffffff81475231>] virtscsi_init+0x91/0x240
[    0.380141]  [<ffffffff81365290>] ? vp_get+0x50/0x70
[    0.380141]  [<ffffffff81475544>] virtscsi_probe+0xf4/0x280
[    0.380141]  [<ffffffff81363ea5>] virtio_dev_probe+0xe5/0x140
[    0.380141]  [<ffffffff8144c669>] driver_probe_device+0x89/0x230
[    0.380141]  [<ffffffff8144c8ab>] __driver_attach+0x9b/0xa0
[    0.380141]  [<ffffffff8144c810>] ? driver_probe_device+0x230/0x230
[    0.380141]  [<ffffffff8144c810>] ? driver_probe_device+0x230/0x230
[    0.380141]  [<ffffffff8144ac1c>] bus_for_each_dev+0x8c/0xb0
[    0.380141]  [<ffffffff8144c499>] driver_attach+0x19/0x20
[    0.380141]  [<ffffffff8144bf28>] bus_add_driver+0x198/0x220
[    0.380141]  [<ffffffff8144ce9f>] driver_register+0x5f/0xf0
[    0.380141]  [<ffffffff81d27c91>] ? spi_transport_init+0x79/0x79
[    0.380141]  [<ffffffff8136403b>] register_virtio_driver+0x1b/0x30
[    0.380141]  [<ffffffff81d27d19>] init+0x88/0xd6
[    0.380141]  [<ffffffff81d27c18>] ? scsi_init_procfs+0x5b/0x5b
[    0.380141]  [<ffffffff81ce88a7>] do_one_initcall+0x7f/0x10a
[    0.380141]  [<ffffffff81ce8aa7>] kernel_init_freeable+0x14a/0x1de
[    0.380141]  [<ffffffff81ce8b3b>] ? kernel_init_freeable+0x1de/0x1de
[    0.380141]  [<ffffffff817dec20>] ? rest_init+0x80/0x80
[    0.380141]  [<ffffffff817dec29>] kernel_init+0x9/0xf0
[    0.380141]  [<ffffffff817e68fc>] ret_from_fork+0x7c/0xb0
[    0.380141]  [<ffffffff817dec20>] ? rest_init+0x80/0x80
[    0.380141] RIP  [<ffffffff814741ef>] __virtscsi_set_affinity+0x4f/0x120
[    0.380141]  RSP <ffff88003c9f9c08>
[    0.380141] CR2: 0000000000000020
[    0.380141] ---[ end trace 8074b70c3d5e1d73 ]---
[    0.475018] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
[    0.475018]
[    0.475068] Kernel Offset: 0x0 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffff9fffffff)
[    0.475068] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009

[jejb: checkpatch fixes]
Signed-off-by: Fam Zheng <famz@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-13 13:59:41 +02:00
Subhash Jadavani facc9df175 scsi: ufs: fix deadlock during runtime resume
Commit e21cdd59b6 (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>
2014-05-09 17:59:40 -07:00
Dan Carpenter 84bb7edf33 SCSI: arcmsr: upper 32 of dma address lost
commit e2c70425f05219b142b3a8a9489a622c736db39d upstream.

The original code always set the upper 32 bits to zero because it was
doing a shift of the wrong variable.

Fixes: 1a4f550a09 ('[SCSI] arcmsr: 1.20.00.15: add SATA RAID plus other fixes')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-06 07:55:30 -07:00
Dan Carpenter daa12c3ab5 SCSI: qla2xxx: fix error handling of qla2x00_mem_alloc()
commit b2a72ec32d0f499aaadf41264232517a12326df0 upstream.

qla2x00_mem_alloc() returns 1 on success and -ENOMEM on failure.  On the
one hand the caller assumes non-zero is success but on the other hand
the caller also assumes that it returns an error code.

I've fixed it to return zero on success and a negative error code on
failure.  This matches the documentation as well.

[jejb: checkpatch fix]
Fixes: e315cd28b9 ('[SCSI] qla2xxx: Code changes for qla data structure refactoring')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-06 07:55:30 -07:00
Linux Build Service Account 16296e0178 Merge "Merge upstream linux-stable v3.10.36 into msm-3.10" 2014-05-05 15:09:00 -07:00
Subhash Jadavani cf13ff10d5 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>
2014-04-30 18:59:46 -07:00
Subhash Jadavani c004419141 scsi: ufs: add support to power collapse UFS host controller
If UFS link is in OFF state then UFS host controller can be power collapsed
to avoid leakage current from it. Note that if UFS host controller is power
collapsed, full UFS reinitialization will be required on resume to
re-establish the link between host and device.

Change-Id: I7b96c65360f170eed5f063b1645bed149b363997
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-04-30 18:21:48 -07:00
Subhash Jadavani 6f8182218c 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>
2014-04-30 17:41:13 -07:00
Raviv Shvili 895abd26f3 scsi: ufs: fix compilation warning on debugfs
msm8994 compilation treats warnings as errors.
function signature should return int instead of ssize_t.

Change-Id: I17a1a7d3b08e710f73690ea03615454c4cda795a
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
2014-04-28 16:23:06 +03:00
Ian Maund 356fb13538 Merge upstream linux-stable v3.10.36 into msm-3.10
* commit 'v3.10.36': (494 commits)
  Linux 3.10.36
  netfilter: nf_conntrack_dccp: fix skb_header_pointer API usages
  mm: close PageTail race
  net: mvneta: rename MVNETA_GMAC2_PSC_ENABLE to MVNETA_GMAC2_PCS_ENABLE
  x86: fix boot on uniprocessor systems
  Input: cypress_ps2 - don't report as a button pads
  Input: synaptics - add manual min/max quirk for ThinkPad X240
  Input: synaptics - add manual min/max quirk
  Input: mousedev - fix race when creating mixed device
  ext4: atomically set inode->i_flags in ext4_set_inode_flags()
  Linux 3.10.35
  sched/autogroup: Fix race with task_groups list
  e100: Fix "disabling already-disabled device" warning
  xhci: Fix resume issues on Renesas chips in Samsung laptops
  Input: wacom - make sure touch_max is set for touch devices
  KVM: VMX: fix use after free of vmx->loaded_vmcs
  KVM: x86: handle invalid root_hpa everywhere
  KVM: MMU: handle invalid root_hpa at __direct_map
  Input: elantech - improve clickpad detection
  ARM: highbank: avoid L2 cache smc calls when PL310 is not present
  ...

Change-Id: Ib68f565291702c53df09e914e637930c5d3e5310
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2014-04-23 16:23:49 -07:00
Linux Build Service Account 16bea607e4 Merge "scsi: ufs: Add sysfs node to dynamically control clock scaling" 2014-04-20 22:49:22 -07:00
Linux Build Service Account b28a332c46 Merge "scsi: ufs: Change power mode at run-time via debug-fs" 2014-04-17 16:29:22 -07:00
Linux Build Service Account 8aa3f9efa8 Merge "scsi: ufs: allow configuring power mode without reading it" 2014-04-17 16:29:19 -07:00
Gilad Broner e21cdd59b6 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>
2014-04-17 13:37:16 +03:00
Dolev Raviv c1d2223338 scsi: ufs: allow configuring power mode without reading it
To enable configuring different power modes (number of lanes,
gear number and fast/slow modes) it is necessary to split the
configuration stage from the stage that reads the device max power mode.
In addition, it is not required to read the configuration more than
once, thus the configuration is stored after reading it once.

Change-Id: If79898eebda3c89d512fcbdf1e7d361de756dcc0
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
2014-04-17 12:57:48 +03:00
Sahitya Tummala 63b08df39c 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>
2014-04-16 16:56:28 +05:30
Linux Build Service Account 1868dab040 Merge "scsi: ufs: add debug counters for recoverable errors during runtime" 2014-04-16 01:09:44 -07:00
Linux Build Service Account 54e78301e7 Merge "scsi: ufs: Add sysfs node to dynamically control clock gating" 2014-04-16 01:09:26 -07:00
Yaniv Gardi b067344883 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>
2014-04-15 22:50:44 +03:00
Subhash Jadavani a285aa3300 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>
2014-04-06 10:47:43 +03:00
Sahitya Tummala 2ba8dad5cb 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>
2014-04-02 12:42:05 +05:30
Raviv Shvili 54e864f95b 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>
2014-04-01 22:20:15 +03:00
Linux Build Service Account 488e1012d6 Merge "scsi: ufs: add read string descriptor api" 2014-03-30 18:28:45 -07:00
Raviv Shvili 93f2fecb78 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>
2014-03-30 13:36:05 +03:00
Sahitya Tummala ed36ca564c scsi: ufs: fix issue with clock gating
In a case where clocks are gated and to ungate them ufshcd_hold()
is called with async flag set to false, clocks would be enabled
within the same context. There is a bug in the current code where
the active_reqs counter is getting incremented twice. This would
further prevent clock gating from happening.  Fix this issue by
updating the active_reqs correctly.

Change-Id: I70bdae8d1ccc189db9bd2e9fee66678c571933f6
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-03-28 09:46:51 +05:30
Linux Build Service Account b198cb9af1 Merge "Merge upstream linux-stable v3.10.28 into msm-3.10" 2014-03-26 23:36:07 -07:00
Ian Maund f1b32d4e47 Merge upstream linux-stable v3.10.28 into msm-3.10
The following commits have been reverted from this merge, as they are
known to introduce new bugs and are currently incompatible with our
audio implementation. Investigation of these commits is ongoing, and
they are expected to be brought in at a later time:

86e6de7 ALSA: compress: fix drain calls blocking other compress functions (v6)
16442d4 ALSA: compress: fix drain calls blocking other compress functions

This merge commit also includes a change in block, necessary for
compilation. Upstream has modified elevator_init_fn to prevent race
conditions, requring updates to row_init_queue and test_init_queue.

* commit 'v3.10.28': (1964 commits)
  Linux 3.10.28
  ARM: 7938/1: OMAP4/highbank: Flush L2 cache before disabling
  drm/i915: Don't grab crtc mutexes in intel_modeset_gem_init()
  serial: amba-pl011: use port lock to guard control register access
  mm: Make {,set}page_address() static inline if WANT_PAGE_VIRTUAL
  md/raid5: Fix possible confusion when multiple write errors occur.
  md/raid10: fix two bugs in handling of known-bad-blocks.
  md/raid10: fix bug when raid10 recovery fails to recover a block.
  md: fix problem when adding device to read-only array with bitmap.
  drm/i915: fix DDI PLLs HW state readout code
  nilfs2: fix segctor bug that causes file system corruption
  thp: fix copy_page_rep GPF by testing is_huge_zero_pmd once only
  ftrace/x86: Load ftrace_ops in parameter not the variable holding it
  SELinux: Fix possible NULL pointer dereference in selinux_inode_permission()
  writeback: Fix data corruption on NFS
  hwmon: (coretemp) Fix truncated name of alarm attributes
  vfs: In d_path don't call d_dname on a mount point
  staging: comedi: adl_pci9111: fix incorrect irq passed to request_irq()
  staging: comedi: addi_apci_1032: fix subdevice type/flags bug
  mm/memory-failure.c: recheck PageHuge() after hugetlb page migrate successfully
  GFS2: Increase i_writecount during gfs2_setattr_chown
  perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h
  perf scripting perl: Fix build error on Fedora 12
  ARM: 7815/1: kexec: offline non panic CPUs on Kdump panic
  Linux 3.10.27
  sched: Guarantee new group-entities always have weight
  sched: Fix hrtimer_cancel()/rq->lock deadlock
  sched: Fix cfs_bandwidth misuse of hrtimer_expires_remaining
  sched: Fix race on toggling cfs_bandwidth_used
  x86, fpu, amd: Clear exceptions in AMD FXSAVE workaround
  netfilter: nf_nat: fix access to uninitialized buffer in IRC NAT helper
  SCSI: sd: Reduce buffer size for vpd request
  intel_pstate: Add X86_FEATURE_APERFMPERF to cpu match parameters.
  mac80211: move "bufferable MMPDU" check to fix AP mode scan
  ACPI / Battery: Add a _BIX quirk for NEC LZ750/LS
  ACPI / TPM: fix memory leak when walking ACPI namespace
  mfd: rtsx_pcr: Disable interrupts before cancelling delayed works
  clk: exynos5250: fix sysmmu_mfc{l,r} gate clocks
  clk: samsung: exynos5250: Add CLK_IGNORE_UNUSED flag for the sysreg clock
  clk: samsung: exynos4: Correct SRC_MFC register
  clk: clk-divider: fix divisor > 255 bug
  ahci: add PCI ID for Marvell 88SE9170 SATA controller
  parisc: Ensure full cache coherency for kmap/kunmap
  drm/nouveau/bios: make jump conditional
  ARM: shmobile: mackerel: Fix coherent DMA mask
  ARM: shmobile: armadillo: Fix coherent DMA mask
  ARM: shmobile: kzm9g: Fix coherent DMA mask
  ARM: dts: exynos5250: Fix MDMA0 clock number
  ARM: fix "bad mode in ... handler" message for undefined instructions
  ARM: fix footbridge clockevent device
  net: Loosen constraints for recalculating checksum in skb_segment()
  bridge: use spin_lock_bh() in br_multicast_set_hash_max
  netpoll: Fix missing TXQ unlock and and OOPS.
  net: llc: fix use after free in llc_ui_recvmsg
  virtio-net: fix refill races during restore
  virtio_net: don't leak memory or block when too many frags
  virtio-net: make all RX paths handle errors consistently
  virtio_net: fix error handling for mergeable buffers
  vlan: Fix header ops passthru when doing TX VLAN offload.
  net: rose: restore old recvmsg behavior
  rds: prevent dereference of a NULL device
  ipv6: always set the new created dst's from in ip6_rt_copy
  net: fec: fix potential use after free
  hamradio/yam: fix info leak in ioctl
  drivers/net/hamradio: Integer overflow in hdlcdrv_ioctl()
  net: inet_diag: zero out uninitialized idiag_{src,dst} fields
  ip_gre: fix msg_name parsing for recvfrom/recvmsg
  net: unix: allow bind to fail on mutex lock
  ipv6: fix illegal mac_header comparison on 32bit
  netvsc: don't flush peers notifying work during setting mtu
  tg3: Initialize REG_BASE_ADDR at PCI config offset 120 to 0
  net: unix: allow set_peek_off to fail
  net: drop_monitor: fix the value of maxattr
  ipv6: don't count addrconf generated routes against gc limit
  packet: fix send path when running with proto == 0
  virtio: delete napi structures from netdev before releasing memory
  macvtap: signal truncated packets
  tun: update file current position
  macvtap: update file current position
  macvtap: Do not double-count received packets
  rds: prevent BUG_ON triggered on congestion update to loopback
  net: do not pretend FRAGLIST support
  IPv6: Fixed support for blackhole and prohibit routes
  HID: Revert "Revert "HID: Fix logitech-dj: missing Unifying device issue""
  gpio-rcar: R-Car GPIO IRQ share interrupt
  clocksource: em_sti: Set cpu_possible_mask to fix SMP broadcast
  irqchip: renesas-irqc: Fix irqc_probe error handling
  Linux 3.10.26
  sh: add EXPORT_SYMBOL(min_low_pfn) and EXPORT_SYMBOL(max_low_pfn) to sh_ksyms_32.c
  ext4: fix bigalloc regression
  arm64: Use Normal NonCacheable memory for writecombine
  arm64: Do not flush the D-cache for anonymous pages
  arm64: Avoid cache flushing in flush_dcache_page()
  ARM: KVM: arch_timers: zero CNTVOFF upon return to host
  ARM: hyp: initialize CNTVOFF to zero
  clocksource: arch_timer: use virtual counters
  arm64: Remove unused cpu_name ascii in arch/arm64/mm/proc.S
  arm64: dts: Reserve the memory used for secondary CPU release address
  arm64: check for number of arguments in syscall_get/set_arguments()
  arm64: fix possible invalid FPSIMD initialization state
  ...

Change-Id: Ia0e5d71b536ab49ec3a1179d59238c05bdd03106
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2014-03-24 14:28:34 -07:00
Raviv Shvili e29daa2502 scsi: ufs: add voting support for host controller power
Add the support for voting of the regulator powering the
host controller logic.

Change-Id: Ibcb7eb4bcc6fabd49aea48957028a21a373c833b
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
2014-03-24 12:57:55 +02:00
Ales Novak 535dba0ec5 SCSI: storvsc: NULL pointer dereference fix
commit b12bb60d6c350b348a4e1460cd68f97ccae9822e upstream.

If the initialization of storvsc fails, the storvsc_device_destroy()
causes NULL pointer dereference.

storvsc_bus_scan()
  scsi_scan_target()
    __scsi_scan_target()
      scsi_probe_and_add_lun(hostdata=NULL)
        scsi_alloc_sdev(hostdata=NULL)

	  sdev->hostdata = hostdata

	  now the host allocation fails

          __scsi_remove_device(sdev)

	  calls sdev->host->hostt->slave_destroy() ==
	  storvsc_device_destroy(sdev)
	    access of sdev->hostdata->request_mempool

Signed-off-by: Ales Novak <alnovak@suse.cz>
Signed-off-by: Thomas Abraham <tabraham@suse.com>
Reviewed-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 21:38:19 -07:00
Giridhar Malavali 2848c03a56 SCSI: qla2xxx: Poll during initialization for ISP25xx and ISP83xx
commit b77ed25c9f8402e8b3e49e220edb4ef09ecfbb53 upstream.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 21:38:19 -07:00
Lukasz Dorau be92db5e00 SCSI: isci: correct erroneous for_each_isci_host macro
commit c59053a23d586675c25d789a7494adfdc02fba57 upstream.

In the first place, the loop 'for' in the macro 'for_each_isci_host'
(drivers/scsi/isci/host.h:314) is incorrect, because it accesses
the 3rd element of 2 element array. After the 2nd iteration it executes
the instruction:
        ihost = to_pci_info(pdev)->hosts[2]
(while the size of the 'hosts' array equals 2) and reads an
out of range element.

In the second place, this loop is incorrectly optimized by GCC v4.8
(see http://marc.info/?l=linux-kernel&m=138998871911336&w=2).
As a result, on platforms with two SCU controllers,
the loop is executed more times than it can be (for i=0,1 and 2).
It causes kernel panic during entering the S3 state
and the following oops after 'rmmod isci':

BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<ffffffff8131360b>] __list_add+0x1b/0xc0
Oops: 0000 [#1] SMP
RIP: 0010:[<ffffffff8131360b>]  [<ffffffff8131360b>] __list_add+0x1b/0xc0
Call Trace:
  [<ffffffff81661b84>] __mutex_lock_slowpath+0x114/0x1b0
  [<ffffffff81661c3f>] mutex_lock+0x1f/0x30
  [<ffffffffa03e97cb>] sas_disable_events+0x1b/0x50 [libsas]
  [<ffffffffa03e9818>] sas_unregister_ha+0x18/0x60 [libsas]
  [<ffffffffa040316e>] isci_unregister+0x1e/0x40 [isci]
  [<ffffffffa0403efd>] isci_pci_remove+0x5d/0x100 [isci]
  [<ffffffff813391cb>] pci_device_remove+0x3b/0xb0
  [<ffffffff813fbf7f>] __device_release_driver+0x7f/0xf0
  [<ffffffff813fc8f8>] driver_detach+0xa8/0xb0
  [<ffffffff813fbb8b>] bus_remove_driver+0x9b/0x120
  [<ffffffff813fcf2c>] driver_unregister+0x2c/0x50
  [<ffffffff813381f3>] pci_unregister_driver+0x23/0x80
  [<ffffffffa04152f8>] isci_exit+0x10/0x1e [isci]
  [<ffffffff810d199b>] SyS_delete_module+0x16b/0x2d0
  [<ffffffff81012a21>] ? do_notify_resume+0x61/0xa0
  [<ffffffff8166ce29>] system_call_fastpath+0x16/0x1b

The loop has been corrected.
This patch fixes kernel panic during entering the S3 state
and the above oops.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Reviewed-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
Tested-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 21:38:19 -07:00
Dan Williams a5748c58fc SCSI: isci: fix reset timeout handling
commit ddfadd7736b677de2d4ca2cd5b4b655368c85a7a upstream.

Remove an erroneous BUG_ON() in the case of a hard reset timeout.  The
reset timeout handler puts the port into the "awaiting link-up" state.
The timeout causes the device to be disconnected and we need to be in
the awaiting link-up state to re-connect the port.  The BUG_ON() made
the incorrect assumption that resets never timeout and we always
complete the reset in the "resetting" state.

Testing this patch also uncovered that libata continues to attempt to
reset the port long after the driver has torn down the context.  Once
the driver has committed to abandoning the link it must indicate to
libata that recovery ends by returning -ENODEV from
->lldd_I_T_nexus_reset().

Acked-by: Lukasz Dorau <lukasz.dorau@intel.com>
Reported-by: David Milburn <dmilburn@redhat.com>
Reported-by: Xun Ni <xun.ni@intel.com>
Tested-by: Xun Ni <xun.ni@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 21:38:19 -07:00
Raviv Shvili 46d0b53c9d 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>
2014-03-22 05:52:40 -07:00
Subhash Jadavani b8acd9db12 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>
2014-03-22 05:51:41 -07:00
Subhash Jadavani a18d2ea155 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>
2014-03-22 05:48:33 -07:00
Subhash Jadavani e889f949eb 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>
2014-03-22 05:48:26 -07:00
Linux Build Service Account 7fbf06d63a Merge "scsi: ufs-msm: allow background operations during runtime suspend" into msm-3.10 2014-03-22 05:32:00 -07:00
Linux Build Service Account d6e8772b09 Merge "scsi: ufs-msm: enable UFS clock scaling and gating functionality" into msm-3.10 2014-03-22 05:30:58 -07:00
Subhash Jadavani 434c3f30ad 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>
2014-03-21 12:45:43 -07:00
Subhash Jadavani 570584dd9b scsi: ufs-msm: enable UFS clock scaling and gating functionality
UFS clock scaling and gating functionality is quite stable now hence
enable it now.

Change-Id: Ia64320b61d96905d8c8b6664ddfaf91d0ca7f187
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-03-20 15:40:36 -07:00
Dolev Raviv 03494f8d81 Revert "scsi: ufs: try read capacity (10) first"
This reverts commit 7d76a33cac.
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>
2014-03-20 11:21:56 +02:00
Linux Build Service Account 8e50707a9c Merge "scsi: ufs: optimize the sending of REQUEST_SENSE to device W-LU" 2014-03-15 10:09:38 -07:00
Subhash Jadavani d284599f95 scsi: ufs: optimize the sending of REQUEST_SENSE to device W-LU
UFS device W-LU (Well known Logical Unit)'s UNIT ATTENTION condition will
not be cleared until explict REQUEST_SENSE scsi command is issued to it
once and then after UNIT ATTENTION condition should remain cleared until
device reset or power-on. Current implementation of UFS driver may send
the REQUEST_SEND command multiple time which is really not needed. This
change would send the REQUEST_SENSE only once after the device reset or
power-on.

Change-Id: I20292e12cbbeded18befffe73abbf2e99ef21ba1
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-03-13 19:01:02 -07:00
Linux Build Service Account 3493059093 Merge "msm: msm_bus: Move bus scaling to platform drivers" 2014-03-11 22:48:49 -07:00
Linux Build Service Account d099051c93 Merge "scsi: ufshcd: suspend clock scaling before clocks are gated" 2014-03-11 19:31:06 -07:00
Dan Sneddon b0da38f02c msm: msm_bus: Move bus scaling to platform drivers
Moves bus scaling code to architecture independant directory
for platform drivers.

Change-Id: Ie0d5b104882d1534fae262af85e99cc09a56ab04
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
2014-03-11 18:00:53 -06:00
Sahitya Tummala 56ec236892 scsi: ufshcd: suspend clock scaling before clocks are gated
Wait for pending clock scaling work to be done before clocks are
turned off in runtime suspend as scaling needs access to controller
registers.

Change-Id: I588544692fa6ceb75b8712b9116745f831586d68
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-03-11 15:14:46 +05:30
Linux Build Service Account 7b15df04c7 Merge "scsi: ufs-msm: 64-bit compatibility fixes" 2014-03-10 04:40:57 -07:00
Dr. Greg Wettstein 31ccf35d55 qla2xxx: Fix kernel panic on selective retransmission request
commit 6f58c780e5a5b43a6d2121e0d43cdcba1d3cc5fc upstream.

A selective retransmission request (SRR) is a fibre-channel
protocol control request which provides support for requesting
retransmission of a data sequence in response to an issue such as
frame loss or corruption.  These events are experienced
infrequently in fibre-channel based networks which makes
it difficult to test and assess codepaths which handle these
events.

We were fortunate enough, for some definition of fortunate, to
have a metro-area single-mode SAN link which, at 10 GBPS
sustained load levels, would consistently generate SRR's in
a SCST based target implementation using our SCST/in-kernel
Qlogic target interface driver.  In response to an SRR the
in-kernel Qlogic target driver immediately panics resulting
in a catastrophic storage failure for serviced initiators.

The culprit was a debug statement in the qla_target.c file which
does not verify that a pointer to the SCSI CDB is not null.
The unchecked pointer dereference results in the kernel panic
and resultant system failure.

The other two references to the SCSI CDB by the SRR handling code
use a ternary operator to verify a non-null pointer is being
acted on.  This patch simply adds a similar test to the implicated
debug statement.

This patch is a candidate for any stable kernel being maintained
since it addresses a potentially catastrophic event with
minimal downside.

Signed-off-by: Dr. Greg Wettstein <greg@enjellic.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-06 21:30:13 -08:00
Raviv Shvili 32cc5ec3ba scsi: ufs-msm: 64-bit compatibility fixes
Fix debug print to be compatible with 64bit platforms.
The debug print is needed in order to diagnose
customers issues.

Change-Id: Ia76daefea3cdcf0afedac31e4b615a3bbfb8ed80
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
2014-03-05 19:06:07 +02:00
Linux Build Service Account d483b0120b Merge "scsi: ufshcd: fix one of the argument type for ufshcd_query_descriptor" 2014-03-05 08:39:16 -08:00
Linux Build Service Account 3b0b56856c Merge "scsi: ufshcd: keep device rails on if link is not in OFF state" 2014-03-05 08:39:14 -08:00
Linux Build Service Account 331a13d646 Merge "scsi: ufs: 64-bit compatibility fixes" 2014-03-05 03:48:48 -08:00
Raviv Shvili c45969de51 scsi: ufs: 64-bit compatibility fixes
Fix debug print to be compatible with 64bit platforms.
The debug print is needed in order to diagnose
customers issues.

Change-Id: I60613faa6772f95257509dae08c52bb5efe664a4
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
2014-03-04 18:18:04 +02:00
Subhash Jadavani 65d193a580 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>
2014-03-01 02:12:17 -08:00
Subhash Jadavani 829a9e8a25 scsi: ufshcd: keep device rails on if link is not in OFF state
If none of the Logical Units on UFS device is power on write protected
then all UFS device power rails (VCC, VCCQ & VCCQ2) can be turned off if
UFS device is in power-off state and UFS link is in OFF state. But current
implementation would disable all device power rails even if UFS link is
not in OFF state.

Change-Id: I039e2df16eedc5c30c4473b5529e808612e53788
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-03-01 01:09:28 -08:00
Subhash Jadavani 59e5f51156 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>
2014-02-27 23:44:31 -08:00
Subhash Jadavani ffc9b69398 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>
2014-02-27 23:41:08 -08:00
Linux Build Service Account 6022cda201 Merge "scsi: ufs: add data integrity test to ufs unit tests" 2014-02-22 14:50:46 -08:00
Lee Susman d34d7769c8 scsi: ufs: add data integrity test to ufs unit tests
This testcase checks data integrity in a random I/O usecase.
The test writes QUEUE_MAX_REQUESTS (usually 118) requests of size 4KB
to randomly and uniquely chosen LBAs. A different pattern is written
to each LBA (pattern written is index of LBA). After successfully writing,
the test reads from the above LBAs and verifies the pattern.

Change-Id: I09c6dda12834f06ae393411501f443bfd058dea4
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
2014-02-20 18:08:33 +02:00
Subhash Jadavani 9afe21c724 scsi: ufs: add PM level for device power-down mode and link hibernate
Add new PM level which allows UFS device to put into power down mode
and UFS link into hibern8 mode.

Change-Id: Ic235824c980db5f94f8441e710c9c41c5892c848
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-02-19 11:29:54 -08:00
Subhash Jadavani 2d4fab9abf 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>
2014-02-16 19:11:02 -08:00
Subhash Jadavani a6582b5d36 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>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-02-14 17:52:01 -08:00
Dolev Raviv 2167ee55a4 scsi: ufs: link-startup on hibern8 exit error
There is no error recovery when encountering Hibern8 exit
errors. To recover from such errors it is required to re-init
the link and the device.

Change-Id: Ib73aaebc6f5c4eff0e5903fcdfd48aa9314bd946
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
2014-02-14 14:04:05 -08:00
Subhash Jadavani eb1bff2236 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>
2014-02-14 14:03:58 -08:00
Subhash Jadavani c02ee8011e 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>
2014-02-13 08:40:53 -08:00
Linux Build Service Account bcd807f15d Merge "scsi: ufs: add capability to control the auto bkops during suspend" 2014-02-13 02:20:10 -08:00
Linux Build Service Account b530479ef1 Merge "scsi: ufs-msm: enable quirk to fix gear change to HS" 2014-02-13 02:20:07 -08:00
Linux Build Service Account 357d5df987 Merge "scsi: ufs: add a quirk to fix gear change to HS" 2014-02-13 02:20:03 -08:00
Subhash Jadavani ab9fa23b65 scsi: ufs: add capability to control the auto bkops during suspend
If host explicitly enables the auto bkops (background operation) on device
then only device would perform the bkops on its own. If auto bkops is not
enabled explicitly and if the device reaches to state where it must do
background operation, device would raise the urgent bkops exception event
to host and then host will enable the auto bkops on device. This patch
adds the option to choose whether auto bkops should be enabled during
runtime suspend or not.

Change-Id: Ib725ad08d5d810a1251c8ae5009504b33b9fcab8
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-02-12 18:16:06 -08:00
Yaniv Gardi cdd914040b 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>
2014-02-12 18:15:15 -08:00
Yaniv Gardi 153b54883a scsi: ufs: add a quirk to fix gear change to HS
With the G3 UFS devices, changing gear into HS is failing.
This 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

Change-Id: Id9c0e391b7bac0ef720841cf75c7da0e3cc44d56
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-02-12 18:15:00 -08:00
Linux Build Service Account 4c55794c7e Merge "scsi: ufs: fix multiple ufs spec violation" 2014-02-12 17:39:31 -08:00
Dolev Raviv 5dfd6e2c61 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>
2014-02-12 10:25:13 +02:00
Yaniv Gardi 4a4c9da0ff 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>
2014-02-11 23:45:01 -08:00
Lee Susman 1e6a8fa10b scsi: ufs: add test case string for long random tests
Add missing test name strings to long random tests.
These test names are used to distinguish between test case when running
automatic tests.

Change-Id: I1d375eb3cfdd2ae645ba086b7e3121026f3652ae
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
2014-02-10 13:07:01 +02:00
Asias He 26996fcd25 virtio-scsi: Fix hotcpu_notifier use-after-free with virtscsi_freeze
commit f466f75385369a181409e46da272db3de6f5c5cb upstream.

vqs are freed in virtscsi_freeze but the hotcpu_notifier is not
unregistered. We will have a use-after-free usage when the notifier
callback is called after virtscsi_freeze.

Fixes: 285e71ea6f
("virtio-scsi: reset virtqueue affinity when doing cpu hotplug")

Signed-off-by: Asias He <asias.hejun@gmail.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-06 11:08:17 -08:00
Vijaya Mohan Guvva ed9d61e94e SCSI: bfa: Chinook quad port 16G FC HBA claim issue
commit dcaf9aed995c2b2a49fb86bbbcfa2f92c797ab5d upstream.

Bfa driver crash is observed while pushing the firmware on to chinook
quad port card due to uninitialized bfi_image_ct2 access which gets
initialized only for CT2 ASIC based cards after request_firmware().
For quard port chinook (CT2 ASIC based), bfi_image_ct2 is not getting
initialized as there is no check for chinook PCI device ID before
request_firmware and instead bfi_image_cb is initialized as it is the
default case for card type check.

This patch includes changes to read the right firmware for quad port chinook.

Signed-off-by: Vijaya Mohan Guvva <vmohan@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-06 11:08:17 -08:00
Lee Susman ee2108e6d7 scsi: ufs: fix sector increment in ufs_long_seq_test
Currently, request sector is incremented in the long sequential test
using a calculation which assumes the device logical block size is
512B (equal to sector size) but this is not the case.
This patch changes the calculation to be correct, using the test bio size,
and assuming sector size is 512B.

Change-Id: I807be243b65834edf9201488a849777e43bb658a
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-01-29 18:29:42 +02:00
Subhash Jadavani 9ea9d2921e ufs: scsi: print the UIC or FATAL errors context
When UFS host controller encounters UIC or other FATAL errors,
driver is printing out the register dumps without any context
information (like why is this dump printed?) which makes hard
to judge the source of this dumps. This patch adds one header
message before register dumps so context is better known for
debugging.

Change-Id: I85a6d4e951bc4932464b6b7cbebce4e511c0cf5e
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-01-24 14:11:05 -08:00
Linux Build Service Account 702a591c01 Merge "scsi: ufs-msm: add PHY calibration values for UFS controller 1.1.1" 2014-01-24 03:25:09 -08:00
Linux Build Service Account bf276a04b2 Merge "scsi: ufs: disable aggressive clock gating" 2014-01-24 03:25:07 -08:00
Linux Build Service Account d16c687a1a Merge "scsi: ufs: disable LCC configuration in the UFS device" 2014-01-24 03:25:06 -08:00
Linux Build Service Account 3885ed726c Merge "scsi: ufs-msm: enable UFSHCD_BROKEN_LCC" 2014-01-24 03:25:05 -08:00
Linux Build Service Account 8aba9fd635 Merge "scsi: ufs: fix ufs error on shoutdown" 2014-01-24 03:24:53 -08:00
Dolev Raviv 55cf5fda8e scsi: ufs: fix ufs error on shoutdown
When running with a UFS controller but without a UFS device,
there are errors on shoutdown. This is because the device
state variable was not initialized before shutdown.
To solve it the device state is initialized to power off.

Change-Id: I89a9def0ed399907896d1492b7f592fc928be260
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
2014-01-23 18:46:30 +02:00
Yaniv Gardi 5e8e919e45 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>
2014-01-22 17:37:34 -08:00
Subhash Jadavani 8325bc63b9 scsi: ufs: disable aggressive clock gating
Power management with UFS host and device has multiple issues. Until
all those issues are fixed, disable the aggressive clock gating mechanism.

Change-Id: I2ab9b3b264ac526d4d7dd3ed0c9eedf4b4db6d8e
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2014-01-22 17:36:59 -08:00
Yaniv Gardi 5cc6ae3c96 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>
2014-01-22 17:36:46 -08:00
Subhash Jadavani 2d2b478548 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>
2014-01-22 17:36:38 -08:00
Subhash Jadavani 7558f4451d 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>
2014-01-22 17:36:33 -08:00
Subhash Jadavani 430841a3a0 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>
2014-01-22 17:36:14 -08:00
Lee Susman f57639a576 scsi: ufs: add long random read/write unit tests
Generalize the long_sequential_test framework to execute long random read
and long random write tests as well.
The random tests submit a large number of 4KB requests to randomly chosen
LBAs. Currently the tests are defined to read/write 64MB.

Change-Id: I9d797c0d61d863b2a9fbcd593a1be9065202ef76
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
2014-01-20 11:20:09 +02:00
Bernd Schubert af313b0319 SCSI: sd: Reduce buffer size for vpd request
commit af73623f5f10eb3832c87a169b28f7df040a875b upstream.

Somehow older areca firmware versions have issues with
scsi_get_vpd_page() and a large buffer, the firmware
seems to crash and the scsi error-handler will start endless
recovery retries.
Limiting the buf-size to 64-bytes fixes this issue with older
firmware versions (<1.49 for my controller).

Fixes a regression with areca controllers and older firmware versions
introduced by commit: 66c28f97120e8a621afd5aa7a31c4b85c547d33d

Reported-by: Nix <nix@esperi.org.uk>
Tested-by: Nix <nix@esperi.org.uk>
Signed-off-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-15 15:28:53 -08:00
Noag d0d13d58c2 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>
2014-01-15 10:52:53 +02:00
Linux Build Service Account 261b83b1fa Merge "scsi: ufs-msm: Add hba->vops->clk_scale_notify()" 2014-01-13 19:41:49 -08:00
Linux Build Service Account be29139871 Merge "scsi: ufs: Add support for clock scaling using devfreq framework" 2014-01-13 19:41:47 -08:00
Linux Build Service Account f324a46238 Merge "ARM: dts: Add freq-table-hz property for apq8084 UFS device" 2014-01-13 19:41:44 -08:00
Linux Build Service Account 23f6b299f4 Merge "scsi: ufs: add queue fullness statistics" 2014-01-13 19:40:28 -08:00
Sahitya Tummala 2bd55132a1 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>
2014-01-13 15:26:45 +05:30
Sahitya Tummala a7e17c0f1a 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>
2014-01-13 15:26:44 +05:30
Sahitya Tummala 042d759504 ARM: dts: Add freq-table-hz property for apq8084 UFS device
Add freq-table-hz propery for UFS device to keep track of
<min max> frequencies supported by UFS clocks.

Change-Id: Ie4add67cae21ef956520e9a411e5f4dad7790961
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2014-01-13 15:26:44 +05:30
Dolev Raviv 8d8b004573 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>
2014-01-12 13:51:23 +02:00
Linux Build Service Account b93e4cf645 Merge "scsi: ufs: fix crash upon reading host_regs debugfs entry" 2014-01-09 15:57:24 -08:00
Linux Build Service Account 47a16e8674 Merge "scsi: ufs-msm: fix a wrong condition when checking array size" 2014-01-09 15:55:10 -08:00
Yaniv Gardi c9ef02be60 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>
2014-01-09 13:18:55 +02:00
Raviv Shvili 0640352e75 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>
2014-01-09 10:22:16 +02:00
Subhash Jadavani 222e38a139 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>
2014-01-08 15:44:17 -08:00
Linux Build Service Account b0a19d1595 Merge "scsi: ufs: remove redundant "Illegal ufs-IOCTL" log for BLKROSET command" 2013-12-30 15:12:07 -08:00
Noag dc1b70e7f6 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>
2013-12-30 12:05:16 +02:00
Sahitya Tummala 6e6ec3f7e5 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>
2013-12-30 15:00:05 +05:30
Sahitya Tummala 9c35c51531 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>
2013-12-30 14:59:52 +05:30