From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH v2 5/5] serdev: Allow polling interval to be adjusted at runtime
Date: Thu, 12 Apr 2018 14:33:17 -0700 [thread overview]
Message-ID: <20180412213317.13199-6-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20180412213317.13199-1-andrew.smirnov@gmail.com>
Due to blocking, synchronous, polling driven nature of Barebox's
serial communication handling trying to use two or more serial ports
at high (1Mbaud+) baudrates results in data loss and noticeable
perofmance degradation. This happens as soon as individual message
being sent around start exceeding HW Rx FIFO in size.
A good example of such a usecase would be using a system that has a
serdev driver (operating @ 1Mbaud+) and trying to do a X/YMODEM
transfer via serial console at comparable baudrates.
To at least partially ameliorate the problem, add code that will
expose "polling_interval" as a parameter, so that the user would have
an option of temporarily disabling (or significatly decreasing the
rate) of a given serdev's polling.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
common/serdev.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/common/serdev.c b/common/serdev.c
index 50eadc804..4a6dbefe6 100644
--- a/common/serdev.c
+++ b/common/serdev.c
@@ -34,12 +34,26 @@ static void serdev_device_poller(void *context)
serdev->polling_interval,
serdev_device_poller,
serdev);
+ } else {
+ poller_async_cancel(&serdev->poller);
}
}
+static int serdev_device_set_polling_interval(struct param_d *param, void *serdev)
+{
+ /*
+ * We execute poller ever time polling_interval changes to get
+ * any unprocessed immediate Rx data as well as to propagate
+ * polling_interval chagnes to outstanging async pollers.
+ */
+ serdev_device_poller(serdev);
+ return 0;
+}
+
int serdev_device_open(struct serdev_device *serdev)
{
struct console_device *cdev = to_console_device(serdev);
+ struct param_d *p;
int ret;
if (!cdev->putc || !cdev->getc)
@@ -57,7 +71,17 @@ int serdev_device_open(struct serdev_device *serdev)
if (ret)
return ret;
- return console_open(cdev);
+ ret = console_open(cdev);
+ if (ret)
+ return ret;
+
+ p = dev_add_param_uint64(serdev->dev, "polling_interval",
+ serdev_device_set_polling_interval, NULL,
+ &serdev->polling_interval, "%llu", serdev);
+ if (IS_ERR(p))
+ return PTR_ERR(p);
+
+ return 0;
}
unsigned int serdev_device_set_baudrate(struct serdev_device *serdev,
--
2.14.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-04-12 21:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-12 21:33 [PATCH v2 0/5] Linux's serdev framwork port Andrey Smirnov
2018-04-12 21:33 ` [PATCH v2 1/5] console: Introduce console_drain() Andrey Smirnov
2018-04-12 21:33 ` [PATCH v2 2/5] console: Add simplified 'serdev' framework from Linux kernel Andrey Smirnov
2018-04-12 21:33 ` [PATCH v2 3/5] serdev: Add trivial blocking read function Andrey Smirnov
2018-04-12 21:33 ` [PATCH v2 4/5] serial: Drop .remove functions from all drivers Andrey Smirnov
2018-04-12 21:33 ` Andrey Smirnov [this message]
2018-04-16 7:00 ` [PATCH v2 0/5] Linux's serdev framwork port Sascha Hauer
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=20180412213317.13199-6-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox