linux-samsung-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 00/15] introduce exynosauto v9 ufs driver
       [not found] <CGME20211018124505epcas2p31437a0fae6711edeb9db5b49eb420e56@epcas2p3.samsung.com>
@ 2021-10-18 12:42 ` Chanho Park
       [not found]   ` <CGME20211018124505epcas2p2d149a4f26d3475830a36c47049591bb2@epcas2p2.samsung.com>
                     ` (15 more replies)
  0 siblings, 16 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park

In ExynosAuto(variant of the Exynos for automotive), the UFS Storage needs
to be accessed from multiple VMs. Traditional virtualization solution
provides para-virtualized block driver such as virtio-blk. However, they
can be highly depends on the Dom0 where the backend of the PV is
located. When the system gets high cpu pressure, the performance of
guest VMs are also affected. To overcome this, the SoC implements the
virtualization concept as the H/W controller level.

Below figure is a conceptual design of the UFS Multi Host architecture.

    +------+          +------+
    | OS#1 |          | OS#2 |
    +------+          +------+
       |                 |
 +------------+     +------------+
 |  Physical  |     |   Virtual  |
 |    Host    |     |    Host    |
 +------------+     +------------+
   |      |              | <-- UTP_CMD_SAP, UTP_TM_SAP
   |   +-------------------------+
   |   |    Function Arbiter     |
   |   +-------------------------+
 +-------------------------------+
 |           UTP Layer           |
 +-------------------------------+
 +-------------------------------+
 |           UIC Layer           |
 +-------------------------------+

There are two types of host controllers of the UFS host controller
that we designed. The controller has a Function Arbiter that arranges
commands of each hosts. It will arrange the doorbells among the PH and
VHs as Round-Robin. When each host transmits a command to the Arbiter,
the Arbiter transmits it to the UTP layer. Physical Host(PH) support all
UFSHCI functions(all SAPs) same as conventional UFSHCI.
Virtual Hosts(VHs) support only data transfer function(UTP_CMD_SAP and
UTP_TM_SAP).

In an environment where multiple VMs are used, the OS that has the
leadership of the system is called System OS(Dom0). This system OS will
own the PH and has a responsibility to handle UIC errors.

VHs can only supports data transfer functions compared with the PH,
they're necessary to send a request to the PH for error handling of VHs.
To interface among the PH and VHs, the UFSHCI controller supports mailbox.
The mailbox register has 8 bit fields and they can be used as
arguments of the mailbox protocol. In this initial patchset, the PH
ready message is supported and they will be implemented to the next
steps.

To support this virtual host type controller which only supports data
transfer function (TP_CMD_SAP and UTP_TM_SAP), we need to add below two
quirks.
- UFSHCD_QUIRK_BROKEN_UIC_CMD
- UFSHCD_QUIRK_SKIP_PH_CONFIGURATION

First two patches, I picked them up from Jonmin's patchset[1] and the third
patch has been dropped because it's not necessary anymore.

[1]: https://lore.kernel.org/linux-scsi/20210527030901.88403-1-jjmin.jeong@samsung.com/

Patch 0003 ~ 0010, they are changes of exynos7 ufs driver to apply
exynosauto v9 variant and PH/VH capabilities.
Patch 0011 ~ 0015, the patches introduce the exynosauto v9 ufs MHCI which
includes the PH and VHs.

Changes from v4:
- s/Arbitor/Arbiter/g of cover-letter.
- Rephrase descriptions of cover letter from original patchset.
- Except 0007-scsi-ufs-ufs-exynos-correct-timeout-value-setting-re.patch
  from this patchset and sent it independently
- Patch11/12: Consolidate sysreg and samsung,ufs-shareability-reg-offset
  property.
- Patch14:
  Drop wlun_dev_clr_ua configuration
  Add TODO: tag for further implementations

Changes from v3:
- Drop "[PATCH v3 06/17] scsi: ufs: ufs-exynos: get sysreg regmap for
  io-coherency" and squash it to Patch12
- Patch12: Use macro to avoid raw value usage and describe the value of M-Phy setting
- Patch13: Add dma-coherent property
- Patch14: Use macro to avoid raw value and describe the value of HCI_MH_ALLOWABLE_TRAN_OF_VH

Changes from v2:
- Separate dt-binding patches on top of
  https://lore.kernel.org/linux-devicetree/YUNdqnZ2kYefxFUC@robh.at.kernel.org/

Changes from v1:
- Change quirk name from UFSHCD_QUIRK_SKIP_INTERFACE_CONFIGURATION to
  UFSHCD_QUIRK_SKIP_PH_CONFIGURATION
- Add compatibles to Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml
  on top of https://lore.kernel.org/linux-scsi/20200613024706.27975-9-alim.akhtar@samsung.com/

Chanho Park (13):
  scsi: ufs: ufs-exynos: change pclk available max value
  scsi: ufs: ufs-exynos: simplify drv_data retrieval
  scsi: ufs: ufs-exynos: add refclkout_stop control
  scsi: ufs: ufs-exynos: add setup_clocks callback
  scsi: ufs: ufs-exynos: support custom version of ufs_hba_variant_ops
  scsi: ufs: ufs-exynos: add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR option
  scsi: ufs: ufs-exynos: factor out priv data init
  scsi: ufs: ufs-exynos: add pre/post_hce_enable drv callbacks
  scsi: ufs: ufs-exynos: support exynosauto v9 ufs driver
  dt-bindings: ufs: exynos-ufs: add io-coherency property
  scsi: ufs: ufs-exynos: multi-host configuration for exynosauto
  scsi: ufs: ufs-exynos: introduce exynosauto v9 virtual host
  dt-bindings: ufs: exynos-ufs: add exynosautov9 compatible

jongmin jeong (2):
  scsi: ufs: add quirk to handle broken UIC command
  scsi: ufs: add quirk to enable host controller without ph
    configuration

 .../bindings/ufs/samsung,exynos-ufs.yaml      |  10 +
 drivers/scsi/ufs/ufs-exynos.c                 | 354 +++++++++++++++++-
 drivers/scsi/ufs/ufs-exynos.h                 |  27 +-
 drivers/scsi/ufs/ufshcd.c                     |   6 +
 drivers/scsi/ufs/ufshcd.h                     |  12 +
 5 files changed, 386 insertions(+), 23 deletions(-)

-- 
2.33.0


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

* [PATCH v5 01/15] scsi: ufs: add quirk to handle broken UIC command
       [not found]   ` <CGME20211018124505epcas2p2d149a4f26d3475830a36c47049591bb2@epcas2p2.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  2021-10-28  3:18       ` Martin K. Petersen
  0 siblings, 1 reply; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, jongmin jeong, Chanho Park

From: jongmin jeong <jjmin.jeong@samsung.com>

samsung ExynosAuto9 SoC has two types of host controller interface to
support the virtualization of UFS Device.
One is the physical host(PH) that the same as conventaional UFSHCI,
and the other is the virtual host(VH) that support data transfer function
only.

In this structure, the virtual host does not support UIC command.
To support this, we add the quirk and return 0 when the UIC command
send function is called.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: James E.J. Bottomley <jejb@linux.ibm.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: jongmin jeong <jjmin.jeong@samsung.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 3 +++
 drivers/scsi/ufs/ufshcd.h | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index bd5a088f12c4..3dbfae32599c 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2323,6 +2323,9 @@ int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
 	int ret;
 	unsigned long flags;
 
+	if (hba->quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD)
+		return 0;
+
 	ufshcd_hold(hba, false);
 	mutex_lock(&hba->uic_cmd_mutex);
 	ufshcd_add_delay_before_dme_cmd(hba);
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 64ce723327b9..5d39aeb2bccb 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -589,6 +589,12 @@ enum ufshcd_quirks {
 	 * This quirk allows only sg entries aligned with page size.
 	 */
 	UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE		= 1 << 14,
+
+	/*
+	 * This quirk needs to be enabled if the host controller does not
+	 * support UIC command
+	 */
+	UFSHCD_QUIRK_BROKEN_UIC_CMD			= 1 << 15,
 };
 
 enum ufshcd_caps {
-- 
2.33.0


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

* [PATCH v5 02/15] scsi: ufs: add quirk to enable host controller without ph configuration
       [not found]   ` <CGME20211018124505epcas2p143bb8374e3399e2670ced625862a8653@epcas2p1.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, jongmin jeong, Chanho Park

