Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1702467pxu; Tue, 24 Nov 2020 07:01:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJze8wJh/OBNKgeFpGe7004XtPfgjdX5Z5aDriklDvVfXtZ9Z8X+3PlcKcttFKLv7cfxQ4VX X-Received: by 2002:a50:9e05:: with SMTP id z5mr4148042ede.231.1606230108613; Tue, 24 Nov 2020 07:01:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606230108; cv=none; d=google.com; s=arc-20160816; b=YXxh+XaIQMw/n18+Zp59ci2Z3JTAGp99jG0FbKxbweTuuFatCnQz3eSTm/O2RtG3tj fkdomzx+wMsyBP9j3cHdrPFEIlS2mtXkmGEFOU0pxadS3cKOTmU54fuH5LxtQI0+GQ0B NwWHm+2+aQtjG1t8GR+UhiS22Z+JSn5ffIk+f9QPLA3Mvalo9WqwkNyI4zE71AtvO/oW Lj6DEDQjJ46zcYiAVVzF1uW462RyZ31HMuWZdj7vDoDBzgVH/0ob7o86bB0UMJQK5nKh NY2l1Z7oCJ1CdeGwVryn0PPxMFUS5ymvEf749d5o4Cvt+Z0u/3k0aBUjMSg66EZa5vCq 8IgQ== 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=J0J3E7b9p8oawWwuEj7kpUYKxWq5ce28QVykTXRpMWw=; b=fTxMjiSvrHo8ioYjEkoVmkK8sLO+wovBQPWtKnKcJXZKn1jh5yurv9nqhzXqKtx2I6 9Q+K+jMGIYW4s0SrgiVJxHkxTJrLb+y3HKclNJPY/sO0w2QeDT8kMfs2GxHSrucc8lfY 77xWjKdY2ETw+Ri4IWIr4NwKJCmIek1rdvzn2O+dR7aa2HXAavJad4TZw8baQiprl49a CG9ScqZ9781mrtDRm4UIdHOEHFwMyFmt6gnKi67Ig1GVNDb+lmshKHeLQjAnOoGKj+/m 33Nc+Ycc9yj3uyDe7611x3j1xnxFuG3s6mU9aqmJwQpfSbSdkbQu4bAlCJXYKT4UIQs+ GU2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=u05sgykD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si9644225edp.494.2020.11.24.07.01.23; Tue, 24 Nov 2020 07:01:48 -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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=u05sgykD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388981AbgKXO5B (ORCPT + 99 others); Tue, 24 Nov 2020 09:57:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728352AbgKXO5A (ORCPT ); Tue, 24 Nov 2020 09:57:00 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C596BC0613D6; Tue, 24 Nov 2020 06:57:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=J0J3E7b9p8oawWwuEj7kpUYKxWq5ce28QVykTXRpMWw=; b=u05sgykDakZ+56Z95sUEBTtjp o6F/rDI/sDO5xwz4tL2EqZb4Nczft02XO9EvJeef0tCFxtkfG3cgkaQo2KgjQLRGhubJNJpywtEIT ZFBFz89nuHKzIvvs8qkcu/caoeaqh24A3ZiVIv2g8JUdxJXbvGt/vnQHJOWj2xkQ4jtCEKb/qbtjb qQO41vt/Sa7p67hJ6Vvg4/cG25PG75Gw5FmDTMwNm/05G0mVRt7tosUcEVMZclmLUoITntUoYBOpV L1GN41vjd/d18I+Y1Sy6FW/DIQl7queUHwgp2UBZzvBBJs6xzJEujOXaF3Vbo/WQEFixU5PWuaWOs KIB7801zQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:35532) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khZkS-0007qo-Q0; Tue, 24 Nov 2020 14:56:52 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1khZkN-0007Qk-I3; Tue, 24 Nov 2020 14:56:47 +0000 Date: Tue, 24 Nov 2020 14:56:47 +0000 From: Russell King - ARM Linux admin To: Antonio Borneo Cc: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Yonglong Liu , stable@vger.kernel.org, linuxarm@huawei.com, Salil Mehta , linux-stm32@st-md-mailman.stormreply.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: phy: fix auto-negotiation in case of 'down-shift' Message-ID: <20201124145647.GF1551@shell.armlinux.org.uk> References: <20201124143848.874894-1-antonio.borneo@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201124143848.874894-1-antonio.borneo@st.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: Russell King - ARM Linux admin Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 24, 2020 at 03:38:48PM +0100, Antonio Borneo wrote: > If the auto-negotiation fails to establish a gigabit link, the phy > can try to 'down-shift': it resets the bits in MII_CTRL1000 to > stop advertising 1Gbps and retries the negotiation at 100Mbps. > > From commit 5502b218e001 ("net: phy: use phy_resolve_aneg_linkmode > in genphy_read_status") the content of MII_CTRL1000 is not checked > anymore at the end of the negotiation, preventing the detection of > phy 'down-shift'. > In case of 'down-shift' phydev->advertising gets out-of-sync wrt > MII_CTRL1000 and still includes modes that the phy have already > dropped. The link partner could still advertise higher speeds, > while the link is established at one of the common lower speeds. > The logic 'and' in phy_resolve_aneg_linkmode() between > phydev->advertising and phydev->lp_advertising will report an > incorrect mode. > > Issue detected with a local phy rtl8211f connected with a gigabit > capable router through a two-pairs network cable. > > After auto-negotiation, read back MII_CTRL1000 and mask-out from > phydev->advertising the modes that have been eventually discarded > due to the 'down-shift'. Sorry, but no. While your solution will appear to work, in introduces unexpected changes to the user visible APIs. > if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) { > + if (phydev->is_gigabit_capable) { > + adv = phy_read(phydev, MII_CTRL1000); > + if (adv < 0) > + return adv; > + /* update advertising in case of 'down-shift' */ > + mii_ctrl1000_mod_linkmode_adv_t(phydev->advertising, > + adv); If a down-shift occurs, this will cause the configured advertising mask to lose the 1G speed, which will be visible to userspace. Userspace doesn't expect the advertising mask to change beneath it. Since updates from userspace are done using a read-modify-write of the ksettings, this can have the undesired effect of removing 1G from the configured advertising mask. We've had other PHYs have this behaviour; the correct solution is for the PHY driver to implement reading the resolution from the PHY rather than relying on the generic implementation if it can down-shift. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!