diff mbox

[1/2] isdn/gigaset: reset tty->receive_room when attaching ser_gigaset

Message ID ff18ec15ffc6347cd5574a66eb67cc9483361afa.1436826434.git.tilman@imap.cc
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Tilman Schmidt July 13, 2015, 10:37 p.m. UTC
Commit 79901317ce80 ("n_tty: Don't flush buffer when closing ldisc"),
first merged in kernel release 3.10, caused the following regression
in the Gigaset M101 driver:

Before that commit, when closing the N_TTY line discipline in
preparation to switching to N_GIGASET_M101, receive_room would be
reset to a non-zero value by the call to n_tty_flush_buffer() in
n_tty's close method. With the removal of that call, receive_room
might be left at zero, blocking data reception on the serial line.

The present patch fixes that regression by setting receive_room
to an appropriate value in the ldisc open method.

Fixes: 79901317ce80 ("n_tty: Don't flush buffer when closing ldisc")
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
---
 drivers/isdn/gigaset/ser-gigaset.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

Comments

Tilman Schmidt July 13, 2015, 11:58 p.m. UTC | #1
Am 14.07.2015 um 01:14 schrieb Peter Hurley:
> On 07/13/2015 06:37 PM, Tilman Schmidt wrote:
>> Commit 79901317ce80 ("n_tty: Don't flush buffer when closing ldisc"),
>> first merged in kernel release 3.10, caused the following regression
>> in the Gigaset M101 driver:
>>
>> Before that commit, when closing the N_TTY line discipline in
>> preparation to switching to N_GIGASET_M101, receive_room would be
>> reset to a non-zero value by the call to n_tty_flush_buffer() in
>> n_tty's close method. With the removal of that call, receive_room
>> might be left at zero, blocking data reception on the serial line.
> 
> That commit didn't cause the problem; it was a bug all along.

Sure. That's why it is correctly fixed in the Gigaset driver.
But before that commit the bug was never actually triggered.
So that commit defines the point in the commit history from
which the fix is needed, and therefore needs to be mentioned
in order to decide which stable releases will need the fix.

> Non-flow controlling line disciplines _must_ set tty->receive_room
> on line discipline open because they are declaring that every
> input they can accept that much data.

I have submitted a corresponding fix to the line discipline
documentation separately.

Thanks,
Tilman
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov July 14, 2015, 12:50 p.m. UTC | #2
Hello.

On 7/14/2015 1:37 AM, Tilman Schmidt wrote:

> Commit 79901317ce80 ("n_tty: Don't flush buffer when closing ldisc"),
> first merged in kernel release 3.10, caused the following regression
> in the Gigaset M101 driver:

> Before that commit, when closing the N_TTY line discipline in
> preparation to switching to N_GIGASET_M101, receive_room would be
> reset to a non-zero value by the call to n_tty_flush_buffer() in
> n_tty's close method. With the removal of that call, receive_room
> might be left at zero, blocking data reception on the serial line.

> The present patch fixes that regression by setting receive_room
> to an appropriate value in the ldisc open method.

> Fixes: 79901317ce80 ("n_tty: Don't flush buffer when closing ldisc")
> Signed-off-by: Tilman Schmidt <tilman@imap.cc>
> ---
>   drivers/isdn/gigaset/ser-gigaset.c |   11 ++++++++++-
>   1 files changed, 10 insertions(+), 1 deletions(-)

> diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
> index 8c91fd5..3ac9c41 100644
> --- a/drivers/isdn/gigaset/ser-gigaset.c
> +++ b/drivers/isdn/gigaset/ser-gigaset.c
> @@ -524,9 +524,18 @@ gigaset_tty_open(struct tty_struct *tty)
>   	cs->hw.ser->tty = tty;
>   	atomic_set(&cs->hw.ser->refcnt, 1);
>   	init_completion(&cs->hw.ser->dead_cmp);
> -

    Unrelated change?

>   	tty->disc_data = cs;
>
> +	/* Set the amount of data we're willing to receive per call
> +	 * from the hardware driver to half of the input buffer size
> +	 * to leave some reserve.
> +	 * Note: We don't do flow control towards the hardware driver.
> +	 * If more data is received than will fit into the input buffer,
> +	 * it will be dropped and an error will be logged. This should
> +	 * never happen as the device is slow and the buffer size ample.
> +	 */
> +	tty->receive_room = RBUFSIZE/2;

    The general kernel coding style is to surround operators with spaces.

[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul Bolle July 14, 2015, 7:01 p.m. UTC | #3
On di, 2015-07-14 at 01:58 +0200, Tilman Schmidt wrote:
> Am 14.07.2015 um 01:14 schrieb Peter Hurley:
> > That commit didn't cause the problem; it was a bug all along.
> 
> Sure. That's why it is correctly fixed in the Gigaset driver.
> But before that commit the bug was never actually triggered.
> So that commit defines the point in the commit history from
> which the fix is needed, and therefore needs to be mentioned
> in order to decide which stable releases will need the fix.

Yes, this seems a classic example of a bugfix that reveals another bug.
So the Fixes: tag, which does sound a bit awkward, really is
appropriate.

For ser-gigaset about the only line discipline change that will be
triggered, in practice, is from N_TTY to N_GIGASET_M101. Until commit
79901317ce80 ("n_tty: Don't flush buffer when closing ldisc") that
change would set receive_room to N_TTY_BUF_SIZE (ie, 4096). This patch
will set receive_room for ser-gigaset to RBUFSIZE/2 (ie, again 4096). So
we're back at the pre v3.10 behavior.

I'm really thankful that Tilman managed to bisect this and subsequently
saw how it could be properly fixed. I hope to forward this patch in a
few weeks so that it might finally be fixed in v4.3.

Applied.


Paul Bolle
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index 8c91fd5..3ac9c41 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -524,9 +524,18 @@  gigaset_tty_open(struct tty_struct *tty)
 	cs->hw.ser->tty = tty;
 	atomic_set(&cs->hw.ser->refcnt, 1);
 	init_completion(&cs->hw.ser->dead_cmp);
-
 	tty->disc_data = cs;
 
+	/* Set the amount of data we're willing to receive per call
+	 * from the hardware driver to half of the input buffer size
+	 * to leave some reserve.
+	 * Note: We don't do flow control towards the hardware driver.
+	 * If more data is received than will fit into the input buffer,
+	 * it will be dropped and an error will be logged. This should
+	 * never happen as the device is slow and the buffer size ample.
+	 */
+	tty->receive_room = RBUFSIZE/2;
+
 	/* OK.. Initialization of the datastructures and the HW is done.. Now
 	 * startup system and notify the LL that we are ready to run
 	 */