All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] i3c: master: some improvment for i3c master
@ 2023-10-16 15:46 ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

These are dependent on bugs fixed serial: https://lore.kernel.org/imx/20231016153232.2851095-1-Frank.Li@nxp.com/T/#t
There are two major improment

1. Add actual size in i3c_transfer because i3c allow target early termiate
transfer.
2. Add API for i3c_dev_gettstatus_format1 for i3c comand GET_STATUS.
3. svc master enable hotjoin default

Frank Li (5):
  i3c: master: svc: enable hotjoin default
  i3c: add actual in i3c_priv_xfer
  i3c: svc: rename read_len as actual_len
  i3c: master: svc return actual transfer data len
  i3c: add API i3c_dev_gettstatus_format1() to get target device status

 drivers/i3c/device.c                | 24 ++++++++++++++++
 drivers/i3c/internals.h             |  1 +
 drivers/i3c/master.c                | 27 ++++++++++++++++++
 drivers/i3c/master/svc-i3c-master.c | 44 +++++++++++++++++++----------
 include/linux/i3c/device.h          |  2 ++
 5 files changed, 83 insertions(+), 15 deletions(-)

-- 
2.34.1


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

* [PATCH 0/5] i3c: master: some improvment for i3c master
@ 2023-10-16 15:46 ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

These are dependent on bugs fixed serial: https://lore.kernel.org/imx/20231016153232.2851095-1-Frank.Li@nxp.com/T/#t
There are two major improment

1. Add actual size in i3c_transfer because i3c allow target early termiate
transfer.
2. Add API for i3c_dev_gettstatus_format1 for i3c comand GET_STATUS.
3. svc master enable hotjoin default

Frank Li (5):
  i3c: master: svc: enable hotjoin default
  i3c: add actual in i3c_priv_xfer
  i3c: svc: rename read_len as actual_len
  i3c: master: svc return actual transfer data len
  i3c: add API i3c_dev_gettstatus_format1() to get target device status

 drivers/i3c/device.c                | 24 ++++++++++++++++
 drivers/i3c/internals.h             |  1 +
 drivers/i3c/master.c                | 27 ++++++++++++++++++
 drivers/i3c/master/svc-i3c-master.c | 44 +++++++++++++++++++----------
 include/linux/i3c/device.h          |  2 ++
 5 files changed, 83 insertions(+), 15 deletions(-)

-- 
2.34.1


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* [PATCH 1/5] i3c: master: svc: enable hotjoin default
  2023-10-16 15:46 ` Frank Li
@ 2023-10-16 15:46   ` Frank Li
  -1 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

Hotjoin require clock running and enable SLVSTART irq.
Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
save power.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/i3c/master/svc-i3c-master.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 18bc277edc8a..f0d99b029e5f 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -128,6 +128,9 @@
 /* This parameter depends on the implementation and may be tuned */
 #define SVC_I3C_FIFO_SIZE 16
 
+static bool hotjoin = true;
+module_param(hotjoin, bool, S_IRUGO | S_IWUSR);
+
 struct svc_i3c_cmd {
 	u8 addr;
 	bool rnw;
@@ -1623,8 +1626,12 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
 	if (ret)
 		goto rpm_disable;
 
-	pm_runtime_mark_last_busy(&pdev->dev);
-	pm_runtime_put_autosuspend(&pdev->dev);
+	if (hotjoin) {
+		svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART);
+	} else {
+		pm_runtime_mark_last_busy(&pdev->dev);
+		pm_runtime_put_autosuspend(&pdev->dev);
+	}
 
 	return 0;
 
-- 
2.34.1


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

* [PATCH 1/5] i3c: master: svc: enable hotjoin default
@ 2023-10-16 15:46   ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

Hotjoin require clock running and enable SLVSTART irq.
Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
save power.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/i3c/master/svc-i3c-master.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 18bc277edc8a..f0d99b029e5f 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -128,6 +128,9 @@
 /* This parameter depends on the implementation and may be tuned */
 #define SVC_I3C_FIFO_SIZE 16
 
+static bool hotjoin = true;
+module_param(hotjoin, bool, S_IRUGO | S_IWUSR);
+
 struct svc_i3c_cmd {
 	u8 addr;
 	bool rnw;
@@ -1623,8 +1626,12 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
 	if (ret)
 		goto rpm_disable;
 
-	pm_runtime_mark_last_busy(&pdev->dev);
-	pm_runtime_put_autosuspend(&pdev->dev);
+	if (hotjoin) {
+		svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART);
+	} else {
+		pm_runtime_mark_last_busy(&pdev->dev);
+		pm_runtime_put_autosuspend(&pdev->dev);
+	}
 
 	return 0;
 
-- 
2.34.1


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* [PATCH 2/5] i3c: add actual in i3c_priv_xfer
  2023-10-16 15:46 ` Frank Li
@ 2023-10-16 15:46   ` Frank Li
  -1 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

In MIPI I3C Specification:

"Ninth Bit of SDR Target Returned (Read) Data as End-of-Data: In I2C, the
ninth Data bit from Target to Controller is an ACK by the Controller. By
contrast, in I3C this bit allows the Target to end a Read, and allows the
Controller to Abort a Read. In SDR terms, the ninth bit of Read data is
referred to as the T-Bit (for ‘Transition’)"

I3C allow devices early terminate data transfer. So need "actual" field to
indicate how much get by i3c_priv_xfer.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 include/linux/i3c/device.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
index 90fa83464f00..f2fa7ee5d96d 100644
--- a/include/linux/i3c/device.h
+++ b/include/linux/i3c/device.h
@@ -66,6 +66,7 @@ struct i3c_priv_xfer {
 		void *in;
 		const void *out;
 	} data;
+	u16 actual;
 	enum i3c_error_code err;
 };
 
-- 
2.34.1


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

* [PATCH 2/5] i3c: add actual in i3c_priv_xfer
@ 2023-10-16 15:46   ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

In MIPI I3C Specification:

"Ninth Bit of SDR Target Returned (Read) Data as End-of-Data: In I2C, the
ninth Data bit from Target to Controller is an ACK by the Controller. By
contrast, in I3C this bit allows the Target to end a Read, and allows the
Controller to Abort a Read. In SDR terms, the ninth bit of Read data is
referred to as the T-Bit (for ‘Transition’)"

I3C allow devices early terminate data transfer. So need "actual" field to
indicate how much get by i3c_priv_xfer.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 include/linux/i3c/device.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
index 90fa83464f00..f2fa7ee5d96d 100644
--- a/include/linux/i3c/device.h
+++ b/include/linux/i3c/device.h
@@ -66,6 +66,7 @@ struct i3c_priv_xfer {
 		void *in;
 		const void *out;
 	} data;
+	u16 actual;
 	enum i3c_error_code err;
 };
 
-- 
2.34.1


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* [PATCH 3/5] i3c: svc: rename read_len as actual_len
  2023-10-16 15:46 ` Frank Li
@ 2023-10-16 15:46   ` Frank Li
  -1 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

I3C transfer, target can early terminate transfer.
I2C transfer, target can NACK write transfer.

'actual_len' is better name than 'read_len'.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/i3c/master/svc-i3c-master.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index f0d99b029e5f..3570b709cf60 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -137,7 +137,7 @@ struct svc_i3c_cmd {
 	u8 *in;
 	const void *out;
 	unsigned int len;
-	unsigned int read_len;
+	unsigned int actual_len;
 	bool continued;
 };
 
