Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1154203rdb; Fri, 16 Feb 2024 07:01:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWP8J/M68jtuiIo2FJlew0SqxX7tBDeKP34rHz5fxn+GJuCbwmGKQt3rxomPzPT1OY6hE6sPiVtBvZYP1G/JkwnTQtPsg4VMAdZJtD5zQ== X-Google-Smtp-Source: AGHT+IFXzpvecC2V+IfByjDGHPcez8i2JU0wTEPeqgmmB2VcNMIwDoks+xxZV5h806eHUNxlqqnz X-Received: by 2002:aa7:cf01:0:b0:564:117e:b9f1 with SMTP id a1-20020aa7cf01000000b00564117eb9f1mr107474edy.24.1708095713235; Fri, 16 Feb 2024 07:01:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708095713; cv=pass; d=google.com; s=arc-20160816; b=gSXTlyBQgr2ofi7rNxhcjJJhaXiuXCOfGf1xMjRE3PAbt8obykfri+/NJycNfSlsLU B5JvSS3swkV7kZaJeE6iXZFERC5xYMeDx+5AP+edtOKlcqYRIyLMWCZae4NuPdtAoE1h D8D4JMrNNCaJoZQpjTNTt+iwaq4IV/yAI4eDL0Auds1gl/xvfHoCZZNZItg9QNk/pBJH tywlwBhtRTRvRw3lAewMq6gjmZN5MuI3NnemMEYQ9FU6Hu4o1fw7jt8vmS+JPlLZs4oF f8bfWKGaCriqLwnqlYUvCU3JraPCiTlhyLbei3JjonvhmlTe17Ip0JiWiMShEnIA6rIB 1A7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LYlr5KosbRmI8zuJFutDt7+/kwZBdkeoiz+ZEDuMca8=; fh=oG7bweP8IWaFLtRAWiiDNwM/Uy9ksCy4A8hSxbvLJdk=; b=P/347pmVHk/tCXKvChltxaT4lZNBL/XQjrUdgjCPOnZyKfCl3bhcRUkI11iAIYi7+V 7fwAcCfh7pVdgcgD2T+1hThcdOqutxGaQZdBfzgob9ZV5+7M4eIg5Ga48kUFyiLB8Ts9 g4VHvhcDKlps+nJbiU8gn5fv0LdTrBy9W5fhifE1lk2huHH/D/Gi4RnNc1bOU0oGNHCj mlQt8keOsEXHHZJWvCCzIzgdcHQdJH89ptWKD9pJX1c37EPwyjlumwJ7K6tm8Qa6sFYR VbNv0xp8e1X6qTh1i58PFbUrxYl1AQlX2fapWyDJYDwSiim3EvGnqQmLAAvPN9U1dix1 Pq7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="AHhoeY/K"; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-67845-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id di3-20020a056402318300b0056212d39c1bsi40994edb.287.2024.02.16.07.01.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 07:01:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67845-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="AHhoeY/K"; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-67845-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 990D11F22DD3 for ; Thu, 15 Feb 2024 23:43:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 279B7145FF7; Thu, 15 Feb 2024 23:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="AHhoeY/K" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60F65145B32; Thu, 15 Feb 2024 23:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708040607; cv=none; b=JsnvIXx8ozUOCnDeZJwJ7FoFAAZziQJ9EAciOcIkHOGYCP0P2apq3DjxzdBtL5QntuK7O6aNr9mAJg0H32bmRJ/EIz0NhsXypr/bJLttunW3WIwOxRE7wR9TNOrB2eKDe+f67HEZtjDV81s3s+Kr8FzrIwD8pWRNMnBKVnM9dhA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708040607; c=relaxed/simple; bh=rzXQp+0xgZRh+hAEef1Ws6p+fPGbGwqJv//E1UQ0gH4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LpKDoikVAN4VrykIz8WVEVNVJQPx/rvaXdLWql0juZod9vy5oNWlrghueAf9uUrfWqiT0AAw2zMn31iW4VgwQ6j0mEPMmM0JIiteAE7Dgos4nsDKfIyUA1T+HAigrRt83EUUbxl/wYhCVZngiyQZI6cyeWFZfHqhDu4FNT36VB8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=AHhoeY/K; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=LYlr5KosbRmI8zuJFutDt7+/kwZBdkeoiz+ZEDuMca8=; b=AHhoeY/KWWcBuiZ9AWj0IDMXml bcS7EOHm1+6aJvNT8cUBTR/AVx7sZ+sPEj0MPpygrijA3WKI7t0k1JhPMB3sI7mfCfRAdEQ8L8Alz TcGdDYduEqaEZV4DyNavYfUirYiwuUIj7lgAC0REMgQ4ECDpdaVpcCy9m/jAKWYLotMY=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1ralO4-007veu-E2; Fri, 16 Feb 2024 00:43:28 +0100 Date: Fri, 16 Feb 2024 00:43:28 +0100 From: Andrew Lunn To: Dimitri Fedrau Cc: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Eichenberger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 net-next 09/14] net: phy: marvell-88q2xxx: add cable test support Message-ID: References: <20240213213955.178762-1-dima.fedrau@gmail.com> <20240213213955.178762-10-dima.fedrau@gmail.com> <20240215210350.GB3103@debian> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240215210350.GB3103@debian> On Thu, Feb 15, 2024 at 10:03:50PM +0100, Dimitri Fedrau wrote: > Am Wed, Feb 14, 2024 at 06:54:58PM +0100 schrieb Andrew Lunn: > > > +static int mv88q222x_cable_test_get_status(struct phy_device *phydev, > > > + bool *finished) > > > +{ > > > + int ret; > > > + u32 dist; > > > + > > > + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_TDR_STATUS); > > > + if (ret < 0) > > > + return ret; > > > + > > > + *finished = true; > > > > That looks odd. Is there no status bit which says it has completed? Is > > it guaranteed to complete within a fixed time? How is it guaranteed that > > mv88q222x_cable_test_get_status() is called at the necessary delay after > > mv88q222x_cable_test_start()? > > > According to the datasheet and the Marvell API bits(0:1) can be used to > check if the test has completed. Sample code waits 500ms before checking > the bits. If the test is not completed after the delay the corresponding > function returns with an error. Thanks for the explanation. > > I just used bits(7:4) where 2'b1000 means that the test is in progress, > and setting *finished = false. I didn't introduced any delay, relying > on the reschedule delay of the PHY state machine. I didn't notice any > problems with this approach. Anyway if the test does not complete for > whatever reasons we get stuck here, right ? It should not happen, and if it does, its a bug in the PHY firmware. And if that happens, the PHY is probably dead anyway. phylib does allow you to break out of the cable test state by calling phy_stop(). That generally happens when you admin down the interface. So please do check the test has completed. Andrew