2024-05-06 13:51:28

by Antonio Borneo

[permalink] [raw]
Subject: [PATCH 0/8] irqchip/stm32-exti: split MCU and MPU code, allow module build

The file 'irq-stm32-exti.c' contains two drivers:
- EXTI for ARMv7m STM32 MCUs;
- EXTI for ARMv7a & ARMv8a STM32MPxxx MPUs.

The current arrangement causes some issue:
- the growing code for MPUs uses precious space on memory constraint
MCUs devices;
- the driver for MPU cannot be built as module;
- there are risks to break one of the two drivers while working on
the other.

Since there are only 4 minor functions shared among the two drivers:
- stm32_exti_set_type();
- stm32_chip_resume();
- stm32_chip_suspend();
- stm32_exti_chip_init();

this series splits the file in two independent files, each containing
a single driver.
To guarantee bisect-ability, the series first introduces some hook in
Kconfig, then splits the file and at the end enables module build on
MPU while cleaning-up Kconfig.
The symbols in the MPU file are renamed to better match the new name
of the driver.

The patches are created with 'git format-patch -C' to correctly show
the deleted parts and the tiny modifications between the original
monolithic file and the two extracted ones.

The series is rebased on irq/core branch of tip as it depends on a
previous series already queued for v6.10 merge window.


Antonio Borneo (8):
irqchip/stm32-exti: add CONFIG_STM32MP_EXTI
ARM: stm32: use different EXTI driver on ARMv7m and ARMv7a
arm64: Kconfig: select STM32MP_EXTI on STM32 platforms
irqchip/stm32-exti: split MCU and MPU code
irqchip/stm32mp-exti: rename internal symbols
irqchip/stm32mp-exti: allow build as module
ARM: stm32: allow build irq-stm32mp-exti driver as module
arm64: Kconfig: allow build irq-stm32mp-exti driver as module

arch/arm/mach-stm32/Kconfig | 2 +-
arch/arm64/Kconfig.platforms | 1 -
drivers/irqchip/Kconfig | 9 +
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-stm32-exti.c | 670 +-------------------------
drivers/irqchip/irq-stm32mp-exti.c | 737 +++++++++++++++++++++++++++++
6 files changed, 752 insertions(+), 668 deletions(-)
create mode 100644 drivers/irqchip/irq-stm32mp-exti.c


base-commit: 382d2ffe86efb1e2fa803d2cf17e5bfc34e574f3
--
2.34.1



2024-05-06 13:52:29

by Antonio Borneo

[permalink] [raw]
Subject: [PATCH 6/8] irqchip/stm32mp-exti: allow build as module

Allow build the driver as a module by adding the necessarily hooks
in Kconfig and in the driver's code.

Since all the probe dependencies linked to this driver has already
been fixed, ignore the no more relevant 'arch_initcall'.

Signed-off-by: Antonio Borneo <[email protected]>
---
drivers/irqchip/Kconfig | 6 +++++-
drivers/irqchip/irq-stm32mp-exti.c | 15 ++++-----------
2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 486022fb7806e..c26d28dc0d45e 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -393,9 +393,13 @@ config PARTITION_PERCPU
bool

config STM32MP_EXTI
- bool
+ tristate "STM32MP extended interrupts and event controller"
+ depends on (ARCH_STM32 && !ARM_SINGLE_ARMV7M) || COMPILE_TEST
+ default y
select IRQ_DOMAIN
select GENERIC_IRQ_CHIP
+ help
+ Support STM32MP EXTI (extended interrupts and event) controller.

config STM32_EXTI
bool
diff --git a/drivers/irqchip/irq-stm32mp-exti.c b/drivers/irqchip/irq-stm32mp-exti.c
index 3ceff6d25b702..2958fbcfbda12 100644
--- a/drivers/irqchip/irq-stm32mp-exti.c
+++ b/drivers/irqchip/irq-stm32mp-exti.c
@@ -730,15 +730,8 @@ static struct platform_driver stm32mp_exti_driver = {
},
};

-static int __init stm32mp_exti_arch_init(void)
-{
- return platform_driver_register(&stm32mp_exti_driver);
-}
-
-static void __exit stm32mp_exti_arch_exit(void)
-{
- return platform_driver_unregister(&stm32mp_exti_driver);
-}
+module_platform_driver(stm32mp_exti_driver);

-arch_initcall(stm32mp_exti_arch_init);
-module_exit(stm32mp_exti_arch_exit);
+MODULE_AUTHOR("Maxime Coquelin <[email protected]>");
+MODULE_DESCRIPTION("STM32MP EXTI driver");
+MODULE_LICENSE("GPL");
--
2.34.1


2024-05-06 13:52:33

by Antonio Borneo

[permalink] [raw]
Subject: [PATCH 8/8] arm64: Kconfig: allow build irq-stm32mp-exti driver as module

Drop auto-selecting the driver, so it can be built either as a
module or built-in.

Signed-off-by: Antonio Borneo <[email protected]>
---
arch/arm64/Kconfig.platforms | 1 -
1 file changed, 1 deletion(-)

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index da85e0d49686f..24335565bad56 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -302,7 +302,6 @@ config ARCH_STM32
select GPIOLIB
select PINCTRL
select PINCTRL_STM32MP257
- select STM32MP_EXTI
select ARM_SMC_MBOX
select ARM_SCMI_PROTOCOL
select COMMON_CLK_SCMI
--
2.34.1


2024-05-07 05:14:18

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 6/8] irqchip/stm32mp-exti: allow build as module

Hi Antonio,

kernel test robot noticed the following build errors:

[auto build test ERROR on 382d2ffe86efb1e2fa803d2cf17e5bfc34e574f3]

url: https://github.com/intel-lab-lkp/linux/commits/Antonio-Borneo/irqchip-stm32-exti-add-CONFIG_STM32MP_EXTI/20240506-213819
base: 382d2ffe86efb1e2fa803d2cf17e5bfc34e574f3
patch link: https://lore.kernel.org/r/20240506133256.948712-7-antonio.borneo%40foss.st.com
patch subject: [PATCH 6/8] irqchip/stm32mp-exti: allow build as module
config: i386-buildonly-randconfig-005-20240507
compiler: gcc-11 (Ubuntu 11.4.0-4ubuntu1) 11.4.0
reproduce (this is a W=1 build):

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

