Host sends MODE_SENSE_10 with caching mode page, to check if the device
supports the cache feature.
Some LLD standards requires DBD field to be set to 1.
This patch allows LLD to define the setting of DBD if required.
Change-Id: I7f6c0ff6613516c3ef49aacc0679b96b8bd9ccc8
Signed-off-by: Maya Erez <merez@codeaurora.org>
[mattw@codeaurora.org: resolved a trivial context conflict in
Scsi_Host struct definition]
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
"Hibern8 on idle" and "Clock gating on idle" features can be turned
on/off selectively which means their state information is only important
if that particular feature is enabled. This change makes sure that we only
look at state of these features if feature itself is enabled.
Change-Id: I25ef3d9dd60e69afe3f2d9dce602ae48f1b4a044
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
The maximum value PA_SaveConfigTime is 250 (10us) but this is not enough
for some vendors. Gear switch from PWM to HS may fail even with this max.
PA_SaveConfigTime. Gear switch can be issued by host controller as an
error recovery and any software delay will not help on this case so we
need to increase PA_SaveConfigTime to >32us as per vendor recommendation.
This change adds a quirk to increase the PA_SaveConfigTime parameter.
Change-Id: I02a0394bb07f165ba8ae6c5802567cc6d8ad0d16
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
UFS compat_ioctl(ufshcd_ioctl) should return -ENOIOCTLCMD for unsupported
IOCTLs so that the IOCTLs can fall back to higher layer.
Change-Id: If6137edd84d38c264555aa2d00ba3a1cab32edb5
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
ufs_qcom_ice_req_setup() function might access the uninitialized pointers,
this change makes sure that there are no null pointer accesses.
Change-Id: I83c3e2f015a474d5eba6ddaeeaa860e79717760f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
UFS specification has been updated and crypto operations
were added. Update the UFS driver code with the new registers
and sequences to facilitate future usage.
Change-Id: I020870f628977c3ebad6cc0afaef3cb1cdd15063
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
* Removed spinlock as it was not locking against anything
* Removed conversion of interrupt status to error number
as it is not used by API client, and in case several bits are
set only 1 error is ever handled and the rest get lost.
Instead pass to the client the complete status.
* Removed redundant includes, variables
* vops structure is returned after performing a lookup in the DTS.
There's no need for that as we already know the structure
to return.
* Other minor corrections
Change-Id: I6d2549ce04c9e4b19fdd8fe3dfee03d83bfd9d77
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: dropped ice driver and mmc ice changes]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Some UFS devices require host PA_TACTIVATE to be higher than
device PA_TACTIVATE otherwise it may get stuck during hibern8 sequence.
This change allows this by using quirk.
Change-Id: Iee1ee7a3e435b34a9e5cca3f5cff3a9b5c36fe1b
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
ICE init & reset can be synchronous now because ICE does not need
to go to secure side for any ICE configuration. This would simplify
interface and make call more efficient.
Change-Id: I7aa4e2d3ba3383d25758b21b8ae261a0220f35f9
Signed-off-by: Dinesh K Garg <dineshg@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: dropped ice driver and mmc ice changes]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Current code does not actually handle ICE errors as the
relevant quirk is not set. Also, ICE errors are checked
only if some host controller error occurred.
Removed the quirk and fixed the check for ICE errors.
Also, removed redundant API crypto_engine_get_err()
and crypto_engine_reset_err().
Change-Id: Ic7f4e9a2cd3771f1f52dff97b2be90d12e32d2e5
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: dropped msm/ice.c changes]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Add support for compat ioctl so that 32-bit application can
access the UFS ioctl calls on 64-bit kernel.
Change-Id: Id4793bea84405adc7d692d6cf6f2265d1e491c28
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
"bBootLunEn" attribute value decides the active Boot LUN but there could
be a case where userspace may want to change it during image update.
This change allows writing to this parameter.
Change-Id: I6e8d630606d8caf6197ef662003ec1ee646afe81
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
from include/linux/kobject.h:21:0,
from include/linux/device.h:17,
from include/linux/devfreq.h:16,
from drivers/scsi/ufs/ufshcd.c:42:
drivers/scsi/ufs/ufshcd.c:
In function 'ufshcd_init_clk_gating':
drivers/scsi/ufs/ufshcd.c:1548:19:
error: 'clk_gating' undeclared (first use in this function)
sysfs_attr_init(&clk_gating->enable_attr.attr);
Change-Id: Ie61be8bc4472cf8960dc0afc3e0683c761ea177e
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
In the old code, there is no way to "disable" the already enabled
error scenarios since the operator in use is a bit-wise OR operator.
This change fixes this issue. Now, the new value overwrites the previous
value so it's possible to disable all error scenarios by:
echo 0 > /d/ufshcd0/err_inj_scenario
Change-Id: I21eadb3345f6587edf5232ea3c03702bfdb930ad
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
The condition in which error message is printed out was incorrect and
resulted error message only if retries exhausted.
But retries happens only if DME command is a peer command, and thus
DME commands which are not peer commands and fail are not printed out.
This change fixes this issue.
Change-Id: I43367befd810da0ebe34efd3a93751b582a19565
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
There is an inconsistency between the actual power mode of the
UFS controller (and UFS device), to the power mode informed to upper
layers in case an error is injected during ERR_INJECT_PWR_CHANGE
scenario. Meaning, power change error is reported although the power
mode has actually changed successfully in the controller and in the
device. This change fixes this inconsistency.
Also, this change fixes a bug where a pointer to u8 is sent as
a pointer to int, which results undesired behavior.
Also, this change removes unused error injection scenarios:
- ERR_INJECT_HIBERN8_ENTER
- ERR_INJECT_HIBERN8_EXIT
Change-Id: I14116656862e3db8f5d6a93b5c798a1470a6b716
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
The removed condition is already checked inside the routine
ufshcd_change_power_mode().
Also, a minor typo is fixed.
Change-Id: Ib238ff9c4bdcd380406505d5319bd2d6c0ed6063
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
In case UFS driver is probed before the phy driver does, the
UFS driver should return a PROBE_DEFER code.
Change-Id: I94ab353fed35889b92fb2f0baf5ee029894b999b
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
This change fixes the signature of the routine
ufshcd_vops_clk_scale_notify() and the callback clk_scale_notify
to receive enum ufs_notify_change_status instead of bool as their 3rd
parameter.
Change-Id: I8463f4f5f0a77bcbc3b0bcdfd05d1a02e334dc8e
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
This change fixes a bug where we check the select_minor value
instead of checking the select_major value.
Change-Id: I852944215a0be484449b578be09b46095fb01931
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
err_inj_scenario debugfs entry used to be a u32 entity.
This change modifies it to be a file entity, so reading it
(cat /d/.../err_inj_scenario) helps the user get useful information
about the enabled/disabled error scenarios.
Change-Id: Ia805e6f5357009752ddcace3ae4ed87061e48759
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
We shouldn't be accessing scsi command's "request" structure after calling
scsi_done callback but it seems pm qos unvoting code path is accessing
this request structure even after caling the scsi_done callback. Fix this
by releasing the pm qos vote before calling scsi_done.
Change-Id: I5c8dd6ba7f0b619397924d73c1fd6c36fe86ebc1
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This change removes error scenario use-cases that have not been
implemented yet, and one error scenario (ERR_INJECT_LINK_STARTUP)
that anyway is not recoverable.
Change-Id: I78948f64ee3868333ec27e17695980b642248dcf
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
In order to simplify working with error injection feature,
and since the capability of controlling error codes per error scenario
has not been useful in debugging phase of the driver, it's decided
to remove this feature.
Now, the error injection framework randomly choose an error code from
a list of error codes available per error scenario.
Change-Id: Iee34b2aa99321f5f51190f26da364c9c129a3f77
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Query commands have 100ms timeout and it may timeout if they are
issued in parallel to ongoing read/write SCSI commands, this change
adds the retry (max: 10) in case command timeouts.
Change-Id: If60e2dd85614c8e383018b1286a625a5e53f872f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
UFS core driver may power collapse the UFS host controller during clock
gating hence we might loose some of the ICE register configuration.
In order to restore ICE register configuration, we should call ICE
driver's resume callback after ungating UFS clocks.
Change-Id: I722a8037d81222c2cd493ebbe608a106f47cedfd
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Currently we have the same gating timeout for both high load and
low load condition but having the different timeouts would help
to save power in low load condition and increase performance
in high load condition. This change also adds support to tune
these timeouts via sysfs.
Change-Id: I0ac79042d0fd0cd6a6a917ebe3b52db2a1abd0b9
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This change enables the aggressive clock gating along with hibern8 at
every 10ms. As hibern8 enter was already @10ms, we are now merging it
with clock gating which will also be @10ms after this change. This change
is needed to save power for real life usecases.
Change-Id: I297d0f7d1c379f0b402298dc5dddd92ac33f6f25
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Currently we are suspending clock scaling during clock gating which doesn't
allow us to have clock gating timeout lower than clock scaling polling
window. If clock gating timeout is smaller than the clock scaling polling
window then we will mostly suspend the clock scaling before clock scaling
polling window expires and we might get stuck in same state (scaled down
or scaled up) for quite a long time. And for this reason, we have clock
gating timeout (50ms) greater than clock scaling polling window (40ms).
We would like to have aggressive clock gating timeout even lower than the
clock scaling polling window hence this change is decoupling the clock
scaling suspend/resume from clock gate/ungate. We will not suspend the
clock scaling as part of clock gating instead clock scaling context will
schedule scaling suspend work if there are no more pending transfer
requests.
Change-Id: I7c1e7580c63bbbfbad551d17921774afa3d95ca6
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Currently we call the scsi_block_requests()/scsi_unblock_requests()
whenever we want to block/unblock scsi requests but as there is no
reference counting, nesting of these calls could leave us in undesired
state sometime. Consider following call flow sequence:
1. func1() calls scsi_block_requests() but calls func2() before
calling scsi_unblock_requests()
2. func2() calls scsi_block_requests()
3. func2() calls scsi_unblock_requests()
4. func1() calls scsi_unblock_requests()
As there is no reference counting, we will have scsi requests unblocked
after #3 instead of it to be unblocked only after #4. Though we may not
have failures seen with this, we might run into some failures in future.
Better solution would be to fix this by adding reference counting.
Change-Id: I1eaa39c0716cf41120269cf389ebb322e3006da1
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Enabling & disabling host PHY ref_clk generally may have high latencies
hence don't disable them during aggresive clock gating otherwise it could
affect the UFS performance badly.
Change-Id: I1741c75a6295c7c0b0d77ff578ab977213dcc484
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
It is quite possible that we might need multiple clocks to be enabled when
UFS transfers are active and we generally turn these clocks off during
runtime & system suspend. In addition, we also vote these clocks off if
aggressive clock gating feature is enabled. Idle timeout for aggressive
clock gating feature is generally ~50 milliseconds. But turning these
clocks on/off could have huge latencies hence we might only want to turn
off few essential (and low latency) clocks during aggressive clock gating.
This change adds support to let the vendor specific setup_clocks callback
know whether it is called from aggressive clock gating context or normal
clock gating context. Having this context information should help vendor
specific setup_clocks callback to selectively disable clocks.
Change-Id: I5e1523a57bc45a91faef463baac1cea2a2c8d2d6
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Voting/devoting device ref_clk source could be time consuming hence add
support to allow ufs variant to decide if it wants to control ref_clk
during aggressive clock gating or not. This clock should still be gated
off during runtime/system suspend.
Change-Id: Ibec8cc8b3689ff4e2418039e74dbf311e589157e
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Currently we power collapse UFS controller core only during runtime suspend
but we could also power collapse it during clock gating as power collapse
latencies are only few microseconds. This change adds this aggressive power
collapse to save power.
Change-Id: Id550bcbcd044670cec08a6abb7225cb9386993b5
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Some platforms don't support restoring the secure configuration as
secure configuration can never be lost hence scm_restore_sec_cfg() is
expected to be failed for such platforms. This change changes the
failure message level from error to debug.
Change-Id: Ie4b96971d5c4c394576a78444fe5013749375c28
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
If we had called the pm_qos_add_request() with PM QoS request type set to
PM_QOS_REQ_AFFINE_IRQ then freeing up the irq makes the free_irq() to
print out warning with call stack. We don't really need to free up irq
during suspend, disabling it during suspend and reenabling it during
resume should be good enough and that's how it was done on 3.10 kernel
as well.
Change-Id: I58379a05e1f9d5f18b46394d64bdf6f106afa963
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
UFS device ref_clk frequency is set during the one time provisioning,
UFS driver just queries the reference clock frequency from device and
prints it out for informational purpose. Although this seems redundant
as incorrect reference clock frequency would anyway be detected during
bootup phase itself. This patch removes this redundant query and in turn
removes one message from going to serial console.
Change-Id: Id6a4d6d84b05f4b07b5299fd90e78e793e9689dc
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Add debug-fs entry to show current state of UFS PM QoS.
Change-Id: Ic1ae582b5a657f332be8a6f8d3bbcc0434bdf3d3
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Add sys-fs entries to allow user space control PM QoS
latency parameters and enable/disable PM QoS voting.
The entries are added under:
/sys/bus/platform/devices/624000.ufshc/624000.ufshc:ufs_variant/
pm_qos_enable:
write 0 to disable PM QoS, 1 to enable.
Example: "echo 1 > pm_qos_enable"
pm_qos_latency_us:
write the desired value for each cpu group, separated by a comma.
Example: "echo 10,20 > pm_qos_latency_us"
Change-Id: I9797a1e62c4867ab831b4f18cbb1e0ca9834247b
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Current UFS PM QoS design and implementation do not seem to give
the desired increase in performance. This change revisits the
PM QoS implementation trying to improve performance by making
the following changes:
* de-couple voting from clock scaling decision so voting
occurs from the first request and unvoting on the completion
of the last request regardless to clock scaling state.
Otherwise, suspending the PM QoS voting during the time it takes
to decide on clock up-scaling, seems to degrade random access
performance.
* vote on a per-cluster basis by inspecting the request object's
cpu field. This follows the soft-irq allocation scheme in the
block layer, so the cpu to which the block layer schedules the
soft-irq will not be put into deep LPM.
We should note that PM QoS voting using cpu mask for specific
cpus is a feature of the qcom specific PM QoS implementation.
Change-Id: I427d202aeb45cd284a3bb128e26e519212614801
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
[venkatg@codeaurora.org: resolved merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
The new UFS Controller (version 3.0.0) has a few changes compared to
previous versions, such as a new vendor specific register, and
different debug register offsets.
Change-Id: Idf455d2dcbdcdadcb1e809a8349fc9adbe9733dd
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Some platforms do not enable the BUS_SCALING feature.
For such cases, we should wrap the routines that use this feature
with a configuration flag.
Change-Id: Iced5b6492a470eb5700b50a50de8260b6bb59753
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
The UFS HCI v2.1 includes a few additional registers. This change
updates the HCI register, the UFS version register content and
the Interrupt Status register.
Change-Id: Icfeef0e6aaed064b456fac1cd5531fff1328ae37
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
When we are resuming the UFS device rails in HPM mode, we are first
powering on the VCC rail while VCCQ and VCCQ2 rails still being in LPM
mode. Some UFS devices may take VCC on event as hint that host wants
UFS device to be resumed and may start drawing more power from the
VCCQ/VCCQ2 rails (while they are still in LPM mode) causing voltage drop
on these rails. This change fixes this issue by bringing VCCQ & VCCQ2 rails
out of LPM before powering on VCC rail.
Change-Id: I950591d2a571257e08d7697e2b33dd5968f7333f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This patch splits the vops by type and creates wrapper
functions for all vops.
Used in order clarify the runtime code and to allow
further types of vops.
This is the first step towards rearchitecting the
variant implementation of the UFS driver - per requirement
from the community. As this will become a full-blown
rearchitecture - incrementing the driver version.
Change-Id: Ifd0a5412a608590bc6c761caf0b3a87aed37f70b
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[venkatg@codeaurora.org: resolved merge conflicts,
change ufshcd_pltfrm_init to use ufs_hba_variant
instead of ufs_hba_variant_ops]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Adds setter/getter functions to set/get a pointer
to the variant control structure in/from the generic
hba control structure.
Change-Id: I4c7b3967366f394472490410e3880fdc6e3608b4
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
[venkatg@codeaurora.org: use ufshcd_set_variant instead of
ufshcd_bind_variant]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
When compiling with gcc5, it throws below errors:
drivers/scsi/ufs/ufs-qcom.c: In function 'ufs_qcom_hce_enable_notify':
drivers/scsi/ufs/ufs-qcom.c:352:10: warning: switch condition has boolean
value [-Wswitch-bool] error, forbidden warning: ufs-qcom.c:352
This is because we are using the boolean value in switch condition and it
seems to be forbidden by compiler (by default). Fix this by using the
proper enum type instead of boolean.
Change-Id: Iee6950e5986dc51afbf9440cd4773b4d0f02fcdc
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>