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=-4.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 CB2B0C433DF for ; Mon, 20 Jul 2020 21:04:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADE74207FC for ; Mon, 20 Jul 2020 21:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726425AbgGTVEy (ORCPT ); Mon, 20 Jul 2020 17:04:54 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:45798 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726012AbgGTVEy (ORCPT ); Mon, 20 Jul 2020 17:04:54 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1jxcxt-0064s4-VK; Mon, 20 Jul 2020 23:04:49 +0200 Date: Mon, 20 Jul 2020 23:04:49 +0200 From: Andrew Lunn To: Helmut Grohne Cc: Florian Fainelli , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Woojung Huh , Microchip Linux Driver Support , Vivien Didelot , Tristram Ha Subject: Re: [PATCH v3] net: dsa: microchip: call phy_remove_link_mode during probe Message-ID: <20200720210449.GP1339445@lunn.ch> References: <20200717131814.GA1336433@lunn.ch> <20200720090416.GA7307@laureti-dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720090416.GA7307@laureti-dev> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > The dev->ports[i].phydev is not actually exposed beyond the driver. The > driver sets the phydev.speed in a few places and even reads it back in > one place. It also sets phydev.duplex, but never reads it back. It > queries phydev.link, which is statically 0 due to using devm_kzalloc. > > I think the use of this ksz_port.phydev is very misleading, but I'm > unsure how to fix this. It is not clear to me whether all those updates > should be performed on the connected phydev instead or whether this is > just internal state tracking. I took a quick look at the code. For PHY addresses < dev->phy_port_cnt it passes all reads/writes through to the hardware. So the Linux MDIO/PHY subsystem will be able to fully drive these PHYs, and the ksz9477 internal phydev is unneeded. Where it gets interesting is addr >= dev->phy_port_cnt. Reads of the PHY registers return hard coded values, or the link speed from the local phydev. Writes to these registers are just ignored. If you compare this to other DSA drivers/DSA switches, reads/write for addresses where there are no internal PHY get passed out to an external MDIO bus, where an external PHY can be connected. The Linux MDIO/PHY subsystem will discover these external PHYs and create phydev instance for them. If there is no external PHY, for example the MAC is connected to another MAC, no PHY will be detected, and fixed-link is used in its place. Do these switches have an external MDIO bus? How are external PHYs usually managed? At a minimum, the internal phydev can be replaced with just a speed, rather than a full phydev, which will reduce confusion. But it would be nice to go further and remove all the addr >= dev->phy_port_cnt handling. But we need to understand the implications of that. Andrew