Commit Graph

983983 Commits

Author SHA1 Message Date
Adrian Hunter
6c3a0cbbe8 UPSTREAM: scsi: ufs: ufs-debugfs: Add user-defined exception_event_mask
Allow users to enable specific exception events via debugfs.

The bits enabled by the driver ee_drv_ctrl are separated from the bits
enabled by the user ee_usr_ctrl. The control mask ee_mask_ctrl is the
logical-or of those two. A mutex is needed to ensure that the masks match
what was written to the device.

Link: https://lore.kernel.org/r/20210209062437.6954-4-adrian.hunter@intel.com
Acked-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit cd46947561)
Bug: 204438323
Change-Id: I80ae782813983c9637d09625b4e9501e854f1090
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:27 -07:00
Adrian Hunter
2f645969bf UPSTREAM: scsi: ufs: Add exception event definitions
For readability and completeness, add exception event definitions.

Link: https://lore.kernel.org/r/20210209062437.6954-3-adrian.hunter@intel.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 37b97b1870)
Bug: 204438323
Change-Id: I40e434a0c25a8953c140d0d933dc97739404ffa4
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:27 -07:00
Adrian Hunter
37ce54fa1f UPSTREAM: scsi: ufs: Add exception event tracepoint
Currently, exception event status can be read from wExceptionEventStatus
attribute (sysfs file attributes/exception_event_status under the UFS host
controller device directory). Polling that attribute to track UFS exception
events is impractical, so add a tracepoint to track exception events for
testing and debugging purposes.

Note, by the time the exception event status is read, the exception event
may have cleared, so the value can be zero - see example below.

Note also, only enabled exception events can be reported. A subsequent
patch adds the ability for users to enable selected exception events via
debugfs.

Example with driver instrumented to enable all exception events:

  # echo 1 > /sys/kernel/debug/tracing/events/ufs/ufshcd_exception_event/enable

  ... do some I/O ...

  # cat /sys/kernel/debug/tracing/trace
  # tracer: nop
  #
  # entries-in-buffer/entries-written: 3/3   #P:5
  #
  #                                _-----=> irqs-off
  #                               / _----=> need-resched
  #                              | / _---=> hardirq/softirq
  #                              || / _--=> preempt-depth
  #                              ||| /     delay
  #           TASK-PID     CPU#  ||||   TIMESTAMP  FUNCTION
  #              | |         |   ||||      |         |
       kworker/2:2-173     [002] ....   731.486419: ufshcd_exception_event: 0000:00:12.5: status 0x0
       kworker/2:2-173     [002] ....   732.608918: ufshcd_exception_event: 0000:00:12.5: status 0x4
       kworker/2:2-173     [002] ....   732.609312: ufshcd_exception_event: 0000:00:12.5: status 0x4

Link: https://lore.kernel.org/r/20210209062437.6954-2-adrian.hunter@intel.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit f7733625ec)
Bug: 204438323
Change-Id: Iebc00a8d240713a2e58753c5f11382159172864b
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:26 -07:00
DooHyun Hwang
6636ec454a UPSTREAM: scsi: ufs: Print the counter of each event history
Print event counter after dumping the event history.

Link: https://lore.kernel.org/r/20210203101443.28934-1-dh0421.hwang@samsung.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: DooHyun Hwang <dh0421.hwang@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit bafd09f8d8)
Bug: 204438323
Change-Id: Ic03a2b5e9d7a0417faca2193089d1cab4d441f6e
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:26 -07:00
Bean Huo
71121c3c33 UPSTREAM: scsi: ufs: Cleanup WB buffer flush toggle implementation
Delete ufshcd_wb_buf_flush_enable() and ufshcd_wb_buf_flush_disable(). Move
the implementation into ufshcd_wb_toggle_flush().

Link: https://lore.kernel.org/r/20210121185736.12471-1-huobean@gmail.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit d3ba622db8)
Bug: 204438323
Change-Id: I1e57d9c6d6c38646d9da01da5ebb244f132d73f0
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:26 -07:00
Hannes Reinecke
0d81d06069 UPSTREAM: scsi: ufs: ufshcd: Do not set COMMAND_COMPLETE
COMMAND_COMPLETE is defined as '0', so setting it is quite pointless.