@@ -1022,7 +1022,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master,
 static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 			       bool rnw, unsigned int xfer_type, u8 addr,
 			       u8 *in, const u8 *out, unsigned int xfer_len,
-			       unsigned int *read_len, bool continued)
+			       unsigned int *actual_len, bool continued)
 {
 	u32 reg;
 	int ret;
@@ -1035,7 +1035,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 	       SVC_I3C_MCTRL_IBIRESP_NACK |
 	       SVC_I3C_MCTRL_DIR(rnw) |
 	       SVC_I3C_MCTRL_ADDR(addr) |
-	       SVC_I3C_MCTRL_RDTERM(*read_len),
+	       SVC_I3C_MCTRL_RDTERM(*actual_len),
 	       master->regs + SVC_I3C_MCTRL);
 
 	ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
@@ -1073,7 +1073,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 		goto emit_stop;
 
 	if (rnw)
-		*read_len = ret;
+		*actual_len = ret;
 
 	ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
 				 SVC_I3C_MSTATUS_COMPLETE(reg), 0, 1000);
@@ -1155,7 +1155,7 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
 
 		ret = svc_i3c_master_xfer(master, cmd->rnw, xfer->type,
 					  cmd->addr, cmd->in, cmd->out,
-					  cmd->len, &cmd->read_len,
+					  cmd->len, &cmd->actual_len,
 					  cmd->continued);
 		if (ret)
 			break;
@@ -1241,7 +1241,7 @@ static int svc_i3c_master_send_bdcast_ccc_cmd(struct svc_i3c_master *master,
 	cmd->in = NULL;
 	cmd->out = buf;
 	cmd->len = xfer_len;
-	cmd->read_len = 0;
+	cmd->actual_len = 0;
 	cmd->continued = false;
 
 	mutex_lock(&master->lock);
@@ -1261,7 +1261,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,
 					      struct i3c_ccc_cmd *ccc)
 {
 	unsigned int xfer_len = ccc->dests[0].payload.len;
-	unsigned int read_len = ccc->rnw ? xfer_len : 0;
+	unsigned int actual_len = ccc->rnw ? xfer_len : 0;
 	struct svc_i3c_xfer *xfer;
 	struct svc_i3c_cmd *cmd;
 	int ret;
@@ -1279,7 +1279,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,
 	cmd->in = NULL;
 	cmd->out = &ccc->id;
 	cmd->len = 1;
-	cmd->read_len = 0;
+	cmd->actual_len = 0;
 	cmd->continued = true;
 
 	/* Directed message */
@@ -1289,7 +1289,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,
 	cmd->in = ccc->rnw ? ccc->dests[0].payload.data : NULL;
 	cmd->out = ccc->rnw ? NULL : ccc->dests[0].payload.data,
 	cmd->len = xfer_len;
-	cmd->read_len = read_len;
+	cmd->actual_len = actual_len;
 	cmd->continued = false;
 
 	mutex_lock(&master->lock);
@@ -1298,8 +1298,8 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,
 		svc_i3c_master_dequeue_xfer(master, xfer);
 	mutex_unlock(&master->lock);
 
-	if (cmd->read_len != xfer_len)
-		ccc->dests[0].payload.len = cmd->read_len;
+	if (cmd->actual_len != xfer_len)
+		ccc->dests[0].payload.len = cmd->actual_len;
 
 	ret = xfer->ret;
 	svc_i3c_master_free_xfer(xfer);
@@ -1349,7 +1349,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
 		cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;
 		cmd->out = xfers[i].rnw ? NULL : xfers[i].data.out;
 		cmd->len = xfers[i].len;
-		cmd->read_len = xfers[i].rnw ? xfers[i].len : 0;
+		cmd->actual_len = xfers[i].rnw ? xfers[i].len : 0;
 		cmd->continued = (i + 1) < nxfers;
 	}
 
@@ -1389,7 +1389,7 @@ static int svc_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
 		cmd->in = cmd->rnw ? xfers[i].buf : NULL;
 		cmd->out = cmd->rnw ? NULL : xfers[i].buf;
 		cmd->len = xfers[i].len;
-		cmd->read_len = cmd->rnw ? xfers[i].len : 0;
+		cmd->actual_len = cmd->rnw ? xfers[i].len : 0;
 		cmd->continued = (i + 1 < nxfers);
 	}
 
-- 
2.34.1


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

* [PATCH 3/5] i3c: svc: rename read_len as actual_len
@ 2023-10-16 15:46   ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

I3C transfer, target can early terminate transfer.
I2C transfer, target can NACK write transfer.

'actual_len' is better name than 'read_len'.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/i3c/master/svc-i3c-master.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index f0d99b029e5f..3570b709cf60 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -137,7 +137,7 @@ struct svc_i3c_cmd {
 	u8 *in;
 	const void *out;
 	unsigned int len;
-	unsigned int read_len;
+	unsigned int actual_len;
 	bool continued;
 };
 
@@ -1022,7 +1022,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master,
 static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 			       bool rnw, unsigned int xfer_type, u8 addr,
 			       u8 *in, const u8 *out, unsigned int xfer_len,
-			       unsigned int *read_len, bool continued)
+			       unsigned int *actual_len, bool continued)
 {
 	u32 reg;
 	int ret;
@@ -1035,7 +1035,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 	       SVC_I3C_MCTRL_IBIRESP_NACK |
 	       SVC_I3C_MCTRL_DIR(rnw) |
 	       SVC_I3C_MCTRL_ADDR(addr) |
-	       SVC_I3C_MCTRL_RDTERM(*read_len),
+	       SVC_I3C_MCTRL_RDTERM(*actual_len),
 	       master->regs + SVC_I3C_MCTRL);
 
 	ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
@@ -1073,7 +1073,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 		goto emit_stop;
 
 	if (rnw)
-		*read_len = ret;
+		*actual_len = ret;
 
 	ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
 				 SVC_I3C_MSTATUS_COMPLETE(reg), 0, 1000);
@@ -1155,7 +1155,7 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
 
 		ret = svc_i3c_master_xfer(master, cmd->rnw, xfer->type,
 					  cmd->addr, cmd->in, cmd->out,
-					  cmd->len, &cmd->read_len,
+					  cmd->len, &cmd->actual_len,
 					  cmd->continued);
 		if (ret)
 			break;
