diff mbox series

[v2] net: txgbe: fix GPIO interrupt blocking

Message ID 20240229024237.22568-1-jiawenwu@trustnetic.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: txgbe: fix GPIO interrupt blocking | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 940 this patch: 940
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: maciej.fijalkowski@intel.com
netdev/build_clang success Errors and warnings before: 957 this patch: 957
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 957 this patch: 957
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 57 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-29--21-00 (tests: 885)

Commit Message

Jiawen Wu Feb. 29, 2024, 2:42 a.m. UTC
There were two problems to be solved in this patch:

1. The register of GPIO interrupt status is masked before MAC IRQ
is enabled. This is because of hardware deficiency. So manually
clear the interrupt status before using them. Otherwise, GPIO
interrupts will never be reported again. There is a workaround for
clearing interrupts to set GPIO EOI in txgbe_up_complete().

2. GPIO EOI is not set to clear interrupt status after handling
the interrupt. It should be done in irq_chip->irq_ack, but this
function is not called in handle_nested_irq(). So executing
function txgbe_gpio_irq_ack() manually in txgbe_gpio_irq_handler().

Fixes: aefd013624a1 ("net: txgbe: use irq_domain for interrupt controller")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 .../net/ethernet/wangxun/txgbe/txgbe_main.c   |  1 +
 .../net/ethernet/wangxun/txgbe/txgbe_phy.c    | 29 +++++++++++++++++++
 .../net/ethernet/wangxun/txgbe/txgbe_phy.h    |  1 +
 3 files changed, 31 insertions(+)

Comments

Jiri Pirko Feb. 29, 2024, 9:32 a.m. UTC | #1
Thu, Feb 29, 2024 at 03:42:37AM CET, jiawenwu@trustnetic.com wrote:
>There were two problems to be solved in this patch:
>
>1. The register of GPIO interrupt status is masked before MAC IRQ
>is enabled. This is because of hardware deficiency. So manually
>clear the interrupt status before using them. Otherwise, GPIO
>interrupts will never be reported again. There is a workaround for
>clearing interrupts to set GPIO EOI in txgbe_up_complete().
>
>2. GPIO EOI is not set to clear interrupt status after handling
>the interrupt. It should be done in irq_chip->irq_ack, but this
>function is not called in handle_nested_irq(). So executing
>function txgbe_gpio_irq_ack() manually in txgbe_gpio_irq_handler().

Two patches then, no?


