Commit 377373d6 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-stmmac-correctly-populate-ptp_clock_ops-getcrosststamp'

Russell King says:

====================
net: stmmac: correctly populate ptp_clock_ops.getcrosststamp

While reviewing code in the stmmac PTP driver, I noticed that the
getcrosststamp() method is always populated, irrespective of whether
it is implemented or not by the stmmac platform specific glue layer.

Where a platform specific glue layer does not implement it, the core
stmmac driver code returns -EOPNOTSUPP. However, the PTP clock core
code uses the presence of the method in ptp_clock_ops to determine
whether this facility should be advertised to userspace (see
ptp_clock_getcaps()).

Moreover, the only platform glue that implements this method is the
Intel glue, and for it not to return -EOPNOTSUPP, the CPU has to
support X86_FEATURE_ART.

This series updates the core stmmac code to only provide the
getcrosststamp() method in ptp_clock_ops when the platform glue code
provides an implementation, and then updates the Intel glue code to
only provide its implementation when the CPU has the necessary
X86_FEATURE_ART feature.
====================

Link: https://patch.msgid.link/aLhJ8Gzb0T2qpXBE@shell.armlinux.org.uk


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 13a94444 0c9fbb38
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -371,9 +371,6 @@ static int intel_crosststamp(ktime_t *device,
	u32 acr_value;
	int i;

	if (!boot_cpu_has(X86_FEATURE_ART))
		return -EOPNOTSUPP;

	intel_priv = priv->plat->bsp_priv;

	/* Both internal crosstimestamping and external triggered event
@@ -755,7 +752,9 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,

	plat->int_snapshot_num = AUX_SNAPSHOT1;

	if (boot_cpu_has(X86_FEATURE_ART))
		plat->crosststamp = intel_crosststamp;

	plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;

	/* Setup MSI vector offset specific to Intel mGbE controller */
+4 −6
Original line number Diff line number Diff line
@@ -279,10 +279,7 @@ static int stmmac_get_syncdevicetime(ktime_t *device,
{
	struct stmmac_priv *priv = (struct stmmac_priv *)ctx;

	if (priv->plat->crosststamp)
	return priv->plat->crosststamp(device, system, ctx);
	else
		return -EOPNOTSUPP;
}

static int stmmac_getcrosststamp(struct ptp_clock_info *ptp,
@@ -310,7 +307,6 @@ const struct ptp_clock_info stmmac_ptp_clock_ops = {
	.gettime64 = stmmac_get_time,
	.settime64 = stmmac_set_time,
	.enable = stmmac_enable,
	.getcrosststamp = stmmac_getcrosststamp,
};

/* structure describing a PTP hardware clock */
@@ -328,7 +324,6 @@ const struct ptp_clock_info dwmac1000_ptp_clock_ops = {
	.gettime64 = stmmac_get_time,
	.settime64 = stmmac_set_time,
	.enable = dwmac1000_ptp_enable,
	.getcrosststamp = stmmac_getcrosststamp,
};

/**
@@ -364,6 +359,9 @@ void stmmac_ptp_register(struct stmmac_priv *priv)
	if (priv->plat->ptp_max_adj)
		priv->ptp_clock_ops.max_adj = priv->plat->ptp_max_adj;

	if (priv->plat->crosststamp)
		priv->ptp_clock_ops.getcrosststamp = stmmac_getcrosststamp;

	rwlock_init(&priv->ptp_lock);
	mutex_init(&priv->aux_ts_lock);