@@ -1241,7 +1241,7 @@ static int svc_i3c_master_send_bdcast_ccc_cmd(struct svc_i3c_master *master,
 	cmd->in = NULL;
 	cmd->out = buf;
 	cmd->len = xfer_len;
-	cmd->read_len = 0;
+	cmd->actual_len = 0;
 	cmd->continued = false;
 
 	mutex_lock(&master->lock);
@@ -1261,7 +1261,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,
 					      struct i3c_ccc_cmd *ccc)
 {
 	unsigned int xfer_len = ccc->dests[0].payload.len;
-	unsigned int read_len = ccc->rnw ? xfer_len : 0;
+	unsigned int actual_len = ccc->rnw ? xfer_len : 0;
 	struct svc_i3c_xfer *xfer;
 	struct svc_i3c_cmd *cmd;
 	int ret;
@@ -1279,7 +1279,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,
 	cmd->in = NULL;
 	cmd->out = &ccc->id;
 	cmd->len = 1;
-	cmd->read_len = 0;
+	cmd->actual_len = 0;
 	cmd->continued = true;
 
 	/* Directed message */
@@ -1289,7 +1289,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,
 	cmd->in = ccc->rnw ? ccc->dests[0].payload.data : NULL;
 	cmd->out = ccc->rnw ? NULL : ccc->dests[0].payload.data,
 	cmd->len = xfer_len;
-	cmd->read_len = read_len;
+	cmd->actual_len = actual_len;
 	cmd->continued = false;
 
 	mutex_lock(&master->lock);
@@ -1298,8 +1298,8 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,
 		svc_i3c_master_dequeue_xfer(master, xfer);
 	mutex_unlock(&master->lock);
 
-	if (cmd->read_len != xfer_len)
-		ccc->dests[0].payload.len = cmd->read_len;
+	if (cmd->actual_len != xfer_len)
+		ccc->dests[0].payload.len = cmd->actual_len;
 
 	ret = xfer->ret;
 	svc_i3c_master_free_xfer(xfer);
@@ -1349,7 +1349,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
 		cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;
 		cmd->out = xfers[i].rnw ? NULL : xfers[i].data.out;
 		cmd->len = xfers[i].len;
-		cmd->read_len = xfers[i].rnw ? xfers[i].len : 0;
+		cmd->actual_len = xfers[i].rnw ? xfers[i].len : 0;
 		cmd->continued = (i + 1) < nxfers;
 	}
 
@@ -1389,7 +1389,7 @@ static int svc_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
 		cmd->in = cmd->rnw ? xfers[i].buf : NULL;
 		cmd->out = cmd->rnw ? NULL : xfers[i].buf;
 		cmd->len = xfers[i].len;
-		cmd->read_len = cmd->rnw ? xfers[i].len : 0;
+		cmd->actual_len = cmd->rnw ? xfers[i].len : 0;
 		cmd->continued = (i + 1 < nxfers);
 	}
 
-- 
2.34.1


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* [PATCH 4/5] i3c: master: svc return actual transfer data len
  2023-10-16 15:46 ` Frank Li
@ 2023-10-16 15:46   ` Frank Li
  -1 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

I3C allow devices early terminate data transfer. So set "actual" to
indicate how much data get by i3c_priv_xfer.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/i3c/master/svc-i3c-master.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 3570b709cf60..444825aafa6f 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -138,6 +138,7 @@ struct svc_i3c_cmd {
 	const void *out;
 	unsigned int len;
 	unsigned int actual_len;
+	struct i3c_priv_xfer *xfer;
 	bool continued;
 };
 
@@ -1045,6 +1046,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 
 	if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) {
 		ret = -ENXIO;
+		*actual_len = 0;
 		goto emit_stop;
 	}
 
@@ -1062,6 +1064,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 	 */
 	if (SVC_I3C_MSTATUS_IBIWON(reg)) {
 		ret = -ENXIO;
+		*actual_len = 0;
 		goto emit_stop;
 	}
 
@@ -1157,6 +1160,9 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
 					  cmd->addr, cmd->in, cmd->out,
 					  cmd->len, &cmd->actual_len,
 					  cmd->continued);
+		if (cmd->xfer)
+			cmd->xfer->actual = cmd->actual_len;
+
 		if (ret)
 			break;
 	}
@@ -1344,6 +1350,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
 	for (i = 0; i < nxfers; i++) {
 		struct svc_i3c_cmd *cmd = &xfer->cmds[i];
 
+		cmd->xfer = xfers + i;
 		cmd->addr = master->addrs[data->index];
 		cmd->rnw = xfers[i].rnw;
 		cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;
-- 
2.34.1


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

* [PATCH 4/5] i3c: master: svc return actual transfer data len
@ 2023-10-16 15:46   ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

I3C allow devices early terminate data transfer. So set "actual" to
indicate how much data get by i3c_priv_xfer.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/i3c/master/svc-i3c-master.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 3570b709cf60..444825aafa6f 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -138,6 +138,7 @@ struct svc_i3c_cmd {
 	const void *out;
 	unsigned int len;
 	unsigned int actual_len;
+	struct i3c_priv_xfer *xfer;
 	bool continued;
 };
 
@@ -1045,6 +1046,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 
 	if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) {
 		ret = -ENXIO;
+		*actual_len = 0;
 		goto emit_stop;
 	}
 
@@ -1062,6 +1064,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 	 */
 	if (SVC_I3C_MSTATUS_IBIWON(reg)) {
 		ret = -ENXIO;
+		*actual_len = 0;
 		goto emit_stop;
 	}
 
@@ -1157,6 +1160,9 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
 					  cmd->addr, cmd->in, cmd->out,
 					  cmd->len, &cmd->actual_len,
 					  cmd->continued);
+		if (cmd->xfer)
+			cmd->xfer->actual = cmd->actual_len;
+
 		if (ret)
 			break;
 	}
@@ -1344,6 +1350,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
 	for (i = 0; i < nxfers; i++) {
 		struct svc_i3c_cmd *cmd = &xfer->cmds[i];
 
+		cmd->xfer = xfers + i;
 		cmd->addr = master->addrs[data->index];
 		cmd->rnw = xfers[i].rnw;
 		cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;
-- 
2.34.1


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* [PATCH 5/5] i3c: add API i3c_dev_gettstatus_format1() to get target device status
  2023-10-16 15:46 ` Frank Li
@ 2023-10-16 15:46   ` Frank Li
  -1 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

I3C standard 5.1.9.3.15 Get Device Status (GETSTATUS):
Get request for one I3C Target Device to return its current status.

Add API to fetch it with format1.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/i3c/device.c       | 24 ++++++++++++++++++++++++
 drivers/i3c/internals.h    |  1 +
 drivers/i3c/master.c       | 27 +++++++++++++++++++++++++++
 include/linux/i3c/device.h |  1 +
 4 files changed, 53 insertions(+)

diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
index 1a6a8703dbc3..0566ab9f1498 100644
--- a/drivers/i3c/device.c
+++ b/drivers/i3c/device.c
@@ -196,6 +196,30 @@ void i3c_device_free_ibi(struct i3c_device *dev)
 }
 EXPORT_SYMBOL_GPL(i3c_device_free_ibi);
 
+/**
+ * i3c_device_getstatus_format1() - Get device status with format 1.
+ * @dev: device for which you want to get status.
+ * @status: I3C status format 1
+ *
+ * Return: 0 in case of success, a negative error core otherwise.
+ */
+int i3c_device_getstatus_format1(struct i3c_device *dev, u16 *status)
+{
+	int ret = -EINVAL;
+
+	if (!status)
+		return -EINVAL;
+
+	i3c_bus_normaluse_lock(dev->bus);
+	if (dev->desc) {
+		ret = i3c_dev_getstatus_format1_locked(dev->desc, status);
+	}
+	i3c_bus_normaluse_unlock(dev->bus);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(i3c_device_getstatus_format1);
+
 /**
  * i3cdev_to_dev() - Returns the device embedded in @i3cdev
  * @i3cdev: I3C device
diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h
index 908a807badaf..976ad26ca79c 100644
--- a/drivers/i3c/internals.h
+++ b/drivers/i3c/internals.h
@@ -24,4 +24,5 @@ int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev);
 int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev,
 			       const struct i3c_ibi_setup *req);
 void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev);
+int i3c_dev_getstatus_format1_locked(struct i3c_dev_desc *dev, u16 *status);
 #endif /* I3C_INTERNAL_H */
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 08aeb69a7800..fa831721f305 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -2840,6 +2840,33 @@ void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev)
 	dev->ibi = NULL;
 }
 
