From: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@linux.intel.com>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>,
hkallweit1@gmail.com, nic_swsd@realtek.com, bhelgaas@google.com
Cc: koba.ko@canonical.com, acelan.kao@canonical.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, vidyas@nvidia.com, rafael.j.wysocki@intel.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org
Subject: Re: [PATCH net-next v9 4/5] r8169: Use spinlock to guard config register locking
Date: Fri, 24 Feb 2023 22:16:33 -0800 [thread overview]
Message-ID: <2221692c-96d4-441e-019f-f62a77f70acd@linux.intel.com> (raw)
In-Reply-To: <20230225034635.2220386-5-kai.heng.feng@canonical.com>
On 2/24/23 7:46 PM, Kai-Heng Feng wrote:
> Right now r8169 doesn't have parallel access to its config register, but
> the next patch makes the driver access config register at anytime.
>
> So add a spinlock to protect the config register from any potential race.
>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
> v9:
> - Replace mutex with spinlock so it can be used in softirq context.
>
> v8:
> - Swap the place when using the mutex. Protect when config register is
> unlocked.
>
> 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 a857650c2e82b..fb73b5386701f 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -613,6 +613,8 @@ struct rtl8169_private {
> struct work_struct work;
> } wk;
>
> + spinlock_t config_lock;
> +
> unsigned supports_gmii:1;
> unsigned aspm_manageable:1;
> dma_addr_t counters_phys_addr;
> @@ -662,10 +664,12 @@ 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);
> + spin_unlock_bh(&tp->config_lock);
You mean spin_lock_bh() here right?
> }
>
> static void rtl_unlock_config_regs(struct rtl8169_private *tp)
> {
> + spin_lock_bh(&tp->config_lock);
> RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
> }
>
> @@ -5217,6 +5221,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> return rc;
> }
>
> + spin_lock_init(&tp->config_lock);
> +
> tp->mmio_addr = pcim_iomap_table(pdev)[region];
>
> xid = (RTL_R32(tp, TxConfig) >> 20) & 0xfcf;
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
next prev parent reply other threads:[~2023-02-25 6:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-25 3:46 [PATCH net-next v9 0/5] r8169: Temporarily disable ASPM on NAPI poll Kai-Heng Feng
2023-02-25 3:46 ` [PATCH net-next v9 1/5] Revert "PCI/ASPM: Unexport pcie_aspm_support_enabled()" Kai-Heng Feng
2023-02-25 6:09 ` Sathyanarayanan Kuppuswamy
2023-02-25 3:46 ` [PATCH net-next v9 2/5] PCI/ASPM: Add pcie_aspm_capable() helper Kai-Heng Feng
2023-02-25 6:10 ` Sathyanarayanan Kuppuswamy
2023-02-25 3:46 ` [PATCH net-next v9 3/5] r8169: Consider chip-specific ASPM can be enabled on more cases Kai-Heng Feng
2023-02-25 6:13 ` Sathyanarayanan Kuppuswamy
2023-03-09 20:17 ` Bjorn Helgaas
2023-03-10 20:42 ` Heiner Kallweit
2023-03-10 20:48 ` Bjorn Helgaas
2023-02-25 3:46 ` [PATCH net-next v9 4/5] r8169: Use spinlock to guard config register locking Kai-Heng Feng
2023-02-25 6:16 ` Sathyanarayanan Kuppuswamy [this message]
2023-02-25 3:46 ` [PATCH net-next v9 5/5] r8169: Disable ASPM while doing NAPI poll Kai-Heng Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2221692c-96d4-441e-019f-f62a77f70acd@linux.intel.com \
--to=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=acelan.kao@canonical.com \
--cc=bhelgaas@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kai.heng.feng@canonical.com \
--cc=koba.ko@canonical.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=pabeni@redhat.com \
--cc=rafael.j.wysocki@intel.com \
--cc=vidyas@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).