linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH i2c-next 0/4] i2c: mlxcpld: Add fixes and features for transaction polling time setting
@ 2021-08-23 14:45 Vadim Pasternak
  2021-08-23 14:45 ` [PATCH i2c-next 1/4] i2c: mlxcpld: Fix criteria for frequency setting Vadim Pasternak
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Vadim Pasternak @ 2021-08-23 14:45 UTC (permalink / raw)
  To: wsa; +Cc: peda, linux-i2c, Vadim Pasternak

This patch set contains:
Patches #1-#2: Fixes for frequency setting.
Patch #3: Reducing driver's transaction polling time.
Patch #4: Flexible setting of transaction polling time according to I2C
	  bus frequency

Vadim Pasternak (4):
  i2c: mlxcpld: Fix criteria for frequency setting
  i2c: mlxcpld: Modify register setting for 400KHz frequency
  i2c: mlxcpld: Reduce polling time for performance improvement
  i2c: mlxcpld: Allow flexible polling time setting for I2C transactions

 drivers/i2c/busses/i2c-mlxcpld.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

-- 
2.20.1


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

* [PATCH i2c-next 1/4] i2c: mlxcpld: Fix criteria for frequency setting
  2021-08-23 14:45 [PATCH i2c-next 0/4] i2c: mlxcpld: Add fixes and features for transaction polling time setting Vadim Pasternak
@ 2021-08-23 14:45 ` Vadim Pasternak
  2021-10-04 19:58   ` Wolfram Sang
  2021-08-23 14:45 ` [PATCH i2c-next 2/4] i2c: mlxcpld: Modify register setting for 400KHz frequency Vadim Pasternak
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Vadim Pasternak @ 2021-08-23 14:45 UTC (permalink / raw)
  To: wsa; +Cc: peda, linux-i2c, Vadim Pasternak

Value for getting frequency capability wrongly has been taken from
register offset instead of register value.

Fixes: 66b0c2846ba8 ("i2c: mlxcpld: Add support for I2C bus frequency setting")
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
---
 drivers/i2c/busses/i2c-mlxcpld.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c
