Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3548591pxb; Mon, 24 Jan 2022 11:58:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW07S3drqEVgaCaN+i5PtQ+ZRwyLKqkjvTJNvVPoqooBFAGv0YV0uBOznDjzSjfeFLrEMx X-Received: by 2002:a63:a706:: with SMTP id d6mr12722715pgf.584.1643054338254; Mon, 24 Jan 2022 11:58:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054338; cv=none; d=google.com; s=arc-20160816; b=V0RRGNGSNRQarB65O1sw/hs2oXN2H+YcCJaEGednMNc7H6R08IjeffKyoq9hDz5RZJ egLjY7VWfc0jIQk2Nr5XxE9mQjiuy9Thl3L4/Bax7yUDyLW3WAbJqLrYtkkV5OKx4H3d oKjMSqGNXyeRCb5mHNpa6uPoolfjEOrI09OMyiwwG0ucto0YOCuCfAb/8YBflJvuwhCP VV6TuQ8sycxm44Y4VlAU++PfDQY7mMzzsIMHXfzOb0edmA04Og7awXigPVm4zwsARmKx vZvDVGwMpdtPwuUEXHw6EGWatVjPGlFyKVYsI/eZmeaw05xs0dE9IHZMfnaeMJedRulk 6RDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jXqDRPzG33G+Qk6eTkicO7KOObZ84Ka8Qm6T+o3L9rs=; b=WJH/1tYpj4/S3zo0DtSiopSN4gHldpIhJOeZ1kdTuY8sGPg7LsK4fRdxlt41XqBcgB v2H+sD0pmB7nStZ87lfdf0VJsCg79Uh/Htx3ojyoaMFBpplKZ35OWyaUPWCVCxOYdiLW Z0ZAKIim96GgLCBnxDGUd+mbg9+a5Os6CQGjcBnTTjge8phjD9p25wcivw4cdtQwJj5C SlBpit6jPcSAc4eX1LlIDOa3EUU3k/zi3iHXbEUK/AG2I9tTdxAOuNpXbg20Xh/Htsyh 29U6JXrrzgQL3uchPTpPUzFrtBEsHI6xSkUeOxe+CoQSPaGaKfcbajI2wewd49Ounjqf XYjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IS8KnmZS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si13826866pgi.368.2022.01.24.11.58.43; Mon, 24 Jan 2022 11:58:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IS8KnmZS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343918AbiAXS42 (ORCPT + 99 others); Mon, 24 Jan 2022 13:56:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343937AbiAXSyT (ORCPT ); Mon, 24 Jan 2022 13:54:19 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F25FC06173D; Mon, 24 Jan 2022 10:53:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 57DF0B8121A; Mon, 24 Jan 2022 18:53:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A2BEC340E5; Mon, 24 Jan 2022 18:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050399; bh=32uOvvkf5PwtZBQ1zKQge2AigcWs01gd5KpLT3qG+qQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IS8KnmZSLOw4K1E+DChIXdwIEvnvWafUg94qP7zsXApeLqfOE7rLUmPOgYPpdb0r3 E5FgSFFwSIhZWTjDaX3X0PTD+wnz963TIYntQoWHgNaMC5TC3RjFQ0JxfNxLkORyV/ fgFoxI4D5JbmOoaRiT741FZmiLajC6SOLQ/ZYZDw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hancock , Andrew Lunn , "David S. Miller" Subject: [PATCH 4.4 105/114] net: axienet: Wait for PhyRstCmplt after core reset Date: Mon, 24 Jan 2022 19:43:20 +0100 Message-Id: <20220124183930.351490754@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robert Hancock commit b400c2f4f4c53c86594dd57098970d97d488bfde upstream. When resetting the device, wait for the PhyRstCmplt bit to be set in the interrupt status register before continuing initialization, to ensure that the core is actually ready. When using an external PHY, this also ensures we do not start trying to access the PHY while it is still in reset. The PHY reset is initiated by the core reset which is triggered just above, but remains asserted for 5ms after the core is reset according to the documentation. The MgtRdy bit could also be waited for, but unfortunately when using 7-series devices, the bit does not appear to work as documented (it seems to behave as some sort of link state indication and not just an indication the transceiver is ready) so it can't really be relied on for this purpose. Fixes: 8a3b7a252dca9 ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver") Signed-off-by: Robert Hancock Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -278,6 +278,16 @@ static int axienet_dma_bd_init(struct ne axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr | XAXIDMA_CR_RUNSTOP_MASK); + /* Wait for PhyRstCmplt bit to be set, indicating the PHY reset has finished */ + ret = read_poll_timeout(axienet_ior, value, + value & XAE_INT_PHYRSTCMPLT_MASK, + DELAY_OF_ONE_MILLISEC, 50000, false, lp, + XAE_IS_OFFSET); + if (ret) { + dev_err(lp->dev, "%s: timeout waiting for PhyRstCmplt\n", __func__); + return ret; + } + return 0; out: axienet_dma_bd_release(ndev);