Skip to content

Commit 61a7904

Browse files
iklimaszbrgl
authored andcommitted
gpio: aspeed: Convert aspeed_gpio.lock to raw_spinlock
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]>
1 parent 9dbd1ab commit 61a7904

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

@@ -716,7 +716,7 @@ static int aspeed_gpio_reset_tolerance(struct gpio_chip *chip,
716716

717717
treg = bank_reg(gpio, to_bank(offset), reg_tolerance);
718718

719-
spin_lock_irqsave(&gpio->lock, flags);
719+
raw_spin_lock_irqsave(&gpio->lock, flags);
720720
copro = aspeed_gpio_copro_request(gpio, offset);
721721

722722
val = readl(treg);
@@ -730,7 +730,7 @@ static int aspeed_gpio_reset_tolerance(struct gpio_chip *chip,
730730

731731
if (copro)
732732
aspeed_gpio_copro_release(gpio, offset);
733-
spin_unlock_irqrestore(&gpio->lock, flags);
733+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
734734

735735
return 0;
736736
}
@@ -856,7 +856,7 @@ static int enable_debounce(struct gpio_chip *chip, unsigned int offset,
856856
return rc;
857857
}
858858

859-
spin_lock_irqsave(&gpio->lock, flags);
859+
raw_spin_lock_irqsave(&gpio->lock, flags);
860860

861861
if (timer_allocation_registered(gpio, offset)) {
862862
rc = unregister_allocated_timer(gpio, offset);
@@ -916,7 +916,7 @@ static int enable_debounce(struct gpio_chip *chip, unsigned int offset,
916916
configure_timer(gpio, offset, i);
917917

918918
out:
919-
spin_unlock_irqrestore(&gpio->lock, flags);
919+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
920920

921921
return rc;
922922
}
@@ -927,13 +927,13 @@ static int disable_debounce(struct gpio_chip *chip, unsigned int offset)
927927
unsigned long flags;
928928
int rc;
929929

930-
spin_lock_irqsave(&gpio->lock, flags);
930+
raw_spin_lock_irqsave(&gpio->lock, flags);
931931

932932
rc = unregister_allocated_timer(gpio, offset);
933933
if (!rc)
934934
configure_timer(gpio, offset, 0);
935935

936-
spin_unlock_irqrestore(&gpio->lock, flags);
936+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
937937

938938
return rc;
939939
}
@@ -1015,7 +1015,7 @@ int aspeed_gpio_copro_grab_gpio(struct gpio_desc *desc,
10151015
return -EINVAL;
10161016
bindex = offset >> 3;
10171017

1018-
spin_lock_irqsave(&gpio->lock, flags);
1018+
raw_spin_lock_irqsave(&gpio->lock, flags);
10191019

10201020
/* Sanity check, this shouldn't happen */
10211021
if (gpio->cf_copro_bankmap[bindex] == 0xff) {
@@ -1036,7 +1036,7 @@ int aspeed_gpio_copro_grab_gpio(struct gpio_desc *desc,
10361036
if (bit)
10371037
*bit = GPIO_OFFSET(offset);
10381038
bail:
1039-
spin_unlock_irqrestore(&gpio->lock, flags);
1039+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
10401040
return rc;
10411041
}
10421042
EXPORT_SYMBOL_GPL(aspeed_gpio_copro_grab_gpio);
@@ -1060,7 +1060,7 @@ int aspeed_gpio_copro_release_gpio(struct gpio_desc *desc)
10601060
return -EINVAL;
10611061
bindex = offset >> 3;
10621062

1063-
spin_lock_irqsave(&gpio->lock, flags);
1063+
raw_spin_lock_irqsave(&gpio->lock, flags);
10641064

10651065
/* Sanity check, this shouldn't happen */
10661066
if (gpio->cf_copro_bankmap[bindex] == 0) {
@@ -1074,7 +1074,7 @@ int aspeed_gpio_copro_release_gpio(struct gpio_desc *desc)
10741074
aspeed_gpio_change_cmd_source(gpio, bank, bindex,
10751075
GPIO_CMDSRC_ARM);
10761076
bail:
1077-
spin_unlock_irqrestore(&gpio->lock, flags);
1077+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
10781078
return rc;
10791079
}
10801080
EXPORT_SYMBOL_GPL(aspeed_gpio_copro_release_gpio);
@@ -1148,7 +1148,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
11481148
if (IS_ERR(gpio->base))
11491149
return PTR_ERR(gpio->base);
11501150

1151-
spin_lock_init(&gpio->lock);
1151+
raw_spin_lock_init(&gpio->lock);
11521152

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

0 commit comments

Comments
 (0)