A barrier request is used to control ordering of write requests without
clearing the device's cache. LLD support for barrier is optional. If LLD
doesn't support barrier, flush will be issued instead to insure logical
correctness.
To maintain this fallback flush s/w path and flags are appended.
This patch implements the necessary requests marking in order to support
the barrier feature in the block layer.
This patch implements two major changes required for the barrier support.
(1) A new flush execution-policy is added to support "ordered" requests
and a fallback , in case barrier is not supported by LLD.
(2) If there is a flush pending in the flush-queue, the received barrier
is ignored, in order not to miss a demand for an actual flush.
Change-Id: I6072d759e5c3bd983105852d81732e949da3d448
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
A barrier request is a type of flush request used to control ordering of
write requests without clearing the device's cache. LLD support for
barrier is optional. To maintain backward compatibility, barrier request
has to maintain flush s/w path and flags.
This patch introduces those flags to define interface between the block
layer and the LLD.
Change-Id: Iefa8e9a5c1b5e8256eaeb0322c435becd4669de9
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[imaund@codeaurora.org: Resolved context conflicts]
Signed-off-by: Ian Maund <imaund@codeaurora.org>
Add new flag "simple_scaling" to on demand governor so that
the clocks can be scaled up only when the load is more than
up threshold and can be scaled down only when the load is less
than down differential data as provided within
struct devfreq_simple_ondemand_data.
Change-Id: Ibc6ab6297c1b64b6e6eaaa76d735d0b9ae0f6477
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[venkatg@codeaurora.org: dereference stat variables]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
This patch adds a new flag to be used in cmd_flags field of struct request
for marking request as urgent.
Urgent request is the one that should be given priority currently handled
(regular) request by the device driver. The decision of a request urgency
is taken by the scheduler.
Change-Id: Ic20470987ef23410f1d0324f96f00578f7df8717
Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
CONFIG_PM_RUNTIME has been eliminated as of kernel 4.4 in favor of
just using CONFIG_PM, hence remove its use.
Change-Id: I096cde564c7bf2c7a041f0948617a7d74df71dd9
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
FILLER relock on error recovery may create an alignment that is not
compatible with host controller. When this issue happens, host controller
no longer detects symbols until LINE-RESET is done by host controller as
a recovery sequence. This change disables FILLER symbol relock.
Change-Id: Id7147bfb0de6be45de4936fe3429a9ad76a3868b
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Hibernate entry failures have been observed with some UFS devices.
The UFS PHY Rx termination is not disabled within the specified
RX_Min_STALL_NoConfig_Time_Capability of 15 SI. The UFS device enables
mid-termination after RX_Min_STALL_NoConfig_Time_Capability SI. The
combination of Rx terminated and device Tx mid-termination collapses
the line state to near the differential mid-point. The signal detect
may report the line state incorrectly as DIF-P. The incorrect DIF-P
moves the Rx FSM into the HS-Burst state rather than the intended
Hibern8 state. Fix this issue by setting the UFS PHY's
RX_MIN_STALL_NOCONFIG_TIME_CAPABILITY to 40.
Change-Id: I475e03686831e8131fd7ec1c30e6e8f53a6e188c
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This change updates the initialization sequence of the QRBTC-V2
phy, for msmcobalt RUMI platform.
Change-Id: I369608b41e0b150334e9a7e9ad99b7cde8341dae
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Some callbacks may not be supported which is a valid case, and should not
be considered as error.
In such cases, and in order to reduce unnecessary logs, we better
remove this error messages.
Change-Id: I75b9e02a2189a330e0ca46387394be4a8c60ef5b
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
This change updates the offsets and calibration values of the
ufs-qmp-v3 phy.
Change-Id: I443a857b7b6620a65acd14e3a805eea9c00fd61c
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
This reverts commit 6ed4bd3af2c153ae3246d89c2d62cfe7919d0320
("phy: qcom-ufs: add ufs phy type selection")
Since a single boot.img should support all phy-qcom-ufs configurations,
all phy-qcom-ufs files should be compiled all together.
Change-Id: I81b3891fb44d927046f39bbe72b5ed24dd9d99d2
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
This change adds the UFS PHY initialization table for UFS controller
version 2.2.0.
Change-Id: Ia77dec85433041e2fab3c89df10cc4727e4a47e9
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Add support for QRBTC V2 UFS PHY that is used in msmcobalt rumi platform.
Change-Id: I21ad3f0db23ea16d05ba40593cc7650e1a443702
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Add support for new QCOM UFS PHY that is used in
future platforms.
Change-Id: I53f162738668ae9f24f5edb9c42a17f947e68b40
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
This patch removes the hard-coded voltage number of vdda-phy regulator
and instead, gets it by using the appropriate API.
Change-Id: Iab753c7e94424dd3ccce95296258bba264979cf2
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Since in future UFS Phy's the tx_iface_clk and rx_iface_clk
are no longer exist, we should not fail when their initialization
fail, but rather just report with debug message.
Change-Id: I87e4deca632d4d4ee9e35a03f2fc9c22987255b3
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Hardware programming guide has updated the PHY power up sequence,
this change adds the relevant changes.
Change-Id: I320e38f501cdafc053d47bf2b21ba7f69b1b12a7
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Currently both 14nm phy and 20nm phy are compiled and built into
the kernel, while only one type is actually present and used.
Add a choice selection to the kernel configuration to specify
which phy type shall be used.
Change-Id: I5608d32fb4815db15e91a970e53099762eabbddd
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
In order to allow UFS PHY and UFS driver to be built as
kernel modules, the driver must export its functions so
they can be used by external code.
Change-Id: Ic617daf1038b5727dcd4b24a4c12a1f1bb8d730e
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: keep upstream version of EXPORT_SYMBOL_GPL]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
On some UFS PHY HW revisions, UFS PHY power up calibration sequence
requires manual VCO tuning code and its better to rely on the VCO
tuning code programmed by boot loader. This change enables the quirk
to program the manually tuned VCO code.
Change-Id: Id1bb2b28816b8de6df7ca22cda5788288b11328a
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Hardware programming guide recommends one more PHY setting as part
of UFS PHY power up sequence hence this change adds it.
Change-Id: I92f77faa6ca28d6f72d7601344b439ef7596d572
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
UFS PHY auto calibration is not working currently hence add workaround
to have manual calibrated configuration as part of power up sequence
itself. We had another workaround for hibern8 enter/exit to work and it
had required us to save the auto calibrated VCO codes after PHY power up
sequence and then set the PHY PLL in VCO bypass mode. As the auto
calibration is not working and we are already having manually calibrated
VCO codes as part of PHY power up sequence itself, this change removes the
old workaround.
Change-Id: I570ea4f7f8c2f79a06321fb43c8cb01575bf0df0
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
To power collapse UFS PHY, we need to write 0 to
UFS_PHY_POWER_DOWN_CONTROL register but instead we are writing 1 to
it. This change fixes this issue.
Change-Id: Ib12226bd3adefb2d5848aa6e7c20ae0263865148
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
UFS_PHY_RX_PWM_GEAR_BAND configuration is changed after the power up
sequence so make sure that this register gets set to power on reset value
during power up sequence. This is required in case power up sequence is
initiated after this register value got changed to value other than power
on reset value.
Change-Id: Ied8ebf6dc181da9e877427420e1ee4476f1c442f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Due to missing reset in the UFS PHY logic, the pll may not lock following
analog power collapse. As a result the common block of the PHY must be put
into reset during hibernate entry and taken out of reset during hibernate
exit. SW needs to save ave the calibrated VCO codes after the PHY power up
sequence is completed, saving these codes will save substantial time on
hibernate exit (<50us vs. 1.7ms).
Change-Id: Id5f5eab04f1a1f93179cf9e5cdd3c7c8be4b17af
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
UFS PHY power up calibration sequence on UFS controller revision 2.0.0
can't have SVS mode configuration otherwise calibration result cannot
be used in HS-G3. So there are additional register writes must be done
after the PHY is initialized but before the controller requests
hibernate exit. Also as this issue is not present on UFS controller
revision 2.1.0, SVS mode configuration registers are written as part
of the power up calibration sequence itself. This change takes care
of these issues related to SVS mode.
Change-Id: Ib431d98345224db13f1d68197e948bb077c95080
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts,
drop include/linux/phy/phy-qcom-ufs.h]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
As there is no support for UFS in APQ8084 under kernel 3.14, we also
can remove the support for 28nm ufs phy (since APQ8084 is the only
platform that uses this phy).
Change-Id: Iae76f98424842cc29e9397c0050a37a010509bcc
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
In some cases link startup fails due to unexpected
termination caused by DIF-N to DIF-Z transition.
This patch will make PHY look only for DIF-N -> DIF-P
transition and not respond to DIF-N to DIF-Z transition.
Hence prevents a case where DIF-Z is identified as
DIF-P, which may result in unexpected LCC interpretation
and PHY switch to HS.
Change-Id: Ia79fceb245516b96f84d8511e983187e09db254a
Signed-off-by: Maya Erez <merez@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Link startup or hibern8 may fail sometimes if analog bias is not on.
To ensure the stability of link startup and hibern8 enter/exit,
this change adds the UFS phy configuration change to keep the analog bias
on.
Change-Id: I22202ee018cb222facbfda87110b83a328d71288
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
UFS device's phy ref_clk is sourced via MSM's ref_clk pad. This pad is
having its own power domain which is powered by 1.2v rail. This change
adds the voting support for this pad rail.
Change-Id: I179b2b9bb7ef2e7938ba0aaa87faed09cdad6139
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: dropped ufs-qcom.h and
include/linux/phy/phy-qcom-ufs.h changes]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
On some chipsets, "ref_clk_parent" clock is not required for the UFS PHY
ref_clk activation hence change this property as optional.
Change-Id: I487fa7c4da7e64e3fb4d0321cc8296dca5091eb3
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[gbroner@codeaurora.org: fix minor conflicts]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Different UFS PHY versions may have different calibration values to some
of the registers.
This change introduces the new calibration values necessary for new
version of UFS 20nm PHY
Change-Id: Ie0522c7293944e3f434fdfe56c82b98d8f5e7994
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Since PHY calibration values for Rate B override those of rate A, it's
unnecessary to have duplicate values.
This patch removes all the redundant values to optimize calibration
sequence
Change-Id: I60638e02292255e3308ea82aa75baa9abde86614
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
scsi.h reference 'struct device', the definition for which is not
included. Most users of this header compile because struct device
happens to be defined before scsi.h is included. Less-fortunate
drivers encounter:
linux/include/scsi/scsi.h:565:49: warning: 'struct device'
declared inside parameter list
Change-Id: I6352b0fc1d1ab296e500f6007b0b20be3b85a1f9
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
The ioctl information should be in header files that expose it
to userspace.
Change-Id: Iabf1e53a1357c2ce22ecdc8dc0270377759effc8
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
The scsi ioctl related files are meant to be used from
userspace and hence should be in the appropriate include/uapi
directory.
Change-Id: Id6b14f353284a9ddac0d58b6b90e17561e2645aa
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
->check_events() callback sends the Test Unit Ready command to check if
underlying media state has changed or not, this is generally not required
for embedded storage media (such as UFS). We have seen race between Test
Unit Ready command and runtime suspend context which basically can put
the Test Unit Ready command at the head of the request queue when queue's
rpm_status is SUSPENDING. In this case, scsi_request_fn will not pull in
the Test Unit Ready command as REQ_PM flag is not set for it. This
basically causes the deadlock situation. Currently there is no better way
to fix this error other than removing the check_events() callback which is
anyway not required for embedded storage like UFS.
Change-Id: Idac374ba1674fede38cb3dcfc2c1f8d3db234d1d
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
scsi disk driver probe first calls the PM runtime get before actually
allocating the scsi disk structure and if the PM runtime status was set
to suspended at this time then it will trigger scsi disk driver's
resume callback. But scsi disk driver's resume callback assumes that
scsi disk structure is always available when it is called but that's not
true always. Fix this issue by skipping the scsi disk resume if scsi disk
structure isn't allocated.
Change-Id: Ica920b1e07976140dc29847f4dc61aac9fa402ae
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
There are many informational log messages printed during the LUN detection
and while binding the scsi device with upper level driver. Most of these
messages are KERN_NOTICE level and hence would show up on serial console.
In fact, as we are using the dev_printk() APIs even KERN_DEBUG level
messages are ending up on console. This patch removes most of these
informational log messages to reduce the load on serial console during
boot up.
Change-Id: I332b71f529e04039645d1f41783395da8abc7f0b
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
If scsi device is not runtime suspended while system resumes then
scsi device's runtime PM status gets changed to RPM_ACTIVE (if its
parent status is already set to RPM_ACTIVE) by the scsi system resume
callback. But if the scsi device's runtime PM is managed by block layer
then runtime status of scsi device's request queue might still remain
in RPM_SUSPENDED hence all the new block requests submitted to the
request queue will have to wait until the queue runtime status gets
changed to RPM_ACTIVE which never happens as scsi device status is
already marked RPM_ACTIVE.
Fix this problem by changing the request queue runtime status to
RPM_ACTIVE when scsi device runtime status changes to RPM_ACTIVE.
Change-Id: I310cf8f1d7f13008b0ab9d87564fc0ac4d2e2314
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
We are seeing deadlock in scsi runtime resume context, here is the
call trace:
__switch_to+0x70/0x7c
__schedule+0x4e0/0x734
schedule+0x70/0x7c
__pm_runtime_barrier+0xdc/0x108
__pm_runtime_disable+0x60/0xf4
scsi_dev_type_resume+0x74/0xb4
scsi_runtime_resume+0x5c/0xbc
__rpm_callback+0x3c/0x74
rpm_callback+0x60/0x84
rpm_resume+0x368/0x47c
__pm_runtime_resume+0x6c/0x94
scsi_autopm_get_device+0x28/0x60
sg_open+0x148/0x5c0
chrdev_open+0x134/0x16c
do_dentry_open+0x260/0x2dc
vfs_open+0x3c/0x48
do_last+0x844/0xae8
path_openat+0x220/0x5c4
do_filp_open+0x2c/0x80
do_sys_open+0x160/0x1fc
SyS_openat+0xc/0x18
It seems commit 3c31b52f96 ("scsi: async sd resume") has introduced a bug
where runtime resume (for scsi devices not managed by upper level driver)
context end up calling pm_runtime_disable() which waits for the runtime
resume to finish and hence causing the deadlock. This change fixes this
issue by making sure that we don't call pm_runtime_disable() if we are
in runtime PM context.
Change-Id: I770060c062ee828ef9117b8e5a4c248f48381f35
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
When user space application opens any scsi generic device node (/dev/sg*),
we will have following call stack:
-> sg_open()
-> scsi_autopm_get_device()
-> pm_runtime_get_sync()
-> scsi_runtime_resume()
-> sdev_runtime_resume()
-> blk_post_runtime_resume()
The request queue device pointer (q->dev) is deferenced but it is NULL.
q->dev is assigned when blk_pm_runtime_init() is called which only takes
place for sd/sr type scsi devices.
SCSI generic driver handles runtime PM get/put on its instead of block
layer handling it. We can move the runtime PM get/put responsibility to
block layer only if all the requests handled by sg driver are getting
inserted to block layer request queue but this is not always true.
For example, if LLD ioctl is issued via scsi generic ioctl then it may
not get converted to block layer request (and hence doesn't get inserted
into block layer request queue) and this may put us in situation where
LLD driver handler the ioctl when it's runtime suspended.
Better solution would be to let the sg driver manage its own runtime PM
get/sync operations and fix the broken scsi_runtime_suspend and
scsi_runtime_resume callbacks to handle SCSI devices which do not have
upper layer driver (like SCSI disk).
Change-Id: I1cae7f992f21a1c420d38c275a817d06baa8923d
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: fixed the compilation failure]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Until now the scsi mid-layer forbids runtime suspend till userspace
enables it. This is mainly to quarantine some disks with broken
runtime power management or have high latencies executing suspend
resume callbacks. If the userspace doesn't enable the runtime suspend
the underlying hardware will be always on even when it is not doing
any useful work and thus wasting power.
Some low-level drivers for the controllers can efficiently use runtime
power management to reduce power consumption and improve battery life.
Allow runtime suspend parameters override within the LLD itself
instead of waiting for userspace to control the power management.
Change-Id: I03e96a89d19c174deeb5bd4f94136c77073eb009
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Generally driver should be silent during the normal operation of the device
hence this change reduces the logs level for suspend/resume messages from
KERN_NOTICE to KERN_DEBUG.
Change-Id: I154fb7c759aa35ed32ea451729083c93fc385c11
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[mattw@codeaurora.org: resolved trivial context conflicts]
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
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>