Link: https://lore.kernel.org/r/20210113090500.129644-24-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit db83d8a5c8)
Bug: 204438323
Change-Id: I9eb11ac47769a031e7cd038165408db2fac30f7f
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:26 -07:00
Bean Huo
0b0e88f6c9 UPSTREAM: scsi: ufs: Group UFS WB related flags in struct ufs_dev_info
UFS device-related flags should be grouped in ufs_dev_info. Move wb_enabled
and wb_buf_flush_enabled out from struct ufs_hba, group them in struct
ufs_dev_info, and align the names of the structure members vertically.

Link: https://lore.kernel.org/r/20210119163847.20165-6-huobean@gmail.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Acked-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 4cd4899564)
Bug: 204438323
Change-Id: Id1e22017c9cc6ebc7fc5e1436767afde3f8b1575
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:26 -07:00
Bean Huo
40c9f64cce UPSTREAM: scsi: ufs: Remove two WB related fields from struct ufs_dev_info
d_wb_alloc_units and d_ext_ufs_feature_sup are only used during WB probe.
They are used to confirm the condition that "if bWriteBoosterBufferType
is set to 01h but dNumSharedWriteBoosterBufferAllocUnits is set to zero,
the WriteBooster feature is disabled", and if UFS device supports WB.

No need to keep them after probing is complete.

Link: https://lore.kernel.org/r/20210119163847.20165-5-huobean@gmail.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit e8d0381394)
Bug: 204438323
Change-Id: I0b48095db5d342b6bd57d8e3e27978d337292a48
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:26 -07:00
Bean Huo
2e2448cd34 UPSTREAM: scsi: ufs: Update comment in the function ufshcd_wb_probe()
USFHCD supports both WriteBooster "LU dedicated buffer" mode and "shared
buffer" mode. Update the comment accordingly in the function
ufshcd_wb_probe().

Link: https://lore.kernel.org/r/20210119163847.20165-4-huobean@gmail.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit ae1ce1fc61)
Bug: 204438323
Change-Id: Ie812740fca47d92cbf62b5888ab902a30cf9c61f
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:26 -07:00
Bean Huo
b59267e60b UPSTREAM: scsi: ufs: Add "wb_on" sysfs node to control WB on/off
Currently UFS WriteBooster driver uses clock scaling up/down to set WB
on/off. For the platforms which don't support UFSHCD_CAP_CLK_SCALING, WB
will be always on. Provide a sysfs attribute to enable/disable WB during
runtime. Write 1/0 to "wb_on" sysfs node to enable/disable UFS WB.

Link: https://lore.kernel.org/r/20210119163847.20165-2-huobean@gmail.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 8e834ca551)
Bug: 204438323
Change-Id: I2f57a56adddf94b7e7e5ddad926a8305668adf86
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:25 -07:00
Bean Huo
d7024c2790 UPSTREAM: scsi: ufs: Delete redundant if statement in ufshcd_intr()
Once going into while-do loop, intr_status is already true, this
if-statement is redundant, remove it.

Link: https://lore.kernel.org/r/20210118201233.3043-1-huobean@gmail.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 60ec37555d)
Bug: 204438323
Change-Id: I78fe0abceea923544bb190223217a4d2fb75ac52
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:25 -07:00
Bart Van Assche
69b48f79e6 ANDROID: scsi: ufs: Protect PM ops and err_handler from user access through sysfs
Commit 3a3b24ef29 ("BACKPORT: FROMGIT: scsi: ufs: Protect PM ops and
err_handler from user access through sysfs") applied most of the
upstream commit 9cd20d3f47 ("scsi: ufs: Protect PM ops and err_handler
from user access through sysfs") but not all of it. Backport the
remaining changes to Android.

Bug: 204438323
Change-Id: Iab8276ea4259f6ea821db9542e2580b304b7fb92
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:25 -07:00
Bean Huo
77de4fc3c1 UPSTREAM: scsi: ufs: Remove unnecessary devm_kfree()
The memory allocated with devm_kzalloc() is freed automatically no need to
explicitly call devm_kfree(). Delete it and save some instruction cycles.

Link: https://lore.kernel.org/r/20210112092128.19295-1-huobean@gmail.com
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit b64750a1b6)
Bug: 204438323
Change-Id: I05096acb5bd2872270e531cd6803ebcc9f35bd30
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:25 -07:00
Avri Altman
e9ca328c8c UPSTREAM: scsi: ufs: A tad optimization in query upiu trace
Remove a redundant if clause in ufshcd_add_query_upiu_trace.

Link: https://lore.kernel.org/r/20210110084618.189371-1-avri.altman@wdc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit fb475b74d6)
Bug: 204438323
Change-Id: Id1968a12559b5205cdc7674f1ac536c1d085a440
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:25 -07:00
Randy Dunlap
54748dbb28 UPSTREAM: scsi: ufs: Fix all Kconfig help text indentation
Use consistent and expected indentation for all Kconfig text.

Link: https://lore.kernel.org/r/20210106205554.18082-1-rdunlap@infradead.org
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: linux-scsi@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit aaac0ea983)
Bug: 204438323
Change-Id: I707f7bc68b40f301b9c83e2596f584ebf4565414
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:25 -07:00
Bean Huo
fcc5df2481 UPSTREAM: scsi: ufs: Make UPIU trace easier differentiate among CDB, OSF, and TM
Transaction Specific Fields (TSF) in the UPIU package could be CDB
(SCSI/UFS Command Descriptor Block), OSF (Opcode Specific Field), and TM
I/O parameter (Task Management Input/Output Parameter). But, currently, we
take all of these as CDB in the UPIU trace. Thus makes user confuse among
CDB, OSF, and TM message. So fix it with this patch.

