imx_serial: set wake bit when we receive a data byte
PATCH 1/1 imx_serial: set wake bit when we receive a data byte
The linux kernel added a flood check for rx data recently in commmit 496a4471b7c3 ("serial: imx: work-around for hardware RX flood"). This check uses the wake bit in the uart status register 2. The wake bit indicates that the receiver detected a start bit. If the kernel sees a number of rx interrupts without the wake bit being set, it treats this as spurious data and resets the uart port. imx_serial does never set the wake bit and triggers the kernel's flood check.
This patch adds support for the wake bit. wake is set when we receive a new character (it's not set for break events). It seems that wake is cleared by the kernel driver, the hardware does not have to clear it automatically after data was read.
--- hw/char/imx_serial.c | 3 +++ 1 file changed, 3 insertions(+)
hw/char/imx_serial.c +3 -0
@@ -321,6 +321,9 @@ static void imx_put_data(void *opaque, uint32_t value)static void imx_receive (void *opaque,const uint8_t *buf,int size) { +IMXSerialState *s = (IMXSerialState *)opaque; + + s->usr2 |=USR2_WAKE ;imx_put_data (opaque, *buf); }
Signature · 1 line
2.30.2
Hi Martin,
Quoted 23 lines · Martin Kaiser
The linux kernel added a flood check for rx data recently in commmit
496a4471b7c3("serial: imx: work-around for hardware RX flood"). This check uses the wake bit in the uart status register 2. The wake bit indicates that the receiver detected a start bit. If the kernel sees a number of rx interrupts without the wake bit being set, it treats this as spurious data and resets the uart port.imx_serialdoes never set the wake bit and triggers the kernel's flood check.This patch adds support for the wake bit. wake is set when we receive a new character (it's not set for break events). It seems that wake is cleared by the kernel driver, the hardware does not have to clear it automatically after data was read.
Signed-off-by Martin Kaiser <[email protected]>--- hw/char/imx_serial.c | 3 +++ 1 file changed, 3 insertions(+)hw/char/imx_serial.c +0
-0
hw/char/imx_serial.c static void imx_put_data(void *opaque, uint32_t value) · line 329
Quoted 9 lines
hw/char/imx_serial.c +3
-0@@ -321,6 +321,9 @@ static void imx_put_data(void *opaque, uint32_t value)static void imx_receive (void *opaque,const uint8_t *buf,int size) { +IMXSerialState *s = (IMXSerialState *)opaque; + + s->usr2 |=USR2_WAKE ;imx_put_data (opaque, *buf); }
Shouldn't we mask this bit for interruptions now?
-- >8 --
include/hw/char/imx_serial.h +0 -0
@@ -71,6 +71,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(IMXSerialState, IMX_SERIAL)#define UCR4_DREN BIT(0)/* Receive Data Ready interrupt
enable */
#define UCR4_TCEN BIT(3) /* TX complete interrupt enable */ +#define UCR4_WKEN BIT(7) /* WAKE interrupt enable */
#define UTS1_TXEMPTY (1<<6)
#define UTS1_RXEMPTY (1<<5)
hw/char/imx_serial.c +1 -2
@@ -80,7 +80,7 @@ static void imx_update(IMXSerialState *s)* TCEN and TXDC are both bit 3 * RDR and DREN are both bit 0 */ - mask |= s->ucr4 & (UCR4_TCEN |UCR4_DREN ); + mask |= s->ucr4 & (UCR4_WKEN |UCR4_TCEN |UCR4_DREN ); usr2 = s->usr2 & mask; ---
Hi Philippe,
thanks for reviewing my patch.
Quoted 1 line · Philippe Mathieu-Daudé
Shouldn't we mask this bit for interruptions now?
yes, we should support interrupts from the wake bit. I'll add your snippet and send a v2.
Thanks,
Martin
Quoted 26 lines
-- >8 --
include/hw/char/imx_serial.h +1
-0@@ -71,6 +71,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(IMXSerialState, IMX_SERIAL)#define UCR4_DREN BIT(0)/* Receive Data Ready interrupt enable */ #define UCR4_TCEN BIT(3)/* TX complete interrupt enable */ +#define UCR4_WKEN BIT(7)/* WAKE interrupt enable */ #define UTS1_TXEMPTY (1<<6)#define UTS1_RXEMPTY (1<<5)hw/char/imx_serial.c +1
-2@@ -80,7 +80,7 @@ static void imx_update(IMXSerialState *s)* TCEN and TXDC are both bit 3 * RDR and DREN are both bit 0 */ - mask |= s->ucr4 & (UCR4_TCEN |UCR4_DREN ); + mask |= s->ucr4 & (UCR4_WKEN |UCR4_TCEN |UCR4_DREN ); usr2 = s->usr2 & mask; ---
PATCH v2 1/1 imx_serial: set wake bit when we receive a data byte
In reply to Martin KaiserThe linux kernel added a flood check for rx data recently in commmit 496a4471b7c3 ("serial: imx: work-around for hardware RX flood"). This check uses the wake bit in the uart status register 2. The wake bit indicates that the receiver detected a start bit on the rx line. If the kernel sees a number of rx interrupts without the wake bit being set, it treats this as spurious data and resets the uart port. imx_serial does never set the wake bit and triggers the kernel's flood check.
This patch adds support for the wake bit. wake is set when we receive a new character (it's not set for break events). It seems that wake is cleared by the kernel driver, the hardware does not have to clear it automatically after data was read.
The wake bit can be configured as an interrupt source. Support this mechanism as well.
---
v2:
- support interrupts from wake
- clean up the commit message
hw/char/imx_serial.c | 5 ++++- include/hw/char/imx_serial.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
hw/char/imx_serial.c +4 -1
@@ -80,7 +80,7 @@ static void imx_update(IMXSerialState *s)* TCEN and TXDC are both bit 3 * RDR and DREN are both bit 0 */ - mask |= s->ucr4 & (UCR4_TCEN |UCR4_DREN ); + mask |= s->ucr4 & (UCR4_WKEN |UCR4_TCEN |UCR4_DREN ); usr2 = s->usr2 & mask;
@@ -321,6 +321,9 @@ static void imx_put_data(void *opaque, uint32_t value)static void imx_receive (void *opaque,const uint8_t *buf,int size) { +IMXSerialState *s = (IMXSerialState *)opaque; + + s->usr2 |=USR2_WAKE ;imx_put_data (opaque, *buf); }
include/hw/char/imx_serial.h +1 -0
@@ -71,6 +71,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(IMXSerialState, IMX_SERIAL)#define UCR4_DREN BIT(0)/* Receive Data Ready interrupt enable */ #define UCR4_TCEN BIT(3)/* TX complete interrupt enable */ +#define UCR4_WKEN BIT(7)/* WAKE interrupt enable */ #define UTS1_TXEMPTY (1<<6)#define UTS1_RXEMPTY (1<<5)
Signature · 1 line
2.30.2
Quoted 1 line · Martin Kaiser
The linux kernel added a flood check for rx data recently in commmit
"Linux", "commit"
Also maybe s/rx/RX/ s/uart/UART/.
Quoted 12 lines
496a4471b7c3("serial: imx: work-around for hardware RX flood"). This check uses the wake bit in the uart status register 2. The wake bit indicates that the receiver detected a start bit on the rx line. If the kernel sees a number of rx interrupts without the wake bit being set, it treats this as spurious data and resets the uart port.imx_serialdoes never set the wake bit and triggers the kernel's flood check.This patch adds support for the wake bit. wake is set when we receive a new character (it's not set for break events). It seems that wake is cleared by the kernel driver, the hardware does not have to clear it automatically after data was read.
Quoted 4 lines
The wake bit can be configured as an interrupt source. Support this mechanism as well.
Co-developed-by Philippe Mathieu-Daudé <[email protected]>
Thanks ;)
Quoted 9 lines
Signed-off-by Martin Kaiser <[email protected]>---
v2:
- support interrupts from wake
- clean up the commit messagehw/char/imx_serial.c | 5 ++++- include/hw/char/imx_serial.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
PATCH v3 1/1 imx_serial: set wake bit when we receive a data byte
In reply to Martin KaiserThe Linux kernel added a flood check for RX data recently in commit 496a4471b7c3 ("serial: imx: work-around for hardware RX flood"). This check uses the wake bit in the UART status register 2. The wake bit indicates that the receiver detected a start bit on the RX line. If the kernel sees a number of RX interrupts without the wake bit being set, it treats this as spurious data and resets the UART port. imx_serial does never set the wake bit and triggers the kernel's flood check.
This patch adds support for the wake bit. wake is set when we receive a new character (it's not set for break events). It seems that wake is cleared by the kernel driver, the hardware does not have to clear it automatically after data was read.
The wake bit can be configured as an interrupt source. Support this mechanism as well.
---
v3:
- fix some spelling mistakes in the commit message
- add Philippe's Reviewed-by
v2:
- support interrupts from wake
- clean up the commit message
hw/char/imx_serial.c | 5 ++++- include/hw/char/imx_serial.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
hw/char/imx_serial.c +4 -1
@@ -80,7 +80,7 @@ static void imx_update(IMXSerialState *s)* TCEN and TXDC are both bit 3 * RDR and DREN are both bit 0 */ - mask |= s->ucr4 & (UCR4_TCEN |UCR4_DREN ); + mask |= s->ucr4 & (UCR4_WKEN |UCR4_TCEN |UCR4_DREN ); usr2 = s->usr2 & mask;
@@ -321,6 +321,9 @@ static void imx_put_data(void *opaque, uint32_t value)static void imx_receive (void *opaque,const uint8_t *buf,int size) { +IMXSerialState *s = (IMXSerialState *)opaque; + + s->usr2 |=USR2_WAKE ;imx_put_data (opaque, *buf); }
include/hw/char/imx_serial.h +1 -0
@@ -71,6 +71,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(IMXSerialState, IMX_SERIAL)#define UCR4_DREN BIT(0)/* Receive Data Ready interrupt enable */ #define UCR4_TCEN BIT(3)/* TX complete interrupt enable */ +#define UCR4_WKEN BIT(7)/* WAKE interrupt enable */ #define UTS1_TXEMPTY (1<<6)#define UTS1_RXEMPTY (1<<5)
Signature · 1 line
2.30.2
Peter Maydell
AppliedQuoted 14 lines · Martin Kaiser
The Linux kernel added a flood check for RX data recently in commit
496a4471b7c3("serial: imx: work-around for hardware RX flood"). This check uses the wake bit in the UART status register 2. The wake bit indicates that the receiver detected a start bit on the RX line. If the kernel sees a number of RX interrupts without the wake bit being set, it treats this as spurious data and resets the UART port.imx_serialdoes never set the wake bit and triggers the kernel's flood check.This patch adds support for the wake bit. wake is set when we receive a new character (it's not set for break events). It seems that wake is cleared by the kernel driver, the hardware does not have to clear it automatically after data was read.
Quoted 6 lines
The wake bit can be configured as an interrupt source. Support this mechanism as well.
Co-developed-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Martin Kaiser <[email protected]>
Applied to target-arm.next, thanks.
-- PMM
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Martin Kaiser
The Linux kernel added a flood check for RX data recently in commit
496a4471b7c3("serial: imx: work-around for hardware RX flood"). This check uses the wake bit in the UART status register 2. The wake bit indicates that the receiver detected a start bit on the RX line. If the kernel sees a number of RX interrupts without the wake bit being set, it treats this as spurious data and resets the UART port.imx_serialdoes never set the wake bit and triggers the kernel's flood check.This patch adds support for the wake bit. wake is set when we receive a new character (it's not set for break events). It seems that wake is cleared by the kernel driver, the hardware does not have to clear it automatically after data was read.
Quoted 4 lines
Quoted 4 lines
The wake bit can be configured as an interrupt source. Support this mechanism as well.
Co-developed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 8 lines
Quoted 2 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Martin Kaiser <[email protected]>Applied to target-arm.next, thanks.
-- PMM