serial: imx-serial - move DMA buffer configuration to DT
Hello,
Quoted 8 lines · Romain Perier
From: Nandor Han <[email protected]>
The size of the DMA buffer can affect the delta time between data being produced and data being consumed. Basically the DMA system will move data to tty buffer when a) DMA buffer is full b) serial line is idle. The situation is visible when producer generates data continuously and there is no possibility for idle line. At this point the DMA buffer is directly affecting the delta time.
This doesn't look like a hw property but a configuration item. Also I don't understand the problematic case. The i.MX is sending continuously and then doesn't receive bytes until the DMA buffer is full? What is the DMA buffer? You don't mean the FIFO here, do you?
That doesn't sound like a good fix but more like a work around. Which other options did you test to fix your problem?
Quoted 18 lines
The patch will add the possibility to configure the DMA buffers in DT, which case by case can be configured separately for every driver instance. The DT configuration is optional and in case missing the driver will use the 4096 buffer with 4 periods (as before), therefore no clients are impacted by this change.
Signed-off-by Nandor Han <[email protected]>Signed-off-by Romain Perier <romain.perier-ZGY8ohtN/[email protected]>--- .../devicetree/bindings/serial/fsl-imx-uart.txt | 2 ++ drivers/tty/serial/imx.c | 25 +++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-)Documentation/devicetree/bindings/serial/fsl-imx-uart.txt +0
-0
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt Optional properties: · line 12
Quoted 4 lines
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt +1
-0@@ -9,6 +9,7 @@ Optional properties: - fsl,irda-mode : Indicate the uart supports irda mode - fsl,dte-mode : Indicate the uart works in DTE mode. The uart works in DCE mode by default. +- fsl,dma-size : Indicate the size of the DMA buffer and its periods
This is a sparse description, just from reading that I don't understand what it does.
Quoted 13 lines
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt +1
-0Please check Documentation/devicetree/bindings/serial/serial.txt for the complete list of generic properties.@@ -28,4 +29,5 @@ uart1: serial@73fbc000 { interrupts = <31>; uart-has-rtscts; fsl,dte-mode; + fsl,dma-size = <1024 4>; };drivers/tty/serial/imx.c +0
-0
drivers/tty/serial/imx.c line 191
Quoted 6 lines
drivers/tty/serial/imx.c +3
-0@@ -186,6 +186,11 @@#define UART_NR 8 +/* RX DMA buffer periods */ +#define RX_DMA_PERIODS 4 +#define RX_BUF_SIZE (PAGE_SIZE)
These names should include "DEFAULT" in their name now to fit their new semantic.
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello Greg,
I'm a bit disappointed that you didn't drop this patch. At the time I sent my review it was still in your tty-testing branch and now it's part of your pull request for 4.13-rc1 (as commit a3015affdf76ef279fbbb3710a220bab7e9ea04b). :-|
I'm still convinced that this patch is wrong in its current form.
Best regards
Uwe
Quoted 68 lines · Uwe Kleine-König
Cc += [email protected]Quoted 8 lines · Romain Perier
From: Nandor Han <[email protected]>
The size of the DMA buffer can affect the delta time between data being produced and data being consumed. Basically the DMA system will move data to tty buffer when a) DMA buffer is full b) serial line is idle. The situation is visible when producer generates data continuously and there is no possibility for idle line. At this point the DMA buffer is directly affecting the delta time.
This doesn't look like a hw property but a configuration item. Also I don't understand the problematic case. The i.MX is sending continuously and then doesn't receive bytes until the DMA buffer is full? What is the DMA buffer? You don't mean the FIFO here, do you?
That doesn't sound like a good fix but more like a work around. Which other options did you test to fix your problem?
Quoted 18 lines
The patch will add the possibility to configure the DMA buffers in DT, which case by case can be configured separately for every driver instance. The DT configuration is optional and in case missing the driver will use the 4096 buffer with 4 periods (as before), therefore no clients are impacted by this change.
Signed-off-by Nandor Han <[email protected]>Signed-off-by Romain Perier <romain.perier-ZGY8ohtN/[email protected]>--- .../devicetree/bindings/serial/fsl-imx-uart.txt | 2 ++ drivers/tty/serial/imx.c | 25 +++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-)Documentation/devicetree/bindings/serial/fsl-imx-uart.txt +0
-0Documentation/devicetree/bindings/serial/fsl-imx-uart.txt Optional properties: · line 12
Quoted 4 lines
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt +1
-0@@ -9,6 +9,7 @@ Optional properties: - fsl,irda-mode : Indicate the uart supports irda mode - fsl,dte-mode : Indicate the uart works in DTE mode. The uart works in DCE mode by default. +- fsl,dma-size : Indicate the size of the DMA buffer and its periodsThis is a sparse description, just from reading that I don't understand what it does.
Quoted 13 lines
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt +1
-0Please check Documentation/devicetree/bindings/serial/serial.txt for the complete list of generic properties.@@ -28,4 +29,5 @@ uart1: serial@73fbc000 { interrupts = <31>; uart-has-rtscts; fsl,dte-mode; + fsl,dma-size = <1024 4>; };drivers/tty/serial/imx.c +0
-0drivers/tty/serial/imx.c line 191
Quoted 6 lines
drivers/tty/serial/imx.c +3
-0@@ -186,6 +186,11 @@#define UART_NR 8 +/* RX DMA buffer periods */ +#define RX_DMA_PERIODS 4 +#define RX_BUF_SIZE (PAGE_SIZE)These names should include "DEFAULT" in their name now to fit their new semantic.
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello,
Quoted 7 lines · Uwe Kleine-König
Hello Greg,
I'm a bit disappointed that you didn't drop this patch. At the time I sent my review it was still in your tty-testing branch and now it's part of your pull request for 4.13-rc1 (as commit
a3015affdf76ef279fbbb3710a220bab7e9ea04b). :-|
Quoted 21 lines
I'm still convinced that this patch is wrong in its current form.
Best regards
UweQuoted 15 lines · Uwe Kleine-König
Cc += [email protected]Quoted 8 lines · Romain Perier
From: Nandor Han <[email protected]>
The size of the DMA buffer can affect the delta time between data being produced and data being consumed. Basically the DMA system will move data to tty buffer when a) DMA buffer is full b) serial line is idle. The situation is visible when producer generates data continuously and there is no possibility for idle line. At this point the DMA buffer is directly affecting the delta time.
This doesn't look like a hw property but a configuration item. Also I don't understand the problematic case. The i.MX is sending continuously and then doesn't receive bytes until the DMA buffer is full? What is the DMA buffer? You don't mean the FIFO here, do you?
by DMA buffer, I mean the size of the RX FIFO. Data will be moved to tty when the FIFO
is full or the serial line is idle. Now suppose you have an important work load and the serial line is never idle,
with the current size of the DMA buffer (PAGE_SIZE) you might introduce latencies between data being produced and data being consumed.
We could also modify dma_rx_callback(), but this current solution is less intrusive, imho.
Regards,
Romain
Quoted 39 lines
Quoted 39 lines
Quoted 18 lines
The patch will add the possibility to configure the DMA buffers in DT, which case by case can be configured separately for every driver instance. The DT configuration is optional and in case missing the driver will use the 4096 buffer with 4 periods (as before), therefore no clients are impacted by this change.
Signed-off-by Nandor Han <[email protected]>Signed-off-by Romain Perier <romain.perier-ZGY8ohtN/[email protected]>--- .../devicetree/bindings/serial/fsl-imx-uart.txt | 2 ++ drivers/tty/serial/imx.c | 25 +++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-)Documentation/devicetree/bindings/serial/fsl-imx-uart.txt +0
-0Documentation/devicetree/bindings/serial/fsl-imx-uart.txt Optional properties: · line 12
Quoted 4 lines
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt +1
-0@@ -9,6 +9,7 @@ Optional properties: - fsl,irda-mode : Indicate the uart supports irda mode - fsl,dte-mode : Indicate the uart works in DTE mode. The uart works in DCE mode by default. +- fsl,dma-size : Indicate the size of the DMA buffer and its periodsThis is a sparse description, just from reading that I don't understand what it does.
Quoted 14 lines
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt +1
-0Please check Documentation/devicetree/bindings/serial/serial.txt for the complete list of generic properties.@@ -28,4 +29,5 @@ uart1: serial@73fbc000 { interrupts = <31>; uart-has-rtscts; fsl,dte-mode; + fsl,dma-size = <1024 4>; };drivers/tty/serial/imx.c +0
-0@@ -186,6 +186,11 @@
Quoted 7 lines
Quoted 7 lines
drivers/tty/serial/imx.c line 191
Quoted 5 lines
drivers/tty/serial/imx.c +3
-0#define UART_NR 8 +/* RX DMA buffer periods */ +#define RX_DMA_PERIODS 4 +#define RX_BUF_SIZE (PAGE_SIZE)These names should include "DEFAULT" in their name now to fit their new semantic.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Uwe Kleine-König
Hello Greg,
Please don't top-post :(
Quoted 4 lines
I'm a bit disappointed that you didn't drop this patch. At the time I sent my review it was still in your tty-testing branch and now it's part of your pull request for 4.13-rc1 (as commit
a3015affdf76ef279fbbb3710a220bab7e9ea04b). :-|
And now it's in Linus's tree! :)
Quoted 1 line
I'm still convinced that this patch is wrong in its current form.
Should I revert it, or can I get a fix for it? Reviewing the patch when it was submitted would have been best, not after it ends up in one of my trees...
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · Greg Kroah-Hartman
Quoted 1 line · Uwe Kleine-König
Hello Greg,
Please don't top-post :(
I only kept the mail for reference, as I didn't reply to specific stuff in the mail I consider writing my stuff at the top of the mail ok (and even better than below the mail because you don't need to scroll down to see what I wrote and I think I gave enough context).
Quoted 6 lines
Quoted 4 lines
I'm a bit disappointed that you didn't drop this patch. At the time I sent my review it was still in your tty-testing branch and now it's part of your pull request for 4.13-rc1 (as commit
a3015affdf76ef279fbbb3710a220bab7e9ea04b). :-|And now it's in Linus's tree! :)
Should I better answer to the pull request mail next time?
Quoted 3 lines
Quoted 1 line
I'm still convinced that this patch is wrong in its current form.
Should I revert it, or can I get a fix for it?
I'd say revert for now. At least it's not clear to me how it should be fixed as the property added to dt shouldn't be there (given my current understanding of the problem).
Quoted 2 lines
Reviewing the patch when it was submitted would have been best, not after it ends up in one of my trees...
Well, I reviewed in less than 24h. I now that Linux development is quick, but please don't make it that quick.
Otherwise I might consider a procmail rule that sends a "please don't apply yet" mail until I come around looking at imx-uart patches. :-)
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello,
Quoted 8 lines · Greg Kroah-Hartman
Quoted 1 line · Uwe Kleine-König
Hello Greg,
Please don't top-post :(
Quoted 4 lines
I'm a bit disappointed that you didn't drop this patch. At the time I sent my review it was still in your tty-testing branch and now it's part of your pull request for 4.13-rc1 (as commit
a3015affdf76ef279fbbb3710a220bab7e9ea04b). :-|
Quoted 6 lines
And now it's in Linus's tree! :)
Quoted 1 line
I'm still convinced that this patch is wrong in its current form.
Should I revert it, or can I get a fix for it? Reviewing the patch when it was submitted would have been best, not after it ends up in one of my trees...
I don't think there is a fix for it. Either you revert the patch and you code the fix differently, as I suggested by changing dma_rx_callback... but that's more intrusive... or you keep this patch.
Quoted 4 lines
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 16 lines · Romain Perier
Quoted 10 lines · Uwe Kleine-König
Quoted 9 lines · Uwe Kleine-König
Quoted 8 lines · Romain Perier
From: Nandor Han <[email protected]>
The size of the DMA buffer can affect the delta time between data being produced and data being consumed. Basically the DMA system will move data to tty buffer when a) DMA buffer is full b) serial line is idle. The situation is visible when producer generates data continuously and there is no possibility for idle line. At this point the DMA buffer is directly affecting the delta time.
Quoted 4 lines
Quoted 4 lines
This doesn't look like a hw property but a configuration item. Also I don't understand the problematic case. The i.MX is sending continuously and then doesn't receive bytes until the DMA buffer is full? What is the DMA buffer? You don't mean the FIFO here, do you?
Quoted 4 lines
by DMA buffer, I mean the size of the RX FIFO. Data will be moved to tty when the FIFO
is full or the serial line is idle. Now suppose you have an important work load and the serial line is never idle,
That means you're waiting for urgent data that already sits in the hardware's RX fifo but as you send in parallel the hardware is busy and doesn't process the RX fifo?
Would it help to decrease UFCR.RXTL? Or is this a HW bug that the RX fifo isn't considered idle when you send much?
Or is this a software problem and the urgent data sits somewhere in the tty or dma layer already?
Quoted 2 lines
with the current size of the DMA buffer (
PAGE_SIZE) you might introduce latencies between data being produced and data being consumed.
Making DMA buffers smaller doesn't sound like the right approach to minimize delays. If you choose to do so you increase the number of irqs and so this is a user policy what you want and shouldn't fixed in the oftree.
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · Romain Perier
Hello,
Quoted 10 lines · Greg Kroah-Hartman
Quoted 1 line · Uwe Kleine-König
Hello Greg,
Please don't top-post :(
Quoted 4 lines
I'm a bit disappointed that you didn't drop this patch. At the time I sent my review it was still in your tty-testing branch and now it's part of your pull request for 4.13-rc1 (as commit
a3015affdf76ef279fbbb3710a220bab7e9ea04b). :-|And now it's in Linus's tree! :)
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
I'm still convinced that this patch is wrong in its current form.
Should I revert it, or can I get a fix for it? Reviewing the patch when it was submitted would have been best, not after it ends up in one of my trees...
I don't think there is a fix for it. Either you revert the patch and you code the fix differently, as I suggested by changing
dma_rx_callback... but that's more intrusive... or you keep this patch.
I'll revert it after 4.13-rc1 is out, unless there are major objections to that...
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 serial: imx-serial - move DMA buffer configuration to DT
In reply to a message not in the archiveQuoted 10 lines
-----Original Message-----
From: Uwe Kleine-König [mailto:[email protected]]
Sent: 29 June 2017 21:26
To: Romain Perier <romain.perier-ZGY8ohtN/[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>; Jiri Slaby <jslaby-IBi9RG/[email protected]>; [email protected]; Han, Nandor (GE Healthcare) <[email protected]>; [email protected]
Subject: EXT: Re: [PATCH] serial: imx-serial - move DMA buffer configuration
to DT
Quoted 13 lines
Hello,
Cc += [email protected]Quoted 8 lines · Romain Perier
From: Nandor Han <[email protected]>
The size of the DMA buffer can affect the delta time between data being produced and data being consumed. Basically the DMA system will move data to tty buffer when a) DMA buffer is full b) serial line is idle. The situation is visible when producer generates data continuously and there is no possibility for idle line. At this point the DMA buffer is directly affecting the delta time.
Hi Uwe,
Maybe I can explain a bit better the situation. At least I've tried to explain well enough
the problem and the fix. :)
Quoted 4 lines
This doesn't look like a hw property but a configuration item. Also I don't understand the problematic case. The i.MX is sending continuously and then doesn't receive bytes until the DMA buffer is full?
Yes
Quoted 3 lines
What is the DMA buffer?
You don't mean the FIFO here, do you?
DMA buffer is not HW FIFO. Is the buffer provided by serial driver to DMA to store data.
Quoted 3 lines
That doesn't sound like a good fix but more like a work around. Which other options did you test to fix your problem?
I haven't tried any other, because except using maybe, ioctl I haven't got anything better.
Our problem is that in our system some serial ports needs to have really low data latency, where others trade more bytes over data latency. This situation results in a need of beeing able to have different DMA buffer size for different ports.
How can DMA buffer size affect latency?
DMA works like this: (To answer to your question DMA buffer is not FIFO)
1. Transfer the data from HW FIFO to DMA buffer based on some interrupts (character received, etc)
2. Transfer the DMA buffer back to serial port based on some events (buffer full, aging timer, etc)
3. Serial port forwards to tty buffer.
Data availability to consumer depends on: DMA buffer size, baud rate and communication pattern. By communication patter I'm refering that we send data continuoselly (serial line is never idle) or packet by packet (serial line is idle in between) Example:
Baud: 19200 (1Byte = 0.52 ms)
DMA buffer size: 100 bytes
Communication pattern: continuously
=> DMA will return data to serial port only when DMA buffer is full, since the communication is continuously. This result in a data latency of 0.52 ms* 100bytes = 52ms. In case the buffer will be 200bytes the letency will be double.
I agree with you, this is not directly a hw property but a DMA configuration item. But I've found this to be the best way to configure this comparing with using ioctl.
Let me know if you need more clarification and I would really be open to other options that will solve our problem.
<snip>
Quoted 5 lines
Quoted 1 line
+- fsl,dma-size : Indicate the size of the DMA buffer and its periods
This is a sparse description, just from reading that I don't understand what it does.
Serial driver configures a circular ring of buffers for DMA. Here we can configure the size and the number of buffers.
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+/* RX DMA buffer periods */ +#define RX_DMA_PERIODS 4 +#define RX_BUF_SIZE (PAGE_SIZE)These names should include "DEFAULT" in their name now to fit their new semantic.
Agree.
Regards,
Nandor
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello,
Quoted 39 lines · Nandor (GE Healthcare)
Quoted 10 lines
-----Original Message-----
From: Uwe Kleine-König [mailto:[email protected]]
Sent: 29 June 2017 21:26
To: Romain Perier <romain.perier-ZGY8ohtN/[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>; Jiri Slaby <jslaby-IBi9RG/[email protected]>; [email protected]; Han, Nandor (GE Healthcare) <[email protected]>; [email protected]
Subject: EXT: Re: [PATCH] serial: imx-serial - move DMA buffer configuration
to DTQuoted 13 lines
Hello,
Cc += [email protected]Quoted 8 lines · Romain Perier
From: Nandor Han <[email protected]>
The size of the DMA buffer can affect the delta time between data being produced and data being consumed. Basically the DMA system will move data to tty buffer when a) DMA buffer is full b) serial line is idle. The situation is visible when producer generates data continuously and there is no possibility for idle line. At this point the DMA buffer is directly affecting the delta time.
Hi Uwe,
Maybe I can explain a bit better the situation. At least I've tried to explain well enough
the problem and the fix. :)Quoted 4 lines
This doesn't look like a hw property but a configuration item. Also I don't understand the problematic case. The i.MX is sending continuously and then doesn't receive bytes until the DMA buffer is full?
Yes
Quoted 3 lines
What is the DMA buffer?
You don't mean the FIFO here, do you?
Quoted 8 lines
DMA buffer is not HW FIFO. Is the buffer provided by serial driver to DMA to store data.
Quoted 3 lines
That doesn't sound like a good fix but more like a work around. Which other options did you test to fix your problem?
I haven't tried any other, because except using maybe, ioctl I haven't got anything better.
My question didn't target where to configure the buffer size instead of dts. I wonder if it would help to change the fifo watermark limits for example.
Quoted 10 lines
Our problem is that in our system some serial ports needs to have really low data latency, where others trade more bytes over data latency. This situation results in a need of beeing able to have different DMA buffer size for different ports.
How can DMA buffer size affect latency?
DMA works like this: (To answer to your question DMA buffer is not FIFO)
1. Transfer the data from HW FIFO to DMA buffer based on some interrupts (character received, etc)
2. Transfer the DMA buffer back to serial port based on some events (buffer full, aging timer, etc)
3. Serial port forwards to tty buffer.
BTW In the past I saw the serial core introduce latency, too. Are you sure that's not your bottle neck?
Quoted 21 lines
Data availability to consumer depends on: DMA buffer size, baud rate and communication pattern. By communication patter I'm refering that we send data continuoselly (serial line is never idle) or packet by packet (serial line is idle in between)
Example:
Baud: 19200 (1Byte = 0.52 ms)
DMA buffer size: 100 bytes
Communication pattern: continuously
=> DMA will return data to serial port only when DMA buffer is full, since the communication is continuously. This result in a data latency of 0.52 ms* 100bytes = 52ms. In case the buffer will be 200bytes the letency will be double.I agree with you, this is not directly a hw property but a DMA configuration item. But I've found this to be the best way to configure this comparing with using ioctl.
Let me know if you need more clarification and I would really be open to other options that will solve our problem.
<snip>
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
+- fsl,dma-size : Indicate the size of the DMA buffer and its periods
This is a sparse description, just from reading that I don't understand what it does.
Serial driver configures a circular ring of buffers for DMA. Here we can configure the size and the number of buffers.
The problem is: How should a person, who wants to make available a port on a machine via dts, choose what value to use for fsl,dma-size?
What you want (for a low latency port) is that also small amounts of data received are passed quickly to the upper layer. The knob you identified to be available for that is the dma buffer size.
I'd prefer to talk about low latency instead of buffer sizes when setting parameters for the port. That this influences the buffer size (and maybe watermark settings) under the hood shouldn't matter for the person configuring the low latency property.
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 serial: imx-serial - move DMA buffer configuration to DT
In reply to a message not in the archiveQuoted 63 lines
-----Original Message-----
From: Uwe Kleine-König [mailto:[email protected]]
Sent: 05 October 2017 00:50
To: Han, Nandor (GE Healthcare) <[email protected]>
Cc: Romain Perier <romain.perier-ZGY8ohtN/[email protected]>; Greg Kroah-Hartman <[email protected]>; Jiri Slaby <jslaby-IBi9RG/[email protected]>; linux- [email protected]; [email protected]
Subject: EXT: Re: [PATCH] serial: imx-serial - move DMA buffer configuration
to DTHello,
Quoted 12 lines · Nandor (GE Healthcare)
Quoted 12 lines
-----Original Message-----
From: Uwe Kleine-König [mailto:[email protected]]
Sent: 29 June 2017 21:26
To: Romain Perier <romain.perier-ZGY8ohtN/[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>; Jiri Slaby <jslaby-IBi9RG/[email protected]>; [email protected]; Han, Nandor (GE Healthcare) <[email protected]>; [email protected]
Subject: EXT: Re: [PATCH] serial: imx-serial - move DMA buffer
configuration to DTHello,
Quoted 8 lines
Quoted 8 lines
Cc += [email protected]Quoted 5 lines · Romain Perier
From: Nandor Han <[email protected]>
The size of the DMA buffer can affect the delta time between data being produced and data being consumed. Basically the DMA system will move data to tty buffer when a) DMA buffer is full b) serial line is
idle.
Quoted 13 lines
Quoted 3 lines
Quoted 3 lines
The situation is visible when producer generates data continuously and there is no possibility for idle line. At this point the DMA buffer is directly affecting the delta time.
Hi Uwe,
Maybe I can explain a bit better the situation. At least I've tried
to explain well enough the problem and the fix. :)Quoted 4 lines
This doesn't look like a hw property but a configuration item. Also I don't understand the problematic case. The i.MX is sending continuously and then doesn't receive bytes until the DMA buffer is full?
Quoted 7 lines
Yes
Quoted 3 lines
What is the DMA buffer?
You don't mean the FIFO here, do you?DMA buffer is not HW FIFO. Is the buffer provided by serial driver to DMA to
store data.
Quoted 5 lines
Quoted 4 lines
That doesn't sound like a good fix but more like a work around. Which other options did you test to fix your problem?
Quoted 6 lines
Quoted 2 lines
I haven't tried any other, because except using maybe, ioctl I haven't got anything better.
My question didn't target where to configure the buffer size instead of dts. I wonder if it would help to change the fifo watermark limits for example.
Ok. Sorry I didn't understand correct. Watermark will not help in this case because it is used only to trigger the moving of the data from RX FIFO to DMA buffer. The iMX DMA (check the iMX6 RM A.3.1.2.4 since is missing from iMX53 RM) will only return data to serial driver when no more data exist in the RX FIFO (is using aging timer for this check) or BD (DMA buffer) is full. If data is sent continuously DMA will return data to driver only when BD is full.
So what we need here is a trigger that will force DMA to return data faster to serial driver. The only one that I could find was the size of the buffer. Of course another way will be to create different SDMA scripts that can do all kinds of handling -- but dint' want to go on that route :)
Quoted 10 lines
Quoted 10 lines
Our problem is that in our system some serial ports needs to have really low data latency, where others trade more bytes over data latency. This situation results in a need of beeing able to have different DMA buffer size for different ports.
How can DMA buffer size affect latency?
DMA works like this: (To answer to your question DMA buffer is not FIFO) 1. Transfer the data from HW FIFO to DMA buffer based on some interrupts (character received, etc) 2. Transfer the DMA buffer back to serial port based on some events (buffer full, aging timer, etc) 3. Serial
Quoted 5 lines
port forwards to tty buffer.
BTW In the past I saw the serial core introduce latency, too. Are you sure that's not your bottle neck?
Can you be more specific? Receiving data seems very straight forward and serial core is not involved that much with or without DMA. Basically the driver handles the moving of the data from rx FIFO to tty buffer. Beside this lowering the DMA buffer fixed our issue. So I will assume that no.
Quoted 30 lines
Quoted 13 lines
Data availability to consumer depends on: DMA buffer size, baud rate and communication pattern. By communication patter I'm refering that we send data continuoselly (serial line is never idle) or packet by packet (serial line is idle in between)
Example:
Baud: 19200 (1Byte = 0.52 ms)
DMA buffer size: 100 bytes
Communication pattern: continuously
=> DMA will return data to serial port only when DMA buffer is full, since the communication is continuously. This result in a data latency of 0.52 ms* 100bytes = 52ms. In case the buffer will be 200bytes the letency will be double.Quoted 1 line
I agree with you, this is not directly a hw property but a DMA configuration
item.
Quoted 1 line
But I've found this to be the best way to configure this comparing with using
ioctl.
Quoted 13 lines
Let me know if you need more clarification and I would really be open to other options that will solve our problem.
<snip>
Quoted 6 lines
Quoted 2 lines
+- fsl,dma-size : Indicate the size of the DMA buffer and its +periods
This is a sparse description, just from reading that I don't understand what it does.
Quoted 5 lines
Quoted 2 lines
Serial driver configures a circular ring of buffers for DMA. Here we can configure the size and the number of buffers.
The problem is: How should a person, who wants to make available a port on a machine via dts, choose what value to use for fsl,dma-size?
It doesn't have too. If this configuration is not provided the serial port will have a default value. The user has the possibility to tweak this settings in case is needed.
Quoted 10 lines
What you want (for a low latency port) is that also small amounts of data received are passed quickly to the upper layer. The knob you identified to be available for that is the dma buffer size.
I'd prefer to talk about low latency instead of buffer sizes when setting parameters for the port. That this influences the buffer size (and maybe watermark settings) under the hood shouldn't matter for the person configuring the low latency property.
I understand your point of view. A simple grep in "Documentation/devicetree/bindings" shows me that both options are used (latency/buffer configurations). We could use latency here as configuration and then translate it to DMA buffer size taking in consideration the baud rate but it's a bit more work to do and beside this we have also the number of buffers configuration which will be trickier to convert it from latency. In my opinion, I don't see a significant difference between latency and buffer since most of the serial port users (userspace level) don't touch these settings. Of course, will be a different story if this configuration will be provided using termios or other means accessible from userspace.
Quoted 3 lines
Best regards
Uwe
Thanks Uwe :)
Regards,
Nandor
Quoted 3 lines
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello,
Quoted 7 lines · Nandor (GE Healthcare)
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
That doesn't sound like a good fix but more like a work around. Which other options did you test to fix your problem?
I haven't tried any other, because except using maybe, ioctl I haven't got anything better.
Quoted 8 lines
Quoted 3 lines
My question didn't target where to configure the buffer size instead of dts. I wonder if it would help to change the fifo watermark limits for example.
Ok. Sorry I didn't understand correct. Watermark will not help in this case because it is used only to trigger the moving of the data from RX FIFO to DMA buffer. The iMX DMA (check the iMX6 RM A.3.1.2.4 since is missing from iMX53 RM) will only return data to serial driver when no more data exist in the RX FIFO (is using aging timer for this check) or BD (DMA buffer) is full. If data is sent continuously DMA will return data to driver only when BD is full.
I read once over the description but I failed to understand it. At least it talks about water mark levels and min(WML-1,Count) which makes me think that the DMA script makes use of water marking too and my idea to play with that instead of buffer sizes might be sensible.
Quoted 5 lines
So what we need here is a trigger that will force DMA to return data faster to serial driver. The only one that I could find was the size of the buffer. Of course another way will be to create different SDMA scripts that can do all kinds of handling -- but dint' want to go on that route :)
:-)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Our problem is that in our system some serial ports needs to have really low data latency, where others trade more bytes over data latency. This situation results in a need of beeing able to have different DMA buffer size for different ports.
How can DMA buffer size affect latency?
DMA works like this: (To answer to your question DMA buffer is not FIFO) 1. Transfer the data from HW FIFO to DMA buffer based on some interrupts (character received, etc) 2. Transfer the DMA buffer back to serial port based on some events (buffer full, aging timer, etc) 3. Serial
Quoted 6 lines
Quoted 4 lines
port forwards to tty buffer.
BTW In the past I saw the serial core introduce latency, too. Are you sure that's not your bottle neck?
Can you be more specific?
http://www.spinics.net/lists/linux-serial/msg17767.html
Quoted 30 lines
Quoted 30 lines
Quoted 13 lines
Data availability to consumer depends on: DMA buffer size, baud rate and communication pattern. By communication patter I'm refering that we send data continuoselly (serial line is never idle) or packet by packet (serial line is idle in between)
Example:
Baud: 19200 (1Byte = 0.52 ms)
DMA buffer size: 100 bytes
Communication pattern: continuously
=> DMA will return data to serial port only when DMA buffer is full, since the communication is continuously. This result in a data latency of 0.52 ms* 100bytes = 52ms. In case the buffer will be 200bytes the letency will be double.Quoted 1 line
I agree with you, this is not directly a hw property but a DMA configuration
item.
Quoted 1 line
But I've found this to be the best way to configure this comparing with using
ioctl.
Quoted 13 lines
Let me know if you need more clarification and I would really be open to other options that will solve our problem.
<snip>
Quoted 6 lines
Quoted 2 lines
+- fsl,dma-size : Indicate the size of the DMA buffer and its +periods
This is a sparse description, just from reading that I don't understand what it does.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Serial driver configures a circular ring of buffers for DMA. Here we can configure the size and the number of buffers.
The problem is: How should a person, who wants to make available a port on a machine via dts, choose what value to use for fsl,dma-size?
It doesn't have too. If this configuration is not provided the serial port will have a default value. The user has the possibility to tweak this settings in case is needed.
"The default value works in general" is no good justification to not provide easy-to-grasp and well documented knobs.
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 serial: imx-serial - move DMA buffer configuration to DT
In reply to a message not in the archiveQuoted 32 lines
-----Original Message-----
From: Uwe Kleine-König [mailto:[email protected]]
Sent: 10 October 2017 11:26
To: Han, Nandor (GE Healthcare) <[email protected]>
Cc: Romain Perier <romain.perier-ZGY8ohtN/[email protected]>; Greg Kroah-Hartman <[email protected]>; Jiri Slaby <jslaby-IBi9RG/[email protected]>; linux- [email protected]; [email protected]
Subject: EXT: Re: [PATCH] serial: imx-serial - move DMA buffer configuration
to DTHello,
Quoted 9 lines · Nandor (GE Healthcare)
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
That doesn't sound like a good fix but more like a work around. Which other options did you test to fix your problem?
I haven't tried any other, because except using maybe, ioctl I haven't got anything better.
My question didn't target where to configure the buffer size instead of dts. I wonder if it would help to change the fifo watermark limits for
example.
Quoted 6 lines
Quoted 1 line
Ok. Sorry I didn't understand correct. Watermark will not help in this case because it is used only to trigger the moving of the data from RX FIFO to DMA buffer. The iMX DMA (check the iMX6 RM A.3.1.2.4 since is missing from iMX53 RM) will only return data to serial driver when no more
Quoted 9 lines
data exist in the RX FIFO (is using aging timer for this check) or BD (DMA buffer) is full. If data is sent continuously DMA will return data to driver only when BD is full.
I read once over the description but I failed to understand it. At least it talks about water mark levels and
min(WML-1,Count)which makes me think that the DMA script makes use of water marking too and my idea to play with that instead of buffer sizes might be sensible.
:). It is tricky, I agree. I will try to explain it even though I think the most important part is to understand that watermark level control when data is moved from out from rx FIFO
to DMA buffer (BD) and is not the trigger that returns the data from DMA buffer (BD) to serial driver
(which is the one that I need).
The SDMA script is using 2 triggers to move data from rx FIFO to DMA buffer (BD): 1) watermark hit and 2) aging timer. It ignores completely the "Idle line" trigger. When watermark trigger is received it will move "min(WML-1,BD count)" data from rx FIFO to BD. After this step in the rx FIFO will remain always at least 1 byte (since we move WML-1). The last byte will be moved based on the aging timer. During which SDMA will check if more data is available and move the rest. SDMA will return the BD in 2 situations: 1) BD is full 2) during aging time trigger the rx FIFO is empty.
Quoted 66 lines
Quoted 5 lines
So what we need here is a trigger that will force DMA to return data faster to serial driver. The only one that I could find was the size of the buffer. Of course another way will be to create different SDMA scripts that can do all kinds of handling -- but dint' want to go on that route :)
:-)
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Our problem is that in our system some serial ports needs to have really low data latency, where others trade more bytes over data latency. This situation results in a need of beeing able to have different DMA buffer size for different ports.
How can DMA buffer size affect latency?
DMA works like this: (To answer to your question DMA buffer is not FIFO) 1. Transfer the data from HW FIFO to DMA buffer based on some interrupts (character received, etc) 2. Transfer the DMA buffer back to serial port based on some events (buffer full, aging timer, etc) 3. SerialQuoted 6 lines
Quoted 4 lines
port forwards to tty buffer.
BTW In the past I saw the serial core introduce latency, too. Are you sure that's not your bottle neck?
Can you be more specific?
http://www.spinics.net/lists/linux-serial/msg17767.html
Quoted 38 lines
Quoted 37 lines
Quoted 13 lines
Data availability to consumer depends on: DMA buffer size, baud rate and communication pattern. By communication patter I'm refering that we send data continuoselly (serial line is never idle) or packet by packet (serial line is idle in between) Example:
Baud: 19200 (1Byte = 0.52 ms)
DMA buffer size: 100 bytes
Communication pattern: continuously
=> DMA will return data to serial port only when DMA buffer is full, since the communication is continuously. This result in a data latency of 0.52 ms* 100bytes = 52ms. In case the buffer will be 200bytes the letency will be double.Quoted 2 lines
I agree with you, this is not directly a hw property but a DMA configuration
item.
Quoted 2 lines
But I've found this to be the best way to configure this comparing with using
ioctl.
Quoted 9 lines
Let me know if you need more clarification and I would really be open to other options that will solve our problem.
<snip>
Quoted 3 lines
Quoted 2 lines
+- fsl,dma-size : Indicate the size of the DMA buffer and its +periods
Quoted 6 lines
Quoted 3 lines
This is a sparse description, just from reading that I don't understand what it does.
Serial driver configures a circular ring of buffers for DMA. Here we can configure the size and the number of buffers.
The problem is: How should a person, who wants to make available a port on a machine via dts, choose what value to use for fsl,dma-size?
Quoted 7 lines
Quoted 1 line
It doesn't have too. If this configuration is not provided the serial port will
have a default value.
Quoted 1 line
The user has the possibility to tweak this settings in case is needed.
"The default value works in general" is no good justification to not provide easy-to-grasp and well documented knobs.
I agree with you on this. But my intention was to say that the driver is using the same settings as before and users are not impacted by this change, and I only add the option to control that value.
Quoted 3 lines
Best regards
Uwe
Regards,
Nandor
Quoted 3 lines
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 25 lines
-----Original Message-----
From: [email protected] [mailto:linux-serial- [email protected]] On Behalf Of Han, Nandor (GE Healthcare)
Sent: 10 October 2017 13:17
To: Uwe Kleine-König <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>; Jiri Slaby <jslaby-IBi9RG/[email protected]>; [email protected]; [email protected]; Martyn Welch <martyn.welch-ZGY8ohtN/[email protected]>
Subject: EXT: [PATCH] serial: imx-serial - move DMA buffer configuration to
DTQuoted 10 lines
-----Original Message-----
From: Uwe Kleine-König [mailto:[email protected]]
Sent: 10 October 2017 11:26
To: Han, Nandor (GE Healthcare) <[email protected]>
Cc: Romain Perier <romain.perier-ZGY8ohtN/[email protected]>; Greg Kroah-Hartman <[email protected]>; Jiri Slaby <jslaby-IBi9RG/[email protected]>; linux- [email protected]; [email protected]
Subject: EXT: Re: [PATCH] serial: imx-serial - move DMA buffer
configuration to DT
Anything that I could still clarify here I'll be happy to explain :)
Quoted 135 lines
Quoted 27 lines
Hello,
Quoted 10 lines · Nandor (GE Healthcare)
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
That doesn't sound like a good fix but more like a work around. Which other options did you test to fix your problem?
I haven't tried any other, because except using maybe, ioctl I haven't got anything better.
My question didn't target where to configure the buffer size instead of dts. I wonder if it would help to change the fifo watermark limits for
example.
Quoted 7 lines
Quoted 1 line
Ok. Sorry I didn't understand correct. Watermark will not help in this case because it is used only to trigger the moving of the data from RX FIFO to DMA buffer. The iMX DMA (check the iMX6 RM A.3.1.2.4 since is missing from iMX53 RM) will only return data to serial driver when no more
data exist in the RX FIFO (is using aging timer for this check) or BD (DMA
buffer) is full. If data is sent continuously DMA will return data to driver only when BD is full.Quoted 5 lines
I read once over the description but I failed to understand it. At least it talks about water mark levels and
min(WML-1,Count)which makes me think that the DMA script makes use of water marking too and my idea to play with that instead of buffer sizes might be sensible.:). It is tricky, I agree. I will try to explain it even though I think the most important part is to understand that watermark level control when data is moved from out from rx FIFO to DMA buffer (BD) and is not the trigger that returns the data from DMA buffer (BD) to serial driver (which is the one that I need).
The SDMA script is using 2 triggers to move data from rx FIFO to DMA buffer (BD): 1) watermark hit and 2) aging timer. It ignores completely the "Idle line" trigger. When watermark trigger is received it will move "
min(WML-1,BD count)" data from rx FIFO to BD. After this step in the rx FIFO will remain always at least 1 byte (since we move WML-1). The last byte will be moved based on the aging timer. During which SDMA will check if more data is available and move the rest. SDMA will return the BD in 2 situations: 1) BD is full 2) during aging time trigger the rx FIFO is empty.Quoted 67 lines
Quoted 5 lines
So what we need here is a trigger that will force DMA to return data faster to serial driver. The only one that I could find was the size of the buffer. Of course another way will be to create different SDMA scripts that can do all kinds of handling -- but dint' want to go on that route :)
:-)
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Our problem is that in our system some serial ports needs to have really low data latency, where others trade more bytes over data latency. This situation results in a need of beeing able to have different DMA buffer size for different ports.
How can DMA buffer size affect latency?
DMA works like this: (To answer to your question DMA buffer is not
FIFO) 1. Transfer the data from HW FIFO to DMA buffer based on some interrupts (character received, etc) 2. Transfer the DMA buffer back to serial port based on some events (buffer full, aging timer, etc) 3. SerialQuoted 6 lines
Quoted 4 lines
port forwards to tty buffer.
BTW In the past I saw the serial core introduce latency, too. Are you sure that's not your bottle neck?
Can you be more specific?
http://www.spinics.net/lists/linux-serial/msg17767.html
Quoted 38 lines
Quoted 37 lines
Quoted 13 lines
Data availability to consumer depends on: DMA buffer size, baud rate and communication pattern. By communication patter I'm refering that we send data continuoselly (serial line is never idle) or packet by packet (serial line is idle in between) Example:
Baud: 19200 (1Byte = 0.52 ms)
DMA buffer size: 100 bytes
Communication pattern: continuously
=> DMA will return data to serial port only when DMA buffer is full, since the communication is continuously. This result in a data latency of 0.52 ms* 100bytes = 52ms. In case the buffer will be 200bytes the letency will be double.Quoted 2 lines
I agree with you, this is not directly a hw property but a DMA configuration
item.
Quoted 2 lines
But I've found this to be the best way to configure this comparing with using
ioctl.
Quoted 9 lines
Let me know if you need more clarification and I would really be open to other options that will solve our problem.
<snip>
Quoted 3 lines
Quoted 2 lines
+- fsl,dma-size : Indicate the size of the DMA buffer and +its periods
Quoted 6 lines
Quoted 3 lines
This is a sparse description, just from reading that I don't understand what it does.
Serial driver configures a circular ring of buffers for DMA. Here we can configure the size and the number of buffers.
The problem is: How should a person, who wants to make available a port on a machine via dts, choose what value to use for fsl,dma-size?
Quoted 8 lines
Quoted 2 lines
It doesn't have too. If this configuration is not provided the serial port will
have a default value.
Quoted 1 line
The user has the possibility to tweak this settings in case is needed.
"The default value works in general" is no good justification to not provide easy-to-grasp and well documented knobs.
I agree with you on this. But my intention was to say that the driver is using the same settings as before and users are not impacted by this change, and I only add the option to control that value.
Quoted 3 lines
Best regards
UweRegards,
Nandor
Quoted 7 lines
Quoted 3 lines
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html