lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210302065918.cbxwen6vz2pz4msn@pengutronix.de>
Date:   Tue, 2 Mar 2021 07:59:18 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Jiri Slaby <jslaby@...e.cz>
Cc:     gregkh@...uxfoundation.org, Fabio Estevam <festevam@...il.com>,
        linux-serial@...r.kernel.org,
        Sascha Hauer <s.hauer@...gutronix.de>,
        linux-kernel@...r.kernel.org, NXP Linux Team <linux-imx@....com>,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        Shawn Guo <shawnguo@...nel.org>,
        Ahmad Fatoum <a.fatoum@...gutronix.de>
Subject: Re: [PATCH 10/44] tty: imx, use ms_to_ktime

Hello Jiri,

On Tue, Mar 02, 2021 at 07:21:40AM +0100, Jiri Slaby wrote:
> This really eliminates multiplications from the assembly. I would have
> thought they are optimized by inlining ktime_set, but not on x86_64 with
> gcc 10.
> 
> Signed-off-by: Jiri Slaby <jslaby@...e.cz>
> Cc: Shawn Guo <shawnguo@...nel.org>
> Cc: Sascha Hauer <s.hauer@...gutronix.de>
> Cc: Pengutronix Kernel Team <kernel@...gutronix.de>
> Cc: Fabio Estevam <festevam@...il.com>
> Cc: NXP Linux Team <linux-imx@....com>
> ---
>  drivers/tty/serial/imx.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 8257597d034d..3f69356937ef 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -394,11 +394,7 @@ static void imx_uart_rts_inactive(struct imx_port *sport, u32 *ucr2)
>  
>  static void start_hrtimer_ms(struct hrtimer *hrt, unsigned long msec)
>  {
> -       long sec = msec / MSEC_PER_SEC;
> -       long nsec = (msec % MSEC_PER_SEC) * 1000000;
> -       ktime_t t = ktime_set(sec, nsec);
> -
> -       hrtimer_start(hrt, t, HRTIMER_MODE_REL);
> +       hrtimer_start(hrt, ms_to_ktime(msec), HRTIMER_MODE_REL);
>  }

What about:


diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 8257597d034d..8731d4f82cb8 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -392,15 +392,6 @@ static void imx_uart_rts_inactive(struct imx_port *sport, u32 *ucr2)
 	mctrl_gpio_set(sport->gpios, sport->port.mctrl);
 }
 
-static void start_hrtimer_ms(struct hrtimer *hrt, unsigned long msec)
-{
-       long sec = msec / MSEC_PER_SEC;
-       long nsec = (msec % MSEC_PER_SEC) * 1000000;
-       ktime_t t = ktime_set(sec, nsec);
-
-       hrtimer_start(hrt, t, HRTIMER_MODE_REL);
-}
-
 /* called with port.lock taken and irqs off */
 static void imx_uart_start_rx(struct uart_port *port)
 {
@@ -457,8 +448,9 @@ static void imx_uart_stop_tx(struct uart_port *port)
 	if (port->rs485.flags & SER_RS485_ENABLED) {
 		if (sport->tx_state == SEND) {
 			sport->tx_state = WAIT_AFTER_SEND;
-			start_hrtimer_ms(&sport->trigger_stop_tx,
-					 port->rs485.delay_rts_after_send);
+			hrtimer_start(&sport->trigger_stop_tx,
+				      ms_to_ktime(port->rs485.delay_rts_after_send),
+				      HRTIMER_MODE_REL);
 			return;
 		}
 
@@ -697,8 +689,9 @@ static void imx_uart_start_tx(struct uart_port *port)
 				imx_uart_stop_rx(port);
 
 			sport->tx_state = WAIT_AFTER_RTS;
-			start_hrtimer_ms(&sport->trigger_start_tx,
-					 port->rs485.delay_rts_before_send);
+			hrtimer_start(&sport->trigger_start_tx,
+				      ms_to_ktime(port->rs485.delay_rts_before_send),
+				      HRTIMER_MODE_REL);
 			return;
 		}
 
instead?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