From: "Wells Lu 呂芳騰" <wells.lu@sunplus.com>
To: Francois Romieu <romieu@fr.zoreil.com>, Wells Lu <wellslutw@gmail.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
"kuba@kernel.org" <kuba@kernel.org>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
"roopa@nvidia.com" <roopa@nvidia.com>,
"andrew@lunn.ch" <andrew@lunn.ch>,
"edumazet@google.com" <edumazet@google.com>
Subject: RE: [PATCH net-next v9 2/2] net: ethernet: Add driver for Sunplus SP7021
Date: Thu, 28 Apr 2022 11:32:56 +0000 [thread overview]
Message-ID: <ff2077684c4c45fca929a8f61447242b@sphcmbx02.sunplus.com.tw> (raw)
In-Reply-To: <Ymh3si+MTg5i0Bnl@electric-eye.fr.zoreil.com>
Hi Francois,
> [...]
> > +int spl2sw_rx_poll(struct napi_struct *napi, int budget) {
> [...]
> > + wmb(); /* make sure settings are effective. */
> > + mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
> > + mask &= ~MAC_INT_RX;
> > + writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
> > +
> > + napi_complete(napi);
> > + return 0;
> > +}
> > +
> > +int spl2sw_tx_poll(struct napi_struct *napi, int budget) {
> [...]
> > + wmb(); /* make sure settings are effective. */
> > + mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
> > + mask &= ~MAC_INT_TX;
> > + writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
> > +
> > + napi_complete(napi);
> > + return 0;
> > +}
> > +
> > +irqreturn_t spl2sw_ethernet_interrupt(int irq, void *dev_id) {
> [...]
> > + if (status & MAC_INT_RX) {
> > + /* Disable RX interrupts. */
> > + mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
> > + mask |= MAC_INT_RX;
> > + writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
> [...]
> > + napi_schedule(&comm->rx_napi);
> > + }
> > +
> > + if (status & MAC_INT_TX) {
> > + /* Disable TX interrupts. */
> > + mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
> > + mask |= MAC_INT_TX;
> > + writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
> > +
> > + if (unlikely(status & MAC_INT_TX_DES_ERR)) {
> [...]
> > + } else {
> > + napi_schedule(&comm->tx_napi);
> > + }
> > + }
>
> The readl/writel sequence in rx_poll (or tx_poll) races with the irq handler performing
> MAC_INT_TX (or MAC_INT_RX) work. If the readl returns the same value to both callers,
> one of the writel will be overwritten.
>
> --
> Ueimor
I will add disable_irq() and enable_irq() for spl2sw_rx_poll() and spl2sw_tx_poll() as shown below:
spl2sw_rx_poll():
wmb(); /* make sure settings are effective. */
disable_irq(comm->irq);
mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
mask &= ~MAC_INT_RX;
writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
enable_irq(comm->irq);
spl2sw_tx_poll():
wmb(); /* make sure settings are effective. */
disable_irq(comm->irq);
mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
mask &= ~MAC_INT_TX;
writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
enable_irq(comm->irq);
Is the modification ok?
Thank you for your review.
Best regards,
Wells
next prev parent reply other threads:[~2022-04-28 11:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-25 10:30 [PATCH net-next v9 0/2] This is a patch series for Ethernet driver of Sunplus SP7021 SoC Wells Lu
2022-04-25 10:30 ` [PATCH net-next v9 1/2] devicetree: bindings: net: Add bindings doc for Sunplus SP7021 Wells Lu
2022-04-25 10:30 ` [PATCH net-next v9 2/2] net: ethernet: Add driver " Wells Lu
2022-04-25 16:24 ` Stephen Hemminger
2022-04-26 1:37 ` Wells Lu 呂芳騰
2022-04-25 16:32 ` Stephen Hemminger
2022-04-26 3:03 ` Wells Lu 呂芳騰
2022-04-26 22:52 ` Francois Romieu
2022-04-28 11:32 ` Wells Lu 呂芳騰 [this message]
2022-04-28 21:35 ` Francois Romieu
2022-04-29 3:46 ` Wells Lu 呂芳騰
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=ff2077684c4c45fca929a8f61447242b@sphcmbx02.sunplus.com.tw \
--to=wells.lu@sunplus.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=robh+dt@kernel.org \
--cc=romieu@fr.zoreil.com \
--cc=roopa@nvidia.com \
--cc=wellslutw@gmail.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
all inboxes | Powered by JetHome®