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]
Date:   Tue, 2 Nov 2021 09:58:06 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     minyard@....org
Cc:     Oleksij Rempel <o.rempel@...gutronix.de>,
        Corey Minyard <cminyard@...sta.com>,
        Andrew Manley <andrew.manley@...lingtech.com>,
        linux-kernel@...r.kernel.org, linux-i2c@...r.kernel.org,
        Pengutronix Kernel Team <kernel@...gutronix.de>
Subject: Re: [PATCH 3/3] i2c:imx: Use an hrtimer, not a timer, for checking
 for bus idle

On Mon, Oct 04, 2021 at 07:32:16PM -0500, minyard@....org wrote:
> From: Corey Minyard <cminyard@...sta.com>
> 
> The timer is too slow and significantly reduces performance.  Use an
> hrtimer to get things working faster.
> 
> Signed-off-by: Corey Minyard <minyard@....org>
> Tested-by: Andrew Manley <andrew.manley@...lingtech.com>
> Reviewed-by: Andrew Manley <andrew.manley@...lingtech.com>
> ---
>  drivers/i2c/busses/i2c-imx.c | 23 +++++++++++++++--------
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 26a04dc0590b..4b0e9d1784dd 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -38,7 +38,7 @@
>  #include <linux/iopoll.h>
>  #include <linux/kernel.h>
>  #include <linux/spinlock.h>
> -#include <linux/timer.h>
> +#include <linux/hrtimer.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> @@ -53,6 +53,8 @@
>  /* This will be the driver name the kernel reports */
>  #define DRIVER_NAME "imx-i2c"
>  
> +#define I2C_IMX_CHECK_DELAY 30000 /* Time to check for bus idle, in NS */
> +
>  /*
>   * Enable DMA if transfer byte size is bigger than this threshold.
>   * As the hardware request, it must bigger than 4 bytes.\
> @@ -214,8 +216,8 @@ struct imx_i2c_struct {
>  	enum i2c_slave_event last_slave_event;
>  
>  	/* For checking slave events. */
> -	spinlock_t	  slave_lock;
> -	struct timer_list slave_timer;
> +	spinlock_t     slave_lock;
> +	struct hrtimer slave_timer;

This is unrelated to this patch, moreover it was introduced only in
patch 1.

>  };
>  
>  static const struct imx_i2c_hwdata imx1_i2c_hwdata = {
> @@ -783,13 +785,16 @@ static irqreturn_t i2c_imx_slave_handle(struct imx_i2c_struct *i2c_imx,
>  	}
>  
>  out:
> -	mod_timer(&i2c_imx->slave_timer, jiffies + 1);
> +	hrtimer_try_to_cancel(&i2c_imx->slave_timer);

Don't you need to check the return value here?

> +	hrtimer_forward_now(&i2c_imx->slave_timer, I2C_IMX_CHECK_DELAY);
> +	hrtimer_restart(&i2c_imx->slave_timer);
>  	return IRQ_HANDLED;
>  }
>  

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