netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stefan Sørensen" <stefan.sorensen@spectralink.com>
To: <davem@davemloft.net>
Cc: netdev@vger.kernel.org, richardcochran@gmail.com,
	"Stefan Sørensen" <stefan.sorensen@spectralink.com>
Subject: [PATCH net-next 2/5] dp83640: Delay scheduled work.
Date: Fri, 30 Oct 2015 13:14:01 +0100	[thread overview]
Message-ID: <1446207244-2206-3-git-send-email-stefan.sorensen@spectralink.com> (raw)
In-Reply-To: <1446207244-2206-1-git-send-email-stefan.sorensen@spectralink.com>

Currently rx_timestamp_work reschedules itself as a regular workqueue item,
effectively causing it run constantly as long as there are packets left in
the queue. Fix by using delayed workqueue items, limiting it to run only
every two jiffies.

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
---
 drivers/net/phy/dp83640.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 9534478..f3e812b 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -69,6 +69,8 @@
 /* phyter seems to miss the mark by 16 ns */
 #define ADJTIME_FIX	16
 
+#define SKB_TIMESTAMP_TIMEOUT	2 /* jiffies */
+
 #if defined(__BIG_ENDIAN)
 #define ENDIAN_FLAG	0
 #elif defined(__LITTLE_ENDIAN)
@@ -111,7 +113,7 @@ struct dp83640_private {
 	struct list_head list;
 	struct dp83640_clock *clock;
 	struct phy_device *phydev;
-	struct work_struct ts_work;
+	struct delayed_work ts_work;
 	int hwts_tx_en;
 	int hwts_rx_en;
 	int layer;
@@ -285,7 +287,7 @@ static void phy2rxts(struct phy_rxts *p, struct rxts *rxts)
 	rxts->seqid = p->seqid;
 	rxts->msgtype = (p->msgtype >> 12) & 0xf;
 	rxts->hash = p->msgtype & 0x0fff;
-	rxts->tmo = jiffies + 2;
+	rxts->tmo = jiffies + SKB_TIMESTAMP_TIMEOUT;
 }
 
 static u64 phy2txts(struct phy_txts *p)
@@ -1111,7 +1113,7 @@ static int dp83640_probe(struct phy_device *phydev)
 		goto no_memory;
 
 	dp83640->phydev = phydev;
-	INIT_WORK(&dp83640->ts_work, rx_timestamp_work);
+	INIT_DELAYED_WORK(&dp83640->ts_work, rx_timestamp_work);
 
 	INIT_LIST_HEAD(&dp83640->rxts);
 	INIT_LIST_HEAD(&dp83640->rxpool);
@@ -1158,7 +1160,7 @@ static void dp83640_remove(struct phy_device *phydev)
 		return;
 
 	enable_status_frames(phydev, false);
-	cancel_work_sync(&dp83640->ts_work);
+	cancel_delayed_work_sync(&dp83640->ts_work);
 
 	skb_queue_purge(&dp83640->rx_queue);
 	skb_queue_purge(&dp83640->tx_queue);
@@ -1352,7 +1354,7 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
 static void rx_timestamp_work(struct work_struct *work)
 {
 	struct dp83640_private *dp83640 =
-		container_of(work, struct dp83640_private, ts_work);
+		container_of(work, struct dp83640_private, ts_work.work);
 	struct sk_buff *skb;
 
 	/* Deliver expired packets. */
@@ -1369,7 +1371,7 @@ static void rx_timestamp_work(struct work_struct *work)
 	}
 
 	if (!skb_queue_empty(&dp83640->rx_queue))
-		schedule_work(&dp83640->ts_work);
+		schedule_delayed_work(&dp83640->ts_work, SKB_TIMESTAMP_TIMEOUT);
 }
 
 static bool dp83640_rxtstamp(struct phy_device *phydev,
@@ -1408,9 +1410,11 @@ static bool dp83640_rxtstamp(struct phy_device *phydev,
 
 	if (!shhwtstamps) {
 		skb_info->ptp_type = type;
-		skb_info->tmo = jiffies + 2;
+		skb_info->tmo = jiffies + SKB_TIMESTAMP_TIMEOUT;
 		skb_queue_tail(&dp83640->rx_queue, skb);
-		schedule_work(&dp83640->ts_work);
+		schedule_delayed_work(&dp83640->ts_work, SKB_TIMESTAMP_TIMEOUT);
+	} else {
+		netif_rx_ni(skb);
 	}
 
 	return true;
-- 
2.5.0

  parent reply	other threads:[~2015-10-30 12:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 12:13 [PATCH net-next 0/5] dp83640 driver fixes Stefan Sørensen
2015-10-30 12:14 ` [PATCH net-next 1/5] dp83640: Include hash in timestamp/packet matching Stefan Sørensen
2015-10-30 20:32   ` Richard Cochran
2015-10-30 12:14 ` Stefan Sørensen [this message]
2015-10-30 20:37   ` [PATCH net-next 2/5] dp83640: Delay scheduled work Richard Cochran
2015-11-02  7:23     ` Sørensen, Stefan
2015-11-02  9:59       ` Richard Cochran
2015-10-30 12:14 ` [PATCH net-next 3/5] dp83640: Prune rx timestamp list before reading from it Stefan Sørensen
2015-10-30 20:38   ` Richard Cochran
2015-10-30 12:14 ` [PATCH net-next 4/5] ptp: Change ptp_class to a proper bitmask Stefan Sørensen
2015-10-30 20:39   ` Richard Cochran
2015-10-30 12:14 ` [PATCH net-next 5/5] dp83640: Only wait for timestamps for packets with timestamping enabled Stefan Sørensen
2015-10-30 20:40   ` Richard Cochran
2015-11-02 20:13 ` [PATCH net-next 0/5] dp83640 driver fixes David Miller
2015-11-03  8:42   ` Richard Cochran

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=1446207244-2206-3-git-send-email-stefan.sorensen@spectralink.com \
    --to=stefan.sorensen@spectralink.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@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;
as well as URLs for NNTP newsgroup(s).