Skip to content

Commit b4fcd43

Browse files
jacob-kellerJeff Kirsher
authored andcommitted
fm10k: use spinlock to implement mailbox lock
Lets not re-invent the locking wheel. Remove our bitlock and use a proper spinlock instead. Signed-off-by: Jacob Keller <[email protected]> Tested-by: Krishneil Singh <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 0b40f45 commit b4fcd43

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

drivers/net/ethernet/intel/fm10k/fm10k.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ enum fm10k_state_t {
276276
__FM10K_SERVICE_SCHED,
277277
__FM10K_SERVICE_REQUEST,
278278
__FM10K_SERVICE_DISABLE,
279-
__FM10K_MBX_LOCK,
280279
__FM10K_LINK_DOWN,
281280
__FM10K_UPDATING_STATS,
282281
/* This value must be last and determines the BITMAP size */
@@ -346,6 +345,8 @@ struct fm10k_intfc {
346345

347346
struct fm10k_hw_stats stats;
348347
struct fm10k_hw hw;
348+
/* Mailbox lock */
349+
spinlock_t mbx_lock;
349350
u32 __iomem *uc_addr;
350351
u32 __iomem *sw_addr;
351352
u16 msg_enable;
@@ -386,23 +387,17 @@ struct fm10k_intfc {
386387

387388
static inline void fm10k_mbx_lock(struct fm10k_intfc *interface)
388389
{
389-
/* busy loop if we cannot obtain the lock as some calls
390-
* such as ndo_set_rx_mode may be made in atomic context
391-
*/
392-
while (test_and_set_bit(__FM10K_MBX_LOCK, interface->state))
393-
udelay(20);
390+
spin_lock(&interface->mbx_lock);
394391
}
395392

396393
static inline void fm10k_mbx_unlock(struct fm10k_intfc *interface)
397394
{
398-
/* flush memory to make sure state is correct */
399-
smp_mb__before_atomic();
400-
clear_bit(__FM10K_MBX_LOCK, interface->state);
395+
spin_unlock(&interface->mbx_lock);
401396
}
402397

403398
static inline int fm10k_mbx_trylock(struct fm10k_intfc *interface)
404399
{
405-
return !test_and_set_bit(__FM10K_MBX_LOCK, interface->state);
400+
return spin_trylock(&interface->mbx_lock);
406401
}
407402

408403
/* fm10k_test_staterr - test bits in Rx descriptor status and error fields */

drivers/net/ethernet/intel/fm10k/fm10k_pci.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,9 @@ static int fm10k_sw_init(struct fm10k_intfc *interface,
19211921
netdev_rss_key_fill(rss_key, sizeof(rss_key));
19221922
memcpy(interface->rssrk, rss_key, sizeof(rss_key));
19231923

1924+
/* Initialize the mailbox lock */
1925+
spin_lock_init(&interface->mbx_lock);
1926+
19241927
/* Start off interface as being down */
19251928
set_bit(__FM10K_DOWN, interface->state);
19261929
set_bit(__FM10K_UPDATING_STATS, interface->state);

0 commit comments

Comments
 (0)