+int i3c_dev_getstatus_format1_locked(struct i3c_dev_desc *dev, u16 *status)
+{
+	struct i3c_master_controller *master = i3c_dev_get_master(dev);
+	struct i3c_ccc_getstatus *format1;
+	struct i3c_ccc_cmd_dest dest;
+	struct i3c_ccc_cmd cmd;
+	int ret;
+
+	format1 = i3c_ccc_cmd_dest_init(&dest, dev->info.dyn_addr,
+					  sizeof(*format1));
+	if (!format1)
+		return -ENOMEM;
+
+	i3c_ccc_cmd_init(&cmd, true, I3C_CCC_GETSTATUS, &dest, 1);
+
+	ret = i3c_master_send_ccc_cmd_locked(master, &cmd);
+	if (ret)
+		goto out;
+
+	*status = be16_to_cpu(format1->status);
+
+out:
+	i3c_ccc_cmd_dest_cleanup(&dest);
+
+	return ret;
+}
+
 static int __init i3c_init(void)
 {
 	int res;
diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
index f2fa7ee5d96d..212cdcd17179 100644
--- a/include/linux/i3c/device.h
+++ b/include/linux/i3c/device.h
@@ -344,4 +344,5 @@ void i3c_device_free_ibi(struct i3c_device *dev);
 int i3c_device_enable_ibi(struct i3c_device *dev);
 int i3c_device_disable_ibi(struct i3c_device *dev);
 
+int i3c_device_getstatus_format1(struct i3c_device *dev, u16 *status);
 #endif /* I3C_DEV_H */
-- 
2.34.1


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

* [PATCH 5/5] i3c: add API i3c_dev_gettstatus_format1() to get target device status
@ 2023-10-16 15:46   ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-16 15:46 UTC (permalink / raw)
  To: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

I3C standard 5.1.9.3.15 Get Device Status (GETSTATUS):
Get request for one I3C Target Device to return its current status.

Add API to fetch it with format1.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/i3c/device.c       | 24 ++++++++++++++++++++++++
 drivers/i3c/internals.h    |  1 +
 drivers/i3c/master.c       | 27 +++++++++++++++++++++++++++
 include/linux/i3c/device.h |  1 +
 4 files changed, 53 insertions(+)

diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
index 1a6a8703dbc3..0566ab9f1498 100644
--- a/drivers/i3c/device.c
+++ b/drivers/i3c/device.c
@@ -196,6 +196,30 @@ void i3c_device_free_ibi(struct i3c_device *dev)
 }
 EXPORT_SYMBOL_GPL(i3c_device_free_ibi);
 
+/**
+ * i3c_device_getstatus_format1() - Get device status with format 1.
+ * @dev: device for which you want to get status.
+ * @status: I3C status format 1
+ *
+ * Return: 0 in case of success, a negative error core otherwise.
+ */
+int i3c_device_getstatus_format1(struct i3c_device *dev, u16 *status)
+{
+	int ret = -EINVAL;
+
+	if (!status)
+		return -EINVAL;
+
+	i3c_bus_normaluse_lock(dev->bus);
+	if (dev->desc) {
+		ret = i3c_dev_getstatus_format1_locked(dev->desc, status);
+	}
+	i3c_bus_normaluse_unlock(dev->bus);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(i3c_device_getstatus_format1);
+
 /**
  * i3cdev_to_dev() - Returns the device embedded in @i3cdev
  * @i3cdev: I3C device
diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h
index 908a807badaf..976ad26ca79c 100644
--- a/drivers/i3c/internals.h
+++ b/drivers/i3c/internals.h
@@ -24,4 +24,5 @@ int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev);
 int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev,
 			       const struct i3c_ibi_setup *req);
 void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev);
+int i3c_dev_getstatus_format1_locked(struct i3c_dev_desc *dev, u16 *status);
 #endif /* I3C_INTERNAL_H */
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 08aeb69a7800..fa831721f305 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -2840,6 +2840,33 @@ void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev)
 	dev->ibi = NULL;
 }
 
+int i3c_dev_getstatus_format1_locked(struct i3c_dev_desc *dev, u16 *status)
+{
+	struct i3c_master_controller *master = i3c_dev_get_master(dev);
+	struct i3c_ccc_getstatus *format1;
+	struct i3c_ccc_cmd_dest dest;
+	struct i3c_ccc_cmd cmd;
+	int ret;
+
+	format1 = i3c_ccc_cmd_dest_init(&dest, dev->info.dyn_addr,
+					  sizeof(*format1));
+	if (!format1)
+		return -ENOMEM;
+
+	i3c_ccc_cmd_init(&cmd, true, I3C_CCC_GETSTATUS, &dest, 1);
+
+	ret = i3c_master_send_ccc_cmd_locked(master, &cmd);
+	if (ret)
+		goto out;
+
+	*status = be16_to_cpu(format1->status);
+
+out:
+	i3c_ccc_cmd_dest_cleanup(&dest);
+
+	return ret;
+}
+
 static int __init i3c_init(void)
 {
 	int res;
diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
index f2fa7ee5d96d..212cdcd17179 100644
--- a/include/linux/i3c/device.h
+++ b/include/linux/i3c/device.h
@@ -344,4 +344,5 @@ void i3c_device_free_ibi(struct i3c_device *dev);
 int i3c_device_enable_ibi(struct i3c_device *dev);
 int i3c_device_disable_ibi(struct i3c_device *dev);
 
+int i3c_device_getstatus_format1(struct i3c_device *dev, u16 *status);
 #endif /* I3C_DEV_H */
-- 
2.34.1


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 2/5] i3c: add actual in i3c_priv_xfer
  2023-10-16 15:46   ` Frank Li
@ 2023-10-17  6:10     ` Jarkko Nikula
  -1 siblings, 0 replies; 34+ messages in thread
From: Jarkko Nikula @ 2023-10-17  6:10 UTC (permalink / raw)
  To: Frank Li, alexandre.belloni, miquel.raynal, conor.culhane, joe,
	linux-i3c, linux-kernel, imx

Hi

On 10/16/23 18:46, Frank Li wrote:
> In MIPI I3C Specification:
> 
> "Ninth Bit of SDR Target Returned (Read) Data as End-of-Data: In I2C, the
> ninth Data bit from Target to Controller is an ACK by the Controller. By
> contrast, in I3C this bit allows the Target to end a Read, and allows the
> Controller to Abort a Read. In SDR terms, the ninth bit of Read data is
> referred to as the T-Bit (for ‘Transition’)"
> 
> I3C allow devices early terminate data transfer. So need "actual" field to
> indicate how much get by i3c_priv_xfer.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>   include/linux/i3c/device.h | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 90fa83464f00..f2fa7ee5d96d 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -66,6 +66,7 @@ struct i3c_priv_xfer {
>   		void *in;
>   		const void *out;
>   	} data;
> +	u16 actual;
>   	enum i3c_error_code err;
>   };
>   
Would this be more clear if named as "actual_len" and put next after 
"len" field in this structure? Also kerneldoc comment is missing.

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

