Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1912952imm; Sat, 4 Aug 2018 13:53:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeHjKPUlSRzjfq4W0hGPVqadJDXIIrEs1W4otrIYfVao+vuYw5kLlOaDLkx+gYp1iRpxizB X-Received: by 2002:a62:998:: with SMTP id 24-v6mr10160140pfj.99.1533416006694; Sat, 04 Aug 2018 13:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533416006; cv=none; d=google.com; s=arc-20160816; b=K7Anx+SzQg1dz3Qngqi52HyrEi/2oiFY/AdKNDUq+wP//S5ttWn/La6UZux0qDp5xa S2lhAn7khPBOVCEqaQP/VLQgyBBDyNxOyb4EFF1/QyO2L6haeAQfRBlcYu/xvFSgZpCz nuriZaj9HskcEkAJaKwK6yOQa4h4cIhYWe66xmz6to67Yu3CbZCEEJx9/S2yTRWIbQBi mJvAKrPIF+k2iq9E23yg2gCjro24Xg8sW1ow9M3q07VqD/Z3ESiwXFrvJ7DagumCjXCc 844K0fgSC+ecMyJs4F2nzLGtQg+7to7mrdk1Lmu5GDPsMGxDCjoll+UegX8r9FdUcreT 2gtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Jxpw+xVPbIb6+LuL1gBVbF9RgLCzuiDcxE23GzFxzU4=; b=PD4wL4BoNgVGJFA3acZ97tKtOcePUlkwik5BK9qUpbDTeY3wBKG7z9ZkE3gXTUfSM2 fTKPi7iVSQTQ95sBb1D6WwOe/fWLErAj7ZxrwQEFJr/ey4xXiNyBh6/nVX1n1LiNUwxh bGpr3plF60KkmvJv3amRfY7ftzS/JQQtiZuF2nDj4RDtqpXRjH3i6G9MYHXRvMxw4WTI byWmhJRupUAEefkHBK9jK5gTNOhlSoIOMmT5GhgntfgF593RUmmSjaf+ojdmxxVVF6x6 GLx/xUHqJqbt/QaLDCV8+2+KBFb5TW58cb/IOs7unkR07RacWmNnOW8qU4rjvsEN/aR7 hv6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HtGukRAo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5-v6si6392165plk.304.2018.08.04.13.52.59; Sat, 04 Aug 2018 13:53:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HtGukRAo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729651AbeHDWxe (ORCPT + 99 others); Sat, 4 Aug 2018 18:53:34 -0400 Received: from mail-ua0-f193.google.com ([209.85.217.193]:39628 "EHLO mail-ua0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728309AbeHDWxe (ORCPT ); Sat, 4 Aug 2018 18:53:34 -0400 Received: by mail-ua0-f193.google.com with SMTP id g18-v6so8167940uam.6; Sat, 04 Aug 2018 13:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Jxpw+xVPbIb6+LuL1gBVbF9RgLCzuiDcxE23GzFxzU4=; b=HtGukRAoZiTEMBXy0p1U17dkZpN2XHcKGFJRIy6Y9amCNutXN3HHgGOtB3ma75KCQ6 uZ87HuVxjSfBtsEr2A0B6cVXI/b9GNnDWh4rbiEzdDzFfQDHAibSSD6WzH5vZDJx/Z7I 6/z2EnAw+lpRCCFwv6kuglC4ownqeCYoOjJen89mlVQqtRD856dgONGksAxBvCo+QeHq M5Z/EPt68/r1xYZP7fOAe2wmURQgHIlDieeHH+FsWo0qis4MRIXW84WdKgaMa+GSwtKC dirsgPWypyUyaMEahP5TgMINf05TXw+tcmCsmzfD+UNf9Zta0pFXKTsQvHfjDMVRbyzC +ONA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Jxpw+xVPbIb6+LuL1gBVbF9RgLCzuiDcxE23GzFxzU4=; b=BuvXrlOv91mqo9G1gK0zaXrF3HwsshcBYCEQDVJ+qep73ke6Vg4VdZjvNG7kfS4g3o NaiHHYw75bhUs5/SPQv/RCKzRkOjsZwBWT0/wqPLyaN2r7qTTTPuztkKrUcQRmrA+cPt smEAVhaKxE3iu2ilWRr5qMXe3Sw6DLCLR0kChZaGNi+JXDzJMt/C+cmyucUUyZVPqrgl DPUL7pLn1j+itHEONiW68IiyBRpfJ/nXLjvKWLsyeqtsM7Xez4jRQM7GPWMl9oHQWkDQ GzTusQ8tqClGsR5mFYJAFy51rXHlPLd31vR3lNwG2b2BX4mPOpKox50pKredCT4eAhlW ZzFg== X-Gm-Message-State: AOUpUlFp3vEQ44VDvNpsIQCQi78EIRxQRuW9eda4gTPdRvmWUVPQUOJe S9qXeBYXBjnxe2uWe6Mglpw5rAL6DctulTPpX1Q= X-Received: by 2002:ab0:13c7:: with SMTP id n7-v6mr6432941uae.47.1533415898600; Sat, 04 Aug 2018 13:51:38 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:2149:0:0:0:0:0 with HTTP; Sat, 4 Aug 2018 13:51:37 -0700 (PDT) In-Reply-To: <1533404620-18536-1-git-send-email-mark.jonas@de.bosch.com> References: <1533404620-18536-1-git-send-email-mark.jonas@de.bosch.com> From: Andy Shevchenko Date: Sat, 4 Aug 2018 23:51:37 +0300 Message-ID: Subject: Re: [PATCH] eeprom: at24: Fix unexpected timeout under high load To: Mark Jonas Cc: Bartosz Golaszewski , Arnd Bergmann , Greg Kroah-Hartman , linux-i2c , Linux Kernel Mailing List , Wang Xin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 4, 2018 at 8:43 PM, Mark Jonas 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