Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3585388pxb; Mon, 24 Jan 2022 12:52:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZRcs9gErKl2NhqpSdiA3qGMz0rEEOX2uAFE2pv8NBRaGFz1L2VZqonQ/2S6aNAExwa+Nc X-Received: by 2002:a17:90b:1a85:: with SMTP id ng5mr73897pjb.53.1643057524054; Mon, 24 Jan 2022 12:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057524; cv=none; d=google.com; s=arc-20160816; b=PgMsk3OfbbkTGjjKbMPdPioGU38n14FgllnUECBBmAKXw37HIfr2zRq0BjBu5IDKpF PoVMRKr7a9Piiv/z2UlIxIPXl6Iw4uRupkpV7Q7fU6p/8KePtGEjc7e5ClVtxxpOv6WX VA62mLkUuK2/g4Ql0qIUBX2UxPgx3IATyFwqS+/BZ3DteOyCgCEnQo2/DUH1TeNDgGOi UjjXr2R/etdcA3tkqVjZ+bGrkXwL41Pr2+ECioVDm++UHnFiSUvKdjxlfMMd7TmDiPgC 1TdjV7WV/oS8rsr/dbFi9+yhcOPYQvj5ItOA4QNkdZN5KZH/6cUSqPwtpuVyQRxT6HQb sh2g== 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=x9OheLk3jZIo9i+IOiMGnHKQykEnXyFS3VE8q5kkge0=; b=XkuGTdRdjyaihjEqs6LOgrCIzTwOnjKxaFANe822OgK5EvIvkCVSrHCV6IFfOsfDJ4 ntdRJP6NklOek9JHCEmfiT7CX3U2GGoLuKGfbkB/O5oYCALleDavmBF47uGzsClQHebj ZyGA+85IIA0s3BQlwij6ud5uy6nWSM0RgrIM+fWLwlLcq6TjmK6vpHUPzwDeDNU4DQKJ QG+fmcwW+I68Vi5ePG1/t5fpImk7muIrtv65J9DrU0Rh3bM4cgrFBsbP8Yjb4//yY3EZ GkXO4kVBdO4vRdcPrD7NtugROMp7k5YNoZ60ZjfRcEje8T99gk0cVmqYBufPcGnWwVVK rQHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fTFhPB0Y; 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 n63si14369110pfn.298.2022.01.24.12.51.52; Mon, 24 Jan 2022 12:52:04 -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=fTFhPB0Y; 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 S1377435AbiAXUFa (ORCPT + 99 others); Mon, 24 Jan 2022 15:05:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343914AbiAXTrs (ORCPT ); Mon, 24 Jan 2022 14:47:48 -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 72947C061797; Mon, 24 Jan 2022 11:23:26 -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 2E55BB8119D; Mon, 24 Jan 2022 19:23:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CCE6C340E5; Mon, 24 Jan 2022 19:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052203; bh=eGU5BZn9pv3lxR8n0x8YyiDNk3dQsF9nkslcgbj7S0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fTFhPB0YhSaEjwXeQ/ilTQQE8jVv4OZMefVM5QjKho1wQkvqiU+/ui8+iAQlGvP+e rq6sFhMwLLzcfm5vTMHh+s1xFMv4jod4YCCb1Jpdg5PDptxgvsT0xnaKdDNYED9yRg ABJWQI4fOZvRQ/yQoTB7rnDat7AExnR46accAj54= 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.19 223/239] net: axienet: Wait for PhyRstCmplt after core reset Date: Mon, 24 Jan 2022 19:44:21 +0100 Message-Id: <20220124183950.200828682@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@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 @@ -279,6 +279,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);