>
>Fixes: aefd013624a1 ("net: txgbe: use irq_domain for interrupt controller")
>Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
>---
> .../net/ethernet/wangxun/txgbe/txgbe_main.c   |  1 +
> .../net/ethernet/wangxun/txgbe/txgbe_phy.c    | 29 +++++++++++++++++++
> .../net/ethernet/wangxun/txgbe/txgbe_phy.h    |  1 +
> 3 files changed, 31 insertions(+)
>
>diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
>index e67a21294158..bd4624d14ca0 100644
>--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
>+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
>@@ -81,6 +81,7 @@ static void txgbe_up_complete(struct wx *wx)
> {
> 	struct net_device *netdev = wx->netdev;
> 
>+	txgbe_reinit_gpio_intr(wx);
> 	wx_control_hw(wx, true);
> 	wx_configure_vectors(wx);
> 
>diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
>index bae0a8ee7014..93295916b1d2 100644
>--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
>+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
>@@ -475,8 +475,10 @@ irqreturn_t txgbe_gpio_irq_handler(int irq, void *data)
> 	gc = txgbe->gpio;
> 	for_each_set_bit(hwirq, &gpioirq, gc->ngpio) {
> 		int gpio = irq_find_mapping(gc->irq.domain, hwirq);
>+		struct irq_data *d = irq_get_irq_data(gpio);
> 		u32 irq_type = irq_get_trigger_type(gpio);
> 
>+		txgbe_gpio_irq_ack(d);
> 		handle_nested_irq(gpio);
> 
> 		if ((irq_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
>@@ -489,6 +491,33 @@ irqreturn_t txgbe_gpio_irq_handler(int irq, void *data)
> 	return IRQ_HANDLED;
> }
> 
>+void txgbe_reinit_gpio_intr(struct wx *wx)
>+{
>+	struct txgbe *txgbe = wx->priv;
>+	irq_hw_number_t hwirq;
>+	unsigned long gpioirq;
>+	struct gpio_chip *gc;
>+	unsigned long flags;
>+
>+	/* for gpio interrupt pending before irq enable */
>+	gpioirq = rd32(wx, WX_GPIO_INTSTATUS);
>+
>+	gc = txgbe->gpio;
>+	for_each_set_bit(hwirq, &gpioirq, gc->ngpio) {
>+		int gpio = irq_find_mapping(gc->irq.domain, hwirq);
>+		struct irq_data *d = irq_get_irq_data(gpio);
>+		u32 irq_type = irq_get_trigger_type(gpio);
>+
>+		txgbe_gpio_irq_ack(d);
>+
>+		if ((irq_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
>+			raw_spin_lock_irqsave(&wx->gpio_lock, flags);
>+			txgbe_toggle_trigger(gc, hwirq);
>+			raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
>+		}
>+	}
>+}
>+
> static int txgbe_gpio_init(struct txgbe *txgbe)
> {
> 	struct gpio_irq_chip *girq;
>diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h
>index 9855d44076cb..8a026d804fe2 100644
>--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h
>+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h
>@@ -5,6 +5,7 @@
> #define _TXGBE_PHY_H_
> 
> irqreturn_t txgbe_gpio_irq_handler(int irq, void *data);
>+void txgbe_reinit_gpio_intr(struct wx *wx);
> irqreturn_t txgbe_link_irq_handler(int irq, void *data);
> int txgbe_init_phy(struct txgbe *txgbe);
> void txgbe_remove_phy(struct txgbe *txgbe);
>-- 
>2.27.0
>
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
index e67a21294158..bd4624d14ca0 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
@@ -81,6 +81,7 @@  static void txgbe_up_complete(struct wx *wx)
 {
 	struct net_device *netdev = wx->netdev;
 
+	txgbe_reinit_gpio_intr(wx);
 	wx_control_hw(wx, true);
 	wx_configure_vectors(wx);
 
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
index bae0a8ee7014..93295916b1d2 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
@@ -475,8 +475,10 @@  irqreturn_t txgbe_gpio_irq_handler(int irq, void *data)
 	gc = txgbe->gpio;
 	for_each_set_bit(hwirq, &gpioirq, gc->ngpio) {
 		int gpio = irq_find_mapping(gc->irq.domain, hwirq);
+		struct irq_data *d = irq_get_irq_data(gpio);
 		u32 irq_type = irq_get_trigger_type(gpio);
 
+		txgbe_gpio_irq_ack(d);
 		handle_nested_irq(gpio);
 
 		if ((irq_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
@@ -489,6 +491,33 @@  irqreturn_t txgbe_gpio_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+void txgbe_reinit_gpio_intr(struct wx *wx)
+{
+	struct txgbe *txgbe = wx->priv;
+	irq_hw_number_t hwirq;
+	unsigned long gpioirq;
+	struct gpio_chip *gc;
+	unsigned long flags;
+
+	/* for gpio interrupt pending before irq enable */
+	gpioirq = rd32(wx, WX_GPIO_INTSTATUS);
+
+	gc = txgbe->gpio;
+	for_each_set_bit(hwirq, &gpioirq, gc->ngpio) {
+		int gpio = irq_find_mapping(gc->irq.domain, hwirq);
+		struct irq_data *d = irq_get_irq_data(gpio);
+		u32 irq_type = irq_get_trigger_type(gpio);
+
+		txgbe_gpio_irq_ack(d);
+
+		if ((irq_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
+			raw_spin_lock_irqsave(&wx->gpio_lock, flags);
+			txgbe_toggle_trigger(gc, hwirq);
+			raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
+		}
+	}
+}
+
 static int txgbe_gpio_init(struct txgbe *txgbe)
 {
 	struct gpio_irq_chip *girq;
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h
index 9855d44076cb..8a026d804fe2 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h
@@ -5,6 +5,7 @@ 
 #define _TXGBE_PHY_H_
 
 irqreturn_t txgbe_gpio_irq_handler(int irq, void *data);
+void txgbe_reinit_gpio_intr(struct wx *wx);
 irqreturn_t txgbe_link_irq_handler(int irq, void *data);
 int txgbe_init_phy(struct txgbe *txgbe);
 void txgbe_remove_phy(struct txgbe *txgbe);