Improvement and fix for HiSilicon I2C driver
Subsystems (2)
cover Improvement and fix for HiSilicon I2C driver
From: Yicong Yang <[email protected]>
This patchset includes 2 patches for 1) Improve the interrupt handling to avoid redundant interrupts and 2) fix the issue that on error case the completion is not handled and corrupt the next transfer.
Yicong Yang (2):
i2c: hisi: Avoid redundant interrupts
i2c: hisi: Only use the completion interrupt to finish the transfer
drivers/i2c/busses/i2c-hisi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
Signature · 1 line
2.24.0
PATCH 1/2 i2c: hisi: Avoid redundant interrupts
From: Yicong Yang <[email protected]>
After issuing all the messages we can disable the TX_EMPTY interrupts to avoid handling redundant interrupts. For doing a sinlge bus detection (i2cdetect -y -r 0) we can reduce ~97% interrupts (before ~12000 after ~400).
--- drivers/i2c/busses/i2c-hisi.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/i2c/busses/i2c-hisi.c +7 -0
@@ -316,6 +316,13 @@ static void hisi_i2c_xfer_msg(struct hisi_i2c_controller *ctlr) max_write == 0)break ; } + +/* +* Disable the TX_EMPTY interrupt after finishing all the messages to +* avoid overwhelming the CPU. +*/ +if (ctlr->msg_tx_idx == ctlr->msg_num) +hisi_i2c_disable_int (ctlr,HISI_I2C_INT_TX_EMPTY ); }static irqreturn_t hisi_i2c_irq (int irq,void *context)
Signature · 1 line
2.24.0
Wolfram Sang
AppliedRe: [PATCH 1/2] i2c: hisi: Avoid redundant interrupts
Quoted 10 lines · Yicong Yang
From: Yicong Yang <[email protected]>
After issuing all the messages we can disable the
TX_EMPTYinterrupts to avoid handling redundant interrupts. For doing a sinlge bus detection (i2cdetect -y -r 0) we can reduce ~97% interrupts (before ~12000 after ~400).Reported-by Sheng Feng <[email protected]>Signed-off-by Sheng Feng <[email protected]>Signed-off-by Yicong Yang <[email protected]>
Applied to for-current, thanks!
PATCH 2/2 i2c: hisi: Only use the completion interrupt to finish the transfer
In reply to Yicong YangFrom: Yicong Yang <[email protected]>
The controller will always generate a completion interrupt when the transfer is finished normally or not. Currently we use either error or completion interrupt to finish, this may result the completion interrupt unhandled and corrupt the next transfer, especially at low speed mode. Since on error case, the error interrupt will come first then is the completion interrupt. So only use the completion interrupt to finish the whole transfer process.
--- drivers/i2c/busses/i2c-hisi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-hisi.c +5 -1
@@ -348,7 +348,11 @@ static irqreturn_t hisi_i2c_irq(int irq, void *context)hisi_i2c_read_rx_fifo (ctlr); out: -if (int_stat &HISI_I2C_INT_TRANS_CPLT || ctlr->xfer_err) { +/* +* Only use TRANS_CPLT to indicate the completion. On error cases we'll +* get two interrupts, INT_ERR first then TRANS_CPLT. +*/ +if (int_stat &HISI_I2C_INT_TRANS_CPLT ) {hisi_i2c_disable_int (ctlr,HISI_I2C_INT_ALL );hisi_i2c_clear_int (ctlr,HISI_I2C_INT_ALL );complete (ctlr->completion);
Signature · 1 line
2.24.0
Wolfram Sang
AppliedRe: [PATCH 2/2] i2c: hisi: Only use the completion interrupt to finish the transfer
Quoted 10 lines · Yicong Yang
From: Yicong Yang <[email protected]>
The controller will always generate a completion interrupt when the transfer is finished normally or not. Currently we use either error or completion interrupt to finish, this may result the completion interrupt unhandled and corrupt the next transfer, especially at low speed mode. Since on error case, the error interrupt will come first then is the completion interrupt. So only use the completion interrupt to finish the whole transfer process.
Quoted 4 lines
Fixes d62fbdb99a85 ("i2c: add support for HiSilicon I2C controller")Reported-by Sheng Feng <[email protected]>Signed-off-by Sheng Feng <[email protected]>Signed-off-by Yicong Yang <[email protected]>
Applied to for-current, thanks!