diff mbox

imx_serial: Generate interrupt on tx empty if enabled

Message ID 1440085955-27951-1-git-send-email-linux@roeck-us.net
State New
Headers show

Commit Message

Guenter Roeck Aug. 20, 2015, 3:52 p.m. UTC
Generate an interrupt if the tx buffer is empty and the tx empty interrupt
is enabled. This fixes a problem seen when running a Linux image since
Linux commit 55c3cb1358e ("serial: imx: remove unneeded imx_transmit_buffer()
from imx_start_tx()"). Linux now waits for the tx empty interrupt before
starting to send data, causing transmit stalls until there is an interrupt
for another reason.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 hw/char/imx_serial.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Michael Tokarev Sept. 11, 2015, 7:37 a.m. UTC | #1
Can we please have some r-b or ACK for this? :)

20.08.2015 18:52, Guenter Roeck wrote:
> Generate an interrupt if the tx buffer is empty and the tx empty interrupt
> is enabled. This fixes a problem seen when running a Linux image since
> Linux commit 55c3cb1358e ("serial: imx: remove unneeded imx_transmit_buffer()
> from imx_start_tx()"). Linux now waits for the tx empty interrupt before
> starting to send data, causing transmit stalls until there is an interrupt
> for another reason.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  hw/char/imx_serial.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
> index f3fbc77..8dc791d 100644
> --- a/hw/char/imx_serial.c
> +++ b/hw/char/imx_serial.c
> @@ -145,7 +145,9 @@ static void imx_update(IMXSerialState *s)
>      uint32_t flags;
>  
>      flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY);
> -    if (!(s->ucr1 & UCR1_TXMPTYEN)) {
> +    if (s->ucr1 & UCR1_TXMPTYEN) {
> +        flags |= (s->uts1 & UTS1_TXEMPTY);
> +    } else {
>          flags &= ~USR1_TRDY;
>      }
>  
>
Peter Crosthwaite Sept. 13, 2015, 8:17 p.m. UTC | #2
On Fri, Sep 11, 2015 at 12:37 AM, Michael Tokarev <mjt@tls.msk.ru> wrote:
>
> Can we please have some r-b or ACK for this? :)
>
> 20.08.2015 18:52, Guenter Roeck wrote:
>> Generate an interrupt if the tx buffer is empty and the tx empty interrupt
>> is enabled. This fixes a problem seen when running a Linux image since
>> Linux commit 55c3cb1358e ("serial: imx: remove unneeded imx_transmit_buffer()
>> from imx_start_tx()"). Linux now waits for the tx empty interrupt before
>> starting to send data, causing transmit stalls until there is an interrupt
>> for another reason.
>>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>


Looks right, Jean-Christophe may know more though.

Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>

>> ---
>>  hw/char/imx_serial.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
>> index f3fbc77..8dc791d 100644
>> --- a/hw/char/imx_serial.c
>> +++ b/hw/char/imx_serial.c
>> @@ -145,7 +145,9 @@ static void imx_update(IMXSerialState *s)
>>      uint32_t flags;
>>
>>      flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY);
>> -    if (!(s->ucr1 & UCR1_TXMPTYEN)) {
>> +    if (s->ucr1 & UCR1_TXMPTYEN) {
>> +        flags |= (s->uts1 & UTS1_TXEMPTY);
>> +    } else {
>>          flags &= ~USR1_TRDY;

Out of scope, but this conditional looks wrong (in original code too).
Why does TXMPTYEN gate TRDY?

Regards,
Peter

>>      }
>>
>>
>
>
Michael Tokarev Sept. 16, 2015, 10:28 a.m. UTC | #3
13.09.2015 23:17, Peter Crosthwaite wrote:
> On Fri, Sep 11, 2015 at 12:37 AM, Michael Tokarev <mjt@tls.msk.ru> wrote:
>>
>> Can we please have some r-b or ACK for this? :)
>>
>> 20.08.2015 18:52, Guenter Roeck wrote:
>>> Generate an interrupt if the tx buffer is empty and the tx empty interrupt
>>> is enabled. This fixes a problem seen when running a Linux image since
>>> Linux commit 55c3cb1358e ("serial: imx: remove unneeded imx_transmit_buffer()
>>> from imx_start_tx()"). Linux now waits for the tx empty interrupt before
>>> starting to send data, causing transmit stalls until there is an interrupt
>>> for another reason.
>>>
>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> 
> Looks right, Jean-Christophe may know more though.

Thanks, applied to the trivial-patches tree :)

/mjt
diff mbox

Patch

diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
index f3fbc77..8dc791d 100644
--- a/hw/char/imx_serial.c
+++ b/hw/char/imx_serial.c
@@ -145,7 +145,9 @@  static void imx_update(IMXSerialState *s)
     uint32_t flags;
 
     flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY);
-    if (!(s->ucr1 & UCR1_TXMPTYEN)) {
+    if (s->ucr1 & UCR1_TXMPTYEN) {
+        flags |= (s->uts1 & UTS1_TXEMPTY);
+    } else {
         flags &= ~USR1_TRDY;
     }