Commit 81b9fd69 authored by Danilo Krummrich's avatar Danilo Krummrich Committed by Dmitry Torokhov

Input: ps2-gpio - don't send rx data before the stop bit

Sending the data before processing the stop bit from the device already
saves the data of the current xfer in case the stop bit is missed.

However, when TX xfers are enabled this introduces a race condition when
a peripheral driver using the bus immediately requests a TX xfer from IRQ
context.

Therefore the data must be send after receiving the stop bit, although
it is possible the data is lost when missing the stop bit.
Signed-off-by: default avatarDanilo Krummrich <danilokrummrich@dk-develop.de>
Link: https://lore.kernel.org/r/20220215160208.34826-5-danilokrummrich@dk-develop.deSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 6283cc9e
...@@ -225,6 +225,13 @@ static irqreturn_t ps2_gpio_irq_rx(struct ps2_gpio_data *drvdata) ...@@ -225,6 +225,13 @@ static irqreturn_t ps2_gpio_irq_rx(struct ps2_gpio_data *drvdata)
if (!drvdata->write_enable) if (!drvdata->write_enable)
goto err; goto err;
} }
break;
case PS2_STOP_BIT:
/* stop bit should be high */
if (unlikely(!data)) {
dev_err(drvdata->dev, "RX: stop bit should be high\n");
goto err;
}
/* /*
* Do not send spurious ACK's and NACK's when write fn is * Do not send spurious ACK's and NACK's when write fn is
...@@ -237,22 +244,9 @@ static irqreturn_t ps2_gpio_irq_rx(struct ps2_gpio_data *drvdata) ...@@ -237,22 +244,9 @@ static irqreturn_t ps2_gpio_irq_rx(struct ps2_gpio_data *drvdata)
break; break;
} }
/*
* Let's send the data without waiting for the stop bit to be
* sent. It may happen that we miss the stop bit. When this
* happens we have no way to recover from this, certainly
* missing the parity bit would be recognized when processing
* the stop bit. When missing both, data is lost.
*/
serio_interrupt(drvdata->serio, byte, rxflags); serio_interrupt(drvdata->serio, byte, rxflags);
dev_dbg(drvdata->dev, "RX: sending byte 0x%x\n", byte); dev_dbg(drvdata->dev, "RX: sending byte 0x%x\n", byte);
break;
case PS2_STOP_BIT:
/* stop bit should be high */
if (unlikely(!data)) {
dev_err(drvdata->dev, "RX: stop bit should be high\n");
goto err;
}
cnt = byte = 0; cnt = byte = 0;
goto end; /* success */ goto end; /* success */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment