Skip to content

Commit 07ecabf

Browse files
iklimaszgregkh
authored andcommitted
gpio: aspeed: Convert aspeed_gpio.lock to raw_spinlock
[ Upstream commit 61a7904 ] The gpio-aspeed driver implements an irq_chip which need to be invoked from hardirq context. Since spin_lock() can sleep with PREEMPT_RT, it is no longer legal to invoke it while interrupts are disabled. This also causes lockdep to complain about: [ 0.649797] [ BUG: Invalid wait context ] because aspeed_gpio.lock (spin_lock_t) is taken under irq_desc.lock (raw_spinlock_t). Let's use of raw_spinlock_t instead of spinlock_t. Signed-off-by: Iwona Winiarska <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 7e09f9d commit 07ecabf

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

drivers/gpio/gpio-aspeed.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct aspeed_gpio_config {
5353
struct aspeed_gpio {
5454
struct gpio_chip chip;
5555
struct irq_chip irqc;
56-
spinlock_t lock;
56+
raw_spinlock_t lock;
5757
void __iomem *base;
5858
int irq;
5959
const struct aspeed_gpio_config *config;
@@ -413,14 +413,14 @@ static void aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset,
413413
unsigned long flags;
414414
bool copro;
415415

416-
spin_lock_irqsave(&gpio->lock, flags);
416+
raw_spin_lock_irqsave(&gpio->lock, flags);
417417
copro = aspeed_gpio_copro_request(gpio, offset);
418418

419419
__aspeed_gpio_set(gc, offset, val);
420420

421421
if (copro)
422422
aspeed_gpio_copro_release(gpio, offset);
423-
spin_unlock_irqrestore(&gpio->lock, flags);
423+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
424424
}
425425

426426
static int aspeed_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
@@ -435,7 +435,7 @@ static int aspeed_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
435435
if (!have_input(gpio, offset))
436436
return -ENOTSUPP;
437437

438-
spin_lock_irqsave(&gpio->lock, flags);
438+
raw_spin_lock_irqsave(&gpio->lock, flags);
439439

440440
reg = ioread32(addr);
441441
reg &= ~GPIO_BIT(offset);
@@ -445,7 +445,7 @@ static int aspeed_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
445445
if (copro)
446446
aspeed_gpio_copro_release(gpio, offset);
447447

448-
spin_unlock_irqrestore(&gpio->lock, flags);
448+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
449449

450450
return 0;
451451
}
@@ -463,7 +463,7 @@ static int aspeed_gpio_dir_out(struct gpio_chip *gc,
463463
if (!have_output(gpio, offset))
464464
return -ENOTSUPP;
465465

466-
spin_lock_irqsave(&gpio->lock, flags);
466+
raw_spin_lock_irqsave(&gpio->lock, flags);
467467

468468
reg = ioread32(addr);
469469
reg |= GPIO_BIT(offset);
@@ -474,7 +474,7 @@ static int aspeed_gpio_dir_out(struct gpio_chip *gc,
474474

475475
if (copro)
476476
aspeed_gpio_copro_release(gpio, offset);
477-
spin_unlock_irqrestore(&gpio->lock, flags);
477+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
478478

479479
return 0;
480480
}
@@ -492,11 +492,11 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
492492
if (!have_output(gpio, offset))
493493
return GPIO_LINE_DIRECTION_IN;
494494

495-
spin_lock_irqsave(&gpio->lock, flags);
495+
raw_spin_lock_irqsave(&gpio->lock, flags);
496496

497497
val = ioread32(bank_reg(gpio, bank, reg_dir)) & GPIO_BIT(offset);
498498

499-
spin_unlock_irqrestore(&gpio->lock, flags);
499+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
500500

501501
return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
502502
}
@@ -539,14 +539,14 @@ static void aspeed_gpio_irq_ack(struct irq_data *d)
539539

540540
status_addr = bank_reg(gpio, bank, reg_irq_status);
541541

542-
spin_lock_irqsave(&gpio->lock, flags);
542+
raw_spin_lock_irqsave(&gpio->lock, flags);
543543
copro = aspeed_gpio_copro_request(gpio, offset);
544544

545545
iowrite32(bit, status_addr);
546546

547547
if (copro)
548548
aspeed_gpio_copro_release(gpio, offset);
549-
spin_unlock_irqrestore(&gpio->lock, flags);
549+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
550550
}
551551

552552
static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set)
@@ -565,7 +565,7 @@ static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set)
565565

566566
addr = bank_reg(gpio, bank, reg_irq_enable);
567567

568-
spin_lock_irqsave(&gpio->lock, flags);
568+
raw_spin_lock_irqsave(&gpio->lock, flags);
569569
copro = aspeed_gpio_copro_request(gpio, offset);
570570

571571
reg = ioread32(addr);
@@ -577,7 +577,7 @@ static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set)
577577

578578
if (copro)
579579
aspeed_gpio_copro_release(gpio, offset);
580-
spin_unlock_irqrestore(&gpio->lock, flags);
580+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
581581
}
582582

583583
static void aspeed_gpio_irq_mask(struct irq_data *d)
@@ -629,7 +629,7 @@ static int aspeed_gpio_set_type(struct irq_data *d, unsigned int type)
629629
return -EINVAL;
630630
}
631631