* Re: [PATCH 2/5] i3c: add actual in i3c_priv_xfer
@ 2023-10-17  6:10     ` Jarkko Nikula
  0 siblings, 0 replies; 34+ messages in thread
From: Jarkko Nikula @ 2023-10-17  6:10 UTC (permalink / raw)
  To: Frank Li, alexandre.belloni, miquel.raynal, conor.culhane, joe,
	linux-i3c, linux-kernel, imx

Hi

On 10/16/23 18:46, Frank Li wrote:
> In MIPI I3C Specification:
> 
> "Ninth Bit of SDR Target Returned (Read) Data as End-of-Data: In I2C, the
> ninth Data bit from Target to Controller is an ACK by the Controller. By
> contrast, in I3C this bit allows the Target to end a Read, and allows the
> Controller to Abort a Read. In SDR terms, the ninth bit of Read data is
> referred to as the T-Bit (for ‘Transition’)"
> 
> I3C allow devices early terminate data transfer. So need "actual" field to
> indicate how much get by i3c_priv_xfer.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>   include/linux/i3c/device.h | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 90fa83464f00..f2fa7ee5d96d 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -66,6 +66,7 @@ struct i3c_priv_xfer {
>   		void *in;
>   		const void *out;
>   	} data;
> +	u16 actual;
>   	enum i3c_error_code err;
>   };
>   
Would this be more clear if named as "actual_len" and put next after 
"len" field in this structure? Also kerneldoc comment is missing.

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 1/5] i3c: master: svc: enable hotjoin default
  2023-10-16 15:46   ` Frank Li
@ 2023-10-17  6:48     ` Joe Perches
  -1 siblings, 0 replies; 34+ messages in thread
From: Joe Perches @ 2023-10-17  6:48 UTC (permalink / raw)
  To: Frank Li, alexandre.belloni, miquel.raynal, conor.culhane,
	linux-i3c, linux-kernel, imx

On Mon, 2023-10-16 at 11:46 -0400, Frank Li wrote:
> Hotjoin require clock running and enable SLVSTART irq.
> Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
> save power.
[]
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
[]
> @@ -128,6 +128,9 @@
>  /* This parameter depends on the implementation and may be tuned */
>  #define SVC_I3C_FIFO_SIZE 16
>  
> +static bool hotjoin = true;
> +module_param(hotjoin, bool, S_IRUGO | S_IWUSR);

Might be nicer using 0644

Consider using checkpatch --strict on the series.


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

* Re: [PATCH 1/5] i3c: master: svc: enable hotjoin default
@ 2023-10-17  6:48     ` Joe Perches
  0 siblings, 0 replies; 34+ messages in thread
From: Joe Perches @ 2023-10-17  6:48 UTC (permalink / raw)
  To: Frank Li, alexandre.belloni, miquel.raynal, conor.culhane,
	linux-i3c, linux-kernel, imx

On Mon, 2023-10-16 at 11:46 -0400, Frank Li wrote:
> Hotjoin require clock running and enable SLVSTART irq.
> Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
> save power.
[]
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
[]
> @@ -128,6 +128,9 @@
>  /* This parameter depends on the implementation and may be tuned */
>  #define SVC_I3C_FIFO_SIZE 16
>  
> +static bool hotjoin = true;
> +module_param(hotjoin, bool, S_IRUGO | S_IWUSR);

Might be nicer using 0644

Consider using checkpatch --strict on the series.


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 4/5] i3c: master: svc return actual transfer data len
  2023-10-16 15:46   ` Frank Li
@ 2023-10-17  8:33     ` Jarkko Nikula
  -1 siblings, 0 replies; 34+ messages in thread
From: Jarkko Nikula @ 2023-10-17  8:33 UTC (permalink / raw)
  To: Frank Li, alexandre.belloni, miquel.raynal, conor.culhane, joe,
	linux-i3c, linux-kernel, imx

Hi

On 10/16/23 18:46, Frank Li wrote:
> I3C allow devices early terminate data transfer. So set "actual" to
> indicate how much data get by i3c_priv_xfer.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>   drivers/i3c/master/svc-i3c-master.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index 3570b709cf60..444825aafa6f 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -138,6 +138,7 @@ struct svc_i3c_cmd {
>   	const void *out;
>   	unsigned int len;
>   	unsigned int actual_len;
> +	struct i3c_priv_xfer *xfer;
>   	bool continued;
>   };
>   
I'm thinking would it make sense to combine this and previous patch by 
removing the read_len/actual_len variable from this structure and use 
the added one (by the patch 2/5) from "struct i3c_priv_xfer" directly?

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

* Re: [PATCH 4/5] i3c: master: svc return actual transfer data len
@ 2023-10-17  8:33     ` Jarkko Nikula
  0 siblings, 0 replies; 34+ messages in thread
From: Jarkko Nikula @ 2023-10-17  8:33 UTC (permalink / raw)
  To: Frank Li, alexandre.belloni, miquel.raynal, conor.culhane, joe,
	linux-i3c, linux-kernel, imx

Hi

On 10/16/23 18:46, Frank Li wrote:
> I3C allow devices early terminate data transfer. So set "actual" to
> indicate how much data get by i3c_priv_xfer.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>   drivers/i3c/master/svc-i3c-master.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index 3570b709cf60..444825aafa6f 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -138,6 +138,7 @@ struct svc_i3c_cmd {
>   	const void *out;
>   	unsigned int len;
>   	unsigned int actual_len;
> +	struct i3c_priv_xfer *xfer;
>   	bool continued;
>   };
>   
I'm thinking would it make sense to combine this and previous patch by 
removing the read_len/actual_len variable from this structure and use 
the added one (by the patch 2/5) from "struct i3c_priv_xfer" directly?

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 1/5] i3c: master: svc: enable hotjoin default
  2023-10-16 15:46   ` Frank Li
@ 2023-10-17 14:04     ` Miquel Raynal
  -1 siblings, 0 replies; 34+ messages in thread
From: Miquel Raynal @ 2023-10-17 14:04 UTC (permalink / raw)
  To: Frank Li
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

Hi Frank,

Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:28 -0400:

> Hotjoin require clock running and enable SLVSTART irq.
> Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
> save power.

I am really not a big fan of the use of modules parameters. Maybe it
makes sense here. Alex, a better idea?

Thanks,
Miquèl

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

* Re: [PATCH 1/5] i3c: master: svc: enable hotjoin default
@ 2023-10-17 14:04     ` Miquel Raynal
  0 siblings, 0 replies; 34+ messages in thread
From: Miquel Raynal @ 2023-10-17 14:04 UTC (permalink / raw)
  To: Frank Li
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

Hi Frank,

Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:28 -0400:

> Hotjoin require clock running and enable SLVSTART irq.
> Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
> save power.

I am really not a big fan of the use of modules parameters. Maybe it
makes sense here. Alex, a better idea?

Thanks,
Miquèl

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 3/5] i3c: svc: rename read_len as actual_len
  2023-10-16 15:46   ` Frank Li
@ 2023-10-17 14:07     ` Miquel Raynal
  -1 siblings, 0 replies; 34+ messages in thread
From: Miquel Raynal @ 2023-10-17 14:07 UTC (permalink / raw)
  To: Frank Li
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

