Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10907ECDFA1 for ; Tue, 25 Oct 2022 12:51:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1EE9580716; Tue, 25 Oct 2022 14:51:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="V6daSegX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9E1A0806DE; Tue, 25 Oct 2022 14:51:10 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2070.outbound.protection.outlook.com [40.107.220.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 753A884D44 for ; Tue, 25 Oct 2022 14:51:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=michal.simek@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S9admgwyGFXKKBzq0pMLeO1qne0yCD+toKaxtxlNzfW+LZFxrftHdlLlDVFOb8yYRdHfzSM7TDRbZqmufOnoRsZGSwv2cetdVZgvMkrbCOzWkKTDkWjWyuhZDDEGBmYhzJ3uqqeOAF0O0h1dpXwyqHlH6jUdIua7Ab56KXC9kDT55pIy5QySA+u/C1OPHLM0M2vrMG+YFbCtX2zC9lS42sn8V49mY64i9kr8A7uF1maCmxxNXp+5PVwlexRKFTIEZuxS4Ykon+UgTvViCIpVIaXB3/egq138A196OtChuHPxmTpjZPch13lYYdSjebEHD4ERj1/zymzTUowVufPvzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qM2n5lUOQMSLxXuuQkCPVVFvAH2pGBSHyslIcMYt1mA=; b=JAe5bo1C+iMJxPfGd5cdfvVP5r6sLcm+uYS6lRa9xPHWvwrwiuuW1+aMXK5RRkQEgrd8aoXOO/HZx4tb4PMGebFW6itZGzlJqRBC21H6D2O3RoPGEW1Gf7BRh5kWOGYaXwwpDz8HaCG8cKFh1RqDjvYbz2+eUx4qVz3qtFZA2KCJAVyNK3/HHfzEuXZSKhxepzT5XV279AC9Gute8wkVt2QDxmXtZD8dhfIzA7OixqGoe5l3/aCKC17j9dOW82Z0lh2KOFzbTbM/73/Ze+ZivIuhffY48AxggR+mwSkZzvFdKZpuSb6p3s5AFRlkdCP4yTImTdnvJ6iBciMKSgyusA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sifive.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qM2n5lUOQMSLxXuuQkCPVVFvAH2pGBSHyslIcMYt1mA=; b=V6daSegXBmkmt2vQQFHsOReEVwy5S5OLcX2TbdukkcVUSfDVty3tG/nDPJKYj8BLDqFzZjMCRq0SOA0V575aq3ZDoIv/cr+RI2yNt6eswEBHmCjp7FXcf+kqBX1ZQS3MSW2jsNzN6+XeczsnU21pOW7XjOfSmTaJlEFozLrllEU= Received: from DS7PR05CA0018.namprd05.prod.outlook.com (2603:10b6:5:3b9::23) by DM4PR12MB7765.namprd12.prod.outlook.com (2603:10b6:8:102::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.35; Tue, 25 Oct 2022 12:51:02 +0000 Received: from DM6NAM11FT104.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b9:cafe::11) by DS7PR05CA0018.outlook.office365.com (2603:10b6:5:3b9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.8 via Frontend Transport; Tue, 25 Oct 2022 12:51:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT104.mail.protection.outlook.com (10.13.173.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Tue, 25 Oct 2022 12:51:02 +0000 Received: from [10.254.241.52] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 07:50:59 -0500 Message-ID: <7ddde0aa-d25a-1aeb-7e7a-d5762e283c1e@amd.com> Date: Tue, 25 Oct 2022 14:50:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Content-Language: en-US To: Andy Chiu CC: , , , References: <20221017111928.462866-1-andy.chiu@sifive.com> <20221017111928.462866-3-andy.chiu@sifive.com> From: Michal Simek Subject: Re: [PATCH 2/2] net:xilinx_axi: check PCS/PMA PHY status in setup_phy In-Reply-To: <20221017111928.462866-3-andy.chiu@sifive.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT104:EE_|DM4PR12MB7765:EE_ X-MS-Office365-Filtering-Correlation-Id: d62da605-9dd7-43d6-283b-08dab6879285 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iep2QM61h2JDh4vmJ78au72OUU3eUAlow+//EZk1rD7mBePAMJUBOpK+3UhoesXZ0Vd+kgKr17Fzk5ihII8SuD7GXQyEqE6EL3O+h/e/mcPCWPx9UZJCGfeY/qDTETxLQt7dl4zK0KdiQ7LrIzOyHX88UuC/mtFfIhTwh+nRseQyGiSUCdKupG3XByT4L5yn4POdh5XU71gT4lXPO8EbP7eLKARLBl56l9ViW009wZ1Lh5hn/JTGAtThattLooQrUPx/ZfmpYNe9vBk8YjdU+w6WKet+X35pXJoyh+bU1zoqVRNPZu5W9Om+asQnsoZ2EwHqu8AoOKtrJ67P5hjdRMR8Q0+kFUW3DknJ6ON9CHdPzY/f3YR5GUVHGmRAKk95R0IDwvlFzdAuTgITdQSEeB4RKWVBqAATap21tqrUqNkLhPar0GP7pem2qfcMUZ6Cyn7z7ZXmu0Zl4wsJJSyIyfKMsMTSEwWtv5dbq413Bh6iKgb5PYXfZi6Zw9XzebwSOBp5GW2nJ9i5KCBZ0/gyok+M61D93S+Bgid6s6vRWtACqx16oL5MKWMGs18HblOaVZTojkYwtJralqMieMrT6UnQpKLehrgEtTPlNUvnq1rx2bXQU7ogOjZf+JNN+G7/7he37OByGcIJ7ZkJhUoJks+7nLwcgGI5e2QNUu1/5B5N4A2w9ZzsUxT/PnrP6po/CRDEg0VzwNsq+Cng1HrXHdcAgakXqYwGntEiHxFOWu6n1nBSXjEOfGT+T5V/BclY16nmWTWYdbYuSmMHqoQQwxPaN6BmUJKp1Tku3xUT0yM6MnJEGV/3HWfDcWFfQGLlObfAxYmPmmixGL8LjMRGOw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(376002)(136003)(346002)(396003)(39860400002)(451199015)(46966006)(40470700004)(36840700001)(16526019)(426003)(2906002)(47076005)(186003)(83380400001)(31686004)(86362001)(336012)(26005)(40460700003)(8676002)(53546011)(41300700001)(81166007)(4326008)(40480700001)(356005)(36756003)(16576012)(2616005)(54906003)(82740400003)(31696002)(6916009)(82310400005)(36860700001)(5660300002)(70586007)(478600001)(8936002)(44832011)(70206006)(316002)(43740500002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 12:51:02.0605 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d62da605-9dd7-43d6-283b-08dab6879285 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT104.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7765 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Also add missing space in subject. On 10/17/22 13:19, Andy Chiu wrote: > Both PCS/PMA PHY and the external PHY need to have a valid link status > in order to have Ethernet traffic. Check and wait this status at > setup_phy() so that we could diagnose if there is a PHY issue. > > Signed-off-by: Andy Chiu > Reviewed-by: Greentime Hu > --- > drivers/net/xilinx_axi_emac.c | 43 +++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c > index 447e1d4c9c..257ab4661e 100644 > --- a/drivers/net/xilinx_axi_emac.c > +++ b/drivers/net/xilinx_axi_emac.c > @@ -336,6 +336,44 @@ static int axiemac_phy_init(struct udevice *dev) > return 0; > } > > +static int pcs_pma_startup(struct axidma_priv *priv) > +{ > + u32 rc; > + u32 retry_cnt = 0; group them together. > + u16 mii_reg; > + > + rc = phyread(priv, priv->pcsaddr, MII_BMCR, &mii_reg); > + if (rc) > + goto failed_mdio; > + > + if (!(mii_reg & BMCR_ANENABLE)) { > + mii_reg |= BMCR_ANENABLE; > + if (phywrite(priv, priv->pcsaddr, MII_BMCR, mii_reg)) > + goto failed_mdio; > + } > + > + /* Check the internal PHY status and warn user if the internal PHY is > + * not resetted reset > + */ > + printf("axiemac: waiting for link status of the PCS/PMA PHY"); I think that you likely not need to see this message in normal run. I would move it to debug. Keep only error message. ZynqMP> ping 192.168.10.20 ethernet@80000000 Waiting for PHY auto negotiation to complete. done axiemac: waiting for link status of the PCS/PMA PHY.Done Using ethernet@80000000 device host 192.168.10.20 is alive > + while (retry_cnt * 10 < PHY_ANEG_TIMEOUT) { > + rc = phyread(priv, priv->pcsaddr, MII_BMSR, &mii_reg); > + if ((mii_reg & BMSR_LSTATUS) && mii_reg != 0xffff && !rc) { > + printf(".Done\n"); > + return 0; > + } > + > + printf("."); genphy_update_link() is using if ((i++ % 10) == 0) printf("."); > + retry_cnt++; > + mdelay(10); > + } > + printf("\n\tWarning, PCS/PMA PHY is not ready, link is down\n"); newline. Are you sure about \n\t . I can't see any advantage of it. > + return 1; newline here. > +failed_mdio: > + printf("axiemac: MDIO to the PCS/PMA PHY has failed\n"); newline > + return 1; > +} > + > /* Setting axi emac and phy to proper setting */ > static int setup_phy(struct udevice *dev) > { > @@ -367,6 +405,11 @@ static int setup_phy(struct udevice *dev) > phydev->dev->name); > return 0; > } > + if (priv->interface == PHY_INTERFACE_MODE_SGMII || > + priv->interface == PHY_INTERFACE_MODE_1000BASEX) { > + if (pcs_pma_startup(priv)) > + return 0; > + } > if (!phydev->link) { > printf("%s: No link.\n", phydev->dev->name); > return 0; M