index 4e0b7c2882ce..6d41c3db8a2b 100644
--- a/drivers/i2c/busses/i2c-mlxcpld.c
+++ b/drivers/i2c/busses/i2c-mlxcpld.c
@@ -495,7 +495,7 @@ mlxcpld_i2c_set_frequency(struct mlxcpld_i2c_priv *priv,
 		return err;
 
 	/* Set frequency only if it is not 100KHz, which is default. */
-	switch ((data->reg & data->mask) >> data->bit) {
+	switch ((regval & data->mask) >> data->bit) {
 	case MLXCPLD_I2C_FREQ_1000KHZ:
 		freq = MLXCPLD_I2C_FREQ_1000KHZ_SET;
 		break;
-- 
2.20.1


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

* [PATCH i2c-next 2/4] i2c: mlxcpld: Modify register setting for 400KHz frequency
  2021-08-23 14:45 [PATCH i2c-next 0/4] i2c: mlxcpld: Add fixes and features for transaction polling time setting Vadim Pasternak
  2021-08-23 14:45 ` [PATCH i2c-next 1/4] i2c: mlxcpld: Fix criteria for frequency setting Vadim Pasternak
@ 2021-08-23 14:45 ` Vadim Pasternak
  2021-10-04 19:59   ` Wolfram Sang
  2021-08-23 14:45 ` [PATCH i2c-next 3/4] i2c: mlxcpld: Reduce polling time for performance improvement Vadim Pasternak
  2021-08-23 14:45 ` [PATCH i2c-next 4/4] i2c: mlxcpld: Allow flexible polling time setting for I2C transactions Vadim Pasternak
  3 siblings, 1 reply; 10+ messages in thread
From: Vadim Pasternak @ 2021-08-23 14:45 UTC (permalink / raw)
  To: wsa; +Cc: peda, linux-i2c, Vadim Pasternak

Change setting for 400KHz frequency support by more accurate value.

Fixes: 66b0c2846ba8 ("i2c: mlxcpld: Add support for I2C bus frequency setting")
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
---
 drivers/i2c/busses/i2c-mlxcpld.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c
index 6d41c3db8a2b..015e11c4663f 100644
--- a/drivers/i2c/busses/i2c-mlxcpld.c
+++ b/drivers/i2c/busses/i2c-mlxcpld.c
@@ -49,7 +49,7 @@
 #define MLXCPLD_LPCI2C_NACK_IND		2
 
 #define MLXCPLD_I2C_FREQ_1000KHZ_SET	0x04
-#define MLXCPLD_I2C_FREQ_400KHZ_SET	0x0f
+#define MLXCPLD_I2C_FREQ_400KHZ_SET	0x0c
 #define MLXCPLD_I2C_FREQ_100KHZ_SET	0x42
 
 enum mlxcpld_i2c_frequency {
-- 
2.20.1


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

* [PATCH i2c-next 3/4] i2c: mlxcpld: Reduce polling time for performance improvement
  2021-08-23 14:45 [PATCH i2c-next 0/4] i2c: mlxcpld: Add fixes and features for transaction polling time setting Vadim Pasternak
  2021-08-23 14:45 ` [PATCH i2c-next 1/4] i2c: mlxcpld: Fix criteria for frequency setting Vadim Pasternak
  2021-08-23 14:45 ` [PATCH i2c-next 2/4] i2c: mlxcpld: Modify register setting for 400KHz frequency Vadim Pasternak
@ 2021-08-23 14:45 ` Vadim Pasternak
  2021-10-04 19:59   ` Wolfram Sang
  2021-08-23 14:45 ` [PATCH i2c-next 4/4] i2c: mlxcpld: Allow flexible polling time setting for I2C transactions Vadim Pasternak
  3 siblings, 1 reply; 10+ messages in thread
From: Vadim Pasternak @ 2021-08-23 14:45 UTC (permalink / raw)
  To: wsa; +Cc: peda, linux-i2c, Vadim Pasternak

Decrease polling time 'MLXCPLD_I2C_POLL_TIME' from 400 usec to 200
usec. It improves performance of I2C transactions.

Reliability of setting polling time to 200 usec has been validated
across all the supported systems.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
---
 drivers/i2c/busses/i2c-mlxcpld.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c
index 015e11c4663f..615f0a98640e 100644
--- a/drivers/i2c/busses/i2c-mlxcpld.c
+++ b/drivers/i2c/busses/i2c-mlxcpld.c
@@ -27,7 +27,7 @@
 #define MLXCPLD_I2C_MAX_ADDR_LEN	4
 #define MLXCPLD_I2C_RETR_NUM		2
 #define MLXCPLD_I2C_XFER_TO		500000 /* usec */
-#define MLXCPLD_I2C_POLL_TIME		400   /* usec */
+#define MLXCPLD_I2C_POLL_TIME		200   /* usec */
 
 /* LPC I2C registers */
 #define MLXCPLD_LPCI2C_CPBLTY_REG	0x0
-- 
2.20.1


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

* [PATCH i2c-next 4/4] i2c: mlxcpld: Allow flexible polling time setting for I2C transactions
  2021-08-23 14:45 [PATCH i2c-next 0/4] i2c: mlxcpld: Add fixes and features for transaction polling time setting Vadim Pasternak
                   ` (2 preceding siblings ...)
  2021-08-23 14:45 ` [PATCH i2c-next 3/4] i2c: mlxcpld: Reduce polling time for performance improvement Vadim Pasternak
@ 2021-08-23 14:45 ` Vadim Pasternak
  2021-10-04 20:00   ` Wolfram Sang
  2021-10-11 10:32   ` Wolfram Sang
  3 siblings, 2 replies; 10+ messages in thread
From: Vadim Pasternak @ 2021-08-23 14:45 UTC (permalink / raw)
  To: wsa; +Cc: peda, linux-i2c, Vadim Pasternak

Allow polling time setting according to I2C frequency supported across
the system. For base frequency 400 KHz and 1 MHz set polling time is set
four times less than for system with base frequency 100KHz.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
---
 drivers/i2c/busses/i2c-mlxcpld.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c
index 615f0a98640e..56aa424fd71d 100644
--- a/drivers/i2c/busses/i2c-mlxcpld.c
+++ b/drivers/i2c/busses/i2c-mlxcpld.c
@@ -73,6 +73,7 @@ struct mlxcpld_i2c_priv {
 	struct  mlxcpld_i2c_curr_xfer xfer;
 	struct device *dev;
 	bool smbus_block;
+	int polling_time;
 };
 
 static void mlxcpld_i2c_lpc_write_buf(u8 *data, u8 len, u32 addr)
@@ -267,8 +268,8 @@ static int mlxcpld_i2c_wait_for_free(struct mlxcpld_i2c_priv *priv)
 	do {
 		if (!mlxcpld_i2c_check_busy(priv))
 			break;
-		usleep_range(MLXCPLD_I2C_POLL_TIME / 2, MLXCPLD_I2C_POLL_TIME);
-		timeout += MLXCPLD_I2C_POLL_TIME;
+		usleep_range(priv->polling_time / 2, priv->polling_time);
+		timeout += priv->polling_time;
 	} while (timeout <= MLXCPLD_I2C_XFER_TO);
 
 	if (timeout > MLXCPLD_I2C_XFER_TO)
@@ -288,10 +289,10 @@ static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv)
 	u8 datalen, val;
 
 	do {
-		usleep_range(MLXCPLD_I2C_POLL_TIME / 2, MLXCPLD_I2C_POLL_TIME);
+		usleep_range(priv->polling_time / 2, priv->polling_time);
 		if (!mlxcpld_i2c_check_status(priv, &status))
 			break;
-		timeout += MLXCPLD_I2C_POLL_TIME;
+		timeout += priv->polling_time;
 	} while (status == 0 && timeout < MLXCPLD_I2C_XFER_TO);
 
 	switch (status) {
@@ -498,9 +499,11 @@ mlxcpld_i2c_set_frequency(struct mlxcpld_i2c_priv *priv,
 	switch ((regval & data->mask) >> data->bit) {
 	case MLXCPLD_I2C_FREQ_1000KHZ:
 		freq = MLXCPLD_I2C_FREQ_1000KHZ_SET;
+		priv->polling_time /= 4;
 		break;
 	case MLXCPLD_I2C_FREQ_400KHZ:
 		freq = MLXCPLD_I2C_FREQ_400KHZ_SET;
+		priv->polling_time /= 4;
 		break;
 	default:
 		return 0;
@@ -527,6 +530,7 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev)
 
 	priv->dev = &pdev->dev;
 	priv->base_addr = MLXPLAT_CPLD_LPC_I2C_BASE_ADDR;
+	priv->polling_time = MLXCPLD_I2C_POLL_TIME;
 
 	/* Set I2C bus frequency if platform data provides this info. */
 	pdata = dev_get_platdata(&pdev->dev);
-- 
2.20.1


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

* Re: [PATCH i2c-next 1/4] i2c: mlxcpld: Fix criteria for frequency setting
  2021-08-23 14:45 ` [PATCH i2c-next 1/4] i2c: mlxcpld: Fix criteria for frequency setting Vadim Pasternak
@ 2021-10-04 19:58   ` Wolfram Sang
  0 siblings, 0 replies; 10+ messages in thread
From: Wolfram Sang @ 2021-10-04 19:58 UTC (permalink / raw)
  To: Vadim Pasternak; +Cc: peda, linux-i2c

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

On Mon, Aug 23, 2021 at 05:45:01PM +0300, Vadim Pasternak wrote:
> Value for getting frequency capability wrongly has been taken from
> register offset instead of register value.
> 
> Fixes: 66b0c2846ba8 ("i2c: mlxcpld: Add support for I2C bus frequency setting")
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH i2c-next 2/4] i2c: mlxcpld: Modify register setting for 400KHz frequency
  2021-08-23 14:45 ` [PATCH i2c-next 2/4] i2c: mlxcpld: Modify register setting for 400KHz frequency Vadim Pasternak
@ 2021-10-04 19:59   ` Wolfram Sang
  0 siblings, 0 replies; 10+ messages in thread
From: Wolfram Sang @ 2021-10-04 19:59 UTC (permalink / raw)
  To: Vadim Pasternak; +Cc: peda, linux-i2c

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

On Mon, Aug 23, 2021 at 05:45:02PM +0300, Vadim Pasternak wrote:
> Change setting for 400KHz frequency support by more accurate value.
> 
> Fixes: 66b0c2846ba8 ("i2c: mlxcpld: Add support for I2C bus frequency setting")
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH i2c-next 3/4] i2c: mlxcpld: Reduce polling time for performance improvement
  2021-08-23 14:45 ` [PATCH i2c-next 3/4] i2c: mlxcpld: Reduce polling time for performance improvement Vadim Pasternak
@ 2021-10-04 19:59   ` Wolfram Sang
  0 siblings, 0 replies; 10+ messages in thread
From: Wolfram Sang @ 2021-10-04 19:59 UTC (permalink / raw)
  To: Vadim Pasternak; +Cc: peda, linux-i2c

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

On Mon, Aug 23, 2021 at 05:45:03PM +0300, Vadim Pasternak wrote:
> Decrease polling time 'MLXCPLD_I2C_POLL_TIME' from 400 usec to 200
> usec. It improves performance of I2C transactions.
> 
> Reliability of setting polling time to 200 usec has been validated
> across all the supported systems.
> 
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH i2c-next 4/4] i2c: mlxcpld: Allow flexible polling time setting for I2C transactions
  2021-08-23 14:45 ` [PATCH i2c-next 4/4] i2c: mlxcpld: Allow flexible polling time setting for I2C transactions Vadim Pasternak
@ 2021-10-04 20:00   ` Wolfram Sang
  2021-10-11 10:32   ` Wolfram Sang
  1 sibling, 0 replies; 10+ messages in thread
From: Wolfram Sang @ 2021-10-04 20:00 UTC (permalink / raw)
  To: Vadim Pasternak; +Cc: peda, linux-i2c

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

On Mon, Aug 23, 2021 at 05:45:04PM +0300, Vadim Pasternak wrote:
> Allow polling time setting according to I2C frequency supported across
> the system. For base frequency 400 KHz and 1 MHz set polling time is set
> four times less than for system with base frequency 100KHz.
> 
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>

Patch is good. Just needs to wait until I merge the next rc into my
for-mergewindow branch, so dependencies are met.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH i2c-next 4/4] i2c: mlxcpld: Allow flexible polling time setting for I2C transactions
  2021-08-23 14:45 ` [PATCH i2c-next 4/4] i2c: mlxcpld: Allow flexible polling time setting for I2C transactions Vadim Pasternak
  2021-10-04 20:00   ` Wolfram Sang
@ 2021-10-11 10:32   ` Wolfram Sang
  1 sibling, 0 replies; 10+ messages in thread
From: Wolfram Sang @ 2021-10-11 10:32 UTC (permalink / raw)
  To: Vadim Pasternak; +Cc: peda, linux-i2c

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

On Mon, Aug 23, 2021 at 05:45:04PM +0300, Vadim Pasternak wrote:
> Allow polling time setting according to I2C frequency supported across
> the system. For base frequency 400 KHz and 1 MHz set polling time is set
> four times less than for system with base frequency 100KHz.
> 
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2021-10-11 10:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 14:45 [PATCH i2c-next 0/4] i2c: mlxcpld: Add fixes and features for transaction polling time setting Vadim Pasternak
2021-08-23 14:45 ` [PATCH i2c-next 1/4] i2c: mlxcpld: Fix criteria for frequency setting Vadim Pasternak
2021-10-04 19:58   ` Wolfram Sang
2021-08-23 14:45 ` [PATCH i2c-next 2/4] i2c: mlxcpld: Modify register setting for 400KHz frequency Vadim Pasternak
2021-10-04 19:59   ` Wolfram Sang
2021-08-23 14:45 ` [PATCH i2c-next 3/4] i2c: mlxcpld: Reduce polling time for performance improvement Vadim Pasternak
2021-10-04 19:59   ` Wolfram Sang
2021-08-23 14:45 ` [PATCH i2c-next 4/4] i2c: mlxcpld: Allow flexible polling time setting for I2C transactions Vadim Pasternak
2021-10-04 20:00   ` Wolfram Sang
2021-10-11 10:32   ` Wolfram Sang

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).