All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/29] UFS patches for kernel v5.19
@ 2022-03-31 22:33 Bart Van Assche
  2022-03-31 22:33 ` [PATCH 01/29] scsi: ufs: Declare ufshcd_wait_for_register() static Bart Van Assche
                   ` (31 more replies)
  0 siblings, 32 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:33 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche

Hi Martin,

This patch series includes the following changes:
- Separation of UFS core and UFS driver source code into separate directories.
- Split the ufshcd.h header file into two header files - one file that
  defines the interface with UFS drivers and another file with definitions
  only used in the core.
- Multiple source code cleanup patches.
- A few patches with minor functional changes.

Please consider these changes for kernel v5.19.

Thank you,

Bart.

Bart Van Assche (29):
  scsi: ufs: Declare ufshcd_wait_for_register() static
  scsi: ufs: Remove superfluous boolean conversions
  scsi: ufs: Simplify statements that return a boolean
  scsi: ufs: Remove ufshcd_lrb.sense_bufflen
  scsi: ufs: Remove ufshcd_lrb.sense_buffer
  scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup()
  scsi: ufs: Remove the UFS_FIX() and END_FIX() macros
  scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk
  scsi: ufs: Declare the quirks array const
  scsi: ufs: Invert the return value of ufshcd_is_hba_active()
  scsi: ufs: Remove unused constants and code
  scsi: ufs: Switch to aggregate initialization
  scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown()
  scsi: ufs: Make the config_scaling_param calls type safe
  scsi: ufs: Remove the driver version
  scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun
  scsi: ufs: Use an SPDX license identifier in the Kconfig file
  scsi: ufs: Remove paths from source code comments
  scsi: ufs: Remove the TRUE and FALSE definitions
  scsi: ufs: Remove locking from around single register writes
  scsi: ufs: Introduce ufshcd_clkgate_delay_set()
  scsi: ufs: qcom: Fix ufs_qcom_resume()
  scsi: ufs: Remove unnecessary ufshcd-crypto.h include directives
  scsi: ufs: Fix kernel-doc syntax in ufshcd.h
  scsi: ufs: Minimize #include directives
  scsi: ufs: Split the ufshcd.h header file
  scsi: ufs: Move the struct ufs_ref_clk definition
  scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition
  scsi: ufs: Split the drivers/scsi/ufs directory

 drivers/scsi/Kconfig                          |   3 +-
 drivers/scsi/Makefile                         |   4 +-
 drivers/scsi/ufs-core/Kconfig                 |  82 ++++
 drivers/scsi/ufs-core/Makefile                |  10 +
 drivers/scsi/{ufs => ufs-core}/ufs-debugfs.c  |   4 +-
 drivers/scsi/{ufs => ufs-core}/ufs-debugfs.h  |   0
 .../{ufs => ufs-core}/ufs-fault-injection.c   |   4 +-
 .../{ufs => ufs-core}/ufs-fault-injection.h   |   0
 drivers/scsi/{ufs => ufs-core}/ufs-hwmon.c    |   4 +-
 drivers/scsi/{ufs => ufs-core}/ufs-sysfs.c    |   8 +-
 drivers/scsi/{ufs => ufs-core}/ufs-sysfs.h    |   3 +-
 drivers/scsi/{ufs => ufs-core}/ufs_bsg.c      |   6 +
 drivers/scsi/{ufs => ufs-core}/ufs_bsg.h      |   7 +-
 .../scsi/{ufs => ufs-core}/ufshcd-crypto.c    |   2 +-
 .../scsi/{ufs => ufs-core}/ufshcd-crypto.h    |   7 +-
 drivers/scsi/ufs-core/ufshcd-priv.h           | 296 ++++++++++++++
 drivers/scsi/{ufs => ufs-core}/ufshcd.c       | 254 ++++++------
 drivers/scsi/{ufs => ufs-core}/ufshpb.c       |  10 +-
 drivers/scsi/{ufs => ufs-core}/ufshpb.h       |   0
 drivers/scsi/ufs-drivers/Kconfig              | 118 ++++++
 drivers/scsi/{ufs => ufs-drivers}/Makefile    |  12 -
 .../scsi/{ufs => ufs-drivers}/cdns-pltfrm.c   |   5 +-
 .../{ufs => ufs-drivers}/tc-dwc-g210-pci.c    |   8 +-
 .../{ufs => ufs-drivers}/tc-dwc-g210-pltfrm.c |  10 +-
 .../scsi/{ufs => ufs-drivers}/tc-dwc-g210.c   |   8 +-
 .../scsi/{ufs => ufs-drivers}/tc-dwc-g210.h   |   2 +
 .../scsi/{ufs => ufs-drivers}/ti-j721e-ufs.c  |   0
 .../scsi/{ufs => ufs-drivers}/ufs-exynos.c    |  17 +-
 .../scsi/{ufs => ufs-drivers}/ufs-exynos.h    |   8 +-
 drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.c  |  17 +-
 drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.h  |   0
 .../{ufs => ufs-drivers}/ufs-mediatek-trace.h |   2 +-
 .../scsi/{ufs => ufs-drivers}/ufs-mediatek.c  |  40 +-
 .../scsi/{ufs => ufs-drivers}/ufs-mediatek.h  |   0
 .../scsi/{ufs => ufs-drivers}/ufs-qcom-ice.c  |   3 +-
 drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.c  |  49 +--
 drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.h  |   6 +-
 .../scsi/{ufs => ufs-drivers}/ufshcd-dwc.c    |   6 +-
 .../scsi/{ufs => ufs-drivers}/ufshcd-dwc.h    |   2 +
 .../scsi/{ufs => ufs-drivers}/ufshcd-pci.c    |  14 +-
 .../scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.c |  35 +-
 .../scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.h |   2 +-
 .../scsi/{ufs => ufs-drivers}/ufshci-dwc.h    |   0
 drivers/scsi/ufs/Kconfig                      | 211 ----------
 {drivers/scsi/ufs => include/scsi}/ufs.h      |  35 --
 .../scsi/ufs => include/scsi}/ufs_quirks.h    |  15 +-
 {drivers/scsi/ufs => include/scsi}/ufshcd.h   | 366 ++++--------------
 {drivers/scsi/ufs => include/scsi}/ufshci.h   |   2 +
 {drivers/scsi/ufs => include/scsi}/unipro.h   |  16 -
 49 files changed, 856 insertions(+), 857 deletions(-)
 create mode 100644 drivers/scsi/ufs-core/Kconfig
 create mode 100644 drivers/scsi/ufs-core/Makefile
 rename drivers/scsi/{ufs => ufs-core}/ufs-debugfs.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-debugfs.h (100%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-fault-injection.c (100%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-fault-injection.h (100%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-hwmon.c (98%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-sysfs.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-sysfs.h (95%)
 rename drivers/scsi/{ufs => ufs-core}/ufs_bsg.c (97%)
 rename drivers/scsi/{ufs => ufs-core}/ufs_bsg.h (77%)
 rename drivers/scsi/{ufs => ufs-core}/ufshcd-crypto.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufshcd-crypto.h (94%)
 create mode 100644 drivers/scsi/ufs-core/ufshcd-priv.h
 rename drivers/scsi/{ufs => ufs-core}/ufshcd.c (98%)
 rename drivers/scsi/{ufs => ufs-core}/ufshpb.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufshpb.h (100%)
 create mode 100644 drivers/scsi/ufs-drivers/Kconfig
 rename drivers/scsi/{ufs => ufs-drivers}/Makefile (56%)
 rename drivers/scsi/{ufs => ufs-drivers}/cdns-pltfrm.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210-pci.c (98%)
 rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210-pltfrm.c (98%)
 rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210.h (95%)
 rename drivers/scsi/{ufs => ufs-drivers}/ti-j721e-ufs.c (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-exynos.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-exynos.h (97%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.h (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek-trace.h (92%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek.c (97%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek.h (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom-ice.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.c (98%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.h (98%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-dwc.c (98%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-dwc.h (95%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pci.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.c (94%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.h (98%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshci-dwc.h (100%)
 delete mode 100644 drivers/scsi/ufs/Kconfig
 rename {drivers/scsi/ufs => include/scsi}/ufs.h (93%)
 rename {drivers/scsi/ufs => include/scsi}/ufs_quirks.h (94%)
 rename {drivers/scsi/ufs => include/scsi}/ufshcd.h (82%)
 rename {drivers/scsi/ufs => include/scsi}/ufshci.h (99%)
 rename {drivers/scsi/ufs => include/scsi}/unipro.h (98%)


^ permalink raw reply	[flat|nested] 101+ messages in thread

* [PATCH 01/29] scsi: ufs: Declare ufshcd_wait_for_register() static
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
@ 2022-03-31 22:33 ` Bart Van Assche
  2022-04-01 18:33   ` Avri Altman
  2022-04-03  9:45   ` Bean Huo
  2022-03-31 22:33 ` [PATCH 02/29] scsi: ufs: Remove superfluous boolean conversions Bart Van Assche
                   ` (30 subsequent siblings)
  31 siblings, 2 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:33 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Avri Altman, Daejun Park,
	Can Guo, Asutosh Das

Declare this function static since it is only used inside the ufshcd.c
source file.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 drivers/scsi/ufs/ufshcd.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 3f9caafa91bf..dbf50b50870b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -639,7 +639,7 @@ EXPORT_SYMBOL_GPL(ufshcd_delay_us);
  * Return:
  * -ETIMEDOUT on error, zero on success.
  */
-int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
+static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
 				u32 val, unsigned long interval_us,
 				unsigned long timeout_ms)
 {
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 88c20f3608c2..949427714d0e 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -1030,9 +1030,6 @@ void ufshcd_remove(struct ufs_hba *);
 int ufshcd_uic_hibern8_enter(struct ufs_hba *hba);
 int ufshcd_uic_hibern8_exit(struct ufs_hba *hba);
 void ufshcd_delay_us(unsigned long us, unsigned long tolerance);
-int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
-				u32 val, unsigned long interval_us,
-				unsigned long timeout_ms);
 void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk);
 void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val);
 void ufshcd_hba_stop(struct ufs_hba *hba);

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 02/29] scsi: ufs: Remove superfluous boolean conversions
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
  2022-03-31 22:33 ` [PATCH 01/29] scsi: ufs: Declare ufshcd_wait_for_register() static Bart Van Assche
@ 2022-03-31 22:33 ` Bart Van Assche
  2022-03-31 23:44   ` Bjorn Andersson
  2022-04-01 18:35   ` Avri Altman
  2022-03-31 22:33 ` [PATCH 03/29] scsi: ufs: Simplify statements that return a boolean Bart Van Assche
                   ` (29 subsequent siblings)
  31 siblings, 2 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:33 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Andy Gross, Bjorn Andersson, James E.J. Bottomley, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

Remove "? true : false" if the preceding expression yields a boolean or if
the result of the expression is assigned to a boolean since in these two
cases the "? true : false" part is superfluous.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-qcom.c | 3 +--
 drivers/scsi/ufs/ufshcd.c   | 9 ++++-----
 drivers/scsi/ufs/ufshcd.h   | 2 +-
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 0d2e950d0865..808b677f6083 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -299,8 +299,7 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
 	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
 	struct phy *phy = host->generic_phy;
 	int ret = 0;
-	bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)
-							? true : false;
+	bool is_rate_B = UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B;
 
 	/* Reset UFS Host Controller and PHY */
 	ret = ufs_qcom_host_reset(hba);
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index dbf50b50870b..983fac14b7cd 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -712,8 +712,7 @@ static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba)
  */
 static inline bool ufshcd_is_device_present(struct ufs_hba *hba)
 {
-	return (ufshcd_readl(hba, REG_CONTROLLER_STATUS) &
-						DEVICE_PRESENT) ? true : false;
+	return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & DEVICE_PRESENT;
 }
 
 /**
@@ -840,7 +839,7 @@ ufshcd_get_rsp_upiu_data_seg_len(struct utp_upiu_rsp *ucd_rsp_ptr)
 static inline bool ufshcd_is_exception_event(struct utp_upiu_rsp *ucd_rsp_ptr)
 {
 	return be32_to_cpu(ucd_rsp_ptr->header.dword_2) &
-			MASK_RSP_EXCEPTION_EVENT ? true : false;
+			MASK_RSP_EXCEPTION_EVENT;
 }
 
 /**
@@ -1350,7 +1349,7 @@ static int ufshcd_devfreq_target(struct device *dev,
 	}
 
 	/* Decide based on the rounded-off frequency and update */
-	scale_up = (*freq == clki->max_freq) ? true : false;
+	scale_up = *freq == clki->max_freq;
 	if (!scale_up)
 		*freq = clki->min_freq;
 	/* Update the frequency */
@@ -2800,7 +2799,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 	lrbp->sense_buffer = cmd->sense_buffer;
 	lrbp->task_tag = tag;
 	lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
-	lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false;
+	lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba);
 
 	ufshcd_prepare_lrbp_crypto(scsi_cmd_to_rq(cmd), lrbp);
 
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 949427714d0e..b2740b51a546 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -985,7 +985,7 @@ static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba)
 
 static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)
 {
-	return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false;
+	return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit);
 }
 
 static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba)

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 03/29] scsi: ufs: Simplify statements that return a boolean
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
  2022-03-31 22:33 ` [PATCH 01/29] scsi: ufs: Declare ufshcd_wait_for_register() static Bart Van Assche
  2022-03-31 22:33 ` [PATCH 02/29] scsi: ufs: Remove superfluous boolean conversions Bart Van Assche
@ 2022-03-31 22:33 ` Bart Van Assche
  2022-03-31 23:45   ` Bjorn Andersson
  2022-04-01 18:49   ` Avri Altman
  2022-03-31 22:33 ` [PATCH 04/29] scsi: ufs: Remove ufshcd_lrb.sense_bufflen Bart Van Assche
                   ` (28 subsequent siblings)
  31 siblings, 2 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:33 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Andy Gross, Bjorn Andersson, James E.J. Bottomley, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

Convert "if (expr) return true; else return false;" into "return expr;"
if either 'expr' is a boolean expression or the return type of the
function is 'bool'.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-qcom.h |  5 +----
 drivers/scsi/ufs/ufshcd.c   | 22 +++++-----------------
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h
index 8208e3a3ef59..51570224a6e2 100644
--- a/drivers/scsi/ufs/ufs-qcom.h
+++ b/drivers/scsi/ufs/ufs-qcom.h
@@ -239,10 +239,7 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host);
 
 static inline bool ufs_qcom_cap_qunipro(struct ufs_qcom_host *host)
 {
-	if (host->caps & UFS_QCOM_CAP_QUNIPRO)
-		return true;
-	else
-		return false;
+	return host->caps & UFS_QCOM_CAP_QUNIPRO;
 }
 
 /* ufs-qcom-ice.c */
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 983fac14b7cd..c60519372b3b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -939,10 +939,7 @@ static bool ufshcd_is_unipro_pa_params_tuning_req(struct ufs_hba *hba)
 	 * logic simple, we will only do manual tuning if local unipro version
 	 * doesn't support ver1.6 or later.
 	 */
-	if (ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6)
-		return true;
-	else
-		return false;
+	return ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6;
 }
 
 /**
@@ -2216,10 +2213,7 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
  */
 static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
 {
-	if (ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY)
-		return true;
-	else
-		return false;
+	return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY;
 }
 
 /**
@@ -5781,10 +5775,7 @@ static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba,
 		return false;
 	}
 	/* Let it continue to flush when available buffer exceeds threshold */
-	if (avail_buf < hba->vps->wb_flush_threshold)
-		return true;
-
-	return false;
+	return avail_buf < hba->vps->wb_flush_threshold;
 }
 
 static void ufshcd_wb_force_disable(struct ufs_hba *hba)
@@ -5863,11 +5854,8 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba)
 		return false;
 	}
 
-	if (!hba->dev_info.b_presrv_uspc_en) {
-		if (avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10))
-			return true;
-		return false;
-	}
+	if (!hba->dev_info.b_presrv_uspc_en)
+		return avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10);
 
 	return ufshcd_wb_presrv_usrspc_keep_vcc_on(hba, avail_buf);
 }

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 04/29] scsi: ufs: Remove ufshcd_lrb.sense_bufflen
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (2 preceding siblings ...)
  2022-03-31 22:33 ` [PATCH 03/29] scsi: ufs: Simplify statements that return a boolean Bart Van Assche
@ 2022-03-31 22:33 ` Bart Van Assche
  2022-04-01 18:56   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 05/29] scsi: ufs: Remove ufshcd_lrb.sense_buffer Bart Van Assche
                   ` (27 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:33 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Avri Altman, Daejun Park,
	Can Guo, Asutosh Das

ufshcd_lrb.sense_bufflen is set but never read. Hence remove this struct
member.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 3 ---
 drivers/scsi/ufs/ufshcd.h | 2 --
 2 files changed, 5 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c60519372b3b..e52e86b0b7a3 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2789,7 +2789,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 	lrbp = &hba->lrb[tag];
 	WARN_ON(lrbp->cmd);
 	lrbp->cmd = cmd;
-	lrbp->sense_bufflen = UFS_SENSE_SIZE;
 	lrbp->sense_buffer = cmd->sense_buffer;
 	lrbp->task_tag = tag;
 	lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
@@ -2830,7 +2829,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
 		struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag)
 {
 	lrbp->cmd = NULL;
-	lrbp->sense_bufflen = 0;
 	lrbp->sense_buffer = NULL;
 	lrbp->task_tag = tag;
 	lrbp->lun = 0; /* device management cmd is not specific to any LUN */
@@ -6802,7 +6800,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
 	lrbp = &hba->lrb[tag];
 	WARN_ON(lrbp->cmd);
 	lrbp->cmd = NULL;
-	lrbp->sense_bufflen = 0;
 	lrbp->sense_buffer = NULL;
 	lrbp->task_tag = tag;
 	lrbp->lun = 0;
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index b2740b51a546..b6162b208d99 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -182,7 +182,6 @@ struct ufs_pm_lvl_states {
  * @ucd_req_dma_addr: UPIU request dma address for debug
  * @cmd: pointer to SCSI command
  * @sense_buffer: pointer to sense buffer address of the SCSI command
- * @sense_bufflen: Length of the sense buffer
  * @scsi_status: SCSI status of the command
  * @command_type: SCSI, UFS, Query.
  * @task_tag: Task tag of the command
@@ -207,7 +206,6 @@ struct ufshcd_lrb {
 
 	struct scsi_cmnd *cmd;
 	u8 *sense_buffer;
-	unsigned int sense_bufflen;
 	int scsi_status;
 
 	int command_type;

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 05/29] scsi: ufs: Remove ufshcd_lrb.sense_buffer
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (3 preceding siblings ...)
  2022-03-31 22:33 ` [PATCH 04/29] scsi: ufs: Remove ufshcd_lrb.sense_bufflen Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-01 19:21   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 06/29] scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup() Bart Van Assche
                   ` (26 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Avri Altman, Daejun Park,
	Can Guo, Asutosh Das

ufshcd_lrb.sense_buffer is NULL if ufshcd_lrb.cmd is NULL and
ufshcd_lrb.sense_buffer points at cmd->sense_buffer if ufshcd_lrb.cmd
is set. In other words, the ufshcd_lrb.sense_buffer member is identical
to cmd->sense_buffer. Hence this patch that removes the
ufshcd_lrb.sense_buffer structure member.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 9 ++++-----
 drivers/scsi/ufs/ufshcd.h | 2 --
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index e52e86b0b7a3..eddaa57b6aad 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2127,15 +2127,17 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag)
  */
 static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)
 {
+	u8 *sense_buffer = lrbp->cmd ? lrbp->cmd->sense_buffer : NULL;
 	int len;
-	if (lrbp->sense_buffer &&
+
+	if (sense_buffer &&
 	    ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) {
 		int len_to_copy;
 
 		len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len);
 		len_to_copy = min_t(int, UFS_SENSE_SIZE, len);
 
-		memcpy(lrbp->sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data,
+		memcpy(sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data,
 		       len_to_copy);
 	}
 }
@@ -2789,7 +2791,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 	lrbp = &hba->lrb[tag];
 	WARN_ON(lrbp->cmd);
 	lrbp->cmd = cmd;
-	lrbp->sense_buffer = cmd->sense_buffer;
 	lrbp->task_tag = tag;
 	lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
 	lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba);
@@ -2829,7 +2830,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
 		struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag)
 {
 	lrbp->cmd = NULL;
-	lrbp->sense_buffer = NULL;
 	lrbp->task_tag = tag;
 	lrbp->lun = 0; /* device management cmd is not specific to any LUN */
 	lrbp->intr_cmd = true; /* No interrupt aggregation */
@@ -6800,7 +6800,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
 	lrbp = &hba->lrb[tag];
 	WARN_ON(lrbp->cmd);
 	lrbp->cmd = NULL;
-	lrbp->sense_buffer = NULL;
 	lrbp->task_tag = tag;
 	lrbp->lun = 0;
 	lrbp->intr_cmd = true;
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index b6162b208d99..b9f17219ca18 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -181,7 +181,6 @@ struct ufs_pm_lvl_states {
  * @ucd_rsp_dma_addr: UPIU response dma address for debug
  * @ucd_req_dma_addr: UPIU request dma address for debug
  * @cmd: pointer to SCSI command
- * @sense_buffer: pointer to sense buffer address of the SCSI command
  * @scsi_status: SCSI status of the command
  * @command_type: SCSI, UFS, Query.
  * @task_tag: Task tag of the command
@@ -205,7 +204,6 @@ struct ufshcd_lrb {
 	dma_addr_t ucd_prdt_dma_addr;
 
 	struct scsi_cmnd *cmd;
-	u8 *sense_buffer;
 	int scsi_status;
 
 	int command_type;

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 06/29] scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup()
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (4 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 05/29] scsi: ufs: Remove ufshcd_lrb.sense_buffer Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-03 11:20   ` Bean Huo
  2022-03-31 22:34 ` [PATCH 07/29] scsi: ufs: Remove the UFS_FIX() and END_FIX() macros Bart Van Assche
                   ` (25 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Avri Altman, Daejun Park,
	Can Guo, Asutosh Das

Use get_unaligned_be16(...) instead of the equivalent but harder to read
be16_to_cpup((__be16 *)...).

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index eddaa57b6aad..016734e987bf 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7334,7 +7334,7 @@ static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan, char *buff)
 	u16 unit;
 
 	for (i = start_scan; i >= 0; i--) {
-		data = be16_to_cpup((__be16 *)&buff[2 * i]);
+		data = get_unaligned_be16(&buff[2 * i]);
 		unit = (data & ATTR_ICC_LVL_UNIT_MASK) >>
 						ATTR_ICC_LVL_UNIT_OFFSET;
 		curr_uA = data & ATTR_ICC_LVL_VALUE_MASK;

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 07/29] scsi: ufs: Remove the UFS_FIX() and END_FIX() macros
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (5 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 06/29] scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup() Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-01 19:43   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 08/29] scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk Bart Van Assche
                   ` (24 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Stanley Chu, James E.J. Bottomley, Matthias Brugger, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

Since these two macros reduce code readability, remove these two macros.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-mediatek.c | 12 +++++----
 drivers/scsi/ufs/ufs_quirks.h   |  9 -------
 drivers/scsi/ufs/ufshcd.c       | 43 +++++++++++++++++++--------------
 3 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 86a938075f30..b275b440f027 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -45,11 +45,13 @@
 	ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)
 
 static struct ufs_dev_fix ufs_mtk_dev_fixups[] = {
-	UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL,
-		UFS_DEVICE_QUIRK_DELAY_AFTER_LPM),
-	UFS_FIX(UFS_VENDOR_SKHYNIX, "H9HQ21AFAMZDAR",
-		UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES),
-	END_FIX
+	{ .wmanufacturerid = UFS_VENDOR_MICRON,
+	  .model = UFS_ANY_MODEL,
+	  .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM },
+	{ .wmanufacturerid = UFS_VENDOR_SKHYNIX,
+	  .model = "H9HQ21AFAMZDAR",
+	  .quirk = UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES },
+	{}
 };
 
 static const struct of_device_id ufs_mtk_of_match[] = {
diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h
index 35ec9ea79869..e6c535c77527 100644
--- a/drivers/scsi/ufs/ufs_quirks.h
+++ b/drivers/scsi/ufs/ufs_quirks.h
@@ -29,15 +29,6 @@ struct ufs_dev_fix {
 	unsigned int quirk;
 };
 
-#define END_FIX { }
-
-/* add specific device quirk */
-#define UFS_FIX(_vendor, _model, _quirk) { \
-	.wmanufacturerid = (_vendor),\
-	.model = (_model),		   \
-	.quirk = (_quirk),		   \
-}
-
 /*
  * Some vendor's UFS device sends back to back NACs for the DL data frames
  * causing the host controller to raise the DFES error status. Sometimes
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 016734e987bf..b7cfe2dca705 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -206,24 +206,31 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state,
 
 static struct ufs_dev_fix ufs_fixups[] = {
 	/* UFS cards deviations table */
-	UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL,
-		UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
-		UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ),
-	UFS_FIX(UFS_VENDOR_SAMSUNG, UFS_ANY_MODEL,
-		UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
-		UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |
-		UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS),
-	UFS_FIX(UFS_VENDOR_SKHYNIX, UFS_ANY_MODEL,
-		UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME),
-	UFS_FIX(UFS_VENDOR_SKHYNIX, "hB8aL1" /*H28U62301AMR*/,
-		UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME),
-	UFS_FIX(UFS_VENDOR_TOSHIBA, UFS_ANY_MODEL,
-		UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM),
-	UFS_FIX(UFS_VENDOR_TOSHIBA, "THGLF2G9C8KBADG",
-		UFS_DEVICE_QUIRK_PA_TACTIVATE),
-	UFS_FIX(UFS_VENDOR_TOSHIBA, "THGLF2G9D8KBADG",
-		UFS_DEVICE_QUIRK_PA_TACTIVATE),
-	END_FIX
+	{ .wmanufacturerid = UFS_VENDOR_MICRON,
+	  .model = UFS_ANY_MODEL,
+	  .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
+		   UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ },
+	{ .wmanufacturerid = UFS_VENDOR_SAMSUNG,
+	  .model = UFS_ANY_MODEL,
+	  .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
+		   UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |
+		   UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS },
+	{ .wmanufacturerid = UFS_VENDOR_SKHYNIX,
+	  .model = UFS_ANY_MODEL,
+	  .quirk = UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME },
+	{ .wmanufacturerid = UFS_VENDOR_SKHYNIX,
+	  .model = "hB8aL1" /*H28U62301AMR*/,
+	  .quirk = UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME },
+	{ .wmanufacturerid = UFS_VENDOR_TOSHIBA,
+	  .model = UFS_ANY_MODEL,
+	  .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM },
+	{ .wmanufacturerid = UFS_VENDOR_TOSHIBA,
+	  .model = "THGLF2G9C8KBADG",
+	  .quirk = UFS_DEVICE_QUIRK_PA_TACTIVATE },
+	{ .wmanufacturerid = UFS_VENDOR_TOSHIBA,
+	  .model = "THGLF2G9D8KBADG",
+	  .quirk = UFS_DEVICE_QUIRK_PA_TACTIVATE },
+	{}
 };
 
 static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba);

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 08/29] scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (6 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 07/29] scsi: ufs: Remove the UFS_FIX() and END_FIX() macros Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-01 19:47   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 09/29] scsi: ufs: Declare the quirks array const Bart Van Assche
                   ` (23 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Stanley Chu, James E.J. Bottomley, Matthias Brugger, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

Since struct ufs_dev_fix contains quirk information, rename it into struct
ufs_dev_quirk.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-mediatek.c | 2 +-
 drivers/scsi/ufs/ufs_quirks.h   | 4 ++--
 drivers/scsi/ufs/ufshcd.c       | 6 +++---
 drivers/scsi/ufs/ufshcd.h       | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index b275b440f027..217348dde6a6 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -44,7 +44,7 @@
 #define ufs_mtk_device_reset_ctrl(high, res) \
 	ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)
 
-static struct ufs_dev_fix ufs_mtk_dev_fixups[] = {
+static struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
 	{ .wmanufacturerid = UFS_VENDOR_MICRON,
 	  .model = UFS_ANY_MODEL,
 	  .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM },
diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h
index e6c535c77527..e38dec5f0351 100644
--- a/drivers/scsi/ufs/ufs_quirks.h
+++ b/drivers/scsi/ufs/ufs_quirks.h
@@ -19,11 +19,11 @@
 #define UFS_VENDOR_WDC         0x145
 
 /**
- * ufs_dev_fix - ufs device quirk info
+ * ufs_dev_quirk - ufs device quirk info
  * @card: ufs card details
  * @quirk: device quirk
  */
-struct ufs_dev_fix {
+struct ufs_dev_quirk {
 	u16 wmanufacturerid;
 	u8 *model;
 	unsigned int quirk;
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index b7cfe2dca705..97b9b2b77593 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -204,7 +204,7 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state,
 	return UFS_PM_LVL_0;
 }
 
-static struct ufs_dev_fix ufs_fixups[] = {
+static struct ufs_dev_quirk ufs_fixups[] = {
 	/* UFS cards deviations table */
 	{ .wmanufacturerid = UFS_VENDOR_MICRON,
 	  .model = UFS_ANY_MODEL,
@@ -7624,9 +7624,9 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, u8 *desc_buf)
 	}
 }
 
-void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups)
+void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups)
 {
-	struct ufs_dev_fix *f;
+	struct ufs_dev_quirk *f;
 	struct ufs_dev_info *dev_info = &hba->dev_info;
 
 	if (!fixups)
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index b9f17219ca18..3d18581afc2b 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -1180,7 +1180,7 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
 
 void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);
 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
-void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups);
+void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups);
 #define SD_ASCII_STD true
 #define SD_RAW false
 int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 09/29] scsi: ufs: Declare the quirks array const
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (7 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 08/29] scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-01 19:56   ` Avri Altman
  2022-04-05  6:14   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 10/29] scsi: ufs: Invert the return value of ufshcd_is_hba_active() Bart Van Assche
                   ` (22 subsequent siblings)
  31 siblings, 2 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Stanley Chu, James E.J. Bottomley, Matthias Brugger, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

Declare the quirks array and also its 'model' member const to make it
explicit that these are not modified.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-mediatek.c | 2 +-
 drivers/scsi/ufs/ufs_quirks.h   | 2 +-
 drivers/scsi/ufs/ufshcd.c       | 7 ++++---
 drivers/scsi/ufs/ufshcd.h       | 3 ++-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 217348dde6a6..9a4474210627 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -44,7 +44,7 @@
 #define ufs_mtk_device_reset_ctrl(high, res) \
 	ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)
 
-static struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
+static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
 	{ .wmanufacturerid = UFS_VENDOR_MICRON,
 	  .model = UFS_ANY_MODEL,
 	  .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM },
diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h
index e38dec5f0351..bcb4f004bed5 100644
--- a/drivers/scsi/ufs/ufs_quirks.h
+++ b/drivers/scsi/ufs/ufs_quirks.h
@@ -25,7 +25,7 @@
  */
 struct ufs_dev_quirk {
 	u16 wmanufacturerid;
-	u8 *model;
+	const u8 *model;
 	unsigned int quirk;
 };
 
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 97b9b2b77593..931ce620fc34 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -204,7 +204,7 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state,
 	return UFS_PM_LVL_0;
 }
 
-static struct ufs_dev_quirk ufs_fixups[] = {
+static const struct ufs_dev_quirk ufs_fixups[] = {
 	/* UFS cards deviations table */
 	{ .wmanufacturerid = UFS_VENDOR_MICRON,
 	  .model = UFS_ANY_MODEL,
@@ -7624,9 +7624,10 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, u8 *desc_buf)
 	}
 }
 
-void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups)
+void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
+			     const struct ufs_dev_quirk *fixups)
 {
-	struct ufs_dev_quirk *f;
+	const struct ufs_dev_quirk *f;
 	struct ufs_dev_info *dev_info = &hba->dev_info;
 
 	if (!fixups)
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 3d18581afc2b..107d19e98d52 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -1180,7 +1180,8 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
 
 void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);
 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
-void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups);
+void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
+			     const struct ufs_dev_quirk *fixups);
 #define SD_ASCII_STD true
 #define SD_RAW false
 int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 10/29] scsi: ufs: Invert the return value of ufshcd_is_hba_active()
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (8 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 09/29] scsi: ufs: Declare the quirks array const Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-02  6:32   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 11/29] scsi: ufs: Remove unused constants and code Bart Van Assche
                   ` (21 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Avri Altman, Daejun Park,
	Can Guo, Asutosh Das

It is confusing that ufshcd_is_hba_active() returns 'true' if the HBA is
not active. Clear up this confusion by inverting the return value of
ufshcd_is_hba_active(). This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 931ce620fc34..1ed54f6aef82 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -917,12 +917,11 @@ static inline void ufshcd_hba_start(struct ufs_hba *hba)
  * ufshcd_is_hba_active - Get controller state
  * @hba: per adapter instance
  *
- * Returns false if controller is active, true otherwise
+ * Returns true if and only if the controller is active.
  */
 static inline bool ufshcd_is_hba_active(struct ufs_hba *hba)
 {
-	return (ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & CONTROLLER_ENABLE)
-		? false : true;
+	return ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & CONTROLLER_ENABLE;
 }
 
 u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba)
@@ -4552,7 +4551,7 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba)
 	int retry_inner;
 
 start:
-	if (!ufshcd_is_hba_active(hba))
+	if (ufshcd_is_hba_active(hba))
 		/* change controller state to "reset state" */
 		ufshcd_hba_stop(hba);
 
@@ -4578,7 +4577,7 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba)
 
 	/* wait for the host controller to complete initialization */
 	retry_inner = 50;
-	while (ufshcd_is_hba_active(hba)) {
+	while (!ufshcd_is_hba_active(hba)) {
 		if (retry_inner) {
 			retry_inner--;
 		} else {

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 11/29] scsi: ufs: Remove unused constants and code
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (9 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 10/29] scsi: ufs: Invert the return value of ufshcd_is_hba_active() Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-02  6:59   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 12/29] scsi: ufs: Switch to aggregate initialization Bart Van Assche
                   ` (20 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Daejun Park, Bean Huo, Avri Altman,
	Jinyoung Choi, Can Guo, Asutosh Das

Commit 5b44a07b6bb2 ("scsi: ufs: Remove pre-defined initial voltage values
of device power") removed the code that uses the UFS_VREG_VCC* constants
and also the code that sets the min_uV and max_uV member variables. Hence
also remove these constants and that member variable.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs.h    | 11 -----------
 drivers/scsi/ufs/ufshcd.c | 29 +++--------------------------
 2 files changed, 3 insertions(+), 37 deletions(-)

diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 4a00c24a3209..225b5b4a2a7e 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -562,15 +562,6 @@ struct ufs_query_res {
 	struct utp_upiu_query upiu_res;
 };
 
-#define UFS_VREG_VCC_MIN_UV	   2700000 /* uV */
-#define UFS_VREG_VCC_MAX_UV	   3600000 /* uV */
-#define UFS_VREG_VCC_1P8_MIN_UV    1700000 /* uV */
-#define UFS_VREG_VCC_1P8_MAX_UV    1950000 /* uV */
-#define UFS_VREG_VCCQ_MIN_UV	   1140000 /* uV */
-#define UFS_VREG_VCCQ_MAX_UV	   1260000 /* uV */
-#define UFS_VREG_VCCQ2_MIN_UV	   1700000 /* uV */
-#define UFS_VREG_VCCQ2_MAX_UV	   1950000 /* uV */
-
 /*
  * VCCQ & VCCQ2 current requirement when UFS device is in sleep state
  * and link is in Hibern8 state.
@@ -582,8 +573,6 @@ struct ufs_vreg {
 	const char *name;
 	bool always_on;
 	bool enabled;
-	int min_uV;
-	int max_uV;
 	int max_uA;
 };
 
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 1ed54f6aef82..a48362165672 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8309,33 +8309,10 @@ static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,
 static int ufshcd_config_vreg(struct device *dev,
 		struct ufs_vreg *vreg, bool on)
 {
-	int ret = 0;
-	struct regulator *reg;
-	const char *name;
-	int min_uV, uA_load;
-
-	BUG_ON(!vreg);
-
-	reg = vreg->reg;
-	name = vreg->name;
-
-	if (regulator_count_voltages(reg) > 0) {
-		uA_load = on ? vreg->max_uA : 0;
-		ret = ufshcd_config_vreg_load(dev, vreg, uA_load);
-		if (ret)
-			goto out;
+	if (regulator_count_voltages(vreg->reg) <= 0)
+		return 0;
 
-		if (vreg->min_uV && vreg->max_uV) {
-			min_uV = on ? vreg->min_uV : 0;
-			ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
-			if (ret)
-				dev_err(dev,
-					"%s: %s set voltage failed, err=%d\n",
-					__func__, name, ret);
-		}
-	}
-out:
-	return ret;
+	return ufshcd_config_vreg_load(dev, vreg, on ? vreg->max_uA : 0);
 }
 
 static int ufshcd_enable_vreg(struct device *dev, struct ufs_vreg *vreg)

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 12/29] scsi: ufs: Switch to aggregate initialization
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (10 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 11/29] scsi: ufs: Remove unused constants and code Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-02  7:07   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 13/29] scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown() Bart Van Assche
                   ` (19 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Xiaoke Wang, Daejun Park,
	Sergey Shtylyov, Srinivas Kandagatla

Make it easier to verify for humans that ufshcd_init_pwr_dev_param()
initializes all structure members. This patch does not change any
functionality.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 87975d1a21c8..2725ce4de1c9 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -297,18 +297,20 @@ EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param);
 
 void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
 {
-	dev_param->tx_lanes = 2;
-	dev_param->rx_lanes = 2;
-	dev_param->hs_rx_gear = UFS_HS_G3;
-	dev_param->hs_tx_gear = UFS_HS_G3;
-	dev_param->pwm_rx_gear = UFS_PWM_G4;
-	dev_param->pwm_tx_gear = UFS_PWM_G4;
-	dev_param->rx_pwr_pwm = SLOW_MODE;
-	dev_param->tx_pwr_pwm = SLOW_MODE;
-	dev_param->rx_pwr_hs = FAST_MODE;
-	dev_param->tx_pwr_hs = FAST_MODE;
-	dev_param->hs_rate = PA_HS_MODE_B;
-	dev_param->desired_working_mode = UFS_HS_MODE;
+	*dev_param = (struct ufs_dev_params){
+		.tx_lanes = 2,
+		.rx_lanes = 2,
+		.hs_rx_gear = UFS_HS_G3,
+		.hs_tx_gear = UFS_HS_G3,
+		.pwm_rx_gear = UFS_PWM_G4,
+		.pwm_tx_gear = UFS_PWM_G4,
+		.rx_pwr_pwm = SLOW_MODE,
+		.tx_pwr_pwm = SLOW_MODE,
+		.rx_pwr_hs = FAST_MODE,
+		.tx_pwr_hs = FAST_MODE,
+		.hs_rate = PA_HS_MODE_B,
+		.desired_working_mode = UFS_HS_MODE,
+	};
 }
 EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param);
 

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 13/29] scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown()
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (11 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 12/29] scsi: ufs: Switch to aggregate initialization Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-01  6:20   ` Adrian Hunter
  2022-03-31 22:34 ` [PATCH 14/29] scsi: ufs: Make the config_scaling_param calls type safe Bart Van Assche
                   ` (18 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Avri Altman, Daejun Park,
	Can Guo, Asutosh Das

Quiescing LUNs falls outside the scope of a shutdown callback. The shutdown
callback is called from inside the reboot() system call and the reboot()
system call is called after user space has stopped accessing block devices.
Hence this patch that removes the quiescing calls from
ufshcd_wl_shutdown(). This patch makes shutdown faster since multiple
synchronize_rcu() calls are removed.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index a48362165672..ae08c7964f2d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -9212,9 +9212,7 @@ static int ufshcd_wl_resume(struct device *dev)
 static void ufshcd_wl_shutdown(struct device *dev)
 {
 	struct scsi_device *sdev = to_scsi_device(dev);
-	struct ufs_hba *hba;
-
-	hba = shost_priv(sdev->host);
+	struct ufs_hba *hba = shost_priv(sdev->host);
 
 	down(&hba->host_sem);
 	hba->shutting_down = true;
@@ -9222,12 +9220,6 @@ static void ufshcd_wl_shutdown(struct device *dev)
 
 	/* Turn on everything while shutting down */
 	ufshcd_rpm_get_sync(hba);
-	scsi_device_quiesce(sdev);
-	shost_for_each_device(sdev, hba->host) {
-		if (sdev == hba->sdev_ufs_device)
-			continue;
-		scsi_device_quiesce(sdev);
-	}
 	__ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);
 }
 

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 14/29] scsi: ufs: Make the config_scaling_param calls type safe
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (12 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 13/29] scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown() Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-03-31 23:48   ` Bjorn Andersson
  2022-03-31 22:34 ` [PATCH 15/29] scsi: ufs: Remove the driver version Bart Van Assche
                   ` (17 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Andy Gross, Bjorn Andersson, James E.J. Bottomley, Bean Huo,
	Daejun Park, Avri Altman, Can Guo, Asutosh Das

Pass the actual type to config_scaling_param callback as the third
argment instead of a void pointer. Remove a superfluous NULL pointer
check from ufs_qcom_config_scaling_param().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-qcom.c | 14 ++++----------
 drivers/scsi/ufs/ufshcd.h   | 10 +++++-----
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 808b677f6083..f24210652fe9 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1463,23 +1463,17 @@ static int ufs_qcom_device_reset(struct ufs_hba *hba)
 
 #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
 static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
-					  struct devfreq_dev_profile *p,
-					  void *data)
+		struct devfreq_dev_profile *p,
+		struct devfreq_simple_ondemand_data *d)
 {
-	static struct devfreq_simple_ondemand_data *d;
-
-	if (!data)
-		return;
-
-	d = (struct devfreq_simple_ondemand_data *)data;
 	p->polling_ms = 60;
 	d->upthreshold = 70;
 	d->downdifferential = 5;
 }
 #else
 static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
-					  struct devfreq_dev_profile *p,
-					  void *data)
+		struct devfreq_dev_profile *p,
+		struct devfreq_simple_ondemand_data *data)
 {
 }
 #endif
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 107d19e98d52..bb2624aabda2 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -348,8 +348,8 @@ struct ufs_hba_variant_ops {
 	int	(*phy_initialization)(struct ufs_hba *);
 	int	(*device_reset)(struct ufs_hba *hba);
 	void	(*config_scaling_param)(struct ufs_hba *hba,
-					struct devfreq_dev_profile *profile,
-					void *data);
+				struct devfreq_dev_profile *profile,
+				struct devfreq_simple_ondemand_data *data);
 	int	(*program_key)(struct ufs_hba *hba,
 			       const union ufs_crypto_cfg_entry *cfg, int slot);
 	void	(*event_notify)(struct ufs_hba *hba,
@@ -1360,11 +1360,11 @@ static inline int ufshcd_vops_device_reset(struct ufs_hba *hba)
 }
 
 static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
-						    struct devfreq_dev_profile
-						    *profile, void *data)
+		struct devfreq_dev_profile *p,
+		struct devfreq_simple_ondemand_data *data)
 {
 	if (hba->vops && hba->vops->config_scaling_param)
-		hba->vops->config_scaling_param(hba, profile, data);
+		hba->vops->config_scaling_param(hba, p, data);
 }
 
 extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 15/29] scsi: ufs: Remove the driver version
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (13 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 14/29] scsi: ufs: Make the config_scaling_param calls type safe Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-03  7:10   ` Avri Altman
                     ` (2 more replies)
  2022-03-31 22:34 ` [PATCH 16/29] scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun Bart Van Assche
                   ` (16 subsequent siblings)
  31 siblings, 3 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Stanley Chu, Daejun Park, Asutosh Das,
	Avri Altman, Bean Huo, Sergey Shtylyov, Srinivas Kandagatla,
	Xiaoke Wang, Can Guo

Driver version numbers are not useful in upstream kernel code. Hence
remove the driver version number from the UFS driver.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/cdns-pltfrm.c   | 1 -
 drivers/scsi/ufs/ufshcd-pci.c    | 1 -
 drivers/scsi/ufs/ufshcd-pltfrm.c | 1 -
 drivers/scsi/ufs/ufshcd.c        | 1 -
 drivers/scsi/ufs/ufshcd.h        | 1 -
 5 files changed, 5 deletions(-)

diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c
index 7da8be2f35c4..e91cf9fd5a95 100644
--- a/drivers/scsi/ufs/cdns-pltfrm.c
+++ b/drivers/scsi/ufs/cdns-pltfrm.c
@@ -340,4 +340,3 @@ module_platform_driver(cdns_ufs_pltfrm_driver);
 MODULE_AUTHOR("Jan Kotas <jank@cadence.com>");
 MODULE_DESCRIPTION("Cadence UFS host controller platform driver");
 MODULE_LICENSE("GPL v2");
-MODULE_VERSION(UFSHCD_DRIVER_VERSION);
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index f76692053ca1..81aa14661072 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -601,4 +601,3 @@ MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>");
 MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
 MODULE_DESCRIPTION("UFS host controller PCI glue driver");
 MODULE_LICENSE("GPL");
-MODULE_VERSION(UFSHCD_DRIVER_VERSION);
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 2725ce4de1c9..81e458d31222 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -386,4 +386,3 @@ MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>");
 MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
 MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
 MODULE_LICENSE("GPL");
-MODULE_VERSION(UFSHCD_DRIVER_VERSION);
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ae08c7964f2d..9d433d2c616d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -9915,4 +9915,3 @@ MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>");
 MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
 MODULE_DESCRIPTION("Generic UFS host controller driver Core");
 MODULE_LICENSE("GPL");
-MODULE_VERSION(UFSHCD_DRIVER_VERSION);
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index bb2624aabda2..49edbdb5ffd6 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -49,7 +49,6 @@
 #include "ufshci.h"
 
 #define UFSHCD "ufshcd"
-#define UFSHCD_DRIVER_VERSION "0.2"
 
 struct ufs_hba;
 

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 16/29] scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (14 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 15/29] scsi: ufs: Remove the driver version Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-03  7:25   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 17/29] scsi: ufs: Use an SPDX license identifier in the Kconfig file Bart Van Assche
                   ` (15 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Avri Altman, Daejun Park,
	Can Guo, Asutosh Das

The new name reflects the role of this member variable better: a WLUN
through which the power mode of the UFS device is controlled.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 48 +++++++++++++++++++--------------------
 drivers/scsi/ufs/ufshcd.h | 17 ++++++--------
 2 files changed, 31 insertions(+), 34 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 9d433d2c616d..c36658d97774 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -540,7 +540,7 @@ static void ufshcd_print_tmrs(struct ufs_hba *hba, unsigned long bitmap)
 
 static void ufshcd_print_host_state(struct ufs_hba *hba)
 {
-	struct scsi_device *sdev_ufs = hba->sdev_ufs_device;
+	struct scsi_device *sdev_ufs = hba->ufs_device_wlun;
 
 	dev_err(hba->dev, "UFS Host state=%d\n", hba->ufshcd_state);
 	dev_err(hba->dev, "outstanding reqs=0x%lx tasks=0x%lx\n",
@@ -4195,7 +4195,7 @@ void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
 
 	if (update &&
-	    !pm_runtime_suspended(&hba->sdev_ufs_device->sdev_gendev)) {
+	    !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) {
 		ufshcd_rpm_get_sync(hba);
 		ufshcd_hold(hba, false);
 		ufshcd_auto_hibern8_enable(hba);
@@ -4911,13 +4911,13 @@ static void ufshcd_setup_links(struct ufs_hba *hba, struct scsi_device *sdev)
 	 * Device wlun is the supplier & rest of the luns are consumers.
 	 * This ensures that device wlun suspends after all other luns.
 	 */
-	if (hba->sdev_ufs_device) {
+	if (hba->ufs_device_wlun) {
 		link = device_link_add(&sdev->sdev_gendev,
-				       &hba->sdev_ufs_device->sdev_gendev,
+				       &hba->ufs_device_wlun->sdev_gendev,
 				       DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
 		if (!link) {
 			dev_err(&sdev->sdev_gendev, "Failed establishing link - %s\n",
-				dev_name(&hba->sdev_ufs_device->sdev_gendev));
+				dev_name(&hba->ufs_device_wlun->sdev_gendev));
 			return;
 		}
 		hba->luns_avail--;
@@ -5053,15 +5053,15 @@ static void ufshcd_slave_destroy(struct scsi_device *sdev)
 	/* Drop the reference as it won't be needed anymore */
 	if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) {
 		spin_lock_irqsave(hba->host->host_lock, flags);
-		hba->sdev_ufs_device = NULL;
+		hba->ufs_device_wlun = NULL;
 		spin_unlock_irqrestore(hba->host->host_lock, flags);
-	} else if (hba->sdev_ufs_device) {
+	} else if (hba->ufs_device_wlun) {
 		struct device *supplier = NULL;
 
 		/* Ensure UFS Device WLUN exists and does not disappear */
 		spin_lock_irqsave(hba->host->host_lock, flags);
-		if (hba->sdev_ufs_device) {
-			supplier = &hba->sdev_ufs_device->sdev_gendev;
+		if (hba->ufs_device_wlun) {
+			supplier = &hba->ufs_device_wlun->sdev_gendev;
 			get_device(supplier);
 		}
 		spin_unlock_irqrestore(hba->host->host_lock, flags);
@@ -6037,7 +6037,7 @@ static void ufshcd_clk_scaling_suspend(struct ufs_hba *hba, bool suspend)
 static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
 {
 	ufshcd_rpm_get_sync(hba);
-	if (pm_runtime_status_suspended(&hba->sdev_ufs_device->sdev_gendev) ||
+	if (pm_runtime_status_suspended(&hba->ufs_device_wlun->sdev_gendev) ||
 	    hba->is_sys_suspended) {
 		enum ufs_pm_op pm_op;
 
@@ -6082,7 +6082,7 @@ static void ufshcd_err_handling_unprepare(struct ufs_hba *hba)
 static inline bool ufshcd_err_handling_should_stop(struct ufs_hba *hba)
 {
 	return (!hba->is_powered || hba->shutting_down ||
-		!hba->sdev_ufs_device ||
+		!hba->ufs_device_wlun ||
 		hba->ufshcd_state == UFSHCD_STATE_ERROR ||
 		(!(hba->saved_err || hba->saved_uic_err || hba->force_reset ||
 		   ufshcd_is_link_broken(hba))));
@@ -6101,7 +6101,7 @@ static void ufshcd_recover_pm_error(struct ufs_hba *hba)
 	 * Set RPM status of wlun device to RPM_ACTIVE,
 	 * this also clears its runtime error.
 	 */
-	ret = pm_runtime_set_active(&hba->sdev_ufs_device->sdev_gendev);
+	ret = pm_runtime_set_active(&hba->ufs_device_wlun->sdev_gendev);
 
 	/* hba device might have a runtime error otherwise */
 	if (ret)
@@ -7495,20 +7495,20 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba)
 	int ret = 0;
 	struct scsi_device *sdev_boot, *sdev_rpmb;
 
-	hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0,
+	hba->ufs_device_wlun = __scsi_add_device(hba->host, 0, 0,
 		ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL);
-	if (IS_ERR(hba->sdev_ufs_device)) {
-		ret = PTR_ERR(hba->sdev_ufs_device);
-		hba->sdev_ufs_device = NULL;
+	if (IS_ERR(hba->ufs_device_wlun)) {
+		ret = PTR_ERR(hba->ufs_device_wlun);
+		hba->ufs_device_wlun = NULL;
 		goto out;
 	}
-	scsi_device_put(hba->sdev_ufs_device);
+	scsi_device_put(hba->ufs_device_wlun);
 
 	sdev_rpmb = __scsi_add_device(hba->host, 0, 0,
 		ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL);
 	if (IS_ERR(sdev_rpmb)) {
 		ret = PTR_ERR(sdev_rpmb);
-		goto remove_sdev_ufs_device;
+		goto remove_ufs_device_wlun;
 	}
 	ufshcd_blk_pm_runtime_init(sdev_rpmb);
 	scsi_device_put(sdev_rpmb);
@@ -7523,8 +7523,8 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba)
 	}
 	goto out;
 
-remove_sdev_ufs_device:
-	scsi_remove_device(hba->sdev_ufs_device);
+remove_ufs_device_wlun:
+	scsi_remove_device(hba->ufs_device_wlun);
 out:
 	return ret;
 }
@@ -8660,7 +8660,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 	int ret, retries;
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	sdp = hba->sdev_ufs_device;
+	sdp = hba->ufs_device_wlun;
 	if (sdp) {
 		ret = scsi_device_get(sdp);
 		if (!ret && !scsi_device_online(sdp)) {
@@ -9437,7 +9437,7 @@ EXPORT_SYMBOL(ufshcd_shutdown);
  */
 void ufshcd_remove(struct ufs_hba *hba)
 {
-	if (hba->sdev_ufs_device)
+	if (hba->ufs_device_wlun)
 		ufshcd_rpm_get_sync(hba);
 	ufs_hwmon_remove(hba);
 	ufs_bsg_remove(hba);
@@ -9765,7 +9765,7 @@ EXPORT_SYMBOL_GPL(ufshcd_resume_complete);
 
 static bool ufshcd_rpm_ok_for_spm(struct ufs_hba *hba)
 {
-	struct device *dev = &hba->sdev_ufs_device->sdev_gendev;
+	struct device *dev = &hba->ufs_device_wlun->sdev_gendev;
 	enum ufs_dev_pwr_mode dev_pwr_mode;
 	enum uic_link_state link_state;
 	unsigned long flags;
@@ -9794,7 +9794,7 @@ int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm)
 	 * if it's runtime suspended. But ufs doesn't follow that.
 	 * Refer ufshcd_resume_complete()
 	 */
-	if (hba->sdev_ufs_device) {
+	if (hba->ufs_device_wlun) {
 		/* Prevent runtime suspend */
 		ufshcd_rpm_get_noresume(hba);
 		/*
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 49edbdb5ffd6..14414225faa1 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -732,6 +732,7 @@ struct ufs_hba_monitor {
  * @utmrdl_dma_addr: UTMRDL DMA address
  * @host: Scsi_Host instance of the driver
  * @dev: device handle
+ * @ufs_device_wlun: WLUN that controls the entire UFS device.
  * @lrb: local reference block
  * @outstanding_tasks: Bits representing outstanding task requests
  * @outstanding_lock: Protects @outstanding_reqs.
@@ -799,11 +800,7 @@ struct ufs_hba {
 
 	struct Scsi_Host *host;
 	struct device *dev;
-	/*
-	 * This field is to keep a reference to "scsi_device" corresponding to
-	 * "UFS device" W-LU.
-	 */
-	struct scsi_device *sdev_ufs_device;
+	struct scsi_device *ufs_device_wlun;
 
 #ifdef CONFIG_SCSI_UFS_HWMON
 	struct device *hwmon_device;
@@ -1407,27 +1404,27 @@ static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba,
 
 static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba)
 {
-	return pm_runtime_get_sync(&hba->sdev_ufs_device->sdev_gendev);
+	return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
 }
 
 static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba)
 {
-	return pm_runtime_put_sync(&hba->sdev_ufs_device->sdev_gendev);
+	return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev);
 }
 
 static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba)
 {
-	pm_runtime_get_noresume(&hba->sdev_ufs_device->sdev_gendev);
+	pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev);
 }
 
 static inline int ufshcd_rpm_resume(struct ufs_hba *hba)
 {
-	return pm_runtime_resume(&hba->sdev_ufs_device->sdev_gendev);
+	return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev);
 }
 
 static inline int ufshcd_rpm_put(struct ufs_hba *hba)
 {
-	return pm_runtime_put(&hba->sdev_ufs_device->sdev_gendev);
+	return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
 }
 
 #endif /* End of Header */

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 17/29] scsi: ufs: Use an SPDX license identifier in the Kconfig file
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (15 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 16/29] scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-03-31 22:34 ` [PATCH 18/29] scsi: ufs: Remove paths from source code comments Bart Van Assche
                   ` (14 subsequent siblings)
  31 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Avri Altman, Bean Huo, Daejun Park,
	Geert Uytterhoeven, Krzysztof Kozlowski, Peter Wang

As requested in Documentation/process/license-rules.rst, use an SPDX
license identifier.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/Kconfig | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 9fe27b01904e..3ebcd5bbc344 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0+
 #
 # Kernel configuration file for the UFS Host Controller
 #
@@ -7,30 +8,6 @@
 # Authors:
 #	Santosh Yaraganavi <santosh.sy@samsung.com>
 #	Vinayak Holikatti <h.vinayak@samsung.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-# See the COPYING file in the top-level directory or visit
-# <http://www.gnu.org/licenses/gpl-2.0.html>
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# This program is provided "AS IS" and "WITH ALL FAULTS" and
-# without warranty of any kind. You are solely responsible for
-# determining the appropriateness of using and distributing
-# the program and assume all risks associated with your exercise
-# of rights with respect to the program, including but not limited
-# to infringement of third party rights, the risks and costs of
-# program errors, damage to or loss of data, programs or equipment,
-# and unavailability or interruption of operations. Under no
-# circumstances will the contributor of this Program be liable for
-# any damages of any kind arising from your use or distribution of
-# this program.
 
 config SCSI_UFSHCD
 	tristate "Universal Flash Storage Controller Driver Core"

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 18/29] scsi: ufs: Remove paths from source code comments
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (16 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 17/29] scsi: ufs: Use an SPDX license identifier in the Kconfig file Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-03  7:33   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 19/29] scsi: ufs: Remove the TRUE and FALSE definitions Bart Van Assche
                   ` (13 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Avri Altman, Stanley Chu,
	Geert Uytterhoeven, Peter Wang, Anders Roxell, Daejun Park,
	Krzysztof Kozlowski, Asutosh Das

Since specifying the path in a source file is redundant, remove the
paths from source code comments.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/Kconfig      | 1 -
 drivers/scsi/ufs/ufshcd-pci.c | 1 -
 drivers/scsi/ufs/unipro.h     | 2 --
 3 files changed, 4 deletions(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 3ebcd5bbc344..393b9a01da36 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -2,7 +2,6 @@
 #
 # Kernel configuration file for the UFS Host Controller
 #
-# This code is based on drivers/scsi/ufs/Kconfig
 # Copyright (C) 2011-2013 Samsung India Software Operations
 #
 # Authors:
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index 81aa14661072..d36873bc44fe 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -2,7 +2,6 @@
 /*
  * Universal Flash Storage Host controller PCI glue driver
  *
- * This code is based on drivers/scsi/ufs/ufshcd-pci.c
  * Copyright (C) 2011-2013 Samsung India Software Operations
  *
  * Authors:
diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
index 8e9e486a4f7b..bdd0fa6a3c74 100644
--- a/drivers/scsi/ufs/unipro.h
+++ b/drivers/scsi/ufs/unipro.h
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
- * drivers/scsi/ufs/unipro.h
- *
  * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  */
 

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 19/29] scsi: ufs: Remove the TRUE and FALSE definitions
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (17 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 18/29] scsi: ufs: Remove paths from source code comments Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-01  2:19   ` Chanho Park
  2022-03-31 22:34 ` [PATCH 20/29] scsi: ufs: Remove locking from around single register writes Bart Van Assche
                   ` (12 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Krzysztof Kozlowski, Chanho Park,
	Alim Akhtar, Bean Huo, Inki Dae, Avri Altman, Daejun Park,
	Can Guo, Asutosh Das

In the Linux kernel coding style document
(Documentation/process/coding-style.rst) it is recommended to use the type
'bool' and also the values 'true' and 'false'. Hence this patch that
removes the definitions and uses of TRUE and FALSE from the UFS driver.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-exynos.c |  4 ++--
 drivers/scsi/ufs/ufs-exynos.h |  8 ++++----
 drivers/scsi/ufs/ufshcd.c     |  8 ++++----
 drivers/scsi/ufs/unipro.h     | 14 --------------
 4 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 474a4a064a68..0b99c74955ef 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -704,7 +704,7 @@ static void exynos_ufs_establish_connt(struct exynos_ufs *ufs)
 
 	/* local unipro attributes */
 	ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID), DEV_ID);
-	ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), TRUE);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), true);
 	ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), PEER_DEV_ID);
 	ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERCPORTID), PEER_CPORT_ID);
 	ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), CPORT_DEF_FLAGS);
@@ -1028,7 +1028,7 @@ static int exynos_ufs_post_link(struct ufs_hba *hba)
 
 	if (ufs->opts & EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB)
 		ufshcd_dme_set(hba,
-			UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), TRUE);
+			UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), true);
 
 	if (attr->pa_granularity) {
 		exynos_ufs_enable_dbg_mode(hba);
diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
index 1c33e5466082..0b0a3d530ca6 100644
--- a/drivers/scsi/ufs/ufs-exynos.h
+++ b/drivers/scsi/ufs/ufs-exynos.h
@@ -248,22 +248,22 @@ long exynos_ufs_calc_time_cntr(struct exynos_ufs *, long);
 
 static inline void exynos_ufs_enable_ov_tm(struct ufs_hba *hba)
 {
-	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), TRUE);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), true);
 }
 
 static inline void exynos_ufs_disable_ov_tm(struct ufs_hba *hba)
 {
-	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), FALSE);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), false);
 }
 
 static inline void exynos_ufs_enable_dbg_mode(struct ufs_hba *hba)
 {
-	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), TRUE);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), true);
 }
 
 static inline void exynos_ufs_disable_dbg_mode(struct ufs_hba *hba)
 {
-	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), FALSE);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), false);
 }
 
 #endif /* _UFS_EXYNOS_H_ */
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c36658d97774..c81b5f3f0b9a 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4325,18 +4325,18 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba,
 			pwr_mode->lane_rx);
 	if (pwr_mode->pwr_rx == FASTAUTO_MODE ||
 			pwr_mode->pwr_rx == FAST_MODE)
-		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), TRUE);
+		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), true);
 	else
-		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), FALSE);
+		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), false);
 
 	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXGEAR), pwr_mode->gear_tx);
 	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_ACTIVETXDATALANES),
 			pwr_mode->lane_tx);
 	if (pwr_mode->pwr_tx == FASTAUTO_MODE ||
 			pwr_mode->pwr_tx == FAST_MODE)
-		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), TRUE);
+		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), true);
 	else
-		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), FALSE);
+		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), false);
 
 	if (pwr_mode->pwr_rx == FASTAUTO_MODE ||
 	    pwr_mode->pwr_tx == FASTAUTO_MODE ||
diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
index bdd0fa6a3c74..91152d8386e6 100644
--- a/drivers/scsi/ufs/unipro.h
+++ b/drivers/scsi/ufs/unipro.h
@@ -298,20 +298,6 @@ enum ufs_unipro_ver {
 #define T_TC0TXMAXSDUSIZE	0x4060
 #define T_TC1TXMAXSDUSIZE	0x4061
 
-#ifdef FALSE
-#undef FALSE
-#endif
-
-#ifdef TRUE
-#undef TRUE
-#endif
-
-/* Boolean attribute values */
-enum {
-	FALSE = 0,
-	TRUE,
-};
-
 /* CPort setting */
 #define E2EFC_ON	(1 << 0)
 #define E2EFC_OFF	(0 << 0)

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 20/29] scsi: ufs: Remove locking from around single register writes
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (18 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 19/29] scsi: ufs: Remove the TRUE and FALSE definitions Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-05  6:19   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 21/29] scsi: ufs: Introduce ufshcd_clkgate_delay_set() Bart Van Assche
                   ` (11 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Stanley Chu, James E.J. Bottomley, Matthias Brugger, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

Single register writes are atomic and hence do not need to be surrounded
by locking. Additionally, PCI bus writes are posted asynchronously and
hence there is no guarantee that these have finished by the time the
spin_unlock*() call has finished.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-mediatek.c | 8 --------
 drivers/scsi/ufs/ufshcd.c       | 4 ----
 2 files changed, 12 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 9a4474210627..2b26acc74efb 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -171,7 +171,6 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba,
 				     enum ufs_notify_change_status status)
 {
 	struct ufs_mtk_host *host = ufshcd_get_variant(hba);
-	unsigned long flags;
 
 	if (status == PRE_CHANGE) {
 		if (host->unipro_lpm) {
@@ -185,12 +184,8 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba,
 			ufs_mtk_crypto_enable(hba);
 
 		if (host->caps & UFS_MTK_CAP_DISABLE_AH8) {
-			spin_lock_irqsave(hba->host->host_lock, flags);
 			ufshcd_writel(hba, 0,
 				      REG_AUTO_HIBERNATE_IDLE_TIMER);
-			spin_unlock_irqrestore(hba->host->host_lock,
-					       flags);
-
 			hba->capabilities &= ~MASK_AUTO_HIBERN8_SUPPORT;
 			hba->ahit = 0;
 		}
@@ -994,13 +989,10 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 
 static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
 {
-	unsigned long flags;
 	int ret;
 
 	/* disable auto-hibern8 */
-	spin_lock_irqsave(hba->host->host_lock, flags);
 	ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
-	spin_unlock_irqrestore(hba->host->host_lock, flags);
 
 	/* wait host return to idle state when auto-hibern8 off */
 	ufs_mtk_wait_idle_state(hba, 5);
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c81b5f3f0b9a..d6af4d82dfed 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4207,14 +4207,10 @@ EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update);
 
 void ufshcd_auto_hibern8_enable(struct ufs_hba *hba)
 {
-	unsigned long flags;
-
 	if (!ufshcd_is_auto_hibern8_supported(hba))
 		return;
 
-	spin_lock_irqsave(hba->host->host_lock, flags);
 	ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);
-	spin_unlock_irqrestore(hba->host->host_lock, flags);
 }
 
  /**

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 21/29] scsi: ufs: Introduce ufshcd_clkgate_delay_set()
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (19 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 20/29] scsi: ufs: Remove locking from around single register writes Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-05  6:20   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 22/29] scsi: ufs: qcom: Fix ufs_qcom_resume() Bart Van Assche
                   ` (10 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Stanley Chu, James E.J. Bottomley, Matthias Brugger, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

Since the code to modify delay_ms while holding the host lock occurs
twice, introduce a function that performs this action.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-mediatek.c |  5 +----
 drivers/scsi/ufs/ufshcd.c       | 18 +++++++++++++-----
 drivers/scsi/ufs/ufshcd.h       |  2 ++
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 2b26acc74efb..d19b35495302 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -857,7 +857,6 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
 
 static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
 {
-	unsigned long flags;
 	u32 ah_ms;
 
 	if (ufshcd_is_clkgating_allowed(hba)) {
@@ -866,9 +865,7 @@ static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
 					  hba->ahit);
 		else
 			ah_ms = 10;
-		spin_lock_irqsave(hba->host->host_lock, flags);
-		hba->clk_gating.delay_ms = ah_ms + 5;
-		spin_unlock_irqrestore(hba->host->host_lock, flags);
+		ufshcd_clkgate_delay_set(hba->dev, ah_ms + 5);
 	}
 }
 
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index d6af4d82dfed..7d04cf8d75ef 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1864,18 +1864,26 @@ static ssize_t ufshcd_clkgate_delay_show(struct device *dev,
 	return sysfs_emit(buf, "%lu\n", hba->clk_gating.delay_ms);
 }
 
+void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value)
+{
+	struct ufs_hba *hba = dev_get_drvdata(dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(hba->host->host_lock, flags);
+	hba->clk_gating.delay_ms = value;
+	spin_unlock_irqrestore(hba->host->host_lock, flags);
+}
+EXPORT_SYMBOL_GPL(ufshcd_clkgate_delay_set);
+
 static ssize_t ufshcd_clkgate_delay_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
 {
-	struct ufs_hba *hba = dev_get_drvdata(dev);
-	unsigned long flags, value;
+	unsigned long value;
 
 	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
-	spin_lock_irqsave(hba->host->host_lock, flags);
-	hba->clk_gating.delay_ms = value;
-	spin_unlock_irqrestore(hba->host->host_lock, flags);
+	ufshcd_clkgate_delay_set(dev, value);
 	return count;
 }
 
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 14414225faa1..3eb5d2c17e39 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -1186,6 +1186,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
 int ufshcd_hold(struct ufs_hba *hba, bool async);
 void ufshcd_release(struct ufs_hba *hba);
 
+void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value);
+
 void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
 				  int *desc_length);
 

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 22/29] scsi: ufs: qcom: Fix ufs_qcom_resume()
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (20 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 21/29] scsi: ufs: Introduce ufshcd_clkgate_delay_set() Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-03-31 23:50   ` Bjorn Andersson
  2022-03-31 22:34 ` [PATCH 23/29] scsi: ufs: Remove unnecessary ufshcd-crypto.h include directives Bart Van Assche
                   ` (9 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Andy Gross, Bjorn Andersson, James E.J. Bottomley,
	Dov Levenglick

Clearing hba->is_sys_suspended if ufs_qcom_resume() succeeds is wrong. That
variable must only be cleared if all actions involved in a resume succeed.
Hence remove the statement that clears hba->is_sys_suspended from
ufs_qcom_resume().

Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-qcom.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index f24210652fe9..808dae751527 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -640,12 +640,7 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 			return err;
 	}
 
-	err = ufs_qcom_ice_resume(host);
-	if (err)
-		return err;
-
-	hba->is_sys_suspended = false;
-	return 0;
+	return ufs_qcom_ice_resume(host);
 }
 
 static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable)

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 23/29] scsi: ufs: Remove unnecessary ufshcd-crypto.h include directives
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (21 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 22/29] scsi: ufs: qcom: Fix ufs_qcom_resume() Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-03-31 22:34 ` [PATCH 24/29] scsi: ufs: Fix kernel-doc syntax in ufshcd.h Bart Van Assche
                   ` (8 subsequent siblings)
  31 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	Stanley Chu, James E.J. Bottomley, Andy Gross, Bjorn Andersson,
	Matthias Brugger

ufshcd-crypto.h declares functions that must only be called by the UFS
core. Hence remove the #include "ufshcd-crypto.h" directive from UFS
drivers.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-mediatek.c | 1 -
 drivers/scsi/ufs/ufs-qcom-ice.c | 1 -
 drivers/scsi/ufs/ufs-qcom.h     | 1 +
 3 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index d19b35495302..84ccb5258736 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -19,7 +19,6 @@
 #include <linux/soc/mediatek/mtk_sip_svc.h>
 
 #include "ufshcd.h"
-#include "ufshcd-crypto.h"
 #include "ufshcd-pltfrm.h"
 #include "ufs_quirks.h"
 #include "unipro.h"
diff --git a/drivers/scsi/ufs/ufs-qcom-ice.c b/drivers/scsi/ufs/ufs-qcom-ice.c
index bbb0ad7590ec..921d6a93b653 100644
--- a/drivers/scsi/ufs/ufs-qcom-ice.c
+++ b/drivers/scsi/ufs/ufs-qcom-ice.c
@@ -9,7 +9,6 @@
 #include <linux/platform_device.h>
 #include <linux/qcom_scm.h>
 
-#include "ufshcd-crypto.h"
 #include "ufs-qcom.h"
 
 #define AES_256_XTS_KEY_SIZE			64
diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h
index 51570224a6e2..771bc95d02c7 100644
--- a/drivers/scsi/ufs/ufs-qcom.h
+++ b/drivers/scsi/ufs/ufs-qcom.h
@@ -7,6 +7,7 @@
 
 #include <linux/reset-controller.h>
 #include <linux/reset.h>
+#include "ufshcd.h"
 
 #define MAX_UFS_QCOM_HOSTS	1
 #define MAX_U32                 (~(u32)0)

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 24/29] scsi: ufs: Fix kernel-doc syntax in ufshcd.h
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (22 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 23/29] scsi: ufs: Remove unnecessary ufshcd-crypto.h include directives Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-05  6:27   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 25/29] scsi: ufs: Minimize #include directives Bart Van Assche
                   ` (7 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Daejun Park, Avri Altman,
	Can Guo, Asutosh Das

This patch fixes all the warnings and errors reported by the following
command:

scripts/kernel-doc -none drivers/scsi/ufs/ufshcd.h

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.h | 89 ++++++++++++++++++++++++++++++---------
 1 file changed, 68 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 3eb5d2c17e39..412fe43cd763 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -236,6 +236,7 @@ struct ufs_query {
  * @type: device management command type - Query, NOP OUT
  * @lock: lock to allow one command at a time
  * @complete: internal commands completion
+ * @query: Device management query information
  */
 struct ufs_dev_cmd {
 	enum dev_cmd_type type;
@@ -253,7 +254,7 @@ struct ufs_dev_cmd {
  * @min_freq: min frequency that can be used for clock scaling
  * @curr_freq: indicates the current frequency that it is set to
  * @keep_link_active: indicates that the clk should not be disabled if
-		      link is active
+ *		      link is active
  * @enabled: variable to check against multiple enable/disable
  */
 struct ufs_clk_info {
@@ -308,11 +309,13 @@ struct ufs_pwr_mode_info {
  *                  to set some things
  * @hibern8_notify: called around hibern8 enter/exit
  * @apply_dev_quirks: called to apply device specific quirks
+ * @fixup_dev_quirks: called to modify device specific quirks
  * @suspend: called during host controller PM callback
  * @resume: called during host controller PM callback
  * @dbg_register_dump: used to dump controller debug information
  * @phy_initialization: used to initialize phys
  * @device_reset: called to issue a reset pulse on the UFS device
+ * @config_scaling_param: called to configure clock scaling parameters
  * @program_key: program or evict an inline encryption key
  * @event_notify: called to notify important events
  */
@@ -379,6 +382,7 @@ enum clk_gating_state {
  * @is_initialized: Indicates whether clock gating is initialized or not
  * @active_reqs: number of requests that are pending and should be waited for
  * completion before gating clocks.
+ * @clk_gating_workq: workqueue for clock gating work.
  */
 struct ufs_clk_gating {
 	struct delayed_work gate_work;
@@ -415,9 +419,9 @@ struct ufs_saved_pwr_info {
  * @resume_work: worker to resume devfreq
  * @min_gear: lowest HS gear to scale down to
  * @is_enabled: tracks if scaling is currently enabled or not, controlled by
-		clkscale_enable sysfs node
+ *		clkscale_enable sysfs node
  * @is_allowed: tracks if scaling is currently allowed or not, used to block
-		clock scaling which is not invoked from devfreq governor
+ *		clock scaling which is not invoked from devfreq governor
  * @is_initialized: Indicates whether clock scaling is initialized or not
  * @is_busy_started: tracks if busy period has started or not
  * @is_suspended: tracks if devfreq is suspended or not
@@ -444,7 +448,7 @@ struct ufs_clk_scaling {
 /**
  * struct ufs_event_hist - keeps history of errors
  * @pos: index to indicate cyclic buffer position
- * @reg: cyclic buffer for registers value
+ * @val: cyclic buffer for registers value
  * @tstamp: cyclic buffer for time stamp
  * @cnt: error counter
  */
@@ -463,6 +467,7 @@ struct ufs_event_hist {
  *		reset this after link-startup.
  * @last_hibern8_exit_tstamp: Set time after the hibern8 exit.
  *		Clear after the first successful command completion.
+ * @event: array with event history.
  */
 struct ufs_stats {
 	u32 last_intr_status;
@@ -733,6 +738,13 @@ struct ufs_hba_monitor {
  * @host: Scsi_Host instance of the driver
  * @dev: device handle
  * @ufs_device_wlun: WLUN that controls the entire UFS device.
+ * @hwmon_device: device instance registered with the hwmon core.
+ * @curr_dev_pwr_mode: active UFS device power mode.
+ * @uic_link_state: active state of the link to the UFS device.
+ * @rpm_lvl: desired UFS power management level during runtime PM.
+ * @spm_lvl: desired UFS power management level during system PM.
+ * @pm_op_in_progress: whether or not a PM operation is in progress.
+ * @ahit: value of Auto-Hibernate Idle Timer register.
  * @lrb: local reference block
  * @outstanding_tasks: Bits representing outstanding task requests
  * @outstanding_lock: Protects @outstanding_reqs.
@@ -743,17 +755,26 @@ struct ufs_hba_monitor {
  * @reserved_slot: Used to submit device commands. Protected by @dev_cmd.lock.
  * @ufs_version: UFS Version to which controller complies
  * @vops: pointer to variant specific operations
+ * @vps: pointer to variant specific parameters
  * @priv: pointer to variant specific private data
  * @irq: Irq number of the controller
- * @active_uic_cmd: handle of active UIC command
- * @uic_cmd_mutex: mutex for UIC command
+ * @is_irq_enabled: whether or not the UFS controller interrupt is enabled.
+ * @dev_ref_clk_freq: reference clock frequency
+ * @quirks: bitmask with information about deviations from the UFSHCI standard.
+ * @dev_quirks: bitmask with information about deviations from the UFS standard.
  * @tmf_tag_set: TMF tag set.
  * @tmf_queue: Used to allocate TMF tags.
- * @pwr_done: completion for power mode change
+ * @tmf_rqs: array with pointers to TMF requests while these are in progress.
+ * @active_uic_cmd: handle of active UIC command
+ * @uic_cmd_mutex: mutex for UIC command
+ * @uic_async_done: completion used during UIC processing
  * @ufshcd_state: UFSHCD state
  * @eh_flags: Error handling flags
  * @intr_mask: Interrupt Mask Bits
  * @ee_ctrl_mask: Exception event control mask
+ * @ee_drv_mask: Exception event mask for driver
+ * @ee_usr_mask: Exception event mask for user (set via debugfs)
+ * @ee_ctrl_mutex: Used to serialize exception event information.
  * @is_powered: flag to check if HBA is powered
  * @shutting_down: flag to check if shutdown has been invoked
  * @host_sem: semaphore used to serialize concurrent contexts
@@ -764,26 +785,52 @@ struct ufs_hba_monitor {
  * @uic_error: UFS interconnect layer error status
  * @saved_err: sticky error mask
  * @saved_uic_err: sticky UIC error mask
+ * @ufs_stats: various error counters
  * @force_reset: flag to force eh_work perform a full reset
  * @force_pmc: flag to force a power mode change
  * @silence_err_logs: flag to silence error logs
  * @dev_cmd: ufs device management command information
  * @last_dme_cmd_tstamp: time stamp of the last completed DME command
+ * @nop_out_timeout: NOP OUT timeout value
+ * @dev_info: information about the UFS device
  * @auto_bkops_enabled: to track whether bkops is enabled in device
  * @vreg_info: UFS device voltage regulator information
  * @clk_list_head: UFS host controller clocks list node head
+ * @req_abort_count: number of times ufshcd_abort() has been called
+ * @lanes_per_direction: number of lanes per data direction between the UFS
+ *	controller and the UFS device.
  * @pwr_info: holds current power mode
  * @max_pwr_info: keeps the device max valid pwm
- * @clk_scaling_lock: used to serialize device commands and clock scaling
- * @desc_size: descriptor sizes reported by device
+ * @clk_gating: information related to clock gating
+ * @caps: bitmask with information about UFS controller capabilities
+ * @devfreq: frequency scaling information owned by the devfreq core
+ * @clk_scaling: frequency scaling information owned by the UFS driver
+ * @is_sys_suspended: whether or not the entire system has been suspended
  * @urgent_bkops_lvl: keeps track of urgent bkops level for device
  * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for
  *  device is known or not.
+ * @clk_scaling_lock: used to serialize device commands and clock scaling
+ * @desc_size: descriptor sizes reported by device
  * @scsi_block_reqs_cnt: reference counting for scsi block requests
+ * @bsg_dev: struct device associated with the BSG queue
+ * @bsg_queue: BSG queue associated with the UFS controller
+ * @rpm_dev_flush_recheck_work: used to suspend from RPM (runtime power
+ *	management) after the UFS device has finished a WriteBooster buffer
+ *	flush or auto BKOP.
+ * @ufshpb_dev: information related to HPB (Host Performance Booster).
+ * @monitor: statistics about UFS commands
  * @crypto_capabilities: Content of crypto capabilities register (0x100)
  * @crypto_cap_array: Array of crypto capabilities
  * @crypto_cfg_register: Start of the crypto cfg array
  * @crypto_profile: the crypto profile of this hba (if applicable)
+ * @debugfs_root: UFS controller debugfs root directory
+ * @debugfs_ee_work: used to restore ee_ctrl_mask after a delay
+ * @debugfs_ee_rate_limit_ms: user configurable delay after which to restore
+ *	ee_ctrl_mask
+ * @luns_avail: number of regular and well known LUNs supported by the UFS
+ *	device
+ * @complete_put: whether or not to call ufshcd_rpm_put() from inside
+ *	ufshcd_resume_complete()
  */
 struct ufs_hba {
 	void __iomem *mmio_base;
@@ -853,9 +900,9 @@ struct ufs_hba {
 	enum ufshcd_state ufshcd_state;
 	u32 eh_flags;
 	u32 intr_mask;
-	u16 ee_ctrl_mask; /* Exception event mask */
-	u16 ee_drv_mask;  /* Exception event mask for driver */
-	u16 ee_usr_mask;  /* Exception event mask for user (via debugfs) */
+	u16 ee_ctrl_mask;
+	u16 ee_drv_mask;
+	u16 ee_usr_mask;
 	struct mutex ee_ctrl_mutex;
 	bool is_powered;
 	bool shutting_down;
@@ -996,11 +1043,11 @@ static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba)
 	readl((hba)->mmio_base + (reg))
 
 /**
- * ufshcd_rmwl - read modify write into a register
- * @hba - per adapter instance
- * @mask - mask to apply on read value
- * @val - actual value to write
- * @reg - register address
+ * ufshcd_rmwl - perform read/modify/write for a controller register
+ * @hba: per adapter instance
+ * @mask: mask to apply on read value
+ * @val: actual value to write
+ * @reg: register address
  */
 static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg)
 {
@@ -1035,8 +1082,8 @@ static inline void check_upiu_size(void)
 
 /**
  * ufshcd_set_variant - set variant specific data to the hba
- * @hba - per adapter instance
- * @variant - pointer to variant specific data
+ * @hba: per adapter instance
+ * @variant: pointer to variant specific data
  */
 static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant)
 {
@@ -1046,7 +1093,7 @@ static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant)
 
 /**
  * ufshcd_get_variant - get variant specific data from the hba
- * @hba - per adapter instance
+ * @hba: per adapter instance
  */
 static inline void *ufshcd_get_variant(struct ufs_hba *hba)
 {
@@ -1367,7 +1414,7 @@ static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
 
 extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
 
-/*
+/**
  * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN
  * @scsi_lun: scsi LUN id
  *

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 25/29] scsi: ufs: Minimize #include directives
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (23 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 24/29] scsi: ufs: Fix kernel-doc syntax in ufshcd.h Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-01  6:53   ` Adrian Hunter
  2022-03-31 22:34 ` [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file Bart Van Assche
                   ` (6 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Krzysztof Kozlowski, Stanley Chu,
	Andy Gross, Bjorn Andersson, Matthias Brugger, Asutosh Das,
	Avri Altman, Daejun Park, Chanho Park, Alim Akhtar, Bean Huo,
	Peter Wang, Phillip Potter, Greg Kroah-Hartman, Can Guo,
	Keoseong Park, Ulf Hansson, Eric Biggers, Mike Snitzer,
	Srinivas Kandagatla, Xiaoke Wang, Sergey Shtylyov,
	Gustavo A. R. Silva, Kiwoong Kim

Only include those headers of which the declarations are used directly.
Sort #include directives alphabetically.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/cdns-pltfrm.c         |  4 ++--
 drivers/scsi/ufs/tc-dwc-g210-pci.c     |  8 +++----
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c  | 10 ++++----
 drivers/scsi/ufs/tc-dwc-g210.c         |  8 +++----
 drivers/scsi/ufs/tc-dwc-g210.h         |  2 ++
 drivers/scsi/ufs/ufs-exynos.c          |  1 +
 drivers/scsi/ufs/ufs-fault-injection.c |  4 ++--
 drivers/scsi/ufs/ufs-hisi.c            | 15 ++++++------
 drivers/scsi/ufs/ufs-mediatek.c        |  4 +++-
 drivers/scsi/ufs/ufs-qcom-ice.c        |  2 +-
 drivers/scsi/ufs/ufs-qcom.c            | 23 ++++++++++--------
 drivers/scsi/ufs/ufs-sysfs.c           |  8 +++----
 drivers/scsi/ufs/ufs-sysfs.h           |  3 ++-
 drivers/scsi/ufs/ufs_bsg.c             |  5 ++++
 drivers/scsi/ufs/ufs_bsg.h             |  7 +-----
 drivers/scsi/ufs/ufshcd-crypto.h       |  5 ++--
 drivers/scsi/ufs/ufshcd-dwc.c          |  6 ++---
 drivers/scsi/ufs/ufshcd-dwc.h          |  2 ++
 drivers/scsi/ufs/ufshcd-pci.c          | 12 ++++++----
 drivers/scsi/ufs/ufshcd-pltfrm.c       |  4 ++--
 drivers/scsi/ufs/ufshcd.c              | 24 ++++++++++++-------
 drivers/scsi/ufs/ufshcd.h              | 33 ++++----------------------
 drivers/scsi/ufs/ufshci.h              |  2 ++
 drivers/scsi/ufs/ufshpb.c              |  7 ++++--
 24 files changed, 101 insertions(+), 98 deletions(-)

diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c
index e91cf9fd5a95..4d05a3b1e4eb 100644
--- a/drivers/scsi/ufs/cdns-pltfrm.c
+++ b/drivers/scsi/ufs/cdns-pltfrm.c
@@ -9,12 +9,12 @@
  *
  */
 
+#include <linux/clk.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/time.h>
-
 #include "ufshcd-pltfrm.h"
 
 #define CDNS_UFS_REG_HCLKDIV	0xFC
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c b/drivers/scsi/ufs/tc-dwc-g210-pci.c
index 7b08e2e07cc5..d679eff3f2f0 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pci.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -7,12 +7,12 @@
  * Authors: Joao Pinto <jpinto@synopsys.com>
  */
 
-#include "ufshcd.h"
-#include "ufshcd-dwc.h"
-#include "tc-dwc-g210.h"
-
+#include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/pm_runtime.h>
+#include "tc-dwc-g210.h"
+#include "ufshcd-dwc.h"
+#include "ufshcd.h"
 
 /* Test Chip type expected values */
 #define TC_G210_20BIT 20
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
index 783ec43efa78..56468268deb8 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
@@ -7,15 +7,15 @@
  * Authors: Joao Pinto <jpinto@synopsys.com>
  */
 
+#include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/platform_device.h>
 #include <linux/of.h>
-#include <linux/delay.h>
-
-#include "ufshcd-pltfrm.h"
-#include "ufshcd-dwc.h"
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include "tc-dwc-g210.h"
+#include "ufshcd-dwc.h"
+#include "ufshcd-pltfrm.h"
 
 /*
  * UFS DWC specific variant operations
diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
index f954a68f6b4c..c1b236f09601 100644
--- a/drivers/scsi/ufs/tc-dwc-g210.c
+++ b/drivers/scsi/ufs/tc-dwc-g210.c
@@ -7,12 +7,12 @@
  * Authors: Joao Pinto <jpinto@synopsys.com>
  */
 
-#include "ufshcd.h"
-#include "unipro.h"
-
+#include <linux/module.h>
+#include "tc-dwc-g210.h"
 #include "ufshcd-dwc.h"
+#include "ufshcd.h"
 #include "ufshci-dwc.h"
-#include "tc-dwc-g210.h"
+#include "unipro.h"
 
 /**
  * tc_dwc_g210_setup_40bit_rmmi()
diff --git a/drivers/scsi/ufs/tc-dwc-g210.h b/drivers/scsi/ufs/tc-dwc-g210.h
index 5a506da03f4a..f7154012f5c7 100644
--- a/drivers/scsi/ufs/tc-dwc-g210.h
+++ b/drivers/scsi/ufs/tc-dwc-g210.h
@@ -10,6 +10,8 @@
 #ifndef _TC_DWC_G210_H
 #define _TC_DWC_G210_H
 
+struct ufs_hba;
+
 int tc_dwc_g210_config_40_bit(struct ufs_hba *hba);
 int tc_dwc_g210_config_20_bit(struct ufs_hba *hba);
 
diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 0b99c74955ef..ddb2d42605c5 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
diff --git a/drivers/scsi/ufs/ufs-fault-injection.c b/drivers/scsi/ufs/ufs-fault-injection.c
index 7ac7c4e7ff83..2453ea8ff265 100644
--- a/drivers/scsi/ufs/ufs-fault-injection.c
+++ b/drivers/scsi/ufs/ufs-fault-injection.c
@@ -1,9 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 
-#include <linux/kconfig.h>
-#include <linux/types.h>
 #include <linux/fault-inject.h>
+#include <linux/kconfig.h>
 #include <linux/module.h>
+#include <linux/types.h>
 #include "ufs-fault-injection.h"
 
 static int ufs_fault_get(char *buffer, const struct kernel_param *kp);
diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c
index ab1a7ebd89b1..8f6168471464 100644
--- a/drivers/scsi/ufs/ufs-hisi.c
+++ b/drivers/scsi/ufs/ufs-hisi.c
@@ -6,19 +6,20 @@
  * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
  */
 
-#include <linux/time.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
-
-#include "ufshcd.h"
-#include "ufshcd-pltfrm.h"
-#include "unipro.h"
+#include <linux/time.h>
 #include "ufs-hisi.h"
-#include "ufshci.h"
 #include "ufs_quirks.h"
+#include "ufshcd-pltfrm.h"
+#include "ufshcd.h"
+#include "ufshci.h"
+#include "unipro.h"
 
 static int ufs_hisi_check_hibern8(struct ufs_hba *hba)
 {
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 84ccb5258736..b804e969915b 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -8,6 +8,9 @@
 
 #include <linux/arm-smccc.h>
 #include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
@@ -17,7 +20,6 @@
 #include <linux/reset.h>
 #include <linux/sched/clock.h>
 #include <linux/soc/mediatek/mtk_sip_svc.h>
-
 #include "ufshcd.h"
 #include "ufshcd-pltfrm.h"
 #include "ufs_quirks.h"
diff --git a/drivers/scsi/ufs/ufs-qcom-ice.c b/drivers/scsi/ufs/ufs-qcom-ice.c
index 921d6a93b653..ee73c1b0d96b 100644
--- a/drivers/scsi/ufs/ufs-qcom-ice.c
+++ b/drivers/scsi/ufs/ufs-qcom-ice.c
@@ -6,9 +6,9 @@
  * Copyright 2019 Google LLC
  */
 
+#include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/qcom_scm.h>
-
 #include "ufs-qcom.h"
 
 #define AES_256_XTS_KEY_SIZE			64
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 808dae751527..9a390cd516bd 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -4,21 +4,24 @@
  */
 
 #include <linux/acpi.h>
-#include <linux/time.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/devfreq.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
 #include <linux/of.h>
-#include <linux/platform_device.h>
 #include <linux/phy/phy.h>
-#include <linux/gpio/consumer.h>
+#include <linux/platform_device.h>
 #include <linux/reset-controller.h>
-#include <linux/devfreq.h>
-
-#include "ufshcd.h"
-#include "ufshcd-pltfrm.h"
-#include "unipro.h"
+#include <linux/time.h>
 #include "ufs-qcom.h"
-#include "ufshci.h"
 #include "ufs_quirks.h"
-#define UFS_QCOM_DEFAULT_DBG_PRINT_EN	\
+#include "ufshcd-pltfrm.h"
+#include "ufshcd.h"
+#include "ufshci.h"
+#include "unipro.h"
+
+#define UFS_QCOM_DEFAULT_DBG_PRINT_EN					\
 	(UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_TEST_BUS_EN)
 
 enum {
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index 5c405ff7b6ea..2bf128e4b613 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -1,13 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2018 Western Digital Corporation
 
+#include <asm/unaligned.h>
+#include <linux/bitfield.h>
 #include <linux/err.h>
 #include <linux/string.h>
-#include <linux/bitfield.h>
-#include <asm/unaligned.h>
-
-#include "ufs.h"
 #include "ufs-sysfs.h"
+#include "ufs.h"
+#include "ufshcd.h"
 
 static const char *ufshcd_uic_link_state_to_string(
 			enum uic_link_state state)
diff --git a/drivers/scsi/ufs/ufs-sysfs.h b/drivers/scsi/ufs/ufs-sysfs.h
index 0f4e750a6748..8d94af3b8077 100644
--- a/drivers/scsi/ufs/ufs-sysfs.h
+++ b/drivers/scsi/ufs/ufs-sysfs.h
@@ -7,11 +7,12 @@
 
 #include <linux/sysfs.h>
 
-#include "ufshcd.h"
+struct device;
 
 void ufs_sysfs_add_nodes(struct device *dev);
 void ufs_sysfs_remove_nodes(struct device *dev);
 
 extern const struct attribute_group ufs_sysfs_unit_descriptor_group;
 extern const struct attribute_group ufs_sysfs_lun_attributes_group;
+
 #endif
diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c
index 39bf204c6ec3..fbcdfb713542 100644
--- a/drivers/scsi/ufs/ufs_bsg.c
+++ b/drivers/scsi/ufs/ufs_bsg.c
@@ -4,7 +4,12 @@
  *
  * Copyright (C) 2018 Western Digital Corporation
  */
+
+#include <linux/bsg-lib.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_host.h>
 #include "ufs_bsg.h"
+#include "ufshcd.h"
 
 static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
 				       struct utp_upiu_query *qr)
diff --git a/drivers/scsi/ufs/ufs_bsg.h b/drivers/scsi/ufs/ufs_bsg.h
index d09918758631..57712d2656d2 100644
--- a/drivers/scsi/ufs/ufs_bsg.h
+++ b/drivers/scsi/ufs/ufs_bsg.h
@@ -5,12 +5,7 @@
 #ifndef UFS_BSG_H
 #define UFS_BSG_H
 
-#include <linux/bsg-lib.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
-
-#include "ufshcd.h"
-#include "ufs.h"
+struct ufs_hba;
 
 #ifdef CONFIG_SCSI_UFS_BSG
 void ufs_bsg_remove(struct ufs_hba *hba);
diff --git a/drivers/scsi/ufs/ufshcd-crypto.h b/drivers/scsi/ufs/ufshcd-crypto.h
index e18c01276873..57dd51256b57 100644
--- a/drivers/scsi/ufs/ufshcd-crypto.h
+++ b/drivers/scsi/ufs/ufshcd-crypto.h
@@ -6,9 +6,10 @@
 #ifndef _UFSHCD_CRYPTO_H
 #define _UFSHCD_CRYPTO_H
 
-#ifdef CONFIG_SCSI_UFS_CRYPTO
+#include <scsi/scsi_cmnd.h>
 #include "ufshcd.h"
-#include "ufshci.h"
+
+#ifdef CONFIG_SCSI_UFS_CRYPTO
 
 static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
 					      struct ufshcd_lrb *lrbp)
diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs/ufshcd-dwc.c
index 5bb9d3a88795..8f1786be3556 100644
--- a/drivers/scsi/ufs/ufshcd-dwc.c
+++ b/drivers/scsi/ufs/ufshcd-dwc.c
@@ -7,11 +7,11 @@
  * Authors: Joao Pinto <jpinto@synopsys.com>
  */
 
-#include "ufshcd.h"
-#include "unipro.h"
-
+#include <linux/module.h>
 #include "ufshcd-dwc.h"
+#include "ufshcd.h"
 #include "ufshci-dwc.h"
+#include "unipro.h"
 
 int ufshcd_dwc_dme_set_attrs(struct ufs_hba *hba,
 				const struct ufshcd_dme_attr_val *v, int n)
diff --git a/drivers/scsi/ufs/ufshcd-dwc.h b/drivers/scsi/ufs/ufshcd-dwc.h
index 4268ca2eb64c..43b70794e24f 100644
--- a/drivers/scsi/ufs/ufshcd-dwc.h
+++ b/drivers/scsi/ufs/ufshcd-dwc.h
@@ -10,6 +10,8 @@
 #ifndef _UFSHCD_DWC_H
 #define _UFSHCD_DWC_H
 
+#include "ufshcd.h"
+
 struct ufshcd_dme_attr_val {
 	u32 attr_sel;
 	u32 mib_val;
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index d36873bc44fe..45df431c720c 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -9,14 +9,16 @@
  *	Vinayak Holikatti <h.vinayak@samsung.com>
  */
 
-#include "ufshcd.h"
+#include <linux/acpi.h>
+#include <linux/debugfs.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
 #include <linux/pci.h>
-#include <linux/pm_runtime.h>
 #include <linux/pm_qos.h>
-#include <linux/debugfs.h>
+#include <linux/pm_runtime.h>
 #include <linux/uuid.h>
-#include <linux/acpi.h>
-#include <linux/gpio/consumer.h>
+#include "ufshcd.h"
 
 struct ufs_host {
 	void (*late_init)(struct ufs_hba *hba);
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 81e458d31222..a1ff5bfd4f71 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -8,10 +8,10 @@
  *	Vinayak Holikatti <h.vinayak@samsung.com>
  */
 
+#include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-#include <linux/of.h>
-
 #include "ufshcd.h"
 #include "ufshcd-pltfrm.h"
 #include "unipro.h"
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 7d04cf8d75ef..de366247628b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -9,24 +9,32 @@
  *	Vinayak Holikatti <h.vinayak@samsung.com>
  */
 
+#include <asm/unaligned.h>
 #include <linux/async.h>
-#include <linux/devfreq.h>
-#include <linux/nls.h>
-#include <linux/of.h>
 #include <linux/bitfield.h>
 #include <linux/blk-pm.h>
 #include <linux/blkdev.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/devfreq.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/nls.h>
+#include <linux/of.h>
+#include <linux/regulator/consumer.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_dbg.h>
 #include <scsi/scsi_driver.h>
-#include "ufshcd.h"
-#include "ufs_quirks.h"
-#include "unipro.h"
-#include "ufs-sysfs.h"
+#include <scsi/scsi_eh.h>
 #include "ufs-debugfs.h"
 #include "ufs-fault-injection.h"
+#include "ufs-sysfs.h"
 #include "ufs_bsg.h"
+#include "ufs_quirks.h"
 #include "ufshcd-crypto.h"
+#include "ufshcd.h"
 #include "ufshpb.h"
-#include <asm/unaligned.h>
+#include "unipro.h"
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/ufs.h>
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 412fe43cd763..ab0c643296c0 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -12,38 +12,13 @@
 #ifndef _UFSHCD_H
 #define _UFSHCD_H
 
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/rwsem.h>
-#include <linux/workqueue.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/wait.h>
-#include <linux/bitops.h>
-#include <linux/pm_runtime.h>
-#include <linux/clk.h>
-#include <linux/completion.h>
-#include <linux/regulator/consumer.h>
 #include <linux/bitfield.h>
-#include <linux/devfreq.h>
 #include <linux/blk-crypto-profile.h>
+#include <linux/blk-mq.h>
+#include <linux/devfreq.h>
+#include <linux/pm_runtime.h>
+#include <scsi/scsi_device.h>
 #include "unipro.h"
-
-#include <asm/irq.h>
-#include <asm/byteorder.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
-#include <scsi/scsi_host.h>
-#include <scsi/scsi_tcq.h>
-#include <scsi/scsi_dbg.h>
-#include <scsi/scsi_eh.h>
-
 #include "ufs.h"
 #include "ufs_quirks.h"
 #include "ufshci.h"
diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index a7ff0e5b5494..f81aa95ffbc4 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -11,6 +11,8 @@
 #ifndef _UFSHCI_H
 #define _UFSHCI_H
 
+#include <scsi/scsi_host.h>
+
 enum {
 	TASK_REQ_UPIU_SIZE_DWORDS	= 8,
 	TASK_RSP_UPIU_SIZE_DWORDS	= 8,
diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c
index b2bec19022cd..d456404e5c49 100644
--- a/drivers/scsi/ufs/ufshpb.c
+++ b/drivers/scsi/ufs/ufshpb.c
@@ -10,10 +10,13 @@
  */
 
 #include <asm/unaligned.h>
-
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <scsi/scsi_cmnd.h>
+#include "../sd.h"
 #include "ufshcd.h"
 #include "ufshpb.h"
-#include "../sd.h"
 
 #define ACTIVATION_THRESHOLD 8 /* 8 IOs */
 #define READ_TO_MS 1000

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (24 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 25/29] scsi: ufs: Minimize #include directives Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-01  0:21   ` Chanho Park
  2022-04-05  6:39   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 27/29] scsi: ufs: Move the struct ufs_ref_clk definition Bart Van Assche
                   ` (5 subsequent siblings)
  31 siblings, 2 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Avri Altman, Can Guo, Asutosh Das,
	Daejun Park, Guenter Roeck, Bean Huo, Keoseong Park,
	Mike Snitzer, Eric Biggers, Jens Axboe, Ulf Hansson

Split the ufshcd.h header file into a header file that defines the
interface used by UFS drivers and another header file with declarations
and data structures only used by the UFS core.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-debugfs.c   |   1 +
 drivers/scsi/ufs/ufs-hwmon.c     |   1 +
 drivers/scsi/ufs/ufs-sysfs.c     |   3 +-
 drivers/scsi/ufs/ufs_bsg.c       |   1 +
 drivers/scsi/ufs/ufshcd-crypto.h |   2 +
 drivers/scsi/ufs/ufshcd-priv.h   | 277 +++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshcd.c        |   1 +
 drivers/scsi/ufs/ufshcd.h        | 212 -----------------------
 drivers/scsi/ufs/ufshpb.c        |   1 +
 9 files changed, 285 insertions(+), 214 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-priv.h

diff --git a/drivers/scsi/ufs/ufs-debugfs.c b/drivers/scsi/ufs/ufs-debugfs.c
index 4a0bbcf1757a..c10a8f09682b 100644
--- a/drivers/scsi/ufs/ufs-debugfs.c
+++ b/drivers/scsi/ufs/ufs-debugfs.c
@@ -5,6 +5,7 @@
 
 #include "ufs-debugfs.h"
 #include "ufshcd.h"
+#include "ufshcd-priv.h"
 
 static struct dentry *ufs_debugfs_root;
 
diff --git a/drivers/scsi/ufs/ufs-hwmon.c b/drivers/scsi/ufs/ufs-hwmon.c
index 74855491dc8f..c38d9d98a86d 100644
--- a/drivers/scsi/ufs/ufs-hwmon.c
+++ b/drivers/scsi/ufs/ufs-hwmon.c
@@ -8,6 +8,7 @@
 #include <linux/units.h>
 
 #include "ufshcd.h"
+#include "ufshcd-priv.h"
 
 struct ufs_hwmon_data {
 	struct ufs_hba *hba;
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index 2bf128e4b613..97ab1a75e3b8 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -6,8 +6,7 @@
 #include <linux/err.h>
 #include <linux/string.h>
 #include "ufs-sysfs.h"
-#include "ufs.h"
-#include "ufshcd.h"
+#include "ufshcd-priv.h"
 
 static const char *ufshcd_uic_link_state_to_string(
 			enum uic_link_state state)
diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c
index fbcdfb713542..9e9b93867cab 100644
--- a/drivers/scsi/ufs/ufs_bsg.c
+++ b/drivers/scsi/ufs/ufs_bsg.c
@@ -10,6 +10,7 @@
 #include <scsi/scsi_host.h>
 #include "ufs_bsg.h"
 #include "ufshcd.h"
+#include "ufshcd-priv.h"
 
 static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
 				       struct utp_upiu_query *qr)
diff --git a/drivers/scsi/ufs/ufshcd-crypto.h b/drivers/scsi/ufs/ufshcd-crypto.h
index 57dd51256b57..9f98f18f9646 100644
--- a/drivers/scsi/ufs/ufshcd-crypto.h
+++ b/drivers/scsi/ufs/ufshcd-crypto.h
@@ -8,6 +8,8 @@
 
 #include <scsi/scsi_cmnd.h>
 #include "ufshcd.h"
+#include "ufshcd-priv.h"
+#include "ufshci.h"
 
 #ifdef CONFIG_SCSI_UFS_CRYPTO
 
diff --git a/drivers/scsi/ufs/ufshcd-priv.h b/drivers/scsi/ufs/ufshcd-priv.h
new file mode 100644
index 000000000000..4ceb0c63aa15
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-priv.h
@@ -0,0 +1,277 @@
+#ifndef _UFSHCD_PRIV_H_
+#define _UFSHCD_PRIV_H_
+
+#include <linux/pm_runtime.h>
+#include "ufshcd.h"
+
+static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba)
+{
+	return !hba->shutting_down;
+}
+
+void ufshcd_schedule_eh_work(struct ufs_hba *hba);
+
+static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
+							struct ufs_hba *hba)
+{
+	return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
+}
+
+static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba)
+{
+	if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED)
+		return hba->dev_info.wb_dedicated_lu;
+	return 0;
+}
+
+#ifdef CONFIG_SCSI_UFS_HWMON
+void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
+void ufs_hwmon_remove(struct ufs_hba *hba);
+void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask);
+#else
+static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
+static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
+static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {}
+#endif
+
+int ufshcd_read_desc_param(struct ufs_hba *hba,
+			   enum desc_idn desc_id,
+			   int desc_index,
+			   u8 param_offset,
+			   u8 *param_read_buf,
+			   u8 param_size);
+int ufshcd_query_attr_retry(struct ufs_hba *hba, enum query_opcode opcode,
+			    enum attr_idn idn, u8 index, u8 selector,
+			    u32 *attr_val);
+int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
+		      enum attr_idn idn, u8 index, u8 selector, u32 *attr_val);
+int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
+	enum flag_idn idn, u8 index, bool *flag_res);
+void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
+
+#define SD_ASCII_STD true
+#define SD_RAW false
+int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
+			    u8 **buf, bool ascii);
+
+int ufshcd_hold(struct ufs_hba *hba, bool async);
+void ufshcd_release(struct ufs_hba *hba);
+
+void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
+				  int *desc_length);
+
+int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd);
+
+int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
+			     struct utp_upiu_req *req_upiu,
+			     struct utp_upiu_req *rsp_upiu,
+			     int msgcode,
+			     u8 *desc_buff, int *buff_len,
+			     enum query_opcode desc_op);
+
+int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable);
+
+/* Wrapper functions for safely calling variant operations */
+static inline const char *ufshcd_get_var_name(struct ufs_hba *hba)
+{
+	if (hba->vops)
+		return hba->vops->name;
+	return "";
+}
+
+static inline void ufshcd_vops_exit(struct ufs_hba *hba)
+{
+	if (hba->vops && hba->vops->exit)
+		return hba->vops->exit(hba);
+}
+
+static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba)
+{
+	if (hba->vops && hba->vops->get_ufs_hci_version)
+		return hba->vops->get_ufs_hci_version(hba);
+
+	return ufshcd_readl(hba, REG_UFS_VERSION);
+}
+
+static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,
+			bool up, enum ufs_notify_change_status status)
+{
+	if (hba->vops && hba->vops->clk_scale_notify)
+		return hba->vops->clk_scale_notify(hba, up, status);
+	return 0;
+}
+
+static inline void ufshcd_vops_event_notify(struct ufs_hba *hba,
+					    enum ufs_event_type evt,
+					    void *data)
+{
+	if (hba->vops && hba->vops->event_notify)
+		hba->vops->event_notify(hba, evt, data);
+}
+
+static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,
+					enum ufs_notify_change_status status)
+{
+	if (hba->vops && hba->vops->setup_clocks)
+		return hba->vops->setup_clocks(hba, on, status);
+	return 0;
+}
+
+static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba,
+						bool status)
+{
+	if (hba->vops && hba->vops->hce_enable_notify)
+		return hba->vops->hce_enable_notify(hba, status);
+
+	return 0;
+}
+static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba,
+						bool status)
+{
+	if (hba->vops && hba->vops->link_startup_notify)
+		return hba->vops->link_startup_notify(hba, status);
+
+	return 0;
+}
+
+static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,
+				  enum ufs_notify_change_status status,
+				  struct ufs_pa_layer_attr *dev_max_params,
+				  struct ufs_pa_layer_attr *dev_req_params)
+{
+	if (hba->vops && hba->vops->pwr_change_notify)
+		return hba->vops->pwr_change_notify(hba, status,
+					dev_max_params, dev_req_params);
+
+	return -ENOTSUPP;
+}
+
+static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
+					int tag, u8 tm_function)
+{
+	if (hba->vops && hba->vops->setup_task_mgmt)
+		return hba->vops->setup_task_mgmt(hba, tag, tm_function);
+}
+
+static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
+					enum uic_cmd_dme cmd,
+					enum ufs_notify_change_status status)
+{
+	if (hba->vops && hba->vops->hibern8_notify)
+		return hba->vops->hibern8_notify(hba, cmd, status);
+}
+
+static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba)
+{
+	if (hba->vops && hba->vops->apply_dev_quirks)
+		return hba->vops->apply_dev_quirks(hba);
+	return 0;
+}
+
+static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba)
+{
+	if (hba->vops && hba->vops->fixup_dev_quirks)
+		hba->vops->fixup_dev_quirks(hba);
+}
+
+static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op,
+				enum ufs_notify_change_status status)
+{
+	if (hba->vops && hba->vops->suspend)
+		return hba->vops->suspend(hba, op, status);
+
+	return 0;
+}
+
+static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op)
+{
+	if (hba->vops && hba->vops->resume)
+		return hba->vops->resume(hba, op);
+
+	return 0;
+}
+
+static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
+{
+	if (hba->vops && hba->vops->dbg_register_dump)
+		hba->vops->dbg_register_dump(hba);
+}
+
+static inline int ufshcd_vops_device_reset(struct ufs_hba *hba)
+{
+	if (hba->vops && hba->vops->device_reset)
+		return hba->vops->device_reset(hba);
+
+	return -EOPNOTSUPP;
+}
+
+static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
+		struct devfreq_dev_profile *p,
+		struct devfreq_simple_ondemand_data *data)
+{
+	if (hba->vops && hba->vops->config_scaling_param)
+		hba->vops->config_scaling_param(hba, p, data);
+}
+
+extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
+
+/**
+ * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN
+ * @scsi_lun: scsi LUN id
+ *
+ * Returns UPIU LUN id
+ */
+static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun)
+{
+	if (scsi_is_wlun(scsi_lun))
+		return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID)
+			| UFS_UPIU_WLUN_ID;
+	else
+		return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID;
+}
+
+int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask);
+int ufshcd_write_ee_control(struct ufs_hba *hba);
+int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask,
+			     u16 set, u16 clr);
+
+static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba,
+					    u16 set, u16 clr)
+{
+	return ufshcd_update_ee_control(hba, &hba->ee_drv_mask,
+					&hba->ee_usr_mask, set, clr);
+}
+
+static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba,
+					    u16 set, u16 clr)
+{
+	return ufshcd_update_ee_control(hba, &hba->ee_usr_mask,
+					&hba->ee_drv_mask, set, clr);
+}
+
+static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba)
+{
+	return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba)
+{
+	return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba)
+{
+	pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+static inline int ufshcd_rpm_resume(struct ufs_hba *hba)
+{
+	return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+static inline int ufshcd_rpm_put(struct ufs_hba *hba)
+{
+	return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+#endif /* _UFSHCD_PRIV_H_ */
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index de366247628b..bab0f1ee41e6 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -32,6 +32,7 @@
 #include "ufs_bsg.h"
 #include "ufs_quirks.h"
 #include "ufshcd-crypto.h"
+#include "ufshcd-priv.h"
 #include "ufshcd.h"
 #include "ufshpb.h"
 #include "unipro.h"
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index ab0c643296c0..b13469fb1e15 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -1007,11 +1007,6 @@ static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba)
 	return hba->caps & UFSHCD_CAP_WB_EN;
 }
 
-static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba)
-{
-	return !hba->shutting_down;
-}
-
 #define ufshcd_writel(hba, val, reg)	\
 	writel((val), (hba)->mmio_base + (reg))
 #define ufshcd_readl(hba, reg)	\
@@ -1075,18 +1070,6 @@ static inline void *ufshcd_get_variant(struct ufs_hba *hba)
 	BUG_ON(!hba);
 	return hba->priv;
 }
-static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
-							struct ufs_hba *hba)
-{
-	return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
-}
-
-static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba)
-{
-	if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED)
-		return hba->dev_info.wb_dedicated_lu;
-	return 0;
-}
 
 #ifdef CONFIG_SCSI_UFS_HWMON
 void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
@@ -1230,13 +1213,6 @@ int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm);
 void ufshcd_resume_complete(struct device *dev);
 
 /* Wrapper functions for safely calling variant operations */
-static inline const char *ufshcd_get_var_name(struct ufs_hba *hba)
-{
-	if (hba->vops)
-		return hba->vops->name;
-	return "";
-}
-
 static inline int ufshcd_vops_init(struct ufs_hba *hba)
 {
 	if (hba->vops && hba->vops->init)
@@ -1245,61 +1221,6 @@ static inline int ufshcd_vops_init(struct ufs_hba *hba)
 	return 0;
 }
 
-static inline void ufshcd_vops_exit(struct ufs_hba *hba)
-{
-	if (hba->vops && hba->vops->exit)
-		return hba->vops->exit(hba);
-}
-
-static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba)
-{
-	if (hba->vops && hba->vops->get_ufs_hci_version)
-		return hba->vops->get_ufs_hci_version(hba);
-
-	return ufshcd_readl(hba, REG_UFS_VERSION);
-}
-
-static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,
-			bool up, enum ufs_notify_change_status status)
-{
-	if (hba->vops && hba->vops->clk_scale_notify)
-		return hba->vops->clk_scale_notify(hba, up, status);
-	return 0;
-}
-
-static inline void ufshcd_vops_event_notify(struct ufs_hba *hba,
-					    enum ufs_event_type evt,
-					    void *data)
-{
-	if (hba->vops && hba->vops->event_notify)
-		hba->vops->event_notify(hba, evt, data);
-}
-
-static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,
-					enum ufs_notify_change_status status)
-{
-	if (hba->vops && hba->vops->setup_clocks)
-		return hba->vops->setup_clocks(hba, on, status);
-	return 0;
-}
-
-static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba,
-						bool status)
-{
-	if (hba->vops && hba->vops->hce_enable_notify)
-		return hba->vops->hce_enable_notify(hba, status);
-
-	return 0;
-}
-static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba,
-						bool status)
-{
-	if (hba->vops && hba->vops->link_startup_notify)
-		return hba->vops->link_startup_notify(hba, status);
-
-	return 0;
-}
-
 static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)
 {
 	if (hba->vops && hba->vops->phy_initialization)
@@ -1308,102 +1229,8 @@ static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)
 	return 0;
 }
 
-static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,
-				  enum ufs_notify_change_status status,
-				  struct ufs_pa_layer_attr *dev_max_params,
-				  struct ufs_pa_layer_attr *dev_req_params)
-{
-	if (hba->vops && hba->vops->pwr_change_notify)
-		return hba->vops->pwr_change_notify(hba, status,
-					dev_max_params, dev_req_params);
-
-	return -ENOTSUPP;
-}
-
-static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
-					int tag, u8 tm_function)
-{
-	if (hba->vops && hba->vops->setup_task_mgmt)
-		return hba->vops->setup_task_mgmt(hba, tag, tm_function);
-}
-
-static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
-					enum uic_cmd_dme cmd,
-					enum ufs_notify_change_status status)
-{
-	if (hba->vops && hba->vops->hibern8_notify)
-		return hba->vops->hibern8_notify(hba, cmd, status);
-}
-
-static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba)
-{
-	if (hba->vops && hba->vops->apply_dev_quirks)
-		return hba->vops->apply_dev_quirks(hba);
-	return 0;
-}
-
-static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba)
-{
-	if (hba->vops && hba->vops->fixup_dev_quirks)
-		hba->vops->fixup_dev_quirks(hba);
-}
-
-static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op,
-				enum ufs_notify_change_status status)
-{
-	if (hba->vops && hba->vops->suspend)
-		return hba->vops->suspend(hba, op, status);
-
-	return 0;
-}
-
-static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op)
-{
-	if (hba->vops && hba->vops->resume)
-		return hba->vops->resume(hba, op);
-
-	return 0;
-}
-
-static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
-{
-	if (hba->vops && hba->vops->dbg_register_dump)
-		hba->vops->dbg_register_dump(hba);
-}
-
-static inline int ufshcd_vops_device_reset(struct ufs_hba *hba)
-{
-	if (hba->vops && hba->vops->device_reset)
-		return hba->vops->device_reset(hba);
-
-	return -EOPNOTSUPP;
-}
-
-static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
-		struct devfreq_dev_profile *p,
-		struct devfreq_simple_ondemand_data *data)
-{
-	if (hba->vops && hba->vops->config_scaling_param)
-		hba->vops->config_scaling_param(hba, p, data);
-}
-
 extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
 
-/**
- * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN
- * @scsi_lun: scsi LUN id
- *
- * Returns UPIU LUN id
- */
-static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun)
-{
-	if (scsi_is_wlun(scsi_lun))
-		return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID)
-			| UFS_UPIU_WLUN_ID;
-	else
-		return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID;
-}
-
 int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
 		     const char *prefix);
 
@@ -1412,43 +1239,4 @@ int ufshcd_write_ee_control(struct ufs_hba *hba);
 int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask,
 			     u16 set, u16 clr);
 
-static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba,
-					    u16 set, u16 clr)
-{
-	return ufshcd_update_ee_control(hba, &hba->ee_drv_mask,
-					&hba->ee_usr_mask, set, clr);
-}
-
-static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba,
-					    u16 set, u16 clr)
-{
-	return ufshcd_update_ee_control(hba, &hba->ee_usr_mask,
-					&hba->ee_drv_mask, set, clr);
-}
-
-static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba)
-{
-	return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
-}
-
-static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba)
-{
-	return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev);
-}
-
-static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba)
-{
-	pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev);
-}
-
-static inline int ufshcd_rpm_resume(struct ufs_hba *hba)
-{
-	return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev);
-}
-
-static inline int ufshcd_rpm_put(struct ufs_hba *hba)
-{
-	return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
-}
-
 #endif /* End of Header */
diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c
index d456404e5c49..daac81290f50 100644
--- a/drivers/scsi/ufs/ufshpb.c
+++ b/drivers/scsi/ufs/ufshpb.c
@@ -17,6 +17,7 @@
 #include "../sd.h"
 #include "ufshcd.h"
 #include "ufshpb.h"
+#include "ufshcd-priv.h"
 
 #define ACTIVATION_THRESHOLD 8 /* 8 IOs */
 #define READ_TO_MS 1000

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 27/29] scsi: ufs: Move the struct ufs_ref_clk definition
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (25 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-05  6:50   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 28/29] scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition Bart Van Assche
                   ` (4 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Daejun Park, Avri Altman, Bean Huo,
	Jinyoung Choi, Can Guo, Asutosh Das

Move the definition of this data structure since it is only used in a
single source file.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs.h    | 5 -----
 drivers/scsi/ufs/ufshcd.c | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 225b5b4a2a7e..f52173b8ad96 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -415,11 +415,6 @@ enum ufs_ref_clk_freq {
 	REF_CLK_FREQ_INVAL	= -1,
 };
 
-struct ufs_ref_clk {
-	unsigned long freq_hz;
-	enum ufs_ref_clk_freq val;
-};
-
 /* Query response result code */
 enum {
 	QUERY_RESULT_SUCCESS                    = 0x00,
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index bab0f1ee41e6..27738f24c4a8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7959,6 +7959,11 @@ static int ufshcd_device_geo_params_init(struct ufs_hba *hba)
 	return err;
 }
 
+struct ufs_ref_clk {
+	unsigned long freq_hz;
+	enum ufs_ref_clk_freq val;
+};
+
 static struct ufs_ref_clk ufs_ref_clk_freqs[] = {
 	{19200000, REF_CLK_FREQ_19_2_MHZ},
 	{26000000, REF_CLK_FREQ_26_MHZ},

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 28/29] scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (26 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 27/29] scsi: ufs: Move the struct ufs_ref_clk definition Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-05  6:53   ` Avri Altman
  2022-03-31 22:34 ` [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory Bart Van Assche
                   ` (3 subsequent siblings)
  31 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Bean Huo, Avri Altman, Daejun Park,
	Jinyoung Choi

Move the definition of this function from a public into a private header
file since it is only used inside the UFS core.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs.h         | 19 -------------------
 drivers/scsi/ufs/ufshcd-priv.h | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index f52173b8ad96..1bba3fead2ce 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -620,23 +620,4 @@ enum ufs_trace_tsf_t {
 	UFS_TSF_CDB, UFS_TSF_OSF, UFS_TSF_TM_INPUT, UFS_TSF_TM_OUTPUT
 };
 
-/**
- * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor
- * @dev_info: pointer of instance of struct ufs_dev_info
- * @lun: LU number to check
- * @return: true if the lun has a matching unit descriptor, false otherwise
- */
-static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info,
-		u8 lun, u8 param_offset)
-{
-	if (!dev_info || !dev_info->max_lu_supported) {
-		pr_err("Max General LU supported by UFS isn't initialized\n");
-		return false;
-	}
-	/* WB is available only for the logical unit from 0 to 7 */
-	if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS)
-		return lun < UFS_UPIU_MAX_WB_LUN_ID;
-	return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported);
-}
-
 #endif /* End of Header */
diff --git a/drivers/scsi/ufs/ufshcd-priv.h b/drivers/scsi/ufs/ufshcd-priv.h
index 4ceb0c63aa15..de699b969aa6 100644
--- a/drivers/scsi/ufs/ufshcd-priv.h
+++ b/drivers/scsi/ufs/ufshcd-priv.h
@@ -274,4 +274,23 @@ static inline int ufshcd_rpm_put(struct ufs_hba *hba)
 	return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
 }
 
+/**
+ * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor
+ * @dev_info: pointer of instance of struct ufs_dev_info
+ * @lun: LU number to check
+ * @return: true if the lun has a matching unit descriptor, false otherwise
+ */
+static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info,
+		u8 lun, u8 param_offset)
+{
+	if (!dev_info || !dev_info->max_lu_supported) {
+		pr_err("Max General LU supported by UFS isn't initialized\n");
+		return false;
+	}
+	/* WB is available only for the logical unit from 0 to 7 */
+	if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS)
+		return lun < UFS_UPIU_MAX_WB_LUN_ID;
+	return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported);
+}
+
 #endif /* _UFSHCD_PRIV_H_ */

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (27 preceding siblings ...)
  2022-03-31 22:34 ` [PATCH 28/29] scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition Bart Van Assche
@ 2022-03-31 22:34 ` Bart Van Assche
  2022-04-01  5:12   ` Christoph Hellwig
  2022-04-01  6:38   ` Adrian Hunter
       [not found] ` <CGME20220331223522epcas2p4f8f20c2ec00dbc6d5a7bf855a1dd7395@epcms2p5>
                   ` (2 subsequent siblings)
  31 siblings, 2 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-03-31 22:34 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Bart Van Assche,
	James E.J. Bottomley, Krzysztof Kozlowski, Stanley Chu,
	Andy Gross, Bjorn Andersson, Matthias Brugger, Avri Altman,
	Can Guo, Asutosh Das, Bean Huo, Guenter Roeck, Daejun Park,
	Keoseong Park, Eric Biggers, Ulf Hansson, Mike Snitzer,
	Jens Axboe, Geert Uytterhoeven, Anders Roxell, Peter Wang,
	Chanho Park, Alim Akhtar, Inki Dae, Phillip Potter,
	Greg Kroah-Hartman, Ye Bin, ChanWoo Lee, Sergey Shtylyov,
	Srinivas Kandagatla, Xiaoke Wang, Jinyoung Choi,
	Gustavo A. R. Silva, Kiwoong Kim

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/Kconfig                          |  3 +-
 drivers/scsi/Makefile                         |  4 +-
 drivers/scsi/ufs-core/Kconfig                 | 82 +++++++++++++++++++
 drivers/scsi/ufs-core/Makefile                | 10 +++
 drivers/scsi/{ufs => ufs-core}/ufs-debugfs.c  |  3 +-
 drivers/scsi/{ufs => ufs-core}/ufs-debugfs.h  |  0
 .../{ufs => ufs-core}/ufs-fault-injection.c   |  0
 .../{ufs => ufs-core}/ufs-fault-injection.h   |  0
 drivers/scsi/{ufs => ufs-core}/ufs-hwmon.c    |  3 +-
 drivers/scsi/{ufs => ufs-core}/ufs-sysfs.c    |  1 +
 drivers/scsi/{ufs => ufs-core}/ufs-sysfs.h    |  0
 drivers/scsi/{ufs => ufs-core}/ufs_bsg.c      |  2 +-
 drivers/scsi/{ufs => ufs-core}/ufs_bsg.h      |  0
 .../scsi/{ufs => ufs-core}/ufshcd-crypto.c    |  2 +-
 .../scsi/{ufs => ufs-core}/ufshcd-crypto.h    |  4 +-
 drivers/scsi/{ufs => ufs-core}/ufshcd-priv.h  |  2 +-
 drivers/scsi/{ufs => ufs-core}/ufshcd.c       |  6 +-
 drivers/scsi/{ufs => ufs-core}/ufshpb.c       |  4 +-
 drivers/scsi/{ufs => ufs-core}/ufshpb.h       |  0
 drivers/scsi/{ufs => ufs-drivers}/Kconfig     | 71 +---------------
 drivers/scsi/{ufs => ufs-drivers}/Makefile    | 12 ---
 .../scsi/{ufs => ufs-drivers}/cdns-pltfrm.c   |  0
 .../{ufs => ufs-drivers}/tc-dwc-g210-pci.c    |  2 +-
 .../{ufs => ufs-drivers}/tc-dwc-g210-pltfrm.c |  0
 .../scsi/{ufs => ufs-drivers}/tc-dwc-g210.c   |  4 +-
 .../scsi/{ufs => ufs-drivers}/tc-dwc-g210.h   |  0
 .../scsi/{ufs => ufs-drivers}/ti-j721e-ufs.c  |  0
 .../scsi/{ufs => ufs-drivers}/ufs-exynos.c    | 12 ++-
 .../scsi/{ufs => ufs-drivers}/ufs-exynos.h    |  0
 drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.c  |  8 +-
 drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.h  |  0
 .../{ufs => ufs-drivers}/ufs-mediatek-trace.h |  2 +-
 .../scsi/{ufs => ufs-drivers}/ufs-mediatek.c  |  8 +-
 .../scsi/{ufs => ufs-drivers}/ufs-mediatek.h  |  0
 .../scsi/{ufs => ufs-drivers}/ufs-qcom-ice.c  |  0
 drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.c  |  8 +-
 drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.h  |  2 +-
 .../scsi/{ufs => ufs-drivers}/ufshcd-dwc.c    |  4 +-
 .../scsi/{ufs => ufs-drivers}/ufshcd-dwc.h    |  2 +-
 .../scsi/{ufs => ufs-drivers}/ufshcd-pci.c    |  2 +-
 .../scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.c |  4 +-
 .../scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.h |  2 +-
 .../scsi/{ufs => ufs-drivers}/ufshci-dwc.h    |  0
 {drivers/scsi/ufs => include/scsi}/ufs.h      |  0
 .../scsi/ufs => include/scsi}/ufs_quirks.h    |  0
 {drivers/scsi/ufs => include/scsi}/ufshcd.h   |  8 +-
 {drivers/scsi/ufs => include/scsi}/ufshci.h   |  0
 {drivers/scsi/ufs => include/scsi}/unipro.h   |  0
 48 files changed, 144 insertions(+), 133 deletions(-)
 create mode 100644 drivers/scsi/ufs-core/Kconfig
 create mode 100644 drivers/scsi/ufs-core/Makefile
 rename drivers/scsi/{ufs => ufs-core}/ufs-debugfs.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-debugfs.h (100%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-fault-injection.c (100%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-fault-injection.h (100%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-hwmon.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-sysfs.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufs-sysfs.h (100%)
 rename drivers/scsi/{ufs => ufs-core}/ufs_bsg.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufs_bsg.h (100%)
 rename drivers/scsi/{ufs => ufs-core}/ufshcd-crypto.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufshcd-crypto.h (97%)
 rename drivers/scsi/{ufs => ufs-core}/ufshcd-priv.h (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufshcd.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufshpb.c (99%)
 rename drivers/scsi/{ufs => ufs-core}/ufshpb.h (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/Kconfig (56%)
 rename drivers/scsi/{ufs => ufs-drivers}/Makefile (56%)
 rename drivers/scsi/{ufs => ufs-drivers}/cdns-pltfrm.c (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210-pci.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210-pltfrm.c (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210.h (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/ti-j721e-ufs.c (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-exynos.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-exynos.h (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.h (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek-trace.h (92%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek.h (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom-ice.c (100%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.h (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-dwc.c (98%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-dwc.h (95%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pci.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.c (99%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.h (98%)
 rename drivers/scsi/{ufs => ufs-drivers}/ufshci-dwc.h (100%)
 rename {drivers/scsi/ufs => include/scsi}/ufs.h (100%)
 rename {drivers/scsi/ufs => include/scsi}/ufs_quirks.h (100%)
 rename {drivers/scsi/ufs => include/scsi}/ufshcd.h (99%)
 rename {drivers/scsi/ufs => include/scsi}/ufshci.h (100%)
 rename {drivers/scsi/ufs => include/scsi}/unipro.h (100%)

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 6e3a04107bb6..40d493dcbcd4 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -500,7 +500,8 @@ source "drivers/scsi/megaraid/Kconfig.megaraid"
 source "drivers/scsi/mpt3sas/Kconfig"
 source "drivers/scsi/mpi3mr/Kconfig"
 source "drivers/scsi/smartpqi/Kconfig"
-source "drivers/scsi/ufs/Kconfig"
+source "drivers/scsi/ufs-core/Kconfig"
+source "drivers/scsi/ufs-drivers/Kconfig"
 
 config SCSI_HPTIOP
 	tristate "HighPoint RocketRAID 3xxx/4xxx Controller support"
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 19814c26c908..b6319b6598d1 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -101,7 +101,9 @@ obj-$(CONFIG_MEGARAID_NEWGEN)	+= megaraid/
 obj-$(CONFIG_MEGARAID_SAS)	+= megaraid/
 obj-$(CONFIG_SCSI_MPT3SAS)	+= mpt3sas/
 obj-$(CONFIG_SCSI_MPI3MR)	+= mpi3mr/
-obj-$(CONFIG_SCSI_UFSHCD)	+= ufs/
+# The link order is important here. ufshcd-core must initialize
+# before vendor drivers.
+obj-$(CONFIG_SCSI_UFSHCD)	+= ufs-core/ ufs-drivers/
 obj-$(CONFIG_SCSI_ACARD)	+= atp870u.o
 obj-$(CONFIG_SCSI_SUNESP)	+= esp_scsi.o	sun_esp.o
 obj-$(CONFIG_SCSI_INITIO)	+= initio.o
diff --git a/drivers/scsi/ufs-core/Kconfig b/drivers/scsi/ufs-core/Kconfig
new file mode 100644
index 000000000000..1226f339f281
--- /dev/null
+++ b/drivers/scsi/ufs-core/Kconfig
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Kernel configuration file for the UFS Host Controller
+#
+# Copyright (C) 2011-2013 Samsung India Software Operations
+#
+# Authors:
+#	Santosh Yaraganavi <santosh.sy@samsung.com>
+#	Vinayak Holikatti <h.vinayak@samsung.com>
+
+config SCSI_UFSHCD
+	tristate "Universal Flash Storage Controller Driver Core"
+	depends on SCSI && SCSI_DMA
+	select PM_DEVFREQ
+	select DEVFREQ_GOV_SIMPLE_ONDEMAND
+	select NLS
+	help
+	  This selects the support for UFS devices in Linux, say Y and make
+	  sure that you know the name of your UFS host adapter (the card
+	  inside your computer that "speaks" the UFS protocol, also
+	  called UFS Host Controller), because you will be asked for it.
+	  The module will be called ufshcd.
+
+	  To compile this driver as a module, choose M here and read
+	  <file:Documentation/scsi/ufs.rst>.
+	  However, do not compile this as a module if your root file system
+	  (the one containing the directory /) is located on a UFS device.
+
+if SCSI_UFSHCD
+
+config SCSI_UFS_BSG
+	bool "Universal Flash Storage BSG device node"
+	select BLK_DEV_BSGLIB
+	help
+	  Universal Flash Storage (UFS) is SCSI transport specification for
+	  accessing flash storage on digital cameras, mobile phones and
+	  consumer electronic devices.
+	  A UFS controller communicates with a UFS device by exchanging
+	  UFS Protocol Information Units (UPIUs).
+	  UPIUs can not only be used as a transport layer for the SCSI protocol
+	  but are also used by the UFS native command set.
+	  This transport driver supports exchanging UFS protocol information units
+	  with a UFS device. See also the ufshcd driver, which is a SCSI driver
+	  that supports UFS devices.
+
+	  Select this if you need a bsg device node for your UFS controller.
+	  If unsure, say N.
+
+config SCSI_UFS_CRYPTO
+	bool "UFS Crypto Engine Support"
+	depends on BLK_INLINE_ENCRYPTION
+	help
+	  Enable Crypto Engine Support in UFS.
+	  Enabling this makes it possible for the kernel to use the crypto
+	  capabilities of the UFS device (if present) to perform crypto
+	  operations on data being transferred to/from the device.
+
+config SCSI_UFS_HPB
+	bool "Support UFS Host Performance Booster"
+	help
+	  The UFS HPB feature improves random read performance. It caches
+	  L2P (logical to physical) map of UFS to host DRAM. The driver uses HPB
+	  read command by piggybacking physical page number for bypassing FTL (flash
+	  translation layer)'s L2P address translation.
+
+config SCSI_UFS_FAULT_INJECTION
+	bool "UFS Fault Injection Support"
+	depends on FAULT_INJECTION
+	help
+	  Enable fault injection support in the UFS driver. This makes it easier
+	  to test the UFS error handler and abort handler.
+
+config SCSI_UFS_HWMON
+	bool "UFS Temperature Notification"
+	depends on SCSI_UFSHCD=HWMON || HWMON=y
+	help
+	  This provides support for UFS hardware monitoring. If enabled,
+	  a hardware monitoring device will be created for the UFS device.
+
+	  If unsure, say N.
+
+endif
diff --git a/drivers/scsi/ufs-core/Makefile b/drivers/scsi/ufs-core/Makefile
new file mode 100644
index 000000000000..740d22440a07
--- /dev/null
+++ b/drivers/scsi/ufs-core/Makefile
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_SCSI_UFSHCD)		+= ufshcd-core.o
+ufshcd-core-y				+= ufshcd.o ufs-sysfs.o
+ufshcd-core-$(CONFIG_DEBUG_FS)		+= ufs-debugfs.o
+ufshcd-core-$(CONFIG_SCSI_UFS_BSG)	+= ufs_bsg.o
+ufshcd-core-$(CONFIG_SCSI_UFS_CRYPTO)	+= ufshcd-crypto.o
+ufshcd-core-$(CONFIG_SCSI_UFS_HPB)	+= ufshpb.o
+ufshcd-core-$(CONFIG_SCSI_UFS_FAULT_INJECTION) += ufs-fault-injection.o
+ufshcd-core-$(CONFIG_SCSI_UFS_HWMON) += ufs-hwmon.o
diff --git a/drivers/scsi/ufs/ufs-debugfs.c b/drivers/scsi/ufs-core/ufs-debugfs.c
similarity index 99%
rename from drivers/scsi/ufs/ufs-debugfs.c
rename to drivers/scsi/ufs-core/ufs-debugfs.c
index c10a8f09682b..2f0d30b1bed6 100644
--- a/drivers/scsi/ufs/ufs-debugfs.c
+++ b/drivers/scsi/ufs-core/ufs-debugfs.c
@@ -2,9 +2,8 @@
 // Copyright (C) 2020 Intel Corporation
 
 #include <linux/debugfs.h>
-
+#include <scsi/ufshcd.h>
 #include "ufs-debugfs.h"
-#include "ufshcd.h"
 #include "ufshcd-priv.h"
 
 static struct dentry *ufs_debugfs_root;
diff --git a/drivers/scsi/ufs/ufs-debugfs.h b/drivers/scsi/ufs-core/ufs-debugfs.h
similarity index 100%
rename from drivers/scsi/ufs/ufs-debugfs.h
rename to drivers/scsi/ufs-core/ufs-debugfs.h
diff --git a/drivers/scsi/ufs/ufs-fault-injection.c b/drivers/scsi/ufs-core/ufs-fault-injection.c
similarity index 100%
rename from drivers/scsi/ufs/ufs-fault-injection.c
rename to drivers/scsi/ufs-core/ufs-fault-injection.c
diff --git a/drivers/scsi/ufs/ufs-fault-injection.h b/drivers/scsi/ufs-core/ufs-fault-injection.h
similarity index 100%
rename from drivers/scsi/ufs/ufs-fault-injection.h
rename to drivers/scsi/ufs-core/ufs-fault-injection.h
diff --git a/drivers/scsi/ufs/ufs-hwmon.c b/drivers/scsi/ufs-core/ufs-hwmon.c
similarity index 99%
rename from drivers/scsi/ufs/ufs-hwmon.c
rename to drivers/scsi/ufs-core/ufs-hwmon.c
index c38d9d98a86d..fe3e48d3df76 100644
--- a/drivers/scsi/ufs/ufs-hwmon.c
+++ b/drivers/scsi/ufs-core/ufs-hwmon.c
@@ -6,8 +6,7 @@
 
 #include <linux/hwmon.h>
 #include <linux/units.h>
-
-#include "ufshcd.h"
+#include <scsi/ufshcd.h>
 #include "ufshcd-priv.h"
 
 struct ufs_hwmon_data {
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs-core/ufs-sysfs.c
similarity index 99%
rename from drivers/scsi/ufs/ufs-sysfs.c
rename to drivers/scsi/ufs-core/ufs-sysfs.c
index 97ab1a75e3b8..4630419f326c 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs-core/ufs-sysfs.c
@@ -5,6 +5,7 @@
 #include <linux/bitfield.h>
 #include <linux/err.h>
 #include <linux/string.h>
+#include <scsi/ufs.h>
 #include "ufs-sysfs.h"
 #include "ufshcd-priv.h"
 
diff --git a/drivers/scsi/ufs/ufs-sysfs.h b/drivers/scsi/ufs-core/ufs-sysfs.h
similarity index 100%
rename from drivers/scsi/ufs/ufs-sysfs.h
rename to drivers/scsi/ufs-core/ufs-sysfs.h
diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs-core/ufs_bsg.c
similarity index 99%
rename from drivers/scsi/ufs/ufs_bsg.c
rename to drivers/scsi/ufs-core/ufs_bsg.c
index 9e9b93867cab..283dcdf7fceb 100644
--- a/drivers/scsi/ufs/ufs_bsg.c
+++ b/drivers/scsi/ufs-core/ufs_bsg.c
@@ -8,8 +8,8 @@
 #include <linux/bsg-lib.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
+#include <scsi/ufshcd.h>
 #include "ufs_bsg.h"
-#include "ufshcd.h"
 #include "ufshcd-priv.h"
 
 static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
diff --git a/drivers/scsi/ufs/ufs_bsg.h b/drivers/scsi/ufs-core/ufs_bsg.h
similarity index 100%
rename from drivers/scsi/ufs/ufs_bsg.h
rename to drivers/scsi/ufs-core/ufs_bsg.h
diff --git a/drivers/scsi/ufs/ufshcd-crypto.c b/drivers/scsi/ufs-core/ufshcd-crypto.c
similarity index 99%
rename from drivers/scsi/ufs/ufshcd-crypto.c
rename to drivers/scsi/ufs-core/ufshcd-crypto.c
index 67402baf6fae..f8f19d8cf4d4 100644
--- a/drivers/scsi/ufs/ufshcd-crypto.c
+++ b/drivers/scsi/ufs-core/ufshcd-crypto.c
@@ -3,7 +3,7 @@
  * Copyright 2019 Google LLC
  */
 
-#include "ufshcd.h"
+#include <scsi/ufshcd.h>
 #include "ufshcd-crypto.h"
 
 /* Blk-crypto modes supported by UFS crypto */
diff --git a/drivers/scsi/ufs/ufshcd-crypto.h b/drivers/scsi/ufs-core/ufshcd-crypto.h
similarity index 97%
rename from drivers/scsi/ufs/ufshcd-crypto.h
rename to drivers/scsi/ufs-core/ufshcd-crypto.h
index 9f98f18f9646..0875d53728d1 100644
--- a/drivers/scsi/ufs/ufshcd-crypto.h
+++ b/drivers/scsi/ufs-core/ufshcd-crypto.h
@@ -7,9 +7,9 @@
 #define _UFSHCD_CRYPTO_H
 
 #include <scsi/scsi_cmnd.h>
-#include "ufshcd.h"
+#include <scsi/ufshcd.h>
+#include <scsi/ufshci.h>
 #include "ufshcd-priv.h"
-#include "ufshci.h"
 
 #ifdef CONFIG_SCSI_UFS_CRYPTO
 
diff --git a/drivers/scsi/ufs/ufshcd-priv.h b/drivers/scsi/ufs-core/ufshcd-priv.h
similarity index 99%
rename from drivers/scsi/ufs/ufshcd-priv.h
rename to drivers/scsi/ufs-core/ufshcd-priv.h
index de699b969aa6..0e094709ec98 100644
--- a/drivers/scsi/ufs/ufshcd-priv.h
+++ b/drivers/scsi/ufs-core/ufshcd-priv.h
@@ -2,7 +2,7 @@
 #define _UFSHCD_PRIV_H_
 
 #include <linux/pm_runtime.h>
-#include "ufshcd.h"
+#include <scsi/ufshcd.h>
 
 static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba)
 {
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs-core/ufshcd.c
similarity index 99%
rename from drivers/scsi/ufs/ufshcd.c
rename to drivers/scsi/ufs-core/ufshcd.c
index 27738f24c4a8..870d285d3685 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs-core/ufshcd.c
@@ -26,16 +26,16 @@
 #include <scsi/scsi_dbg.h>
 #include <scsi/scsi_driver.h>
 #include <scsi/scsi_eh.h>
+#include <scsi/ufs_quirks.h>
+#include <scsi/ufshcd.h>
+#include <scsi/unipro.h>
 #include "ufs-debugfs.h"
 #include "ufs-fault-injection.h"
 #include "ufs-sysfs.h"
 #include "ufs_bsg.h"
-#include "ufs_quirks.h"
 #include "ufshcd-crypto.h"
 #include "ufshcd-priv.h"
-#include "ufshcd.h"
 #include "ufshpb.h"
-#include "unipro.h"
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/ufs.h>
diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs-core/ufshpb.c
similarity index 99%
rename from drivers/scsi/ufs/ufshpb.c
rename to drivers/scsi/ufs-core/ufshpb.c
index daac81290f50..7fc0a89e8d8f 100644
--- a/drivers/scsi/ufs/ufshpb.c
+++ b/drivers/scsi/ufs-core/ufshpb.c
@@ -14,10 +14,10 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <scsi/scsi_cmnd.h>
+#include <scsi/ufshcd.h>
 #include "../sd.h"
-#include "ufshcd.h"
-#include "ufshpb.h"
 #include "ufshcd-priv.h"
+#include "ufshpb.h"
 
 #define ACTIVATION_THRESHOLD 8 /* 8 IOs */
 #define READ_TO_MS 1000
diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs-core/ufshpb.h
similarity index 100%
rename from drivers/scsi/ufs/ufshpb.h
rename to drivers/scsi/ufs-core/ufshpb.h
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs-drivers/Kconfig
similarity index 56%
rename from drivers/scsi/ufs/Kconfig
rename to drivers/scsi/ufs-drivers/Kconfig
index 393b9a01da36..aa53c0e90c8e 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs-drivers/Kconfig
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
-# Kernel configuration file for the UFS Host Controller
+# Kernel configuration file for the UFS drivers
 #
 # Copyright (C) 2011-2013 Samsung India Software Operations
 #
@@ -8,24 +8,6 @@
 #	Santosh Yaraganavi <santosh.sy@samsung.com>
 #	Vinayak Holikatti <h.vinayak@samsung.com>
 
-config SCSI_UFSHCD
-	tristate "Universal Flash Storage Controller Driver Core"
-	depends on SCSI && SCSI_DMA
-	select PM_DEVFREQ
-	select DEVFREQ_GOV_SIMPLE_ONDEMAND
-	select NLS
-	help
-	  This selects the support for UFS devices in Linux, say Y and make
-	  sure that you know the name of your UFS host adapter (the card
-	  inside your computer that "speaks" the UFS protocol, also
-	  called UFS Host Controller), because you will be asked for it.
-	  The module will be called ufshcd.
-
-	  To compile this driver as a module, choose M here and read
-	  <file:Documentation/scsi/ufs.rst>.
-	  However, do not compile this as a module if your root file system
-	  (the one containing the directory /) is located on a UFS device.
-
 if SCSI_UFSHCD
 
 config SCSI_UFSHCD_PCI
@@ -122,24 +104,6 @@ config SCSI_UFS_TI_J721E
 	  Selects this if you have TI platform with UFS controller.
 	  If unsure, say N.
 
-config SCSI_UFS_BSG
-	bool "Universal Flash Storage BSG device node"
-	select BLK_DEV_BSGLIB
-	help
-	  Universal Flash Storage (UFS) is SCSI transport specification for
-	  accessing flash storage on digital cameras, mobile phones and
-	  consumer electronic devices.
-	  A UFS controller communicates with a UFS device by exchanging
-	  UFS Protocol Information Units (UPIUs).
-	  UPIUs can not only be used as a transport layer for the SCSI protocol
-	  but are also used by the UFS native command set.
-	  This transport driver supports exchanging UFS protocol information units
-	  with a UFS device. See also the ufshcd driver, which is a SCSI driver
-	  that supports UFS devices.
-
-	  Select this if you need a bsg device node for your UFS controller.
-	  If unsure, say N.
-
 config SCSI_UFS_EXYNOS
 	tristate "Exynos specific hooks to UFS controller platform driver"
 	depends on SCSI_UFSHCD_PLATFORM && (ARCH_EXYNOS || COMPILE_TEST)
@@ -151,37 +115,4 @@ config SCSI_UFS_EXYNOS
 	  Select this if you have UFS host controller on Samsung Exynos SoC.
 	  If unsure, say N.
 
-config SCSI_UFS_CRYPTO
-	bool "UFS Crypto Engine Support"
-	depends on BLK_INLINE_ENCRYPTION
-	help
-	  Enable Crypto Engine Support in UFS.
-	  Enabling this makes it possible for the kernel to use the crypto
-	  capabilities of the UFS device (if present) to perform crypto
-	  operations on data being transferred to/from the device.
-
-config SCSI_UFS_HPB
-	bool "Support UFS Host Performance Booster"
-	help
-	  The UFS HPB feature improves random read performance. It caches
-	  L2P (logical to physical) map of UFS to host DRAM. The driver uses HPB
-	  read command by piggybacking physical page number for bypassing FTL (flash
-	  translation layer)'s L2P address translation.
-
-config SCSI_UFS_FAULT_INJECTION
-	bool "UFS Fault Injection Support"
-	depends on FAULT_INJECTION
-	help
-	  Enable fault injection support in the UFS driver. This makes it easier
-	  to test the UFS error handler and abort handler.
-
-config SCSI_UFS_HWMON
-	bool "UFS Temperature Notification"
-	depends on SCSI_UFSHCD=HWMON || HWMON=y
-	help
-	  This provides support for UFS hardware monitoring. If enabled,
-	  a hardware monitoring device will be created for the UFS device.
-
-	  If unsure, say N.
-
 endif
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs-drivers/Makefile
similarity index 56%
rename from drivers/scsi/ufs/Makefile
rename to drivers/scsi/ufs-drivers/Makefile
index 966048875b50..e4be54273c98 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs-drivers/Makefile
@@ -1,16 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-# UFSHCD makefile
-
-# The link order is important here. ufshcd-core must initialize
-# before vendor drivers.
-obj-$(CONFIG_SCSI_UFSHCD)		+= ufshcd-core.o
-ufshcd-core-y				+= ufshcd.o ufs-sysfs.o
-ufshcd-core-$(CONFIG_DEBUG_FS)		+= ufs-debugfs.o
-ufshcd-core-$(CONFIG_SCSI_UFS_BSG)	+= ufs_bsg.o
-ufshcd-core-$(CONFIG_SCSI_UFS_CRYPTO)	+= ufshcd-crypto.o
-ufshcd-core-$(CONFIG_SCSI_UFS_HPB)	+= ufshpb.o
-ufshcd-core-$(CONFIG_SCSI_UFS_FAULT_INJECTION) += ufs-fault-injection.o
-ufshcd-core-$(CONFIG_SCSI_UFS_HWMON) += ufs-hwmon.o
 
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o
diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs-drivers/cdns-pltfrm.c
similarity index 100%
rename from drivers/scsi/ufs/cdns-pltfrm.c
rename to drivers/scsi/ufs-drivers/cdns-pltfrm.c
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c b/drivers/scsi/ufs-drivers/tc-dwc-g210-pci.c
similarity index 99%
rename from drivers/scsi/ufs/tc-dwc-g210-pci.c
rename to drivers/scsi/ufs-drivers/tc-dwc-g210-pci.c
index d679eff3f2f0..68c40e5b61e4 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pci.c
+++ b/drivers/scsi/ufs-drivers/tc-dwc-g210-pci.c
@@ -10,9 +10,9 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/pm_runtime.h>
+#include <scsi/ufshcd.h>
 #include "tc-dwc-g210.h"
 #include "ufshcd-dwc.h"
-#include "ufshcd.h"
 
 /* Test Chip type expected values */
 #define TC_G210_20BIT 20
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c b/drivers/scsi/ufs-drivers/tc-dwc-g210-pltfrm.c
similarity index 100%
rename from drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
rename to drivers/scsi/ufs-drivers/tc-dwc-g210-pltfrm.c
diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs-drivers/tc-dwc-g210.c
similarity index 99%
rename from drivers/scsi/ufs/tc-dwc-g210.c
rename to drivers/scsi/ufs-drivers/tc-dwc-g210.c
index c1b236f09601..14486afc42f1 100644
--- a/drivers/scsi/ufs/tc-dwc-g210.c
+++ b/drivers/scsi/ufs-drivers/tc-dwc-g210.c
@@ -8,11 +8,11 @@
  */
 
 #include <linux/module.h>
+#include <scsi/ufshcd.h>
+#include <scsi/unipro.h>
 #include "tc-dwc-g210.h"
 #include "ufshcd-dwc.h"
-#include "ufshcd.h"
 #include "ufshci-dwc.h"
-#include "unipro.h"
 
 /**
  * tc_dwc_g210_setup_40bit_rmmi()
diff --git a/drivers/scsi/ufs/tc-dwc-g210.h b/drivers/scsi/ufs-drivers/tc-dwc-g210.h
similarity index 100%
rename from drivers/scsi/ufs/tc-dwc-g210.h
rename to drivers/scsi/ufs-drivers/tc-dwc-g210.h
diff --git a/drivers/scsi/ufs/ti-j721e-ufs.c b/drivers/scsi/ufs-drivers/ti-j721e-ufs.c
similarity index 100%
rename from drivers/scsi/ufs/ti-j721e-ufs.c
rename to drivers/scsi/ufs-drivers/ti-j721e-ufs.c
diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs-drivers/ufs-exynos.c
similarity index 99%
rename from drivers/scsi/ufs/ufs-exynos.c
rename to drivers/scsi/ufs-drivers/ufs-exynos.c
index ddb2d42605c5..64f4ed3639b0 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs-drivers/ufs-exynos.c
@@ -10,20 +10,18 @@
 
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/mfd/syscon.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
-
-#include "ufshcd.h"
-#include "ufshcd-pltfrm.h"
-#include "ufshci.h"
-#include "unipro.h"
-
+#include <scsi/ufshcd.h>
+#include <scsi/ufshci.h>
+#include <scsi/unipro.h>
 #include "ufs-exynos.h"
+#include "ufshcd-pltfrm.h"
 
 /*
  * Exynos's Vendor specific registers for UFSHCI
diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs-drivers/ufs-exynos.h
similarity index 100%
rename from drivers/scsi/ufs/ufs-exynos.h
rename to drivers/scsi/ufs-drivers/ufs-exynos.h
diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs-drivers/ufs-hisi.c
similarity index 99%
rename from drivers/scsi/ufs/ufs-hisi.c
rename to drivers/scsi/ufs-drivers/ufs-hisi.c
index 8f6168471464..09ac3280a73e 100644
--- a/drivers/scsi/ufs/ufs-hisi.c
+++ b/drivers/scsi/ufs-drivers/ufs-hisi.c
@@ -14,12 +14,12 @@
 #include <linux/platform_device.h>
 #include <linux/reset.h>
 #include <linux/time.h>
+#include <scsi/ufs_quirks.h>
+#include <scsi/ufshcd.h>
+#include <scsi/ufshci.h>
+#include <scsi/unipro.h>
 #include "ufs-hisi.h"
-#include "ufs_quirks.h"
 #include "ufshcd-pltfrm.h"
-#include "ufshcd.h"
-#include "ufshci.h"
-#include "unipro.h"
 
 static int ufs_hisi_check_hibern8(struct ufs_hba *hba)
 {
diff --git a/drivers/scsi/ufs/ufs-hisi.h b/drivers/scsi/ufs-drivers/ufs-hisi.h
similarity index 100%
rename from drivers/scsi/ufs/ufs-hisi.h
rename to drivers/scsi/ufs-drivers/ufs-hisi.h
diff --git a/drivers/scsi/ufs/ufs-mediatek-trace.h b/drivers/scsi/ufs-drivers/ufs-mediatek-trace.h
similarity index 92%
rename from drivers/scsi/ufs/ufs-mediatek-trace.h
rename to drivers/scsi/ufs-drivers/ufs-mediatek-trace.h
index 895e82ea6ece..d33ffce9d01f 100644
--- a/drivers/scsi/ufs/ufs-mediatek-trace.h
+++ b/drivers/scsi/ufs-drivers/ufs-mediatek-trace.h
@@ -31,6 +31,6 @@ TRACE_EVENT(ufs_mtk_event,
 
 #undef TRACE_INCLUDE_PATH
 #undef TRACE_INCLUDE_FILE
-#define TRACE_INCLUDE_PATH ../../drivers/scsi/ufs/
+#define TRACE_INCLUDE_PATH ../../drivers/scsi/ufs-drivers
 #define TRACE_INCLUDE_FILE ufs-mediatek-trace
 #include <trace/define_trace.h>
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs-drivers/ufs-mediatek.c
similarity index 99%
rename from drivers/scsi/ufs/ufs-mediatek.c
rename to drivers/scsi/ufs-drivers/ufs-mediatek.c
index b804e969915b..3207a19b900a 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs-drivers/ufs-mediatek.c
@@ -20,11 +20,11 @@
 #include <linux/reset.h>
 #include <linux/sched/clock.h>
 #include <linux/soc/mediatek/mtk_sip_svc.h>
-#include "ufshcd.h"
-#include "ufshcd-pltfrm.h"
-#include "ufs_quirks.h"
-#include "unipro.h"
+#include <scsi/ufs_quirks.h>
+#include <scsi/ufshcd.h>
+#include <scsi/unipro.h>
 #include "ufs-mediatek.h"
+#include "ufshcd-pltfrm.h"
 
 #define CREATE_TRACE_POINTS
 #include "ufs-mediatek-trace.h"
diff --git a/drivers/scsi/ufs/ufs-mediatek.h b/drivers/scsi/ufs-drivers/ufs-mediatek.h
similarity index 100%
rename from drivers/scsi/ufs/ufs-mediatek.h
rename to drivers/scsi/ufs-drivers/ufs-mediatek.h
diff --git a/drivers/scsi/ufs/ufs-qcom-ice.c b/drivers/scsi/ufs-drivers/ufs-qcom-ice.c
similarity index 100%
rename from drivers/scsi/ufs/ufs-qcom-ice.c
rename to drivers/scsi/ufs-drivers/ufs-qcom-ice.c
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs-drivers/ufs-qcom.c
similarity index 99%
rename from drivers/scsi/ufs/ufs-qcom.c
rename to drivers/scsi/ufs-drivers/ufs-qcom.c
index 9a390cd516bd..dbfaa7ead11a 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs-drivers/ufs-qcom.c
@@ -14,12 +14,12 @@
 #include <linux/platform_device.h>
 #include <linux/reset-controller.h>
 #include <linux/time.h>
+#include <scsi/ufs_quirks.h>
+#include <scsi/ufshcd.h>
+#include <scsi/ufshci.h>
+#include <scsi/unipro.h>
 #include "ufs-qcom.h"
-#include "ufs_quirks.h"
 #include "ufshcd-pltfrm.h"
-#include "ufshcd.h"
-#include "ufshci.h"
-#include "unipro.h"
 
 #define UFS_QCOM_DEFAULT_DBG_PRINT_EN					\
 	(UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_TEST_BUS_EN)
diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs-drivers/ufs-qcom.h
similarity index 99%
rename from drivers/scsi/ufs/ufs-qcom.h
rename to drivers/scsi/ufs-drivers/ufs-qcom.h
index 771bc95d02c7..ad70d425c544 100644
--- a/drivers/scsi/ufs/ufs-qcom.h
+++ b/drivers/scsi/ufs-drivers/ufs-qcom.h
@@ -7,7 +7,7 @@
 
 #include <linux/reset-controller.h>
 #include <linux/reset.h>
-#include "ufshcd.h"
+#include <scsi/ufshcd.h>
 
 #define MAX_UFS_QCOM_HOSTS	1
 #define MAX_U32                 (~(u32)0)
diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs-drivers/ufshcd-dwc.c
similarity index 98%
rename from drivers/scsi/ufs/ufshcd-dwc.c
rename to drivers/scsi/ufs-drivers/ufshcd-dwc.c
index 8f1786be3556..a4066373d994 100644
--- a/drivers/scsi/ufs/ufshcd-dwc.c
+++ b/drivers/scsi/ufs-drivers/ufshcd-dwc.c
@@ -8,10 +8,10 @@
  */
 
 #include <linux/module.h>
+#include <scsi/ufshcd.h>
+#include <scsi/unipro.h>
 #include "ufshcd-dwc.h"
-#include "ufshcd.h"
 #include "ufshci-dwc.h"
-#include "unipro.h"
 
 int ufshcd_dwc_dme_set_attrs(struct ufs_hba *hba,
 				const struct ufshcd_dme_attr_val *v, int n)
diff --git a/drivers/scsi/ufs/ufshcd-dwc.h b/drivers/scsi/ufs-drivers/ufshcd-dwc.h
similarity index 95%
rename from drivers/scsi/ufs/ufshcd-dwc.h
rename to drivers/scsi/ufs-drivers/ufshcd-dwc.h
index 43b70794e24f..3195002f6692 100644
--- a/drivers/scsi/ufs/ufshcd-dwc.h
+++ b/drivers/scsi/ufs-drivers/ufshcd-dwc.h
@@ -10,7 +10,7 @@
 #ifndef _UFSHCD_DWC_H
 #define _UFSHCD_DWC_H
 
-#include "ufshcd.h"
+#include <scsi/ufshcd.h>
 
 struct ufshcd_dme_attr_val {
 	u32 attr_sel;
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs-drivers/ufshcd-pci.c
similarity index 99%
rename from drivers/scsi/ufs/ufshcd-pci.c
rename to drivers/scsi/ufs-drivers/ufshcd-pci.c
index 45df431c720c..c82972fd4ece 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs-drivers/ufshcd-pci.c
@@ -18,7 +18,7 @@
 #include <linux/pm_qos.h>
 #include <linux/pm_runtime.h>
 #include <linux/uuid.h>
-#include "ufshcd.h"
+#include <scsi/ufshcd.h>
 
 struct ufs_host {
 	void (*late_init)(struct ufs_hba *hba);
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs-drivers/ufshcd-pltfrm.c
similarity index 99%
rename from drivers/scsi/ufs/ufshcd-pltfrm.c
rename to drivers/scsi/ufs-drivers/ufshcd-pltfrm.c
index a1ff5bfd4f71..a6191e21dbbd 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs-drivers/ufshcd-pltfrm.c
@@ -12,9 +12,9 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-#include "ufshcd.h"
+#include <scsi/ufshcd.h>
+#include <scsi/unipro.h>
 #include "ufshcd-pltfrm.h"
-#include "unipro.h"
 
 #define UFSHCD_DEFAULT_LANES_PER_DIRECTION		2
 
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.h b/drivers/scsi/ufs-drivers/ufshcd-pltfrm.h
similarity index 98%
rename from drivers/scsi/ufs/ufshcd-pltfrm.h
rename to drivers/scsi/ufs-drivers/ufshcd-pltfrm.h
index c33e28ac6ef6..63cb306ed0ac 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.h
+++ b/drivers/scsi/ufs-drivers/ufshcd-pltfrm.h
@@ -5,7 +5,7 @@
 #ifndef UFSHCD_PLTFRM_H_
 #define UFSHCD_PLTFRM_H_
 
-#include "ufshcd.h"
+#include <scsi/ufshcd.h>
 
 #define UFS_PWM_MODE 1
 #define UFS_HS_MODE  2
diff --git a/drivers/scsi/ufs/ufshci-dwc.h b/drivers/scsi/ufs-drivers/ufshci-dwc.h
similarity index 100%
rename from drivers/scsi/ufs/ufshci-dwc.h
rename to drivers/scsi/ufs-drivers/ufshci-dwc.h
diff --git a/drivers/scsi/ufs/ufs.h b/include/scsi/ufs.h
similarity index 100%
rename from drivers/scsi/ufs/ufs.h
rename to include/scsi/ufs.h
diff --git a/drivers/scsi/ufs/ufs_quirks.h b/include/scsi/ufs_quirks.h
similarity index 100%
rename from drivers/scsi/ufs/ufs_quirks.h
rename to include/scsi/ufs_quirks.h
diff --git a/drivers/scsi/ufs/ufshcd.h b/include/scsi/ufshcd.h
similarity index 99%
rename from drivers/scsi/ufs/ufshcd.h
rename to include/scsi/ufshcd.h
index b13469fb1e15..946d915f5a42 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/include/scsi/ufshcd.h
@@ -18,10 +18,10 @@
 #include <linux/devfreq.h>
 #include <linux/pm_runtime.h>
 #include <scsi/scsi_device.h>
-#include "unipro.h"
-#include "ufs.h"
-#include "ufs_quirks.h"
-#include "ufshci.h"
+#include <scsi/ufs.h>
+#include <scsi/ufs_quirks.h>
+#include <scsi/ufshci.h>
+#include <scsi/unipro.h>
 
 #define UFSHCD "ufshcd"
 
diff --git a/drivers/scsi/ufs/ufshci.h b/include/scsi/ufshci.h
similarity index 100%
rename from drivers/scsi/ufs/ufshci.h
rename to include/scsi/ufshci.h
diff --git a/drivers/scsi/ufs/unipro.h b/include/scsi/unipro.h
similarity index 100%
rename from drivers/scsi/ufs/unipro.h
rename to include/scsi/unipro.h

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* Re: [PATCH 02/29] scsi: ufs: Remove superfluous boolean conversions
  2022-03-31 22:33 ` [PATCH 02/29] scsi: ufs: Remove superfluous boolean conversions Bart Van Assche
@ 2022-03-31 23:44   ` Bjorn Andersson
  2022-04-03  3:20     ` Bart Van Assche
  2022-04-01 18:35   ` Avri Altman
  1 sibling, 1 reply; 101+ messages in thread
From: Bjorn Andersson @ 2022-03-31 23:44 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, Jaegeuk Kim, Adrian Hunter, linux-scsi,
	Andy Gross, James E.J. Bottomley, Bean Huo, Avri Altman,
	Daejun Park, Can Guo, Asutosh Das

On Thu 31 Mar 15:33 PDT 2022, Bart Van Assche wrote:

> Remove "? true : false" if the preceding expression yields a boolean or if
> the result of the expression is assigned to a boolean since in these two
> cases the "? true : false" part is superfluous.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> ---
>  drivers/scsi/ufs/ufs-qcom.c | 3 +--
>  drivers/scsi/ufs/ufshcd.c   | 9 ++++-----
>  drivers/scsi/ufs/ufshcd.h   | 2 +-
>  3 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index 0d2e950d0865..808b677f6083 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -299,8 +299,7 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
>  	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
>  	struct phy *phy = host->generic_phy;
>  	int ret = 0;
> -	bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)
> -							? true : false;
> +	bool is_rate_B = UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B;

UFS_QCOM_LIMIT_HS_RATE is defined as PA_HS_MODE_B. I wonder if this is
expected to change at some point, or if we could clean this up further
(in a future change).

Regards,
Bjorn

>  
>  	/* Reset UFS Host Controller and PHY */
>  	ret = ufs_qcom_host_reset(hba);
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index dbf50b50870b..983fac14b7cd 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -712,8 +712,7 @@ static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba)
>   */
>  static inline bool ufshcd_is_device_present(struct ufs_hba *hba)
>  {
> -	return (ufshcd_readl(hba, REG_CONTROLLER_STATUS) &
> -						DEVICE_PRESENT) ? true : false;
> +	return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & DEVICE_PRESENT;
>  }
>  
>  /**
> @@ -840,7 +839,7 @@ ufshcd_get_rsp_upiu_data_seg_len(struct utp_upiu_rsp *ucd_rsp_ptr)
>  static inline bool ufshcd_is_exception_event(struct utp_upiu_rsp *ucd_rsp_ptr)
>  {
>  	return be32_to_cpu(ucd_rsp_ptr->header.dword_2) &
> -			MASK_RSP_EXCEPTION_EVENT ? true : false;
> +			MASK_RSP_EXCEPTION_EVENT;
>  }
>  
>  /**
> @@ -1350,7 +1349,7 @@ static int ufshcd_devfreq_target(struct device *dev,
>  	}
>  
>  	/* Decide based on the rounded-off frequency and update */
> -	scale_up = (*freq == clki->max_freq) ? true : false;
> +	scale_up = *freq == clki->max_freq;
>  	if (!scale_up)
>  		*freq = clki->min_freq;
>  	/* Update the frequency */
> @@ -2800,7 +2799,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
>  	lrbp->sense_buffer = cmd->sense_buffer;
>  	lrbp->task_tag = tag;
>  	lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
> -	lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false;
> +	lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba);
>  
>  	ufshcd_prepare_lrbp_crypto(scsi_cmd_to_rq(cmd), lrbp);
>  
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 949427714d0e..b2740b51a546 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -985,7 +985,7 @@ static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba)
>  
>  static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)
>  {
> -	return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false;
> +	return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit);
>  }
>  
>  static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba)

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 03/29] scsi: ufs: Simplify statements that return a boolean
  2022-03-31 22:33 ` [PATCH 03/29] scsi: ufs: Simplify statements that return a boolean Bart Van Assche
@ 2022-03-31 23:45   ` Bjorn Andersson
  2022-04-01 18:49   ` Avri Altman
  1 sibling, 0 replies; 101+ messages in thread
From: Bjorn Andersson @ 2022-03-31 23:45 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, Jaegeuk Kim, Adrian Hunter, linux-scsi,
	Andy Gross, James E.J. Bottomley, Bean Huo, Avri Altman,
	Daejun Park, Can Guo, Asutosh Das

On Thu 31 Mar 15:33 PDT 2022, Bart Van Assche wrote:

> Convert "if (expr) return true; else return false;" into "return expr;"
> if either 'expr' is a boolean expression or the return type of the
> function is 'bool'.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> ---
>  drivers/scsi/ufs/ufs-qcom.h |  5 +----
>  drivers/scsi/ufs/ufshcd.c   | 22 +++++-----------------
>  2 files changed, 6 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h
> index 8208e3a3ef59..51570224a6e2 100644
> --- a/drivers/scsi/ufs/ufs-qcom.h
> +++ b/drivers/scsi/ufs/ufs-qcom.h
> @@ -239,10 +239,7 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host);
>  
>  static inline bool ufs_qcom_cap_qunipro(struct ufs_qcom_host *host)
>  {
> -	if (host->caps & UFS_QCOM_CAP_QUNIPRO)
> -		return true;
> -	else
> -		return false;
> +	return host->caps & UFS_QCOM_CAP_QUNIPRO;
>  }
>  
>  /* ufs-qcom-ice.c */
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 983fac14b7cd..c60519372b3b 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -939,10 +939,7 @@ static bool ufshcd_is_unipro_pa_params_tuning_req(struct ufs_hba *hba)
>  	 * logic simple, we will only do manual tuning if local unipro version
>  	 * doesn't support ver1.6 or later.
>  	 */
> -	if (ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6)
> -		return true;
> -	else
> -		return false;
> +	return ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6;
>  }
>  
>  /**
> @@ -2216,10 +2213,7 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
>   */
>  static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
>  {
> -	if (ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY)
> -		return true;
> -	else
> -		return false;
> +	return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY;
>  }
>  
>  /**
> @@ -5781,10 +5775,7 @@ static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba,
>  		return false;
>  	}
>  	/* Let it continue to flush when available buffer exceeds threshold */
> -	if (avail_buf < hba->vps->wb_flush_threshold)
> -		return true;
> -
> -	return false;
> +	return avail_buf < hba->vps->wb_flush_threshold;
>  }
>  
>  static void ufshcd_wb_force_disable(struct ufs_hba *hba)
> @@ -5863,11 +5854,8 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba)
>  		return false;
>  	}
>  
> -	if (!hba->dev_info.b_presrv_uspc_en) {
> -		if (avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10))
> -			return true;
> -		return false;
> -	}
> +	if (!hba->dev_info.b_presrv_uspc_en)
> +		return avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10);
>  
>  	return ufshcd_wb_presrv_usrspc_keep_vcc_on(hba, avail_buf);
>  }

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 14/29] scsi: ufs: Make the config_scaling_param calls type safe
  2022-03-31 22:34 ` [PATCH 14/29] scsi: ufs: Make the config_scaling_param calls type safe Bart Van Assche
@ 2022-03-31 23:48   ` Bjorn Andersson
  2022-04-01  4:08     ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Bjorn Andersson @ 2022-03-31 23:48 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, Jaegeuk Kim, Adrian Hunter, linux-scsi,
	Andy Gross, James E.J. Bottomley, Bean Huo, Daejun Park,
	Avri Altman, Can Guo, Asutosh Das

On Thu 31 Mar 15:34 PDT 2022, Bart Van Assche wrote:

> Pass the actual type to config_scaling_param callback as the third
> argment instead of a void pointer. Remove a superfluous NULL pointer
> check from ufs_qcom_config_scaling_param().
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufs-qcom.c | 14 ++++----------
>  drivers/scsi/ufs/ufshcd.h   | 10 +++++-----
>  2 files changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index 808b677f6083..f24210652fe9 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -1463,23 +1463,17 @@ static int ufs_qcom_device_reset(struct ufs_hba *hba)
>  
>  #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
>  static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
> -					  struct devfreq_dev_profile *p,
> -					  void *data)
> +		struct devfreq_dev_profile *p,
> +		struct devfreq_simple_ondemand_data *d)

This doesn't look to be properly indended to match the '('?
What does ./scripts/checkpatch.pl --strict say about the patch?


Other than that, the change looks good, so feel free to add my r-b once
you've double checked the indentation.

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

>  {
> -	static struct devfreq_simple_ondemand_data *d;
> -
> -	if (!data)
> -		return;
> -
> -	d = (struct devfreq_simple_ondemand_data *)data;
>  	p->polling_ms = 60;
>  	d->upthreshold = 70;
>  	d->downdifferential = 5;
>  }
>  #else
>  static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
> -					  struct devfreq_dev_profile *p,
> -					  void *data)
> +		struct devfreq_dev_profile *p,
> +		struct devfreq_simple_ondemand_data *data)
>  {
>  }
>  #endif
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 107d19e98d52..bb2624aabda2 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -348,8 +348,8 @@ struct ufs_hba_variant_ops {
>  	int	(*phy_initialization)(struct ufs_hba *);
>  	int	(*device_reset)(struct ufs_hba *hba);
>  	void	(*config_scaling_param)(struct ufs_hba *hba,
> -					struct devfreq_dev_profile *profile,
> -					void *data);
> +				struct devfreq_dev_profile *profile,
> +				struct devfreq_simple_ondemand_data *data);
>  	int	(*program_key)(struct ufs_hba *hba,
>  			       const union ufs_crypto_cfg_entry *cfg, int slot);
>  	void	(*event_notify)(struct ufs_hba *hba,
> @@ -1360,11 +1360,11 @@ static inline int ufshcd_vops_device_reset(struct ufs_hba *hba)
>  }
>  
>  static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
> -						    struct devfreq_dev_profile
> -						    *profile, void *data)
> +		struct devfreq_dev_profile *p,
> +		struct devfreq_simple_ondemand_data *data)
>  {
>  	if (hba->vops && hba->vops->config_scaling_param)
> -		hba->vops->config_scaling_param(hba, profile, data);
> +		hba->vops->config_scaling_param(hba, p, data);
>  }
>  
>  extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 22/29] scsi: ufs: qcom: Fix ufs_qcom_resume()
  2022-03-31 22:34 ` [PATCH 22/29] scsi: ufs: qcom: Fix ufs_qcom_resume() Bart Van Assche
@ 2022-03-31 23:50   ` Bjorn Andersson
  0 siblings, 0 replies; 101+ messages in thread
From: Bjorn Andersson @ 2022-03-31 23:50 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, Jaegeuk Kim, Adrian Hunter, linux-scsi,
	Andy Gross, James E.J. Bottomley, Dov Levenglick

On Thu 31 Mar 15:34 PDT 2022, Bart Van Assche wrote:

> Clearing hba->is_sys_suspended if ufs_qcom_resume() succeeds is wrong. That
> variable must only be cleared if all actions involved in a resume succeed.
> Hence remove the statement that clears hba->is_sys_suspended from
> ufs_qcom_resume().
> 

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufs-qcom.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index f24210652fe9..808dae751527 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -640,12 +640,7 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
>  			return err;
>  	}
>  
> -	err = ufs_qcom_ice_resume(host);
> -	if (err)
> -		return err;
> -
> -	hba->is_sys_suspended = false;
> -	return 0;
> +	return ufs_qcom_ice_resume(host);
>  }
>  
>  static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable)

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file
  2022-03-31 22:34 ` [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file Bart Van Assche
@ 2022-04-01  0:21   ` Chanho Park
  2022-04-01  4:14     ` Bart Van Assche
  2022-04-05  6:39   ` Avri Altman
  1 sibling, 1 reply; 101+ messages in thread
From: Chanho Park @ 2022-04-01  0:21 UTC (permalink / raw)
  To: 'Bart Van Assche', 'Martin K . Petersen'
  Cc: 'Jaegeuk Kim', 'Adrian Hunter',
	linux-scsi, 'James E.J. Bottomley', 'Avri Altman',
	'Can Guo', 'Asutosh Das', 'Daejun Park',
	'Guenter Roeck', 'Bean Huo',
	'Keoseong Park', 'Mike Snitzer',
	'Eric Biggers', 'Jens Axboe',
	'Ulf Hansson'

Hi,

I'm seeing below build error when I applied this patch. Any baseline do I
need?

In file included from drivers/scsi/ufs/ufs-sysfs.c:9:
drivers/scsi/ufs/ufshcd-priv.h:32:20: error: redefinition of
'ufs_hwmon_probe'
   32 | static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
      |                    ^~~~~~~~~~~~~~~
In file included from drivers/scsi/ufs/ufshcd-priv.h:5,
                 from drivers/scsi/ufs/ufs-sysfs.c:9:
drivers/scsi/ufs/ufshcd.h:1079:20: note: previous definition of
'ufs_hwmon_probe' with type 'void(struct ufs_hba *, u8)' {aka 'void(struct
ufs_hba *, unsigned char)'}
 1079 | static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
      |                    ^~~~~~~~~~~~~~~
In file included from drivers/scsi/ufs/ufs-sysfs.c:9:
drivers/scsi/ufs/ufshcd-priv.h:33:20: error: redefinition of
'ufs_hwmon_remove'
   33 | static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
      |                    ^~~~~~~~~~~~~~~~
In file included from drivers/scsi/ufs/ufshcd-priv.h:5,
                 from drivers/scsi/ufs/ufs-sysfs.c:9:
drivers/scsi/ufs/ufshcd.h:1080:20: note: previous definition of
'ufs_hwmon_remove' with type 'void(struct ufs_hba *)'
 1080 | static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
      |                    ^~~~~~~~~~~~~~~~

Best Regards,
Chanho Park

-----Original Message-----
From: Bart Van Assche <bvanassche@acm.org> 
Sent: Friday, April 1, 2022 7:34 AM
To: Martin K . Petersen <martin.petersen@oracle.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>; Adrian Hunter
<adrian.hunter@intel.com>; linux-scsi@vger.kernel.org; Bart Van Assche
<bvanassche@acm.org>; James E.J. Bottomley <jejb@linux.ibm.com>; Avri Altman
<Avri.Altman@wdc.com>; Can Guo <cang@codeaurora.org>; Asutosh Das
<asutoshd@codeaurora.org>; Daejun Park <daejun7.park@samsung.com>; Guenter
Roeck <linux@roeck-us.net>; Bean Huo <beanhuo@micron.com>; Keoseong Park
<keosung.park@samsung.com>; Mike Snitzer <snitzer@redhat.com>; Eric Biggers
<ebiggers@google.com>; Jens Axboe <axboe@kernel.dk>; Ulf Hansson
<ulf.hansson@linaro.org>
Subject: [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file

Split the ufshcd.h header file into a header file that defines the interface
used by UFS drivers and another header file with declarations and data
structures only used by the UFS core.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-debugfs.c   |   1 +
 drivers/scsi/ufs/ufs-hwmon.c     |   1 +
 drivers/scsi/ufs/ufs-sysfs.c     |   3 +-
 drivers/scsi/ufs/ufs_bsg.c       |   1 +
 drivers/scsi/ufs/ufshcd-crypto.h |   2 +
 drivers/scsi/ufs/ufshcd-priv.h   | 277 +++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshcd.c        |   1 +
 drivers/scsi/ufs/ufshcd.h        | 212 -----------------------
 drivers/scsi/ufs/ufshpb.c        |   1 +
 9 files changed, 285 insertions(+), 214 deletions(-)  create mode 100644
drivers/scsi/ufs/ufshcd-priv.h

diff --git a/drivers/scsi/ufs/ufs-debugfs.c b/drivers/scsi/ufs/ufs-debugfs.c
index 4a0bbcf1757a..c10a8f09682b 100644
--- a/drivers/scsi/ufs/ufs-debugfs.c
+++ b/drivers/scsi/ufs/ufs-debugfs.c
@@ -5,6 +5,7 @@
 
 #include "ufs-debugfs.h"
 #include "ufshcd.h"
+#include "ufshcd-priv.h"
 
 static struct dentry *ufs_debugfs_root;
 
diff --git a/drivers/scsi/ufs/ufs-hwmon.c b/drivers/scsi/ufs/ufs-hwmon.c
index 74855491dc8f..c38d9d98a86d 100644
--- a/drivers/scsi/ufs/ufs-hwmon.c
+++ b/drivers/scsi/ufs/ufs-hwmon.c
@@ -8,6 +8,7 @@
 #include <linux/units.h>
 
 #include "ufshcd.h"
+#include "ufshcd-priv.h"
 
 struct ufs_hwmon_data {
 	struct ufs_hba *hba;
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index 2bf128e4b613..97ab1a75e3b8 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -6,8 +6,7 @@
 #include <linux/err.h>
 #include <linux/string.h>
 #include "ufs-sysfs.h"
-#include "ufs.h"
-#include "ufshcd.h"
+#include "ufshcd-priv.h"
 
 static const char *ufshcd_uic_link_state_to_string(
 			enum uic_link_state state)
diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c index
fbcdfb713542..9e9b93867cab 100644
--- a/drivers/scsi/ufs/ufs_bsg.c
+++ b/drivers/scsi/ufs/ufs_bsg.c
@@ -10,6 +10,7 @@
 #include <scsi/scsi_host.h>
 #include "ufs_bsg.h"
 #include "ufshcd.h"
+#include "ufshcd-priv.h"
 
 static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
 				       struct utp_upiu_query *qr)
diff --git a/drivers/scsi/ufs/ufshcd-crypto.h
b/drivers/scsi/ufs/ufshcd-crypto.h
index 57dd51256b57..9f98f18f9646 100644
--- a/drivers/scsi/ufs/ufshcd-crypto.h
+++ b/drivers/scsi/ufs/ufshcd-crypto.h
@@ -8,6 +8,8 @@
 
 #include <scsi/scsi_cmnd.h>
 #include "ufshcd.h"
+#include "ufshcd-priv.h"
+#include "ufshci.h"
 
 #ifdef CONFIG_SCSI_UFS_CRYPTO
 
diff --git a/drivers/scsi/ufs/ufshcd-priv.h b/drivers/scsi/ufs/ufshcd-priv.h
new file mode 100644 index 000000000000..4ceb0c63aa15
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-priv.h
@@ -0,0 +1,277 @@
+#ifndef _UFSHCD_PRIV_H_
+#define _UFSHCD_PRIV_H_
+
+#include <linux/pm_runtime.h>
+#include "ufshcd.h"
+
+static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba) {
+	return !hba->shutting_down;
+}
+
+void ufshcd_schedule_eh_work(struct ufs_hba *hba);
+
+static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
+							struct ufs_hba *hba)
+{
+	return hba->caps &
UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
+}
+
+static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) {
+	if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED)
+		return hba->dev_info.wb_dedicated_lu;
+	return 0;
+}
+
+#ifdef CONFIG_SCSI_UFS_HWMON
+void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask); void 
+ufs_hwmon_remove(struct ufs_hba *hba); void 
+ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask); #else static 
+inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {} static 
+inline void ufs_hwmon_remove(struct ufs_hba *hba) {} static inline void 
+ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {} #endif
+
+int ufshcd_read_desc_param(struct ufs_hba *hba,
+			   enum desc_idn desc_id,
+			   int desc_index,
+			   u8 param_offset,
+			   u8 *param_read_buf,
+			   u8 param_size);
+int ufshcd_query_attr_retry(struct ufs_hba *hba, enum query_opcode opcode,
+			    enum attr_idn idn, u8 index, u8 selector,
+			    u32 *attr_val);
+int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
+		      enum attr_idn idn, u8 index, u8 selector, u32
*attr_val); int 
+ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
+	enum flag_idn idn, u8 index, bool *flag_res); void 
+ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
+
+#define SD_ASCII_STD true
+#define SD_RAW false
+int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
+			    u8 **buf, bool ascii);
+
+int ufshcd_hold(struct ufs_hba *hba, bool async); void 
+ufshcd_release(struct ufs_hba *hba);
+
+void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn
desc_id,
+				  int *desc_length);
+
+int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command 
+*uic_cmd);
+
+int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
+			     struct utp_upiu_req *req_upiu,
+			     struct utp_upiu_req *rsp_upiu,
+			     int msgcode,
+			     u8 *desc_buff, int *buff_len,
+			     enum query_opcode desc_op);
+
+int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable);
+
+/* Wrapper functions for safely calling variant operations */ static 
+inline const char *ufshcd_get_var_name(struct ufs_hba *hba) {
+	if (hba->vops)
+		return hba->vops->name;
+	return "";
+}
+
+static inline void ufshcd_vops_exit(struct ufs_hba *hba) {
+	if (hba->vops && hba->vops->exit)
+		return hba->vops->exit(hba);
+}
+
+static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba) 
+{
+	if (hba->vops && hba->vops->get_ufs_hci_version)
+		return hba->vops->get_ufs_hci_version(hba);
+
+	return ufshcd_readl(hba, REG_UFS_VERSION); }
+
+static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,
+			bool up, enum ufs_notify_change_status status) {
+	if (hba->vops && hba->vops->clk_scale_notify)
+		return hba->vops->clk_scale_notify(hba, up, status);
+	return 0;
+}
+
+static inline void ufshcd_vops_event_notify(struct ufs_hba *hba,
+					    enum ufs_event_type evt,
+					    void *data)
+{
+	if (hba->vops && hba->vops->event_notify)
+		hba->vops->event_notify(hba, evt, data); }
+
+static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,
+					enum ufs_notify_change_status
status) {
+	if (hba->vops && hba->vops->setup_clocks)
+		return hba->vops->setup_clocks(hba, on, status);
+	return 0;
+}
+
+static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba,
+						bool status)
+{
+	if (hba->vops && hba->vops->hce_enable_notify)
+		return hba->vops->hce_enable_notify(hba, status);
+
+	return 0;
+}
+static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba,
+						bool status)
+{
+	if (hba->vops && hba->vops->link_startup_notify)
+		return hba->vops->link_startup_notify(hba, status);
+
+	return 0;
+}
+
+static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,
+				  enum ufs_notify_change_status status,
+				  struct ufs_pa_layer_attr *dev_max_params,
+				  struct ufs_pa_layer_attr *dev_req_params)
{
+	if (hba->vops && hba->vops->pwr_change_notify)
+		return hba->vops->pwr_change_notify(hba, status,
+					dev_max_params, dev_req_params);
+
+	return -ENOTSUPP;
+}
+
+static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
+					int tag, u8 tm_function)
+{
+	if (hba->vops && hba->vops->setup_task_mgmt)
+		return hba->vops->setup_task_mgmt(hba, tag, tm_function); }
+
+static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
+					enum uic_cmd_dme cmd,
+					enum ufs_notify_change_status
status) {
+	if (hba->vops && hba->vops->hibern8_notify)
+		return hba->vops->hibern8_notify(hba, cmd, status); }
+
+static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba) {
+	if (hba->vops && hba->vops->apply_dev_quirks)
+		return hba->vops->apply_dev_quirks(hba);
+	return 0;
+}
+
+static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba) {
+	if (hba->vops && hba->vops->fixup_dev_quirks)
+		hba->vops->fixup_dev_quirks(hba);
+}
+
+static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op
op,
+				enum ufs_notify_change_status status) {
+	if (hba->vops && hba->vops->suspend)
+		return hba->vops->suspend(hba, op, status);
+
+	return 0;
+}
+
+static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum 
+ufs_pm_op op) {
+	if (hba->vops && hba->vops->resume)
+		return hba->vops->resume(hba, op);
+
+	return 0;
+}
+
+static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) {
+	if (hba->vops && hba->vops->dbg_register_dump)
+		hba->vops->dbg_register_dump(hba);
+}
+
+static inline int ufshcd_vops_device_reset(struct ufs_hba *hba) {
+	if (hba->vops && hba->vops->device_reset)
+		return hba->vops->device_reset(hba);
+
+	return -EOPNOTSUPP;
+}
+
+static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
+		struct devfreq_dev_profile *p,
+		struct devfreq_simple_ondemand_data *data) {
+	if (hba->vops && hba->vops->config_scaling_param)
+		hba->vops->config_scaling_param(hba, p, data); }
+
+extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
+
+/**
+ * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN
+ * @scsi_lun: scsi LUN id
+ *
+ * Returns UPIU LUN id
+ */
+static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun) {
+	if (scsi_is_wlun(scsi_lun))
+		return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID)
+			| UFS_UPIU_WLUN_ID;
+	else
+		return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID; }
+
+int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask); 
+int ufshcd_write_ee_control(struct ufs_hba *hba); int 
+ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask,
+			     u16 set, u16 clr);
+
+static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba,
+					    u16 set, u16 clr)
+{
+	return ufshcd_update_ee_control(hba, &hba->ee_drv_mask,
+					&hba->ee_usr_mask, set, clr);
+}
+
+static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba,
+					    u16 set, u16 clr)
+{
+	return ufshcd_update_ee_control(hba, &hba->ee_usr_mask,
+					&hba->ee_drv_mask, set, clr);
+}
+
+static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba) {
+	return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) {
+	return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba) {
+	pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+static inline int ufshcd_rpm_resume(struct ufs_hba *hba) {
+	return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+static inline int ufshcd_rpm_put(struct ufs_hba *hba) {
+	return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
+}
+
+#endif /* _UFSHCD_PRIV_H_ */
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index
de366247628b..bab0f1ee41e6 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -32,6 +32,7 @@
 #include "ufs_bsg.h"
 #include "ufs_quirks.h"
 #include "ufshcd-crypto.h"
+#include "ufshcd-priv.h"
 #include "ufshcd.h"
 #include "ufshpb.h"
 #include "unipro.h"
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index
ab0c643296c0..b13469fb1e15 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -1007,11 +1007,6 @@ static inline bool ufshcd_is_wb_allowed(struct
ufs_hba *hba)
 	return hba->caps & UFSHCD_CAP_WB_EN;
 }
 
-static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba) -{
-	return !hba->shutting_down;
-}
-
 #define ufshcd_writel(hba, val, reg)	\
 	writel((val), (hba)->mmio_base + (reg))
 #define ufshcd_readl(hba, reg)	\
@@ -1075,18 +1070,6 @@ static inline void *ufshcd_get_variant(struct ufs_hba
*hba)
 	BUG_ON(!hba);
 	return hba->priv;
 }
-static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
-							struct ufs_hba *hba)
-{
-	return hba->caps &
UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
-}
-
-static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) -{
-	if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED)
-		return hba->dev_info.wb_dedicated_lu;
-	return 0;
-}
 
 #ifdef CONFIG_SCSI_UFS_HWMON
 void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask); @@ -1230,13 +1213,6 @@
int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm);  void
ufshcd_resume_complete(struct device *dev);
 
 /* Wrapper functions for safely calling variant operations */ -static
inline const char *ufshcd_get_var_name(struct ufs_hba *hba) -{
-	if (hba->vops)
-		return hba->vops->name;
-	return "";
-}
-
 static inline int ufshcd_vops_init(struct ufs_hba *hba)  {
 	if (hba->vops && hba->vops->init)
@@ -1245,61 +1221,6 @@ static inline int ufshcd_vops_init(struct ufs_hba
*hba)
 	return 0;
 }
 
-static inline void ufshcd_vops_exit(struct ufs_hba *hba) -{
-	if (hba->vops && hba->vops->exit)
-		return hba->vops->exit(hba);
-}
-
-static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba) -{
-	if (hba->vops && hba->vops->get_ufs_hci_version)
-		return hba->vops->get_ufs_hci_version(hba);
-
-	return ufshcd_readl(hba, REG_UFS_VERSION);
-}
-
-static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,
-			bool up, enum ufs_notify_change_status status)
-{
-	if (hba->vops && hba->vops->clk_scale_notify)
-		return hba->vops->clk_scale_notify(hba, up, status);
-	return 0;
-}
-
-static inline void ufshcd_vops_event_notify(struct ufs_hba *hba,
-					    enum ufs_event_type evt,
-					    void *data)
-{
-	if (hba->vops && hba->vops->event_notify)
-		hba->vops->event_notify(hba, evt, data);
-}
-
-static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,
-					enum ufs_notify_change_status
status)
-{
-	if (hba->vops && hba->vops->setup_clocks)
-		return hba->vops->setup_clocks(hba, on, status);
-	return 0;
-}
-
-static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba,
-						bool status)
-{
-	if (hba->vops && hba->vops->hce_enable_notify)
-		return hba->vops->hce_enable_notify(hba, status);
-
-	return 0;
-}
-static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba,
-						bool status)
-{
-	if (hba->vops && hba->vops->link_startup_notify)
-		return hba->vops->link_startup_notify(hba, status);
-
-	return 0;
-}
-
 static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)  {
 	if (hba->vops && hba->vops->phy_initialization) @@ -1308,102 +1229,8
@@ static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)
 	return 0;
 }
 
-static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,
-				  enum ufs_notify_change_status status,
-				  struct ufs_pa_layer_attr *dev_max_params,
-				  struct ufs_pa_layer_attr *dev_req_params)
-{
-	if (hba->vops && hba->vops->pwr_change_notify)
-		return hba->vops->pwr_change_notify(hba, status,
-					dev_max_params, dev_req_params);
-
-	return -ENOTSUPP;
-}
-
-static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
-					int tag, u8 tm_function)
-{
-	if (hba->vops && hba->vops->setup_task_mgmt)
-		return hba->vops->setup_task_mgmt(hba, tag, tm_function);
-}
-
-static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
-					enum uic_cmd_dme cmd,
-					enum ufs_notify_change_status
status)
-{
-	if (hba->vops && hba->vops->hibern8_notify)
-		return hba->vops->hibern8_notify(hba, cmd, status);
-}
-
-static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba) -{
-	if (hba->vops && hba->vops->apply_dev_quirks)
-		return hba->vops->apply_dev_quirks(hba);
-	return 0;
-}
-
-static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba) -{
-	if (hba->vops && hba->vops->fixup_dev_quirks)
-		hba->vops->fixup_dev_quirks(hba);
-}
-
-static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op
op,
-				enum ufs_notify_change_status status)
-{
-	if (hba->vops && hba->vops->suspend)
-		return hba->vops->suspend(hba, op, status);
-
-	return 0;
-}
-
-static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op
op) -{
-	if (hba->vops && hba->vops->resume)
-		return hba->vops->resume(hba, op);
-
-	return 0;
-}
-
-static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) -{
-	if (hba->vops && hba->vops->dbg_register_dump)
-		hba->vops->dbg_register_dump(hba);
-}
-
-static inline int ufshcd_vops_device_reset(struct ufs_hba *hba) -{
-	if (hba->vops && hba->vops->device_reset)
-		return hba->vops->device_reset(hba);
-
-	return -EOPNOTSUPP;
-}
-
-static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
-		struct devfreq_dev_profile *p,
-		struct devfreq_simple_ondemand_data *data)
-{
-	if (hba->vops && hba->vops->config_scaling_param)
-		hba->vops->config_scaling_param(hba, p, data);
-}
-
 extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
 
-/**
- * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN
- * @scsi_lun: scsi LUN id
- *
- * Returns UPIU LUN id
- */
-static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun) -{
-	if (scsi_is_wlun(scsi_lun))
-		return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID)
-			| UFS_UPIU_WLUN_ID;
-	else
-		return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID;
-}
-
 int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
 		     const char *prefix);
 
@@ -1412,43 +1239,4 @@ int ufshcd_write_ee_control(struct ufs_hba *hba);
int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16
*other_mask,
 			     u16 set, u16 clr);
 
-static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba,
-					    u16 set, u16 clr)
-{
-	return ufshcd_update_ee_control(hba, &hba->ee_drv_mask,
-					&hba->ee_usr_mask, set, clr);
-}
-
-static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba,
-					    u16 set, u16 clr)
-{
-	return ufshcd_update_ee_control(hba, &hba->ee_usr_mask,
-					&hba->ee_drv_mask, set, clr);
-}
-
-static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba) -{
-	return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
-}
-
-static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) -{
-	return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev);
-}
-
-static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba) -{
-	pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev);
-}
-
-static inline int ufshcd_rpm_resume(struct ufs_hba *hba) -{
-	return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev);
-}
-
-static inline int ufshcd_rpm_put(struct ufs_hba *hba) -{
-	return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
-}
-
 #endif /* End of Header */
diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index
d456404e5c49..daac81290f50 100644
--- a/drivers/scsi/ufs/ufshpb.c
+++ b/drivers/scsi/ufs/ufshpb.c
@@ -17,6 +17,7 @@
 #include "../sd.h"
 #include "ufshcd.h"
 #include "ufshpb.h"
+#include "ufshcd-priv.h"
 
 #define ACTIVATION_THRESHOLD 8 /* 8 IOs */  #define READ_TO_MS 1000


^ permalink raw reply related	[flat|nested] 101+ messages in thread

* RE: [PATCH 19/29] scsi: ufs: Remove the TRUE and FALSE definitions
  2022-03-31 22:34 ` [PATCH 19/29] scsi: ufs: Remove the TRUE and FALSE definitions Bart Van Assche
@ 2022-04-01  2:19   ` Chanho Park
  2022-04-04  2:39     ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Chanho Park @ 2022-04-01  2:19 UTC (permalink / raw)
  To: 'Bart Van Assche', 'Martin K . Petersen'
  Cc: 'Jaegeuk Kim', 'Adrian Hunter',
	linux-scsi, 'James E.J. Bottomley',
	'Krzysztof Kozlowski', 'Alim Akhtar',
	'Bean Huo', 'Inki Dae', 'Avri Altman',
	'Daejun Park'

> In the Linux kernel coding style document
> (Documentation/process/coding-style.rst) it is recommended to use the type
> 'bool' and also the values 'true' and 'false'. Hence this patch that
> removes the definitions and uses of TRUE and FALSE from the UFS driver.

The third parameter of ufshcd_dme_set is "int" type.
I think the coding-style doc recommends to use "bool" as comparison purpose
not int type conversion.
However, regarding C99 and C11, they might be converted to 0 and 1
respectively.

Reviewed-by: Chanho Park <chanho61.park@samsung.com>

The usage of 'TRUE' and 'FALSE' seems to be written as following the
description of below JEDEC doc.
> A Flag is a single Boolean value that represents a TRUE or FALSE, '0' or
'1', ON or OFF type of value.

Best Regards,
Chanho Park

> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufs-exynos.c |  4 ++--  drivers/scsi/ufs/ufs-exynos.h |
> 8 ++++----
>  drivers/scsi/ufs/ufshcd.c     |  8 ++++----
>  drivers/scsi/ufs/unipro.h     | 14 --------------
>  4 files changed, 10 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
> index 474a4a064a68..0b99c74955ef 100644
> --- a/drivers/scsi/ufs/ufs-exynos.c
> +++ b/drivers/scsi/ufs/ufs-exynos.c
> @@ -704,7 +704,7 @@ static void exynos_ufs_establish_connt(struct
> exynos_ufs *ufs)
> 
>  	/* local unipro attributes */
>  	ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID), DEV_ID);
> -	ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), TRUE);
> +	ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), true);
>  	ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), PEER_DEV_ID);
>  	ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERCPORTID), PEER_CPORT_ID);
>  	ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), CPORT_DEF_FLAGS); @@
> -1028,7 +1028,7 @@ static int exynos_ufs_post_link(struct ufs_hba *hba)
> 
>  	if (ufs->opts & EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB)
>  		ufshcd_dme_set(hba,
> -			UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), TRUE);
> +			UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), true);
> 
>  	if (attr->pa_granularity) {
>  		exynos_ufs_enable_dbg_mode(hba);
> diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
> index 1c33e5466082..0b0a3d530ca6 100644
> --- a/drivers/scsi/ufs/ufs-exynos.h
> +++ b/drivers/scsi/ufs/ufs-exynos.h
> @@ -248,22 +248,22 @@ long exynos_ufs_calc_time_cntr(struct exynos_ufs *,
> long);
> 
>  static inline void exynos_ufs_enable_ov_tm(struct ufs_hba *hba)  {
> -	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), TRUE);
> +	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), true);
>  }
> 
>  static inline void exynos_ufs_disable_ov_tm(struct ufs_hba *hba)  {
> -	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), FALSE);
> +	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), false);
>  }
> 
>  static inline void exynos_ufs_enable_dbg_mode(struct ufs_hba *hba)  {
> -	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), TRUE);
> +	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), true);
>  }
> 
>  static inline void exynos_ufs_disable_dbg_mode(struct ufs_hba *hba)  {
> -	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), FALSE);
> +	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), false);
>  }
> 
>  #endif /* _UFS_EXYNOS_H_ */
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index
> c36658d97774..c81b5f3f0b9a 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -4325,18 +4325,18 @@ static int ufshcd_change_power_mode(struct ufs_hba
> *hba,
>  			pwr_mode->lane_rx);
>  	if (pwr_mode->pwr_rx == FASTAUTO_MODE ||
>  			pwr_mode->pwr_rx == FAST_MODE)
> -		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), TRUE);
> +		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), true);
>  	else
> -		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), FALSE);
> +		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), false);
> 
>  	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXGEAR), pwr_mode->gear_tx);
>  	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_ACTIVETXDATALANES),
>  			pwr_mode->lane_tx);
>  	if (pwr_mode->pwr_tx == FASTAUTO_MODE ||
>  			pwr_mode->pwr_tx == FAST_MODE)
> -		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), TRUE);
> +		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), true);
>  	else
> -		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), FALSE);
> +		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), false);
> 
>  	if (pwr_mode->pwr_rx == FASTAUTO_MODE ||
>  	    pwr_mode->pwr_tx == FASTAUTO_MODE || diff --git
> a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h index
> bdd0fa6a3c74..91152d8386e6 100644
> --- a/drivers/scsi/ufs/unipro.h
> +++ b/drivers/scsi/ufs/unipro.h
> @@ -298,20 +298,6 @@ enum ufs_unipro_ver {
>  #define T_TC0TXMAXSDUSIZE	0x4060
>  #define T_TC1TXMAXSDUSIZE	0x4061
> 
> -#ifdef FALSE
> -#undef FALSE
> -#endif
> -
> -#ifdef TRUE
> -#undef TRUE
> -#endif
> -
> -/* Boolean attribute values */
> -enum {
> -	FALSE = 0,
> -	TRUE,
> -};
> -
>  /* CPort setting */
>  #define E2EFC_ON	(1 << 0)
>  #define E2EFC_OFF	(0 << 0)


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 14/29] scsi: ufs: Make the config_scaling_param calls type safe
  2022-03-31 23:48   ` Bjorn Andersson
@ 2022-04-01  4:08     ` Bart Van Assche
  2022-04-03  3:51       ` Bjorn Andersson
  0 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-04-01  4:08 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Martin K . Petersen, Jaegeuk Kim, Adrian Hunter, linux-scsi,
	Andy Gross, James E.J. Bottomley, Bean Huo, Daejun Park,
	Avri Altman, Can Guo, Asutosh Das

On 3/31/22 16:48, Bjorn Andersson wrote:
> On Thu 31 Mar 15:34 PDT 2022, Bart Van Assche wrote:
>>   #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
>>   static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
>> -					  struct devfreq_dev_profile *p,
>> -					  void *data)
>> +		struct devfreq_dev_profile *p,
>> +		struct devfreq_simple_ondemand_data *d)
> 
> This doesn't look to be properly indended to match the '('?
> What does ./scripts/checkpatch.pl --strict say about the patch?
> 
> 
> Other than that, the change looks good, so feel free to add my r-b once
> you've double checked the indentation.
> 
> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Checkpatch doesn't verify this kind of indentation as far as I know.
Anyway, I will fix up the indentation when I repost this patch. Thanks
for having taken a look.

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file
  2022-04-01  0:21   ` Chanho Park
@ 2022-04-01  4:14     ` Bart Van Assche
  2022-04-01  4:30       ` Chanho Park
  0 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-04-01  4:14 UTC (permalink / raw)
  To: Chanho Park, 'Martin K . Petersen'
  Cc: 'Jaegeuk Kim', 'Adrian Hunter',
	linux-scsi, 'James E.J. Bottomley', 'Avri Altman',
	'Can Guo', 'Asutosh Das', 'Daejun Park',
	'Guenter Roeck', 'Bean Huo',
	'Keoseong Park', 'Mike Snitzer',
	'Eric Biggers', 'Jens Axboe',
	'Ulf Hansson'

On 3/31/22 17:21, Chanho Park wrote:
> I'm seeing below build error when I applied this patch. Any baseline do I
> need?
> 
> In file included from drivers/scsi/ufs/ufs-sysfs.c:9:
> drivers/scsi/ufs/ufshcd-priv.h:32:20: error: redefinition of
> 'ufs_hwmon_probe'
>     32 | static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
>        |                    ^~~~~~~~~~~~~~~
> In file included from drivers/scsi/ufs/ufshcd-priv.h:5,
>                   from drivers/scsi/ufs/ufs-sysfs.c:9:
> drivers/scsi/ufs/ufshcd.h:1079:20: note: previous definition of
> 'ufs_hwmon_probe' with type 'void(struct ufs_hba *, u8)' {aka 'void(struct
> ufs_hba *, unsigned char)'}
>   1079 | static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
>        |                    ^~~~~~~~~~~~~~~
> In file included from drivers/scsi/ufs/ufs-sysfs.c:9:
> drivers/scsi/ufs/ufshcd-priv.h:33:20: error: redefinition of
> 'ufs_hwmon_remove'
>     33 | static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
>        |                    ^~~~~~~~~~~~~~~~
> In file included from drivers/scsi/ufs/ufshcd-priv.h:5,
>                   from drivers/scsi/ufs/ufs-sysfs.c:9:
> drivers/scsi/ufs/ufshcd.h:1080:20: note: previous definition of
> 'ufs_hwmon_remove' with type 'void(struct ufs_hba *)'
>   1080 | static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
>        |                    ^~~~~~~~~~~~~~~~

Hi Chanho,

Patch 26/29 duplicates the ufs_hwmon_remove() etc. definitions instead 
of moving these. The patch below needs to be applied on top of this 
patch to make it build. I will fix this when I repost this patch series.

Thanks,

Bart.

diff --git a/include/scsi/ufshcd.h b/include/scsi/ufshcd.h
index 946d915f5a42..3caec295d87a 100644
--- a/include/scsi/ufshcd.h
+++ b/include/scsi/ufshcd.h
@@ -1071,16 +1071,6 @@ static inline void *ufshcd_get_variant(struct 
ufs_hba *hba)
  	return hba->priv;
  }

-#ifdef CONFIG_SCSI_UFS_HWMON
-void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
-void ufs_hwmon_remove(struct ufs_hba *hba);
-void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask);
-#else
-static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
-static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
-static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 
ee_mask) {}
-#endif
-
  #ifdef CONFIG_PM
  extern int ufshcd_runtime_suspend(struct device *dev);
  extern int ufshcd_runtime_resume(struct device *dev);

^ permalink raw reply related	[flat|nested] 101+ messages in thread

* RE: [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file
  2022-04-01  4:14     ` Bart Van Assche
@ 2022-04-01  4:30       ` Chanho Park
  0 siblings, 0 replies; 101+ messages in thread
From: Chanho Park @ 2022-04-01  4:30 UTC (permalink / raw)
  To: 'Bart Van Assche', 'Martin K . Petersen'
  Cc: 'Jaegeuk Kim', 'Adrian Hunter',
	linux-scsi, 'James E.J. Bottomley', 'Avri Altman',
	'Daejun Park', 'Guenter Roeck',
	'Bean Huo', 'Keoseong Park',
	'Mike Snitzer', 'Eric Biggers',
	'Jens Axboe', 'Ulf Hansson'

> > I'm seeing below build error when I applied this patch. Any baseline
> > do I need?
> >
> > In file included from drivers/scsi/ufs/ufs-sysfs.c:9:
> > drivers/scsi/ufs/ufshcd-priv.h:32:20: error: redefinition of
> > 'ufs_hwmon_probe'
> >     32 | static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask)
> {}
> >        |                    ^~~~~~~~~~~~~~~
> > In file included from drivers/scsi/ufs/ufshcd-priv.h:5,
> >                   from drivers/scsi/ufs/ufs-sysfs.c:9:
> > drivers/scsi/ufs/ufshcd.h:1079:20: note: previous definition of
> > 'ufs_hwmon_probe' with type 'void(struct ufs_hba *, u8)' {aka
> > 'void(struct ufs_hba *, unsigned char)'}
> >   1079 | static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask)
> {}
> >        |                    ^~~~~~~~~~~~~~~
> > In file included from drivers/scsi/ufs/ufs-sysfs.c:9:
> > drivers/scsi/ufs/ufshcd-priv.h:33:20: error: redefinition of
> > 'ufs_hwmon_remove'
> >     33 | static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
> >        |                    ^~~~~~~~~~~~~~~~
> > In file included from drivers/scsi/ufs/ufshcd-priv.h:5,
> >                   from drivers/scsi/ufs/ufs-sysfs.c:9:
> > drivers/scsi/ufs/ufshcd.h:1080:20: note: previous definition of
> > 'ufs_hwmon_remove' with type 'void(struct ufs_hba *)'
> >   1080 | static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
> >        |                    ^~~~~~~~~~~~~~~~
> 
> Hi Chanho,
> 
> Patch 26/29 duplicates the ufs_hwmon_remove() etc. definitions instead of
> moving these. The patch below needs to be applied on top of this patch to
> make it build. I will fix this when I repost this patch series.

Below can fix the build errors. Thanks for the update.

Best Regards,
Chanho Park

> 
> Thanks,
> 
> Bart.
> 
> diff --git a/include/scsi/ufshcd.h b/include/scsi/ufshcd.h index
> 946d915f5a42..3caec295d87a 100644
> --- a/include/scsi/ufshcd.h
> +++ b/include/scsi/ufshcd.h
> @@ -1071,16 +1071,6 @@ static inline void *ufshcd_get_variant(struct
> ufs_hba *hba)
>   	return hba->priv;
>   }
> 
> -#ifdef CONFIG_SCSI_UFS_HWMON
> -void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask); -void
> ufs_hwmon_remove(struct ufs_hba *hba); -void ufs_hwmon_notify_event(struct
> ufs_hba *hba, u8 ee_mask); -#else -static inline void
> ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {} -static inline void
> ufs_hwmon_remove(struct ufs_hba *hba) {} -static inline void
> ufs_hwmon_notify_event(struct ufs_hba *hba, u8
> ee_mask) {}
> -#endif
> -
>   #ifdef CONFIG_PM
>   extern int ufshcd_runtime_suspend(struct device *dev);
>   extern int ufshcd_runtime_resume(struct device *dev);


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory
  2022-03-31 22:34 ` [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory Bart Van Assche
@ 2022-04-01  5:12   ` Christoph Hellwig
  2022-04-01 13:56     ` Bart Van Assche
  2022-04-01  6:38   ` Adrian Hunter
  1 sibling, 1 reply; 101+ messages in thread
From: Christoph Hellwig @ 2022-04-01  5:12 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, Jaegeuk Kim, Adrian Hunter, linux-scsi,
	James E.J. Bottomley, Krzysztof Kozlowski, Stanley Chu,
	Andy Gross, Bjorn Andersson, Matthias Brugger, Avri Altman,
	Can Guo, Asutosh Das, Bean Huo, Guenter Roeck, Daejun Park,
	Keoseong Park, Eric Biggers, Ulf Hansson, Mike Snitzer,
	Jens Axboe, Geert Uytterhoeven, Anders Roxell, Peter Wang,
	Chanho Park, Alim Akhtar, Inki Dae, Phillip Potter,
	Greg Kroah-Hartman, Ye Bin, ChanWoo Lee, Sergey Shtylyov,
	Srinivas Kandagatla, Xiaoke Wang, Jinyoung Choi,
	Gustavo A. R. Silva, Kiwoong Kim

This lacks a changelog.  And making such a mess of the directory and
creating annoyingly long paths better have a really good one.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 04/29] scsi: ufs: Remove ufshcd_lrb.sense_bufflen
       [not found] ` <CGME20220331223522epcas2p4f8f20c2ec00dbc6d5a7bf855a1dd7395@epcms2p5>
@ 2022-04-01  6:14   ` Keoseong Park
  0 siblings, 0 replies; 101+ messages in thread
From: Keoseong Park @ 2022-04-01  6:14 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Avri Altman, Daejun Park, Can Guo, Asutosh Das

Hi Bart,
>ufshcd_lrb.sense_bufflen is set but never read. Hence remove this struct
>member.
> 
>Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Keoseong Park <keosung.park@samsung.com>

Best Regards,
Keoseong Park

>---
> drivers/scsi/ufs/ufshcd.c | 3 ---
> drivers/scsi/ufs/ufshcd.h | 2 --
> 2 files changed, 5 deletions(-)
> 
>diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
>index c60519372b3b..e52e86b0b7a3 100644
>--- a/drivers/scsi/ufs/ufshcd.c
>+++ b/drivers/scsi/ufs/ufshcd.c
>@@ -2789,7 +2789,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
>         lrbp = &hba->lrb[tag];
>         WARN_ON(lrbp->cmd);
>         lrbp->cmd = cmd;
>-        lrbp->sense_bufflen = UFS_SENSE_SIZE;
>         lrbp->sense_buffer = cmd->sense_buffer;
>         lrbp->task_tag = tag;
>         lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
>@@ -2830,7 +2829,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
>                 struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag)
> {
>         lrbp->cmd = NULL;
>-        lrbp->sense_bufflen = 0;
>         lrbp->sense_buffer = NULL;
>         lrbp->task_tag = tag;
>         lrbp->lun = 0; /* device management cmd is not specific to any LUN */
>@@ -6802,7 +6800,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
>         lrbp = &hba->lrb[tag];
>         WARN_ON(lrbp->cmd);
>         lrbp->cmd = NULL;
>-        lrbp->sense_bufflen = 0;
>         lrbp->sense_buffer = NULL;
>         lrbp->task_tag = tag;
>         lrbp->lun = 0;
>diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
>index b2740b51a546..b6162b208d99 100644
>--- a/drivers/scsi/ufs/ufshcd.h
>+++ b/drivers/scsi/ufs/ufshcd.h
>@@ -182,7 +182,6 @@ struct ufs_pm_lvl_states {
>  * @ucd_req_dma_addr: UPIU request dma address for debug
>  * @cmd: pointer to SCSI command
>  * @sense_buffer: pointer to sense buffer address of the SCSI command
>- * @sense_bufflen: Length of the sense buffer
>  * @scsi_status: SCSI status of the command
>  * @command_type: SCSI, UFS, Query.
>  * @task_tag: Task tag of the command
>@@ -207,7 +206,6 @@ struct ufshcd_lrb {
> 
>         struct scsi_cmnd *cmd;
>         u8 *sense_buffer;
>-        unsigned int sense_bufflen;
>         int scsi_status;
> 
>         int command_type;
> 

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 13/29] scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown()
  2022-03-31 22:34 ` [PATCH 13/29] scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown() Bart Van Assche
@ 2022-04-01  6:20   ` Adrian Hunter
  2022-04-01 13:52     ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Adrian Hunter @ 2022-04-01  6:20 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, linux-scsi, James E.J. Bottomley, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

On 01/04/2022 1.34, Bart Van Assche wrote:
> Quiescing LUNs falls outside the scope of a shutdown callback. The shutdown
> callback is called from inside the reboot() system call and the reboot()
> system call is called after user space has stopped accessing block devices.
> Hence this patch that removes the quiescing calls from
> ufshcd_wl_shutdown(). This patch makes shutdown faster since multiple
> synchronize_rcu() calls are removed.

AFAIK there is nothing stopping shutdown being called during intense UFS I/O.
What happens then?

> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufshcd.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index a48362165672..ae08c7964f2d 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -9212,9 +9212,7 @@ static int ufshcd_wl_resume(struct device *dev)
>  static void ufshcd_wl_shutdown(struct device *dev)
>  {
>  	struct scsi_device *sdev = to_scsi_device(dev);
> -	struct ufs_hba *hba;
> -
> -	hba = shost_priv(sdev->host);
> +	struct ufs_hba *hba = shost_priv(sdev->host);
>  
>  	down(&hba->host_sem);
>  	hba->shutting_down = true;
> @@ -9222,12 +9220,6 @@ static void ufshcd_wl_shutdown(struct device *dev)
>  
>  	/* Turn on everything while shutting down */
>  	ufshcd_rpm_get_sync(hba);
> -	scsi_device_quiesce(sdev);
> -	shost_for_each_device(sdev, hba->host) {
> -		if (sdev == hba->sdev_ufs_device)
> -			continue;
> -		scsi_device_quiesce(sdev);
> -	}
>  	__ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);
>  }
>  


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory
  2022-03-31 22:34 ` [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory Bart Van Assche
  2022-04-01  5:12   ` Christoph Hellwig
@ 2022-04-01  6:38   ` Adrian Hunter
  2022-04-01 13:58     ` Bart Van Assche
  1 sibling, 1 reply; 101+ messages in thread
From: Adrian Hunter @ 2022-04-01  6:38 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, linux-scsi, James E.J. Bottomley,
	Krzysztof Kozlowski, Stanley Chu, Andy Gross, Bjorn Andersson,
	Matthias Brugger, Avri Altman, Can Guo, Asutosh Das, Bean Huo,
	Guenter Roeck, Daejun Park, Keoseong Park, Eric Biggers,
	Ulf Hansson, Mike Snitzer, Jens Axboe, Geert Uytterhoeven,
	Anders Roxell, Peter Wang, Chanho Park, Alim Akhtar, Inki Dae,
	Phillip Potter, Greg Kroah-Hartman, Ye Bin, ChanWoo Lee,
	Sergey Shtylyov, Srinivas Kandagatla, Xiaoke Wang, Jinyoung Choi,
	Gustavo A. R. Silva, Kiwoong Kim

On 01/04/2022 1.34, Bart Van Assche wrote:
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---

Commit message?

In particular drivers/ufs/core and drivers/ufs/host would seem a
more typical arrangement.


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 25/29] scsi: ufs: Minimize #include directives
  2022-03-31 22:34 ` [PATCH 25/29] scsi: ufs: Minimize #include directives Bart Van Assche
@ 2022-04-01  6:53   ` Adrian Hunter
  2022-04-01 13:52     ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Adrian Hunter @ 2022-04-01  6:53 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, linux-scsi, James E.J. Bottomley,
	Krzysztof Kozlowski, Stanley Chu, Andy Gross, Bjorn Andersson,
	Matthias Brugger, Asutosh Das, Avri Altman, Daejun Park,
	Chanho Park, Alim Akhtar, Bean Huo, Peter Wang, Phillip Potter,
	Greg Kroah-Hartman, Can Guo, Keoseong Park, Ulf Hansson,
	Eric Biggers, Mike Snitzer, Srinivas Kandagatla, Xiaoke Wang,
	Sergey Shtylyov, Gustavo A. R. Silva, Kiwoong Kim

On 01/04/2022 1.34, Bart Van Assche wrote:
> Sort #include directives alphabetically.

I do not think we should start the "what is the correct order for includes" debate.
Can't we leave them alone.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 00/29] UFS patches for kernel v5.19
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (29 preceding siblings ...)
       [not found] ` <CGME20220331223522epcas2p4f8f20c2ec00dbc6d5a7bf855a1dd7395@epcms2p5>
@ 2022-04-01  9:28 ` Bean Huo
  2022-04-01  9:32 ` Bean Huo
  31 siblings, 0 replies; 101+ messages in thread
From: Bean Huo @ 2022-04-01  9:28 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, Can Guo
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

Bart,

Agree that the current UFS driver is messy, but I don't think there was
such a big structural change before UFS 4.0 was released, especially
the design of the UFS CQE driver. If you already have a plan for CQE,
it's best to state it in the patch. If you have made such a big change
in an environment that is now very stable, do we have to make changes
after UFS 4.0? ?


Kind regards,
Bean


On Thu, 2022-03-31 at 15:33 -0700, Bart Van Assche wrote:
> Hi Martin,
> 
> This patch series includes the following changes:
> - Separation of UFS core and UFS driver source code into separate
> directories.
> - Split the ufshcd.h header file into two header files - one file
> that
>   defines the interface with UFS drivers and another file with
> definitions
>   only used in the core.
> - Multiple source code cleanup patches.
> - A few patches with minor functional changes.
> 
> Please consider these changes for kernel v5.19.
> 
> Thank you,
> 
> Bart.
> 
> Bart Van Assche (29):
>   scsi: ufs: Declare ufshcd_wait_for_register() static
>   scsi: ufs: Remove superfluous boolean conversions
>   scsi: ufs: Simplify statements that return a boolean
>   scsi: ufs: Remove ufshcd_lrb.sense_bufflen
>   scsi: ufs: Remove ufshcd_lrb.sense_buffer
>   scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup()
>   scsi: ufs: Remove the UFS_FIX() and END_FIX() macros
>   scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk
>   scsi: ufs: Declare the quirks array const
>   scsi: ufs: Invert the return value of ufshcd_is_hba_active()
>   scsi: ufs: Remove unused constants and code
>   scsi: ufs: Switch to aggregate initialization
>   scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown()
>   scsi: ufs: Make the config_scaling_param calls type safe
>   scsi: ufs: Remove the driver version
>   scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun
>   scsi: ufs: Use an SPDX license identifier in the Kconfig file
>   scsi: ufs: Remove paths from source code comments
>   scsi: ufs: Remove the TRUE and FALSE definitions
>   scsi: ufs: Remove locking from around single register writes
>   scsi: ufs: Introduce ufshcd_clkgate_delay_set()
>   scsi: ufs: qcom: Fix ufs_qcom_resume()
>   scsi: ufs: Remove unnecessary ufshcd-crypto.h include directives
>   scsi: ufs: Fix kernel-doc syntax in ufshcd.h
>   scsi: ufs: Minimize #include directives
>   scsi: ufs: Split the ufshcd.h header file
>   scsi: ufs: Move the struct ufs_ref_clk definition
>   scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition
>   scsi: ufs: Split the drivers/scsi/ufs directory
> 
>  drivers/scsi/Kconfig                          |   3 +-
>  drivers/scsi/Makefile                         |   4 +-
>  drivers/scsi/ufs-core/Kconfig                 |  82 ++++
>  drivers/scsi/ufs-core/Makefile                |  10 +
>  drivers/scsi/{ufs => ufs-core}/ufs-debugfs.c  |   4 +-
>  drivers/scsi/{ufs => ufs-core}/ufs-debugfs.h  |   0
>  .../{ufs => ufs-core}/ufs-fault-injection.c   |   4 +-
>  .../{ufs => ufs-core}/ufs-fault-injection.h   |   0
>  drivers/scsi/{ufs => ufs-core}/ufs-hwmon.c    |   4 +-
>  drivers/scsi/{ufs => ufs-core}/ufs-sysfs.c    |   8 +-
>  drivers/scsi/{ufs => ufs-core}/ufs-sysfs.h    |   3 +-
>  drivers/scsi/{ufs => ufs-core}/ufs_bsg.c      |   6 +
>  drivers/scsi/{ufs => ufs-core}/ufs_bsg.h      |   7 +-
>  .../scsi/{ufs => ufs-core}/ufshcd-crypto.c    |   2 +-
>  .../scsi/{ufs => ufs-core}/ufshcd-crypto.h    |   7 +-
>  drivers/scsi/ufs-core/ufshcd-priv.h           | 296 ++++++++++++++
>  drivers/scsi/{ufs => ufs-core}/ufshcd.c       | 254 ++++++------
>  drivers/scsi/{ufs => ufs-core}/ufshpb.c       |  10 +-
>  drivers/scsi/{ufs => ufs-core}/ufshpb.h       |   0
>  drivers/scsi/ufs-drivers/Kconfig              | 118 ++++++
>  drivers/scsi/{ufs => ufs-drivers}/Makefile    |  12 -
>  .../scsi/{ufs => ufs-drivers}/cdns-pltfrm.c   |   5 +-
>  .../{ufs => ufs-drivers}/tc-dwc-g210-pci.c    |   8 +-
>  .../{ufs => ufs-drivers}/tc-dwc-g210-pltfrm.c |  10 +-
>  .../scsi/{ufs => ufs-drivers}/tc-dwc-g210.c   |   8 +-
>  .../scsi/{ufs => ufs-drivers}/tc-dwc-g210.h   |   2 +
>  .../scsi/{ufs => ufs-drivers}/ti-j721e-ufs.c  |   0
>  .../scsi/{ufs => ufs-drivers}/ufs-exynos.c    |  17 +-
>  .../scsi/{ufs => ufs-drivers}/ufs-exynos.h    |   8 +-
>  drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.c  |  17 +-
>  drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.h  |   0
>  .../{ufs => ufs-drivers}/ufs-mediatek-trace.h |   2 +-
>  .../scsi/{ufs => ufs-drivers}/ufs-mediatek.c  |  40 +-
>  .../scsi/{ufs => ufs-drivers}/ufs-mediatek.h  |   0
>  .../scsi/{ufs => ufs-drivers}/ufs-qcom-ice.c  |   3 +-
>  drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.c  |  49 +--
>  drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.h  |   6 +-
>  .../scsi/{ufs => ufs-drivers}/ufshcd-dwc.c    |   6 +-
>  .../scsi/{ufs => ufs-drivers}/ufshcd-dwc.h    |   2 +
>  .../scsi/{ufs => ufs-drivers}/ufshcd-pci.c    |  14 +-
>  .../scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.c |  35 +-
>  .../scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.h |   2 +-
>  .../scsi/{ufs => ufs-drivers}/ufshci-dwc.h    |   0
>  drivers/scsi/ufs/Kconfig                      | 211 ----------
>  {drivers/scsi/ufs => include/scsi}/ufs.h      |  35 --
>  .../scsi/ufs => include/scsi}/ufs_quirks.h    |  15 +-
>  {drivers/scsi/ufs => include/scsi}/ufshcd.h   | 366 ++++----------
> ----
>  {drivers/scsi/ufs => include/scsi}/ufshci.h   |   2 +
>  {drivers/scsi/ufs => include/scsi}/unipro.h   |  16 -
>  49 files changed, 856 insertions(+), 857 deletions(-)
>  create mode 100644 drivers/scsi/ufs-core/Kconfig
>  create mode 100644 drivers/scsi/ufs-core/Makefile
>  rename drivers/scsi/{ufs => ufs-core}/ufs-debugfs.c (99%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-debugfs.h (100%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-fault-injection.c (100%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-fault-injection.h (100%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-hwmon.c (98%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-sysfs.c (99%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-sysfs.h (95%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs_bsg.c (97%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs_bsg.h (77%)
>  rename drivers/scsi/{ufs => ufs-core}/ufshcd-crypto.c (99%)
>  rename drivers/scsi/{ufs => ufs-core}/ufshcd-crypto.h (94%)
>  create mode 100644 drivers/scsi/ufs-core/ufshcd-priv.h
>  rename drivers/scsi/{ufs => ufs-core}/ufshcd.c (98%)
>  rename drivers/scsi/{ufs => ufs-core}/ufshpb.c (99%)
>  rename drivers/scsi/{ufs => ufs-core}/ufshpb.h (100%)
>  create mode 100644 drivers/scsi/ufs-drivers/Kconfig
>  rename drivers/scsi/{ufs => ufs-drivers}/Makefile (56%)
>  rename drivers/scsi/{ufs => ufs-drivers}/cdns-pltfrm.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210-pci.c (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210-pltfrm.c (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210.h (95%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ti-j721e-ufs.c (100%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-exynos.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-exynos.h (97%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.h (100%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek-trace.h (92%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek.c (97%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek.h (100%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom-ice.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.c (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.h (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-dwc.c (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-dwc.h (95%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pci.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.c (94%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.h (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshci-dwc.h (100%)
>  delete mode 100644 drivers/scsi/ufs/Kconfig
>  rename {drivers/scsi/ufs => include/scsi}/ufs.h (93%)
>  rename {drivers/scsi/ufs => include/scsi}/ufs_quirks.h (94%)
>  rename {drivers/scsi/ufs => include/scsi}/ufshcd.h (82%)
>  rename {drivers/scsi/ufs => include/scsi}/ufshci.h (99%)
>  rename {drivers/scsi/ufs => include/scsi}/unipro.h (98%)
> 


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 00/29] UFS patches for kernel v5.19
  2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
                   ` (30 preceding siblings ...)
  2022-04-01  9:28 ` [PATCH 00/29] UFS patches for kernel v5.19 Bean Huo
@ 2022-04-01  9:32 ` Bean Huo
  2022-04-01 14:12   ` Bart Van Assche
  31 siblings, 1 reply; 101+ messages in thread
From: Bean Huo @ 2022-04-01  9:32 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, Can Guo
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

Bart,

Agree that the current UFS driver is messy, but I don't think there was
such a big structural change before UFS 4.0 was released, especially
the design of the UFS CQE driver. If you already have a plan for CQE,
it's best to state it in the patch. If you have made such a big change
in an environment that is now very stable, do we have to make changes
after UFS 4.0? ?


Kind regards,
Bean


On Thu, 2022-03-31 at 15:33 -0700, Bart Van Assche wrote:
> Hi Martin,
> 
> This patch series includes the following changes:
> - Separation of UFS core and UFS driver source code into separate
> directories.
> - Split the ufshcd.h header file into two header files - one file
> that
>   defines the interface with UFS drivers and another file with
> definitions
>   only used in the core.
> - Multiple source code cleanup patches.
> - A few patches with minor functional changes.
> 
> Please consider these changes for kernel v5.19.
> 
> Thank you,
> 
> Bart.
> 
> Bart Van Assche (29):
>   scsi: ufs: Declare ufshcd_wait_for_register() static
>   scsi: ufs: Remove superfluous boolean conversions
>   scsi: ufs: Simplify statements that return a boolean
>   scsi: ufs: Remove ufshcd_lrb.sense_bufflen
>   scsi: ufs: Remove ufshcd_lrb.sense_buffer
>   scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup()
>   scsi: ufs: Remove the UFS_FIX() and END_FIX() macros
>   scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk
>   scsi: ufs: Declare the quirks array const
>   scsi: ufs: Invert the return value of ufshcd_is_hba_active()
>   scsi: ufs: Remove unused constants and code
>   scsi: ufs: Switch to aggregate initialization
>   scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown()
>   scsi: ufs: Make the config_scaling_param calls type safe
>   scsi: ufs: Remove the driver version
>   scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun
>   scsi: ufs: Use an SPDX license identifier in the Kconfig file
>   scsi: ufs: Remove paths from source code comments
>   scsi: ufs: Remove the TRUE and FALSE definitions
>   scsi: ufs: Remove locking from around single register writes
>   scsi: ufs: Introduce ufshcd_clkgate_delay_set()
>   scsi: ufs: qcom: Fix ufs_qcom_resume()
>   scsi: ufs: Remove unnecessary ufshcd-crypto.h include directives
>   scsi: ufs: Fix kernel-doc syntax in ufshcd.h
>   scsi: ufs: Minimize #include directives
>   scsi: ufs: Split the ufshcd.h header file
>   scsi: ufs: Move the struct ufs_ref_clk definition
>   scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition
>   scsi: ufs: Split the drivers/scsi/ufs directory
> 
>  drivers/scsi/Kconfig                          |   3 +-
>  drivers/scsi/Makefile                         |   4 +-
>  drivers/scsi/ufs-core/Kconfig                 |  82 ++++
>  drivers/scsi/ufs-core/Makefile                |  10 +
>  drivers/scsi/{ufs => ufs-core}/ufs-debugfs.c  |   4 +-
>  drivers/scsi/{ufs => ufs-core}/ufs-debugfs.h  |   0
>  .../{ufs => ufs-core}/ufs-fault-injection.c   |   4 +-
>  .../{ufs => ufs-core}/ufs-fault-injection.h   |   0
>  drivers/scsi/{ufs => ufs-core}/ufs-hwmon.c    |   4 +-
>  drivers/scsi/{ufs => ufs-core}/ufs-sysfs.c    |   8 +-
>  drivers/scsi/{ufs => ufs-core}/ufs-sysfs.h    |   3 +-
>  drivers/scsi/{ufs => ufs-core}/ufs_bsg.c      |   6 +
>  drivers/scsi/{ufs => ufs-core}/ufs_bsg.h      |   7 +-
>  .../scsi/{ufs => ufs-core}/ufshcd-crypto.c    |   2 +-
>  .../scsi/{ufs => ufs-core}/ufshcd-crypto.h    |   7 +-
>  drivers/scsi/ufs-core/ufshcd-priv.h           | 296 ++++++++++++++
>  drivers/scsi/{ufs => ufs-core}/ufshcd.c       | 254 ++++++------
>  drivers/scsi/{ufs => ufs-core}/ufshpb.c       |  10 +-
>  drivers/scsi/{ufs => ufs-core}/ufshpb.h       |   0
>  drivers/scsi/ufs-drivers/Kconfig              | 118 ++++++
>  drivers/scsi/{ufs => ufs-drivers}/Makefile    |  12 -
>  .../scsi/{ufs => ufs-drivers}/cdns-pltfrm.c   |   5 +-
>  .../{ufs => ufs-drivers}/tc-dwc-g210-pci.c    |   8 +-
>  .../{ufs => ufs-drivers}/tc-dwc-g210-pltfrm.c |  10 +-
>  .../scsi/{ufs => ufs-drivers}/tc-dwc-g210.c   |   8 +-
>  .../scsi/{ufs => ufs-drivers}/tc-dwc-g210.h   |   2 +
>  .../scsi/{ufs => ufs-drivers}/ti-j721e-ufs.c  |   0
>  .../scsi/{ufs => ufs-drivers}/ufs-exynos.c    |  17 +-
>  .../scsi/{ufs => ufs-drivers}/ufs-exynos.h    |   8 +-
>  drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.c  |  17 +-
>  drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.h  |   0
>  .../{ufs => ufs-drivers}/ufs-mediatek-trace.h |   2 +-
>  .../scsi/{ufs => ufs-drivers}/ufs-mediatek.c  |  40 +-
>  .../scsi/{ufs => ufs-drivers}/ufs-mediatek.h  |   0
>  .../scsi/{ufs => ufs-drivers}/ufs-qcom-ice.c  |   3 +-
>  drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.c  |  49 +--
>  drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.h  |   6 +-
>  .../scsi/{ufs => ufs-drivers}/ufshcd-dwc.c    |   6 +-
>  .../scsi/{ufs => ufs-drivers}/ufshcd-dwc.h    |   2 +
>  .../scsi/{ufs => ufs-drivers}/ufshcd-pci.c    |  14 +-
>  .../scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.c |  35 +-
>  .../scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.h |   2 +-
>  .../scsi/{ufs => ufs-drivers}/ufshci-dwc.h    |   0
>  drivers/scsi/ufs/Kconfig                      | 211 ----------
>  {drivers/scsi/ufs => include/scsi}/ufs.h      |  35 --
>  .../scsi/ufs => include/scsi}/ufs_quirks.h    |  15 +-
>  {drivers/scsi/ufs => include/scsi}/ufshcd.h   | 366 ++++----------
> ----
>  {drivers/scsi/ufs => include/scsi}/ufshci.h   |   2 +
>  {drivers/scsi/ufs => include/scsi}/unipro.h   |  16 -
>  49 files changed, 856 insertions(+), 857 deletions(-)
>  create mode 100644 drivers/scsi/ufs-core/Kconfig
>  create mode 100644 drivers/scsi/ufs-core/Makefile
>  rename drivers/scsi/{ufs => ufs-core}/ufs-debugfs.c (99%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-debugfs.h (100%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-fault-injection.c (100%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-fault-injection.h (100%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-hwmon.c (98%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-sysfs.c (99%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs-sysfs.h (95%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs_bsg.c (97%)
>  rename drivers/scsi/{ufs => ufs-core}/ufs_bsg.h (77%)
>  rename drivers/scsi/{ufs => ufs-core}/ufshcd-crypto.c (99%)
>  rename drivers/scsi/{ufs => ufs-core}/ufshcd-crypto.h (94%)
>  create mode 100644 drivers/scsi/ufs-core/ufshcd-priv.h
>  rename drivers/scsi/{ufs => ufs-core}/ufshcd.c (98%)
>  rename drivers/scsi/{ufs => ufs-core}/ufshpb.c (99%)
>  rename drivers/scsi/{ufs => ufs-core}/ufshpb.h (100%)
>  create mode 100644 drivers/scsi/ufs-drivers/Kconfig
>  rename drivers/scsi/{ufs => ufs-drivers}/Makefile (56%)
>  rename drivers/scsi/{ufs => ufs-drivers}/cdns-pltfrm.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210-pci.c (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210-pltfrm.c (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/tc-dwc-g210.h (95%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ti-j721e-ufs.c (100%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-exynos.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-exynos.h (97%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-hisi.h (100%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek-trace.h (92%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek.c (97%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-mediatek.h (100%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom-ice.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.c (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufs-qcom.h (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-dwc.c (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-dwc.h (95%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pci.c (99%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.c (94%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshcd-pltfrm.h (98%)
>  rename drivers/scsi/{ufs => ufs-drivers}/ufshci-dwc.h (100%)
>  delete mode 100644 drivers/scsi/ufs/Kconfig
>  rename {drivers/scsi/ufs => include/scsi}/ufs.h (93%)
>  rename {drivers/scsi/ufs => include/scsi}/ufs_quirks.h (94%)
>  rename {drivers/scsi/ufs => include/scsi}/ufshcd.h (82%)
>  rename {drivers/scsi/ufs => include/scsi}/ufshci.h (99%)
>  rename {drivers/scsi/ufs => include/scsi}/unipro.h (98%)
> 


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 13/29] scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown()
  2022-04-01  6:20   ` Adrian Hunter
@ 2022-04-01 13:52     ` Bart Van Assche
  2022-04-01 14:35       ` Adrian Hunter
  0 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-04-01 13:52 UTC (permalink / raw)
  To: Adrian Hunter, Martin K . Petersen
  Cc: Jaegeuk Kim, linux-scsi, James E.J. Bottomley, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

On 3/31/22 23:20, Adrian Hunter wrote:
> On 01/04/2022 1.34, Bart Van Assche wrote:
>> Quiescing LUNs falls outside the scope of a shutdown callback. The shutdown
>> callback is called from inside the reboot() system call and the reboot()
>> system call is called after user space has stopped accessing block devices.
>> Hence this patch that removes the quiescing calls from
>> ufshcd_wl_shutdown(). This patch makes shutdown faster since multiple
>> synchronize_rcu() calls are removed.
> 
> AFAIK there is nothing stopping shutdown being called during intense UFS I/O.
> What happens then?

Hmm ... how could this happen? Am I perhaps misunderstanding something 
about the Linux shutdown sequence?

The UFS driver is the only driver I know that tries to stop I/O from 
inside its shutdown callback. I'm not aware of any other Linux kernel 
driver that tries to pause I/O from inside its shutdown callback.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 25/29] scsi: ufs: Minimize #include directives
  2022-04-01  6:53   ` Adrian Hunter
@ 2022-04-01 13:52     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-01 13:52 UTC (permalink / raw)
  To: Adrian Hunter, Martin K . Petersen
  Cc: Jaegeuk Kim, linux-scsi, James E.J. Bottomley,
	Krzysztof Kozlowski, Stanley Chu, Andy Gross, Bjorn Andersson,
	Matthias Brugger, Asutosh Das, Avri Altman, Daejun Park,
	Chanho Park, Alim Akhtar, Bean Huo, Peter Wang, Phillip Potter,
	Greg Kroah-Hartman, Can Guo, Keoseong Park, Ulf Hansson,
	Eric Biggers, Mike Snitzer, Srinivas Kandagatla, Xiaoke Wang,
	Sergey Shtylyov, Gustavo A. R. Silva, Kiwoong Kim

On 3/31/22 23:53, Adrian Hunter wrote:
> On 01/04/2022 1.34, Bart Van Assche wrote:
>> Sort #include directives alphabetically.
> 
> I do not think we should start the "what is the correct order for includes" debate.
> Can't we leave them alone.

Where to insert new #include directives if the existing include 
directives are not sorted alphabetically? Anyway, I will drop this patch.

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory
  2022-04-01  5:12   ` Christoph Hellwig
@ 2022-04-01 13:56     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-01 13:56 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Martin K . Petersen, Jaegeuk Kim, Adrian Hunter, linux-scsi,
	James E.J. Bottomley, Krzysztof Kozlowski, Stanley Chu,
	Andy Gross, Bjorn Andersson, Matthias Brugger, Avri Altman,
	Can Guo, Asutosh Das, Bean Huo, Guenter Roeck, Daejun Park,
	Keoseong Park, Eric Biggers, Ulf Hansson, Mike Snitzer,
	Jens Axboe, Geert Uytterhoeven, Anders Roxell, Peter Wang,
	Chanho Park, Alim Akhtar, Inki Dae, Phillip Potter,
	Greg Kroah-Hartman, Ye Bin, ChanWoo Lee, Sergey Shtylyov,
	Srinivas Kandagatla, Xiaoke Wang, Jinyoung Choi,
	Gustavo A. R. Silva, Kiwoong Kim

On 3/31/22 22:12, Christoph Hellwig wrote:
> This lacks a changelog.  And making such a mess of the directory and
> creating annoyingly long paths better have a really good one.

I accidentally sent out a version of this patch series that is slightly 
older than the finalized patches - hence the build issue with patch 
26/29 and the missing description for this patch. Anyway, how about 
adding the following description to this patch:

"Split the drivers/scsi/ufs directory into a ufs-core and a ufs-drivers
directory. Move shared header files into the include/scsi directory.
This separation makes it clear which header files UFS drivers are
allowed to include (include/scsi/*.h) and which header files UFS drivers
are not allowed to include (drivers/scsi/ufs-core/*.h)."

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory
  2022-04-01  6:38   ` Adrian Hunter
@ 2022-04-01 13:58     ` Bart Van Assche
  2022-04-01 17:03       ` Alim Akhtar
  0 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-04-01 13:58 UTC (permalink / raw)
  To: Adrian Hunter, Martin K . Petersen
  Cc: Jaegeuk Kim, linux-scsi, James E.J. Bottomley,
	Krzysztof Kozlowski, Stanley Chu, Andy Gross, Bjorn Andersson,
	Matthias Brugger, Avri Altman, Can Guo, Asutosh Das, Bean Huo,
	Guenter Roeck, Daejun Park, Keoseong Park, Eric Biggers,
	Ulf Hansson, Mike Snitzer, Jens Axboe, Geert Uytterhoeven,
	Anders Roxell, Peter Wang, Chanho Park, Alim Akhtar, Inki Dae,
	Phillip Potter, Greg Kroah-Hartman, Ye Bin, ChanWoo Lee,
	Sergey Shtylyov, Srinivas Kandagatla, Xiaoke Wang, Jinyoung Choi,
	Gustavo A. R. Silva, Kiwoong Kim

On 3/31/22 23:38, Adrian Hunter wrote:
> In particular drivers/ufs/core and drivers/ufs/host would seem a
> more typical arrangement.

Hi Adrian,

Thanks for having taken a look at this patch series. I'm open to 
changing the directory names. Moving the ufs directory one level up 
sounds like a good idea to me. However, I'm not sure that 
drivers/ufs/host would be a better name than drivers/ufs/drivers since 
all files in drivers/ufs/core also implement UFS host controller support.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 00/29] UFS patches for kernel v5.19
  2022-04-01  9:32 ` Bean Huo
@ 2022-04-01 14:12   ` Bart Van Assche
  2022-04-03  5:59     ` Avri Altman
  0 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-04-01 14:12 UTC (permalink / raw)
  To: Bean Huo, Martin K . Petersen, Can Guo
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

On 4/1/22 02:32, Bean Huo wrote:
> Agree that the current UFS driver is messy, but I don't think there was
> such a big structural change before UFS 4.0 was released, especially
> the design of the UFS CQE driver. If you already have a plan for CQE,
> it's best to state it in the patch. If you have made such a big change
> in an environment that is now very stable, do we have to make changes
> after UFS 4.0? ?

Hi Bean,

Although this patch series will make it easier to add UFSHCI 4.0 
support, I think that UFSHCI 4.0 support can also be added without this 
patch series.

I'm not sure what CQE stands for in this context? Did you perhaps want 
to refer to MCQ?

The following changes will have to be made to add UFSHCI 4.0 support 
(this list is probably incomplete):
* At driver initialization time, query how many queues are supported by 
the UFS controller and set scsi_host->nr_hw_queues accordingly.
* Modify all code that submits SCSI commands to a UFS controller or that 
processes completions such that it uses the UFSHCI 3.0 registers for 
controllers that do not support MCQ and the UFSHCI 4.0 registers for 
controllers that do support MCQ.
* In ufshcd_queuecommand(), use blk_mq_unique_tag_to_hwq() to derive the 
controller queue index from the SCSI command data structure.
* In the command completion path, use scsi_host_find_tag() to convert 
the (MCQ index, command ID) pair into a SCSI command pointer.
* Add a mechanism to fall back to the UFSHCI 3.0 registers (no MCQ) to 
make it easy to test the UFSHCI 3.0 code paths with UFSHCI 4.0 controllers.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 13/29] scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown()
  2022-04-01 13:52     ` Bart Van Assche
@ 2022-04-01 14:35       ` Adrian Hunter
  2022-04-05 19:11         ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Adrian Hunter @ 2022-04-01 14:35 UTC (permalink / raw)
  To: Bart Van Assche, Adrian Hunter, Martin K . Petersen
  Cc: Jaegeuk Kim, linux-scsi, James E.J. Bottomley, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

On 01/04/2022 16.52, Bart Van Assche wrote:
> On 3/31/22 23:20, Adrian Hunter wrote:
>> On 01/04/2022 1.34, Bart Van Assche wrote:
>>> Quiescing LUNs falls outside the scope of a shutdown callback. The shutdown
>>> callback is called from inside the reboot() system call and the reboot()
>>> system call is called after user space has stopped accessing block devices.
>>> Hence this patch that removes the quiescing calls from
>>> ufshcd_wl_shutdown(). This patch makes shutdown faster since multiple
>>> synchronize_rcu() calls are removed.
>>
>> AFAIK there is nothing stopping shutdown being called during intense UFS I/O.
>> What happens then?
> 
> Hmm ... how could this happen? Am I perhaps misunderstanding something about the Linux shutdown sequence?
> 
> The UFS driver is the only driver I know that tries to stop I/O from inside its shutdown callback. I'm not aware of any other Linux kernel driver that tries to pause I/O from inside its shutdown callback.

We are putting the UFS device into powerdown mode.  I am not sure what will happen if the device is processing requests at the same time.


^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory
  2022-04-01 13:58     ` Bart Van Assche
@ 2022-04-01 17:03       ` Alim Akhtar
  2022-04-02  3:21         ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Alim Akhtar @ 2022-04-01 17:03 UTC (permalink / raw)
  To: 'Bart Van Assche', 'Adrian Hunter',
	'Martin K . Petersen'
  Cc: 'Jaegeuk Kim', linux-scsi, 'James E.J. Bottomley',
	'Krzysztof Kozlowski', 'Stanley Chu',
	'Andy Gross', 'Bjorn Andersson',
	'Matthias Brugger', 'Avri Altman',
	'Can Guo', 'Asutosh Das', 'Bean Huo',
	'Guenter Roeck', 'Daejun Park',
	'Keoseong Park', 'Eric Biggers',
	'Ulf Hansson', 'Mike Snitzer',
	'Jens Axboe', 'Geert Uytterhoeven',
	'Anders Roxell', 'Peter Wang',
	'Chanho Park', 'Inki Dae',
	'Phillip Potter', 'Greg Kroah-Hartman',
	'Ye Bin', 'ChanWoo Lee',
	'Sergey Shtylyov', 'Srinivas Kandagatla',
	'Xiaoke Wang', 'Jinyoung Choi',
	'Gustavo A. R. Silva', 'Kiwoong Kim'



>-----Original Message-----
>From: Bart Van Assche [mailto:bvanassche@acm.org]
>Sent: Friday, April 1, 2022 7:29 PM
>To: Adrian Hunter <adrian.hunter@intel.com>; Martin K . Petersen
><martin.petersen@oracle.com>
>Cc: Jaegeuk Kim <jaegeuk@kernel.org>; linux-scsi@vger.kernel.org; James
>E.J. Bottomley <jejb@linux.ibm.com>; Krzysztof Kozlowski
><krzk@kernel.org>; Stanley Chu <stanley.chu@mediatek.com>; Andy Gross
><agross@kernel.org>; Bjorn Andersson <bjorn.andersson@linaro.org>;
>Matthias Brugger <matthias.bgg@gmail.com>; Avri Altman
><Avri.Altman@wdc.com>; Can Guo <cang@codeaurora.org>; Asutosh Das
><asutoshd@codeaurora.org>; Bean Huo <beanhuo@micron.com>; Guenter
>Roeck <linux@roeck-us.net>; Daejun Park <daejun7.park@samsung.com>;
>Keoseong Park <keosung.park@samsung.com>; Eric Biggers
><ebiggers@google.com>; Ulf Hansson <ulf.hansson@linaro.org>; Mike Snitzer
><snitzer@redhat.com>; Jens Axboe <axboe@kernel.dk>; Geert
>Uytterhoeven <geert@linux-m68k.org>; Anders Roxell
><anders.roxell@linaro.org>; Peter Wang <peter.wang@mediatek.com>;
>Chanho Park <chanho61.park@samsung.com>; Alim Akhtar
><alim.akhtar@samsung.com>; Inki Dae <inki.dae@samsung.com>; Phillip
>Potter <phil@philpotter.co.uk>; Greg Kroah-Hartman
><gregkh@linuxfoundation.org>; Ye Bin <yebin10@huawei.com>; ChanWoo
>Lee <cw9316.lee@samsung.com>; Sergey Shtylyov
><s.shtylyov@omprussia.ru>; Srinivas Kandagatla
><srinivas.kandagatla@linaro.org>; Xiaoke Wang
><xkernel.wang@foxmail.com>; Jinyoung Choi <j-young.choi@samsung.com>;
>Gustavo A. R. Silva <gustavoars@kernel.org>; Kiwoong Kim
><kwmad.kim@samsung.com>
>Subject: Re: [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory
>
>On 3/31/22 23:38, Adrian Hunter wrote:
>> In particular drivers/ufs/core and drivers/ufs/host would seem a more
>> typical arrangement.
>
>Hi Adrian,
>
>Thanks for having taken a look at this patch series. I'm open to changing the
>directory names. Moving the ufs directory one level up sounds like a good
>idea to me. However, I'm not sure that drivers/ufs/host would be a better
>name than drivers/ufs/drivers since all files in drivers/ufs/core also implement
>UFS host controller support.
>
Hi Bart,

Interesting, it is true that ufshcd.c does have implementation of UFS HCI specification.
And since core uses a lot of vendor specific callbacks implementation, so may be 
drivers/ufs/core and 
drivers/ufs/hci-vendor or drivers/ufs/pltfm{-vendor} might be good logical one.

Having said that, looking at mmc sub-system directory structure, it is simply 
drivers/mmc/core and drivers/mmc/host


 
>Thanks,
>
>Bart.


^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 01/29] scsi: ufs: Declare ufshcd_wait_for_register() static
  2022-03-31 22:33 ` [PATCH 01/29] scsi: ufs: Declare ufshcd_wait_for_register() static Bart Van Assche
@ 2022-04-01 18:33   ` Avri Altman
  2022-04-03  9:45   ` Bean Huo
  1 sibling, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-01 18:33 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Daejun Park, Can Guo, Asutosh Das

 
> Declare this function static since it is only used inside the ufshcd.c source file.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 02/29] scsi: ufs: Remove superfluous boolean conversions
  2022-03-31 22:33 ` [PATCH 02/29] scsi: ufs: Remove superfluous boolean conversions Bart Van Assche
  2022-03-31 23:44   ` Bjorn Andersson
@ 2022-04-01 18:35   ` Avri Altman
  1 sibling, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-01 18:35 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Andy Gross,
	Bjorn Andersson, James E.J. Bottomley, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

 
> Remove "? true : false" if the preceding expression yields a boolean or if the
> result of the expression is assigned to a boolean since in these two cases the "?
> true : false" part is superfluous.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 03/29] scsi: ufs: Simplify statements that return a boolean
  2022-03-31 22:33 ` [PATCH 03/29] scsi: ufs: Simplify statements that return a boolean Bart Van Assche
  2022-03-31 23:45   ` Bjorn Andersson
@ 2022-04-01 18:49   ` Avri Altman
  2022-04-03  3:30     ` Bart Van Assche
  1 sibling, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-01 18:49 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Andy Gross,
	Bjorn Andersson, James E.J. Bottomley, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

 
> Convert "if (expr) return true; else return false;" into "return expr;"
> if either 'expr' is a boolean expression or the return type of the function is 'bool'.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Maybe also add ufshpb_is_pinned_region()

Thanks,
Avri

> ---
>  drivers/scsi/ufs/ufs-qcom.h |  5 +----
>  drivers/scsi/ufs/ufshcd.c   | 22 +++++-----------------
>  2 files changed, 6 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h index
> 8208e3a3ef59..51570224a6e2 100644
> --- a/drivers/scsi/ufs/ufs-qcom.h
> +++ b/drivers/scsi/ufs/ufs-qcom.h
> @@ -239,10 +239,7 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host
> *host);
> 
>  static inline bool ufs_qcom_cap_qunipro(struct ufs_qcom_host *host)  {
> -       if (host->caps & UFS_QCOM_CAP_QUNIPRO)
> -               return true;
> -       else
> -               return false;
> +       return host->caps & UFS_QCOM_CAP_QUNIPRO;
>  }
> 
>  /* ufs-qcom-ice.c */
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index
> 983fac14b7cd..c60519372b3b 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -939,10 +939,7 @@ static bool
> ufshcd_is_unipro_pa_params_tuning_req(struct ufs_hba *hba)
>          * logic simple, we will only do manual tuning if local unipro version
>          * doesn't support ver1.6 or later.
>          */
> -       if (ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6)
> -               return true;
> -       else
> -               return false;
> +       return ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6;
>  }
> 
>  /**
> @@ -2216,10 +2213,7 @@ static inline int ufshcd_hba_capabilities(struct
> ufs_hba *hba)
>   */
>  static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)  {
> -       if (ufshcd_readl(hba, REG_CONTROLLER_STATUS) &
> UIC_COMMAND_READY)
> -               return true;
> -       else
> -               return false;
> +       return ufshcd_readl(hba, REG_CONTROLLER_STATUS) &
> + UIC_COMMAND_READY;
>  }
> 
>  /**
> @@ -5781,10 +5775,7 @@ static bool
> ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba,
>                 return false;
>         }
>         /* Let it continue to flush when available buffer exceeds threshold */
> -       if (avail_buf < hba->vps->wb_flush_threshold)
> -               return true;
> -
> -       return false;
> +       return avail_buf < hba->vps->wb_flush_threshold;
>  }
> 
>  static void ufshcd_wb_force_disable(struct ufs_hba *hba) @@ -5863,11
> +5854,8 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba)
>                 return false;
>         }
> 
> -       if (!hba->dev_info.b_presrv_uspc_en) {
> -               if (avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10))
> -                       return true;
> -               return false;
> -       }
> +       if (!hba->dev_info.b_presrv_uspc_en)
> +               return avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10);
> 
>         return ufshcd_wb_presrv_usrspc_keep_vcc_on(hba, avail_buf);  }

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 04/29] scsi: ufs: Remove ufshcd_lrb.sense_bufflen
  2022-03-31 22:33 ` [PATCH 04/29] scsi: ufs: Remove ufshcd_lrb.sense_bufflen Bart Van Assche
@ 2022-04-01 18:56   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-01 18:56 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Daejun Park, Can Guo, Asutosh Das

 
> ufshcd_lrb.sense_bufflen is set but never read. Hence remove this struct
> member.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 05/29] scsi: ufs: Remove ufshcd_lrb.sense_buffer
  2022-03-31 22:34 ` [PATCH 05/29] scsi: ufs: Remove ufshcd_lrb.sense_buffer Bart Van Assche
@ 2022-04-01 19:21   ` Avri Altman
  2022-04-03  4:26     ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-01 19:21 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Daejun Park, Can Guo, Asutosh Das

> ufshcd_lrb.sense_buffer is NULL if ufshcd_lrb.cmd is NULL and
> ufshcd_lrb.sense_buffer points at cmd->sense_buffer if ufshcd_lrb.cmd
> is set. In other words, the ufshcd_lrb.sense_buffer member is identical
> to cmd->sense_buffer. Hence this patch that removes the
> ufshcd_lrb.sense_buffer structure member.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufshcd.c | 9 ++++-----
>  drivers/scsi/ufs/ufshcd.h | 2 --
>  2 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index e52e86b0b7a3..eddaa57b6aad 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -2127,15 +2127,17 @@ void ufshcd_send_command(struct ufs_hba *hba,
> unsigned int task_tag)
>   */
>  static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)
>  {
> +       u8 *sense_buffer = lrbp->cmd ? lrbp->cmd->sense_buffer : NULL;
lrbp->cmd  is tested in __ufshcd_transfer_req_compl(),
which is the only caller of ufshcd_transfer_rsp_status(),
which is the only caller of ufshcd_scsi_cmd_status(),
which is the only caller of ufshcd_copy_sense_data().
 
Thanks,
Avri

>         int len;
> -       if (lrbp->sense_buffer &&
> +
> +       if (sense_buffer &&
>             ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) {
>                 int len_to_copy;
> 
>                 len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len);
>                 len_to_copy = min_t(int, UFS_SENSE_SIZE, len);
> 
> -               memcpy(lrbp->sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data,
> +               memcpy(sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data,
>                        len_to_copy);
>         }
>  }
> @@ -2789,7 +2791,6 @@ static int ufshcd_queuecommand(struct Scsi_Host
> *host, struct scsi_cmnd *cmd)
>         lrbp = &hba->lrb[tag];
>         WARN_ON(lrbp->cmd);
>         lrbp->cmd = cmd;
> -       lrbp->sense_buffer = cmd->sense_buffer;
>         lrbp->task_tag = tag;
>         lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
>         lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba);
> @@ -2829,7 +2830,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba
> *hba,
>                 struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag)
>  {
>         lrbp->cmd = NULL;
> -       lrbp->sense_buffer = NULL;
>         lrbp->task_tag = tag;
>         lrbp->lun = 0; /* device management cmd is not specific to any LUN */
>         lrbp->intr_cmd = true; /* No interrupt aggregation */
> @@ -6800,7 +6800,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct
> ufs_hba *hba,
>         lrbp = &hba->lrb[tag];
>         WARN_ON(lrbp->cmd);
>         lrbp->cmd = NULL;
> -       lrbp->sense_buffer = NULL;
>         lrbp->task_tag = tag;
>         lrbp->lun = 0;
>         lrbp->intr_cmd = true;
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index b6162b208d99..b9f17219ca18 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -181,7 +181,6 @@ struct ufs_pm_lvl_states {
>   * @ucd_rsp_dma_addr: UPIU response dma address for debug
>   * @ucd_req_dma_addr: UPIU request dma address for debug
>   * @cmd: pointer to SCSI command
> - * @sense_buffer: pointer to sense buffer address of the SCSI command
>   * @scsi_status: SCSI status of the command
>   * @command_type: SCSI, UFS, Query.
>   * @task_tag: Task tag of the command
> @@ -205,7 +204,6 @@ struct ufshcd_lrb {
>         dma_addr_t ucd_prdt_dma_addr;
> 
>         struct scsi_cmnd *cmd;
> -       u8 *sense_buffer;
>         int scsi_status;
> 
>         int command_type;

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 07/29] scsi: ufs: Remove the UFS_FIX() and END_FIX() macros
  2022-03-31 22:34 ` [PATCH 07/29] scsi: ufs: Remove the UFS_FIX() and END_FIX() macros Bart Van Assche
@ 2022-04-01 19:43   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-01 19:43 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Stanley Chu,
	James E.J. Bottomley, Matthias Brugger, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das


> 
> Since these two macros reduce code readability, remove these two macros.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 08/29] scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk
  2022-03-31 22:34 ` [PATCH 08/29] scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk Bart Van Assche
@ 2022-04-01 19:47   ` Avri Altman
  2022-04-04 21:15     ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-01 19:47 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Stanley Chu,
	James E.J. Bottomley, Matthias Brugger, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

 
> Since struct ufs_dev_fix contains quirk information, rename it into struct
> ufs_dev_quirk.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Maybe squashed this one to 07/29?

Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 09/29] scsi: ufs: Declare the quirks array const
  2022-03-31 22:34 ` [PATCH 09/29] scsi: ufs: Declare the quirks array const Bart Van Assche
@ 2022-04-01 19:56   ` Avri Altman
  2022-04-04 21:14     ` Bart Van Assche
  2022-04-05  6:14   ` Avri Altman
  1 sibling, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-01 19:56 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Stanley Chu,
	James E.J. Bottomley, Matthias Brugger, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

> 
> Declare the quirks array and also its 'model' member const to make it explicit
> that these are not modified.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Sometimes it's useful to be able to add a quirk as part of e.g. a debug session in the OEM premises.
And not always we are able to recompile the kernel. 
Since we have a debugfs now, how about adding this capability, instead of blocking it?

Thanks,
Avri
> ---
>  drivers/scsi/ufs/ufs-mediatek.c | 2 +-
>  drivers/scsi/ufs/ufs_quirks.h   | 2 +-
>  drivers/scsi/ufs/ufshcd.c       | 7 ++++---
>  drivers/scsi/ufs/ufshcd.h       | 3 ++-
>  4 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
> index 217348dde6a6..9a4474210627 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -44,7 +44,7 @@
>  #define ufs_mtk_device_reset_ctrl(high, res) \
>         ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)
> 
> -static struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
> +static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
>         { .wmanufacturerid = UFS_VENDOR_MICRON,
>           .model = UFS_ANY_MODEL,
>           .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM }, diff --git
> a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h index
> e38dec5f0351..bcb4f004bed5 100644
> --- a/drivers/scsi/ufs/ufs_quirks.h
> +++ b/drivers/scsi/ufs/ufs_quirks.h
> @@ -25,7 +25,7 @@
>   */
>  struct ufs_dev_quirk {
>         u16 wmanufacturerid;
> -       u8 *model;
> +       const u8 *model;
>         unsigned int quirk;
>  };
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index
> 97b9b2b77593..931ce620fc34 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -204,7 +204,7 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum
> ufs_dev_pwr_mode dev_state,
>         return UFS_PM_LVL_0;
>  }
> 
> -static struct ufs_dev_quirk ufs_fixups[] = {
> +static const struct ufs_dev_quirk ufs_fixups[] = {
>         /* UFS cards deviations table */
>         { .wmanufacturerid = UFS_VENDOR_MICRON,
>           .model = UFS_ANY_MODEL,
> @@ -7624,9 +7624,10 @@ static void ufshcd_temp_notif_probe(struct ufs_hba
> *hba, u8 *desc_buf)
>         }
>  }
> 
> -void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups)
> +void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
> +                            const struct ufs_dev_quirk *fixups)
>  {
> -       struct ufs_dev_quirk *f;
> +       const struct ufs_dev_quirk *f;
>         struct ufs_dev_info *dev_info = &hba->dev_info;
> 
>         if (!fixups)
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index
> 3d18581afc2b..107d19e98d52 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -1180,7 +1180,8 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum
> query_opcode opcode,
> 
>  void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);  void
> ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); -void
> ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups);
> +void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
> +                            const struct ufs_dev_quirk *fixups);
>  #define SD_ASCII_STD true
>  #define SD_RAW false
>  int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory
  2022-04-01 17:03       ` Alim Akhtar
@ 2022-04-02  3:21         ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-02  3:21 UTC (permalink / raw)
  To: Alim Akhtar, 'Adrian Hunter', 'Martin K . Petersen'
  Cc: 'Jaegeuk Kim', linux-scsi, 'James E.J. Bottomley',
	'Krzysztof Kozlowski', 'Stanley Chu',
	'Andy Gross', 'Bjorn Andersson',
	'Matthias Brugger', 'Avri Altman',
	'Can Guo', 'Asutosh Das', 'Bean Huo',
	'Guenter Roeck', 'Daejun Park',
	'Keoseong Park', 'Eric Biggers',
	'Ulf Hansson', 'Mike Snitzer',
	'Jens Axboe', 'Geert Uytterhoeven',
	'Anders Roxell', 'Peter Wang',
	'Chanho Park', 'Inki Dae',
	'Phillip Potter', 'Greg Kroah-Hartman',
	'Ye Bin', 'ChanWoo Lee',
	'Sergey Shtylyov', 'Srinivas Kandagatla',
	'Xiaoke Wang', 'Jinyoung Choi',
	'Gustavo A. R. Silva', 'Kiwoong Kim'

On 4/1/22 10:03, Alim Akhtar wrote:
> Having said that, looking at mmc sub-system directory structure, it is simply
> drivers/mmc/core and drivers/mmc/host

Let's follow Adrian's proposal and use the drivers/ufs/core and 
drivers/ufs/host directory names.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 10/29] scsi: ufs: Invert the return value of ufshcd_is_hba_active()
  2022-03-31 22:34 ` [PATCH 10/29] scsi: ufs: Invert the return value of ufshcd_is_hba_active() Bart Van Assche
@ 2022-04-02  6:32   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-02  6:32 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Daejun Park, Can Guo, Asutosh Das

 
> It is confusing that ufshcd_is_hba_active() returns 'true' if the HBA is not active.
> Clear up this confusion by inverting the return value of ufshcd_is_hba_active().
> This patch does not change any functionality.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 11/29] scsi: ufs: Remove unused constants and code
  2022-03-31 22:34 ` [PATCH 11/29] scsi: ufs: Remove unused constants and code Bart Van Assche
@ 2022-04-02  6:59   ` Avri Altman
  2022-04-04  2:07     ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-02  6:59 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Daejun Park, Bean Huo, Jinyoung Choi, Can Guo, Asutosh Das

> 
> Commit 5b44a07b6bb2 ("scsi: ufs: Remove pre-defined initial voltage values
> of device power") removed the code that uses the UFS_VREG_VCC* constants
> and also the code that sets the min_uV and max_uV member variables. Hence
> also remove these constants and that member variable.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Looks fine to me, but better get an ack from Stanley,
because he specifically wrote in his commit log:
"...
Note that we keep struct ufs_vreg unchanged. This allows vendors to
    configure proper min_uV and max_uV of any regulators to make
    regulator_set_voltage() works during regulator toggling flow in the
    future. Without specific vendor configurations, min_uV and max_uV will be
    NULL by default and UFS core driver will enable or disable the regulator
    only without adjusting its voltage.
..."

Thanks,
Avri

> ---
>  drivers/scsi/ufs/ufs.h    | 11 -----------
>  drivers/scsi/ufs/ufshcd.c | 29 +++--------------------------
>  2 files changed, 3 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
> index 4a00c24a3209..225b5b4a2a7e 100644
> --- a/drivers/scsi/ufs/ufs.h
> +++ b/drivers/scsi/ufs/ufs.h
> @@ -562,15 +562,6 @@ struct ufs_query_res {
>         struct utp_upiu_query upiu_res;
>  };
> 
> -#define UFS_VREG_VCC_MIN_UV       2700000 /* uV */
> -#define UFS_VREG_VCC_MAX_UV       3600000 /* uV */
> -#define UFS_VREG_VCC_1P8_MIN_UV    1700000 /* uV */
> -#define UFS_VREG_VCC_1P8_MAX_UV    1950000 /* uV */
> -#define UFS_VREG_VCCQ_MIN_UV      1140000 /* uV */
> -#define UFS_VREG_VCCQ_MAX_UV      1260000 /* uV */
> -#define UFS_VREG_VCCQ2_MIN_UV     1700000 /* uV */
> -#define UFS_VREG_VCCQ2_MAX_UV     1950000 /* uV */
> -
>  /*
>   * VCCQ & VCCQ2 current requirement when UFS device is in sleep state
>   * and link is in Hibern8 state.
> @@ -582,8 +573,6 @@ struct ufs_vreg {
>         const char *name;
>         bool always_on;
>         bool enabled;
> -       int min_uV;
> -       int max_uV;
>         int max_uA;
>  };
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 1ed54f6aef82..a48362165672 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -8309,33 +8309,10 @@ static inline int ufshcd_config_vreg_hpm(struct
> ufs_hba *hba,
>  static int ufshcd_config_vreg(struct device *dev,
>                 struct ufs_vreg *vreg, bool on)
>  {
> -       int ret = 0;
> -       struct regulator *reg;
> -       const char *name;
> -       int min_uV, uA_load;
> -
> -       BUG_ON(!vreg);
> -
> -       reg = vreg->reg;
> -       name = vreg->name;
> -
> -       if (regulator_count_voltages(reg) > 0) {
> -               uA_load = on ? vreg->max_uA : 0;
> -               ret = ufshcd_config_vreg_load(dev, vreg, uA_load);
> -               if (ret)
> -                       goto out;
> +       if (regulator_count_voltages(vreg->reg) <= 0)
> +               return 0;
> 
> -               if (vreg->min_uV && vreg->max_uV) {
> -                       min_uV = on ? vreg->min_uV : 0;
> -                       ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
> -                       if (ret)
> -                               dev_err(dev,
> -                                       "%s: %s set voltage failed, err=%d\n",
> -                                       __func__, name, ret);
> -               }
> -       }
> -out:
> -       return ret;
> +       return ufshcd_config_vreg_load(dev, vreg, on ? vreg->max_uA : 0);
>  }
> 
>  static int ufshcd_enable_vreg(struct device *dev, struct ufs_vreg *vreg)

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 12/29] scsi: ufs: Switch to aggregate initialization
  2022-03-31 22:34 ` [PATCH 12/29] scsi: ufs: Switch to aggregate initialization Bart Van Assche
@ 2022-04-02  7:07   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-02  7:07 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Xiaoke Wang, Daejun Park, Sergey Shtylyov,
	Srinivas Kandagatla

> 
> Make it easier to verify for humans that ufshcd_init_pwr_dev_param() initializes
> all structure members. This patch does not change any functionality.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 02/29] scsi: ufs: Remove superfluous boolean conversions
  2022-03-31 23:44   ` Bjorn Andersson
@ 2022-04-03  3:20     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-03  3:20 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Martin K . Petersen, Jaegeuk Kim, Adrian Hunter, linux-scsi,
	Andy Gross, James E.J. Bottomley, Bean Huo, Avri Altman,
	Daejun Park, Can Guo, Asutosh Das

On 3/31/22 16:44, Bjorn Andersson wrote:
> On Thu 31 Mar 15:33 PDT 2022, Bart Van Assche wrote:
>> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
>> index 0d2e950d0865..808b677f6083 100644
>> --- a/drivers/scsi/ufs/ufs-qcom.c
>> +++ b/drivers/scsi/ufs/ufs-qcom.c
>> @@ -299,8 +299,7 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
>>   	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
>>   	struct phy *phy = host->generic_phy;
>>   	int ret = 0;
>> -	bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)
>> -							? true : false;
>> +	bool is_rate_B = UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B;
> 
> UFS_QCOM_LIMIT_HS_RATE is defined as PA_HS_MODE_B. I wonder if this is
> expected to change at some point, or if we could clean this up further
> (in a future change).

If someone would like to work on this I can help with reviewing the 
resulting patches.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 03/29] scsi: ufs: Simplify statements that return a boolean
  2022-04-01 18:49   ` Avri Altman
@ 2022-04-03  3:30     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-03  3:30 UTC (permalink / raw)
  To: Avri Altman, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Andy Gross,
	Bjorn Andersson, James E.J. Bottomley, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

On 4/1/22 11:49, Avri Altman wrote:
>   
>> Convert "if (expr) return true; else return false;" into "return expr;"
>> if either 'expr' is a boolean expression or the return type of the function is 'bool'.
>>
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> Maybe also add ufshpb_is_pinned_region()

Thanks for the feedback. I will take a look at that function.

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 14/29] scsi: ufs: Make the config_scaling_param calls type safe
  2022-04-01  4:08     ` Bart Van Assche
@ 2022-04-03  3:51       ` Bjorn Andersson
  0 siblings, 0 replies; 101+ messages in thread
From: Bjorn Andersson @ 2022-04-03  3:51 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, Jaegeuk Kim, Adrian Hunter, linux-scsi,
	Andy Gross, James E.J. Bottomley, Bean Huo, Daejun Park,
	Avri Altman, Can Guo, Asutosh Das

On Thu 31 Mar 21:08 PDT 2022, Bart Van Assche wrote:

> On 3/31/22 16:48, Bjorn Andersson wrote:
> > On Thu 31 Mar 15:34 PDT 2022, Bart Van Assche wrote:
> > >   #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
> > >   static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
> > > -					  struct devfreq_dev_profile *p,
> > > -					  void *data)
> > > +		struct devfreq_dev_profile *p,
> > > +		struct devfreq_simple_ondemand_data *d)
> > 
> > This doesn't look to be properly indended to match the '('?
> > What does ./scripts/checkpatch.pl --strict say about the patch?
> > 
> > 
> > Other than that, the change looks good, so feel free to add my r-b once
> > you've double checked the indentation.
> > 
> > Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> 
> Checkpatch doesn't verify this kind of indentation as far as I know.

I was expecting to get the "Alignment should match open parenthesis",
but apparently this case doesn't trigger that check, for some reason...

> Anyway, I will fix up the indentation when I repost this patch.

Cool, thanks!

PS. This patch is quite trivial and could definitely be merged
independent of the big shuffling later in the series.
If you send such patches on their own, or at least early in the series
its possible for the maintainer to pick it up while you continue to
iterate the more complex things at the end - and hence you won't
continue to respin 29 patches.

> Thanks for having taken a look.
> 

You're welcome,
Bjorn

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 05/29] scsi: ufs: Remove ufshcd_lrb.sense_buffer
  2022-04-01 19:21   ` Avri Altman
@ 2022-04-03  4:26     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-03  4:26 UTC (permalink / raw)
  To: Avri Altman, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Daejun Park, Can Guo, Asutosh Das

On 4/1/22 12:21, Avri Altman wrote:
>> ufshcd_lrb.sense_buffer is NULL if ufshcd_lrb.cmd is NULL and
>> ufshcd_lrb.sense_buffer points at cmd->sense_buffer if ufshcd_lrb.cmd
>> is set. In other words, the ufshcd_lrb.sense_buffer member is identical
>> to cmd->sense_buffer. Hence this patch that removes the
>> ufshcd_lrb.sense_buffer structure member.
>>
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>> ---
>>   drivers/scsi/ufs/ufshcd.c | 9 ++++-----
>>   drivers/scsi/ufs/ufshcd.h | 2 --
>>   2 files changed, 4 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
>> index e52e86b0b7a3..eddaa57b6aad 100644
>> --- a/drivers/scsi/ufs/ufshcd.c
>> +++ b/drivers/scsi/ufs/ufshcd.c
>> @@ -2127,15 +2127,17 @@ void ufshcd_send_command(struct ufs_hba *hba,
>> unsigned int task_tag)
>>    */
>>   static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)
>>   {
>> +       u8 *sense_buffer = lrbp->cmd ? lrbp->cmd->sense_buffer : NULL;
> lrbp->cmd  is tested in __ufshcd_transfer_req_compl(),
> which is the only caller of ufshcd_transfer_rsp_status(),
> which is the only caller of ufshcd_scsi_cmd_status(),
> which is the only caller of ufshcd_copy_sense_data().

Thanks for the feedback. I will update this patch and leave out the 
lrbp->cmd test.

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 00/29] UFS patches for kernel v5.19
  2022-04-01 14:12   ` Bart Van Assche
@ 2022-04-03  5:59     ` Avri Altman
  2022-04-03 21:36       ` Bean Huo
  0 siblings, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-03  5:59 UTC (permalink / raw)
  To: Bart Van Assche, Bean Huo, Martin K . Petersen, Can Guo
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

> On 4/1/22 02:32, Bean Huo wrote:
> > Agree that the current UFS driver is messy, but I don't think there
> > was such a big structural change before UFS 4.0 was released,
> > especially the design of the UFS CQE driver. If you already have a
> > plan for CQE, it's best to state it in the patch. If you have made
> > such a big change in an environment that is now very stable, do we
> > have to make changes after UFS 4.0? ?
> 
> Hi Bean,
> 
> Although this patch series will make it easier to add UFSHCI 4.0 support, I think
> that UFSHCI 4.0 support can also be added without this patch series.
Also, UFS4.0 and its UFSHCI4.0 companion are expected to be published around end of May, right?
I doubt if we'll have platforms to test those changes within the V5.19, or even V5.20 timeframe.
So MCQ should not conflict with those, mostly structural, cleanups.

Thanks,
Avri 

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 15/29] scsi: ufs: Remove the driver version
  2022-03-31 22:34 ` [PATCH 15/29] scsi: ufs: Remove the driver version Bart Van Assche
@ 2022-04-03  7:10   ` Avri Altman
  2022-04-03 21:51     ` Bart Van Assche
  2022-04-03 15:52   ` Bean Huo
  2022-04-04  6:25   ` Avri Altman
  2 siblings, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-03  7:10 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Stanley Chu, Daejun Park, Asutosh Das, Bean Huo, Sergey Shtylyov,
	Srinivas Kandagatla, Xiaoke Wang, Can Guo

> Driver version numbers are not useful in upstream kernel code. Hence
Yet still - very common across the stack, and particularly in many scsi low level drivers.
Why the ufs drivers is any different?

> remove the driver version number from the UFS driver.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/cdns-pltfrm.c   | 1 -
>  drivers/scsi/ufs/ufshcd-pci.c    | 1 -
>  drivers/scsi/ufs/ufshcd-pltfrm.c | 1 -
>  drivers/scsi/ufs/ufshcd.c        | 1 -
>  drivers/scsi/ufs/ufshcd.h        | 1 -
>  5 files changed, 5 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c
> index 7da8be2f35c4..e91cf9fd5a95 100644
> --- a/drivers/scsi/ufs/cdns-pltfrm.c
> +++ b/drivers/scsi/ufs/cdns-pltfrm.c
> @@ -340,4 +340,3 @@ module_platform_driver(cdns_ufs_pltfrm_driver);
>  MODULE_AUTHOR("Jan Kotas <jank@cadence.com>");
>  MODULE_DESCRIPTION("Cadence UFS host controller platform driver");
>  MODULE_LICENSE("GPL v2");
> -MODULE_VERSION(UFSHCD_DRIVER_VERSION);
> diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
> index f76692053ca1..81aa14661072 100644
> --- a/drivers/scsi/ufs/ufshcd-pci.c
> +++ b/drivers/scsi/ufs/ufshcd-pci.c
> @@ -601,4 +601,3 @@ MODULE_AUTHOR("Santosh Yaragnavi
> <santosh.sy@samsung.com>");
>  MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
>  MODULE_DESCRIPTION("UFS host controller PCI glue driver");
>  MODULE_LICENSE("GPL");
> -MODULE_VERSION(UFSHCD_DRIVER_VERSION);
> diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
> index 2725ce4de1c9..81e458d31222 100644
> --- a/drivers/scsi/ufs/ufshcd-pltfrm.c
> +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
> @@ -386,4 +386,3 @@ MODULE_AUTHOR("Santosh Yaragnavi
> <santosh.sy@samsung.com>");
>  MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
>  MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
>  MODULE_LICENSE("GPL");
> -MODULE_VERSION(UFSHCD_DRIVER_VERSION);
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index ae08c7964f2d..9d433d2c616d 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -9915,4 +9915,3 @@ MODULE_AUTHOR("Santosh Yaragnavi
> <santosh.sy@samsung.com>");
>  MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
>  MODULE_DESCRIPTION("Generic UFS host controller driver Core");
>  MODULE_LICENSE("GPL");
> -MODULE_VERSION(UFSHCD_DRIVER_VERSION);
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index bb2624aabda2..49edbdb5ffd6 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -49,7 +49,6 @@
>  #include "ufshci.h"
> 
>  #define UFSHCD "ufshcd"
> -#define UFSHCD_DRIVER_VERSION "0.2"
> 
>  struct ufs_hba;


^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 16/29] scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun
  2022-03-31 22:34 ` [PATCH 16/29] scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun Bart Van Assche
@ 2022-04-03  7:25   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-03  7:25 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Daejun Park, Can Guo, Asutosh Das

 
> The new name reflects the role of this member variable better: a WLUN
> through which the power mode of the UFS device is controlled.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>


> + * @ufs_device_wlun: WLUN that controls the entire UFS device.
An optional suggestion: wlun that provides device-level interaction

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 18/29] scsi: ufs: Remove paths from source code comments
  2022-03-31 22:34 ` [PATCH 18/29] scsi: ufs: Remove paths from source code comments Bart Van Assche
@ 2022-04-03  7:33   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-03  7:33 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Stanley Chu, Geert Uytterhoeven, Peter Wang,
	Anders Roxell, Daejun Park, Krzysztof Kozlowski, Asutosh Das

 
> Since specifying the path in a source file is redundant, remove the paths from
> source code comments.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 01/29] scsi: ufs: Declare ufshcd_wait_for_register() static
  2022-03-31 22:33 ` [PATCH 01/29] scsi: ufs: Declare ufshcd_wait_for_register() static Bart Van Assche
  2022-04-01 18:33   ` Avri Altman
@ 2022-04-03  9:45   ` Bean Huo
  1 sibling, 0 replies; 101+ messages in thread
From: Bean Huo @ 2022-04-03  9:45 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Avri Altman, Daejun Park, Can Guo, Asutosh Das

On Thu, 2022-03-31 at 15:33 -0700, Bart Van Assche wrote:
> Declare this function static since it is only used inside the
> ufshcd.c
> source file.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 06/29] scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup()
  2022-03-31 22:34 ` [PATCH 06/29] scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup() Bart Van Assche
@ 2022-04-03 11:20   ` Bean Huo
  0 siblings, 0 replies; 101+ messages in thread
From: Bean Huo @ 2022-04-03 11:20 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Avri Altman, Daejun Park, Asutosh Das

On Thu, 2022-03-31 at 15:34 -0700, Bart Van Assche wrote:
> Use get_unaligned_be16(...) instead of the equivalent but harder to
> read
> be16_to_cpup((__be16 *)...).
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 15/29] scsi: ufs: Remove the driver version
  2022-03-31 22:34 ` [PATCH 15/29] scsi: ufs: Remove the driver version Bart Van Assche
  2022-04-03  7:10   ` Avri Altman
@ 2022-04-03 15:52   ` Bean Huo
  2022-04-04  6:25   ` Avri Altman
  2 siblings, 0 replies; 101+ messages in thread
From: Bean Huo @ 2022-04-03 15:52 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Stanley Chu, Daejun Park, Asutosh Das, Avri Altman, Bean Huo,
	Sergey Shtylyov, Srinivas Kandagatla, Xiaoke Wang

On Thu, 2022-03-31 at 15:34 -0700, Bart Van Assche wrote:
> Driver version numbers are not useful in upstream kernel code. Hence
> remove the driver version number from the UFS driver.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Bean Huo <beanhuo@micron.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 00/29] UFS patches for kernel v5.19
  2022-04-03  5:59     ` Avri Altman
@ 2022-04-03 21:36       ` Bean Huo
  2022-04-03 21:54         ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Bean Huo @ 2022-04-03 21:36 UTC (permalink / raw)
  To: Avri Altman, Bart Van Assche, Martin K . Petersen, Can Guo
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

On Sun, 2022-04-03 at 05:59 +0000, Avri Altman wrote:
> > On 4/1/22 02:32, Bean Huo wrote:
> > > Agree that the current UFS driver is messy, but I don't think
> > > there
> > > was such a big structural change before UFS 4.0 was released,
> > > especially the design of the UFS CQE driver. If you already have
> > > a
> > > plan for CQE, it's best to state it in the patch. If you have
> > > made
> > > such a big change in an environment that is now very stable, do
> > > we
> > > have to make changes after UFS 4.0? ?
> > 
> > Hi Bean,
> > 
> > Although this patch series will make it easier to add UFSHCI 4.0
> > support, I think
> > that UFSHCI 4.0 support can also be added without this patch
> > series.
> Also, UFS4.0 and its UFSHCI4.0 companion are expected to be published
> around end of May, right?
> I doubt if we'll have platforms to test those changes within the
> V5.19, or even V5.20 timeframe.
> So MCQ should not conflict with those, mostly structural, cleanups.
> 
> Thanks,
> Avri 

Yes, I reviewed the entire series of patches and there are no
significant structural changes. Still want to squeeze ufs driver under
driver/scsi/ufs/. No major conflict with pending submissions. Go ahead.

Kind regards,
Bean

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 15/29] scsi: ufs: Remove the driver version
  2022-04-03  7:10   ` Avri Altman
@ 2022-04-03 21:51     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-03 21:51 UTC (permalink / raw)
  To: Avri Altman, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Stanley Chu, Daejun Park, Asutosh Das, Bean Huo, Sergey Shtylyov,
	Srinivas Kandagatla, Xiaoke Wang, Can Guo

On 4/3/22 00:10, Avri Altman wrote:
>> Driver version numbers are not useful in upstream kernel code. Hence
> Yet still - very common across the stack, and particularly in many scsi low level drivers.
> Why the ufs drivers is any different?

Some authors of SCSI drivers use the version number to track which 
version of their driver ends up in Linux distributions like RHEL or 
SLES. I think that the driver version numbers are not useful in the UFS 
drivers because the current version number is 0.2 and that version 
number was assigned in 2013, more than nine years ago. See also commit
e0eca63e3421 ("[SCSI] ufs: Separate PCI code into glue driver").

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 00/29] UFS patches for kernel v5.19
  2022-04-03 21:36       ` Bean Huo
@ 2022-04-03 21:54         ` Bart Van Assche
  2022-04-04  8:12           ` Bean Huo
  0 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-04-03 21:54 UTC (permalink / raw)
  To: Bean Huo, Avri Altman, Martin K . Petersen, Can Guo
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

On 4/3/22 14:36, Bean Huo wrote:
> Yes, I reviewed the entire series of patches and there are no
> significant structural changes. Still want to squeeze ufs driver under
> driver/scsi/ufs/. No major conflict with pending submissions. Go ahead.

Hi Bean,

It has been suggested to move the UFS driver code into the following two 
directories to keep paths short:
* drivers/ufs/core
* drivers/ufs/host

That approach is similar to the approach followed for the MMC and NVMe 
drivers.

Additionally, some other SCSI drivers already occur outside the 
drivers/scsi directory, e.g. the drivers/infiniband/ulp/srp/ib_srp.c driver.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 11/29] scsi: ufs: Remove unused constants and code
  2022-04-02  6:59   ` Avri Altman
@ 2022-04-04  2:07     ` Bart Van Assche
  2022-04-05  6:55       ` Avri Altman
  0 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-04-04  2:07 UTC (permalink / raw)
  To: Avri Altman, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Daejun Park, Bean Huo, Jinyoung Choi, Can Guo, Asutosh Das,
	Stanley Chu

On 4/1/22 23:59, Avri Altman wrote:
>>
>> Commit 5b44a07b6bb2 ("scsi: ufs: Remove pre-defined initial voltage values
>> of device power") removed the code that uses the UFS_VREG_VCC* constants
>> and also the code that sets the min_uV and max_uV member variables. Hence
>> also remove these constants and that member variable.
>>
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> Looks fine to me, but better get an ack from Stanley,
> because he specifically wrote in his commit log:
> "...
> Note that we keep struct ufs_vreg unchanged. This allows vendors to
>      configure proper min_uV and max_uV of any regulators to make
>      regulator_set_voltage() works during regulator toggling flow in the
>      future. Without specific vendor configurations, min_uV and max_uV will be
>      NULL by default and UFS core driver will enable or disable the regulator
>      only without adjusting its voltage.
> ..."

(+Stanley)

Hi Stanley,

Can you take a look at this patch?

Thanks,

Bart.


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 19/29] scsi: ufs: Remove the TRUE and FALSE definitions
  2022-04-01  2:19   ` Chanho Park
@ 2022-04-04  2:39     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-04  2:39 UTC (permalink / raw)
  To: Chanho Park, 'Martin K . Petersen'
  Cc: 'Jaegeuk Kim', 'Adrian Hunter',
	linux-scsi, 'James E.J. Bottomley',
	'Krzysztof Kozlowski', 'Alim Akhtar',
	'Bean Huo', 'Inki Dae', 'Avri Altman',
	'Daejun Park'

On 3/31/22 19:19, Chanho Park wrote:
>> In the Linux kernel coding style document
>> (Documentation/process/coding-style.rst) it is recommended to use the type
>> 'bool' and also the values 'true' and 'false'. Hence this patch that
>> removes the definitions and uses of TRUE and FALSE from the UFS driver.
> 
> The third parameter of ufshcd_dme_set is "int" type.
> I think the coding-style doc recommends to use "bool" as comparison purpose
> not int type conversion.
> However, regarding C99 and C11, they might be converted to 0 and 1
> respectively.

That's right, 'true' and 'false' are converted into 1 and 0 respectively 
when converted to type 'int'. I want to keep the type of the third 
argument of ufshcd_dme_set() as 'u32' because many other values are 
passed to that parameter than only true and false.

> The usage of 'TRUE' and 'FALSE' seems to be written as following the
> description of below JEDEC doc.
> "A Flag is a single Boolean value that represents a TRUE or FALSE, '0' or
> '1', ON or OFF type of value."

Agreed that this is how it has been specified in the standard. I think 
that we have the freedom to use any symbolic names for 0 and 1 as long 
as these symbolic names are translated into the numerical values 
required by the standard.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 15/29] scsi: ufs: Remove the driver version
  2022-03-31 22:34 ` [PATCH 15/29] scsi: ufs: Remove the driver version Bart Van Assche
  2022-04-03  7:10   ` Avri Altman
  2022-04-03 15:52   ` Bean Huo
@ 2022-04-04  6:25   ` Avri Altman
  2 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-04  6:25 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Stanley Chu, Daejun Park, Asutosh Das, Bean Huo, Sergey Shtylyov,
	Srinivas Kandagatla, Xiaoke Wang, Can Guo

> 
> Driver version numbers are not useful in upstream kernel code. Hence
> remove the driver version number from the UFS driver.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 00/29] UFS patches for kernel v5.19
  2022-04-03 21:54         ` Bart Van Assche
@ 2022-04-04  8:12           ` Bean Huo
  2022-04-04 21:13             ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Bean Huo @ 2022-04-04  8:12 UTC (permalink / raw)
  To: Bart Van Assche, Avri Altman, Martin K . Petersen, quic_cang
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

On Sun, 2022-04-03 at 14:54 -0700, Bart Van Assche wrote:
> On 4/3/22 14:36, Bean Huo wrote:
> > Yes, I reviewed the entire series of patches and there are no
> > significant structural changes. Still want to squeeze ufs driver
> > under
> > driver/scsi/ufs/. No major conflict with pending submissions. Go
> > ahead.
> 
> Hi Bean,
> 
> It has been suggested to move the UFS driver code into the following
> two 
> directories to keep paths short:
> * drivers/ufs/core
> * drivers/ufs/host
> 
Bart,

Very interested in this design. I'm assuming you're still going to
continue parsing SCSI commands. Can we also shorten the UFS command
path?

Meaning we convert block requests directly to UFS UPIU commands?
instead of like the current one: block request -> CDB -> UPIU.

> That approach is similar to the approach followed for the MMC and
> NVMe 
> drivers.
> 
> Additionally, some other SCSI drivers already occur outside the 
> drivers/scsi directory, e.g. the drivers/infiniband/ulp/srp/ib_srp.c
> driver.

I'll take a look at its design, it seems to give us hope that we can
make the UFS stack more vertical.

Kind regards,
Bean




> 
> Thanks,
> 
> Bart.


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 00/29] UFS patches for kernel v5.19
  2022-04-04  8:12           ` Bean Huo
@ 2022-04-04 21:13             ` Bart Van Assche
  2022-04-05  9:33               ` Bean Huo
  0 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-04-04 21:13 UTC (permalink / raw)
  To: Bean Huo, Avri Altman, Martin K . Petersen, quic_cang
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

On 4/4/22 01:12, Bean Huo wrote:
> Very interested in this design. I'm assuming you're still going to
> continue parsing SCSI commands. Can we also shorten the UFS command
> path?
> 
> Meaning we convert block requests directly to UFS UPIU commands?
> instead of like the current one: block request -> CDB -> UPIU.

Hi Bean,

Is there any data that shows that the benefits of shortening the UFS 
command path outweigh the disadvantages? For other SCSI LLDs the cost of 
atomic operations and memory barriers in the LLD outweighs the cost of 
the operations in the SCSI core and sd drivers. I'm not sure whether 
that's also the case for the UFS driver.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 09/29] scsi: ufs: Declare the quirks array const
  2022-04-01 19:56   ` Avri Altman
@ 2022-04-04 21:14     ` Bart Van Assche
  2022-04-08 14:41       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 101+ messages in thread
From: Bart Van Assche @ 2022-04-04 21:14 UTC (permalink / raw)
  To: Avri Altman, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Stanley Chu,
	James E.J. Bottomley, Matthias Brugger, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

On 4/1/22 12:56, Avri Altman wrote:
>> Declare the quirks array and also its 'model' member const to make it explicit
>> that these are not modified.
>
> Sometimes it's useful to be able to add a quirk as part of e.g. a debug session in the OEM premises.
> And not always we are able to recompile the kernel.
> Since we have a debugfs now, how about adding this capability, instead of blocking it?

Hmm ... does declaring data const prevent from modifying that data from 
inside a kernel debugger? Don't kernel debuggers allow to cast away 
constness?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 08/29] scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk
  2022-04-01 19:47   ` Avri Altman
@ 2022-04-04 21:15     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-04 21:15 UTC (permalink / raw)
  To: Avri Altman, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Stanley Chu,
	James E.J. Bottomley, Matthias Brugger, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

On 4/1/22 12:47, Avri Altman wrote:
>   
>> Since struct ufs_dev_fix contains quirk information, rename it into struct
>> ufs_dev_quirk.
>
> Maybe squashed this one to 07/29?

Not sure what the best approach is in this case. I tried to make patches 
easy to review by splitting these if it makes sense.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 09/29] scsi: ufs: Declare the quirks array const
  2022-03-31 22:34 ` [PATCH 09/29] scsi: ufs: Declare the quirks array const Bart Van Assche
  2022-04-01 19:56   ` Avri Altman
@ 2022-04-05  6:14   ` Avri Altman
  1 sibling, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-05  6:14 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Stanley Chu,
	James E.J. Bottomley, Matthias Brugger, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

> 
> Declare the quirks array and also its 'model' member const to make it explicit
> that these are not modified.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 20/29] scsi: ufs: Remove locking from around single register writes
  2022-03-31 22:34 ` [PATCH 20/29] scsi: ufs: Remove locking from around single register writes Bart Van Assche
@ 2022-04-05  6:19   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-05  6:19 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Stanley Chu,
	James E.J. Bottomley, Matthias Brugger, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

> 
> Single register writes are atomic and hence do not need to be surrounded by
> locking. Additionally, PCI bus writes are posted asynchronously and hence
> there is no guarantee that these have finished by the time the
> spin_unlock*() call has finished.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
(maybe minus the pci reference)

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 21/29] scsi: ufs: Introduce ufshcd_clkgate_delay_set()
  2022-03-31 22:34 ` [PATCH 21/29] scsi: ufs: Introduce ufshcd_clkgate_delay_set() Bart Van Assche
@ 2022-04-05  6:20   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-05  6:20 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Stanley Chu,
	James E.J. Bottomley, Matthias Brugger, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

 
> Since the code to modify delay_ms while holding the host lock occurs twice,
> introduce a function that performs this action.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 24/29] scsi: ufs: Fix kernel-doc syntax in ufshcd.h
  2022-03-31 22:34 ` [PATCH 24/29] scsi: ufs: Fix kernel-doc syntax in ufshcd.h Bart Van Assche
@ 2022-04-05  6:27   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-05  6:27 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Daejun Park, Can Guo, Asutosh Das

> 
> This patch fixes all the warnings and errors reported by the following
> command:
> 
> scripts/kernel-doc -none drivers/scsi/ufs/ufshcd.h
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file
  2022-03-31 22:34 ` [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file Bart Van Assche
  2022-04-01  0:21   ` Chanho Park
@ 2022-04-05  6:39   ` Avri Altman
  2022-04-05 14:10     ` Bart Van Assche
  1 sibling, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-05  6:39 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Can Guo, Asutosh Das, Daejun Park, Guenter Roeck, Bean Huo,
	Keoseong Park, Mike Snitzer, Eric Biggers, Jens Axboe,
	Ulf Hansson

> diff --git a/drivers/scsi/ufs/ufshcd-priv.h b/drivers/scsi/ufs/ufshcd-priv.h
> new file mode 100644 index 000000000000..4ceb0c63aa15
> --- /dev/null
> +++ b/drivers/scsi/ufs/ufshcd-priv.h
> @@ -0,0 +1,277 @@
License identifier & copyright?


^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 27/29] scsi: ufs: Move the struct ufs_ref_clk definition
  2022-03-31 22:34 ` [PATCH 27/29] scsi: ufs: Move the struct ufs_ref_clk definition Bart Van Assche
@ 2022-04-05  6:50   ` Avri Altman
  0 siblings, 0 replies; 101+ messages in thread
From: Avri Altman @ 2022-04-05  6:50 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Daejun Park, Bean Huo, Jinyoung Choi, Can Guo, Asutosh Das

 
> Move the definition of this data structure since it is only used in a single
> source file.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

> ---
>  drivers/scsi/ufs/ufs.h    | 5 -----
>  drivers/scsi/ufs/ufshcd.c | 5 +++++
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index
> 225b5b4a2a7e..f52173b8ad96 100644
> --- a/drivers/scsi/ufs/ufs.h
> +++ b/drivers/scsi/ufs/ufs.h
> @@ -415,11 +415,6 @@ enum ufs_ref_clk_freq {
>         REF_CLK_FREQ_INVAL      = -1,
>  };
> 
> -struct ufs_ref_clk {
> -       unsigned long freq_hz;
> -       enum ufs_ref_clk_freq val;
> -};
> -
>  /* Query response result code */
>  enum {
>         QUERY_RESULT_SUCCESS                    = 0x00,
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index
> bab0f1ee41e6..27738f24c4a8 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -7959,6 +7959,11 @@ static int ufshcd_device_geo_params_init(struct
> ufs_hba *hba)
>         return err;
>  }
> 
> +struct ufs_ref_clk {
> +       unsigned long freq_hz;
> +       enum ufs_ref_clk_freq val;
> +};
> +
>  static struct ufs_ref_clk ufs_ref_clk_freqs[] = {
>         {19200000, REF_CLK_FREQ_19_2_MHZ},
>         {26000000, REF_CLK_FREQ_26_MHZ},
While at it, maybe also declare this struct as const?

Thanks,
Avri

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 28/29] scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition
  2022-03-31 22:34 ` [PATCH 28/29] scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition Bart Van Assche
@ 2022-04-05  6:53   ` Avri Altman
  2022-04-05 14:13     ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-05  6:53 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Daejun Park, Jinyoung Choi

> 
> Move the definition of this function from a public into a private header file
> since it is only used inside the UFS core.
Should be in patch 26/29? 

> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufs.h         | 19 -------------------
>  drivers/scsi/ufs/ufshcd-priv.h | 19 +++++++++++++++++++
>  2 files changed, 19 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index
> f52173b8ad96..1bba3fead2ce 100644
> --- a/drivers/scsi/ufs/ufs.h
> +++ b/drivers/scsi/ufs/ufs.h
> @@ -620,23 +620,4 @@ enum ufs_trace_tsf_t {
>         UFS_TSF_CDB, UFS_TSF_OSF, UFS_TSF_TM_INPUT,
> UFS_TSF_TM_OUTPUT  };
> 
> -/**
> - * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor
> - * @dev_info: pointer of instance of struct ufs_dev_info
> - * @lun: LU number to check
> - * @return: true if the lun has a matching unit descriptor, false otherwise
> - */
> -static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info,
> -               u8 lun, u8 param_offset)
> -{
> -       if (!dev_info || !dev_info->max_lu_supported) {
> -               pr_err("Max General LU supported by UFS isn't initialized\n");
> -               return false;
> -       }
> -       /* WB is available only for the logical unit from 0 to 7 */
> -       if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS)
> -               return lun < UFS_UPIU_MAX_WB_LUN_ID;
> -       return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info-
> >max_lu_supported);
> -}
> -
>  #endif /* End of Header */
> diff --git a/drivers/scsi/ufs/ufshcd-priv.h b/drivers/scsi/ufs/ufshcd-priv.h
> index 4ceb0c63aa15..de699b969aa6 100644
> --- a/drivers/scsi/ufs/ufshcd-priv.h
> +++ b/drivers/scsi/ufs/ufshcd-priv.h
> @@ -274,4 +274,23 @@ static inline int ufshcd_rpm_put(struct ufs_hba
> *hba)
>         return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
>  }
> 
> +/**
> + * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit
> +descriptor
> + * @dev_info: pointer of instance of struct ufs_dev_info
> + * @lun: LU number to check
> + * @return: true if the lun has a matching unit descriptor, false
> +otherwise  */ static inline bool ufs_is_valid_unit_desc_lun(struct
> +ufs_dev_info *dev_info,
> +               u8 lun, u8 param_offset) {
> +       if (!dev_info || !dev_info->max_lu_supported) {
> +               pr_err("Max General LU supported by UFS isn't initialized\n");
> +               return false;
> +       }
> +       /* WB is available only for the logical unit from 0 to 7 */
> +       if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS)
> +               return lun < UFS_UPIU_MAX_WB_LUN_ID;
> +       return lun == UFS_UPIU_RPMB_WLUN || (lun <
> +dev_info->max_lu_supported); }
> +
>  #endif /* _UFSHCD_PRIV_H_ */

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: [PATCH 11/29] scsi: ufs: Remove unused constants and code
  2022-04-04  2:07     ` Bart Van Assche
@ 2022-04-05  6:55       ` Avri Altman
  2022-04-07  2:33         ` Stanley Chu
  0 siblings, 1 reply; 101+ messages in thread
From: Avri Altman @ 2022-04-05  6:55 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Daejun Park, Bean Huo, Jinyoung Choi, Can Guo, Asutosh Das,
	Stanley Chu

> 
> On 4/1/22 23:59, Avri Altman wrote:
> >>
> >> Commit 5b44a07b6bb2 ("scsi: ufs: Remove pre-defined initial voltage
> >> values of device power") removed the code that uses the
> UFS_VREG_VCC*
> >> constants and also the code that sets the min_uV and max_uV member
> >> variables. Hence also remove these constants and that member variable.
> >>
> >> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> > Looks fine to me, but better get an ack from Stanley, because he
> > specifically wrote in his commit log:
> > "...
> > Note that we keep struct ufs_vreg unchanged. This allows vendors to
> >      configure proper min_uV and max_uV of any regulators to make
> >      regulator_set_voltage() works during regulator toggling flow in the
> >      future. Without specific vendor configurations, min_uV and max_uV will
> be
> >      NULL by default and UFS core driver will enable or disable the regulator
> >      only without adjusting its voltage.
> > ..."
> 
> (+Stanley)
> 
> Hi Stanley,
> 
> Can you take a look at this patch?
If Stanley won't comment by your v2 - please add my RB.

Thanks,
Avri

> 
> Thanks,
> 
> Bart.


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 00/29] UFS patches for kernel v5.19
  2022-04-04 21:13             ` Bart Van Assche
@ 2022-04-05  9:33               ` Bean Huo
  2022-04-05 14:22                 ` Bart Van Assche
  0 siblings, 1 reply; 101+ messages in thread
From: Bean Huo @ 2022-04-05  9:33 UTC (permalink / raw)
  To: Bart Van Assche, Avri Altman, Martin K . Petersen, quic_cang
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

Hi Bart,

On Mon, 2022-04-04 at 14:13 -0700, Bart Van Assche wrote:
> On 4/4/22 01:12, Bean Huo wrote:
> > Very interested in this design. I'm assuming you're still going to
> > continue parsing SCSI commands. Can we also shorten the UFS command
> > path?
> > 
> > Meaning we convert block requests directly to UFS UPIU commands?
> > instead of like the current one: block request -> CDB -> UPIU.
> 
> Hi Bean,
> 
> Is there any data that shows that the benefits of shortening the UFS 
> command path outweigh the disadvantages? 


For performance improvement, according to my test, if we abandon SCSI
command parsing, we can get 3%~5% performance improvement. Maybe this
is little or no improvement? Yes, reliability issues outweigh this
performance improvement. Error handling and UFS probes should also be
rebuilt. But most importantly, it makes UFS more scalable. How do you
think about adding an immature development driver to drever/staging
first? name it driver/staging/lightweight-ufs?


> For other SCSI LLDs the cost of 
> atomic operations and memory barriers in the LLD outweighs the cost
> of 
> the operations in the SCSI core and sd drivers. I'm not sure whether 
> that's also the case for the UFS driver.
> 

I didn't take this into account, maybe it's not a big deal, since the
UFS driver might use its own lock/serialization lock.

Kind regards,
Bean.

> Thanks,
> 
> Bart.


^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file
  2022-04-05  6:39   ` Avri Altman
@ 2022-04-05 14:10     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-05 14:10 UTC (permalink / raw)
  To: Avri Altman, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Can Guo, Asutosh Das, Daejun Park, Guenter Roeck, Bean Huo,
	Keoseong Park, Mike Snitzer, Eric Biggers, Jens Axboe,
	Ulf Hansson

On 4/4/22 23:39, Avri Altman wrote:
>> diff --git a/drivers/scsi/ufs/ufshcd-priv.h b/drivers/scsi/ufs/ufshcd-priv.h
>> new file mode 100644 index 000000000000..4ceb0c63aa15
>> --- /dev/null
>> +++ b/drivers/scsi/ufs/ufshcd-priv.h
>> @@ -0,0 +1,277 @@
> License identifier & copyright?

I will add the same SPDX identifier as the one that occurs in ufshcd.h.

Thanks,

Bart.



^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 28/29] scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition
  2022-04-05  6:53   ` Avri Altman
@ 2022-04-05 14:13     ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-05 14:13 UTC (permalink / raw)
  To: Avri Altman, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Bean Huo, Daejun Park, Jinyoung Choi

On 4/4/22 23:53, Avri Altman wrote:
>>
>> Move the definition of this function from a public into a private header file
>> since it is only used inside the UFS core.
>
> Should be in patch 26/29?

Patch 26/29 splits the ufshcd.h header file. This patch moves a 
definition from ufs.h into ufshcd-priv.h. I do not have a strong opinion 
about whether that should happen in separate patches or in a single patch.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 00/29] UFS patches for kernel v5.19
  2022-04-05  9:33               ` Bean Huo
@ 2022-04-05 14:22                 ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-05 14:22 UTC (permalink / raw)
  To: Bean Huo, Avri Altman, Martin K . Petersen, quic_cang
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi

[-- Attachment #1: Type: text/plain, Size: 1574 bytes --]

On 4/5/22 02:33, Bean Huo wrote:
> For performance improvement, according to my test, if we abandon SCSI
> command parsing, we can get 3%~5% performance improvement. Maybe this
> is little or no improvement? Yes, reliability issues outweigh this
> performance improvement. Error handling and UFS probes should also be
> rebuilt. But most importantly, it makes UFS more scalable. How do you
> think about adding an immature development driver to drever/staging
> first? name it driver/staging/lightweight-ufs?

I do not understand the interest in bypassing the SCSI core. The 
scsi_debug driver supports more than a million IOPS on a single CPU core 
(see also the attached script). I think this shows that the SCSI core is 
not a performance bottleneck. Additionally, I think it will take a while 
until UFS devices scale from the current performance level (100K IOPS?) 
to more than a million IOPS.

Please note that bypassing the SCSI core would make it much harder than 
necessary to introduce zoned storage support and also that this would 
lead to plenty of duplicated code.

>> For other SCSI LLDs the cost of
>> atomic operations and memory barriers in the LLD outweighs the cost
>> of
>> the operations in the SCSI core and sd drivers. I'm not sure whether
>> that's also the case for the UFS driver.
> 
> I didn't take this into account, maybe it's not a big deal, since the
> UFS driver might use its own lock/serialization lock.

Every single atomic operation in the hot path has a measurable 
performance impact. That includes locking operations.

Thanks,

Bart.

[-- Attachment #2: scsi_debug-iops --]
[-- Type: text/plain, Size: 947 bytes --]

#!/bin/bash

set -e

iodepth=${1:-1}
runtime=30
blocksize=512
numcpus=$(nproc)

modprobe -r scsi_debug
modprobe scsi_debug max_queue=128 submit_queues="$numcpus" delay=0 fake_rw=1 &&
    udevadm settle

DEVICE=$(find /sys/bus/pseudo/drivers/scsi_debug/adapter*/host*/target*/*/block/ -maxdepth 1 -type d | grep -v 'block/$' | head -1 | xargs basename) || exit $?
[ -n "$DEVICE" ] || exit $?

args=()
if [ "$iodepth" = 1 ]; then
	args+=(--ioengine=psync)
else
	args+=(--ioengine=io_uring --iodepth_batch=$((iodepth/2)) --hipri=1)
fi
args+=(
    --bs="${blocksize}"
    --direct=1
    --filename=/dev/"$DEVICE"
    --group_reporting=1
    --gtod_reduce=1
    --invalidate=1
    --iodepth="$iodepth"
    --ioscheduler=none
    --name=scsi_debug
    --numjobs=1
    --runtime="$runtime"
    --rw=read
    --thread
    --time_based=1
)
set -x
if numactl -m 0 -N 0 echo >&/dev/null; then
	numactl -m 0 -N 0 -- fio "${args[@]}"
else
	fio "${args[@]}"
fi

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 13/29] scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown()
  2022-04-01 14:35       ` Adrian Hunter
@ 2022-04-05 19:11         ` Bart Van Assche
  0 siblings, 0 replies; 101+ messages in thread
From: Bart Van Assche @ 2022-04-05 19:11 UTC (permalink / raw)
  To: Adrian Hunter, Martin K . Petersen
  Cc: Jaegeuk Kim, linux-scsi, James E.J. Bottomley, Bean Huo,
	Avri Altman, Daejun Park, Can Guo, Asutosh Das

On 4/1/22 07:35, Adrian Hunter wrote:
> On 01/04/2022 16.52, Bart Van Assche wrote:
>> On 3/31/22 23:20, Adrian Hunter wrote:
>>> On 01/04/2022 1.34, Bart Van Assche wrote:
>>>> Quiescing LUNs falls outside the scope of a shutdown callback.
>>>> The shutdown callback is called from inside the reboot() system
>>>> call and the reboot() system call is called after user space
>>>> has stopped accessing block devices. Hence this patch that
>>>> removes the quiescing calls from ufshcd_wl_shutdown(). This
>>>> patch makes shutdown faster since multiple synchronize_rcu()
>>>> calls are removed.
>>> 
>>> AFAIK there is nothing stopping shutdown being called during
>>> intense UFS I/O. What happens then?
>> 
>> Hmm ... how could this happen? Am I perhaps misunderstanding
>> something about the Linux shutdown sequence?
>> 
>> The UFS driver is the only driver I know that tries to stop I/O
>> from inside its shutdown callback. I'm not aware of any other Linux
>> kernel driver that tries to pause I/O from inside its shutdown
>> callback.
> 
> We are putting the UFS device into powerdown mode.  I am not sure
> what will happen if the device is processing requests at the same
> time.

I will remove this patch from this patch series such that it does not
block adoption of the other patches in this patch series.

Thanks,

Bart.



^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 11/29] scsi: ufs: Remove unused constants and code
  2022-04-05  6:55       ` Avri Altman
@ 2022-04-07  2:33         ` Stanley Chu
  0 siblings, 0 replies; 101+ messages in thread
From: Stanley Chu @ 2022-04-07  2:33 UTC (permalink / raw)
  To: Avri Altman, Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, James E.J. Bottomley,
	Daejun Park, Bean Huo, Jinyoung Choi, Can Guo, Asutosh Das

Hi Bart, Avri,

On Tue, 2022-04-05 at 06:55 +0000, Avri Altman wrote:
> > 
> > On 4/1/22 23:59, Avri Altman wrote:
> > > > 
> > > > Commit 5b44a07b6bb2 ("scsi: ufs: Remove pre-defined initial
> > > > voltage
> > > > values of device power") removed the code that uses the
> > 
> > UFS_VREG_VCC*
> > > > constants and also the code that sets the min_uV and max_uV
> > > > member
> > > > variables. Hence also remove these constants and that member
> > > > variable.
> > > > 
> > > > Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> > > 
> > > Looks fine to me, but better get an ack from Stanley, because he
> > > specifically wrote in his commit log:
> > > "...
> > > Note that we keep struct ufs_vreg unchanged. This allows vendors
> > > to
> > >      configure proper min_uV and max_uV of any regulators to make
> > >      regulator_set_voltage() works during regulator toggling flow
> > > in the
> > >      future. Without specific vendor configurations, min_uV and
> > > max_uV will
> > 
> > be
> > >      NULL by default and UFS core driver will enable or disable
> > > the regulator
> > >      only without adjusting its voltage.
> > > ..."
> > 
> > (+Stanley)
> > 
> > Hi Stanley,
> > 
> > Can you take a look at this patch?
> 
> If Stanley won't comment by your v2 - please add my RB.
> 
> Thanks,
> Avri
> 

Fine to me: )

Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>



^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: [PATCH 09/29] scsi: ufs: Declare the quirks array const
  2022-04-04 21:14     ` Bart Van Assche
@ 2022-04-08 14:41       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 101+ messages in thread
From: Krzysztof Kozlowski @ 2022-04-08 14:41 UTC (permalink / raw)
  To: Bart Van Assche, Avri Altman, Martin K . Petersen
  Cc: Jaegeuk Kim, Adrian Hunter, linux-scsi, Stanley Chu,
	James E.J. Bottomley, Matthias Brugger, Bean Huo, Daejun Park,
	Can Guo, Asutosh Das

On 04/04/2022 23:14, Bart Van Assche wrote:
> On 4/1/22 12:56, Avri Altman wrote:
>>> Declare the quirks array and also its 'model' member const to make it explicit
>>> that these are not modified.
>>
>> Sometimes it's useful to be able to add a quirk as part of e.g. a debug session in the OEM premises.
>> And not always we are able to recompile the kernel.
>> Since we have a debugfs now, how about adding this capability, instead of blocking it?
> 
> Hmm ... does declaring data const prevent from modifying that data from 
> inside a kernel debugger? Don't kernel debuggers allow to cast away 
> constness?

We strive to make all initdata const for several safety reasons, so such
debugging/hacking session without recompiling the kernel is not a good
reason to abandon that goal.

Such data is already const (or constified in progress) in most of the
kernel places, so why UFS is special? Other subsystems are not...

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 101+ messages in thread

end of thread, other threads:[~2022-04-08 14:41 UTC | newest]

Thread overview: 101+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 22:33 [PATCH 00/29] UFS patches for kernel v5.19 Bart Van Assche
2022-03-31 22:33 ` [PATCH 01/29] scsi: ufs: Declare ufshcd_wait_for_register() static Bart Van Assche
2022-04-01 18:33   ` Avri Altman
2022-04-03  9:45   ` Bean Huo
2022-03-31 22:33 ` [PATCH 02/29] scsi: ufs: Remove superfluous boolean conversions Bart Van Assche
2022-03-31 23:44   ` Bjorn Andersson
2022-04-03  3:20     ` Bart Van Assche
2022-04-01 18:35   ` Avri Altman
2022-03-31 22:33 ` [PATCH 03/29] scsi: ufs: Simplify statements that return a boolean Bart Van Assche
2022-03-31 23:45   ` Bjorn Andersson
2022-04-01 18:49   ` Avri Altman
2022-04-03  3:30     ` Bart Van Assche
2022-03-31 22:33 ` [PATCH 04/29] scsi: ufs: Remove ufshcd_lrb.sense_bufflen Bart Van Assche
2022-04-01 18:56   ` Avri Altman
2022-03-31 22:34 ` [PATCH 05/29] scsi: ufs: Remove ufshcd_lrb.sense_buffer Bart Van Assche
2022-04-01 19:21   ` Avri Altman
2022-04-03  4:26     ` Bart Van Assche
2022-03-31 22:34 ` [PATCH 06/29] scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup() Bart Van Assche
2022-04-03 11:20   ` Bean Huo
2022-03-31 22:34 ` [PATCH 07/29] scsi: ufs: Remove the UFS_FIX() and END_FIX() macros Bart Van Assche
2022-04-01 19:43   ` Avri Altman
2022-03-31 22:34 ` [PATCH 08/29] scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk Bart Van Assche
2022-04-01 19:47   ` Avri Altman
2022-04-04 21:15     ` Bart Van Assche
2022-03-31 22:34 ` [PATCH 09/29] scsi: ufs: Declare the quirks array const Bart Van Assche
2022-04-01 19:56   ` Avri Altman
2022-04-04 21:14     ` Bart Van Assche
2022-04-08 14:41       ` Krzysztof Kozlowski
2022-04-05  6:14   ` Avri Altman
2022-03-31 22:34 ` [PATCH 10/29] scsi: ufs: Invert the return value of ufshcd_is_hba_active() Bart Van Assche
2022-04-02  6:32   ` Avri Altman
2022-03-31 22:34 ` [PATCH 11/29] scsi: ufs: Remove unused constants and code Bart Van Assche
2022-04-02  6:59   ` Avri Altman
2022-04-04  2:07     ` Bart Van Assche
2022-04-05  6:55       ` Avri Altman
2022-04-07  2:33         ` Stanley Chu
2022-03-31 22:34 ` [PATCH 12/29] scsi: ufs: Switch to aggregate initialization Bart Van Assche
2022-04-02  7:07   ` Avri Altman
2022-03-31 22:34 ` [PATCH 13/29] scsi: ufs: Remove the LUN quiescing code from ufshcd_wl_shutdown() Bart Van Assche
2022-04-01  6:20   ` Adrian Hunter
2022-04-01 13:52     ` Bart Van Assche
2022-04-01 14:35       ` Adrian Hunter
2022-04-05 19:11         ` Bart Van Assche
2022-03-31 22:34 ` [PATCH 14/29] scsi: ufs: Make the config_scaling_param calls type safe Bart Van Assche
2022-03-31 23:48   ` Bjorn Andersson
2022-04-01  4:08     ` Bart Van Assche
2022-04-03  3:51       ` Bjorn Andersson
2022-03-31 22:34 ` [PATCH 15/29] scsi: ufs: Remove the driver version Bart Van Assche
2022-04-03  7:10   ` Avri Altman
2022-04-03 21:51     ` Bart Van Assche
2022-04-03 15:52   ` Bean Huo
2022-04-04  6:25   ` Avri Altman
2022-03-31 22:34 ` [PATCH 16/29] scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun Bart Van Assche
2022-04-03  7:25   ` Avri Altman
2022-03-31 22:34 ` [PATCH 17/29] scsi: ufs: Use an SPDX license identifier in the Kconfig file Bart Van Assche
2022-03-31 22:34 ` [PATCH 18/29] scsi: ufs: Remove paths from source code comments Bart Van Assche
2022-04-03  7:33   ` Avri Altman
2022-03-31 22:34 ` [PATCH 19/29] scsi: ufs: Remove the TRUE and FALSE definitions Bart Van Assche
2022-04-01  2:19   ` Chanho Park
2022-04-04  2:39     ` Bart Van Assche
2022-03-31 22:34 ` [PATCH 20/29] scsi: ufs: Remove locking from around single register writes Bart Van Assche
2022-04-05  6:19   ` Avri Altman
2022-03-31 22:34 ` [PATCH 21/29] scsi: ufs: Introduce ufshcd_clkgate_delay_set() Bart Van Assche
2022-04-05  6:20   ` Avri Altman
2022-03-31 22:34 ` [PATCH 22/29] scsi: ufs: qcom: Fix ufs_qcom_resume() Bart Van Assche
2022-03-31 23:50   ` Bjorn Andersson
2022-03-31 22:34 ` [PATCH 23/29] scsi: ufs: Remove unnecessary ufshcd-crypto.h include directives Bart Van Assche
2022-03-31 22:34 ` [PATCH 24/29] scsi: ufs: Fix kernel-doc syntax in ufshcd.h Bart Van Assche
2022-04-05  6:27   ` Avri Altman
2022-03-31 22:34 ` [PATCH 25/29] scsi: ufs: Minimize #include directives Bart Van Assche
2022-04-01  6:53   ` Adrian Hunter
2022-04-01 13:52     ` Bart Van Assche
2022-03-31 22:34 ` [PATCH 26/29] scsi: ufs: Split the ufshcd.h header file Bart Van Assche
2022-04-01  0:21   ` Chanho Park
2022-04-01  4:14     ` Bart Van Assche
2022-04-01  4:30       ` Chanho Park
2022-04-05  6:39   ` Avri Altman
2022-04-05 14:10     ` Bart Van Assche
2022-03-31 22:34 ` [PATCH 27/29] scsi: ufs: Move the struct ufs_ref_clk definition Bart Van Assche
2022-04-05  6:50   ` Avri Altman
2022-03-31 22:34 ` [PATCH 28/29] scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition Bart Van Assche
2022-04-05  6:53   ` Avri Altman
2022-04-05 14:13     ` Bart Van Assche
2022-03-31 22:34 ` [PATCH 29/29] scsi: ufs: Split the drivers/scsi/ufs directory Bart Van Assche
2022-04-01  5:12   ` Christoph Hellwig
2022-04-01 13:56     ` Bart Van Assche
2022-04-01  6:38   ` Adrian Hunter
2022-04-01 13:58     ` Bart Van Assche
2022-04-01 17:03       ` Alim Akhtar
2022-04-02  3:21         ` Bart Van Assche
     [not found] ` <CGME20220331223522epcas2p4f8f20c2ec00dbc6d5a7bf855a1dd7395@epcms2p5>
2022-04-01  6:14   ` [PATCH 04/29] scsi: ufs: Remove ufshcd_lrb.sense_bufflen Keoseong Park
2022-04-01  9:28 ` [PATCH 00/29] UFS patches for kernel v5.19 Bean Huo
2022-04-01  9:32 ` Bean Huo
2022-04-01 14:12   ` Bart Van Assche
2022-04-03  5:59     ` Avri Altman
2022-04-03 21:36       ` Bean Huo
2022-04-03 21:54         ` Bart Van Assche
2022-04-04  8:12           ` Bean Huo
2022-04-04 21:13             ` Bart Van Assche
2022-04-05  9:33               ` Bean Huo
2022-04-05 14:22                 ` Bart Van Assche

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.