Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7485230ybp; Wed, 16 Oct 2019 09:19:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjF8805MZXWp03g81hsYoPedUKOaHPNDll7rKpeNfAWKk/NBGZOIVDgSaPPzjrC+N3+/3y X-Received: by 2002:a50:d4d7:: with SMTP id e23mr40140989edj.135.1571242795213; Wed, 16 Oct 2019 09:19:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571242795; cv=none; d=google.com; s=arc-20160816; b=L5QvRC2Ly0fJzwE4TG7xRMu5Ecf0GOya/paUjy8dYNerGlvAEWfy0ze+PqaszphreP z9teK8s9jn2tacodJKxt/Ewe0aV7EjlqynN2i8gmWB190OIx2mg1vZw6tULTxeNV75qX 1Y6vL+oqQlK+6Scmf9Im10WQKm/VGcITYI8kJD7TR/E2hN1r6IgjkeZKiuL5brRTJyQq yY50lFgZ7LzTdVV+E35QYhcFqPw3dxi2w7iMpdpfyFoIIvx6bYLKHifJmd4u1H0eIoNj 1EfvlAVn0WWrdeNVoYecGFtp4lZFp42Nv103h3t6SX4YhD9kcY73AeDUQb2UZjL0pD/f oEzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2gfBz9doyaXqlfWGuAYNroU7aTSAFE6JHtbYJe4Wvoo=; b=nwlujIb6vHOb2LDSxHWHnqtGNCYKczvaD9FZfUJmam0RNy58+0izDeKDbq5RLif4C4 jw9wIzE6NSYSjRPPznhoe1/xl339iO/yHfRJN7KmuF30oyluodrZT2tVI3ICmH/79VFI VTiuB/B4MZ3ymSiNQnQ5qGfRau/E43AWJcAJaOazLfdTQ12CKDWgUD3NmE5LL0/Tfate zRe0wf8YfVpCSIOocfgpTR7UOmnXWrws7ujtnXQtD306GBEtGNo9Ktcxnf5YVe7AIfmj qqZXf6HgZN1VjLOQx0iq2jPQtuAHXLsj+qVZiv+lbCwgNJLYG3yM81ItCxp78rVGc9UR OEYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=OflYA2g4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a38si16257799edf.260.2019.10.16.09.19.31; Wed, 16 Oct 2019 09:19:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=OflYA2g4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393928AbfJPOTz (ORCPT + 99 others); Wed, 16 Oct 2019 10:19:55 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:48500 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727442AbfJPOTz (ORCPT ); Wed, 16 Oct 2019 10:19:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=2gfBz9doyaXqlfWGuAYNroU7aTSAFE6JHtbYJe4Wvoo=; b=OflYA2g45TEOHaOj3PxZPb2irR iuDLs2iQqK9Toz8vWWSaccnAYSd83vMzaXLBjRPHsFegisJWmx7AzxLWb7lS/WrdEywG1gx5ONnN1 ATUcuVRmDrEsyfswvfLPTKjnryIY5BgcIuYKYr41t+KwOvXwhw3IKlypFrZjW1RiQa8U=; Received: from andrew by vps0.lunn.ch with local (Exim 4.92.2) (envelope-from ) id 1iKk9W-0007pf-RD; Wed, 16 Oct 2019 16:19:50 +0200 Date: Wed, 16 Oct 2019 16:19:50 +0200 From: Andrew Lunn To: Florian Fainelli Cc: netdev@vger.kernel.org, "David S. Miller" , open list , hkallweit1@gmail.com, bcm-kernel-feedback-list@broadcom.com, olteanv@gmail.com, rmk+kernel@armlinux.org.uk, cphealy@gmail.com, Jose Abreu Subject: Re: [PATCH net-next 2/2] net: phy: Add ability to debug RGMII connections Message-ID: <20191016141950.GC17013@lunn.ch> References: <20191015224953.24199-1-f.fainelli@gmail.com> <20191015224953.24199-3-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191015224953.24199-3-f.fainelli@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > If all is well, we stop iterating over all possible RGMII combinations > and offer the one that is deemed suitable which is what an user should > be trying by configuring the platform appropriately. Hi Florian I like the idea, however... I think it would be good to always iterate over all possible delay modes, not until it works. We want to try to catch PHY drivers which don't implement all four possible settings. If two or more delay modes work, it suggests something is wrong in the implementation, not all modes are supported correctly. > +int phy_rgmii_debug_probe(struct phy_device *phydev) > +{ > + struct net_device *ndev = phydev->attached_dev; > + unsigned char operstate = ndev->operstate; > + phy_interface_t rgmii_modes[4] = { > + PHY_INTERFACE_MODE_RGMII, > + PHY_INTERFACE_MODE_RGMII_ID, > + PHY_INTERFACE_MODE_RGMII_RXID, > + PHY_INTERFACE_MODE_RGMII_TXID > + }; > + struct phy_rgmii_debug_priv *priv; > + unsigned int i, count; > + int ret; > + > + ret = phy_rgmii_can_debug(phydev); > + if (ret <= 0) > + return ret; > + > + priv = kzalloc(sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + if (phy_rgmii_probes_type.af_packet_priv) > + return -EBUSY; > + > + phy_rgmii_probes_type.af_packet_priv = priv; > + priv->phydev = phydev; > + INIT_WORK(&priv->work, phy_rgmii_probe_xmit_work); > + init_completion(&priv->compl); > + > + /* We are now testing this network device */ > + ndev->operstate = IF_OPER_TESTING; I should dig out and re-submit my patch set of doing this. > + > + dev_add_pack(&phy_rgmii_probes_type); > + > + /* Determine where to start */ > + for (i = 0; i < ARRAY_SIZE(rgmii_modes); i++) { > + if (phydev->interface == rgmii_modes[i]) > + break; > + } I don't think that is a good idea. What if setting the RGMII delay is a NOP, and relying on strapping? We will never know we have the wrong mode in DT, because it works. I would much prefer we used all four modes, all four modes pass, and then we know the driver is broken. Andrew