From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9BC0C10F06 for ; Sat, 6 Apr 2019 16:25:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97F9A2133F for ; Sat, 6 Apr 2019 16:25:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="To2+FrGU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726489AbfDFQZh (ORCPT ); Sat, 6 Apr 2019 12:25:37 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38795 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726404AbfDFQZh (ORCPT ); Sat, 6 Apr 2019 12:25:37 -0400 Received: by mail-wm1-f68.google.com with SMTP id w15so10265123wmc.3 for ; Sat, 06 Apr 2019 09:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=SCEjWWW06NyEra2bfnRuS9yPcYhFgAo17HOqp6xn7rc=; b=To2+FrGUJgoEC5V64wnD2bk1yTgxNJ8peIsjMJ98dlltzj7qq3jhaPJMlQEn8/n9w0 hM49oBvhXEuTz0lo6N0BpFoR4IHRRFpcxqmKNqcZVVYKpE6ibcP05uR76ZcyJyBY6Vef mcrtvLCGZfNxLdu1bZTtGH6JnlAsvtOQqUPGFHcVfPLLdWqIF6t1oBpw0kRbmV/E9xKL p3YbKMW1+sE+jngcuHhAXSHJLBRi9nFwn0MEiyd4QSy9rmQwwHg/0RJCEKLrnH7kpCQg zzeUPLuV0RJI+Kqw14upNRCQySezC+TTMRSh8483OkDQ+hA0/oCE1kRYWFVfS0cesAES A86A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=SCEjWWW06NyEra2bfnRuS9yPcYhFgAo17HOqp6xn7rc=; b=gn/8dmoSBLfSR6ezqR/sFMsHOx5XS7cRsEIxlT52HE5adrusErOwQtVWG0hcNRMyba I1acziM1ZNqZjJPp4VaJe6Xy4hWAN/OswPRKxr2uvkRwvPLKbLdnD/E/e8EgbDvaXL8J o/1/ugshOAv9zoPyktdCop+pGO7RNbUWz5Tu9kO6NcQpvISjI87qh0Ofam7MdOkp30dv QRK5qWHmRrU5BAD9EnG740gCI9/+58ofYbM0uvVYr6H3wUDwmMcUHpjNIaG60cVeQNzF 1bv4ESS0uTH6YL+hDqHGWIv3BFRU7uRmUdpwYL/wg7eqdXjCH/QKWVrXHGQQWoGytX0X mnIQ== X-Gm-Message-State: APjAAAWsTKOyg/HDuef/A0/b8RXVabKE8Gd7zNhaSL/LC0GKzvqBhLxb cHdN7DSS0JBX/fUVmRCI3ow+o5Pl X-Google-Smtp-Source: APXvYqy0OSsDLqxBXtMRJjYbuX02XJhMfJpDQJWtIowmgTP7oPUvlmbqEkAWVhpDBAmJMIhAo1QkJg== X-Received: by 2002:a1c:ed12:: with SMTP id l18mr9595069wmh.13.1554567935158; Sat, 06 Apr 2019 09:25:35 -0700 (PDT) Received: from ?IPv6:2003:ea:8be1:dd00:ad7a:bfe3:68fd:9752? (p200300EA8BE1DD00AD7ABFE368FD9752.dip0.t-ipconnect.de. [2003:ea:8be1:dd00:ad7a:bfe3:68fd:9752]) by smtp.googlemail.com with ESMTPSA id y1sm72055849wrd.34.2019.04.06.09.25.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Apr 2019 09:25:33 -0700 (PDT) Subject: Re: [PATCH net-next] net: phy: improve link partner capability detection To: Florian Fainelli , Andrew Lunn Cc: David Miller , "netdev@vger.kernel.org" References: <20190405212734.GE27350@lunn.ch> <626265b0-3020-8971-1a11-0fce46075bef@gmail.com> <43505b5e-084d-0fe5-32b1-fc71358a4cda@gmail.com> <36b1ecfb-4cde-9c48-3d1b-6304418991f8@gmail.com> From: Heiner Kallweit Message-ID: <3cfe1614-9aea-0591-1d67-bba8110c5dcf@gmail.com> Date: Sat, 6 Apr 2019 18:25:25 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <36b1ecfb-4cde-9c48-3d1b-6304418991f8@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 05.04.2019 23:54, Florian Fainelli wrote: > On 4/5/19 2:52 PM, Heiner Kallweit wrote: >> On 05.04.2019 23:38, Heiner Kallweit wrote: >>> On 05.04.2019 23:27, Andrew Lunn wrote: >>>>> + 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; >>>>> + >>>> >>>> What i'm trying to get at is, why do we need this bit of the patch? >>>> Why do we need this flag? The hardware should tell us if it can do >>>> gigabit. >>>> >>> The code to query BMSR_ESTATEN and MII_ESTATUS is in genphy_read_status. >>> However we also have to cover the case that this function isn't used. >>> Therefore I query phydev->supported before the speed could be limited. >>> (relying on the PHY driver not lying about gigabit capability) >>> This part of the patch is directly before of_set_phy_supported(). >>> >>> I just see that we can re-use is_gigabit_capable also in >>> genphy_config_advert. >>> >>> Of course I can read in every place the hardware for gigabit support. >>> But IMO this creates unnecessary code duplication. >>> >> I just see that we can reuse is_gigabit_capable also in >> genphy_config_advert(). >> >> And when checking occurrences of BMSR_ESTATEN there seems to be more >> work waiting: In swphy BMSR_ESTATEN is set, but MII_ESTATUS isn't >> configured. It just works by chance becausing reading this register >> returns the default 0xffff. > > It is not clear to me what we are trying to optimize for here, given > everything is pretty much a slow path anyway. I am concerned though > about mis-behaving PHYs where caching of BMSR_ESTATEN could result in > incorrect behaviors, I don't have any data to back that claim, but > reading the registers should always be the safest way to determine what > HW is capable of (famous last words). Not feeling strongly about either > direction though... > At this point I have to quote Einstein: "If you can't explain it simply, you don't understand it well enough." Means I'll spend few more thoughts on it ..