]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
amd-xgbe: Add a workaround for Tx timestamp issue
authorLendacky, Thomas <Thomas.Lendacky@amd.com>
Thu, 10 Nov 2016 23:09:45 +0000 (17:09 -0600)
committerDavid S. Miller <davem@davemloft.net>
Sun, 13 Nov 2016 05:56:26 +0000 (00:56 -0500)
Update the reading of the Tx timestamp to account for a hardware issue
on how the fields and interrupt are cleared.  The "seconds" portion of
the timestamp should be read first, followed by the "nanoseconds" portion.
Reading the "nanoseconds" portion should clear the timestamp data and the
interrupt.  Because of an issue with the hardware this order is reversed
and reading the "seconds" portion actually clears the timestamp.  The code
currently follows this workaround, but to guard against future versions
where this is fixed add a field to the version data to indicate if the
workaround is required or not.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amd/xgbe/xgbe-dev.c
drivers/net/ethernet/amd/xgbe/xgbe-platform.c
drivers/net/ethernet/amd/xgbe/xgbe.h

index e3862bbf2f761887afdfa2307eeb22dea0c0a3d8..81d47807c3ccd7b2fad9d11aad595c3c4758d1ec 100644 (file)
@@ -1360,14 +1360,21 @@ static u64 xgbe_get_tstamp_time(struct xgbe_prv_data *pdata)
 
 static u64 xgbe_get_tx_tstamp(struct xgbe_prv_data *pdata)
 {
-       unsigned int tx_snr;
+       unsigned int tx_snr, tx_ssr;
        u64 nsec;
 
-       tx_snr = XGMAC_IOREAD(pdata, MAC_TXSNR);
+       if (pdata->vdata->tx_tstamp_workaround) {
+               tx_snr = XGMAC_IOREAD(pdata, MAC_TXSNR);
+               tx_ssr = XGMAC_IOREAD(pdata, MAC_TXSSR);
+       } else {
+               tx_ssr = XGMAC_IOREAD(pdata, MAC_TXSSR);
+               tx_snr = XGMAC_IOREAD(pdata, MAC_TXSNR);
+       }
+
        if (XGMAC_GET_BITS(tx_snr, MAC_TXSNR, TXTSSTSMIS))
                return 0;
 
-       nsec = XGMAC_IOREAD(pdata, MAC_TXSSR);
+       nsec = tx_ssr;
        nsec *= NSEC_PER_SEC;
        nsec += tx_snr;
 
index 0edbcd523f8f4b05e822b17ba0d622d4c0648e25..7a701de5eed3a52ff787c035371ebaddd30da00f 100644 (file)
@@ -581,6 +581,7 @@ static const struct xgbe_version_data xgbe_v1 = {
        .xpcs_access                    = XGBE_XPCS_ACCESS_V1,
        .tx_max_fifo_size               = 81920,
        .rx_max_fifo_size               = 81920,
+       .tx_tstamp_workaround           = 1,
 };
 
 #ifdef CONFIG_ACPI
index 0779247057fb3dc369bc4301142d091941e4be70..8523779329f8855092cea416722a1a99fd2c0760 100644 (file)
@@ -805,6 +805,7 @@ struct xgbe_version_data {
        unsigned int mmc_64bit;
        unsigned int tx_max_fifo_size;
        unsigned int rx_max_fifo_size;
+       unsigned int tx_tstamp_workaround;
 };
 
 struct xgbe_prv_data {