netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] r8169: improvements for scheduled task handling
@ 2020-03-22 18:01 Heiner Kallweit
  2020-03-22 18:02 ` [PATCH net-next 1/3] r8169: simplify rtl_task Heiner Kallweit
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Heiner Kallweit @ 2020-03-22 18:01 UTC (permalink / raw)
  To: Realtek linux nic maintainers, David Miller; +Cc: netdev

This series includes some improvements for handling of scheduled tasks.

Heiner Kallweit (3):
  r8169: simplify rtl_task
  r8169: improve rtl_schedule_task
  r8169: improve RTL8168b FIFO overflow workaround

 drivers/net/ethernet/realtek/r8169_main.c | 27 +++++------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

-- 
2.25.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next 1/3] r8169: simplify rtl_task
  2020-03-22 18:01 [PATCH net-next 0/3] r8169: improvements for scheduled task handling Heiner Kallweit
@ 2020-03-22 18:02 ` Heiner Kallweit
  2020-03-22 18:03 ` [PATCH net-next 2/3] r8169: improve rtl_schedule_task Heiner Kallweit
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2020-03-22 18:02 UTC (permalink / raw)
  To: Realtek linux nic maintainers, David Miller; +Cc: netdev

Currently rtl_task() is designed to handle a large number of tasks.
However we have just one, so we can remove some overhead.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index d2eef3754..242b14cc7 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4589,31 +4589,17 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
 
 static void rtl_task(struct work_struct *work)
 {
-	static const struct {
-		int bitnr;
-		void (*action)(struct rtl8169_private *);
-	} rtl_work[] = {
-		{ RTL_FLAG_TASK_RESET_PENDING,	rtl_reset_work },
-	};
 	struct rtl8169_private *tp =
 		container_of(work, struct rtl8169_private, wk.work);
-	struct net_device *dev = tp->dev;
-	int i;
 
 	rtl_lock_work(tp);
 
-	if (!netif_running(dev) ||
+	if (!netif_running(tp->dev) ||
 	    !test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
 		goto out_unlock;
 
-	for (i = 0; i < ARRAY_SIZE(rtl_work); i++) {
-		bool pending;
-
-		pending = test_and_clear_bit(rtl_work[i].bitnr, tp->wk.flags);
-		if (pending)
-			rtl_work[i].action(tp);
-	}
-
+	if (test_and_clear_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags))
+		rtl_reset_work(tp);
 out_unlock:
 	rtl_unlock_work(tp);
 }
-- 
2.25.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 2/3] r8169: improve rtl_schedule_task
  2020-03-22 18:01 [PATCH net-next 0/3] r8169: improvements for scheduled task handling Heiner Kallweit
  2020-03-22 18:02 ` [PATCH net-next 1/3] r8169: simplify rtl_task Heiner Kallweit
@ 2020-03-22 18:03 ` Heiner Kallweit
  2020-03-22 18:03 ` [PATCH net-next 3/3] r8169: improve RTL8168b FIFO overflow workaround Heiner Kallweit
  2020-03-24  4:38 ` [PATCH net-next 0/3] r8169: improvements for scheduled task handling David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2020-03-22 18:03 UTC (permalink / raw)
  To: Realtek linux nic maintainers, David Miller; +Cc: netdev

The current implementation makes the implicit assumption that if a bit
is set, then the work is scheduled already. Remove the need for this
implicit assumption and call schedule_work() always. It will check
internally whether the work is scheduled already.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 242b14cc7..e9ced0360 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -2228,8 +2228,8 @@ u16 rtl8168h_2_get_adc_bias_ioffset(struct rtl8169_private *tp)
 
 static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag)
 {
-	if (!test_and_set_bit(flag, tp->wk.flags))
-		schedule_work(&tp->wk.work);
+	set_bit(flag, tp->wk.flags);
+	schedule_work(&tp->wk.work);
 }
 
 static void rtl8169_init_phy(struct rtl8169_private *tp)
-- 
2.25.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 3/3] r8169: improve RTL8168b FIFO overflow workaround
  2020-03-22 18:01 [PATCH net-next 0/3] r8169: improvements for scheduled task handling Heiner Kallweit
  2020-03-22 18:02 ` [PATCH net-next 1/3] r8169: simplify rtl_task Heiner Kallweit
  2020-03-22 18:03 ` [PATCH net-next 2/3] r8169: improve rtl_schedule_task Heiner Kallweit
@ 2020-03-22 18:03 ` Heiner Kallweit
  2020-03-24  4:38 ` [PATCH net-next 0/3] r8169: improvements for scheduled task handling David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2020-03-22 18:03 UTC (permalink / raw)
  To: Realtek linux nic maintainers, David Miller; +Cc: netdev

So far only the reset bit it set, but the handler executing the reset
is not scheduled. Therefore nothing will happen until some other action
schedules the handler. Improve this by ensuring that the handler is
scheduled.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index e9ced0360..b7dc1c112 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4575,8 +4575,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
 	if (unlikely(status & RxFIFOOver &&
 	    tp->mac_version == RTL_GIGA_MAC_VER_11)) {
 		netif_stop_queue(tp->dev);
-		/* XXX - Hack alert. See rtl_task(). */
-		set_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags);
+		rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
 	}
 
 	rtl_irq_disable(tp);
-- 
2.25.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 0/3] r8169: improvements for scheduled task handling
  2020-03-22 18:01 [PATCH net-next 0/3] r8169: improvements for scheduled task handling Heiner Kallweit
                   ` (2 preceding siblings ...)
  2020-03-22 18:03 ` [PATCH net-next 3/3] r8169: improve RTL8168b FIFO overflow workaround Heiner Kallweit
@ 2020-03-24  4:38 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-03-24  4:38 UTC (permalink / raw)
  To: hkallweit1; +Cc: nic_swsd, netdev

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Sun, 22 Mar 2020 19:01:31 +0100

> This series includes some improvements for handling of scheduled tasks.

Series applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-24  4:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-22 18:01 [PATCH net-next 0/3] r8169: improvements for scheduled task handling Heiner Kallweit
2020-03-22 18:02 ` [PATCH net-next 1/3] r8169: simplify rtl_task Heiner Kallweit
2020-03-22 18:03 ` [PATCH net-next 2/3] r8169: improve rtl_schedule_task Heiner Kallweit
2020-03-22 18:03 ` [PATCH net-next 3/3] r8169: improve RTL8168b FIFO overflow workaround Heiner Kallweit
2020-03-24  4:38 ` [PATCH net-next 0/3] r8169: improvements for scheduled task handling David Miller

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).