From patchwork Fri Apr 5 19:23:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 1078656 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kwfocbyD"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44bV8s01fPz9sNB for ; Sat, 6 Apr 2019 06:23:24 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731812AbfDETXX (ORCPT ); Fri, 5 Apr 2019 15:23:23 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34061 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731760AbfDETXW (ORCPT ); Fri, 5 Apr 2019 15:23:22 -0400 Received: by mail-wr1-f65.google.com with SMTP id p10so9300757wrq.1 for ; Fri, 05 Apr 2019 12:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=mONn8qWg8BKNy1aKKkwZ76Jyo4xLoot6Ei7hfEtL/fU=; b=kwfocbyD/K+g72p+BgUT4jbe4A+DRTZ/XwsxBN49UyzOvipYZFJuQS6RlybkI8th3/ WyFZK24P4xBFJ6yBTi5R9cMdRiKQVnD9WXiMVbzzNERlBKyprr8zsm6QTlKHGuYPbogH JpxEt1y+2JHjzf2jItLjm8pDOn+WYhNg7ms7j5P0/imO2Stm8H3uRCrxPQgQChUt7V4z oALmBvbWyzm8mMalwcadGJGB2Zy1PkWUdAu0ZHB0bPzvnUdqe750Ck6eZZp1nIkDaK2e t0x0CVBUssqGMFWfqR7N7Xz6SyvNT/rNIXjp4TUA0WlSEmTSc0PkMdb3nTCLJ9XLnvrI UjKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=mONn8qWg8BKNy1aKKkwZ76Jyo4xLoot6Ei7hfEtL/fU=; b=sB1B6+YWYU8uCHfjkNwnk5EaRMZlgaJUNfG7L2z7rvaVUm2tGjwaCKsahCDAOu5but 9DV9dNJctVcirf4Z+UMO57Xj33QFWVxOG5CCbxg5Iw/MYftf66zm3ZhHCPG+nLU7MA/y k6ssxEcgDQi2A1wuabmg8pVHIYQj5INJo8BN1BumgcV8qKnQbvaDYwh+b8Zzbf5NDMLh NlGMeBWRMJ3GYMevt1p1FHl5TvfnG5GPZRf+LgfIs5F+VNmw50yqp3ah75WrqeXMM1WK ZhEE7bbZBtCOV+2VydG6DMzCN2twA9bBLeSQ8sPeOuBrONs4sTCmDlKTot2c0SrtYb/w QR6g== X-Gm-Message-State: APjAAAXsX0PTuBq9eEylqhcTUfuy66t0OF32Mgf9D7Rut7CPg195OgSu R7sEkN/kpJpNqrqbXuk6FZ2N0GOG X-Google-Smtp-Source: APXvYqz18ffOQOxSytgZ6swW7FXu3cGkVwzo/3wqbe8Uixz9YQnNrzKpBZ9d5Y5xnwDdpD7u6Tyf+g== X-Received: by 2002:a5d:5111:: with SMTP id s17mr9563541wrt.159.1554492200774; Fri, 05 Apr 2019 12:23:20 -0700 (PDT) Received: from ?IPv6:2003:ea:8be1:dd00:c5f4:1013:b1cb:d123? (p200300EA8BE1DD00C5F41013B1CBD123.dip0.t-ipconnect.de. [2003:ea:8be1:dd00:c5f4:1013:b1cb:d123]) by smtp.googlemail.com with ESMTPSA id w18sm35268587wru.24.2019.04.05.12.23.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2019 12:23:19 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH net-next] net: phy: improve link partner capability detection To: Andrew Lunn , Florian Fainelli , David Miller Cc: "netdev@vger.kernel.org" Message-ID: Date: Fri, 5 Apr 2019 21:23:13 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org genphy_read_status() so far checks phydev->supported, not the actual PHY capabilities. This can make a difference if the supported speeds have been limited by of_set_phy_supported() or phy_set_max_speed(). It seems that this issue only affects the link partner advertisements as displayed by ethtool. Also this patch wouldn't apply to older kernels because linkmode bitmaps have been introduced recently. Therefore net-next. Signed-off-by: Heiner Kallweit Reviewed-by: Florian Fainelli --- drivers/net/phy/phy_device.c | 12 ++++++++---- include/linux/phy.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index f7a6d0ffb..dab3ecbb4 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1756,10 +1756,7 @@ int genphy_read_status(struct phy_device *phydev) linkmode_zero(phydev->lp_advertising); if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) { - if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, - phydev->supported) || - linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, - phydev->supported)) { + if (phydev->is_gigabit_capable) { lpagb = phy_read(phydev, MII_STAT1000); if (lpagb < 0) return lpagb; @@ -2154,6 +2151,13 @@ static int phy_probe(struct device *dev) if (err) goto out; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, + phydev->supported)) + phydev->is_gigabit_capable = 1; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + phydev->supported)) + phydev->is_gigabit_capable = 1; + of_set_phy_supported(phydev); linkmode_copy(phydev->advertising, phydev->supported); diff --git a/include/linux/phy.h b/include/linux/phy.h index ab7439b3d..0f9552b17 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -345,6 +345,7 @@ struct phy_c45_device_ids { * is_c45: Set to true if this phy uses clause 45 addressing. * is_internal: Set to true if this phy is internal to a MAC. * is_pseudo_fixed_link: Set to true if this phy is an Ethernet switch, etc. + * is_gigabit_capable: Set to true if PHY supports 1000Mbps * has_fixups: Set to true if this phy has fixups/quirks. * suspended: Set to true if this phy has been suspended successfully. * sysfs_links: Internal boolean tracking sysfs symbolic links setup/removal. @@ -382,6 +383,7 @@ struct phy_device { unsigned is_c45:1; unsigned is_internal:1; unsigned is_pseudo_fixed_link:1; + unsigned is_gigabit_capable:1; unsigned has_fixups:1; unsigned suspended:1; unsigned sysfs_links:1;