Skip to content

Commit 95aca43

Browse files
jacob-kelleranguy11
authored andcommitted
ice: use read_poll_timeout_atomic in ice_read_phy_tstamp_ll_e810
The ice_read_phy_tstamp_ll_e810 function repeatedly reads the PF_SB_ATQBAL register until the TS_LL_READ_TS bit is cleared. This is a perfect candidate for using rd32_poll_timeout. However, the default implementation uses a sleep-based wait. Use read_poll_timeout_atomic macro which is based on the non-sleeping implementation and use it to replace the loop reading in the ice_read_phy_tstamp_ll_e810 function. Co-developed-by: Karol Kolacinski <[email protected]> Signed-off-by: Karol Kolacinski <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Signed-off-by: Anton Nadezhdin <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 4c9f13a commit 95aca43

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

drivers/net/ethernet/intel/ice/ice_ptp_hw.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4858,32 +4858,29 @@ static int
48584858
ice_read_phy_tstamp_ll_e810(struct ice_hw *hw, u8 idx, u8 *hi, u32 *lo)
48594859
{
48604860
u32 val;
4861-
u8 i;
4861+
int err;
48624862

48634863
/* Write TS index to read to the PF register so the FW can read it */
48644864
val = FIELD_PREP(TS_LL_READ_TS_IDX, idx) | TS_LL_READ_TS;
48654865
wr32(hw, PF_SB_ATQBAL, val);
48664866

48674867
/* Read the register repeatedly until the FW provides us the TS */
4868-
for (i = TS_LL_READ_RETRIES; i > 0; i--) {
4869-
val = rd32(hw, PF_SB_ATQBAL);
4870-
4871-
/* When the bit is cleared, the TS is ready in the register */
4872-
if (!(FIELD_GET(TS_LL_READ_TS, val))) {
4873-
/* High 8 bit value of the TS is on the bits 16:23 */
4874-
*hi = FIELD_GET(TS_LL_READ_TS_HIGH, val);
4868+
err = read_poll_timeout_atomic(rd32, val,
4869+
!FIELD_GET(TS_LL_READ_TS, val), 10,
4870+
TS_LL_READ_TIMEOUT, false, hw,
4871+
PF_SB_ATQBAL);
4872+
if (err) {
4873+
ice_debug(hw, ICE_DBG_PTP, "Failed to read PTP timestamp using low latency read\n");
4874+
return err;
4875+
}
48754876

4876-
/* Read the low 32 bit value and set the TS valid bit */
4877-
*lo = rd32(hw, PF_SB_ATQBAH) | TS_VALID;
4878-
return 0;
4879-
}
4877+
/* High 8 bit value of the TS is on the bits 16:23 */
4878+
*hi = FIELD_GET(TS_LL_READ_TS_HIGH, val);
48804879

4881-
udelay(10);
4882-
}
4880+
/* Read the low 32 bit value and set the TS valid bit */
4881+
*lo = rd32(hw, PF_SB_ATQBAH) | TS_VALID;
48834882

4884-
/* FW failed to provide the TS in time */
4885-
ice_debug(hw, ICE_DBG_PTP, "Failed to read PTP timestamp using low latency read\n");
4886-
return -EINVAL;
4883+
return 0;
48874884
}
48884885

48894886
/**

drivers/net/ethernet/intel/ice/ice_ptp_hw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ static inline bool ice_is_dual(struct ice_hw *hw)
689689
#define BYTES_PER_IDX_ADDR_L 4
690690

691691
/* Tx timestamp low latency read definitions */
692-
#define TS_LL_READ_RETRIES 200
692+
#define TS_LL_READ_TIMEOUT 2000
693693
#define TS_LL_READ_TS_HIGH GENMASK(23, 16)
694694
#define TS_LL_READ_TS_IDX GENMASK(29, 24)
695695
#define TS_LL_READ_TS_INTR BIT(30)

0 commit comments

Comments
 (0)