Skip to content

Commit 097c317

Browse files
Karol Kolacinskianguy11
authored andcommitted
ice: retry acquiring hardware semaphore during cross-timestamp request
The hardware for performing a cross-timestamp on E822 uses a hardware semaphore which we must acquire before initiating the cross-timestamp operation. The current implementation only attempts to acquire the semaphore once, and assumes that it will succeed. If the semaphore is busy for any reason, the cross-timestamp operation fails with -EFAULT. Instead of immediately failing, try the acquire the lock a few times with a small sleep between attempts. This ensures that most requests will go through without issue. Additionally, return -EBUSY instead of -EFAULT if the operation can't continue due to the semaphore being busy. Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 40326b2 commit 097c317

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,21 +1976,29 @@ ice_ptp_get_syncdevicetime(ktime_t *device,
19761976
u32 hh_lock, hh_art_ctl;
19771977
int i;
19781978

1979-
/* Get the HW lock */
1980-
hh_lock = rd32(hw, PFHH_SEM + (PFTSYN_SEM_BYTES * hw->pf_id));
1979+
#define MAX_HH_HW_LOCK_TRIES 5
1980+
#define MAX_HH_CTL_LOCK_TRIES 100
1981+
1982+
for (i = 0; i < MAX_HH_HW_LOCK_TRIES; i++) {
1983+
/* Get the HW lock */
1984+
hh_lock = rd32(hw, PFHH_SEM + (PFTSYN_SEM_BYTES * hw->pf_id));
1985+
if (hh_lock & PFHH_SEM_BUSY_M) {
1986+
usleep_range(10000, 15000);
1987+
continue;
1988+
}
1989+
break;
1990+
}
19811991
if (hh_lock & PFHH_SEM_BUSY_M) {
19821992
dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n");
1983-
return -EFAULT;
1993+
return -EBUSY;
19841994
}
19851995

19861996
/* Start the ART and device clock sync sequence */
19871997
hh_art_ctl = rd32(hw, GLHH_ART_CTL);
19881998
hh_art_ctl = hh_art_ctl | GLHH_ART_CTL_ACTIVE_M;
19891999
wr32(hw, GLHH_ART_CTL, hh_art_ctl);
19902000

1991-
#define MAX_HH_LOCK_TRIES 100
1992-
1993-
for (i = 0; i < MAX_HH_LOCK_TRIES; i++) {
2001+
for (i = 0; i < MAX_HH_CTL_LOCK_TRIES; i++) {
19942002
/* Wait for sync to complete */
19952003
hh_art_ctl = rd32(hw, GLHH_ART_CTL);
19962004
if (hh_art_ctl & GLHH_ART_CTL_ACTIVE_M) {
@@ -2019,7 +2027,7 @@ ice_ptp_get_syncdevicetime(ktime_t *device,
20192027
hh_lock = hh_lock & ~PFHH_SEM_BUSY_M;
20202028
wr32(hw, PFHH_SEM + (PFTSYN_SEM_BYTES * hw->pf_id), hh_lock);
20212029

2022-
if (i == MAX_HH_LOCK_TRIES)
2030+
if (i == MAX_HH_CTL_LOCK_TRIES)
20232031
return -ETIMEDOUT;
20242032

20252033
return 0;

0 commit comments

Comments
 (0)