Skip to content

Commit bd01942

Browse files
chelsiocudbgdavem330
authored andcommitted
cxgb4: fix large delays in PTP synchronization
Fetching PTP sync information from mailbox is slow and can take up to 10 milliseconds. Reduce this unnecessary delay by directly reading the information from the corresponding registers. Fixes: 9c33e42 ("cxgb4: Add PTP Hardware Clock (PHC) support") Signed-off-by: Manoj Malviya <[email protected]> Signed-off-by: Rahul Lakkireddy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f0212a5 commit bd01942

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -311,32 +311,17 @@ static int cxgb4_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
311311
*/
312312
static int cxgb4_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
313313
{
314-
struct adapter *adapter = (struct adapter *)container_of(ptp,
315-
struct adapter, ptp_clock_info);
316-
struct fw_ptp_cmd c;
314+
struct adapter *adapter = container_of(ptp, struct adapter,
315+
ptp_clock_info);
317316
u64 ns;
318-
int err;
319-
320-
memset(&c, 0, sizeof(c));
321-
c.op_to_portid = cpu_to_be32(FW_CMD_OP_V(FW_PTP_CMD) |
322-
FW_CMD_REQUEST_F |
323-
FW_CMD_READ_F |
324-
FW_PTP_CMD_PORTID_V(0));
325-
c.retval_len16 = cpu_to_be32(FW_CMD_LEN16_V(sizeof(c) / 16));
326-
c.u.ts.sc = FW_PTP_SC_GET_TIME;
327317

328-
err = t4_wr_mbox(adapter, adapter->mbox, &c, sizeof(c), &c);
329-
if (err < 0) {
330-
dev_err(adapter->pdev_dev,
331-
"PTP: %s error %d\n", __func__, -err);
332-
return err;
333-
}
318+
ns = t4_read_reg(adapter, T5_PORT_REG(0, MAC_PORT_PTP_SUM_LO_A));
319+
ns |= (u64)t4_read_reg(adapter,
320+
T5_PORT_REG(0, MAC_PORT_PTP_SUM_HI_A)) << 32;
334321

335322
/* convert to timespec*/
336-
ns = be64_to_cpu(c.u.ts.tm);
337323
*ts = ns_to_timespec64(ns);
338-
339-
return err;
324+
return 0;
340325
}
341326

342327
/**

drivers/net/ethernet/chelsio/cxgb4/t4_regs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,9 @@
19061906

19071907
#define MAC_PORT_CFG2_A 0x818
19081908

1909+
#define MAC_PORT_PTP_SUM_LO_A 0x990
1910+
#define MAC_PORT_PTP_SUM_HI_A 0x994
1911+
19091912
#define MPS_CMN_CTL_A 0x9000
19101913

19111914
#define COUNTPAUSEMCRX_S 5

0 commit comments

Comments
 (0)