Hi Frank,

Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:30 -0400:

> I3C transfer, target can early terminate transfer.
> I2C transfer, target can NACK write transfer.
> 
> 'actual_len' is better name than 'read_len'.

I don't find read_len confusing because it may mean "how much bytes
were actually read" rather than "how much we need to read". But if
actual_len sounds better, I'm fine.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>

Thanks,
Miquèl

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

* Re: [PATCH 3/5] i3c: svc: rename read_len as actual_len
@ 2023-10-17 14:07     ` Miquel Raynal
  0 siblings, 0 replies; 34+ messages in thread
From: Miquel Raynal @ 2023-10-17 14:07 UTC (permalink / raw)
  To: Frank Li
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

Hi Frank,

Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:30 -0400:

> I3C transfer, target can early terminate transfer.
> I2C transfer, target can NACK write transfer.
> 
> 'actual_len' is better name than 'read_len'.

I don't find read_len confusing because it may mean "how much bytes
were actually read" rather than "how much we need to read". But if
actual_len sounds better, I'm fine.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>

Thanks,
Miquèl

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 4/5] i3c: master: svc return actual transfer data len
  2023-10-16 15:46   ` Frank Li
@ 2023-10-17 14:10     ` Miquel Raynal
  -1 siblings, 0 replies; 34+ messages in thread
From: Miquel Raynal @ 2023-10-17 14:10 UTC (permalink / raw)
  To: Frank Li
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

Hi Frank,

Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:31 -0400:

> I3C allow devices early terminate data transfer. So set "actual" to
> indicate how much data get by i3c_priv_xfer.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>  drivers/i3c/master/svc-i3c-master.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index 3570b709cf60..444825aafa6f 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -138,6 +138,7 @@ struct svc_i3c_cmd {
>  	const void *out;
>  	unsigned int len;
>  	unsigned int actual_len;
> +	struct i3c_priv_xfer *xfer;
>  	bool continued;
>  };
>  
> @@ -1045,6 +1046,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
>  
>  	if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) {
>  		ret = -ENXIO;
> +		*actual_len = 0;
>  		goto emit_stop;
>  	}
>  
> @@ -1062,6 +1064,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
>  	 */
>  	if (SVC_I3C_MSTATUS_IBIWON(reg)) {
>  		ret = -ENXIO;
> +		*actual_len = 0;
>  		goto emit_stop;
>  	}
>  
> @@ -1157,6 +1160,9 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
>  					  cmd->addr, cmd->in, cmd->out,
>  					  cmd->len, &cmd->actual_len,
>  					  cmd->continued);
> +		if (cmd->xfer)
> +			cmd->xfer->actual = cmd->actual_len;

Just to be sure, wouldn't it be more natural to always fill cmd->xfer
rather than checking it here?

> +
>  		if (ret)
>  			break;
>  	}
> @@ -1344,6 +1350,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
>  	for (i = 0; i < nxfers; i++) {
>  		struct svc_i3c_cmd *cmd = &xfer->cmds[i];
>  
> +		cmd->xfer = xfers + i;

Please follow the same pattern as below: = &xfers[i]

>  		cmd->addr = master->addrs[data->index];
>  		cmd->rnw = xfers[i].rnw;
>  		cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;


Thanks,
Miquèl

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

* Re: [PATCH 4/5] i3c: master: svc return actual transfer data len
@ 2023-10-17 14:10     ` Miquel Raynal
  0 siblings, 0 replies; 34+ messages in thread
From: Miquel Raynal @ 2023-10-17 14:10 UTC (permalink / raw)
  To: Frank Li
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

Hi Frank,

Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:31 -0400:

> I3C allow devices early terminate data transfer. So set "actual" to
> indicate how much data get by i3c_priv_xfer.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>  drivers/i3c/master/svc-i3c-master.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index 3570b709cf60..444825aafa6f 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -138,6 +138,7 @@ struct svc_i3c_cmd {
>  	const void *out;
>  	unsigned int len;
>  	unsigned int actual_len;
> +	struct i3c_priv_xfer *xfer;
>  	bool continued;
>  };
>  
> @@ -1045,6 +1046,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
>  
>  	if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) {
>  		ret = -ENXIO;
> +		*actual_len = 0;
>  		goto emit_stop;
>  	}
>  
> @@ -1062,6 +1064,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
>  	 */
>  	if (SVC_I3C_MSTATUS_IBIWON(reg)) {
>  		ret = -ENXIO;
> +		*actual_len = 0;
>  		goto emit_stop;
>  	}
>  
> @@ -1157,6 +1160,9 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
>  					  cmd->addr, cmd->in, cmd->out,
>  					  cmd->len, &cmd->actual_len,
>  					  cmd->continued);
> +		if (cmd->xfer)
> +			cmd->xfer->actual = cmd->actual_len;

Just to be sure, wouldn't it be more natural to always fill cmd->xfer
rather than checking it here?

> +
>  		if (ret)
>  			break;
>  	}
> @@ -1344,6 +1350,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
>  	for (i = 0; i < nxfers; i++) {
>  		struct svc_i3c_cmd *cmd = &xfer->cmds[i];
>  
> +		cmd->xfer = xfers + i;

Please follow the same pattern as below: = &xfers[i]

>  		cmd->addr = master->addrs[data->index];
>  		cmd->rnw = xfers[i].rnw;
>  		cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;


Thanks,
Miquèl

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 1/5] i3c: master: svc: enable hotjoin default
  2023-10-17 14:04     ` Miquel Raynal
@ 2023-10-17 14:51       ` Frank Li
  -1 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-17 14:51 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

On Tue, Oct 17, 2023 at 04:04:57PM +0200, Miquel Raynal wrote:
> Hi Frank,
> 
> Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:28 -0400:
> 
> > Hotjoin require clock running and enable SLVSTART irq.
> > Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
> > save power.
> 
> I am really not a big fan of the use of modules parameters. Maybe it
> makes sense here. Alex, a better idea?

Maybe we can create sys entry to enable/disable hotjoin. I think i3c
should default support hotjoin, but it exist user case that needn't hj and
want more aggressive power saving.

If create /sys/ entry, it need change driver/i3c/master.c.

Frank

> 
> Thanks,
> Miquèl

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

* Re: [PATCH 1/5] i3c: master: svc: enable hotjoin default
@ 2023-10-17 14:51       ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-17 14:51 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

On Tue, Oct 17, 2023 at 04:04:57PM +0200, Miquel Raynal wrote:
> Hi Frank,
> 
> Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:28 -0400:
> 
> > Hotjoin require clock running and enable SLVSTART irq.
> > Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
> > save power.
> 
> I am really not a big fan of the use of modules parameters. Maybe it
> makes sense here. Alex, a better idea?

Maybe we can create sys entry to enable/disable hotjoin. I think i3c
should default support hotjoin, but it exist user case that needn't hj and
want more aggressive power saving.

If create /sys/ entry, it need change driver/i3c/master.c.

Frank

> 
> Thanks,
> Miquèl

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 3/5] i3c: svc: rename read_len as actual_len
  2023-10-17 14:07     ` Miquel Raynal
@ 2023-10-17 20:43       ` Frank Li
  -1 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-17 20:43 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