Link: https://lore.kernel.org/r/20210105113446.16027-7-huobean@gmail.com
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 867fdc2d6e)
Bug: 204438323
Change-Id: I0a58393c5febba32d174a554a568fd00abbbc9fb
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:25 -07:00
Bean Huo
08ef43477b UPSTREAM: scsi: ufs: Distinguish between TM request UPIU and response UPIU in TM UPIU trace
Distinguish between TM request UPIU and response UPIU in TM UPIU trace, for
the TM response, let TM UPIU trace print its TM response UPIU.

Link: https://lore.kernel.org/r/20210105113446.16027-6-huobean@gmail.com
Acked-by: Avri Altman <avri.altman@wdc.com>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 0ed083e916)
Bug: 204438323
Change-Id: I04a22f8ff90f11d938e43570d49f69391f9bd9ed
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:24 -07:00
Bean Huo
db02af8d32 UPSTREAM: scsi: ufs: Distinguish between query REQ and query RSP in query trace
Currently, in the query completion trace print, since we use
hba->lrb[tag].ucd_req_ptr and didn't differentiate UPIU between request and
response, thus header and transaction-specific field in UPIU printed by
query trace are identical. This is not very practical. As below:

query_send: HDR:16 00 00 0e 00 81 00 00 00 00 00 00, CDB:06 0e 03 00 00 00 00 00 00 00 00 00 00 00 00 00
query_complete: HDR:16 00 00 0e 00 81 00 00 00 00 00 00, CDB:06 0e 03 00 00 00 00 00 00 00 00 00 00 00 00 00

For the failure analysis, we want to understand the real response reported
by the UFS device, however, the current query trace tells us nothing. After
this patch, the query trace on the query_send, and the above a pair of
query_send and query_complete will be:

query_send: HDR:16 00 00 0e 00 81 00 00 00 00 00 00, CDB:06 0e 03 00 00 00 00 00 00 00 00 00 00 00 00 00
ufshcd_upiu: HDR:36 00 00 0e 00 81 00 00 00 00 00 00, CDB:06 0e 03 00 00 00 00 00 00 00 00 01 00 00 00 00

Link: https://lore.kernel.org/r/20210105113446.16027-5-huobean@gmail.com
Acked-by: Avri Altman <avri.altman@wdc.com>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit be20b51cfd)
Bug: 204438323
Change-Id: Ie5254274cbf2882396c8b1aacdf4b0dd2bb7e413
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:24 -07:00
Bean Huo
5ceb0f7be3 UPSTREAM: scsi: ufs: Don't call trace_ufshcd_upiu() in case trace poit is disabled
Don't call trace_ufshcd_upiu() in case ufshba_upiu trace poit is not
enabled.

Link: https://lore.kernel.org/r/20210105113446.16027-4-huobean@gmail.com
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 9d5095e74c)
Bug: 204438323
Change-Id: Ia205c0aadd5c830eed89f3c69ec1da45ee3f070e
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:24 -07:00
Bean Huo
761aed4e6d UPSTREAM: scsi: ufs: Use __print_symbolic() for UFS trace string print
__print_symbolic() is designed for exporting the print formatting table to
userspace and allows parsing tool, such as trace-cmd and perf, to analyze
trace log according to this print formatting table, meanwhile, by using
__print_symbolic()s, save space in the trace ring buffer.