From: jongmin jeong <jjmin.jeong@samsung.com>

samsung ExynosAuto SoC has two types of host controller interface to
support the virtualization of UFS Device.
One is the physical host(PH) that the same as conventaional UFSHCI,
and the other is the virtual host(VH) that support data transfer function only.

In this structure, the virtual host does not support like device management.
This patch skips the physical host interface configuration part that cannot
be performed in the virtual host.

Suggested-by: Alim Akhtar <alim.akhtar@samsung.com>
Cc: James E.J. Bottomley <jejb@linux.ibm.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: jongmin jeong <jjmin.jeong@samsung.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 3 +++
 drivers/scsi/ufs/ufshcd.h | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 3dbfae32599c..a25b88721b34 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8010,6 +8010,9 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
 	if (ret)
 		goto out;
 
+	if (hba->quirks & UFSHCD_QUIRK_SKIP_PH_CONFIGURATION)
+		goto out;
+
 	/* Debug counters initialization */
 	ufshcd_clear_dbg_ufs_stats(hba);
 
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 5d39aeb2bccb..0c474432f2ed 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -595,6 +595,12 @@ enum ufshcd_quirks {
 	 * support UIC command
 	 */
 	UFSHCD_QUIRK_BROKEN_UIC_CMD			= 1 << 15,
+
+	/*
+	 * This quirk needs to be enabled if the host controller cannot
+	 * support physical host configuration.
+	 */
+	UFSHCD_QUIRK_SKIP_PH_CONFIGURATION		= 1 << 16,
 };
 
 enum ufshcd_caps {
-- 
2.33.0


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

* [PATCH v5 03/15] scsi: ufs: ufs-exynos: change pclk available max value
       [not found]   ` <CGME20211018124505epcas2p4f96cd4d9ea01a030d07fdf25c5a3d163@epcas2p4.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Inki Dae

To support 167MHz PCLK, we need to adjust the maximum value.

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
index dadf4fd10dd8..0a31f77a5f48 100644
--- a/drivers/scsi/ufs/ufs-exynos.h
+++ b/drivers/scsi/ufs/ufs-exynos.h
@@ -99,7 +99,7 @@ struct exynos_ufs;
 #define PA_HIBERN8TIME_VAL	0x20
 
 #define PCLK_AVAIL_MIN	70000000
-#define PCLK_AVAIL_MAX	133000000
+#define PCLK_AVAIL_MAX	167000000
 
 struct exynos_ufs_uic_attr {
 	/* TX Attributes */
-- 
2.33.0


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

* [PATCH v5 04/15] scsi: ufs: ufs-exynos: simplify drv_data retrieval
       [not found]   ` <CGME20211018124505epcas2p22a463738c9ee028274be7ad06ed97a0d@epcas2p2.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park

The compatible field of exynos_ufs_drv_data is not necessary because
of_device_id already has it. Thus, we don't need it anymore and we can
get drv_data by device_get_match_data.

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 10 +---------
 drivers/scsi/ufs/ufs-exynos.h |  3 +--
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 30d0c1aba0c7..57210114ca0a 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -893,17 +893,10 @@ static int exynos_ufs_post_link(struct ufs_hba *hba)
 static int exynos_ufs_parse_dt(struct device *dev, struct exynos_ufs *ufs)
 {
 	struct device_node *np = dev->of_node;
-	struct exynos_ufs_drv_data *drv_data = &exynos_ufs_drvs;
 	struct exynos_ufs_uic_attr *attr;
 	int ret = 0;
 
-	while (drv_data->compatible) {
-		if (of_device_is_compatible(np, drv_data->compatible)) {
-			ufs->drv_data = drv_data;
-			break;
-		}
-		drv_data++;
-	}
+	ufs->drv_data = device_get_match_data(dev);
 
 	if (ufs->drv_data && ufs->drv_data->uic_attr) {
 		attr = ufs->drv_data->uic_attr;
@@ -1262,7 +1255,6 @@ static struct exynos_ufs_uic_attr exynos7_uic_attr = {
 };
 
 static struct exynos_ufs_drv_data exynos_ufs_drvs = {
-	.compatible		= "samsung,exynos7-ufs",
 	.uic_attr		= &exynos7_uic_attr,
 	.quirks			= UFSHCD_QUIRK_PRDT_BYTE_GRAN |
 				  UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR |
diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
index 0a31f77a5f48..2e72aabaa673 100644
--- a/drivers/scsi/ufs/ufs-exynos.h
+++ b/drivers/scsi/ufs/ufs-exynos.h
@@ -142,7 +142,6 @@ struct exynos_ufs_uic_attr {
 };
 
 struct exynos_ufs_drv_data {
-	char *compatible;
 	struct exynos_ufs_uic_attr *uic_attr;
 	unsigned int quirks;
 	unsigned int opts;
@@ -191,7 +190,7 @@ struct exynos_ufs {
 	struct ufs_pa_layer_attr dev_req_params;
 	struct ufs_phy_time_cfg t_cfg;
 	ktime_t entry_hibern8_t;
-	struct exynos_ufs_drv_data *drv_data;
+	const struct exynos_ufs_drv_data *drv_data;
 
 	u32 opts;
 #define EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL		BIT(0)
-- 
2.33.0


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

* [PATCH v5 05/15] scsi: ufs: ufs-exynos: add refclkout_stop control
       [not found]   ` <CGME20211018124505epcas2p32c65e409d95954c4995f8a1c22842509@epcas2p3.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park

This patch adds REFCLKOUT_STOP control to CLK_STOP_MASK. It can
en/disable reference clock out control for UFS device.

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 57210114ca0a..e75736ce1534 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -48,10 +48,11 @@
 #define HCI_ERR_EN_T_LAYER	0x84
 #define HCI_ERR_EN_DME_LAYER	0x88
 #define HCI_CLKSTOP_CTRL	0xB0
+#define REFCLKOUT_STOP		BIT(4)
 #define REFCLK_STOP		BIT(2)
 #define UNIPRO_MCLK_STOP	BIT(1)
 #define UNIPRO_PCLK_STOP	BIT(0)
-#define CLK_STOP_MASK		(REFCLK_STOP |\
+#define CLK_STOP_MASK		(REFCLKOUT_STOP | REFCLK_STOP |\
 				 UNIPRO_MCLK_STOP |\
 				 UNIPRO_PCLK_STOP)
 #define HCI_MISC		0xB4
-- 
2.33.0


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

* [PATCH v5 06/15] scsi: ufs: ufs-exynos: add setup_clocks callback
       [not found]   ` <CGME20211018124505epcas2p1d58eebe57563823e4768962342477a35@epcas2p1.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Kiwoong Kim

This patch adds setup_clocks callback to control/gate clocks by ufshcd.
To avoid calling before initialization, it needs to check whether ufs is
null or not and call it initially from pre_link callback.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index e75736ce1534..226e7e64fad4 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -794,6 +794,27 @@ static void exynos_ufs_config_intr(struct exynos_ufs *ufs, u32 errs, u8 index)
 	}
 }
 
+static int exynos_ufs_setup_clocks(struct ufs_hba *hba, bool on,
+				   enum ufs_notify_change_status status)
+{
+	struct exynos_ufs *ufs = ufshcd_get_variant(hba);
+
+	if (!ufs)
+		return 0;
+
+	if (on && status == PRE_CHANGE) {
+		if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL)
+			exynos_ufs_disable_auto_ctrl_hcc(ufs);
+		exynos_ufs_ungate_clks(ufs);
+	} else if (!on && status == POST_CHANGE) {
+		exynos_ufs_gate_clks(ufs);
+		if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL)
+			exynos_ufs_enable_auto_ctrl_hcc(ufs);
+	}
+
+	return 0;
+}
+
 static int exynos_ufs_pre_link(struct ufs_hba *hba)
 {
 	struct exynos_ufs *ufs = ufshcd_get_variant(hba);
@@ -812,6 +833,8 @@ static int exynos_ufs_pre_link(struct ufs_hba *hba)
 	exynos_ufs_config_phy_time_attr(ufs);
 	exynos_ufs_config_phy_cap_attr(ufs);
 
+	exynos_ufs_setup_clocks(hba, true, PRE_CHANGE);
+
 	if (ufs->drv_data->pre_link)
 		ufs->drv_data->pre_link(ufs);
 
@@ -1202,6 +1225,7 @@ static struct ufs_hba_variant_ops ufs_hba_exynos_ops = {
 	.hce_enable_notify		= exynos_ufs_hce_enable_notify,
 	.link_startup_notify		= exynos_ufs_link_startup_notify,
 	.pwr_change_notify		= exynos_ufs_pwr_change_notify,
+	.setup_clocks			= exynos_ufs_setup_clocks,
 	.setup_xfer_req			= exynos_ufs_specify_nexus_t_xfer_req,
 	.setup_task_mgmt		= exynos_ufs_specify_nexus_t_tm_req,
 	.hibern8_notify			= exynos_ufs_hibern8_notify,
-- 
2.33.0


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

* [PATCH v5 07/15] scsi: ufs: ufs-exynos: support custom version of ufs_hba_variant_ops
       [not found]   ` <CGME20211018124505epcas2p2c68234b4e04cd3149eb21c987d474755@epcas2p2.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Kiwoong Kim

By default, ufs_hba_exynos_ops will be used but this patch supports to
use custom version of ufs_hba_variant_ops because some variants of
exynos-ufs will use only few callbacks.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 8 +++++++-
 drivers/scsi/ufs/ufs-exynos.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 226e7e64fad4..5536b104794a 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -1237,8 +1237,14 @@ static int exynos_ufs_probe(struct platform_device *pdev)
 {
 	int err;
 	struct device *dev = &pdev->dev;
+	const struct ufs_hba_variant_ops *vops = &ufs_hba_exynos_ops;
+	const struct exynos_ufs_drv_data *drv_data =
+		device_get_match_data(dev);
 
-	err = ufshcd_pltfrm_init(pdev, &ufs_hba_exynos_ops);
+	if (drv_data && drv_data->vops)
+		vops = drv_data->vops;
+
+	err = ufshcd_pltfrm_init(pdev, vops);
 	if (err)
 		dev_err(dev, "ufshcd_pltfrm_init() failed %d\n", err);
 
diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
index 2e72aabaa673..74f556d8a003 100644
--- a/drivers/scsi/ufs/ufs-exynos.h
+++ b/drivers/scsi/ufs/ufs-exynos.h
@@ -142,6 +142,7 @@ struct exynos_ufs_uic_attr {
 };
 
 struct exynos_ufs_drv_data {
+	const struct ufs_hba_variant_ops *vops;
 	struct exynos_ufs_uic_attr *uic_attr;
 	unsigned int quirks;
 	unsigned int opts;
-- 
2.33.0


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

* [PATCH v5 08/15] scsi: ufs: ufs-exynos: add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR option
       [not found]   ` <CGME20211018124505epcas2p4bf7f7fe8419a03d5510c9adf67aee5ab@epcas2p4.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Kiwoong Kim

To skip exynos_ufs_config_phy_*_attr settings for exynos-ufs variant,
this patch provides EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR as an opts
flag. Regarding exynosauto v9 SoC's controller, M-Phy timinig setting is
not required and most of vendor specific configurations will be
configured on pre_link callback function.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 6 ++++--
 drivers/scsi/ufs/ufs-exynos.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 5536b104794a..ce9ac3bf5e95 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -830,8 +830,10 @@ static int exynos_ufs_pre_link(struct ufs_hba *hba)
 
 	/* m-phy */
 	exynos_ufs_phy_init(ufs);
-	exynos_ufs_config_phy_time_attr(ufs);
-	exynos_ufs_config_phy_cap_attr(ufs);
+	if (!(ufs->opts & EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR)) {
+		exynos_ufs_config_phy_time_attr(ufs);
+		exynos_ufs_config_phy_cap_attr(ufs);
+	}
 
 	exynos_ufs_setup_clocks(hba, true, PRE_CHANGE);
 
diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
index 74f556d8a003..89955ae226dc 100644
--- a/drivers/scsi/ufs/ufs-exynos.h
+++ b/drivers/scsi/ufs/ufs-exynos.h
@@ -199,6 +199,7 @@ struct exynos_ufs {
 #define EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL	BIT(2)
 #define EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX	BIT(3)
 #define EXYNOS_UFS_OPT_USE_SW_HIBERN8_TIMER	BIT(4)
+#define EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR	BIT(5)
 };
 
 #define for_each_ufs_rx_lane(ufs, i) \
-- 
2.33.0


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

* [PATCH v5 09/15] scsi: ufs: ufs-exynos: factor out priv data init
       [not found]   ` <CGME20211018124505epcas2p38f13fa432c4f6e5ca4898a8f41c2b041@epcas2p3.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Kiwoong Kim

To be used this assignment code for other variant exynos-ufs driver,
this patch factors out the codes as inline code.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index ce9ac3bf5e95..6bb4bbb2af21 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -946,6 +946,18 @@ static int exynos_ufs_parse_dt(struct device *dev, struct exynos_ufs *ufs)
 	return ret;
 }
 
+static inline void exynos_ufs_priv_init(struct ufs_hba *hba,
+					struct exynos_ufs *ufs)
+{
+	ufs->hba = hba;
+	ufs->opts = ufs->drv_data->opts;
+	ufs->rx_sel_idx = PA_MAXDATALANES;
+	if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX)
+		ufs->rx_sel_idx = 0;
+	hba->priv = (void *)ufs;
+	hba->quirks = ufs->drv_data->quirks;
+}
+
 static int exynos_ufs_init(struct ufs_hba *hba)
 {
 	struct device *dev = hba->dev;
@@ -995,13 +1007,8 @@ static int exynos_ufs_init(struct ufs_hba *hba)
 	if (ret)
 		goto phy_off;
 
-	ufs->hba = hba;
-	ufs->opts = ufs->drv_data->opts;
-	ufs->rx_sel_idx = PA_MAXDATALANES;
-	if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX)
-		ufs->rx_sel_idx = 0;
-	hba->priv = (void *)ufs;
-	hba->quirks = ufs->drv_data->quirks;
+	exynos_ufs_priv_init(hba, ufs);
+
 	if (ufs->drv_data->drv_init) {
 		ret = ufs->drv_data->drv_init(dev, ufs);
 		if (ret) {
-- 
2.33.0


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

* [PATCH v5 10/15] scsi: ufs: ufs-exynos: add pre/post_hce_enable drv callbacks
       [not found]   ` <CGME20211018124505epcas2p37bd15e319f80e82d321f85565afd7712@epcas2p3.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Kiwoong Kim

This patch adds driver-specific pre/post_hce_enable callbacks to execute
extra initializations before and after hce_enable_notify callback.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 10 ++++++++++
 drivers/scsi/ufs/ufs-exynos.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 6bb4bbb2af21..c9e933655322 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -1136,6 +1136,12 @@ static int exynos_ufs_hce_enable_notify(struct ufs_hba *hba,
 
 	switch (status) {
 	case PRE_CHANGE:
+		if (ufs->drv_data->pre_hce_enable) {
+			ret = ufs->drv_data->pre_hce_enable(ufs);
+			if (ret)
+				return ret;
+		}
+
 		ret = exynos_ufs_host_reset(hba);
 		if (ret)
 			return ret;
@@ -1145,6 +1151,10 @@ static int exynos_ufs_hce_enable_notify(struct ufs_hba *hba,
 		exynos_ufs_calc_pwm_clk_div(ufs);
 		if (!(ufs->opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL))
 			exynos_ufs_enable_auto_ctrl_hcc(ufs);
+
+		if (ufs->drv_data->post_hce_enable)
+			ret = ufs->drv_data->post_hce_enable(ufs);
+
 		break;
 	}
 
diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
index 89955ae226dc..02308faea422 100644
--- a/drivers/scsi/ufs/ufs-exynos.h
+++ b/drivers/scsi/ufs/ufs-exynos.h
@@ -154,6 +154,8 @@ struct exynos_ufs_drv_data {
 				struct ufs_pa_layer_attr *pwr);
 	int (*post_pwr_change)(struct exynos_ufs *ufs,
 				struct ufs_pa_layer_attr *pwr);
+	int (*pre_hce_enable)(struct exynos_ufs *ufs);
+	int (*post_hce_enable)(struct exynos_ufs *ufs);
 };
 
 struct ufs_phy_time_cfg {
-- 
2.33.0


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

* [PATCH v5 11/15] scsi: ufs: ufs-exynos: support exynosauto v9 ufs driver
       [not found]   ` <CGME20211018124506epcas2p27ae65b5e8ee4919cde0d989708c24ca6@epcas2p2.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Kiwoong Kim

This patch adds to support ufs variant for ExynosAuto v9 SoC. This
requires control UFS IP sharability register via syscon and regmap.
The offset of the register can be different according to the ufs
instance and SoC specific offset value. So, we need to get the offset
value from DT property.
Unlike exynos7, it has different m-phy setting so it can be configured
by exynosauto_ufs_pre_link.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 118 ++++++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufs-exynos.h |  18 ++++++
 2 files changed, 136 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index c9e933655322..2ff9bbd8b821 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -12,8 +12,10 @@
 #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"
@@ -75,6 +77,12 @@
 				 UIC_TRANSPORT_NO_CONNECTION_RX |\
 				 UIC_TRANSPORT_BAD_TC)
 
+/* FSYS UFS Shareability */
+#define UFS_WR_SHARABLE		BIT(2)
+#define UFS_RD_SHARABLE		BIT(1)
+#define UFS_SHARABLE		(UFS_WR_SHARABLE | UFS_RD_SHARABLE)
+#define UFS_SHAREABILITY_OFFSET	0x710
+
 enum {
 	UNIPRO_L1_5 = 0,/* PHY Adapter */
 	UNIPRO_L2,	/* Data Link */
@@ -150,6 +158,89 @@ static int exynos7_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
 	return 0;
 }
 
+static int exynosauto_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
+{
+	struct exynos_ufs_uic_attr *attr = ufs->drv_data->uic_attr;
+
+	/* IO Coherency setting */
+	if (ufs->sysreg) {
+		return regmap_update_bits(ufs->sysreg,
+					  ufs->shareability_reg_offset,
+					  UFS_SHARABLE, UFS_SHARABLE);
+	}
+
+	attr->tx_dif_p_nsec = 3200000;
+
+	return 0;
+}
+
+static int exynosauto_ufs_pre_link(struct exynos_ufs *ufs)
+{
+	struct ufs_hba *hba = ufs->hba;
+	int i;
+	u32 tx_line_reset_period, rx_line_reset_period;
+
+	rx_line_reset_period = (RX_LINE_RESET_TIME * ufs->mclk_rate) / NSEC_PER_MSEC;
+	tx_line_reset_period = (TX_LINE_RESET_TIME * ufs->mclk_rate) / NSEC_PER_MSEC;
+
+	ufshcd_dme_set(hba, UIC_ARG_MIB(0x200), 0x40);
+	for_each_ufs_rx_lane(ufs, i) {
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_CLK_PRD, i),
+			       DIV_ROUND_UP(NSEC_PER_SEC, ufs->mclk_rate));
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_CLK_PRD_EN, i), 0x0);
+
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_LINERESET_VALUE2, i),
+			       (rx_line_reset_period >> 16) & 0xFF);
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_LINERESET_VALUE1, i),
+			       (rx_line_reset_period >> 8) & 0xFF);
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_LINERESET_VALUE0, i),
+			       (rx_line_reset_period) & 0xFF);
+
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x2f, i), 0x79);
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x84, i), 0x1);
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x25, i), 0xf6);
+	}
+
+	for_each_ufs_tx_lane(ufs, i) {
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_CLK_PRD, i),
+			       DIV_ROUND_UP(NSEC_PER_SEC, ufs->mclk_rate));
+		/* Not to affect VND_TX_LINERESET_PVALUE to VND_TX_CLK_PRD */
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_CLK_PRD_EN, i),
+			       0x02);
+
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_LINERESET_PVALUE2, i),
+			       (tx_line_reset_period >> 16) & 0xFF);
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_LINERESET_PVALUE1, i),
+			       (tx_line_reset_period >> 8) & 0xFF);
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_LINERESET_PVALUE0, i),
+			       (tx_line_reset_period) & 0xFF);
+
+		/* TX PWM Gear Capability / PWM_G1_ONLY */
+		ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x04, i), 0x1);
+	}
+
+	ufshcd_dme_set(hba, UIC_ARG_MIB(0x200), 0x0);
+
+	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0x0);
+
+	ufshcd_dme_set(hba, UIC_ARG_MIB(0xa011), 0x8000);
+
+	return 0;
+}
+
+static int exynosauto_ufs_pre_pwr_change(struct exynos_ufs *ufs,
+					 struct ufs_pa_layer_attr *pwr)
+{
+	struct ufs_hba *hba = ufs->hba;
+
+	/* PACP_PWR_req and delivered to the remote DME */
+	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA0), 12000);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA1), 32000);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA2), 16000);
+
+	return 0;
+}
+
 static int exynos7_ufs_pre_link(struct exynos_ufs *ufs)
 {
 	struct ufs_hba *hba = ufs->hba;
@@ -932,6 +1023,17 @@ static int exynos_ufs_parse_dt(struct device *dev, struct exynos_ufs *ufs)
 		goto out;
 	}
 
+	ufs->sysreg = syscon_regmap_lookup_by_phandle(np, "samsung,sysreg");
+	if (IS_ERR(ufs->sysreg))
+		ufs->sysreg = NULL;
+	else {
+		if (of_property_read_u32_index(np, "samsung,sysreg", 1,
+					       &ufs->shareability_reg_offset)) {
+			dev_warn(dev, "can't get an offset from sysreg. Set to default value\n");
+			ufs->shareability_reg_offset = UFS_SHAREABILITY_OFFSET;
+		}
+	}
+
 	ufs->pclk_avail_min = PCLK_AVAIL_MIN;
 	ufs->pclk_avail_max = PCLK_AVAIL_MAX;
 
@@ -1304,6 +1406,20 @@ static struct exynos_ufs_uic_attr exynos7_uic_attr = {
 	.pa_dbg_option_suite		= 0x30103,
 };
 
+static struct exynos_ufs_drv_data exynosauto_ufs_drvs = {
+	.uic_attr		= &exynos7_uic_attr,
+	.quirks			= UFSHCD_QUIRK_PRDT_BYTE_GRAN |
+				  UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR |
+				  UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |
+				  UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING,
+	.opts			= EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL |
+				  EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
+				  EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX,
+	.drv_init		= exynosauto_ufs_drv_init,
+	.pre_link		= exynosauto_ufs_pre_link,
+	.pre_pwr_change		= exynosauto_ufs_pre_pwr_change,
+};
+
 static struct exynos_ufs_drv_data exynos_ufs_drvs = {
 	.uic_attr		= &exynos7_uic_attr,
 	.quirks			= UFSHCD_QUIRK_PRDT_BYTE_GRAN |
@@ -1329,6 +1445,8 @@ static struct exynos_ufs_drv_data exynos_ufs_drvs = {
 static const struct of_device_id exynos_ufs_of_match[] = {
 	{ .compatible = "samsung,exynos7-ufs",
 	  .data	      = &exynos_ufs_drvs },
+	{ .compatible = "samsung,exynosautov9-ufs",
+	  .data	      = &exynosauto_ufs_drvs },
 	{},
 };
 
diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
index 02308faea422..1c33e5466082 100644
--- a/drivers/scsi/ufs/ufs-exynos.h
+++ b/drivers/scsi/ufs/ufs-exynos.h
@@ -56,6 +56,22 @@
 #define TX_GRAN_NVAL_10_08	0x0296
 #define TX_GRAN_NVAL_H(v)	(((v) >> 8) & 0x3)
 
+#define VND_TX_CLK_PRD		0xAA
+#define VND_TX_CLK_PRD_EN	0xA9
+#define VND_TX_LINERESET_PVALUE0	0xAD
+#define VND_TX_LINERESET_PVALUE1	0xAC
+#define VND_TX_LINERESET_PVALUE2	0xAB
+
+#define TX_LINE_RESET_TIME	3200
+
+#define VND_RX_CLK_PRD		0x12
+#define VND_RX_CLK_PRD_EN	0x11
+#define VND_RX_LINERESET_VALUE0	0x1D
+#define VND_RX_LINERESET_VALUE1	0x1C
+#define VND_RX_LINERESET_VALUE2	0x1B
+
+#define RX_LINE_RESET_TIME	1000
+
 #define RX_FILLER_ENABLE	0x0316
 #define RX_FILLER_EN		(1 << 1)
 #define RX_LINERESET_VAL	0x0317
@@ -194,6 +210,8 @@ struct exynos_ufs {
 	struct ufs_phy_time_cfg t_cfg;
 	ktime_t entry_hibern8_t;
 	const struct exynos_ufs_drv_data *drv_data;
+	struct regmap *sysreg;
+	u32 shareability_reg_offset;
 
 	u32 opts;
 #define EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL		BIT(0)
-- 
2.33.0


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

* [PATCH v5 12/15] dt-bindings: ufs: exynos-ufs: add io-coherency property
       [not found]   ` <CGME20211018124506epcas2p25100e2163029de4ee8b8b87e7ff0f2a3@epcas2p2.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  2021-10-18 17:54       ` Rob Herring
  0 siblings, 1 reply; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Rob Herring,
	devicetree

Add "samsung,sysreg" regmap and the offset to the ufs shareability
register for setting io coherency of the samsung ufs. "dma-coherent"
property is also required because the driver code needs to know.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 .../devicetree/bindings/ufs/samsung,exynos-ufs.yaml       | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml b/Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml
index b9ca8ef4f2be..691741f9d6c0 100644
--- a/Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml
+++ b/Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml
@@ -54,6 +54,14 @@ properties:
   phy-names:
     const: ufs-phy
 
+  samsung,sysreg:
+    $ref: '/schemas/types.yaml#/definitions/phandle-array'
+    description: Should be phandle/offset pair. The phandle to the syscon node
+                 which indicates the FSYSx sysreg interface and the offset of
+                 the control register for UFS io coherency setting.
+
+  dma-coherent: true
+
 required:
   - compatible
   - reg
-- 
2.33.0


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

* [PATCH v5 13/15] scsi: ufs: ufs-exynos: multi-host configuration for exynosauto
       [not found]   ` <CGME20211018124506epcas2p4cadea8f87fde299c22317496a2d29f14@epcas2p4.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Kiwoong Kim,
	Inki Dae

UFS controller of ExynosAuto v9 SoC supports multi-host interface for I/O
virtualization. In general, we're using para-virtualized driver to
support a block device by several virtual machines. However, it should
be relayed by backend driver. Multi-host functionality extends the host
controller by providing register interfaces that can be used by each
VM's ufs drivers respectively. By this, we can provide direct access to
the UFS device for multiple VMs. It's similar with SR-IOV of PCIe.

We divide this M-HCI as PH(Physical Host) and VHs(Virtual Host). The PH
supports all UFSHCI functions(all SAPs) same as conventional UFSHCI but
the VH only supports data transfer function. Thus, except UTP_CMD_SAP and
UTP_TMPSAP, the PH should handle all the physical features.

This patch provides an initial implementation of PH part. M-HCI can
support up to four interfaces(1 for a PH and 3 for VHs) but this patch
initially supports only 1 PH and 1 VH. For this, we uses TASK_TAG[7:5]
field so TASK_TAG[4:0] for 32 doorbel will be supported. After the PH is
initiated, this will send a ready message to VHs through a mailbox
register. The message handler is not fully implemented yet such as
supporting reset / abort cases.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 68 +++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 2ff9bbd8b821..6e6149d99609 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -83,6 +83,44 @@
 #define UFS_SHARABLE		(UFS_WR_SHARABLE | UFS_RD_SHARABLE)
 #define UFS_SHAREABILITY_OFFSET	0x710
 
+/* Multi-host registers */
+#define MHCTRL			0xC4
+#define MHCTRL_EN_VH_MASK	(0xE)
+#define MHCTRL_EN_VH(vh)	(vh << 1)
+#define PH2VH_MBOX		0xD8
+
+#define MH_MSG_MASK		(0xFF)
+
+#define MH_MSG(id, msg)		((id << 8) | (msg & 0xFF))
+#define MH_MSG_PH_READY		0x1
+#define MH_MSG_VH_READY		0x2
+
+#define ALLOW_INQUIRY		BIT(25)
+#define ALLOW_MODE_SELECT	BIT(24)
+#define ALLOW_MODE_SENSE	BIT(23)
+#define ALLOW_PRE_FETCH		GENMASK(22, 21)
+#define ALLOW_READ_CMD_ALL	GENMASK(20, 18)	/* read_6/10/16 */
+#define ALLOW_READ_BUFFER	BIT(17)
+#define ALLOW_READ_CAPACITY	GENMASK(16, 15)
+#define ALLOW_REPORT_LUNS	BIT(14)
+#define ALLOW_REQUEST_SENSE	BIT(13)
+#define ALLOW_SYNCHRONIZE_CACHE	GENMASK(8, 7)
+#define ALLOW_TEST_UNIT_READY	BIT(6)
+#define ALLOW_UNMAP		BIT(5)
+#define ALLOW_VERIFY		BIT(4)
+#define ALLOW_WRITE_CMD_ALL	GENMASK(3, 1)	/* write_6/10/16 */
+
+#define ALLOW_TRANS_VH_DEFAULT	(ALLOW_INQUIRY | ALLOW_MODE_SELECT | \
+				 ALLOW_MODE_SENSE | ALLOW_PRE_FETCH | \
+				 ALLOW_READ_CMD_ALL | ALLOW_READ_BUFFER | \
+				 ALLOW_READ_CAPACITY | ALLOW_REPORT_LUNS | \
+				 ALLOW_REQUEST_SENSE | ALLOW_SYNCHRONIZE_CACHE | \
+				 ALLOW_TEST_UNIT_READY | ALLOW_UNMAP | \
+				 ALLOW_VERIFY | ALLOW_WRITE_CMD_ALL)
+
+#define HCI_MH_ALLOWABLE_TRAN_OF_VH		0x30C
+#define HCI_MH_IID_IN_TASK_TAG			0X308
+
 enum {
 	UNIPRO_L1_5 = 0,/* PHY Adapter */
 	UNIPRO_L2,	/* Data Link */
@@ -174,6 +212,20 @@ static int exynosauto_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
 	return 0;
 }
 
+static int exynosauto_ufs_post_hce_enable(struct exynos_ufs *ufs)
+{
+	struct ufs_hba *hba = ufs->hba;
+
+	/* Enable Virtual Host #1 */
+	ufshcd_rmwl(hba, MHCTRL_EN_VH_MASK, MHCTRL_EN_VH(1), MHCTRL);
+	/* Default VH Transfer permissions */
+	hci_writel(ufs, ALLOW_TRANS_VH_DEFAULT, HCI_MH_ALLOWABLE_TRAN_OF_VH);
+	/* IID information is replaced in TASKTAG[7:5] instead of IID in UCD */
+	hci_writel(ufs, 0x1, HCI_MH_IID_IN_TASK_TAG);
+
+	return 0;
+}
+
 static int exynosauto_ufs_pre_link(struct exynos_ufs *ufs)
 {
 	struct ufs_hba *hba = ufs->hba;
@@ -241,6 +293,20 @@ static int exynosauto_ufs_pre_pwr_change(struct exynos_ufs *ufs,
 	return 0;
 }
 
+static int exynosauto_ufs_post_pwr_change(struct exynos_ufs *ufs,
+					  struct ufs_pa_layer_attr *pwr)
+{
+	struct ufs_hba *hba = ufs->hba;
+	u32 enabled_vh;
+
+	enabled_vh = ufshcd_readl(hba, MHCTRL) & MHCTRL_EN_VH_MASK;
+
+	/* Send physical host ready message to virtual hosts */
+	ufshcd_writel(hba, MH_MSG(enabled_vh, MH_MSG_PH_READY), PH2VH_MBOX);
+
+	return 0;
+}
+
 static int exynos7_ufs_pre_link(struct exynos_ufs *ufs)
 {
 	struct ufs_hba *hba = ufs->hba;
@@ -1416,8 +1482,10 @@ static struct exynos_ufs_drv_data exynosauto_ufs_drvs = {
 				  EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
 				  EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX,
 	.drv_init		= exynosauto_ufs_drv_init,
+	.post_hce_enable	= exynosauto_ufs_post_hce_enable,
 	.pre_link		= exynosauto_ufs_pre_link,
 	.pre_pwr_change		= exynosauto_ufs_pre_pwr_change,
+	.post_pwr_change	= exynosauto_ufs_post_pwr_change,
 };
 
 static struct exynos_ufs_drv_data exynos_ufs_drvs = {
-- 
2.33.0


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

* [PATCH v5 14/15] scsi: ufs: ufs-exynos: introduce exynosauto v9 virtual host
       [not found]   ` <CGME20211018124506epcas2p3a014f68fb3d6cdfa43a3562c74bb6895@epcas2p3.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Kiwoong Kim

This patch introduces virtual host driver of exynosauto v9 ufs mHCI.
VH(Virtual Host) only supports data transfer functions. So, most of
physical features are broken. So, we need to set below quirks.
- UFSHCD_QUIRK_BROKEN_UIC_CMD
- UFSHCD_QUIRK_SKIP_PH_CONFIGURATION
Before initialization, the VH is necessary to wait until PH is ready.
It's implemented as polling at the moment.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 86 +++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 6e6149d99609..cd26bc82462e 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -121,6 +121,8 @@
 #define HCI_MH_ALLOWABLE_TRAN_OF_VH		0x30C
 #define HCI_MH_IID_IN_TASK_TAG			0X308
 
+#define PH_READY_TIMEOUT_MS			(5 * MSEC_PER_SEC)
+
 enum {
 	UNIPRO_L1_5 = 0,/* PHY Adapter */
 	UNIPRO_L2,	/* Data Link */
@@ -1406,6 +1408,70 @@ static int exynos_ufs_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 	return 0;
 }
 
+static int exynosauto_ufs_vh_link_startup_notify(struct ufs_hba *hba,
+						 enum ufs_notify_change_status status)
+{
+	if (status == POST_CHANGE) {
+		ufshcd_set_link_active(hba);
+		ufshcd_set_ufs_dev_active(hba);
+	}
+
+	return 0;
+}
+
+static int exynosauto_ufs_vh_wait_ph_ready(struct ufs_hba *hba)
+{
+	u32 mbox;
+	ktime_t start, stop;
+
+	start = ktime_get();
+	stop = ktime_add(start, ms_to_ktime(PH_READY_TIMEOUT_MS));
+
+	do {
+		mbox = ufshcd_readl(hba, PH2VH_MBOX);
+		/* TODO: Mailbox message protocols between the PH and VHs are
+		 * not implemented yet. This will be supported later
+		 */
+		if ((mbox & MH_MSG_MASK) == MH_MSG_PH_READY)
+			return 0;
+
+		usleep_range(40, 50);
+	} while (ktime_before(ktime_get(), stop));
+
+	return -ETIME;
+}
+
+static int exynosauto_ufs_vh_init(struct ufs_hba *hba)
+{
+	struct device *dev = hba->dev;
+	struct platform_device *pdev = to_platform_device(dev);
+	struct exynos_ufs *ufs;
+	int ret;
+
+	ufs = devm_kzalloc(dev, sizeof(*ufs), GFP_KERNEL);
+	if (!ufs)
+		return -ENOMEM;
+
+	/* exynos-specific hci */
+	ufs->reg_hci = devm_platform_ioremap_resource_byname(pdev, "vs_hci");
+	if (IS_ERR(ufs->reg_hci)) {
+		dev_err(dev, "cannot ioremap for hci vendor register\n");
+		return PTR_ERR(ufs->reg_hci);
+	}
+
+	ret = exynosauto_ufs_vh_wait_ph_ready(hba);
+	if (ret)
+		return ret;
+
+	ufs->drv_data = device_get_match_data(dev);
+	if (!ufs->drv_data)
+		return -ENODEV;
+
+	exynos_ufs_priv_init(hba, ufs);
+
+	return 0;
+}
+
 static struct ufs_hba_variant_ops ufs_hba_exynos_ops = {
 	.name				= "exynos_ufs",
 	.init				= exynos_ufs_init,
@@ -1420,6 +1486,12 @@ static struct ufs_hba_variant_ops ufs_hba_exynos_ops = {
 	.resume				= exynos_ufs_resume,
 };
 
+static struct ufs_hba_variant_ops ufs_hba_exynosauto_vh_ops = {
+	.name				= "exynosauto_ufs_vh",
+	.init				= exynosauto_ufs_vh_init,
+	.link_startup_notify		= exynosauto_ufs_vh_link_startup_notify,
+};
+
 static int exynos_ufs_probe(struct platform_device *pdev)
 {
 	int err;
@@ -1488,6 +1560,18 @@ static struct exynos_ufs_drv_data exynosauto_ufs_drvs = {
 	.post_pwr_change	= exynosauto_ufs_post_pwr_change,
 };
 
+static struct exynos_ufs_drv_data exynosauto_ufs_vh_drvs = {
+	.vops			= &ufs_hba_exynosauto_vh_ops,
+	.quirks			= UFSHCD_QUIRK_PRDT_BYTE_GRAN |
+				  UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR |
+				  UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |
+				  UFSHCI_QUIRK_BROKEN_HCE |
+				  UFSHCD_QUIRK_BROKEN_UIC_CMD |
+				  UFSHCD_QUIRK_SKIP_PH_CONFIGURATION |
+				  UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING,
+	.opts			= EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX,
+};
+
 static struct exynos_ufs_drv_data exynos_ufs_drvs = {
 	.uic_attr		= &exynos7_uic_attr,
 	.quirks			= UFSHCD_QUIRK_PRDT_BYTE_GRAN |
@@ -1515,6 +1599,8 @@ static const struct of_device_id exynos_ufs_of_match[] = {
 	  .data	      = &exynos_ufs_drvs },
 	{ .compatible = "samsung,exynosautov9-ufs",
 	  .data	      = &exynosauto_ufs_drvs },
+	{ .compatible = "samsung,exynosautov9-ufs-vh",
+	  .data	      = &exynosauto_ufs_vh_drvs },
 	{},
 };
 
-- 
2.33.0


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

* [PATCH v5 15/15] dt-bindings: ufs: exynos-ufs: add exynosautov9 compatible
       [not found]   ` <CGME20211018124506epcas2p190b89643fbb14d99d7ab52f5ab97bf38@epcas2p1.samsung.com>
@ 2021-10-18 12:42     ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-18 12:42 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski
  Cc: Bean Huo, Bart Van Assche, Adrian Hunter, Christoph Hellwig,
	Can Guo, Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, Chanho Park, Rob Herring,
	devicetree, Rob Herring

Below two compatibles can be used for exynosautov9 SoC UFS controller.

- samsung,exynosautov9-ufs: ExynosAutov9 UFS Physical Host
- samsung,exynosautov9-ufs-vh: ExynosAutov9 UFS Virtual Host

Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml b/Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml
index 691741f9d6c0..95ac1c18334d 100644
--- a/Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml
+++ b/Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml
@@ -20,6 +20,8 @@ properties:
   compatible:
     enum:
       - samsung,exynos7-ufs
+      - samsung,exynosautov9-ufs
+      - samsung,exynosautov9-ufs-vh
 
   reg:
     items:
-- 
2.33.0


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

* Re: [PATCH v5 12/15] dt-bindings: ufs: exynos-ufs: add io-coherency property
  2021-10-18 12:42     ` [PATCH v5 12/15] dt-bindings: ufs: exynos-ufs: add io-coherency property Chanho Park
@ 2021-10-18 17:54       ` Rob Herring
  0 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2021-10-18 17:54 UTC (permalink / raw)
  To: Chanho Park
  Cc: Bean Huo, Jaehoon Chung, devicetree, Bart Van Assche, Sowon Na,
	Adrian Hunter, Alim Akhtar, linux-scsi, Krzysztof Kozlowski,
	Avri Altman, Jaegeuk Kim, Rob Herring, Can Guo, Gyunghoon Kwon,
	Christoph Hellwig, linux-samsung-soc, Martin K . Petersen,
	James E . J . Bottomley

On Mon, 18 Oct 2021 21:42:13 +0900, Chanho Park wrote:
> Add "samsung,sysreg" regmap and the offset to the ufs shareability
> register for setting io coherency of the samsung ufs. "dma-coherent"
> property is also required because the driver code needs to know.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Chanho Park <chanho61.park@samsung.com>
> ---
>  .../devicetree/bindings/ufs/samsung,exynos-ufs.yaml       | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v5 01/15] scsi: ufs: add quirk to handle broken UIC command
  2021-10-18 12:42     ` [PATCH v5 01/15] scsi: ufs: add quirk to handle broken UIC command Chanho Park
@ 2021-10-28  3:18       ` Martin K. Petersen
  2021-10-28  4:32         ` Chanho Park
  0 siblings, 1 reply; 20+ messages in thread
From: Martin K. Petersen @ 2021-10-28  3:18 UTC (permalink / raw)
  To: Chanho Park
  Cc: Alim Akhtar, Avri Altman, James E . J . Bottomley,
	Martin K . Petersen, Krzysztof Kozlowski, Bean Huo,
	Bart Van Assche, Adrian Hunter, Christoph Hellwig, Can Guo,
	Jaegeuk Kim, Jaehoon Chung, Gyunghoon Kwon, Sowon Na,
	linux-samsung-soc, linux-scsi, jongmin jeong


Chanho,

> samsung ExynosAuto9 SoC has two types of host controller interface to
> support the virtualization of UFS Device.  One is the physical
> host(PH) that the same as conventaional UFSHCI, and the other is the
> virtual host(VH) that support data transfer function only.

Applied to 5.16/scsi-staging, thanks! I skipped the dt-bindings patches
since the relevant yaml file is not yet upstream.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* RE: [PATCH v5 01/15] scsi: ufs: add quirk to handle broken UIC command
  2021-10-28  3:18       ` Martin K. Petersen
@ 2021-10-28  4:32         ` Chanho Park
  0 siblings, 0 replies; 20+ messages in thread
From: Chanho Park @ 2021-10-28  4:32 UTC (permalink / raw)
  To: 'Martin K. Petersen', 'Rob Herring'
  Cc: 'Alim Akhtar', 'Avri Altman',
	'James E . J . Bottomley', 'Krzysztof Kozlowski',
	'Bean Huo', 'Bart Van Assche',
	'Adrian Hunter', 'Christoph Hellwig',
	'Can Guo', 'Jaegeuk Kim', 'Jaehoon Chung',
	'Gyunghoon Kwon', 'Sowon Na',
	linux-samsung-soc, linux-scsi, 'jongmin jeong'

> Applied to 5.16/scsi-staging, thanks! I skipped the dt-bindings patches
> since the relevant yaml file is not yet upstream.

Thanks. It has a dependency with the exynos,ufs dt-binding patch of Rob's
tree.

https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git/commit/?h=dt/
linus&id=e22e509c1cd90b48ae31099905418de74515e56f

Dear Rob,
Could you pick them up on your tree?

https://lore.kernel.org/linux-scsi/20211018124216.153072-1-chanho61.park@sam
sung.com/T/#m16a3920d16ae8843a78fdbefbb402bd321e5ab31
https://lore.kernel.org/linux-scsi/20211018124216.153072-1-chanho61.park@sam
sung.com/T/#mc9380270b1cdab2be6660444fd2f318b29caf182

Best Regards,
Chanho Park


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

* Re: [PATCH v5 00/15] introduce exynosauto v9 ufs driver
  2021-10-18 12:42 ` [PATCH v5 00/15] introduce exynosauto v9 ufs driver Chanho Park
                     ` (14 preceding siblings ...)
       [not found]   ` <CGME20211018124506epcas2p190b89643fbb14d99d7ab52f5ab97bf38@epcas2p1.samsung.com>
@ 2021-10-28 13:26   ` Rob Herring
  15 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2021-10-28 13:26 UTC (permalink / raw)
  To: Chanho Park
  Cc: linux-scsi, linux-samsung-soc, Jaehoon Chung, Bart Van Assche,
	Martin K . Petersen, James E . J . Bottomley, Can Guo,
	Christoph Hellwig, Alim Akhtar, Bean Huo, Gyunghoon Kwon,
	Sowon Na, Jaegeuk Kim, Avri Altman, Krzysztof Kozlowski,
	Adrian Hunter

On Mon, 18 Oct 2021 21:42:01 +0900, Chanho Park wrote:
> In ExynosAuto(variant of the Exynos for automotive), the UFS Storage needs
> to be accessed from multiple VMs. Traditional virtualization solution
> provides para-virtualized block driver such as virtio-blk. However, they
> can be highly depends on the Dom0 where the backend of the PV is
> located. When the system gets high cpu pressure, the performance of
> guest VMs are also affected. To overcome this, the SoC implements the
> virtualization concept as the H/W controller level.
> 
> Below figure is a conceptual design of the UFS Multi Host architecture.
> 
>     +------+          +------+
>     | OS#1 |          | OS#2 |
>     +------+          +------+
>        |                 |
>  +------------+     +------------+
>  |  Physical  |     |   Virtual  |
>  |    Host    |     |    Host    |
>  +------------+     +------------+
>    |      |              | <-- UTP_CMD_SAP, UTP_TM_SAP
>    |   +-------------------------+
>    |   |    Function Arbiter     |
>    |   +-------------------------+
>  +-------------------------------+
>  |           UTP Layer           |
>  +-------------------------------+
>  +-------------------------------+
>  |           UIC Layer           |
>  +-------------------------------+
> 
> There are two types of host controllers of the UFS host controller
> that we designed. The controller has a Function Arbiter that arranges
> commands of each hosts. It will arrange the doorbells among the PH and
> VHs as Round-Robin. When each host transmits a command to the Arbiter,
> the Arbiter transmits it to the UTP layer. Physical Host(PH) support all
> UFSHCI functions(all SAPs) same as conventional UFSHCI.
> Virtual Hosts(VHs) support only data transfer function(UTP_CMD_SAP and
> UTP_TM_SAP).
> 
> In an environment where multiple VMs are used, the OS that has the
> leadership of the system is called System OS(Dom0). This system OS will
> own the PH and has a responsibility to handle UIC errors.
> 
> VHs can only supports data transfer functions compared with the PH,
> they're necessary to send a request to the PH for error handling of VHs.
> To interface among the PH and VHs, the UFSHCI controller supports mailbox.
> The mailbox register has 8 bit fields and they can be used as
> arguments of the mailbox protocol. In this initial patchset, the PH
> ready message is supported and they will be implemented to the next
> steps.
> 
> To support this virtual host type controller which only supports data
> transfer function (TP_CMD_SAP and UTP_TM_SAP), we need to add below two
> quirks.
> - UFSHCD_QUIRK_BROKEN_UIC_CMD
> - UFSHCD_QUIRK_SKIP_PH_CONFIGURATION
> 
> First two patches, I picked them up from Jonmin's patchset[1] and the third
> patch has been dropped because it's not necessary anymore.
> 
> [1]: https://lore.kernel.org/linux-scsi/20210527030901.88403-1-jjmin.jeong@samsung.com/
> 
> Patch 0003 ~ 0010, they are changes of exynos7 ufs driver to apply
> exynosauto v9 variant and PH/VH capabilities.
> Patch 0011 ~ 0015, the patches introduce the exynosauto v9 ufs MHCI which
> includes the PH and VHs.
> 
> Changes from v4:
> - s/Arbitor/Arbiter/g of cover-letter.
> - Rephrase descriptions of cover letter from original patchset.
> - Except 0007-scsi-ufs-ufs-exynos-correct-timeout-value-setting-re.patch
>   from this patchset and sent it independently
> - Patch11/12: Consolidate sysreg and samsung,ufs-shareability-reg-offset
>   property.
> - Patch14:
>   Drop wlun_dev_clr_ua configuration
>   Add TODO: tag for further implementations
> 
> Changes from v3:
> - Drop "[PATCH v3 06/17] scsi: ufs: ufs-exynos: get sysreg regmap for
>   io-coherency" and squash it to Patch12
> - Patch12: Use macro to avoid raw value usage and describe the value of M-Phy setting
> - Patch13: Add dma-coherent property
> - Patch14: Use macro to avoid raw value and describe the value of HCI_MH_ALLOWABLE_TRAN_OF_VH
> 
> Changes from v2:
> - Separate dt-binding patches on top of
>   https://lore.kernel.org/linux-devicetree/YUNdqnZ2kYefxFUC@robh.at.kernel.org/
> 
> Changes from v1:
> - Change quirk name from UFSHCD_QUIRK_SKIP_INTERFACE_CONFIGURATION to
>   UFSHCD_QUIRK_SKIP_PH_CONFIGURATION
> - Add compatibles to Documentation/devicetree/bindings/ufs/samsung,exynos-ufs.yaml
>   on top of https://lore.kernel.org/linux-scsi/20200613024706.27975-9-alim.akhtar@samsung.com/
> 
> Chanho Park (13):
>   scsi: ufs: ufs-exynos: change pclk available max value
>   scsi: ufs: ufs-exynos: simplify drv_data retrieval
>   scsi: ufs: ufs-exynos: add refclkout_stop control
>   scsi: ufs: ufs-exynos: add setup_clocks callback
>   scsi: ufs: ufs-exynos: support custom version of ufs_hba_variant_ops
>   scsi: ufs: ufs-exynos: add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR option
>   scsi: ufs: ufs-exynos: factor out priv data init
>   scsi: ufs: ufs-exynos: add pre/post_hce_enable drv callbacks
>   scsi: ufs: ufs-exynos: support exynosauto v9 ufs driver
>   dt-bindings: ufs: exynos-ufs: add io-coherency property
>   scsi: ufs: ufs-exynos: multi-host configuration for exynosauto
>   scsi: ufs: ufs-exynos: introduce exynosauto v9 virtual host
>   dt-bindings: ufs: exynos-ufs: add exynosautov9 compatible
> 
> jongmin jeong (2):
>   scsi: ufs: add quirk to handle broken UIC command
>   scsi: ufs: add quirk to enable host controller without ph
>     configuration
> 
>  .../bindings/ufs/samsung,exynos-ufs.yaml      |  10 +
>  drivers/scsi/ufs/ufs-exynos.c                 | 354 +++++++++++++++++-
>  drivers/scsi/ufs/ufs-exynos.h                 |  27 +-
>  drivers/scsi/ufs/ufshcd.c                     |   6 +
>  drivers/scsi/ufs/ufshcd.h                     |  12 +
>  5 files changed, 386 insertions(+), 23 deletions(-)
> 
> --
> 2.33.0
> 
> 
> 
> 

Applied patches 12 and 15, thanks!

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

end of thread, other threads:[~2021-10-28 13:26 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20211018124505epcas2p31437a0fae6711edeb9db5b49eb420e56@epcas2p3.samsung.com>
2021-10-18 12:42 ` [PATCH v5 00/15] introduce exynosauto v9 ufs driver Chanho Park
     [not found]   ` <CGME20211018124505epcas2p2d149a4f26d3475830a36c47049591bb2@epcas2p2.samsung.com>
2021-10-18 12:42     ` [PATCH v5 01/15] scsi: ufs: add quirk to handle broken UIC command Chanho Park
2021-10-28  3:18       ` Martin K. Petersen
2021-10-28  4:32         ` Chanho Park
     [not found]   ` <CGME20211018124505epcas2p143bb8374e3399e2670ced625862a8653@epcas2p1.samsung.com>
2021-10-18 12:42     ` [PATCH v5 02/15] scsi: ufs: add quirk to enable host controller without ph configuration Chanho Park
     [not found]   ` <CGME20211018124505epcas2p4f96cd4d9ea01a030d07fdf25c5a3d163@epcas2p4.samsung.com>
2021-10-18 12:42     ` [PATCH v5 03/15] scsi: ufs: ufs-exynos: change pclk available max value Chanho Park
     [not found]   ` <CGME20211018124505epcas2p22a463738c9ee028274be7ad06ed97a0d@epcas2p2.samsung.com>
2021-10-18 12:42     ` [PATCH v5 04/15] scsi: ufs: ufs-exynos: simplify drv_data retrieval Chanho Park
     [not found]   ` <CGME20211018124505epcas2p32c65e409d95954c4995f8a1c22842509@epcas2p3.samsung.com>
2021-10-18 12:42     ` [PATCH v5 05/15] scsi: ufs: ufs-exynos: add refclkout_stop control Chanho Park
     [not found]   ` <CGME20211018124505epcas2p1d58eebe57563823e4768962342477a35@epcas2p1.samsung.com>
2021-10-18 12:42     ` [PATCH v5 06/15] scsi: ufs: ufs-exynos: add setup_clocks callback Chanho Park
     [not found]   ` <CGME20211018124505epcas2p2c68234b4e04cd3149eb21c987d474755@epcas2p2.samsung.com>
2021-10-18 12:42     ` [PATCH v5 07/15] scsi: ufs: ufs-exynos: support custom version of ufs_hba_variant_ops Chanho Park
     [not found]   ` <CGME20211018124505epcas2p4bf7f7fe8419a03d5510c9adf67aee5ab@epcas2p4.samsung.com>
2021-10-18 12:42     ` [PATCH v5 08/15] scsi: ufs: ufs-exynos: add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR option Chanho Park
     [not found]   ` <CGME20211018124505epcas2p38f13fa432c4f6e5ca4898a8f41c2b041@epcas2p3.samsung.com>
2021-10-18 12:42     ` [PATCH v5 09/15] scsi: ufs: ufs-exynos: factor out priv data init Chanho Park
     [not found]   ` <CGME20211018124505epcas2p37bd15e319f80e82d321f85565afd7712@epcas2p3.samsung.com>
2021-10-18 12:42     ` [PATCH v5 10/15] scsi: ufs: ufs-exynos: add pre/post_hce_enable drv callbacks Chanho Park
     [not found]   ` <CGME20211018124506epcas2p27ae65b5e8ee4919cde0d989708c24ca6@epcas2p2.samsung.com>
2021-10-18 12:42     ` [PATCH v5 11/15] scsi: ufs: ufs-exynos: support exynosauto v9 ufs driver Chanho Park
     [not found]   ` <CGME20211018124506epcas2p25100e2163029de4ee8b8b87e7ff0f2a3@epcas2p2.samsung.com>
2021-10-18 12:42     ` [PATCH v5 12/15] dt-bindings: ufs: exynos-ufs: add io-coherency property Chanho Park
2021-10-18 17:54       ` Rob Herring
     [not found]   ` <CGME20211018124506epcas2p4cadea8f87fde299c22317496a2d29f14@epcas2p4.samsung.com>
2021-10-18 12:42     ` [PATCH v5 13/15] scsi: ufs: ufs-exynos: multi-host configuration for exynosauto Chanho Park
     [not found]   ` <CGME20211018124506epcas2p3a014f68fb3d6cdfa43a3562c74bb6895@epcas2p3.samsung.com>
2021-10-18 12:42     ` [PATCH v5 14/15] scsi: ufs: ufs-exynos: introduce exynosauto v9 virtual host Chanho Park
     [not found]   ` <CGME20211018124506epcas2p190b89643fbb14d99d7ab52f5ab97bf38@epcas2p1.samsung.com>
2021-10-18 12:42     ` [PATCH v5 15/15] dt-bindings: ufs: exynos-ufs: add exynosautov9 compatible Chanho Park
2021-10-28 13:26   ` [PATCH v5 00/15] introduce exynosauto v9 ufs driver Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).