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=-9.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 128EAC433DB for ; Sat, 23 Jan 2021 00:05:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C831123B6C for ; Sat, 23 Jan 2021 00:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbhAWAF3 (ORCPT ); Fri, 22 Jan 2021 19:05:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726960AbhAWACc (ORCPT ); Fri, 22 Jan 2021 19:02:32 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F870C06174A; Fri, 22 Jan 2021 16:01:52 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id n7so4917864pgg.2; Fri, 22 Jan 2021 16:01:52 -0800 (PST) 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=r0zcK5OGmywiWXQCPpHyBJ5jwx8Q3v3tj2k5NoX1R4Q=; b=U737ERJNYiWCeT5giCEIOY1SeZ/4Mw/RzSJX0+E6pRRZvMwJV8V+vLwGzKo9mvQbsJ QkrhuxfT3OKODEe6eoyfd4FJew1ACBjtrxP/NJPtdzZvidzzVOg2UgBXM1GGmB12rvk1 aSwWTiYyWJQMD9JP13QWxYPhePUUhp+CoT9BFtkzHk2XnwtEXgvwP15yv4FGjsSqCmRA WO31bLDYCWubuzApTfw4q8kRDWAAgX4T78lNMdw8aXGbRvxTyDhZSH3WaT8RVcKBZtSx VK2bQKct3ajsQrNSGLvY60/cA0pRv8ZSSZrpX1uTNEctIRBjhteqcI/xvvhLKQsnC18P GhgA== 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=r0zcK5OGmywiWXQCPpHyBJ5jwx8Q3v3tj2k5NoX1R4Q=; b=OQcuG8qfDkGKzgIp6vLTKAbqD1AKtWyKdi/A/nd5WVy/1j7o9Vu8NIzXIwG2Jahy+w yJUYO+HVVGZ+4wPg5P6k+ibi8feUNE0CcEn8BYJ7UVDkqQsxIFJbqVc8aSgf8cGtmz9u EVrjnahD7mIPWkFSNl6JM+APvFX8k1+JudeX5NvdHMZEdXPblCGswRaNBnzCe3JWASDJ R2R5K+tYxGn0WQan7oYJPx1SlQ4XtHrzrlq9Mxh/kVn5HYme418JUJvT3b0fS9627N8B uS6m92d7+dtlBOwi2Dz7j68IloHpnmdKZm517ouSg0CCBv0WXhPUoRmEcKNkrc5/3nib f+SA== X-Gm-Message-State: AOAM533bRfbveL3wLUoZqnwrsbSgKt0b+owkvpKN3HJx3lCFUcOR3ZiQ 1sRuyUPeKch8azSwj5FKFyBcpHN1pig= X-Google-Smtp-Source: ABdhPJxfA9Pq32dZsQYHANNjveL0UbSMEAjfsLAaAiTyhuv6PA+IBKth7yRvQCFWe8eSHo0cmbho6Q== X-Received: by 2002:a63:db03:: with SMTP id e3mr7069054pgg.225.1611360111166; Fri, 22 Jan 2021 16:01:51 -0800 (PST) Received: from [10.230.29.30] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a9sm10077912pfn.178.2021.01.22.16.01.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Jan 2021 16:01:50 -0800 (PST) Subject: Re: [PATCH v2] lan743x: add virtual PHY for PHY-less devices To: Sergej Bauer , Andrew Lunn Cc: netdev@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Bryan Whitehead , UNGLinuxDriver@microchip.com, Simon Horman , Mark Einon , Madalin Bucur , Arnd Bergmann , Masahiro Yamada , linux-kernel@vger.kernel.org References: <20210122214247.6536-1-sbauer@blackbox.su> <21783568.4JFRnjC3Rk@metabook> <3174210.ndmClRx9B8@metabook> From: Florian Fainelli Message-ID: <5306ffe6-112c-83c9-826a-9bacd661691b@gmail.com> Date: Fri, 22 Jan 2021 16:01:47 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <3174210.ndmClRx9B8@metabook> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 1/22/2021 3:58 PM, Sergej Bauer wrote: > On Saturday, January 23, 2021 2:23:25 AM MSK Andrew Lunn wrote: >>>>> @@ -1000,8 +1005,10 @@ static void lan743x_phy_close(struct >>>>> lan743x_adapter *adapter)> >>>>> >>>>> struct net_device *netdev = adapter->netdev; >>>>> >>>>> phy_stop(netdev->phydev); >>>>> >>>>> - phy_disconnect(netdev->phydev); >>>>> - netdev->phydev = NULL; >>>>> + if (phy_is_pseudo_fixed_link(netdev->phydev)) >>>>> + lan743x_virtual_phy_disconnect(netdev->phydev); >>>>> + else >>>>> + phy_disconnect(netdev->phydev); >>>> >>>> phy_disconnect() should work. You might want to call >> >> There are drivers which call phy_disconnect() on a fixed_link. e.g. >> >> https://elixir.bootlin.com/linux/v5.11-rc4/source/drivers/net/usb/lan78xx.c# >> L3555. >> > >> It could be your missing call to fixed_phy_unregister() is leaving >> behind bad state. >> > lan743x_virtual_phy_disconnect removes sysfs-links and calls > fixed_phy_unregister() > and the reason was phydev in sysfs. > >>> It was to make ethtool show full set of supported speeds and MII only in >>> supported ports (without TP and the no any ports in the bare card). >> >> But fixed link does not support the full set of speed. It is fixed. It >> supports only one speed it is configured with. > That's why I "re-implemented the fixed PHY driver" as Florian said. > The goal of virtual phy was to make an illusion of real device working in > loopback mode. So I could use ethtool and ioctl's to switch speed of device. > >> And by setting it >> wrongly, you are going to allow the user to do odd things, like use >> ethtool force the link speed to a speed which is not actually >> supported. > I have lan743x only and in loopback mode it allows to use speeds > 10/100/1000MBps > in full-duplex mode only. But the highest speed I have achived was something > near > 752Mbps... > And I can switch speed on the fly, without reloading the module. > > May by I should limit the list of acceptable devices? It is not clear what your use case is so maybe start with explaining it and we can help you define something that may be acceptable for upstream inclusion. -- Florian