original print format:

print fmt: "%s: %s: HDR:%s, CDB:%s", __get_str(str), __get_str(dev_name),
            __print_hex(REC->hdr, sizeof(REC->hdr)),
            __print_hex(REC->tsf, sizeof(REC->tsf))

after this change:

print fmt: "%s: %s: HDR:%s, CDB:%s",
      print_symbolic(REC->str_t, {0, "send"},
                                 {1, "complete"},
                                 {2, "dev_complete"},
                                 {3, "query_send"},
                                 {4, "query_complete"},
                                 {5, "query_complete_err"},
                                 {6, "tm_send"},
                                 {7, "tm_complete"},
                                 {8, "tm_complete_err"}),
      __get_str(dev_name), __print_hex(REC->hdr, sizeof(REC->hdr)),
      __print_hex(REC->tsf, sizeof(REC->tsf))

Note: This patch just converts current __get_str(str) to __print_symbolic(),
      the original tracing log will not be affected by this change, so it
      doesn't break what current parsers expect.

Link: https://lore.kernel.org/r/20210105113446.16027-3-huobean@gmail.com
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[bvanasche: updated Android trace statements]
(cherry picked from commit 28fa68fc55)
Bug: 204438323
Change-Id: Id8d4605fc304abbe90a8e654edb2e18c44f2e37d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:24 -07:00
Bean Huo
532194fdde UPSTREAM: scsi: ufs: Remove stringize operator '#' restriction
Current EM macro definition, we use stringize operator '#', which turns the
argument it precedes into a quoted string. Thus requires the symbol of
__print_symbolic() should be the string corresponding to the name of the
enum.

However, we have other cases, the symbol and enum name are not the same, we
can redefine EM/EMe, but there will introduce some redundant codes.  This
patch is to remove this restriction, let others reuse the current EM/EMe
definition.

Link: https://lore.kernel.org/r/20210105113446.16027-2-huobean@gmail.com
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit c7c730ac6a)
Bug: 204438323
Change-Id: Ib20ffee0cce2c430d8aea3c17c27127306ac6550
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:24 -07:00
Stanley Chu
2daebf16f7 UPSTREAM: scsi: ufs: Un-inline ufshcd_vops_device_reset function
More and more statements are being added to ufshcd_vops_device_reset() and
this function is being called from multiple locations in the driver.
Un-inline the function to allow the compiler to make better decisions.

Link: https://lore.kernel.org/r/20201208135635.15326-3-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 31a5d9caff)
Bug: 204438323
Change-Id: Ib63ce7d7802e93eb153c19919870ecdd8e721a0d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:24 -07:00
Bean Huo
62580d18a7 UPSTREAM: scsi: ufs: Remove unused macro definition POWER_DESC_MAX_SIZE
POWER_DESC_MAX_SIZE is unused, remove it.

Link: https://lore.kernel.org/r/20201207190137.6858-2-huobean@gmail.com
Acked-by: Avri Altman <avri.altman@wdc.com>
Acked-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 44fd9fb599)
Bug: 204438323
Change-Id: I1beb35fa107e649fa67fb57737d7477fa740ad2f
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:24 -07:00
Stanley Chu
70c7deb9d9 UPSTREAM: scsi: ufs-dwc: Use phy_initialization helper
Use phy_initialization helper instead of direct invocation.

Link: https://lore.kernel.org/r/20201205120041.26869-5-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit ab98105484)
Bug: 204438323
Change-Id: I67e9046996aea433c8e6ecca2bbd1c9917fafa66
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:24 -07:00
Stanley Chu
afc50512d7 UPSTREAM: scsi: ufs-cdns: Use phy_initialization helper
Use phy_initialization helper instead of direct function invocation.

Link: https://lore.kernel.org/r/20201205120041.26869-4-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 885445736b)
Bug: 204438323
Change-Id: Id4c9e3d3ebc28a592430ff3f1cf8dda8b519f5fd
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:23 -07:00
Stanley Chu
5da68a465a UPSTREAM: scsi: ufs: Introduce phy_initialization helper
Introduce phy_initialization helper since this is the only one variant
function without helper.

