Skip to content

Commit e867ed3

Browse files
Jiawen Wukuba-moo
authored andcommitted
net: txgbe: remove GPIO interrupt controller
Since the GPIO interrupt controller is always not working properly, we need to constantly add workaround to cope with hardware deficiencies. So just remove GPIO interrupt controller, and let the SFP driver poll the GPIO status. Fixes: b4a2496 ("net: txgbe: fix GPIO interrupt blocking") Signed-off-by: Jiawen Wu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4be4a91 commit e867ed3

File tree

5 files changed

+4
-196
lines changed

5 files changed

+4
-196
lines changed

drivers/net/ethernet/wangxun/txgbe/txgbe_irq.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ int txgbe_request_queue_irqs(struct wx *wx)
7272
return err;
7373
}
7474

75-
static int txgbe_request_gpio_irq(struct txgbe *txgbe)
76-
{
77-
txgbe->gpio_irq = irq_find_mapping(txgbe->misc.domain, TXGBE_IRQ_GPIO);
78-
return request_threaded_irq(txgbe->gpio_irq, NULL,
79-
txgbe_gpio_irq_handler,
80-
IRQF_ONESHOT, "txgbe-gpio-irq", txgbe);
81-
}
82-
8375
static int txgbe_request_link_irq(struct txgbe *txgbe)
8476
{
8577
txgbe->link_irq = irq_find_mapping(txgbe->misc.domain, TXGBE_IRQ_LINK);
@@ -149,11 +141,6 @@ static irqreturn_t txgbe_misc_irq_thread_fn(int irq, void *data)
149141
u32 eicr;
150142

151143
eicr = wx_misc_isb(wx, WX_ISB_MISC);
152-
if (eicr & TXGBE_PX_MISC_GPIO) {
153-
sub_irq = irq_find_mapping(txgbe->misc.domain, TXGBE_IRQ_GPIO);
154-
handle_nested_irq(sub_irq);
155-
nhandled++;
156-
}
157144
if (eicr & (TXGBE_PX_MISC_ETH_LK | TXGBE_PX_MISC_ETH_LKDN |
158145
TXGBE_PX_MISC_ETH_AN)) {
159146
sub_irq = irq_find_mapping(txgbe->misc.domain, TXGBE_IRQ_LINK);
@@ -179,7 +166,6 @@ static void txgbe_del_irq_domain(struct txgbe *txgbe)
179166

180167
void txgbe_free_misc_irq(struct txgbe *txgbe)
181168
{
182-
free_irq(txgbe->gpio_irq, txgbe);
183169
free_irq(txgbe->link_irq, txgbe);
184170
free_irq(txgbe->misc.irq, txgbe);
185171
txgbe_del_irq_domain(txgbe);
@@ -191,7 +177,7 @@ int txgbe_setup_misc_irq(struct txgbe *txgbe)
191177
struct wx *wx = txgbe->wx;
192178
int hwirq, err;
193179

194-
txgbe->misc.nirqs = 2;
180+
txgbe->misc.nirqs = 1;
195181
txgbe->misc.domain = irq_domain_add_simple(NULL, txgbe->misc.nirqs, 0,
196182
&txgbe_misc_irq_domain_ops, txgbe);
197183
if (!txgbe->misc.domain)
@@ -216,20 +202,14 @@ int txgbe_setup_misc_irq(struct txgbe *txgbe)
216202
if (err)
217203
goto del_misc_irq;
218204

219-
err = txgbe_request_gpio_irq(txgbe);
220-
if (err)
221-
goto free_msic_irq;
222-
223205
err = txgbe_request_link_irq(txgbe);
224206
if (err)
225-
goto free_gpio_irq;
207+
goto free_msic_irq;
226208

227209
wx->misc_irq_domain = true;
228210

229211
return 0;
230212

231-
free_gpio_irq:
232-
free_irq(txgbe->gpio_irq, txgbe);
233213
free_msic_irq:
234214
free_irq(txgbe->misc.irq, txgbe);
235215
del_misc_irq:

drivers/net/ethernet/wangxun/txgbe/txgbe_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ static void txgbe_up_complete(struct wx *wx)
8282
{
8383
struct net_device *netdev = wx->netdev;
8484

85-
txgbe_reinit_gpio_intr(wx);
8685
wx_control_hw(wx, true);
8786
wx_configure_vectors(wx);
8887

drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c

Lines changed: 0 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -358,169 +358,8 @@ static int txgbe_gpio_direction_out(struct gpio_chip *chip, unsigned int offset,
358358
return 0;
359359
}
360360

361-
static void txgbe_gpio_irq_ack(struct irq_data *d)
362-
{
363-
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
364-
irq_hw_number_t hwirq = irqd_to_hwirq(d);
365-
struct wx *wx = gpiochip_get_data(gc);
366-
unsigned long flags;
367-
368-
raw_spin_lock_irqsave(&wx->gpio_lock, flags);
369-
wr32(wx, WX_GPIO_EOI, BIT(hwirq));
370-
raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
371-
}
372-
373-
static void txgbe_gpio_irq_mask(struct irq_data *d)
374-
{
375-
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
376-
irq_hw_number_t hwirq = irqd_to_hwirq(d);
377-
struct wx *wx = gpiochip_get_data(gc);
378-
unsigned long flags;
379-
380-
gpiochip_disable_irq(gc, hwirq);
381-
382-
raw_spin_lock_irqsave(&wx->gpio_lock, flags);
383-
wr32m(wx, WX_GPIO_INTMASK, BIT(hwirq), BIT(hwirq));
384-
raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
385-
}
386-
387-
static void txgbe_gpio_irq_unmask(struct irq_data *d)
388-
{
389-
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
390-
irq_hw_number_t hwirq = irqd_to_hwirq(d);
391-
struct wx *wx = gpiochip_get_data(gc);
392-
unsigned long flags;
393-
394-
gpiochip_enable_irq(gc, hwirq);
395-
396-
raw_spin_lock_irqsave(&wx->gpio_lock, flags);
397-
wr32m(wx, WX_GPIO_INTMASK, BIT(hwirq), 0);
398-
raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
399-
}
400-
401-
static void txgbe_toggle_trigger(struct gpio_chip *gc, unsigned int offset)
402-
{
403-
struct wx *wx = gpiochip_get_data(gc);
404-
u32 pol, val;
405-
406-
pol = rd32(wx, WX_GPIO_POLARITY);
407-
val = rd32(wx, WX_GPIO_EXT);
408-
409-
if (val & BIT(offset))
410-
pol &= ~BIT(offset);
411-
else
412-
pol |= BIT(offset);
413-
414-
wr32(wx, WX_GPIO_POLARITY, pol);
415-
}
416-
417-
static int txgbe_gpio_set_type(struct irq_data *d, unsigned int type)
418-
{
419-
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
420-
irq_hw_number_t hwirq = irqd_to_hwirq(d);
421-
struct wx *wx = gpiochip_get_data(gc);
422-
u32 level, polarity, mask;
423-
unsigned long flags;
424-
425-
mask = BIT(hwirq);
426-
427-
if (type & IRQ_TYPE_LEVEL_MASK) {
428-
level = 0;
429-
irq_set_handler_locked(d, handle_level_irq);
430-
} else {
431-
level = mask;
432-
irq_set_handler_locked(d, handle_edge_irq);
433-
}
434-
435-
if (type == IRQ_TYPE_EDGE_RISING || type == IRQ_TYPE_LEVEL_HIGH)
436-
polarity = mask;
437-
else
438-
polarity = 0;
439-
440-
raw_spin_lock_irqsave(&wx->gpio_lock, flags);
441-
442-
wr32m(wx, WX_GPIO_INTEN, mask, mask);
443-
wr32m(wx, WX_GPIO_INTTYPE_LEVEL, mask, level);
444-
if (type == IRQ_TYPE_EDGE_BOTH)
445-
txgbe_toggle_trigger(gc, hwirq);
446-
else
447-
wr32m(wx, WX_GPIO_POLARITY, mask, polarity);
448-
449-
raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
450-
451-
return 0;
452-
}
453-
454-
static const struct irq_chip txgbe_gpio_irq_chip = {
455-
.name = "txgbe-gpio-irq",
456-
.irq_ack = txgbe_gpio_irq_ack,
457-
.irq_mask = txgbe_gpio_irq_mask,
458-
.irq_unmask = txgbe_gpio_irq_unmask,
459-
.irq_set_type = txgbe_gpio_set_type,
460-
.flags = IRQCHIP_IMMUTABLE,
461-
GPIOCHIP_IRQ_RESOURCE_HELPERS,
462-
};
463-
464-
irqreturn_t txgbe_gpio_irq_handler(int irq, void *data)
465-
{
466-
struct txgbe *txgbe = data;
467-
struct wx *wx = txgbe->wx;
468-
irq_hw_number_t hwirq;
469-
unsigned long gpioirq;
470-
struct gpio_chip *gc;
471-
unsigned long flags;
472-
473-
gpioirq = rd32(wx, WX_GPIO_INTSTATUS);
474-
475-
gc = txgbe->gpio;
476-
for_each_set_bit(hwirq, &gpioirq, gc->ngpio) {
477-
int gpio = irq_find_mapping(gc->irq.domain, hwirq);
478-
struct irq_data *d = irq_get_irq_data(gpio);
479-
u32 irq_type = irq_get_trigger_type(gpio);
480-
481-
txgbe_gpio_irq_ack(d);
482-
handle_nested_irq(gpio);
483-
484-
if ((irq_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
485-
raw_spin_lock_irqsave(&wx->gpio_lock, flags);
486-
txgbe_toggle_trigger(gc, hwirq);
487-
raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
488-
}
489-
}
490-
491-
return IRQ_HANDLED;
492-
}
493-
494-
void txgbe_reinit_gpio_intr(struct wx *wx)
495-
{
496-
struct txgbe *txgbe = wx->priv;
497-
irq_hw_number_t hwirq;
498-
unsigned long gpioirq;
499-
struct gpio_chip *gc;
500-
unsigned long flags;
501-
502-
/* for gpio interrupt pending before irq enable */
503-
gpioirq = rd32(wx, WX_GPIO_INTSTATUS);
504-
505-
gc = txgbe->gpio;
506-
for_each_set_bit(hwirq, &gpioirq, gc->ngpio) {
507-
int gpio = irq_find_mapping(gc->irq.domain, hwirq);
508-
struct irq_data *d = irq_get_irq_data(gpio);
509-
u32 irq_type = irq_get_trigger_type(gpio);
510-
511-
txgbe_gpio_irq_ack(d);
512-
513-
if ((irq_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
514-
raw_spin_lock_irqsave(&wx->gpio_lock, flags);
515-
txgbe_toggle_trigger(gc, hwirq);
516-
raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
517-
}
518-
}
519-
}
520-
521361
static int txgbe_gpio_init(struct txgbe *txgbe)
522362
{
523-
struct gpio_irq_chip *girq;
524363
struct gpio_chip *gc;
525364
struct device *dev;
526365
struct wx *wx;
@@ -550,11 +389,6 @@ static int txgbe_gpio_init(struct txgbe *txgbe)
550389
gc->direction_input = txgbe_gpio_direction_in;
551390
gc->direction_output = txgbe_gpio_direction_out;
552391

553-
girq = &gc->irq;
554-
gpio_irq_chip_set_chip(girq, &txgbe_gpio_irq_chip);
555-
girq->default_type = IRQ_TYPE_NONE;
556-
girq->handler = handle_bad_irq;
557-
558392
ret = devm_gpiochip_add_data(dev, gc, wx);
559393
if (ret)
560394
return ret;

drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#ifndef _TXGBE_PHY_H_
55
#define _TXGBE_PHY_H_
66

7-
irqreturn_t txgbe_gpio_irq_handler(int irq, void *data);
8-
void txgbe_reinit_gpio_intr(struct wx *wx);
97
irqreturn_t txgbe_link_irq_handler(int irq, void *data);
108
int txgbe_init_phy(struct txgbe *txgbe);
119
void txgbe_remove_phy(struct txgbe *txgbe);

drivers/net/ethernet/wangxun/txgbe/txgbe_type.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
#define TXGBE_PX_MISC_IEN_MASK \
7676
(TXGBE_PX_MISC_ETH_LKDN | TXGBE_PX_MISC_DEV_RST | \
7777
TXGBE_PX_MISC_ETH_EVENT | TXGBE_PX_MISC_ETH_LK | \
78-
TXGBE_PX_MISC_ETH_AN | TXGBE_PX_MISC_INT_ERR | \
79-
TXGBE_PX_MISC_GPIO)
78+
TXGBE_PX_MISC_ETH_AN | TXGBE_PX_MISC_INT_ERR)
8079

8180
/* Port cfg registers */
8281
#define TXGBE_CFG_PORT_ST 0x14404
@@ -313,8 +312,7 @@ struct txgbe_nodes {
313312
};
314313

315314
enum txgbe_misc_irqs {
316-
TXGBE_IRQ_GPIO = 0,
317-
TXGBE_IRQ_LINK,
315+
TXGBE_IRQ_LINK = 0,
318316
TXGBE_IRQ_MAX
319317
};
320318

@@ -335,7 +333,6 @@ struct txgbe {
335333
struct clk_lookup *clock;
336334
struct clk *clk;
337335
struct gpio_chip *gpio;
338-
unsigned int gpio_irq;
339336
unsigned int link_irq;
340337

341338
/* flow director */

0 commit comments

Comments
 (0)