Skip to content

Commit

Permalink
net: txgbe: fix GPIO interrupt blocking
Browse files Browse the repository at this point in the history
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().

Fixes: aefd013 ("net: txgbe: use irq_domain for interrupt controller")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Link: https://lore.kernel.org/r/20240301092956.18544-1-jiawenwu@trustnetic.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Jiawen Wu authored and Paolo Abeni committed Mar 5, 2024
1 parent b307e25 commit b4a2496
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
27 changes: 27 additions & 0 deletions drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,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;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b4a2496

Please sign in to comment.