Link: https://lore.kernel.org/r/20201205120041.26869-3-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 92bcebe4b6)
Bug: 204438323
Change-Id: I4ded425eacbf92c48880d6103cb7682bb2e45560
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:23 -07:00
Stanley Chu
637490a76d UPSTREAM: scsi: ufs: Remove unused setup_regulators variant function
Since setup_regulators variant function is not used by any vendors, simply
remove it.

Link: https://lore.kernel.org/r/20201205120041.26869-2-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit ade921a891)
Bug: 204438323
Change-Id: I4b700f50a600b275470f5c85573d3eb1aab4ab44
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:23 -07:00
Can Guo
9fdfb63d17 UPSTREAM: scsi: ufs-qcom: Keep core_clk_unipro on while link is active
If we want to disable clocks to save power but still keep the link active,
core_clk_unipro, like ref_clk, should not be the one being disabled.

Link: https://lore.kernel.org/r/1606356063-38380-3-git-send-email-cang@codeaurora.org
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 96f08cc594)
Bug: 204438323
Change-Id: I89f8e8d481effb6086183c4dd293a1104f8b44ed
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:23 -07:00
Bean Huo
4fb6025d52 UPSTREAM: scsi: ufs: Remove unnecessary if condition in ufshcd_suspend()
In the case that auto_bkops_enable is false, which means auto bkops has
been disabled, there is no need to call ufshcd_disable_auto_bkops().

Link: https://lore.kernel.org/r/20201125185300.3394-1-huobean@gmail.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 939785d35d)
Bug: 204438323
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: Id05e190482ce2c782a4cf4ea99e683cfc592c5f1
2021-11-03 13:31:23 -07:00
Bjorn Andersson
3442ca89f2 UPSTREAM: scsi: ufs: Adjust logic in common ADAPT helper
The introduction of ufshcd_dme_configure_adapt() refactored out duplication
from the Mediatek and Qualcomm drivers.

Both these implementations had the logic of:

    gear_tx == UFS_HS_G4 => PA_INITIAL_ADAPT
    gear_tx != UFS_HS_G4 => PA_NO_ADAPT

but now both implementations pass PA_INITIAL_ADAPT as "adapt_val" and if
gear_tx is not UFS_HS_G4 that is replaced with PA_INITIAL_ADAPT. In other
words, it's PA_INITIAL_ADAPT in both above cases.

The result is that e.g. Qualcomm SM8150 has no longer functional UFS, so
adjust the logic to match the previous implementation.

Link: https://lore.kernel.org/r/20201121044810.507288-1-bjorn.andersson@linaro.org
Fixes: fc85a74e28 ("scsi: ufs: Refactor ADAPT configuration function")
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 66df79ccbc)
Bug: 204438323
Change-Id: Ibb643d41f8d27a6982fac7ce301b6debdc72dbd2
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:23 -07:00
Stanley Chu
0bc5bb161a UPSTREAM: scsi: ufs: ufs-qcom: Use common ADAPT configuration function
Use common ADAPT configuration function to reduce duplicated code in UFS
drivers.

Link: https://lore.kernel.org/r/20201116065054.7658-10-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit d9fa1e731e)
Bug: 204438323
Change-Id: I1616679b35771b6efe3fc714d98a824dd570063c
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:23 -07:00
Stanley Chu
f7a28d2c91 UPSTREAM: scsi: ufs: ufs-mediatek: Use common ADAPT configuration function
Use common ADAPT configuration function to reduce duplicated code in UFS
drivers.

Link: https://lore.kernel.org/r/20201116065054.7658-9-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit e1e25d1b89)
Bug: 204438323
Change-Id: I7836ace10a782205112df4c6d29092a0ba638cef
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:22 -07:00
Stanley Chu
6582f7c0aa UPSTREAM: scsi: ufs: Refactor ADAPT configuration function
Several vendors are using same code to configure ADAPT settings for
HS-G4. Simply refactor it as common function.

Link: https://lore.kernel.org/r/20201116065054.7658-8-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit fc85a74e28)
Bug: 204438323
Change-Id: Ic2d373f9eb5e500fd0186c159f6e676723a97758
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:22 -07:00
Stanley Chu
04c6c4249a UPSTREAM: scsi: ufs: ufs-hisi: Use device parameter initialization function
Use common device parameter initialization function instead of initializing
those parameters by vendor driver itself.

Link: https://lore.kernel.org/r/20201116065054.7658-7-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 85d6d3c189)
Bug: 204438323
Change-Id: I343af684a6705ddea843d7424191f37f91dc6edd
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:22 -07:00
Stanley Chu
18e85ddf9b UPSTREAM: scsi: ufs: ufs-exynos: Use device parameter initialization function
Use common device parameter initialization function instead of initializing
those parameters by vendor driver itself.

