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 87105C10F06 for ; Sat, 6 Apr 2019 20:21:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4AD3C213F2 for ; Sat, 6 Apr 2019 20:21:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZFoBt1LC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726623AbfDFUVb (ORCPT ); Sat, 6 Apr 2019 16:21:31 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:36797 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726493AbfDFUVb (ORCPT ); Sat, 6 Apr 2019 16:21:31 -0400 Received: by mail-yb1-f193.google.com with SMTP id s7so3733531ybo.3 for ; Sat, 06 Apr 2019 13:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=RGakad14W3o0Kq89WsO0y7N9+Ah+6Bj4DC/Ts07W29c=; b=ZFoBt1LCAXIw4XavOEsaxJWaBWgk+NvwjTMHN+t1KweEN+cxIQU8D/skkczydW5qTK pplkr91SnPf2YqyPNHS2GGPIUpxX2tmBcOjXojjxWmbBjJP5V4mBzOPYkuk4IvzUjJub sxAs8PqVMPvyqDmUIQf5W8tFupekL2YWWnkTfltkYlxcAVvTXUR9lz/S4cbTwMe8kkyv oZY5h52S6d4svSmCebylEpjvN2SwhlUOkP/xL31eKnImuDGW+9Kh8zVRKFpDUcO6812u LDOulcykuWG7DlIHNWrK58N63X/BcYcmgZD2yM920+15iMA8oPMmRPlW4pvb7w76GQc9 W69A== 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:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=RGakad14W3o0Kq89WsO0y7N9+Ah+6Bj4DC/Ts07W29c=; b=PgSWWy9JV8YULlQtmPMY0vcp8kNyhhjAtj7cmJ2M3YM5BXKhWJJNSN08EP8Q5+m2yn plFPV0/bmqUbCBIJeE0q9z/E7GsLcEYHxrbGawyfCGng2/wJVb7kf6Q40AhakotV21Lh OAas0CMsQIvHDWfdjCFQBSmbU/gzgEazg00YVxf2nfp6TpEoLQP6sLQduqiu3hV3BdfG eMSBb4R54tJQ+3lO13MCls5GDDOXF+pMNg5czVeJ2V7sqrOas+mC/SNh4uAF4H9yPMD6 jEPjZGn+IsKAvLRHvbQV/4sDE9x2w1S9xXY2yJ885ob2BAb4z6cxwWc6WnCoD07uWr4V RUJQ== X-Gm-Message-State: APjAAAW5+1r8dcgpklRvzylhNb3NnRduoNt/XXKNKnIlkxJdUFblkTPe Rwo8VdlRnHjvd8jPm12eLxqOpxX0 X-Google-Smtp-Source: APXvYqx6LkMMz4gZZXyVqLFNhM2tKbgWww3P/2634x07BEm9xBPQNwnBODGT8u5z+iAJMYIU6iBjZA== X-Received: by 2002:a25:4bc5:: with SMTP id y188mr17639744yba.109.1554582089717; Sat, 06 Apr 2019 13:21:29 -0700 (PDT) Received: from [10.230.25.168] ([192.19.224.250]) by smtp.gmail.com with ESMTPSA id x16sm19525836ywx.74.2019.04.06.13.21.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Apr 2019 13:21:28 -0700 (PDT) Subject: Re: [PATCH net-next] net: phy: improve link partner capability detection To: Heiner Kallweit , 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> <3cfe1614-9aea-0591-1d67-bba8110c5dcf@gmail.com> From: Florian Fainelli Openpgp: preference=signencrypt Message-ID: <8b9271de-4a96-54d2-894b-52e7f7322a8e@gmail.com> Date: Sat, 6 Apr 2019 13:21:21 -0700 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: <3cfe1614-9aea-0591-1d67-bba8110c5dcf@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 4/6/2019 9:25 AM, Heiner Kallweit wrote: > 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 .. I have re-read the patch more carefully now and understand what it is fixing, sorry for the pointless discussion. -- Florian