Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4629732imd; Tue, 30 Oct 2018 05:13:20 -0700 (PDT) X-Google-Smtp-Source: AJdET5eQTnkFKUuDTTKhsi8oK0y5rglVaV9MsOvqVWTo2qsenY8I/IntQsyVYnjiPzlsfLImQ/nN X-Received: by 2002:a63:a612:: with SMTP id t18-v6mr17639800pge.338.1540901600573; Tue, 30 Oct 2018 05:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540901600; cv=none; d=google.com; s=arc-20160816; b=M1/qpC2ibVs+SpBRXh7mZ8NxlsX29ozdhFRUT67uwyWNQ07fT4olQ++qlNm1f6qG9s 6FqIvGNP0ghp3Npwig2FvY1BsVcPv6/XgniE+RG5zAxiPCKaLnTHcCisMKpcPnZ5BB4Y 32D68UH7KpAcvCWDtifJcG7uLKRmf+LIqtOqnsjS/w49SeUyNN0Y6UTjvd8kYS03UIw1 bkcDFPKXZbHpxUyWt3IJ4U5E7jzvp/AvDCqllmafDxx8L02scQp1tboO3gxgOGu7R9gZ 7n67F2tuhy0uvpuV+9ohADJvaK73wvv1DYEXL+OSzhfSHy2koFuCihKMRm72A4FiKISC pj9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DA0W34KdCdXK/M1/fLBkxMH1gHDRPC+AUNQWiO2+iN0=; b=h2lvc9orlAcTaxjHw9iy9M2fO02DCB6+OTrLk+5p3yNqk9Okfnv7FL+E/PdczX5R7a JWJPfR/bDGQBW031hhCqCCUf/znBUXptG6tGt9Huo2O8eKGNKhpQwin2bmhGG91lb9jO Hk71sV46A89wMGosSZpj7f2tXIdw7omLvuIL3X26o7rb/T0/VTsHUHRT5X5aZs11/nJb 6Ilh6mFE2s7u/YHZtAaHukd1NAzm6sZ2Ru61EJRqn1m1gFBStbLjLzsUbEZSbaEvWUcM 0ZNVx7qQaxClhV8avy3YDgJ4AOy8DDBBCVuZLgy6vNQRPogoNr91tJFQieJgfMDPvR72 SDSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=s7ZAakij; 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 r12-v6si23203491pga.346.2018.10.30.05.13.04; Tue, 30 Oct 2018 05:13:20 -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=@lunn.ch header.s=20171124 header.b=s7ZAakij; 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 S1728028AbeJ3VDy (ORCPT + 99 others); Tue, 30 Oct 2018 17:03:54 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:46056 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727863AbeJ3VDy (ORCPT ); Tue, 30 Oct 2018 17:03:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=DA0W34KdCdXK/M1/fLBkxMH1gHDRPC+AUNQWiO2+iN0=; b=s7ZAakijiwU/THh9P3rH0x0//N+a8O59YT1lpdqG/Y7to0auMvCnFbIvLiabkYjg0gTQj0PO2Tw6G5J31dHRbk+w1y/uSuhRpHYQxUP9peFSAXJOlzeEG/nPy0QKE2RCJiNlmvc/MZM6kpUY5S0Ua/CvUvfaDDtSueMWX7kZbfA=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1gHSqs-0007U1-3i; Tue, 30 Oct 2018 13:10:30 +0100 Date: Tue, 30 Oct 2018 13:10:30 +0100 From: Andrew Lunn To: Kurt Kanzenbach Cc: Anirudha Sarangi , John Linn , "David S. Miller" , Michal Simek , Radhey Shyam Pandey , YueHaibing , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] net: xilinx_emaclite: recheck condition after timeout in mdio_wait() Message-ID: <20181030121030.GD27873@lunn.ch> References: <20181030093139.10226-1-kurt@linutronix.de> <20181030093139.10226-3-kurt@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181030093139.10226-3-kurt@linutronix.de> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 30, 2018 at 10:31:39AM +0100, Kurt Kanzenbach wrote: > The function could report a false positive if it gets preempted between reading > the XEL_MDIOCTRL_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 > --- > drivers/net/ethernet/xilinx/xilinx_emaclite.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c > index 639e3e99af46..957d03085bd0 100644 > --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c > +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c > @@ -714,19 +714,29 @@ static irqreturn_t xemaclite_interrupt(int irq, void *dev_id) > static int xemaclite_mdio_wait(struct net_local *lp) > { > unsigned long end = jiffies + 2; > + u32 val; > > /* wait for the MDIO interface to not be busy or timeout > * after some time. > */ > - while (xemaclite_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET) & > - XEL_MDIOCTRL_MDIOSTS_MASK) { > + while (1) { > + val = xemaclite_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET); Hi Kurt It looks like readx_poll_timeout() should work here. Andrew