lkml.org 
[lkml]   [2021]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC] [PATCH net-next v7 3/4] r8169: Use mutex to guard config register locking
Date
Right now r8169 doesn't have parallel access to its config register, but
the next patch will access config register at anytime.

So add a mutex to prevent the race.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v7:
- This is a new patch.

drivers/net/ethernet/realtek/r8169_main.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 53936ebb3b3a6..b91de853e60f0 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -621,6 +621,8 @@ struct rtl8169_private {
struct work_struct work;
} wk;

+ struct mutex config_lock;
+
unsigned supports_gmii:1;
dma_addr_t counters_phys_addr;
struct rtl8169_counters *counters;
@@ -670,12 +672,14 @@ static inline struct device *tp_to_dev(struct rtl8169_private *tp)

static void rtl_lock_config_regs(struct rtl8169_private *tp)
{
+ mutex_lock(&tp->config_lock);
RTL_W8(tp, Cfg9346, Cfg9346_Lock);
}

static void rtl_unlock_config_regs(struct rtl8169_private *tp)
{
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
+ mutex_unlock(&tp->config_lock);
}

static void rtl_pci_commit(struct rtl8169_private *tp)
@@ -5307,6 +5311,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
return rc;
}

+ mutex_init(&tp->config_lock);
+
tp->mmio_addr = pcim_iomap_table(pdev)[region];

xid = (RTL_R32(tp, TxConfig) >> 20) & 0xfcf;
--
2.32.0
\
 
 \ /
  Last update: 2021-10-16 09:55    [W:0.047 / U:0.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site