Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6095268imd; Wed, 31 Oct 2018 06:49:01 -0700 (PDT) X-Google-Smtp-Source: AJdET5ev1j4RKD9gIQq3EjGBZLPXSVveQ8zwUg50duIjWdaQdX2qwmKHZlvbKOLvvjajqrP1J57J X-Received: by 2002:a63:2a11:: with SMTP id q17-v6mr3261240pgq.374.1540993741320; Wed, 31 Oct 2018 06:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540993741; cv=none; d=google.com; s=arc-20160816; b=RmBPJ99gIwe5lVbTm+8byz5JMlzyzTDhJzua6jlvPPUwBMG7MMhrn16nMIVFpjAtnx qIgEH4batpGkRtE7ypmaDmXUyvfGNnQb0O4KyFcDlsnFzVCNk/OiIBYosU1QeiGiHQTs IfLfmx9wNN0XTpdQGKJ8H2vERKl3wBX5Y2r5whDcbONIFhur0HS0+5EfhEPkorNERx6b sIuXz7c3GeI92Pe1iTPcZfyCVpFMz6B5kaPGCrYud1JCP8jdSRQ+MB1Tm510KK3wNNAo CMznjd4xw7S8Ef0/jrYPI5gu2WP2h23/mfN8ZJ7240Fym9MTh54IEaK5wHkhy+w/wi4l jufw== 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=VvzyrPCQQvm51D8pcXiYfmEq+4lollpwZhoa5CLFeEo=; b=EClfD46tJX5Cp85OZzTG+DMvWswD/k+gRHcv3bDdmKxrERYK5LIDX51PbDykrYOJZw BnvvFtzKgBIQHxCpswWkzrmiUA8NYi2+K8OxQKZb18BkMMradOMaHRlhKOAvOdHaKGv4 rvfDyTkjLNNCuO3eC4i4hlZ+M4kjJIDvk/NYec7CVKTJJZ7a/z3MiQiwAa/V3gWMtmWI 9vsDjFI5P8QsDjZI0AHMsb6c7m7Q9DiMq553Zn8+xNBjdl9+jp6lJngeUFkv6qzJbgcW rNtLyw5kwZJPP4jIOLSmyNzMchmHY1boZf4OPkLLxsgj1MXhMEH6hBljls/ViSMgYA8q /T3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=pM8kZQD6; 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 a70si12665740pge.421.2018.10.31.06.48.46; Wed, 31 Oct 2018 06:49:01 -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=pM8kZQD6; 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 S1729330AbeJaWqV (ORCPT + 99 others); Wed, 31 Oct 2018 18:46:21 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:47183 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728849AbeJaWqV (ORCPT ); Wed, 31 Oct 2018 18:46:21 -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=VvzyrPCQQvm51D8pcXiYfmEq+4lollpwZhoa5CLFeEo=; b=pM8kZQD6c8Ng9jdk5hYhHqf7vSu5bmrP2xDE9t5A9hQHV8k8RlBUZECELZ6ywnrqKfUYVr7NwKNm1yNw8UjfUG2UXr7PB7z6aq1AXqNJIol03xssmgGaJ70ENWziGQgzhr5Z+al86F9eti23v6sMV2KLr1X3AMyZnS6VLNqBph8=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1gHqqw-0005mJ-Bg; Wed, 31 Oct 2018 14:48:10 +0100 Date: Wed, 31 Oct 2018 14:48:10 +0100 From: Andrew Lunn To: Harini Katakam Cc: nicolas.ferre@microchip.com, davem@davemloft.net, claudiu.beznea@microchip.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, michal.simek@xilinx.com, harinikatakamlinux@gmail.com, Harini Katakam , Shubhrajyoti Datta , Sai Pavan Boddu Subject: Re: [PATCH 1/4] net: macb: Check MDIO state before read/write and use timeouts Message-ID: <20181031134810.GD20889@lunn.ch> References: <1540957223-30984-1-git-send-email-harini.katakam@xilinx.com> <1540957223-30984-2-git-send-email-harini.katakam@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1540957223-30984-2-git-send-email-harini.katakam@xilinx.com> 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 Wed, Oct 31, 2018 at 09:10:20AM +0530, Harini Katakam wrote: > From: Harini Katakam > > Replace the while loop in MDIO read/write functions with a timeout. > In addition, add a check for MDIO bus busy before initiating a new > operation as well to make sure there is no ongoing MDIO operation. > > Signed-off-by: Shubhrajyoti Datta > Signed-off-by: Sai Pavan Boddu > Signed-off-by: Harini Katakam > --- > Changes form RFC: > Cleaned up timeout implementation and moved it to a helper. > > drivers/net/ethernet/cadence/macb_main.c | 44 +++++++++++++++++++++++++++----- > 1 file changed, 38 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c > index 0acaef3..b4e26c1 100644 > --- a/drivers/net/ethernet/cadence/macb_main.c > +++ b/drivers/net/ethernet/cadence/macb_main.c > @@ -318,10 +318,36 @@ static void macb_get_hwaddr(struct macb *bp) > eth_hw_addr_random(bp->dev); > } > > +static int macb_mdio_wait_for_idle(struct macb *bp) > +{ > + ulong timeout; > + > + timeout = jiffies + msecs_to_jiffies(1000); > + /* wait for end of transfer */ > + while (1) { > + if (MACB_BFEXT(IDLE, macb_readl(bp, NSR))) > + break; > + > + if (time_after_eq(jiffies, timeout)) { > + netdev_err(bp->dev, "wait for end of transfer timed out\n"); > + return -ETIMEDOUT; > + } > + > + cpu_relax(); > + } > + > + return 0; > +} Hi Harini Could you make use of readx_poll_timeout(). You will need to add a helper for the read of the register, since readx_poll_timeout() only allows one parameter. Otherwise, this looks O.K. Andrew