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@xxxxxxx> > Cc: Shawn Guo <shawnguo@xxxxxxxxxx> > Cc: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> > Cc: Pengutronix Kernel Team <kernel@xxxxxxxxxxxxxx> > Cc: Fabio Estevam <festevam@xxxxxxxxx> > Cc: NXP Linux Team <linux-imx@xxxxxxx> > --- > 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/ |
Attachment:
signature.asc
Description: PGP signature