Skip to contentSkip to conversation

Small fix with i2c-ismt driver

PATCH Applied Fan Du 3 participants 7 messages Sep 16, 2014 – Sep 20, 2014 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Fan Du

author
#0 lore raw

cover Small fix with i2c-ismt driver

Hi,

This patcheset fix two issue with i2c ismt driver:

Patch1: Use only 2 descriptor for transfer and receive
Patch2: Only copy valid data when transfer

Fan Du (2):
i2c-ismt: Use minimum descriptor size
i2c-ismt: use correct length when copy buffer

 drivers/i2c/busses/i2c-ismt.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1410859264-7118-1-git-send-email-fan.du-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

author
#2 lore raw

PATCH 1/2 i2c-ismt: Use minimum descriptor size

Software is allowed to allocate number of descriptor size from 2 to 256, this i2c controller could process more descriptor, but for i2c core soft ware layer, only one i2c transaction is allowed each time.

So here switch to minimum 2 descriptor when initialization.

---
 drivers/i2c/busses/i2c-ismt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-ismt.c +1 -1
index 9844925..8a0275c 100644
@@ -81,7 +81,7 @@
 #define PCI_DEVICE_ID_INTEL_S1200_SMT1	0x0c5a
 #define PCI_DEVICE_ID_INTEL_AVOTON_SMT	0x1f15
 
-#define ISMT_DESC_ENTRIES	32	/* number of descriptor entries */
+#define ISMT_DESC_ENTRIES	2	/* number of descriptor entries */
 #define ISMT_MAX_RETRIES	3	/* number of SMBus retries to attempt */
 
 /* Hardware Descriptor Constants - Control Field */
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1410859264-7118-2-git-send-email-fan.du-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

Acked-by
#4 lore raw

Re: [PATCH 1/2] i2c-ismt: Use minimum descriptor size

Quoted 28 lines · Fan Du

Software is allowed to allocate number of descriptor size from 2 to 256, this i2c controller could process more descriptor, but for i2c core soft ware layer, only one i2c transaction is allowed each time.

So here switch to minimum 2 descriptor when initialization.

---
 drivers/i2c/busses/i2c-ismt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-ismt.c +1 -1
index 9844925..8a0275c 100644
@@ -81,7 +81,7 @@
 #define PCI_DEVICE_ID_INTEL_S1200_SMT1	0x0c5a
 #define PCI_DEVICE_ID_INTEL_AVOTON_SMT	0x1f15
 
-#define ISMT_DESC_ENTRIES	32	/* number of descriptor entries */
+#define ISMT_DESC_ENTRIES	2	/* number of descriptor entries */
 #define ISMT_MAX_RETRIES	3	/* number of SMBus retries to attempt */
 
 /* Hardware Descriptor Constants - Control Field */
Signature · 1 line
1.7.9.5
Applied
#5 lore raw

Re: [PATCH 1/2] i2c-ismt: Use minimum descriptor size

In reply to a message not in the archive
Quoted 7 lines · Fan Du

Software is allowed to allocate number of descriptor size from 2 to 256, this i2c controller could process more descriptor, but for i2c core soft ware layer, only one i2c transaction is allowed each time.

So here switch to minimum 2 descriptor when initialization.

Applied to for-next, thanks!

author
#6 lore raw

PATCH 2/2 i2c-ismt: use correct length when copy buffer

In reply to a message not in the archive

In block write mode, when encapsulating dma_buffer, first element is 'command', the rest is data buffer, so only copy actual data buffer starting from block[1] with the size indicating by block[0].

---
 drivers/i2c/busses/i2c-ismt.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-ismt.c +2 -2
index 8a0275c..3f6ecbf 100644
@@ -497,7 +497,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
 			desc->wr_len_cmd = dma_size;
 			desc->control |= ISMT_DESC_BLK;
 			priv->dma_buffer[0] = command;
-			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size);
+			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
 		} else {
 			/* Block Read */
 			dev_dbg(dev, "I2C_SMBUS_BLOCK_DATA:  READ\n");
@@ -525,7 +525,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
 			desc->wr_len_cmd = dma_size;
 			desc->control |= ISMT_DESC_I2C;
 			priv->dma_buffer[0] = command;
-			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size);
+			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
 		} else {
 			/* i2c Block Read */
 			dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA:  READ\n");
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1410859264-7118-3-git-send-email-fan.du-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

Acked-by
#8 lore raw

Re: [PATCH 2/2] i2c-ismt: use correct length when copy buffer

Quoted 35 lines · Fan Du

In block write mode, when encapsulating dma_buffer, first element is 'command', the rest is data buffer, so only copy actual data buffer starting from block[1] with the size indicating by block[0].

---
 drivers/i2c/busses/i2c-ismt.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-ismt.c +2 -2
index 8a0275c..3f6ecbf 100644
@@ -497,7 +497,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
 			desc->wr_len_cmd = dma_size;
 			desc->control |= ISMT_DESC_BLK;
 			priv->dma_buffer[0] = command;
-			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size);
+			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
 		} else {
 			/* Block Read */
 			dev_dbg(dev, "I2C_SMBUS_BLOCK_DATA:  READ\n");
@@ -525,7 +525,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
 			desc->wr_len_cmd = dma_size;
 			desc->control |= ISMT_DESC_I2C;
 			priv->dma_buffer[0] = command;
-			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size);
+			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
 		} else {
 			/* i2c Block Read */
 			dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA:  READ\n");
Signature · 1 line
1.7.9.5
Applied
#9 lore raw

Re: [PATCH 2/2] i2c-ismt: use correct length when copy buffer

In reply to a message not in the archive
Quoted 5 lines · Fan Du

In block write mode, when encapsulating dma_buffer, first element is 'command', the rest is data buffer, so only copy actual data buffer starting from block[1] with the size indicating by block[0].

Applied to for-current and added stable, thanks!