* [Xenomai-core] [patch] serial driver fixes/improvements
@ 2005-10-27 11:05 Jan Kiszka
2005-10-27 11:49 ` Philippe Gerum
2005-10-28 22:34 ` Hannes Mayer
0 siblings, 2 replies; 6+ messages in thread
From: Jan Kiszka @ 2005-10-27 11:05 UTC (permalink / raw)
To: xenomai-core
[-- Attachment #1.1: Type: text/plain, Size: 898 bytes --]
Hi,
this patch improves the behaviour of xeno_16550A on
RTSER_RTIOC_EVENT_WAIT. In case it is invoked from non-RT, the driver
tries to trigger an automatic switch-back to RT via returning ENOSYS.
The patch also fixes another remaining issue about the right context
when calling RTSER_RTIOC_SET_CONFIG (forgot the corner case of releasing
the RX history buffer in RT).
Note that I intentionally did not apply the EPERM->ENOSYS scheme on
RTSER_RTIOC_SET_CONFIG. Here a switch to non-RT might be required if the
device was opened in non-RT and a reconfigure request regarding the RX
history buffer is now issued in RT. I think it's better to let the user
decide via a preceding explicit switch to non-RT if leaving RT is really
correct.
The patch furthermore contains a README describing the device setup. I
hope I addressed potential questions and problems sufficiently, feedback
is welcome.
Jan
[-- Attachment #1.2: 16550A-1.1.2.patch --]
[-- Type: text/plain, Size: 4095 bytes --]
Index: drivers/16550A/Kconfig
===================================================================
--- drivers/16550A/Kconfig (revision 73)
+++ drivers/16550A/Kconfig (working copy)
@@ -3,4 +3,5 @@
bool "16550A UART driver"
default n
help
- Real-time UART driver for 16550A compatible controllers.
+ Real-time UART driver for 16550A compatible controllers. See
+ drivers/16550A/README for more details.
Index: drivers/16550A/16550A.c
===================================================================
--- drivers/16550A/16550A.c (revision 73)
+++ drivers/16550A/16550A.c (working copy)
@@ -556,18 +556,24 @@
config = &config_buf;
}
- if (testbits(config->config_mask, RTSER_SET_TIMESTAMP_HISTORY) &&
- testbits(config->timestamp_history,
- RTSER_RX_TIMESTAMP_HISTORY)) {
- if (test_bit(RTDM_CREATED_IN_NRT, &context->context_flags)) {
- if (rtdm_in_rt_context())
- return -EPERM;
+ if (testbits(config->config_mask, RTSER_SET_TIMESTAMP_HISTORY)) {
+ if (test_bit(RTDM_CREATED_IN_NRT, &context->context_flags) &&
+ rtdm_in_rt_context()) {
+ /* already fail if we MAY allocate or release a non-RT
+ * buffer in RT context */
+ return -EPERM;
+ }
- hist_buf = kmalloc(IN_BUFFER_SIZE * sizeof(__u64),
- GFP_KERNEL);
- } else
- hist_buf =
- rtdm_malloc(IN_BUFFER_SIZE * sizeof(__u64));
+ if (testbits(config->timestamp_history,
+ RTSER_RX_TIMESTAMP_HISTORY)) {
+ if (test_bit(RTDM_CREATED_IN_NRT,
+ &context->context_flags))
+ hist_buf = kmalloc(IN_BUFFER_SIZE * sizeof(__u64),
+ GFP_KERNEL);
+ else
+ hist_buf =
+ rtdm_malloc(IN_BUFFER_SIZE * sizeof(__u64));
+ }
if (!hist_buf)
return -ENOMEM;
@@ -643,7 +649,7 @@
rtdm_toseq_t timeout_seq;
if (!rtdm_in_rt_context())
- return -EPERM;
+ return -ENOSYS;
/* only one waiter allowed, stop any further attempts here */
if (test_and_set_bit(0, &ctx->ioc_event_lock))
@@ -1005,7 +1011,7 @@
device_class: RTDM_CLASS_SERIAL,
device_sub_class: RTDM_SUBCLASS_16550A,
driver_name: "rt_16550A",
- driver_version: RTDM_DRIVER_VER(1, 1, 1),
+ driver_version: RTDM_DRIVER_VER(1, 1, 2),
peripheral_name: "UART 16550A",
provider_name: "Jan Kiszka",
};
Index: drivers/16550A/README
===================================================================
--- drivers/16550A/README (revision 0)
+++ drivers/16550A/README (revision 0)
@@ -0,0 +1,34 @@
+Real-Time Serial Driver for 16550A-Compatible Devices
+=====================================================
+
+Preparation
+-----------
+ - decide which serial ports are to be managed by the real-time driver
+
+ - identify their I/O addresses and IRQ numbers:
+
+ setserial /dev/ttyS<N>
+
+ - disable the Linux driver for all these devices:
+
+ setserial /dev/ttyS<N> uart none
+
+
+Invocation
+----------
+
+modprobe xeno_16550A ioaddr=<io1>[,<io2>...] irq=<irq1>[,<irq2>...]
+ [tx_fifo=<len1>[,<len2>...]] [start_index=<index>]
+
+Arguments:
+ ioaddr<N> - I/O address of device <N> (e.g. 0x3f8 for ttyS0)
+ irq<N> - interrupt number of device <N> (e.g. 4 for ttyS0)
+ tx_fifo<N> - Transmitter FIFO size in bytes of device <N>, default is 16
+ start_index - First device instance number to be used, default is 0
+
+
+Usage
+-----
+
+The API is described in the API documentation under Modules -> Real-Time
+Driver Model -> Device Profiles -> Serial Devices.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 254 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-core] [patch] serial driver fixes/improvements
2005-10-27 11:05 [Xenomai-core] [patch] serial driver fixes/improvements Jan Kiszka
@ 2005-10-27 11:49 ` Philippe Gerum
2005-10-28 22:34 ` Hannes Mayer
1 sibling, 0 replies; 6+ messages in thread
From: Philippe Gerum @ 2005-10-27 11:49 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai-core
Jan Kiszka wrote:
> Hi,
>
> this patch improves the behaviour of xeno_16550A on
> RTSER_RTIOC_EVENT_WAIT. In case it is invoked from non-RT, the driver
> tries to trigger an automatic switch-back to RT via returning ENOSYS.
> The patch also fixes another remaining issue about the right context
> when calling RTSER_RTIOC_SET_CONFIG (forgot the corner case of releasing
> the RX history buffer in RT).
>
> Note that I intentionally did not apply the EPERM->ENOSYS scheme on
> RTSER_RTIOC_SET_CONFIG. Here a switch to non-RT might be required if the
> device was opened in non-RT and a reconfigure request regarding the RX
> history buffer is now issued in RT. I think it's better to let the user
> decide via a preceding explicit switch to non-RT if leaving RT is really
> correct.
Applied, thanks.
>
> The patch furthermore contains a README describing the device setup. I
> hope I addressed potential questions and problems sufficiently, feedback
> is welcome.
>
> Jan
>
>
> ------------------------------------------------------------------------
>
> Index: drivers/16550A/Kconfig
> ===================================================================
> --- drivers/16550A/Kconfig (revision 73)
> +++ drivers/16550A/Kconfig (working copy)
> @@ -3,4 +3,5 @@
> bool "16550A UART driver"
> default n
> help
> - Real-time UART driver for 16550A compatible controllers.
> + Real-time UART driver for 16550A compatible controllers. See
> + drivers/16550A/README for more details.
> Index: drivers/16550A/16550A.c
> ===================================================================
> --- drivers/16550A/16550A.c (revision 73)
> +++ drivers/16550A/16550A.c (working copy)
> @@ -556,18 +556,24 @@
> config = &config_buf;
> }
>
> - if (testbits(config->config_mask, RTSER_SET_TIMESTAMP_HISTORY) &&
> - testbits(config->timestamp_history,
> - RTSER_RX_TIMESTAMP_HISTORY)) {
> - if (test_bit(RTDM_CREATED_IN_NRT, &context->context_flags)) {
> - if (rtdm_in_rt_context())
> - return -EPERM;
> + if (testbits(config->config_mask, RTSER_SET_TIMESTAMP_HISTORY)) {
> + if (test_bit(RTDM_CREATED_IN_NRT, &context->context_flags) &&
> + rtdm_in_rt_context()) {
> + /* already fail if we MAY allocate or release a non-RT
> + * buffer in RT context */
> + return -EPERM;
> + }
>
> - hist_buf = kmalloc(IN_BUFFER_SIZE * sizeof(__u64),
> - GFP_KERNEL);
> - } else
> - hist_buf =
> - rtdm_malloc(IN_BUFFER_SIZE * sizeof(__u64));
> + if (testbits(config->timestamp_history,
> + RTSER_RX_TIMESTAMP_HISTORY)) {
> + if (test_bit(RTDM_CREATED_IN_NRT,
> + &context->context_flags))
> + hist_buf = kmalloc(IN_BUFFER_SIZE * sizeof(__u64),
> + GFP_KERNEL);
> + else
> + hist_buf =
> + rtdm_malloc(IN_BUFFER_SIZE * sizeof(__u64));
> + }
>
> if (!hist_buf)
> return -ENOMEM;
> @@ -643,7 +649,7 @@
> rtdm_toseq_t timeout_seq;
>
> if (!rtdm_in_rt_context())
> - return -EPERM;
> + return -ENOSYS;
>
> /* only one waiter allowed, stop any further attempts here */
> if (test_and_set_bit(0, &ctx->ioc_event_lock))
> @@ -1005,7 +1011,7 @@
> device_class: RTDM_CLASS_SERIAL,
> device_sub_class: RTDM_SUBCLASS_16550A,
> driver_name: "rt_16550A",
> - driver_version: RTDM_DRIVER_VER(1, 1, 1),
> + driver_version: RTDM_DRIVER_VER(1, 1, 2),
> peripheral_name: "UART 16550A",
> provider_name: "Jan Kiszka",
> };
> Index: drivers/16550A/README
> ===================================================================
> --- drivers/16550A/README (revision 0)
> +++ drivers/16550A/README (revision 0)
> @@ -0,0 +1,34 @@
> +Real-Time Serial Driver for 16550A-Compatible Devices
> +=====================================================
> +
> +Preparation
> +-----------
> + - decide which serial ports are to be managed by the real-time driver
> +
> + - identify their I/O addresses and IRQ numbers:
> +
> + setserial /dev/ttyS<N>
> +
> + - disable the Linux driver for all these devices:
> +
> + setserial /dev/ttyS<N> uart none
> +
> +
> +Invocation
> +----------
> +
> +modprobe xeno_16550A ioaddr=<io1>[,<io2>...] irq=<irq1>[,<irq2>...]
> + [tx_fifo=<len1>[,<len2>...]] [start_index=<index>]
> +
> +Arguments:
> + ioaddr<N> - I/O address of device <N> (e.g. 0x3f8 for ttyS0)
> + irq<N> - interrupt number of device <N> (e.g. 4 for ttyS0)
> + tx_fifo<N> - Transmitter FIFO size in bytes of device <N>, default is 16
> + start_index - First device instance number to be used, default is 0
> +
> +
> +Usage
> +-----
> +
> +The API is described in the API documentation under Modules -> Real-Time
> +Driver Model -> Device Profiles -> Serial Devices.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Xenomai-core mailing list
> Xenomai-core@domain.hid
> https://mail.gna.org/listinfo/xenomai-core
--
Philippe.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-core] [patch] serial driver fixes/improvements
2005-10-27 11:05 [Xenomai-core] [patch] serial driver fixes/improvements Jan Kiszka
2005-10-27 11:49 ` Philippe Gerum
@ 2005-10-28 22:34 ` Hannes Mayer
2005-10-29 1:16 ` Jan Kiszka
1 sibling, 1 reply; 6+ messages in thread
From: Hannes Mayer @ 2005-10-28 22:34 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai-core
Hi Jan et al.!
Jan Kiszka wrote:
[...]
> +modprobe xeno_16550A ioaddr=<io1>[,<io2>...] irq=<irq1>[,<irq2>...]
> + [tx_fifo=<len1>[,<len2>...]] [start_index=<index>]
> +
> +Arguments:
> + ioaddr<N> - I/O address of device <N> (e.g. 0x3f8 for ttyS0)
> + irq<N> - interrupt number of device <N> (e.g. 4 for ttyS0)
> + tx_fifo<N> - Transmitter FIFO size in bytes of device <N>, default is 16
> + start_index - First device instance number to be used, default is 0
If I may throw in my 2 eurocents:
I think the Arguments-section is a bit misleading.
One doesn't specify ioaddr1, ioaddr2 etc. on the command line, as suggested
by ioaddr<N>, but ioaddr=[1.dev],[2.dev]...
Same for irq and tx_fifo.
What about this:
Arguments:
ioaddr - I/O addresses of devices (e.g. 0x3f8 for ttyS0), separated by comma
irq - interrupt numbers of devices (e.g. 4 for ttyS0), separated by comma
tx_fifo - Transmitter FIFO sizes in bytes of devices, default is 16, separated by comma
start_index - First device instance number to be used, default is 0 => rtser0
Just trying to make it as clear as possible :-)
Best regards,
Hannes.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-core] [patch] serial driver fixes/improvements
2005-10-28 22:34 ` Hannes Mayer
@ 2005-10-29 1:16 ` Jan Kiszka
2005-10-29 8:24 ` Jan Kiszka
0 siblings, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2005-10-29 1:16 UTC (permalink / raw)
To: Hannes Mayer; +Cc: xenomai-core
[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]
Hannes Mayer wrote:
> Hi Jan et al.!
>
> Jan Kiszka wrote:
> [...]
>
>> +modprobe xeno_16550A ioaddr=<io1>[,<io2>...] irq=<irq1>[,<irq2>...]
>> + [tx_fifo=<len1>[,<len2>...]] [start_index=<index>]
>> +
>> +Arguments:
>> + ioaddr<N> - I/O address of device <N> (e.g. 0x3f8 for ttyS0)
>> + irq<N> - interrupt number of device <N> (e.g. 4 for ttyS0)
>> + tx_fifo<N> - Transmitter FIFO size in bytes of device <N>,
>> default is 16
>> + start_index - First device instance number to be used, default is 0
>
>
> If I may throw in my 2 eurocents:
> I think the Arguments-section is a bit misleading.
> One doesn't specify ioaddr1, ioaddr2 etc. on the command line, as suggested
> by ioaddr<N>, but ioaddr=[1.dev],[2.dev]...
> Same for irq and tx_fifo.
>
> What about this:
>
> Arguments:
> ioaddr - I/O addresses of devices (e.g. 0x3f8 for ttyS0),
> separated by comma
> irq - interrupt numbers of devices (e.g. 4 for ttyS0),
> separated by comma
> tx_fifo - Transmitter FIFO sizes in bytes of devices, default is
> 16, separated by comma
> start_index - First device instance number to be used, default is 0
> => rtser0
>
> Just trying to make it as clear as possible :-)
>
Indeed, my version is misleading, your version makes more sense. Just
the parameter for ttyS0 are not necessarily the one you listed, only
typically. Will post a patch.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-core] [patch] serial driver fixes/improvements
2005-10-29 1:16 ` Jan Kiszka
@ 2005-10-29 8:24 ` Jan Kiszka
2005-10-29 21:10 ` Hannes Mayer
0 siblings, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2005-10-29 8:24 UTC (permalink / raw)
To: Hannes Mayer; +Cc: xenomai-core
[-- Attachment #1: Type: text/plain, Size: 1642 bytes --]
Jan Kiszka wrote:
> Hannes Mayer wrote:
>
>>Hi Jan et al.!
>>
>>Jan Kiszka wrote:
>>[...]
>>
>>
>>>+modprobe xeno_16550A ioaddr=<io1>[,<io2>...] irq=<irq1>[,<irq2>...]
>>>+ [tx_fifo=<len1>[,<len2>...]] [start_index=<index>]
>>>+
>>>+Arguments:
>>>+ ioaddr<N> - I/O address of device <N> (e.g. 0x3f8 for ttyS0)
>>>+ irq<N> - interrupt number of device <N> (e.g. 4 for ttyS0)
>>>+ tx_fifo<N> - Transmitter FIFO size in bytes of device <N>,
>>>default is 16
>>>+ start_index - First device instance number to be used, default is 0
>>
>>
>>If I may throw in my 2 eurocents:
>>I think the Arguments-section is a bit misleading.
>>One doesn't specify ioaddr1, ioaddr2 etc. on the command line, as suggested
>>by ioaddr<N>, but ioaddr=[1.dev],[2.dev]...
>>Same for irq and tx_fifo.
>>
>>What about this:
>>
>>Arguments:
>> ioaddr - I/O addresses of devices (e.g. 0x3f8 for ttyS0),
>>separated by comma
>> irq - interrupt numbers of devices (e.g. 4 for ttyS0),
>>separated by comma
>> tx_fifo - Transmitter FIFO sizes in bytes of devices, default is
>>16, separated by comma
>> start_index - First device instance number to be used, default is 0
>>=> rtser0
>>
>>Just trying to make it as clear as possible :-)
>>
>
>
> Indeed, my version is misleading, your version makes more sense. Just
> the parameter for ttyS0 are not necessarily the one you listed, only
Oops, actually I originally sorted ttyS0 to 0x3f8, not you. As I said:
don't trust anything I produce between 3 and 5 am...
> typically. Will post a patch.
>
Patch posted, feel free to comment again!
Thanks,
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-core] [patch] serial driver fixes/improvements
2005-10-29 8:24 ` Jan Kiszka
@ 2005-10-29 21:10 ` Hannes Mayer
0 siblings, 0 replies; 6+ messages in thread
From: Hannes Mayer @ 2005-10-29 21:10 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai-core
Hi Jan!
Jan Kiszka wrote:
[...]
> Oops, actually I originally sorted ttyS0 to 0x3f8, not you. As I said:
> don't trust anything I produce between 3 and 5 am...
Well, as long as it is just documentation ;-)
I've never worked on other arch's than i386 with RTAI, so you are the
expert here to make it as general as possible.
Thanks again! Meanwhile my Xeno serial prog. is happily talking to the
ATmega16 :-)
Best regards,
Hannes.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-10-29 21:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-27 11:05 [Xenomai-core] [patch] serial driver fixes/improvements Jan Kiszka
2005-10-27 11:49 ` Philippe Gerum
2005-10-28 22:34 ` Hannes Mayer
2005-10-29 1:16 ` Jan Kiszka
2005-10-29 8:24 ` Jan Kiszka
2005-10-29 21:10 ` Hannes Mayer
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.