Skip to content

Commit

Permalink
r8169: enable cfg9346 config register access in atomic context
Browse files Browse the repository at this point in the history
For disabling ASPM during NAPI poll we'll have to unlock access
to the config registers in atomic context. Other code parts
running with config register access unlocked are partially
longer and can sleep. Add a usage counter to enable parallel
execution of code parts requiring unlocked config registers.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Tested-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Heiner Kallweit authored and David S. Miller committed Mar 8, 2023
1 parent 6bc6c4e commit 59ee97c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions drivers/net/ethernet/realtek/r8169_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ struct rtl8169_private {
spinlock_t config25_lock;
spinlock_t mac_ocp_lock;

spinlock_t cfg9346_usage_lock;
int cfg9346_usage_count;

unsigned supports_gmii:1;
unsigned aspm_manageable:1;
dma_addr_t counters_phys_addr;
Expand Down Expand Up @@ -664,12 +667,22 @@ static inline struct device *tp_to_dev(struct rtl8169_private *tp)

static void rtl_lock_config_regs(struct rtl8169_private *tp)
{
RTL_W8(tp, Cfg9346, Cfg9346_Lock);
unsigned long flags;

spin_lock_irqsave(&tp->cfg9346_usage_lock, flags);
if (!--tp->cfg9346_usage_count)
RTL_W8(tp, Cfg9346, Cfg9346_Lock);
spin_unlock_irqrestore(&tp->cfg9346_usage_lock, flags);
}

static void rtl_unlock_config_regs(struct rtl8169_private *tp)
{
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
unsigned long flags;

spin_lock_irqsave(&tp->cfg9346_usage_lock, flags);
if (!tp->cfg9346_usage_count++)
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
spin_unlock_irqrestore(&tp->cfg9346_usage_lock, flags);
}

static void rtl_pci_commit(struct rtl8169_private *tp)
Expand Down Expand Up @@ -5229,6 +5242,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->eee_adv = -1;
tp->ocp_base = OCP_STD_PHY_BASE;

spin_lock_init(&tp->cfg9346_usage_lock);
spin_lock_init(&tp->config25_lock);
spin_lock_init(&tp->mac_ocp_lock);

Expand Down

0 comments on commit 59ee97c

Please sign in to comment.