Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1245784rdb; Wed, 6 Dec 2023 12:48:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEDUlCufqZHlS7Tsjgh4ltMQOFe7xL9o9s3KtDU0jIBXU99lewPmvof4j9sDSjxCt2SUNF X-Received: by 2002:a05:6a00:3499:b0:6ce:4295:fec9 with SMTP id cp25-20020a056a00349900b006ce4295fec9mr1693245pfb.69.1701895681726; Wed, 06 Dec 2023 12:48:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701895681; cv=none; d=google.com; s=arc-20160816; b=J8Oeir7wxnestH69n6fvZb0rPqapCCZqGt0XFeqba2epvZnkw/r87G0+mVYtWx9lsd eb2lN7VQlXkB1eeUJgi6FOhyFxRiedw3CWIOyJkNpvoyY1ftiyWZh/+kA4mzAh9drFDM FXJoADYwI+Z/Q1U8o8aocr4adCo2OnO8fg1ZBdkJLVBQQU/rb20mxQ4qbC+GIhcoqlJH MTF3k/giwYK5ZxEucR5qIC8u8uQHS4QUxRi1s3EJMFy6ZY8gBoLRhN8OdVP9O134x+j1 u+xh1WScD5ygwMhx0JEHPBxp0RCjrnpiEfrVeGxlow4RrERXOdnJ26NOWPphT3FCcc2K KN7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=vrjJfibQMgA96B/QSQucim4XmKfuhb9W3RFthVGXvpM=; fh=uY+7ONsNykR7xnB1nTQcaVQTLmIvLm97L6svsWS9qxw=; b=Yp0YwepwoQK+Bu5mPoX2xhkzeSokCJwxrh2yq3H7E5+15SsavhC6X3eCZZe9a3NWZQ aK9io3US9+FpUehkm4Q9Uk8KD5nV3rrqb5Qy6V4LgRnVAuIexM/B3qFGEUjqpkGeGFGn Q1nCNC5NN9VrbQiIX2c6AfEeP5sF+bITJdQ9CWVXY0P+y25+qi5b8FcGsmnps1LWiZca FZPA+w/Tb1FXBPzFgR2e2S1n8SyNsUB2z+mh0F2pQjQ7imJGbPpxKN3N/0ni+k28Prgv bQn1giO66U99rBX4+Fj8++SsDTDN98iF+e/Bhorgux4z4OI9XAzLsIifDS9Ql1nkSJ9w uEZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bq11-20020a056a02044b00b005c663e195d6si445399pgb.446.2023.12.06.12.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 12:48:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C7F8B80A7F29; Wed, 6 Dec 2023 12:47:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230328AbjLFUrn (ORCPT + 99 others); Wed, 6 Dec 2023 15:47:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230335AbjLFUrl (ORCPT ); Wed, 6 Dec 2023 15:47:41 -0500 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24242135; Wed, 6 Dec 2023 12:47:48 -0800 (PST) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from ) id 1rAynn-0007mp-2m; Wed, 06 Dec 2023 20:47:29 +0000 Date: Wed, 6 Dec 2023 20:47:25 +0000 From: Daniel Golle To: "Russell King (Oracle)" Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , Andrew Lunn , Heiner Kallweit , Alexander Couzens , Qingfang Deng , SkyLake Huang , Philipp Zabel , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org Subject: Re: [RFC PATCH v2 8/8] net: ethernet: mtk_eth_soc: add paths and SerDes modes for MT7988 Message-ID: References: <3ccc33fa14310ab47e90ff8e6ce46f1562bb838e.1701826319.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 12:47:58 -0800 (PST) Hi Russell, thank for going into my patch in depth and taking your time for an elaborate and constructive answer. On Wed, Dec 06, 2023 at 08:23:05PM +0000, Russell King (Oracle) wrote: > On Wed, Dec 06, 2023 at 07:52:23PM +0000, Daniel Golle wrote: > > On Wed, Dec 06, 2023 at 06:55:50PM +0000, Russell King (Oracle) wrote: > > > On Wed, Dec 06, 2023 at 01:45:17AM +0000, Daniel Golle wrote: > > > > @@ -516,6 +538,21 @@ static struct phylink_pcs *mtk_mac_select_pcs(struct phylink_config *config, > > > > struct mtk_eth *eth = mac->hw; > > > > unsigned int sid; > > > > > > > > + if (mtk_is_netsys_v3_or_greater(eth)) { > > > > + switch (interface) { > > > > + case PHY_INTERFACE_MODE_1000BASEX: > > > > + case PHY_INTERFACE_MODE_2500BASEX: > > > > + case PHY_INTERFACE_MODE_SGMII: > > > > + return mtk_pcs_lynxi_select_pcs(mac->sgmii_pcs_of_node, interface); > > > > + case PHY_INTERFACE_MODE_5GBASER: > > > > + case PHY_INTERFACE_MODE_10GBASER: > > > > + case PHY_INTERFACE_MODE_USXGMII: > > > > + return mtk_usxgmii_select_pcs(mac->usxgmii_pcs_of_node, interface); > > > > > > From what I can see, neither of these two "select_pcs" methods that > > > you're calling makes any use of the "interface" you pass to them. > > > I'm not sure what they _could_ do with it either, given that what > > > you're effectively doing here is getting the phylink_pcs structure from > > > the driver, and each one only has a single phylink_pcs. > > > > Yes, you are right, the interface parameter isn't used, I will drop > > it from both mtk_*_select_pcs() prototypes. > > > > In the long run we may want something like > > struct phylink_pcs *of_pcs_get(struct device_node *np, phy_interface_t interface) > > provided by a to-be-built drivers/net/pcs/core.c... > > Again... it's not as simple as that. As soon as we get into the > situation that some _other_ driver becomes responsible for providing > the struct phylink_pcs pointer, we _then_ need to have some way of > dealing with that device going away. I assume you are referring to struct phylink_pcs *of_pcs_get(...), right? And true, it'd be quite a complex piece of infrastructure. > > By that I mean that the memory pointed to returned from such a function > that you are proposing above could be freed - or worse could be unmapped > from the kernel address space, and the same goes for the operations > structure as well - even more so if the "ops" are part of module data > and the module is unloaded. > > As I know how these discussions go (it's not my first time bringing up > these kinds of multi-driver interations), no, locking the module into > memory doesn't work, and shows a lack of a full understanding of the > problem. > > We need to have a way that when a PCS device is removed, that is > propagated up the management levels and causes the PCS to be gracefully > removed from the network driver (in other words, from phylink). I see -- spontanous removal of the PCS may not be a practical problem on that very hardware, but from the driver model point of view, it is. Should the callback for removal be implemented as part of the network driver or are you suggesting to add such infrastructure to phylink? > > I won't accept a hack that sticky-plasters around the problem - not for > code that I am involved in actively maintaining - and sticky-plastering > around this class of problem seems to happen all too often in the > kernel. Oh yes, I can see that every day when testing various SFP modules with exposed PHYs -- and often get stackdumps thrown at me when I remove them...