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>
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>
"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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
In this change a global variable which is never referenced is being
removed.
Change-Id: I2eda5157cf5e77e61d776d450cb036ca51027a08
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
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>
* 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>
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>
In this change there is a fix of a possible NULL pointer access.
Change-Id: Ibc5031f7ccb8b0efda65453b3899a23abfce94c5
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
In this change there is a fix of a possible NULL pointer access.
Change-Id: I4c6d4020d914a24b88153641db24519a2c36e4b0
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
[ 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>
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>
* 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Allow reading descriptors with length which is different
than the descriptors max size.
Change-Id: Ia0685ae147883f33466865d2348d71473e0d5173
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
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>
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>
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>
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>
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>
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>
Moves bus scaling code to architecture independant directory
for platform drivers.
Change-Id: Ie0d5b104882d1534fae262af85e99cc09a56ab04
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This change fixes a wrong condition that results a false error message
Change-Id: Iacb9224eaa908c0eec612fe3570b38ada3f90b37
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
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>
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>
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>
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>
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>