On Tue, Oct 17, 2023 at 04:07:29PM +0200, Miquel Raynal wrote:
> Hi Frank,
> 
> Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:30 -0400:
> 
> > I3C transfer, target can early terminate transfer.
> > I2C transfer, target can NACK write transfer.
> > 
> > 'actual_len' is better name than 'read_len'.
> 
> I don't find read_len confusing because it may mean "how much bytes
> were actually read" rather than "how much we need to read". But if
> actual_len sounds better, I'm fine.

Another reason: According to i3c spec. 5.2.2.3.6 line 6090.
Target ends or continues the write transfer.

in HDR mode, target can end write transfer. So use 'actual_len'

Do you think I need add it to commit message

Frank

> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> 
> > 
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> 
> Thanks,
> Miquèl

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

* Re: [PATCH 3/5] i3c: svc: rename read_len as actual_len
@ 2023-10-17 20:43       ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-17 20:43 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

On Tue, Oct 17, 2023 at 04:07:29PM +0200, Miquel Raynal wrote:
> Hi Frank,
> 
> Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:30 -0400:
> 
> > I3C transfer, target can early terminate transfer.
> > I2C transfer, target can NACK write transfer.
> > 
> > 'actual_len' is better name than 'read_len'.
> 
> I don't find read_len confusing because it may mean "how much bytes
> were actually read" rather than "how much we need to read". But if
> actual_len sounds better, I'm fine.

Another reason: According to i3c spec. 5.2.2.3.6 line 6090.
Target ends or continues the write transfer.

in HDR mode, target can end write transfer. So use 'actual_len'

Do you think I need add it to commit message

Frank

> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> 
> > 
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> 
> Thanks,
> Miquèl

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 1/5] i3c: master: svc: enable hotjoin default
  2023-10-17 14:51       ` Frank Li
@ 2023-10-17 22:22         ` Alexandre Belloni
  -1 siblings, 0 replies; 34+ messages in thread
From: Alexandre Belloni @ 2023-10-17 22:22 UTC (permalink / raw)
  To: Frank Li; +Cc: Miquel Raynal, conor.culhane, joe, linux-i3c, linux-kernel, imx

Hello,

On 17/10/2023 10:51:25-0400, Frank Li wrote:
> On Tue, Oct 17, 2023 at 04:04:57PM +0200, Miquel Raynal wrote:
> > Hi Frank,
> > 
> > Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:28 -0400:
> > 
> > > Hotjoin require clock running and enable SLVSTART irq.
> > > Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
> > > save power.
> > 
> > I am really not a big fan of the use of modules parameters. Maybe it
> > makes sense here. Alex, a better idea?
> 
> Maybe we can create sys entry to enable/disable hotjoin. I think i3c
> should default support hotjoin, but it exist user case that needn't hj and
> want more aggressive power saving.
> 
> If create /sys/ entry, it need change driver/i3c/master.c.
> 

If this can be changed dynamically, I guess ideally, we should be able
to set it independently per controller so it could be disabled on a bus
but kept enabled on others.


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH 1/5] i3c: master: svc: enable hotjoin default
@ 2023-10-17 22:22         ` Alexandre Belloni
  0 siblings, 0 replies; 34+ messages in thread
From: Alexandre Belloni @ 2023-10-17 22:22 UTC (permalink / raw)
  To: Frank Li; +Cc: Miquel Raynal, conor.culhane, joe, linux-i3c, linux-kernel, imx

Hello,

On 17/10/2023 10:51:25-0400, Frank Li wrote:
> On Tue, Oct 17, 2023 at 04:04:57PM +0200, Miquel Raynal wrote:
> > Hi Frank,
> > 
> > Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:28 -0400:
> > 
> > > Hotjoin require clock running and enable SLVSTART irq.
> > > Add module parameter 'hotjoin' to disable hotjoin and enable runtime_pm to
> > > save power.
> > 
> > I am really not a big fan of the use of modules parameters. Maybe it
> > makes sense here. Alex, a better idea?
> 
> Maybe we can create sys entry to enable/disable hotjoin. I think i3c
> should default support hotjoin, but it exist user case that needn't hj and
> want more aggressive power saving.
> 
> If create /sys/ entry, it need change driver/i3c/master.c.
> 

If this can be changed dynamically, I guess ideally, we should be able
to set it independently per controller so it could be disabled on a bus
but kept enabled on others.


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 4/5] i3c: master: svc return actual transfer data len
  2023-10-17  8:33     ` Jarkko Nikula
@ 2023-10-18 20:18       ` Frank Li
  -1 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-18 20:18 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

On Tue, Oct 17, 2023 at 11:33:34AM +0300, Jarkko Nikula wrote:
> Hi
> 
> On 10/16/23 18:46, Frank Li wrote:
> > I3C allow devices early terminate data transfer. So set "actual" to
> > indicate how much data get by i3c_priv_xfer.
> > 
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> >   drivers/i3c/master/svc-i3c-master.c | 7 +++++++
> >   1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> > index 3570b709cf60..444825aafa6f 100644
> > --- a/drivers/i3c/master/svc-i3c-master.c
> > +++ b/drivers/i3c/master/svc-i3c-master.c
> > @@ -138,6 +138,7 @@ struct svc_i3c_cmd {
> >   	const void *out;
> >   	unsigned int len;
> >   	unsigned int actual_len;
> > +	struct i3c_priv_xfer *xfer;
> >   	bool continued;
> >   };
> I'm thinking would it make sense to combine this and previous patch by
> removing the read_len/actual_len variable from this structure and use the
> added one (by the patch 2/5) from "struct i3c_priv_xfer" directly?

Some I2C transfer and CCC use svc_i3c_cmd, in such case xfer is NULL. Keep
len/actual_len is more simple.

Frank 

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

* Re: [PATCH 4/5] i3c: master: svc return actual transfer data len
@ 2023-10-18 20:18       ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-18 20:18 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: alexandre.belloni, miquel.raynal, conor.culhane, joe, linux-i3c,
	linux-kernel, imx

On Tue, Oct 17, 2023 at 11:33:34AM +0300, Jarkko Nikula wrote:
> Hi
> 
> On 10/16/23 18:46, Frank Li wrote:
> > I3C allow devices early terminate data transfer. So set "actual" to
> > indicate how much data get by i3c_priv_xfer.
> > 
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> >   drivers/i3c/master/svc-i3c-master.c | 7 +++++++
> >   1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> > index 3570b709cf60..444825aafa6f 100644
> > --- a/drivers/i3c/master/svc-i3c-master.c
> > +++ b/drivers/i3c/master/svc-i3c-master.c
> > @@ -138,6 +138,7 @@ struct svc_i3c_cmd {
> >   	const void *out;
> >   	unsigned int len;
> >   	unsigned int actual_len;
> > +	struct i3c_priv_xfer *xfer;
> >   	bool continued;
> >   };
> I'm thinking would it make sense to combine this and previous patch by
> removing the read_len/actual_len variable from this structure and use the
> added one (by the patch 2/5) from "struct i3c_priv_xfer" directly?

Some I2C transfer and CCC use svc_i3c_cmd, in such case xfer is NULL. Keep
len/actual_len is more simple.

Frank 

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

* Re: [PATCH 4/5] i3c: master: svc return actual transfer data len
  2023-10-17 14:10     ` Miquel Raynal
