lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220425031239.GA6294@hoboy.vegasvil.org>
Date:   Sun, 24 Apr 2022 20:12:39 -0700
From:   Richard Cochran <richardcochran@...il.com>
To:     Jonathan Lemon <jonathan.lemon@...il.com>
Cc:     f.fainelli@...il.com, bcm-kernel-feedback-list@...adcom.com,
        andrew@...n.ch, hkallweit1@...il.com, linux@...linux.org.uk,
        netdev@...r.kernel.org, kernel-team@...com
Subject: Re: [PATCH net-next v1 1/4] net: phy: broadcom: Add PTP support for
 some Broadcom PHYs.

On Sat, Apr 23, 2022 at 07:23:53PM -0700, Jonathan Lemon wrote:

> +static int bcm_ptp_settime_locked(struct bcm_ptp_private *priv,
> +				  const struct timespec64 *ts)
> +{
> +	struct phy_device *phydev = priv->phydev;
> +	u16 ctrl;
> +
> +	/* set up time code */
> +	bcm_phy_write_exp(phydev, TIME_CODE_0, ts->tv_nsec);
> +	bcm_phy_write_exp(phydev, TIME_CODE_1, ts->tv_nsec >> 16);
> +	bcm_phy_write_exp(phydev, TIME_CODE_2, ts->tv_sec);
> +	bcm_phy_write_exp(phydev, TIME_CODE_3, ts->tv_sec >> 16);
> +	bcm_phy_write_exp(phydev, TIME_CODE_4, ts->tv_sec >> 32);
> +
> +	/* zero out NCO counter */
> +	bcm_phy_write_exp(phydev, NCO_TIME_0, 0);
> +	bcm_phy_write_exp(phydev, NCO_TIME_1, 0);
> +	bcm_phy_write_exp(phydev, NCO_TIME_2_CTRL, 0);

You are setting the 48 bit counter to zero.

But Lasse's version does this:

	// Assign original time codes (48 bit)
	local_time_codes[2] = 0x4000;
	local_time_codes[1] = (u16)(ts->tv_nsec >> 20);
	local_time_codes[0] = (u16)(ts->tv_nsec >> 4);

	...

	// Write Local Time Code Register
	bcm_phy_write_exp(phydev, NSE_DPPL_NCO_2_0_REG, local_time_codes[0]);
	bcm_phy_write_exp(phydev, NSE_DPPL_NCO_2_1_REG, local_time_codes[1]);
	bcm_phy_write_exp(phydev, NSE_DPPL_NCO_2_2_REG, local_time_codes[2]);

My understanding is that the PPS output function uses the 48 bit
counter, and so it ought to be set to a non-zero value.

In any case, it would be nice to have the 80/48 bit register usage
clearly explained.

> +	/* set up load on next frame sync */
> +	bcm_phy_write_exp(phydev, SHADOW_LOAD, TIME_CODE_LOAD | NCO_TIME_LOAD);
> +
> +	ctrl = priv->nse_ctrl;
> +	return bcm_ptp_framesync(phydev, NULL, ctrl | NSE_INIT);
> +}

Thanks,
Richard

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