632-
spin_lock_irqsave(&gpio->lock, flags);
632+
raw_spin_lock_irqsave(&gpio->lock, flags);
633633
copro = aspeed_gpio_copro_request(gpio, offset);
634634

635635
addr = bank_reg(gpio, bank, reg_irq_type0);
@@ -649,7 +649,7 @@ static int aspeed_gpio_set_type(struct irq_data *d, unsigned int type)
649649

650650
if (copro)
651651
aspeed_gpio_copro_release(gpio, offset);
652-
spin_unlock_irqrestore(&gpio->lock, flags);
652+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
653653

654654
irq_set_handler_locked(d, handler);
655655

@@ -719,7 +719,7 @@ static int aspeed_gpio_reset_tolerance(struct gpio_chip *chip,
719719

720720
treg = bank_reg(gpio, to_bank(offset), reg_tolerance);
721721

722-
spin_lock_irqsave(&gpio->lock, flags);
722+
raw_spin_lock_irqsave(&gpio->lock, flags);
723723
copro = aspeed_gpio_copro_request(gpio, offset);
724724

725725
val = readl(treg);
@@ -733,7 +733,7 @@ static int aspeed_gpio_reset_tolerance(struct gpio_chip *chip,
733733

734734
if (copro)
735735
aspeed_gpio_copro_release(gpio, offset);
736-
spin_unlock_irqrestore(&gpio->lock, flags);
736+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
737737

738738
return 0;
739739
}
@@ -859,7 +859,7 @@ static int enable_debounce(struct gpio_chip *chip, unsigned int offset,
859859
return rc;
860860
}
861861

862-
spin_lock_irqsave(&gpio->lock, flags);
862+
raw_spin_lock_irqsave(&gpio->lock, flags);
863863

864864
if (timer_allocation_registered(gpio, offset)) {
865865
rc = unregister_allocated_timer(gpio, offset);
@@ -919,7 +919,7 @@ static int enable_debounce(struct gpio_chip *chip, unsigned int offset,
919919
configure_timer(gpio, offset, i);
920920

921921
out:
922-
spin_unlock_irqrestore(&gpio->lock, flags);
922+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
923923

924924
return rc;
925925
}
@@ -930,13 +930,13 @@ static int disable_debounce(struct gpio_chip *chip, unsigned int offset)
930930
unsigned long flags;
931931
int rc;
932932

933-
spin_lock_irqsave(&gpio->lock, flags);
933+
raw_spin_lock_irqsave(&gpio->lock, flags);
934934

935935
rc = unregister_allocated_timer(gpio, offset);
936936
if (!rc)
937937
configure_timer(gpio, offset, 0);
938938

939-
spin_unlock_irqrestore(&gpio->lock, flags);
939+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
940940

941941
return rc;
942942
}
@@ -1018,7 +1018,7 @@ int aspeed_gpio_copro_grab_gpio(struct gpio_desc *desc,
10181018
return -EINVAL;
10191019
bindex = offset >> 3;
10201020

1021-
spin_lock_irqsave(&gpio->lock, flags);
1021+
raw_spin_lock_irqsave(&gpio->lock, flags);
10221022

10231023
/* Sanity check, this shouldn't happen */
10241024
if (gpio->cf_copro_bankmap[bindex] == 0xff) {
@@ -1039,7 +1039,7 @@ int aspeed_gpio_copro_grab_gpio(struct gpio_desc *desc,
10391039
if (bit)
10401040
*bit = GPIO_OFFSET(offset);
10411041
bail:
1042-
spin_unlock_irqrestore(&gpio->lock, flags);
1042+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
10431043
return rc;
10441044
}
10451045
EXPORT_SYMBOL_GPL(aspeed_gpio_copro_grab_gpio);
@@ -1063,7 +1063,7 @@ int aspeed_gpio_copro_release_gpio(struct gpio_desc *desc)
10631063
return -EINVAL;
10641064
bindex = offset >> 3;
10651065

1066-
spin_lock_irqsave(&gpio->lock, flags);
1066+
raw_spin_lock_irqsave(&gpio->lock, flags);
10671067

10681068
/* Sanity check, this shouldn't happen */
10691069
if (gpio->cf_copro_bankmap[bindex] == 0) {
@@ -1077,7 +1077,7 @@ int aspeed_gpio_copro_release_gpio(struct gpio_desc *desc)
10771077
aspeed_gpio_change_cmd_source(gpio, bank, bindex,
10781078
GPIO_CMDSRC_ARM);
10791079
bail:
1080-
spin_unlock_irqrestore(&gpio->lock, flags);
1080+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
10811081
return rc;
10821082
}
10831083
EXPORT_SYMBOL_GPL(aspeed_gpio_copro_release_gpio);
@@ -1151,7 +1151,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
11511151
if (IS_ERR(gpio->base))
11521152
return PTR_ERR(gpio->base);
11531153

1154-
spin_lock_init(&gpio->lock);
1154+
raw_spin_lock_init(&gpio->lock);
11551155

11561156
gpio_id = of_match_node(aspeed_gpio_of_table, pdev->dev.of_node);
11571157
if (!gpio_id)

0 commit comments

Comments
 (0)