drivers/irqchip/irq-stm32mp-exti.c: In function 'stm32mp_exti_eoi':
>> drivers/irqchip/irq-stm32mp-exti.c:340:14: error: 'struct irq_data' has no member named 'parent_data'
340 | if (d->parent_data->chip)
| ^~
>> drivers/irqchip/irq-stm32mp-exti.c:341:17: error: implicit declaration of function 'irq_chip_eoi_parent'; did you mean 'irq_chip_pm_put'? [-Werror=implicit-function-declaration]
341 | irq_chip_eoi_parent(d);
| ^~~~~~~~~~~~~~~~~~~
| irq_chip_pm_put
drivers/irqchip/irq-stm32mp-exti.c: In function 'stm32mp_exti_mask':
drivers/irqchip/irq-stm32mp-exti.c:353:14: error: 'struct irq_data' has no member named 'parent_data'
353 | if (d->parent_data->chip)
| ^~
>> drivers/irqchip/irq-stm32mp-exti.c:354:17: error: implicit declaration of function 'irq_chip_mask_parent' [-Werror=implicit-function-declaration]
354 | irq_chip_mask_parent(d);
| ^~~~~~~~~~~~~~~~~~~~
drivers/irqchip/irq-stm32mp-exti.c: In function 'stm32mp_exti_unmask':
drivers/irqchip/irq-stm32mp-exti.c:366:14: error: 'struct irq_data' has no member named 'parent_data'
366 | if (d->parent_data->chip)
| ^~
>> drivers/irqchip/irq-stm32mp-exti.c:367:17: error: implicit declaration of function 'irq_chip_unmask_parent' [-Werror=implicit-function-declaration]
367 | irq_chip_unmask_parent(d);
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/irqchip/irq-stm32mp-exti.c: In function 'stm32mp_exti_set_affinity':
drivers/irqchip/irq-stm32mp-exti.c:428:14: error: 'struct irq_data' has no member named 'parent_data'
428 | if (d->parent_data->chip)
| ^~
>> drivers/irqchip/irq-stm32mp-exti.c:429:24: error: implicit declaration of function 'irq_chip_set_affinity_parent'; did you mean 'irq_set_affinity_hint'? [-Werror=implicit-function-declaration]
429 | return irq_chip_set_affinity_parent(d, dest, force);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| irq_set_affinity_hint
drivers/irqchip/irq-stm32mp-exti.c: At top level:
>> drivers/irqchip/irq-stm32mp-exti.c:488:35: error: 'irq_chip_eoi_parent' undeclared here (not in a function); did you mean 'irq_chip_pm_put'?
488 | .irq_eoi = irq_chip_eoi_parent,
| ^~~~~~~~~~~~~~~~~~~
| irq_chip_pm_put
>> drivers/irqchip/irq-stm32mp-exti.c:489:35: error: 'irq_chip_ack_parent' undeclared here (not in a function); did you mean 'irq_chip_pm_put'?
489 | .irq_ack = irq_chip_ack_parent,
| ^~~~~~~~~~~~~~~~~~~
| irq_chip_pm_put
>> drivers/irqchip/irq-stm32mp-exti.c:492:35: error: 'irq_chip_retrigger_hierarchy' undeclared here (not in a function)
492 | .irq_retrigger = irq_chip_retrigger_hierarchy,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/irqchip/irq-stm32mp-exti.c:493:35: error: 'irq_chip_set_type_parent' undeclared here (not in a function)
493 | .irq_set_type = irq_chip_set_type_parent,
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/irqchip/irq-stm32mp-exti.c:496:60: error: 'irq_chip_set_affinity_parent' undeclared here (not in a function); did you mean 'irq_set_affinity_hint'?
496 | .irq_set_affinity = IS_ENABLED(CONFIG_SMP) ? irq_chip_set_affinity_parent : NULL,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| irq_set_affinity_hint
drivers/irqchip/irq-stm32mp-exti.c: In function 'stm32mp_exti_domain_alloc':
>> drivers/irqchip/irq-stm32mp-exti.c:530:9: error: implicit declaration of function 'irq_domain_set_hwirq_and_chip'; did you mean 'irq_domain_get_irq_data'? [-Werror=implicit-function-declaration]
530 | irq_domain_set_hwirq_and_chip(dm, virq, hwirq, chip, chip_data);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| irq_domain_get_irq_data
>> drivers/irqchip/irq-stm32mp-exti.c:540:56: error: 'struct irq_domain' has no member named 'parent'
540 | if (of_node_to_fwnode(out_irq.np) != dm->parent->fwnode)
| ^~
>> drivers/irqchip/irq-stm32mp-exti.c:546:24: error: implicit declaration of function 'irq_domain_alloc_irqs_parent'; did you mean 'irq_domain_alloc_irqs'? [-Werror=implicit-function-declaration]
546 | return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| irq_domain_alloc_irqs
drivers/irqchip/irq-stm32mp-exti.c:554:37: error: 'struct irq_domain' has no member named 'parent'
554 | p_fwspec.fwnode = dm->parent->fwnode;
| ^~
drivers/irqchip/irq-stm32mp-exti.c: At top level:
>> drivers/irqchip/irq-stm32mp-exti.c:597:10: error: 'const struct irq_domain_ops' has no member named 'alloc'
597 | .alloc = stm32mp_exti_domain_alloc,
| ^~~~~
>> drivers/irqchip/irq-stm32mp-exti.c:597:19: error: initialization of 'int (*)(struct irq_domain *, struct device_node *, enum irq_domain_bus_token)' from incompatible pointer type 'int (*)(struct irq_domain *, unsigned int, unsigned int, void *)' [-Werror=incompatible-pointer-types]
597 | .alloc = stm32mp_exti_domain_alloc,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/irqchip/irq-stm32mp-exti.c:597:19: note: (near initialization for 'stm32mp_exti_domain_ops.match')
>> drivers/irqchip/irq-stm32mp-exti.c:598:10: error: 'const struct irq_domain_ops' has no member named 'free'
598 | .free = irq_domain_free_irqs_common,
| ^~~~
>> drivers/irqchip/irq-stm32mp-exti.c:598:19: error: 'irq_domain_free_irqs_common' undeclared here (not in a function); did you mean 'irq_domain_free_irqs'?
598 | .free = irq_domain_free_irqs_common,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| irq_domain_free_irqs
drivers/irqchip/irq-stm32mp-exti.c: In function 'stm32mp_exti_probe':
>> drivers/irqchip/irq-stm32mp-exti.c:693:18: error: implicit declaration of function 'irq_domain_add_hierarchy'; did you mean 'irq_domain_is_hierarchy'? [-Werror=implicit-function-declaration]
693 | domain = irq_domain_add_hierarchy(parent_domain, 0,
| ^~~~~~~~~~~~~~~~~~~~~~~~
| irq_domain_is_hierarchy
>> drivers/irqchip/irq-stm32mp-exti.c:693:16: warning: assignment to 'struct irq_domain *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
693 | domain = irq_domain_add_hierarchy(parent_domain, 0,
| ^
cc1: some warnings being treated as errors


vim +340 drivers/irqchip/irq-stm32mp-exti.c

64782652b8d981 Antonio Borneo 2024-05-06 327
4386976d39c92f Antonio Borneo 2024-05-06 328 static void stm32mp_exti_eoi(struct irq_data *d)
64782652b8d981 Antonio Borneo 2024-05-06 329 {
4386976d39c92f Antonio Borneo 2024-05-06 330 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 331 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 332
64782652b8d981 Antonio Borneo 2024-05-06 333 raw_spin_lock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 334
4386976d39c92f Antonio Borneo 2024-05-06 335 stm32mp_exti_write_bit(d, bank->rpr_ofst);
4386976d39c92f Antonio Borneo 2024-05-06 336 stm32mp_exti_write_bit(d, bank->fpr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 337
64782652b8d981 Antonio Borneo 2024-05-06 338 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 339
64782652b8d981 Antonio Borneo 2024-05-06 @340 if (d->parent_data->chip)
64782652b8d981 Antonio Borneo 2024-05-06 @341 irq_chip_eoi_parent(d);
64782652b8d981 Antonio Borneo 2024-05-06 342 }
64782652b8d981 Antonio Borneo 2024-05-06 343
4386976d39c92f Antonio Borneo 2024-05-06 344 static void stm32mp_exti_mask(struct irq_data *d)
64782652b8d981 Antonio Borneo 2024-05-06 345 {
4386976d39c92f Antonio Borneo 2024-05-06 346 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 347 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 348
64782652b8d981 Antonio Borneo 2024-05-06 349 raw_spin_lock(&chip_data->rlock);
4386976d39c92f Antonio Borneo 2024-05-06 350 chip_data->mask_cache = stm32mp_exti_clr_bit(d, bank->imr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 351 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 352
64782652b8d981 Antonio Borneo 2024-05-06 353 if (d->parent_data->chip)
64782652b8d981 Antonio Borneo 2024-05-06 @354 irq_chip_mask_parent(d);
64782652b8d981 Antonio Borneo 2024-05-06 355 }
64782652b8d981 Antonio Borneo 2024-05-06 356
4386976d39c92f Antonio Borneo 2024-05-06 357 static void stm32mp_exti_unmask(struct irq_data *d)
64782652b8d981 Antonio Borneo 2024-05-06 358 {
4386976d39c92f Antonio Borneo 2024-05-06 359 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 360 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 361
64782652b8d981 Antonio Borneo 2024-05-06 362 raw_spin_lock(&chip_data->rlock);
4386976d39c92f Antonio Borneo 2024-05-06 363 chip_data->mask_cache = stm32mp_exti_set_bit(d, bank->imr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 364 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 365
64782652b8d981 Antonio Borneo 2024-05-06 366 if (d->parent_data->chip)
64782652b8d981 Antonio Borneo 2024-05-06 @367 irq_chip_unmask_parent(d);
64782652b8d981 Antonio Borneo 2024-05-06 368 }
64782652b8d981 Antonio Borneo 2024-05-06 369
4386976d39c92f Antonio Borneo 2024-05-06 370 static int stm32mp_exti_set_type(struct irq_data *d, unsigned int type)
64782652b8d981 Antonio Borneo 2024-05-06 371 {
4386976d39c92f Antonio Borneo 2024-05-06 372 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 373 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 374 struct hwspinlock *hwlock = chip_data->host_data->hwlock;
64782652b8d981 Antonio Borneo 2024-05-06 375 void __iomem *base = chip_data->host_data->base;
64782652b8d981 Antonio Borneo 2024-05-06 376 u32 rtsr, ftsr;
64782652b8d981 Antonio Borneo 2024-05-06 377 int err;
64782652b8d981 Antonio Borneo 2024-05-06 378
64782652b8d981 Antonio Borneo 2024-05-06 379 raw_spin_lock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 380
64782652b8d981 Antonio Borneo 2024-05-06 381 if (hwlock) {
64782652b8d981 Antonio Borneo 2024-05-06 382 err = hwspin_lock_timeout_in_atomic(hwlock, HWSPNLCK_TIMEOUT);
64782652b8d981 Antonio Borneo 2024-05-06 383 if (err) {
64782652b8d981 Antonio Borneo 2024-05-06 384 pr_err("%s can't get hwspinlock (%d)\n", __func__, err);
64782652b8d981 Antonio Borneo 2024-05-06 385 goto unlock;
64782652b8d981 Antonio Borneo 2024-05-06 386 }
64782652b8d981 Antonio Borneo 2024-05-06 387 }
64782652b8d981 Antonio Borneo 2024-05-06 388
4386976d39c92f Antonio Borneo 2024-05-06 389 rtsr = readl_relaxed(base + bank->rtsr_ofst);
4386976d39c92f Antonio Borneo 2024-05-06 390 ftsr = readl_relaxed(base + bank->ftsr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 391
4386976d39c92f Antonio Borneo 2024-05-06 392 err = stm32mp_exti_convert_type(d, type, &rtsr, &ftsr);
64782652b8d981 Antonio Borneo 2024-05-06 393 if (err)
64782652b8d981 Antonio Borneo 2024-05-06 394 goto unspinlock;
64782652b8d981 Antonio Borneo 2024-05-06 395
4386976d39c92f Antonio Borneo 2024-05-06 396 writel_relaxed(rtsr, base + bank->rtsr_ofst);
4386976d39c92f Antonio Borneo 2024-05-06 397 writel_relaxed(ftsr, base + bank->ftsr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 398
64782652b8d981 Antonio Borneo 2024-05-06 399 unspinlock:
64782652b8d981 Antonio Borneo 2024-05-06 400 if (hwlock)
64782652b8d981 Antonio Borneo 2024-05-06 401 hwspin_unlock_in_atomic(hwlock);
64782652b8d981 Antonio Borneo 2024-05-06 402 unlock:
64782652b8d981 Antonio Borneo 2024-05-06 403 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 404
64782652b8d981 Antonio Borneo 2024-05-06 405 return err;
64782652b8d981 Antonio Borneo 2024-05-06 406 }
64782652b8d981 Antonio Borneo 2024-05-06 407
4386976d39c92f Antonio Borneo 2024-05-06 408 static int stm32mp_exti_set_wake(struct irq_data *d, unsigned int on)
64782652b8d981 Antonio Borneo 2024-05-06 409 {
4386976d39c92f Antonio Borneo 2024-05-06 410 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
64782652b8d981 Antonio Borneo 2024-05-06 411 u32 mask = BIT(d->hwirq % IRQS_PER_BANK);
64782652b8d981 Antonio Borneo 2024-05-06 412
64782652b8d981 Antonio Borneo 2024-05-06 413 raw_spin_lock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 414
64782652b8d981 Antonio Borneo 2024-05-06 415 if (on)
64782652b8d981 Antonio Borneo 2024-05-06 416 chip_data->wake_active |= mask;
64782652b8d981 Antonio Borneo 2024-05-06 417 else
64782652b8d981 Antonio Borneo 2024-05-06 418 chip_data->wake_active &= ~mask;
64782652b8d981 Antonio Borneo 2024-05-06 419
64782652b8d981 Antonio Borneo 2024-05-06 420 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 421
64782652b8d981 Antonio Borneo 2024-05-06 422 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 423 }
64782652b8d981 Antonio Borneo 2024-05-06 424
4386976d39c92f Antonio Borneo 2024-05-06 425 static int stm32mp_exti_set_affinity(struct irq_data *d,
64782652b8d981 Antonio Borneo 2024-05-06 426 const struct cpumask *dest, bool force)
64782652b8d981 Antonio Borneo 2024-05-06 427 {
64782652b8d981 Antonio Borneo 2024-05-06 @428 if (d->parent_data->chip)
64782652b8d981 Antonio Borneo 2024-05-06 @429 return irq_chip_set_affinity_parent(d, dest, force);
64782652b8d981 Antonio Borneo 2024-05-06 430
64782652b8d981 Antonio Borneo 2024-05-06 431 return IRQ_SET_MASK_OK_DONE;
64782652b8d981 Antonio Borneo 2024-05-06 432 }
64782652b8d981 Antonio Borneo 2024-05-06 433
4386976d39c92f Antonio Borneo 2024-05-06 434 static int stm32mp_exti_suspend(struct device *dev)
64782652b8d981 Antonio Borneo 2024-05-06 435 {
4386976d39c92f Antonio Borneo 2024-05-06 436 struct stm32mp_exti_host_data *host_data = dev_get_drvdata(dev);
4386976d39c92f Antonio Borneo 2024-05-06 437 struct stm32mp_exti_chip_data *chip_data;
64782652b8d981 Antonio Borneo 2024-05-06 438 int i;
64782652b8d981 Antonio Borneo 2024-05-06 439
64782652b8d981 Antonio Borneo 2024-05-06 440 for (i = 0; i < host_data->drv_data->bank_nr; i++) {
64782652b8d981 Antonio Borneo 2024-05-06 441 chip_data = &host_data->chips_data[i];
4386976d39c92f Antonio Borneo 2024-05-06 442 stm32mp_chip_suspend(chip_data, chip_data->wake_active);
64782652b8d981 Antonio Borneo 2024-05-06 443 }
64782652b8d981 Antonio Borneo 2024-05-06 444
64782652b8d981 Antonio Borneo 2024-05-06 445 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 446 }
64782652b8d981 Antonio Borneo 2024-05-06 447
4386976d39c92f Antonio Borneo 2024-05-06 448 static int stm32mp_exti_resume(struct device *dev)
64782652b8d981 Antonio Borneo 2024-05-06 449 {
4386976d39c92f Antonio Borneo 2024-05-06 450 struct stm32mp_exti_host_data *host_data = dev_get_drvdata(dev);
4386976d39c92f Antonio Borneo 2024-05-06 451 struct stm32mp_exti_chip_data *chip_data;
64782652b8d981 Antonio Borneo 2024-05-06 452 int i;
64782652b8d981 Antonio Borneo 2024-05-06 453
64782652b8d981 Antonio Borneo 2024-05-06 454 for (i = 0; i < host_data->drv_data->bank_nr; i++) {
64782652b8d981 Antonio Borneo 2024-05-06 455 chip_data = &host_data->chips_data[i];
4386976d39c92f Antonio Borneo 2024-05-06 456 stm32mp_chip_resume(chip_data, chip_data->mask_cache);
64782652b8d981 Antonio Borneo 2024-05-06 457 }
64782652b8d981 Antonio Borneo 2024-05-06 458
64782652b8d981 Antonio Borneo 2024-05-06 459 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 460 }
64782652b8d981 Antonio Borneo 2024-05-06 461
4386976d39c92f Antonio Borneo 2024-05-06 462 static int stm32mp_exti_retrigger(struct irq_data *d)
64782652b8d981 Antonio Borneo 2024-05-06 463 {
4386976d39c92f Antonio Borneo 2024-05-06 464 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 465 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 466 void __iomem *base = chip_data->host_data->base;
64782652b8d981 Antonio Borneo 2024-05-06 467 u32 mask = BIT(d->hwirq % IRQS_PER_BANK);
64782652b8d981 Antonio Borneo 2024-05-06 468
4386976d39c92f Antonio Borneo 2024-05-06 469 writel_relaxed(mask, base + bank->swier_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 470
64782652b8d981 Antonio Borneo 2024-05-06 471 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 472 }
64782652b8d981 Antonio Borneo 2024-05-06 473
4386976d39c92f Antonio Borneo 2024-05-06 474 static struct irq_chip stm32mp_exti_chip = {
4386976d39c92f Antonio Borneo 2024-05-06 475 .name = "stm32mp-exti",
4386976d39c92f Antonio Borneo 2024-05-06 476 .irq_eoi = stm32mp_exti_eoi,
4386976d39c92f Antonio Borneo 2024-05-06 477 .irq_mask = stm32mp_exti_mask,
4386976d39c92f Antonio Borneo 2024-05-06 478 .irq_unmask = stm32mp_exti_unmask,
4386976d39c92f Antonio Borneo 2024-05-06 479 .irq_retrigger = stm32mp_exti_retrigger,
4386976d39c92f Antonio Borneo 2024-05-06 480 .irq_set_type = stm32mp_exti_set_type,
4386976d39c92f Antonio Borneo 2024-05-06 481 .irq_set_wake = stm32mp_exti_set_wake,
64782652b8d981 Antonio Borneo 2024-05-06 482 .flags = IRQCHIP_MASK_ON_SUSPEND,
4386976d39c92f Antonio Borneo 2024-05-06 483 .irq_set_affinity = IS_ENABLED(CONFIG_SMP) ? stm32mp_exti_set_affinity : NULL,
64782652b8d981 Antonio Borneo 2024-05-06 484 };
64782652b8d981 Antonio Borneo 2024-05-06 485
4386976d39c92f Antonio Borneo 2024-05-06 486 static struct irq_chip stm32mp_exti_chip_direct = {
4386976d39c92f Antonio Borneo 2024-05-06 487 .name = "stm32mp-exti-direct",
64782652b8d981 Antonio Borneo 2024-05-06 @488 .irq_eoi = irq_chip_eoi_parent,
64782652b8d981 Antonio Borneo 2024-05-06 @489 .irq_ack = irq_chip_ack_parent,
4386976d39c92f Antonio Borneo 2024-05-06 490 .irq_mask = stm32mp_exti_mask,
4386976d39c92f Antonio Borneo 2024-05-06 491 .irq_unmask = stm32mp_exti_unmask,
64782652b8d981 Antonio Borneo 2024-05-06 @492 .irq_retrigger = irq_chip_retrigger_hierarchy,
64782652b8d981 Antonio Borneo 2024-05-06 @493 .irq_set_type = irq_chip_set_type_parent,
4386976d39c92f Antonio Borneo 2024-05-06 494 .irq_set_wake = stm32mp_exti_set_wake,
64782652b8d981 Antonio Borneo 2024-05-06 495 .flags = IRQCHIP_MASK_ON_SUSPEND,
64782652b8d981 Antonio Borneo 2024-05-06 @496 .irq_set_affinity = IS_ENABLED(CONFIG_SMP) ? irq_chip_set_affinity_parent : NULL,
64782652b8d981 Antonio Borneo 2024-05-06 497 };
64782652b8d981 Antonio Borneo 2024-05-06 498
4386976d39c92f Antonio Borneo 2024-05-06 499 static int stm32mp_exti_domain_alloc(struct irq_domain *dm,
64782652b8d981 Antonio Borneo 2024-05-06 500 unsigned int virq,
64782652b8d981 Antonio Borneo 2024-05-06 501 unsigned int nr_irqs, void *data)
64782652b8d981 Antonio Borneo 2024-05-06 502 {
4386976d39c92f Antonio Borneo 2024-05-06 503 struct stm32mp_exti_host_data *host_data = dm->host_data;
4386976d39c92f Antonio Borneo 2024-05-06 504 struct stm32mp_exti_chip_data *chip_data;
64782652b8d981 Antonio Borneo 2024-05-06 505 u8 desc_irq;
64782652b8d981 Antonio Borneo 2024-05-06 506 struct irq_fwspec *fwspec = data;
64782652b8d981 Antonio Borneo 2024-05-06 507 struct irq_fwspec p_fwspec;
64782652b8d981 Antonio Borneo 2024-05-06 508 irq_hw_number_t hwirq;
64782652b8d981 Antonio Borneo 2024-05-06 509 int bank;
64782652b8d981 Antonio Borneo 2024-05-06 510 u32 event_trg;
64782652b8d981 Antonio Borneo 2024-05-06 511 struct irq_chip *chip;
64782652b8d981 Antonio Borneo 2024-05-06 512
64782652b8d981 Antonio Borneo 2024-05-06 513 hwirq = fwspec->param[0];
64782652b8d981 Antonio Borneo 2024-05-06 514 if (hwirq >= host_data->drv_data->bank_nr * IRQS_PER_BANK)
64782652b8d981 Antonio Borneo 2024-05-06 515 return -EINVAL;
64782652b8d981 Antonio Borneo 2024-05-06 516
64782652b8d981 Antonio Borneo 2024-05-06 517 bank = hwirq / IRQS_PER_BANK;
64782652b8d981 Antonio Borneo 2024-05-06 518 chip_data = &host_data->chips_data[bank];
64782652b8d981 Antonio Borneo 2024-05-06 519
64782652b8d981 Antonio Borneo 2024-05-06 520 /* Check if event is reserved (Secure) */
64782652b8d981 Antonio Borneo 2024-05-06 521 if (chip_data->event_reserved & BIT(hwirq % IRQS_PER_BANK)) {
64782652b8d981 Antonio Borneo 2024-05-06 522 dev_err(host_data->dev, "event %lu is reserved, secure\n", hwirq);
64782652b8d981 Antonio Borneo 2024-05-06 523 return -EPERM;
64782652b8d981 Antonio Borneo 2024-05-06 524 }
64782652b8d981 Antonio Borneo 2024-05-06 525
64782652b8d981 Antonio Borneo 2024-05-06 526 event_trg = readl_relaxed(host_data->base + chip_data->reg_bank->trg_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 527 chip = (event_trg & BIT(hwirq % IRQS_PER_BANK)) ?
4386976d39c92f Antonio Borneo 2024-05-06 528 &stm32mp_exti_chip : &stm32mp_exti_chip_direct;
64782652b8d981 Antonio Borneo 2024-05-06 529
64782652b8d981 Antonio Borneo 2024-05-06 @530 irq_domain_set_hwirq_and_chip(dm, virq, hwirq, chip, chip_data);
64782652b8d981 Antonio Borneo 2024-05-06 531
64782652b8d981 Antonio Borneo 2024-05-06 532 if (host_data->dt_has_irqs_desc) {
64782652b8d981 Antonio Borneo 2024-05-06 533 struct of_phandle_args out_irq;
64782652b8d981 Antonio Borneo 2024-05-06 534 int ret;
64782652b8d981 Antonio Borneo 2024-05-06 535
64782652b8d981 Antonio Borneo 2024-05-06 536 ret = of_irq_parse_one(host_data->dev->of_node, hwirq, &out_irq);
64782652b8d981 Antonio Borneo 2024-05-06 537 if (ret)
64782652b8d981 Antonio Borneo 2024-05-06 538 return ret;
64782652b8d981 Antonio Borneo 2024-05-06 539 /* we only support one parent, so far */
64782652b8d981 Antonio Borneo 2024-05-06 540 if (of_node_to_fwnode(out_irq.np) != dm->parent->fwnode)
64782652b8d981 Antonio Borneo 2024-05-06 541 return -EINVAL;
64782652b8d981 Antonio Borneo 2024-05-06 542
64782652b8d981 Antonio Borneo 2024-05-06 543 of_phandle_args_to_fwspec(out_irq.np, out_irq.args,
64782652b8d981 Antonio Borneo 2024-05-06 544 out_irq.args_count, &p_fwspec);
64782652b8d981 Antonio Borneo 2024-05-06 545
64782652b8d981 Antonio Borneo 2024-05-06 546 return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);
64782652b8d981 Antonio Borneo 2024-05-06 547 }
64782652b8d981 Antonio Borneo 2024-05-06 548
64782652b8d981 Antonio Borneo 2024-05-06 549 if (!host_data->drv_data->desc_irqs)
64782652b8d981 Antonio Borneo 2024-05-06 550 return -EINVAL;
64782652b8d981 Antonio Borneo 2024-05-06 551
64782652b8d981 Antonio Borneo 2024-05-06 552 desc_irq = host_data->drv_data->desc_irqs[hwirq];
64782652b8d981 Antonio Borneo 2024-05-06 553 if (desc_irq != EXTI_INVALID_IRQ) {
64782652b8d981 Antonio Borneo 2024-05-06 554 p_fwspec.fwnode = dm->parent->fwnode;
64782652b8d981 Antonio Borneo 2024-05-06 555 p_fwspec.param_count = 3;
64782652b8d981 Antonio Borneo 2024-05-06 556 p_fwspec.param[0] = GIC_SPI;
64782652b8d981 Antonio Borneo 2024-05-06 557 p_fwspec.param[1] = desc_irq;
64782652b8d981 Antonio Borneo 2024-05-06 558 p_fwspec.param[2] = IRQ_TYPE_LEVEL_HIGH;
64782652b8d981 Antonio Borneo 2024-05-06 559
64782652b8d981 Antonio Borneo 2024-05-06 560 return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);
64782652b8d981 Antonio Borneo 2024-05-06 561 }
64782652b8d981 Antonio Borneo 2024-05-06 562
64782652b8d981 Antonio Borneo 2024-05-06 563 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 564 }
64782652b8d981 Antonio Borneo 2024-05-06 565

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


Attachments:
(No filename) (25.84 kB)
reproduce (407.00 B)
config (148.42 kB)
Download all attachments

2024-05-07 06:24:41

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 6/8] irqchip/stm32mp-exti: allow build as module

Hi Antonio,

kernel test robot noticed the following build errors:

[auto build test ERROR on 382d2ffe86efb1e2fa803d2cf17e5bfc34e574f3]

url: https://github.com/intel-lab-lkp/linux/commits/Antonio-Borneo/irqchip-stm32-exti-add-CONFIG_STM32MP_EXTI/20240506-213819
base: 382d2ffe86efb1e2fa803d2cf17e5bfc34e574f3
patch link: https://lore.kernel.org/r/20240506133256.948712-7-antonio.borneo%40foss.st.com
patch subject: [PATCH 6/8] irqchip/stm32mp-exti: allow build as module
config: hexagon-randconfig-r064-20240507
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 37ae4ad0eef338776c7e2cffb3896153d43dcd90)
reproduce (this is a W=1 build):

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/irqchip/irq-stm32mp-exti.c:10:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from drivers/irqchip/irq-stm32mp-exti.c:10:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from drivers/irqchip/irq-stm32mp-exti.c:10:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
>> drivers/irqchip/irq-stm32mp-exti.c:340:9: error: no member named 'parent_data' in 'struct irq_data'
340 | if (d->parent_data->chip)
| ~ ^
>> drivers/irqchip/irq-stm32mp-exti.c:341:3: error: call to undeclared function 'irq_chip_eoi_parent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
341 | irq_chip_eoi_parent(d);
| ^
drivers/irqchip/irq-stm32mp-exti.c:353:9: error: no member named 'parent_data' in 'struct irq_data'
353 | if (d->parent_data->chip)
| ~ ^
>> drivers/irqchip/irq-stm32mp-exti.c:354:3: error: call to undeclared function 'irq_chip_mask_parent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
354 | irq_chip_mask_parent(d);
| ^
drivers/irqchip/irq-stm32mp-exti.c:366:9: error: no member named 'parent_data' in 'struct irq_data'
366 | if (d->parent_data->chip)
| ~ ^
>> drivers/irqchip/irq-stm32mp-exti.c:367:3: error: call to undeclared function 'irq_chip_unmask_parent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
367 | irq_chip_unmask_parent(d);
| ^
drivers/irqchip/irq-stm32mp-exti.c:428:9: error: no member named 'parent_data' in 'struct irq_data'
428 | if (d->parent_data->chip)
| ~ ^
>> drivers/irqchip/irq-stm32mp-exti.c:429:10: error: call to undeclared function 'irq_chip_set_affinity_parent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
429 | return irq_chip_set_affinity_parent(d, dest, force);
| ^
drivers/irqchip/irq-stm32mp-exti.c:429:10: note: did you mean 'irq_set_affinity_hint'?
include/linux/interrupt.h:349:19: note: 'irq_set_affinity_hint' declared here
349 | static inline int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
| ^
>> drivers/irqchip/irq-stm32mp-exti.c:488:14: error: use of undeclared identifier 'irq_chip_eoi_parent'
488 | .irq_eoi = irq_chip_eoi_parent,
| ^
>> drivers/irqchip/irq-stm32mp-exti.c:489:14: error: use of undeclared identifier 'irq_chip_ack_parent'
489 | .irq_ack = irq_chip_ack_parent,
| ^
>> drivers/irqchip/irq-stm32mp-exti.c:492:20: error: use of undeclared identifier 'irq_chip_retrigger_hierarchy'
492 | .irq_retrigger = irq_chip_retrigger_hierarchy,
| ^
>> drivers/irqchip/irq-stm32mp-exti.c:493:19: error: use of undeclared identifier 'irq_chip_set_type_parent'
493 | .irq_set_type = irq_chip_set_type_parent,
| ^
>> drivers/irqchip/irq-stm32mp-exti.c:496:47: error: use of undeclared identifier 'irq_chip_set_affinity_parent'; did you mean 'irq_set_affinity_hint'?
496 | .irq_set_affinity = IS_ENABLED(CONFIG_SMP) ? irq_chip_set_affinity_parent : NULL,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| irq_set_affinity_hint
include/linux/interrupt.h:349:19: note: 'irq_set_affinity_hint' declared here
349 | static inline int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
| ^
>> drivers/irqchip/irq-stm32mp-exti.c:530:2: error: call to undeclared function 'irq_domain_set_hwirq_and_chip'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
530 | irq_domain_set_hwirq_and_chip(dm, virq, hwirq, chip, chip_data);
| ^
>> drivers/irqchip/irq-stm32mp-exti.c:540:44: error: no member named 'parent' in 'struct irq_domain'
540 | if (of_node_to_fwnode(out_irq.np) != dm->parent->fwnode)
| ~~ ^
>> drivers/irqchip/irq-stm32mp-exti.c:546:10: error: call to undeclared function 'irq_domain_alloc_irqs_parent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
546 | return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);
| ^
drivers/irqchip/irq-stm32mp-exti.c:546:10: note: did you mean 'irq_domain_alloc_irqs'?
include/linux/irqdomain.h:576:19: note: 'irq_domain_alloc_irqs' declared here
576 | static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
| ^
drivers/irqchip/irq-stm32mp-exti.c:554:25: error: no member named 'parent' in 'struct irq_domain'
554 | p_fwspec.fwnode = dm->parent->fwnode;
| ~~ ^
drivers/irqchip/irq-stm32mp-exti.c:560:10: error: call to undeclared function 'irq_domain_alloc_irqs_parent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
560 | return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);
| ^
>> drivers/irqchip/irq-stm32mp-exti.c:598:10: error: use of undeclared identifier 'irq_domain_free_irqs_common'; did you mean 'irq_domain_free_irqs'?
598 | .free = irq_domain_free_irqs_common,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| irq_domain_free_irqs
include/linux/irqdomain.h:582:20: note: 'irq_domain_free_irqs' declared here
582 | static inline void irq_domain_free_irqs(unsigned int virq,
| ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
6 warnings and 20 errors generated.


vim +340 drivers/irqchip/irq-stm32mp-exti.c

64782652b8d981 Antonio Borneo 2024-05-06 327
4386976d39c92f Antonio Borneo 2024-05-06 328 static void stm32mp_exti_eoi(struct irq_data *d)
64782652b8d981 Antonio Borneo 2024-05-06 329 {
4386976d39c92f Antonio Borneo 2024-05-06 330 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 331 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 332
64782652b8d981 Antonio Borneo 2024-05-06 333 raw_spin_lock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 334
4386976d39c92f Antonio Borneo 2024-05-06 335 stm32mp_exti_write_bit(d, bank->rpr_ofst);
4386976d39c92f Antonio Borneo 2024-05-06 336 stm32mp_exti_write_bit(d, bank->fpr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 337
64782652b8d981 Antonio Borneo 2024-05-06 338 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 339
64782652b8d981 Antonio Borneo 2024-05-06 @340 if (d->parent_data->chip)
64782652b8d981 Antonio Borneo 2024-05-06 @341 irq_chip_eoi_parent(d);
64782652b8d981 Antonio Borneo 2024-05-06 342 }
64782652b8d981 Antonio Borneo 2024-05-06 343
4386976d39c92f Antonio Borneo 2024-05-06 344 static void stm32mp_exti_mask(struct irq_data *d)
64782652b8d981 Antonio Borneo 2024-05-06 345 {
4386976d39c92f Antonio Borneo 2024-05-06 346 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 347 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 348
64782652b8d981 Antonio Borneo 2024-05-06 349 raw_spin_lock(&chip_data->rlock);
4386976d39c92f Antonio Borneo 2024-05-06 350 chip_data->mask_cache = stm32mp_exti_clr_bit(d, bank->imr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 351 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 352
64782652b8d981 Antonio Borneo 2024-05-06 353 if (d->parent_data->chip)
64782652b8d981 Antonio Borneo 2024-05-06 @354 irq_chip_mask_parent(d);
64782652b8d981 Antonio Borneo 2024-05-06 355 }
64782652b8d981 Antonio Borneo 2024-05-06 356
4386976d39c92f Antonio Borneo 2024-05-06 357 static void stm32mp_exti_unmask(struct irq_data *d)
64782652b8d981 Antonio Borneo 2024-05-06 358 {
4386976d39c92f Antonio Borneo 2024-05-06 359 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 360 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 361
64782652b8d981 Antonio Borneo 2024-05-06 362 raw_spin_lock(&chip_data->rlock);
4386976d39c92f Antonio Borneo 2024-05-06 363 chip_data->mask_cache = stm32mp_exti_set_bit(d, bank->imr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 364 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 365
64782652b8d981 Antonio Borneo 2024-05-06 366 if (d->parent_data->chip)
64782652b8d981 Antonio Borneo 2024-05-06 @367 irq_chip_unmask_parent(d);
64782652b8d981 Antonio Borneo 2024-05-06 368 }
64782652b8d981 Antonio Borneo 2024-05-06 369
4386976d39c92f Antonio Borneo 2024-05-06 370 static int stm32mp_exti_set_type(struct irq_data *d, unsigned int type)
64782652b8d981 Antonio Borneo 2024-05-06 371 {
4386976d39c92f Antonio Borneo 2024-05-06 372 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 373 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 374 struct hwspinlock *hwlock = chip_data->host_data->hwlock;
64782652b8d981 Antonio Borneo 2024-05-06 375 void __iomem *base = chip_data->host_data->base;
64782652b8d981 Antonio Borneo 2024-05-06 376 u32 rtsr, ftsr;
64782652b8d981 Antonio Borneo 2024-05-06 377 int err;
64782652b8d981 Antonio Borneo 2024-05-06 378
64782652b8d981 Antonio Borneo 2024-05-06 379 raw_spin_lock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 380
64782652b8d981 Antonio Borneo 2024-05-06 381 if (hwlock) {
64782652b8d981 Antonio Borneo 2024-05-06 382 err = hwspin_lock_timeout_in_atomic(hwlock, HWSPNLCK_TIMEOUT);
64782652b8d981 Antonio Borneo 2024-05-06 383 if (err) {
64782652b8d981 Antonio Borneo 2024-05-06 384 pr_err("%s can't get hwspinlock (%d)\n", __func__, err);
64782652b8d981 Antonio Borneo 2024-05-06 385 goto unlock;
64782652b8d981 Antonio Borneo 2024-05-06 386 }
64782652b8d981 Antonio Borneo 2024-05-06 387 }
64782652b8d981 Antonio Borneo 2024-05-06 388
4386976d39c92f Antonio Borneo 2024-05-06 389 rtsr = readl_relaxed(base + bank->rtsr_ofst);
4386976d39c92f Antonio Borneo 2024-05-06 390 ftsr = readl_relaxed(base + bank->ftsr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 391
4386976d39c92f Antonio Borneo 2024-05-06 392 err = stm32mp_exti_convert_type(d, type, &rtsr, &ftsr);
64782652b8d981 Antonio Borneo 2024-05-06 393 if (err)
64782652b8d981 Antonio Borneo 2024-05-06 394 goto unspinlock;
64782652b8d981 Antonio Borneo 2024-05-06 395
4386976d39c92f Antonio Borneo 2024-05-06 396 writel_relaxed(rtsr, base + bank->rtsr_ofst);
4386976d39c92f Antonio Borneo 2024-05-06 397 writel_relaxed(ftsr, base + bank->ftsr_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 398
64782652b8d981 Antonio Borneo 2024-05-06 399 unspinlock:
64782652b8d981 Antonio Borneo 2024-05-06 400 if (hwlock)
64782652b8d981 Antonio Borneo 2024-05-06 401 hwspin_unlock_in_atomic(hwlock);
64782652b8d981 Antonio Borneo 2024-05-06 402 unlock:
64782652b8d981 Antonio Borneo 2024-05-06 403 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 404
64782652b8d981 Antonio Borneo 2024-05-06 405 return err;
64782652b8d981 Antonio Borneo 2024-05-06 406 }
64782652b8d981 Antonio Borneo 2024-05-06 407
4386976d39c92f Antonio Borneo 2024-05-06 408 static int stm32mp_exti_set_wake(struct irq_data *d, unsigned int on)
64782652b8d981 Antonio Borneo 2024-05-06 409 {
4386976d39c92f Antonio Borneo 2024-05-06 410 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
64782652b8d981 Antonio Borneo 2024-05-06 411 u32 mask = BIT(d->hwirq % IRQS_PER_BANK);
64782652b8d981 Antonio Borneo 2024-05-06 412
64782652b8d981 Antonio Borneo 2024-05-06 413 raw_spin_lock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 414
64782652b8d981 Antonio Borneo 2024-05-06 415 if (on)
64782652b8d981 Antonio Borneo 2024-05-06 416 chip_data->wake_active |= mask;
64782652b8d981 Antonio Borneo 2024-05-06 417 else
64782652b8d981 Antonio Borneo 2024-05-06 418 chip_data->wake_active &= ~mask;
64782652b8d981 Antonio Borneo 2024-05-06 419
64782652b8d981 Antonio Borneo 2024-05-06 420 raw_spin_unlock(&chip_data->rlock);
64782652b8d981 Antonio Borneo 2024-05-06 421
64782652b8d981 Antonio Borneo 2024-05-06 422 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 423 }
64782652b8d981 Antonio Borneo 2024-05-06 424
4386976d39c92f Antonio Borneo 2024-05-06 425 static int stm32mp_exti_set_affinity(struct irq_data *d,
64782652b8d981 Antonio Borneo 2024-05-06 426 const struct cpumask *dest, bool force)
64782652b8d981 Antonio Borneo 2024-05-06 427 {
64782652b8d981 Antonio Borneo 2024-05-06 428 if (d->parent_data->chip)
64782652b8d981 Antonio Borneo 2024-05-06 @429 return irq_chip_set_affinity_parent(d, dest, force);
64782652b8d981 Antonio Borneo 2024-05-06 430
64782652b8d981 Antonio Borneo 2024-05-06 431 return IRQ_SET_MASK_OK_DONE;
64782652b8d981 Antonio Borneo 2024-05-06 432 }
64782652b8d981 Antonio Borneo 2024-05-06 433
4386976d39c92f Antonio Borneo 2024-05-06 434 static int stm32mp_exti_suspend(struct device *dev)
64782652b8d981 Antonio Borneo 2024-05-06 435 {
4386976d39c92f Antonio Borneo 2024-05-06 436 struct stm32mp_exti_host_data *host_data = dev_get_drvdata(dev);
4386976d39c92f Antonio Borneo 2024-05-06 437 struct stm32mp_exti_chip_data *chip_data;
64782652b8d981 Antonio Borneo 2024-05-06 438 int i;
64782652b8d981 Antonio Borneo 2024-05-06 439
64782652b8d981 Antonio Borneo 2024-05-06 440 for (i = 0; i < host_data->drv_data->bank_nr; i++) {
64782652b8d981 Antonio Borneo 2024-05-06 441 chip_data = &host_data->chips_data[i];
4386976d39c92f Antonio Borneo 2024-05-06 442 stm32mp_chip_suspend(chip_data, chip_data->wake_active);
64782652b8d981 Antonio Borneo 2024-05-06 443 }
64782652b8d981 Antonio Borneo 2024-05-06 444
64782652b8d981 Antonio Borneo 2024-05-06 445 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 446 }
64782652b8d981 Antonio Borneo 2024-05-06 447
4386976d39c92f Antonio Borneo 2024-05-06 448 static int stm32mp_exti_resume(struct device *dev)
64782652b8d981 Antonio Borneo 2024-05-06 449 {
4386976d39c92f Antonio Borneo 2024-05-06 450 struct stm32mp_exti_host_data *host_data = dev_get_drvdata(dev);
4386976d39c92f Antonio Borneo 2024-05-06 451 struct stm32mp_exti_chip_data *chip_data;
64782652b8d981 Antonio Borneo 2024-05-06 452 int i;
64782652b8d981 Antonio Borneo 2024-05-06 453
64782652b8d981 Antonio Borneo 2024-05-06 454 for (i = 0; i < host_data->drv_data->bank_nr; i++) {
64782652b8d981 Antonio Borneo 2024-05-06 455 chip_data = &host_data->chips_data[i];
4386976d39c92f Antonio Borneo 2024-05-06 456 stm32mp_chip_resume(chip_data, chip_data->mask_cache);
64782652b8d981 Antonio Borneo 2024-05-06 457 }
64782652b8d981 Antonio Borneo 2024-05-06 458
64782652b8d981 Antonio Borneo 2024-05-06 459 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 460 }
64782652b8d981 Antonio Borneo 2024-05-06 461
4386976d39c92f Antonio Borneo 2024-05-06 462 static int stm32mp_exti_retrigger(struct irq_data *d)
64782652b8d981 Antonio Borneo 2024-05-06 463 {
4386976d39c92f Antonio Borneo 2024-05-06 464 struct stm32mp_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
4386976d39c92f Antonio Borneo 2024-05-06 465 const struct stm32mp_exti_bank *bank = chip_data->reg_bank;
64782652b8d981 Antonio Borneo 2024-05-06 466 void __iomem *base = chip_data->host_data->base;
64782652b8d981 Antonio Borneo 2024-05-06 467 u32 mask = BIT(d->hwirq % IRQS_PER_BANK);
64782652b8d981 Antonio Borneo 2024-05-06 468
4386976d39c92f Antonio Borneo 2024-05-06 469 writel_relaxed(mask, base + bank->swier_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 470
64782652b8d981 Antonio Borneo 2024-05-06 471 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 472 }
64782652b8d981 Antonio Borneo 2024-05-06 473
4386976d39c92f Antonio Borneo 2024-05-06 474 static struct irq_chip stm32mp_exti_chip = {
4386976d39c92f Antonio Borneo 2024-05-06 475 .name = "stm32mp-exti",
4386976d39c92f Antonio Borneo 2024-05-06 476 .irq_eoi = stm32mp_exti_eoi,
4386976d39c92f Antonio Borneo 2024-05-06 477 .irq_mask = stm32mp_exti_mask,
4386976d39c92f Antonio Borneo 2024-05-06 478 .irq_unmask = stm32mp_exti_unmask,
4386976d39c92f Antonio Borneo 2024-05-06 479 .irq_retrigger = stm32mp_exti_retrigger,
4386976d39c92f Antonio Borneo 2024-05-06 480 .irq_set_type = stm32mp_exti_set_type,
4386976d39c92f Antonio Borneo 2024-05-06 481 .irq_set_wake = stm32mp_exti_set_wake,
64782652b8d981 Antonio Borneo 2024-05-06 482 .flags = IRQCHIP_MASK_ON_SUSPEND,
4386976d39c92f Antonio Borneo 2024-05-06 483 .irq_set_affinity = IS_ENABLED(CONFIG_SMP) ? stm32mp_exti_set_affinity : NULL,
64782652b8d981 Antonio Borneo 2024-05-06 484 };
64782652b8d981 Antonio Borneo 2024-05-06 485
4386976d39c92f Antonio Borneo 2024-05-06 486 static struct irq_chip stm32mp_exti_chip_direct = {
4386976d39c92f Antonio Borneo 2024-05-06 487 .name = "stm32mp-exti-direct",
64782652b8d981 Antonio Borneo 2024-05-06 @488 .irq_eoi = irq_chip_eoi_parent,
64782652b8d981 Antonio Borneo 2024-05-06 @489 .irq_ack = irq_chip_ack_parent,
4386976d39c92f Antonio Borneo 2024-05-06 490 .irq_mask = stm32mp_exti_mask,
4386976d39c92f Antonio Borneo 2024-05-06 491 .irq_unmask = stm32mp_exti_unmask,
64782652b8d981 Antonio Borneo 2024-05-06 @492 .irq_retrigger = irq_chip_retrigger_hierarchy,
64782652b8d981 Antonio Borneo 2024-05-06 @493 .irq_set_type = irq_chip_set_type_parent,
4386976d39c92f Antonio Borneo 2024-05-06 494 .irq_set_wake = stm32mp_exti_set_wake,
64782652b8d981 Antonio Borneo 2024-05-06 495 .flags = IRQCHIP_MASK_ON_SUSPEND,
64782652b8d981 Antonio Borneo 2024-05-06 @496 .irq_set_affinity = IS_ENABLED(CONFIG_SMP) ? irq_chip_set_affinity_parent : NULL,
64782652b8d981 Antonio Borneo 2024-05-06 497 };
64782652b8d981 Antonio Borneo 2024-05-06 498
4386976d39c92f Antonio Borneo 2024-05-06 499 static int stm32mp_exti_domain_alloc(struct irq_domain *dm,
64782652b8d981 Antonio Borneo 2024-05-06 500 unsigned int virq,
64782652b8d981 Antonio Borneo 2024-05-06 501 unsigned int nr_irqs, void *data)
64782652b8d981 Antonio Borneo 2024-05-06 502 {
4386976d39c92f Antonio Borneo 2024-05-06 503 struct stm32mp_exti_host_data *host_data = dm->host_data;
4386976d39c92f Antonio Borneo 2024-05-06 504 struct stm32mp_exti_chip_data *chip_data;
64782652b8d981 Antonio Borneo 2024-05-06 505 u8 desc_irq;
64782652b8d981 Antonio Borneo 2024-05-06 506 struct irq_fwspec *fwspec = data;
64782652b8d981 Antonio Borneo 2024-05-06 507 struct irq_fwspec p_fwspec;
64782652b8d981 Antonio Borneo 2024-05-06 508 irq_hw_number_t hwirq;
64782652b8d981 Antonio Borneo 2024-05-06 509 int bank;
64782652b8d981 Antonio Borneo 2024-05-06 510 u32 event_trg;
64782652b8d981 Antonio Borneo 2024-05-06 511 struct irq_chip *chip;
64782652b8d981 Antonio Borneo 2024-05-06 512
64782652b8d981 Antonio Borneo 2024-05-06 513 hwirq = fwspec->param[0];
64782652b8d981 Antonio Borneo 2024-05-06 514 if (hwirq >= host_data->drv_data->bank_nr * IRQS_PER_BANK)
64782652b8d981 Antonio Borneo 2024-05-06 515 return -EINVAL;
64782652b8d981 Antonio Borneo 2024-05-06 516
64782652b8d981 Antonio Borneo 2024-05-06 517 bank = hwirq / IRQS_PER_BANK;
64782652b8d981 Antonio Borneo 2024-05-06 518 chip_data = &host_data->chips_data[bank];
64782652b8d981 Antonio Borneo 2024-05-06 519
64782652b8d981 Antonio Borneo 2024-05-06 520 /* Check if event is reserved (Secure) */
64782652b8d981 Antonio Borneo 2024-05-06 521 if (chip_data->event_reserved & BIT(hwirq % IRQS_PER_BANK)) {
64782652b8d981 Antonio Borneo 2024-05-06 522 dev_err(host_data->dev, "event %lu is reserved, secure\n", hwirq);
64782652b8d981 Antonio Borneo 2024-05-06 523 return -EPERM;
64782652b8d981 Antonio Borneo 2024-05-06 524 }
64782652b8d981 Antonio Borneo 2024-05-06 525
64782652b8d981 Antonio Borneo 2024-05-06 526 event_trg = readl_relaxed(host_data->base + chip_data->reg_bank->trg_ofst);
64782652b8d981 Antonio Borneo 2024-05-06 527 chip = (event_trg & BIT(hwirq % IRQS_PER_BANK)) ?
4386976d39c92f Antonio Borneo 2024-05-06 528 &stm32mp_exti_chip : &stm32mp_exti_chip_direct;
64782652b8d981 Antonio Borneo 2024-05-06 529
64782652b8d981 Antonio Borneo 2024-05-06 @530 irq_domain_set_hwirq_and_chip(dm, virq, hwirq, chip, chip_data);
64782652b8d981 Antonio Borneo 2024-05-06 531
64782652b8d981 Antonio Borneo 2024-05-06 532 if (host_data->dt_has_irqs_desc) {
64782652b8d981 Antonio Borneo 2024-05-06 533 struct of_phandle_args out_irq;
64782652b8d981 Antonio Borneo 2024-05-06 534 int ret;
64782652b8d981 Antonio Borneo 2024-05-06 535
64782652b8d981 Antonio Borneo 2024-05-06 536 ret = of_irq_parse_one(host_data->dev->of_node, hwirq, &out_irq);
64782652b8d981 Antonio Borneo 2024-05-06 537 if (ret)
64782652b8d981 Antonio Borneo 2024-05-06 538 return ret;
64782652b8d981 Antonio Borneo 2024-05-06 539 /* we only support one parent, so far */
64782652b8d981 Antonio Borneo 2024-05-06 540 if (of_node_to_fwnode(out_irq.np) != dm->parent->fwnode)
64782652b8d981 Antonio Borneo 2024-05-06 541 return -EINVAL;
64782652b8d981 Antonio Borneo 2024-05-06 542
64782652b8d981 Antonio Borneo 2024-05-06 543 of_phandle_args_to_fwspec(out_irq.np, out_irq.args,
64782652b8d981 Antonio Borneo 2024-05-06 544 out_irq.args_count, &p_fwspec);
64782652b8d981 Antonio Borneo 2024-05-06 545
64782652b8d981 Antonio Borneo 2024-05-06 546 return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);
64782652b8d981 Antonio Borneo 2024-05-06 547 }
64782652b8d981 Antonio Borneo 2024-05-06 548
64782652b8d981 Antonio Borneo 2024-05-06 549 if (!host_data->drv_data->desc_irqs)
64782652b8d981 Antonio Borneo 2024-05-06 550 return -EINVAL;
64782652b8d981 Antonio Borneo 2024-05-06 551
64782652b8d981 Antonio Borneo 2024-05-06 552 desc_irq = host_data->drv_data->desc_irqs[hwirq];
64782652b8d981 Antonio Borneo 2024-05-06 553 if (desc_irq != EXTI_INVALID_IRQ) {
64782652b8d981 Antonio Borneo 2024-05-06 554 p_fwspec.fwnode = dm->parent->fwnode;
64782652b8d981 Antonio Borneo 2024-05-06 555 p_fwspec.param_count = 3;
64782652b8d981 Antonio Borneo 2024-05-06 556 p_fwspec.param[0] = GIC_SPI;
64782652b8d981 Antonio Borneo 2024-05-06 557 p_fwspec.param[1] = desc_irq;
64782652b8d981 Antonio Borneo 2024-05-06 558 p_fwspec.param[2] = IRQ_TYPE_LEVEL_HIGH;
64782652b8d981 Antonio Borneo 2024-05-06 559
64782652b8d981 Antonio Borneo 2024-05-06 560 return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);
64782652b8d981 Antonio Borneo 2024-05-06 561 }
64782652b8d981 Antonio Borneo 2024-05-06 562
64782652b8d981 Antonio Borneo 2024-05-06 563 return 0;
64782652b8d981 Antonio Borneo 2024-05-06 564 }
64782652b8d981 Antonio Borneo 2024-05-06 565

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


Attachments:
(No filename) (28.24 kB)
reproduce (533.00 B)
config (137.02 kB)
Download all attachments