All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: C Smith <csmithquestions@gmail.com>
Cc: Sumitabh Ghosh via Xenomai <xenomai@xenomai.org>
Subject: Re: rt_dev_send() stalls periodic task
Date: Thu, 18 Apr 2019 10:36:29 +0200	[thread overview]
Message-ID: <2ade719a-84c7-c53d-9895-a5e6eea354a3@siemens.com> (raw)
In-Reply-To: <CA+K1mPEvKLN+gyDPwLE0OovtSn-iQ_BBZ86zQf12Fv65Ht5KbQ@mail.gmail.com>

On 18.04.19 08:42, C Smith wrote:
> 
> 
> On Tue, Apr 16, 2019 at 1:03 AM Jan Kiszka <jan.kiszka@siemens.com 
> <mailto:jan.kiszka@siemens.com>> wrote:
> 
>      > The serial device is set up this way:
>      > struct rtser_config serial_config = {
>      >          .config_mask       = 0xFFFF,
>      >          .baud_rate         = 115200,
>      >          .parity            = RTSER_NO_PARITY,
>      >          .data_bits         = RTSER_8_BITS,
>      >          .stop_bits         = RTSER_1_STOPB,
>      >          .handshake         = RTSER_NO_HAND,
>      >          .fifo_depth        = RTSER_DEF_FIFO_DEPTH, //RTSER_FIFO_DEPTH_8,
>      >      .reserved          = 0,
>      >          .rx_timeout        = 500000,
>      >          .tx_timeout        = RTSER_DEF_TIMEOUT,
>      >          .event_timeout     = 5000000,
>      >          .timestamp_history = RTSER_RX_TIMESTAMP_HISTORY,
>      >          .event_mask        = RTSER_EVENT_RXPEND,
>      > };
>      > fd_tty[0] = rt_dev_open("rtser1", O_RDWR | O_NONBLOCK);
>      > sret = rt_dev_ioctl(fd_tty[0], RTSER_RTIOC_SET_CONFIG, &serial_config);
>      >
>      > The application transmits a packet of about 75 bytes repeatedly from a
>      > xenomai periodic task that wakes up at 125Hz repeatedly. Note that there is
>      > also a small RX serial packet arriving so there is some full-duplex
>      > overlap.  On rtser0 this works fine, on the other serial ports the stall
>      > happens after a few hours and my periodic xenomai task stops. There is no
>      > xenomai watchdog message in dmesg. The code is repeatedly checking the
>      > serial port status ioctl and there are no errors like framing errors etc.
>      >
>      > The periodic task is just a typical xenomai while() loop:
>      >    next += period_ns + adjust_ns;
>      >      rt_task_sleep_until(next);
>      >
>      > When my periodic task stops the kernel says the stack trace is:
>      > [root@oyx ~]# cd /proc/1066/task/1075/
>      > [root@oyx 1075]# cat stack
>      > [<c112d058>] xnpod_suspend_thread+0x3d8/0x650
>      > [<c1132f09>] xnsynch_sleep_on+0x139/0x320
>      > [<c11a7f14>] rtdm_event_timedwait+0x2e4/0x390
>      > [<e858ed3b>] rt_16550_write+0x35b/0x540 [xeno_16550A]
> 
>     This means the driver is stuck while writing because there are no more free
>     entries in the hardware TX FIFO. Do you have hardware flow control enabled? Are
>     you sure the that the receiving side is playing nicely?
>     Jan
> 
> 
> Well I'm not trying to use hardware flow control. Is hardware flow control the 
> xeno_16550A driver default?
> I am using a 3-wire serial cable, no RTS/CTS wires at all, they are floating.z
> 
> At present my app only ever calls the ioctl RTSER_RTIOC_SET_CONFIG as detailed 
> above.
> Are you saying I need to do an ioctl RTSER_RTIOC_SET_CONTROL and clear control 
> bit *RTSER_MCR_RTS*   ?
> 
> I have another Xenomai app which has been running fine as a 3-wire serial 
> connection for about 4 years,
> and it does not do an ioctl RTSER_RTIOC_SET_CONFIG either. Doesn't that mean 
> setting flow control is unnecessary?

The default handshake mode is

#define RTSER_DEF_HAND                  RTSER_NO_HAND

and your setting also does not change that. So that is not the reason. but we 
still see that the TX fifo does not get emptied at some point - or we miss the 
interrupt that informs us about this.

You could confirm that missed-interrupt theory by checking the line status 
register (RTSER_RTIOC_GET_STATUS -> RTSER_LSR_TRANSM_EMPTY) when TX got stuck.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


  reply	other threads:[~2019-04-18  8:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-15 17:28 rt_dev_send() stalls periodic task C Smith
2019-04-16  8:03 ` Jan Kiszka
2019-04-18  6:42   ` C Smith
2019-04-18  8:36     ` Jan Kiszka [this message]
2019-04-21  4:33       ` C Smith
2019-04-21 20:10         ` Steve Freyder
2019-04-22  6:40           ` C Smith
2019-04-22  6:45             ` Jan Kiszka
2019-04-22 19:51               ` Steve Freyder
2019-04-22 20:58                 ` Steve Freyder
2019-04-22 22:56                   ` C Smith
2019-04-22 23:44                     ` Steve Freyder
2019-04-23 12:15               ` Jan Kiszka
2019-04-24  6:53                 ` C Smith
2019-04-25  7:15                 ` C Smith
2019-04-25  8:23                   ` Jan Kiszka
2019-04-26  0:59                     ` C Smith
2019-04-26 16:38                       ` Jan Kiszka
2019-04-24 13:05 Jeff Webb
2019-04-24 14:36 ` Jan Kiszka
2019-04-26  0:41   ` Jeff Webb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ade719a-84c7-c53d-9895-a5e6eea354a3@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=csmithquestions@gmail.com \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.