@ 2023-10-18 20:26       ` Frank Li
  -1 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-18 20:26 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

On Tue, Oct 17, 2023 at 04:10:07PM +0200, Miquel Raynal wrote:
> Hi Frank,
> 
> Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:31 -0400:
> 
> > I3C allow devices early terminate data transfer. So set "actual" to
> > indicate how much data get by i3c_priv_xfer.
> > 
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> >  drivers/i3c/master/svc-i3c-master.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> > index 3570b709cf60..444825aafa6f 100644
> > --- a/drivers/i3c/master/svc-i3c-master.c
> > +++ b/drivers/i3c/master/svc-i3c-master.c
> > @@ -138,6 +138,7 @@ struct svc_i3c_cmd {
> >  	const void *out;
> >  	unsigned int len;
> >  	unsigned int actual_len;
> > +	struct i3c_priv_xfer *xfer;
> >  	bool continued;
> >  };
> >  
> > @@ -1045,6 +1046,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
> >  
> >  	if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) {
> >  		ret = -ENXIO;
> > +		*actual_len = 0;
> >  		goto emit_stop;
> >  	}
> >  
> > @@ -1062,6 +1064,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
> >  	 */
> >  	if (SVC_I3C_MSTATUS_IBIWON(reg)) {
> >  		ret = -ENXIO;
> > +		*actual_len = 0;
> >  		goto emit_stop;
> >  	}
> >  
> > @@ -1157,6 +1160,9 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
> >  					  cmd->addr, cmd->in, cmd->out,
> >  					  cmd->len, &cmd->actual_len,
> >  					  cmd->continued);
> > +		if (cmd->xfer)
> > +			cmd->xfer->actual = cmd->actual_len;
> 
> Just to be sure, wouldn't it be more natural to always fill cmd->xfer
> rather than checking it here?

cmd->xfer is NULL for i2c and ccc transfer. So need check it. 
I will add comments here

Frank
> 
> > +
> >  		if (ret)
> >  			break;
> >  	}
> > @@ -1344,6 +1350,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
> >  	for (i = 0; i < nxfers; i++) {
> >  		struct svc_i3c_cmd *cmd = &xfer->cmds[i];
> >  
> > +		cmd->xfer = xfers + i;
> 
> Please follow the same pattern as below: = &xfers[i]
> 
> >  		cmd->addr = master->addrs[data->index];
> >  		cmd->rnw = xfers[i].rnw;
> >  		cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;
> 
> 
> Thanks,
> Miquèl

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

* Re: [PATCH 4/5] i3c: master: svc return actual transfer data len
@ 2023-10-18 20:26       ` Frank Li
  0 siblings, 0 replies; 34+ messages in thread
From: Frank Li @ 2023-10-18 20:26 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: alexandre.belloni, conor.culhane, joe, linux-i3c, linux-kernel, imx

On Tue, Oct 17, 2023 at 04:10:07PM +0200, Miquel Raynal wrote:
> Hi Frank,
> 
> Frank.Li@nxp.com wrote on Mon, 16 Oct 2023 11:46:31 -0400:
> 
> > I3C allow devices early terminate data transfer. So set "actual" to
> > indicate how much data get by i3c_priv_xfer.
> > 
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> >  drivers/i3c/master/svc-i3c-master.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> > index 3570b709cf60..444825aafa6f 100644
> > --- a/drivers/i3c/master/svc-i3c-master.c
> > +++ b/drivers/i3c/master/svc-i3c-master.c
> > @@ -138,6 +138,7 @@ struct svc_i3c_cmd {
> >  	const void *out;
> >  	unsigned int len;
> >  	unsigned int actual_len;
> > +	struct i3c_priv_xfer *xfer;
> >  	bool continued;
> >  };
> >  
> > @@ -1045,6 +1046,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
> >  
> >  	if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) {
> >  		ret = -ENXIO;
> > +		*actual_len = 0;
> >  		goto emit_stop;
> >  	}
> >  
> > @@ -1062,6 +1064,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
> >  	 */
> >  	if (SVC_I3C_MSTATUS_IBIWON(reg)) {
> >  		ret = -ENXIO;
> > +		*actual_len = 0;
> >  		goto emit_stop;
> >  	}
> >  
> > @@ -1157,6 +1160,9 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
> >  					  cmd->addr, cmd->in, cmd->out,
> >  					  cmd->len, &cmd->actual_len,
> >  					  cmd->continued);
> > +		if (cmd->xfer)
> > +			cmd->xfer->actual = cmd->actual_len;
> 
> Just to be sure, wouldn't it be more natural to always fill cmd->xfer
> rather than checking it here?

cmd->xfer is NULL for i2c and ccc transfer. So need check it. 
I will add comments here

Frank
> 
> > +
> >  		if (ret)
> >  			break;
> >  	}
> > @@ -1344,6 +1350,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
> >  	for (i = 0; i < nxfers; i++) {
> >  		struct svc_i3c_cmd *cmd = &xfer->cmds[i];
> >  
> > +		cmd->xfer = xfers + i;
> 
> Please follow the same pattern as below: = &xfers[i]
> 
> >  		cmd->addr = master->addrs[data->index];
> >  		cmd->rnw = xfers[i].rnw;
> >  		cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;
> 
> 
> Thanks,
> Miquèl

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

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

end of thread, other threads:[~2023-10-18 20:26 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-16 15:46 [PATCH 0/5] i3c: master: some improvment for i3c master Frank Li
2023-10-16 15:46 ` Frank Li
2023-10-16 15:46 ` [PATCH 1/5] i3c: master: svc: enable hotjoin default Frank Li
2023-10-16 15:46   ` Frank Li
2023-10-17  6:48   ` Joe Perches
2023-10-17  6:48     ` Joe Perches
2023-10-17 14:04   ` Miquel Raynal
2023-10-17 14:04     ` Miquel Raynal
2023-10-17 14:51     ` Frank Li
2023-10-17 14:51       ` Frank Li
2023-10-17 22:22       ` Alexandre Belloni
2023-10-17 22:22         ` Alexandre Belloni
2023-10-16 15:46 ` [PATCH 2/5] i3c: add actual in i3c_priv_xfer Frank Li
2023-10-16 15:46   ` Frank Li
2023-10-17  6:10   ` Jarkko Nikula
2023-10-17  6:10     ` Jarkko Nikula
2023-10-16 15:46 ` [PATCH 3/5] i3c: svc: rename read_len as actual_len Frank Li
2023-10-16 15:46   ` Frank Li
2023-10-17 14:07   ` Miquel Raynal
2023-10-17 14:07     ` Miquel Raynal
2023-10-17 20:43     ` Frank Li
2023-10-17 20:43       ` Frank Li
2023-10-16 15:46 ` [PATCH 4/5] i3c: master: svc return actual transfer data len Frank Li
2023-10-16 15:46   ` Frank Li
2023-10-17  8:33   ` Jarkko Nikula
2023-10-17  8:33     ` Jarkko Nikula
2023-10-18 20:18     ` Frank Li
2023-10-18 20:18       ` Frank Li
2023-10-17 14:10   ` Miquel Raynal
2023-10-17 14:10     ` Miquel Raynal
2023-10-18 20:26     ` Frank Li
2023-10-18 20:26       ` Frank Li
2023-10-16 15:46 ` [PATCH 5/5] i3c: add API i3c_dev_gettstatus_format1() to get target device status Frank Li
2023-10-16 15:46   ` Frank Li

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.