From: Stephen Hemminger <shemminger@linux-foundation.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 1/6] sky2: status polling loop (post merge)
Date: Thu, 11 Oct 2007 18:29:21 -0700 [thread overview]
Message-ID: <20071011182921.1b20505c@freepuppy.rosehill> (raw)
In-Reply-To: <20071011.182358.21595252.davem@davemloft.net>
Handle the corner case where budget is exhausted correctly.
And save unnecessary read of index register.
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
--- a/drivers/net/sky2.c 2007-10-11 18:26:56.000000000 -0700
+++ b/drivers/net/sky2.c 2007-10-11 18:27:12.000000000 -0700
@@ -2245,15 +2245,13 @@ static inline void sky2_tx_done(struct n
}
/* Process status response ring */
-static int sky2_status_intr(struct sky2_hw *hw, int to_do)
+static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
{
int work_done = 0;
unsigned rx[2] = { 0, 0 };
- u16 hwidx = sky2_read16(hw, STAT_PUT_IDX);
rmb();
-
- while (hw->st_idx != hwidx) {
+ do {
struct sky2_port *sky2;
struct sky2_status_le *le = hw->st_le + hw->st_idx;
unsigned port = le->css & CSS_LINK_BIT;
@@ -2364,7 +2362,7 @@ static int sky2_status_intr(struct sky2_
printk(KERN_WARNING PFX
"unknown status opcode 0x%x\n", le->opcode);
}
- }
+ } while (hw->st_idx != idx);
/* Fully processed status ring so clear irq */
sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
@@ -2607,6 +2605,7 @@ static int sky2_poll(struct napi_struct
struct sky2_hw *hw = container_of(napi, struct sky2_hw, napi);
u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
int work_done = 0;
+ u16 idx;
if (unlikely(status & Y2_IS_ERROR))
sky2_err_intr(hw, status);
@@ -2617,29 +2616,23 @@ static int sky2_poll(struct napi_struct
if (status & Y2_IS_IRQ_PHY2)
sky2_phy_intr(hw, 1);
- for(;;) {
- work_done += sky2_status_intr(hw, work_limit);
+ while ((idx = sky2_read16(hw, STAT_PUT_IDX)) != hw->st_idx) {
+ work_done += sky2_status_intr(hw, work_limit - work_done, idx);
if (work_done >= work_limit)
- break;
-
- /* More work? */
- if (hw->st_idx != sky2_read16(hw, STAT_PUT_IDX))
- continue;
-
- /* Bug/Errata workaround?
- * Need to kick the TX irq moderation timer.
- */
- if (sky2_read8(hw, STAT_TX_TIMER_CTRL) == TIM_START) {
- sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
- sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
- }
-
- napi_complete(napi);
- sky2_read32(hw, B0_Y2_SP_LISR);
- break;
+ goto done;
+ }
+ /* Bug/Errata workaround?
+ * Need to kick the TX irq moderation timer.
+ */
+ if (sky2_read8(hw, STAT_TX_TIMER_CTRL) == TIM_START) {
+ sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
+ sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
}
+ napi_complete(napi);
+ sky2_read32(hw, B0_Y2_SP_LISR);
+done:
return work_done;
}
next prev parent reply other threads:[~2007-10-12 1:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-12 1:19 [PATCH 0/6] sky2 patches for net-2.6 Stephen Hemminger
2007-10-12 1:19 ` [PATCH 1/6] sky2: status polling loop Stephen Hemminger
2007-10-12 1:23 ` David Miller
2007-10-12 1:25 ` Stephen Hemminger
2007-10-12 1:29 ` Stephen Hemminger [this message]
2007-10-12 1:31 ` [PATCH 1/6] sky2: status polling loop (post merge) David Miller
2007-10-12 1:36 ` Stephen Hemminger
2007-10-12 1:19 ` [PATCH 2/6] sky2: ethtool register reserved area blackout Stephen Hemminger
2007-10-12 1:19 ` [PATCH 3/6] sky2: fix power settings on Yukon XL Stephen Hemminger
2007-10-12 1:19 ` [PATCH 4/6] sky2: fiber advertise bits initialization (trivial) Stephen Hemminger
2007-10-12 1:19 ` [PATCH 5/6] sky2: use netdevice stats struct Stephen Hemminger
2007-10-12 1:19 ` [PATCH 6/6] sky2: version 1.19 Stephen Hemminger
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=20071011182921.1b20505c@freepuppy.rosehill \
--to=shemminger@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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