linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Mark Jonas <mark.jonas@de.bosch.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-i2c <linux-i2c@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Wang Xin <xin.wang7@cn.bosch.com>
Subject: Re: [PATCH] eeprom: at24: Fix unexpected timeout under high load
Date: Sat, 4 Aug 2018 23:51:37 +0300	[thread overview]
Message-ID: <CAHp75Veo__Zu_Uk5-CN5q_yEUHs0fDsKZu9van89JBX2Prs7-w@mail.gmail.com> (raw)
In-Reply-To: <1533404620-18536-1-git-send-email-mark.jonas@de.bosch.com>

On Sat, Aug 4, 2018 at 8:43 PM, Mark Jonas <mark.jonas@de.bosch.com> wrote:


> -#define at24_loop_until_timeout(tout, op_time)                         \
> -       for (tout = jiffies + msecs_to_jiffies(at24_write_timeout),     \
> -            op_time = 0;                                               \
> -            op_time ? time_before(op_time, tout) : true;               \
> -            usleep_range(1000, 1500), op_time = jiffies)

This one understandble and represents one operation.

> +#define at24_loop_until_timeout_begin(tout, op_time)           \
> +       tout = jiffies + msecs_to_jiffies(at24_write_timeout);  \
> +       while (true) {                                          \
> +               op_time = jiffies;
> +
> +#define at24_loop_until_timeout_end(tout, op_time)             \
> +               if (time_before(tout, op_time))                 \
> +                       break;                                  \
> +               usleep_range(1000, 1500);                       \
> +       }

Besides `while (true)`, which is a red flag for timeout loops,
these are done in an hack way. Just open code them in both cases, or
rewrite original one to keel it's semantics.

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2018-08-04 20:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-04 17:43 [PATCH] eeprom: at24: Fix unexpected timeout under high load Mark Jonas
2018-08-04 20:51 ` Andy Shevchenko [this message]
2018-08-16 17:45 ` [PATCH v2] " Mark Jonas
2018-08-17  9:01   ` Bartosz Golaszewski
2018-09-25 15:21   ` Bartosz Golaszewski
2018-08-05 12:26 [PATCH] " Jonas Mark (BT-FIR/ENG1)
2018-08-05 14:09 ` Andy Shevchenko
2018-08-06 11:39 Jonas Mark (BT-FIR/ENG1)
2018-08-14 12:50 ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHp75Veo__Zu_Uk5-CN5q_yEUHs0fDsKZu9van89JBX2Prs7-w@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=brgl@bgdev.pl \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.jonas@de.bosch.com \
    --cc=xin.wang7@cn.bosch.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).