Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-stmmac-use-correct-pps-input-indexing'

Johannes Zink says:

====================
net: stmmac: use correct PPS input indexing

The stmmac can have 0 to 4 auxiliary snapshot in channels, which can be
used for capturing external triggers with respect to the eqos PTP timer.

Previously when enabling the auxiliary snapshot, an invalid request was
written to the hardware register, except for the Intel variant of this
driver, where the only snapshot available was hardcoded.

Patch 1 of this series cleans up the debug netdev_dbg message indicating
the auxiliary snapshot being {en,dis}abled. No functional changes here

Patch 2 of this series writes the correct PPS input indexing to the
hardware registers instead of a previously used fixed value

Patch 3 of this series removes a field member from plat_stmmacnet_data
that is no longer needed

Patch 4 of this series prepares Patch 5 by protecting the snapshot
enabled flag by the aux_ts_lock mutex

Patch 5 of this series adds a temporary workaround, since at the moment
the driver can handle only one single auxiliary snapshot at a time.
Previously the driver silently dropped the previous configuration and
enabled the new one. Now, if a snapshot is already enabled and userspace
tries to enable another without previously disabling the snapshot currently
enabled: issue a netdev_err and return an errorcode indicating the device is
busy.

This series is a "never worked, doesn't hurt anyone" touchup to the PPS
capture for non-intel variants of the dwmac driver.
====================

Link: https://lore.kernel.org/r/20231010-stmmac_fix_auxiliary_event_capture-v2-0-51d5f56542d7@pengutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+21 -15
-1
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
··· 605 605 plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR; 606 606 607 607 plat->int_snapshot_num = AUX_SNAPSHOT1; 608 - plat->ext_snapshot_num = AUX_SNAPSHOT0; 609 608 610 609 plat->crosststamp = intel_crosststamp; 611 610 plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;
+20 -12
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
··· 191 191 priv->systime_flags); 192 192 write_unlock_irqrestore(&priv->ptp_lock, flags); 193 193 break; 194 - case PTP_CLK_REQ_EXTTS: 195 - if (on) 196 - priv->plat->flags |= STMMAC_FLAG_EXT_SNAPSHOT_EN; 197 - else 198 - priv->plat->flags &= ~STMMAC_FLAG_EXT_SNAPSHOT_EN; 194 + case PTP_CLK_REQ_EXTTS: { 195 + u8 channel; 196 + 199 197 mutex_lock(&priv->aux_ts_lock); 200 198 acr_value = readl(ptpaddr + PTP_ACR); 199 + channel = ilog2(FIELD_GET(PTP_ACR_MASK, acr_value)); 201 200 acr_value &= ~PTP_ACR_MASK; 201 + 202 202 if (on) { 203 + if (FIELD_GET(PTP_ACR_MASK, acr_value)) { 204 + netdev_err(priv->dev, 205 + "Cannot enable auxiliary snapshot %d as auxiliary snapshot %d is already enabled", 206 + rq->extts.index, channel); 207 + mutex_unlock(&priv->aux_ts_lock); 208 + return -EBUSY; 209 + } 210 + 211 + priv->plat->flags |= STMMAC_FLAG_EXT_SNAPSHOT_EN; 212 + 203 213 /* Enable External snapshot trigger */ 204 - acr_value |= priv->plat->ext_snapshot_num; 214 + acr_value |= PTP_ACR_ATSEN(rq->extts.index); 205 215 acr_value |= PTP_ACR_ATSFC; 206 - netdev_dbg(priv->dev, "Auxiliary Snapshot %d enabled.\n", 207 - priv->plat->ext_snapshot_num >> 208 - PTP_ACR_ATSEN_SHIFT); 209 216 } else { 210 - netdev_dbg(priv->dev, "Auxiliary Snapshot %d disabled.\n", 211 - priv->plat->ext_snapshot_num >> 212 - PTP_ACR_ATSEN_SHIFT); 217 + priv->plat->flags &= ~STMMAC_FLAG_EXT_SNAPSHOT_EN; 213 218 } 219 + netdev_dbg(priv->dev, "Auxiliary Snapshot %d %s.\n", 220 + rq->extts.index, on ? "enabled" : "disabled"); 214 221 writel(acr_value, ptpaddr + PTP_ACR); 215 222 mutex_unlock(&priv->aux_ts_lock); 216 223 /* wait for auxts fifo clear to finish */ ··· 225 218 !(acr_value & PTP_ACR_ATSFC), 226 219 10, 10000); 227 220 break; 221 + } 228 222 229 223 default: 230 224 break;
+1 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
··· 79 79 #define PTP_ACR_ATSEN1 BIT(5) /* Auxiliary Snapshot 1 Enable */ 80 80 #define PTP_ACR_ATSEN2 BIT(6) /* Auxiliary Snapshot 2 Enable */ 81 81 #define PTP_ACR_ATSEN3 BIT(7) /* Auxiliary Snapshot 3 Enable */ 82 - #define PTP_ACR_ATSEN_SHIFT 5 /* Auxiliary Snapshot shift */ 82 + #define PTP_ACR_ATSEN(index) (PTP_ACR_ATSEN0 << (index)) 83 83 #define PTP_ACR_MASK GENMASK(7, 4) /* Aux Snapshot Mask */ 84 84 #define PMC_ART_VALUE0 0x01 /* PMC_ART[15:0] timer value */ 85 85 #define PMC_ART_VALUE1 0x02 /* PMC_ART[31:16] timer value */
-1
include/linux/stmmac.h
··· 303 303 unsigned int eee_usecs_rate; 304 304 struct pci_dev *pdev; 305 305 int int_snapshot_num; 306 - int ext_snapshot_num; 307 306 int msi_mac_vec; 308 307 int msi_wol_vec; 309 308 int msi_lpi_vec;