Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753608AbbKQK0A (ORCPT ); Tue, 17 Nov 2015 05:26:00 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:35573 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753576AbbKQKZ5 convert rfc822-to-8bit (ORCPT ); Tue, 17 Nov 2015 05:25:57 -0500 MIME-Version: 1.0 In-Reply-To: <20151117092442.GL22022@pengutronix.de> References: <1447338836-8785-1-git-send-email-matwey@sai.msu.ru> <1447338836-8785-6-git-send-email-matwey@sai.msu.ru> <20151117092442.GL22022@pengutronix.de> From: "Matwey V. Kornilov" Date: Tue, 17 Nov 2015 13:25:36 +0300 X-Google-Sender-Auth: tXTotLI7bSWR2THdys56tvFRyYk Message-ID: Subject: Re: [PATCH v3 5/5] tty: Add software emulated RS485 support for 8250 To: =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= Cc: Greg KH , jslaby@suse.com, Peter Hurley , linux-kernel , linux-serial@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2552 Lines: 72 2015-11-17 12:24 GMT+03:00 Uwe Kleine-König : > Hello, > > On Thu, Nov 12, 2015 at 05:33:56PM +0300, Matwey V. Kornilov wrote: >> +static void serial8250_start_tx(struct uart_port *port) >> +{ >> + struct uart_8250_port *up = up_to_u8250p(port); >> + __u32 delay; >> + >> + serial8250_rpm_get_tx(up); >> + >> + if (timer_pending(&up->rs485_start_tx_timer)) >> + return; > > I think this is wrong (or at least suboptimal). The .start_tx callback > can be called even if transmission is already ongoing. In this case you > don't want to restart the rs485_start_tx_timer. If I understand you correctly, this maybe suboptimal but not wrong. Calling .start_tx during transmission will lead to call serial8250_rs485_start_tx which will return 0 because RTS is already in proper state, and then __start_tx will be called immediately. Just as it happens now. > >> + if ((delay = serial8250_rs485_start_tx(up))) { >> + mod_timer(&up->rs485_start_tx_timer, jiffies + delay * HZ / 1000); >> + } else { >> + __start_tx(port); >> + } >> +} >> + >> [...] >> diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h >> index faa0e03..c4905e7 100644 >> --- a/include/linux/serial_8250.h >> +++ b/include/linux/serial_8250.h >> @@ -86,6 +86,8 @@ struct uart_8250_ops { >> struct uart_8250_port { >> struct uart_port port; >> struct timer_list timer; /* "no irq" timer */ >> + struct timer_list rs485_start_tx_timer; /* "rs485 start tx" timer */ >> + struct timer_list rs485_stop_tx_timer; /* "rs485 stop tx" timer */ > > Do you really need two timers here? At each point in time there should > only be at most one of them active. You are right, only one is active. Having two timers is implicit way to store the state ('starting' or 'stopping'). I don't think that this is the worst way. > > Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-König | > Industrial Linux Solutions | http://www.pengutronix.de/ | > -- With best regards, Matwey V. Kornilov. Sternberg Astronomical Institute, Lomonosov Moscow State University, Russia 119991, Moscow, Universitetsky pr-k 13, +7 (495) 9392382 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/