Link: https://lore.kernel.org/r/20201116065054.7658-6-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 5b3573d68d)
Bug: 204438323
Change-Id: I0b53b05e570b8a64eebeab75669f228a0a1108d7
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:22 -07:00
Stanley Chu
908aa4a14a UPSTREAM: scsi: ufs: ufs-qcom: Use device parameter initialization function
Use common device parameter initialization function instead of initializing
those parameters by vendor driver itself.

Link: https://lore.kernel.org/r/20201116065054.7658-5-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 8beef54716)
Bug: 204438323
Change-Id: I168c25ee8d845e70adbfbb35e4c0eed423685c33
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:22 -07:00
Stanley Chu
9c4a8eb73a UPSTREAM: scsi: ufs: ufs-mediatek: Use device parameter initialization function
Use common device parameter initialization function instead of initializing
those parameters by vendor driver itself.

Link: https://lore.kernel.org/r/20201116065054.7658-4-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit a4b537ea65)
Bug: 204438323
Change-Id: I51245627fa918a260bf6e22a705240dd243e0a9a
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:22 -07:00
Stanley Chu
66f77bcd7d UPSTREAM: scsi: ufs: Introduce device parameter initialization function
Nowadays many vendors initialize their device parameters in their own
vendor drivers. The initialization code is almost the same as well as the
pre-defined definitions. Introduce a common device parameter initialization
function which assign the most common initial values. With this function,
we could remove those duplicated codes in vendor drivers.

Link: https://lore.kernel.org/r/20201116065054.7658-3-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 65858014ee)
Bug: 204438323
Change-Id: Ib64ea3e3e45e9702c8416807884442eefef4f486
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:22 -07:00
Stanley Chu
925faada23 UPSTREAM: scsi: ufs: ufs-mediatek: Refactor performance scaling functions
Refactor performance scaling related functions in MediaTek UFS driver.

Link: https://lore.kernel.org/r/20201116065054.7658-2-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 54770cbebe)
Bug: 204438323
Change-Id: I6a3ffc145bd404985a8d55680fb70ec7ad96b945
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:21 -07:00
Eric Biggers
21c587653b UPSTREAM: scsi: ufs-qcom: Only select QCOM_SCM if SCSI_UFS_CRYPTO
QCOM_SCM is only needed to make the qcom_scm_*() calls in ufs-qcom-ice.c,
which is only compiled when SCSI_UFS_CRYPTO=y.  So don't unnecessarily
enable QCOM_SCM when SCSI_UFS_CRYPTO=n.

Link: https://lore.kernel.org/r/20201114004754.235378-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 6ac63216a7)
Bug: 204438323
Change-Id: I23cc346284de92b223da87917b335e763078eec8
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:21 -07:00
Stanley Chu
d1f44de521 UPSTREAM: scsi: ufs-mediatek: Assign arguments with correct type
In ufs_mtk_unipro_set_lpm(), use specific unsigned values as the argument
to invoke ufshcd_dme_set().

At the same time, change the name of ufs_mtk_unipro_set_pm() to
ufs_mtk_unipro_set_lpm() to align the naming convention in MediaTek UFS
driver.

Link: https://lore.kernel.org/r/20201029115750.24391-2-stanley.chu@mediatek.com
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit a004147a33)
Bug: 204438323
Change-Id: I1e75b05fdc8a1204cb5d53fbff0252a2e0432340
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:21 -07:00
Adrian Hunter
c098fbf4cf UPSTREAM: scsi: ufs: Add DeepSleep feature
DeepSleep is a UFS v3.1 feature that achieves the lowest power consumption
of the device, apart from power off.

In DeepSleep mode, no commands are accepted, and the only way to exit is
using a hardware reset or power cycle.

This patch assumes that if a power cycle was an option, then power off
would be preferable, so only exit via a hardware reset is supported.

Drivers that wish to support DeepSleep need to set a new capability flag
UFSHCD_CAP_DEEPSLEEP and provide a hardware reset via the existing
 ->device_reset() callback.

It is assumed that UFS devices with wspecversion >= 0x310 support
DeepSleep.

[mkp: dropped sysfs ABI doc due to conflicts]

