Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5075948imd; Tue, 30 Oct 2018 11:34:34 -0700 (PDT) X-Google-Smtp-Source: AJdET5dtWvoden7p1wpb+PKX1rooQ/uXePA1IZA955lVwlD3yRmKiY8w9Fu1gXB1LGpkG/e4YioH X-Received: by 2002:a63:bd51:: with SMTP id d17mr8534639pgp.443.1540924474125; Tue, 30 Oct 2018 11:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540924474; cv=none; d=google.com; s=arc-20160816; b=01PIQdfTXsdR3Wkqme0IfhI6Gi2rWUYxYhtUewtbwEon3PRLz1aySg76m5PNOAcDZ4 LtmIpfU/U+oGUaWX6oRUZmtHf9XL40epz1+JlQi0UhW5DODxLncBlR9gISo3HvL4bacb 5hs+UYjm+FBChVNjxn914/2m5n+jQ8nikEySY5CEOj7+hPvolrr9yLRiZxfGuoxtHfDj d2uuYS/fm/4N9MjQTQEcLC0iMnHlvAsRxYBLiG6YmAADKc2DgKV482ve0sN0WGdzJL0a mk54bi5VOfvXAdLPLtHijNCNVZ0WOBBgkoWl78QPkzuAavmNLcSXiKe6NVbW20SwxJEq S+JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=NaxwuM3bbqWBbCi6BG+aJAPJN7INVv9trogffbM+Wyc=; b=UhL0e8mQwQQg/4JJvlOHTufhwkpuao3xEAgyVedOKhOdwXdhgpiJy+tOsmhqpj7SbA rnYexo2vQLXCIdWiLQZ5nM0jDotBnZeyyd1hVC1A2x6Vsu2MguLUS3uH5g+KEX9+UZdH DCYw9hz5QbDUlDfFFqTbqHaefsfiZAxKO2FWLwEIhC7quNw2y0qMUkCPl3Vw1Ydptm9t FOyyln4qnpjpc66WtnvKrzCEl0PgxAhg0cek/6eRTI0cuNAXvcx/eYQ0RIoWoHZvPCMN /9GZR1Ky81dxBYi9q9X3tZDmXxX0muFLTBR0TRaYzMWgrK+dAZuRZI5anuZ8r6lMxUEH efew== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g189-v6si24094235pgc.204.2018.10.30.11.34.08; Tue, 30 Oct 2018 11:34:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728127AbeJaDTq (ORCPT + 99 others); Tue, 30 Oct 2018 23:19:46 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:58074 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725988AbeJaDTq (ORCPT ); Tue, 30 Oct 2018 23:19:46 -0400 Received: from localhost (c-67-183-62-245.hsd1.wa.comcast.net [67.183.62.245]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id E056814076BDE; Tue, 30 Oct 2018 11:25:11 -0700 (PDT) Date: Tue, 30 Oct 2018 11:25:11 -0700 (PDT) Message-Id: <20181030.112511.957438343014682098.davem@davemloft.net> To: kurt@linutronix.de Cc: anirudh@xilinx.com, John.Linn@xilinx.com, michal.simek@xilinx.com, radhey.shyam.pandey@xilinx.com, andrew@lunn.ch, yuehaibing@huawei.com, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] net: axienet: recheck condition after timeout in mdio_wait() From: David Miller In-Reply-To: <20181030093139.10226-2-kurt@linutronix.de> References: <20181030093139.10226-1-kurt@linutronix.de> <20181030093139.10226-2-kurt@linutronix.de> X-Mailer: Mew version 6.7 on Emacs 26 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Tue, 30 Oct 2018 11:25:12 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kurt Kanzenbach Date: Tue, 30 Oct 2018 10:31:38 +0100 > The function could report a false positive if it gets preempted between reading > the XAE_MDIO_MCR_OFFSET register and checking for the timeout. In such a case, > the condition has to be rechecked to avoid false positives. > > Therefore, check for expected condition even after the timeout occurred. > > Signed-off-by: Kurt Kanzenbach ... > if (time_before_eq(end, jiffies)) { > - WARN_ON(1); > - return -ETIMEDOUT; > + val = axienet_ior(lp, XAE_MDIO_MCR_OFFSET); > + break; > } > + > udelay(1); > } > - return 0; > + if (val & XAE_MDIO_MCR_READY_MASK) > + return 0; > + > + WARN_ON(1); > + return -ETIMEDOUT; You are not fundamentally changing the situation at all. The condtion could change right after your last read of XAR_MDIO_MCR_OFFSET, which is the same thing that happens before your modifications to this code. It sounds more like the timeout is slightly too short, and that's the real problem that causes whatever behavior you think you are fixing here. I'm not applying this.