Link: https://lore.kernel.org/r/20201103141403.2142-2-adrian.hunter@intel.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Acked-by: Jonathan Corbet <corbet@lwn.net>
Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit fe1d4c2ebc)
Bug: 204438323
Change-Id: I054995d84b1d92b696ab9d8dda0946c1bbe47f92
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:21 -07:00
Asutosh Das
260ba85526 UPSTREAM: scsi: ufs: qcom: Enable aggressive power collapse for ufs HBA
Enabling this capability to let HBA power-collapse more often to save
power.

Link: https://lore.kernel.org/r/1306284ab2215425ca0a3d9c802574cbd6d35ea7.1603825776.git.asutoshd@codeaurora.org
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 61906fd465)
Bug: 204438323
Change-Id: I03e54c651d7735d9eaeb15dabea1dc6c5c54b413
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:21 -07:00
Bart Van Assche
43031c379c ANDROID: Revert "FROMGIT: ufs: ufs-exynos: use UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE"
Android commit d9ade6f2d9 ("FROMGIT: ufs: ufs-exynos: use
UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE") differs from the upstream
commit f1ef9047aa ("scsi: ufs: ufs-exynos: Use
UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE"). Additionally, that upstream
commit has already been backported. See also Android commit
e74b237ef9 ("scsi: ufs: ufs-exynos: Use
UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE"). Hence this revert.

Bug: 204438323
Change-Id: I61242407e621e7f963a32d83daf63b30efddbfd9
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:21 -07:00
Bart Van Assche
daa0085d45 ANDROID: scsi: ufs: Move the ufs_mtk_host.hw_ver member variable
Align a structure definition with the upstream code. See also upstream
commit 638e6271ca ("scsi: ufs-mediatek: Add HS-G4 support").

Bug: 204438323
Change-Id: Ie4eac4b7088950fe813ab7236718ea872a91c085
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:21 -07:00
Bart Van Assche
27a75f9751 ANDROID: scsi: ufs: Align ufshcd_init() with its upstream equivalent
This patch only changes whitespace. See also commit 4db7a23605 ("scsi:
ufs: Fix concurrency of error handler and other error recovery paths").

Bug: 204438323
Change-Id: I18e1bf734f3f2b2a3451c62184d5177a2cb28a6c
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:21 -07:00
Bart Van Assche
e555992723 ANDROID: scsi: ufs: Adjust ufshcd_uic_hibern8_*() declarations
Move the ufshcd_uic_hibern8_enter() and ufshcd_uic_hibern8_exit()
declarations to where these occur in the upstream code.

Bug: 204438323
Change-Id: Ia7fbee3828baefe53e11f7189522abe129479f43
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-11-03 13:31:20 -07:00
Yifan Hong
b2a2f767ac ANDROID: Kleaf: common kernel public
.... so it can be referenced in mixed builds.

Test: build cuttlefish
Bug: 202075496
Change-Id: I8d79847c54c639fa619edf3280c021f02ba76645
Signed-off-by: Yifan Hong <elsk@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-11-03 18:52:11 +00:00
Marc Zyngier
437b0bbd10 UPSTREAM: KVM: arm64: pkvm: Give priority to standard traps over pvm handling
Checking for pvm handling first means that we cannot handle ptrauth
traps or apply any of the workarounds (GICv3 or TX2 #219).

Flip the order around.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Fuad Tabba <tabba@google.com>
Tested-by: Fuad Tabba <tabba@google.com>
Link: https://lore.kernel.org/r/20211013120346.2926621-12-maz@kernel.org
(cherry picked from commit 0730559011)
Bug: 204960018
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I89b2cf3dd330ddcde01c8da3dc42aac83be05c0b
2021-11-03 18:31:55 +00:00
Marc Zyngier
a6ee337e90 UPSTREAM: KVM: arm64: pkvm: Pass vpcu instead of kvm to kvm_get_exit_handler_array()
Passing a VM pointer around is odd, and results in extra work on
VHE. Follow the rest of the design that uses the vcpu instead, and
let the nVHE code look into the struct kvm as required.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Fuad Tabba <tabba@google.com>
Tested-by: Fuad Tabba <tabba@google.com>
Link: https://lore.kernel.org/r/20211013120346.2926621-11-maz@kernel.org
(cherry picked from commit 0c7639cc83)
Bug: 204960018
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I729249b737cdfa9044a062623ebc38a151b65be9
2021-11-03 18:31:55 +00:00