[v2] of: OF_IRQ: select IRQ_DOMAIN instead of depending on it

Message ID 20240213225619.11726-1-rdunlap@infradead.org
State New
Headers
Series [v2] of: OF_IRQ: select IRQ_DOMAIN instead of depending on it |

Commit Message

Randy Dunlap Feb. 13, 2024, 10:56 p.m. UTC
  IRQ_DOMAIN is a hidden (not user visible) symbol. Users cannot set
it directly thru "make *config", so drivers should select it instead
of depending on it if they need it.
Relying on it being set for a dependency is risky.

Consistently using "select" or "depends on" can also help reduce
Kconfig circular dependency issues.

Therefore, change OF_IRQ's use of "depends on" to "select".

This patch reduces one Kconfig circular dependency in
drivers/mux/Kconfig when MUX_MMIO attempts to select REGMAP (a failed
patch), which that driver needs (but does not completely resolve that
issue). [1]

before this patch: (10 lines of detail)
drivers/net/ethernet/arc/Kconfig:19:error: recursive dependency detected!
drivers/net/ethernet/arc/Kconfig:19:	symbol ARC_EMAC_CORE is selected by ARC_EMAC
drivers/net/ethernet/arc/Kconfig:26:	symbol ARC_EMAC depends on OF_IRQ
drivers/of/Kconfig:81:	symbol OF_IRQ depends on IRQ_DOMAIN
kernel/irq/Kconfig:60:	symbol IRQ_DOMAIN is selected by REGMAP
drivers/base/regmap/Kconfig:6:	symbol REGMAP is selected by MUX_MMIO
drivers/mux/Kconfig:48:	symbol MUX_MMIO depends on MULTIPLEXER
drivers/mux/Kconfig:6:	symbol MULTIPLEXER is selected by MDIO_BUS_MUX_MULTIPLEXER
drivers/net/mdio/Kconfig:275:	symbol MDIO_BUS_MUX_MULTIPLEXER depends on MDIO_DEVICE
drivers/net/mdio/Kconfig:6:	symbol MDIO_DEVICE is selected by PHYLIB
drivers/net/phy/Kconfig:16:	symbol PHYLIB is selected by ARC_EMAC_CORE

after this patch: (5 lines of detail)
drivers/mux/Kconfig:6:error: recursive dependency detected!
drivers/mux/Kconfig:6:	symbol MULTIPLEXER is selected by MDIO_BUS_MUX_MULTIPLEXER
drivers/net/mdio/Kconfig:275:	symbol MDIO_BUS_MUX_MULTIPLEXER depends on MDIO_BUS
drivers/net/mdio/Kconfig:13:	symbol MDIO_BUS is selected by REGMAP
drivers/base/regmap/Kconfig:6:	symbol REGMAP is selected by MUX_MMIO
drivers/mux/Kconfig:48:	symbol MUX_MMIO depends on MULTIPLEXER

[1] https://lore.kernel.org/lkml/20230210115625.GA30942@pengutronix.de/

Fixes: 63c60e3a6dc3 ("of: OF_IRQ should depend on IRQ_DOMAIN")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Peter Rosin <peda@axentia.se>
Cc: devicetree@vger.kernel.org
---
v2: update patch description, rebase & resend

 drivers/of/Kconfig |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Marc Zyngier Feb. 14, 2024, 9:52 a.m. UTC | #1
On Tue, 13 Feb 2024 22:56:19 +0000,
Randy Dunlap <rdunlap@infradead.org> wrote:
> 
> IRQ_DOMAIN is a hidden (not user visible) symbol. Users cannot set
> it directly thru "make *config", so drivers should select it instead
> of depending on it if they need it.
> Relying on it being set for a dependency is risky.
> 
> Consistently using "select" or "depends on" can also help reduce
> Kconfig circular dependency issues.
> 
> Therefore, change OF_IRQ's use of "depends on" to "select".
> 
> This patch reduces one Kconfig circular dependency in
> drivers/mux/Kconfig when MUX_MMIO attempts to select REGMAP (a failed
> patch), which that driver needs (but does not completely resolve that
> issue). [1]
> 
> before this patch: (10 lines of detail)
> drivers/net/ethernet/arc/Kconfig:19:error: recursive dependency detected!
> drivers/net/ethernet/arc/Kconfig:19:	symbol ARC_EMAC_CORE is selected by ARC_EMAC
> drivers/net/ethernet/arc/Kconfig:26:	symbol ARC_EMAC depends on OF_IRQ
> drivers/of/Kconfig:81:	symbol OF_IRQ depends on IRQ_DOMAIN
> kernel/irq/Kconfig:60:	symbol IRQ_DOMAIN is selected by REGMAP
> drivers/base/regmap/Kconfig:6:	symbol REGMAP is selected by MUX_MMIO
> drivers/mux/Kconfig:48:	symbol MUX_MMIO depends on MULTIPLEXER
> drivers/mux/Kconfig:6:	symbol MULTIPLEXER is selected by MDIO_BUS_MUX_MULTIPLEXER
> drivers/net/mdio/Kconfig:275:	symbol MDIO_BUS_MUX_MULTIPLEXER depends on MDIO_DEVICE
> drivers/net/mdio/Kconfig:6:	symbol MDIO_DEVICE is selected by PHYLIB
> drivers/net/phy/Kconfig:16:	symbol PHYLIB is selected by ARC_EMAC_CORE
> 
> after this patch: (5 lines of detail)
> drivers/mux/Kconfig:6:error: recursive dependency detected!
> drivers/mux/Kconfig:6:	symbol MULTIPLEXER is selected by MDIO_BUS_MUX_MULTIPLEXER
> drivers/net/mdio/Kconfig:275:	symbol MDIO_BUS_MUX_MULTIPLEXER depends on MDIO_BUS
> drivers/net/mdio/Kconfig:13:	symbol MDIO_BUS is selected by REGMAP
> drivers/base/regmap/Kconfig:6:	symbol REGMAP is selected by MUX_MMIO
> drivers/mux/Kconfig:48:	symbol MUX_MMIO depends on MULTIPLEXER
> 
> [1] https://lore.kernel.org/lkml/20230210115625.GA30942@pengutronix.de/
> 
> Fixes: 63c60e3a6dc3 ("of: OF_IRQ should depend on IRQ_DOMAIN")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Peter Rosin <peda@axentia.se>
> Cc: devicetree@vger.kernel.org
> ---
> v2: update patch description, rebase & resend
> 
>  drivers/of/Kconfig |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff -- a/drivers/of/Kconfig b/drivers/of/Kconfig
> --- a/drivers/of/Kconfig
> +++ b/drivers/of/Kconfig
> @@ -80,7 +80,8 @@ config OF_ADDRESS
>  
>  config OF_IRQ
>  	def_bool y
> -	depends on !SPARC && IRQ_DOMAIN
> +	depends on !SPARC
> +	select IRQ_DOMAIN
>  
>  config OF_RESERVED_MEM
>  	def_bool OF_EARLY_FLATTREE
> 

This seems to be moving is the right direction. FWIW,

Acked-by: Marc Zyngier <maz@kernel.org>

	M.
  
Arnd Bergmann Feb. 14, 2024, 4:06 p.m. UTC | #2
On Wed, Feb 14, 2024, at 10:52, Marc Zyngier wrote:
> On Tue, 13 Feb 2024 22:56:19 +0000, Randy Dunlap <rdunlap@infradead.org> wrote:
>>
>> diff -- a/drivers/of/Kconfig b/drivers/of/Kconfig
>> --- a/drivers/of/Kconfig
>> +++ b/drivers/of/Kconfig
>> @@ -80,7 +80,8 @@ config OF_ADDRESS
>>  
>>  config OF_IRQ
>>  	def_bool y
>> -	depends on !SPARC && IRQ_DOMAIN
>> +	depends on !SPARC
>> +	select IRQ_DOMAIN
> 
>
> This seems to be moving is the right direction.

Can we move the 'select IRQ_DOMAIN' under CONFIG_IRQCHIP
then and remove the individual selects from the irqchip
drivers? It looks like CONFIG_OF (other than sparc) now
unconditionally enables OF_IRQ and IRQCHIP anyway.

     Arnd
  
Marc Zyngier Feb. 14, 2024, 4:35 p.m. UTC | #3
On Wed, 14 Feb 2024 16:06:06 +0000,
"Arnd Bergmann" <arnd@arndb.de> wrote:
> 
> On Wed, Feb 14, 2024, at 10:52, Marc Zyngier wrote:
> > On Tue, 13 Feb 2024 22:56:19 +0000, Randy Dunlap <rdunlap@infradead.org> wrote:
> >>
> >> diff -- a/drivers/of/Kconfig b/drivers/of/Kconfig
> >> --- a/drivers/of/Kconfig
> >> +++ b/drivers/of/Kconfig
> >> @@ -80,7 +80,8 @@ config OF_ADDRESS
> >>  
> >>  config OF_IRQ
> >>  	def_bool y
> >> -	depends on !SPARC && IRQ_DOMAIN
> >> +	depends on !SPARC
> >> +	select IRQ_DOMAIN
> > 
> >
> > This seems to be moving is the right direction.
> 
> Can we move the 'select IRQ_DOMAIN' under CONFIG_IRQCHIP
> then and remove the individual selects from the irqchip
> drivers? It looks like CONFIG_OF (other than sparc) now
> unconditionally enables OF_IRQ and IRQCHIP anyway.

As long as it also works ACPI, it should be OK.

	M.
  
Arnd Bergmann Feb. 14, 2024, 5:22 p.m. UTC | #4
On Wed, Feb 14, 2024, at 17:35, Marc Zyngier wrote:
> On Wed, 14 Feb 2024 16:06:06 +0000,
> "Arnd Bergmann" <arnd@arndb.de> wrote:
>> 
>> On Wed, Feb 14, 2024, at 10:52, Marc Zyngier wrote:
>> > On Tue, 13 Feb 2024 22:56:19 +0000, Randy Dunlap <rdunlap@infradead.org> wrote:
>> >>
>> >> diff -- a/drivers/of/Kconfig b/drivers/of/Kconfig
>> >> --- a/drivers/of/Kconfig
>> >> +++ b/drivers/of/Kconfig
>> >> @@ -80,7 +80,8 @@ config OF_ADDRESS
>> >>  
>> >>  config OF_IRQ
>> >>  	def_bool y
>> >> -	depends on !SPARC && IRQ_DOMAIN
>> >> +	depends on !SPARC
>> >> +	select IRQ_DOMAIN
>> > 
>> >
>> > This seems to be moving is the right direction.
>> 
>> Can we move the 'select IRQ_DOMAIN' under CONFIG_IRQCHIP
>> then and remove the individual selects from the irqchip
>> drivers? It looks like CONFIG_OF (other than sparc) now
>> unconditionally enables OF_IRQ and IRQCHIP anyway.
>
> As long as it also works ACPI, it should be OK.

Out of the four architectures that have ACPI support (x86,
arm64, loongarch, rv64), only x86 doesn't always select
IRQ_DOMAIN already, and x86 selects it for almost all
configs:

config X86_UP_APIC
        bool "Local APIC support on uniprocessors" if !PCI_MSI
        default PCI_MSI
        depends on X86_32 && !SMP && !X86_32_NON_STANDARD

config X86_LOCAL_APIC
        def_bool y
        depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC || PCI_MSI
        select IRQ_DOMAIN_HIERARCHY

so it's only disabled here with

CONFIG_64BIT=n
CONFIG_SMP=n
CONFIG_X86_32_NON_STANDARD=n
CONFIG_ACPI=y
CONFIG_PCI=y (implied by ACPI)
CONFIG_PCI_MSI=n

As far as I can tell, this specific configuration is
currently able to save a little bit of kernel size
by avoiding IRQ_DOMAIN, but we are probably better off
enabling it here as well for consistency

     Arnd
  
Rob Herring Feb. 15, 2024, 3:08 p.m. UTC | #5
On Wed, Feb 14, 2024 at 06:22:53PM +0100, Arnd Bergmann wrote:
> On Wed, Feb 14, 2024, at 17:35, Marc Zyngier wrote:
> > On Wed, 14 Feb 2024 16:06:06 +0000,
> > "Arnd Bergmann" <arnd@arndb.de> wrote:
> >> 
> >> On Wed, Feb 14, 2024, at 10:52, Marc Zyngier wrote:
> >> > On Tue, 13 Feb 2024 22:56:19 +0000, Randy Dunlap <rdunlap@infradead.org> wrote:
> >> >>
> >> >> diff -- a/drivers/of/Kconfig b/drivers/of/Kconfig
> >> >> --- a/drivers/of/Kconfig
> >> >> +++ b/drivers/of/Kconfig
> >> >> @@ -80,7 +80,8 @@ config OF_ADDRESS
> >> >>  
> >> >>  config OF_IRQ
> >> >>  	def_bool y
> >> >> -	depends on !SPARC && IRQ_DOMAIN
> >> >> +	depends on !SPARC
> >> >> +	select IRQ_DOMAIN
> >> > 
> >> >
> >> > This seems to be moving is the right direction.
> >> 
> >> Can we move the 'select IRQ_DOMAIN' under CONFIG_IRQCHIP
> >> then and remove the individual selects from the irqchip
> >> drivers? It looks like CONFIG_OF (other than sparc) now
> >> unconditionally enables OF_IRQ and IRQCHIP anyway.
> >
> > As long as it also works ACPI, it should be OK.
> 
> Out of the four architectures that have ACPI support (x86,
> arm64, loongarch, rv64), only x86 doesn't always select
> IRQ_DOMAIN already, and x86 selects it for almost all
> configs:
> 
> config X86_UP_APIC
>         bool "Local APIC support on uniprocessors" if !PCI_MSI
>         default PCI_MSI
>         depends on X86_32 && !SMP && !X86_32_NON_STANDARD
> 
> config X86_LOCAL_APIC
>         def_bool y
>         depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC || PCI_MSI
>         select IRQ_DOMAIN_HIERARCHY
> 
> so it's only disabled here with
> 
> CONFIG_64BIT=n
> CONFIG_SMP=n
> CONFIG_X86_32_NON_STANDARD=n
> CONFIG_ACPI=y
> CONFIG_PCI=y (implied by ACPI)
> CONFIG_PCI_MSI=n
> 
> As far as I can tell, this specific configuration is
> currently able to save a little bit of kernel size
> by avoiding IRQ_DOMAIN, but we are probably better off
> enabling it here as well for consistency

+1

Also, looks like we have a couple of 'select OF_IRQ' that could be 
dropped.

Rob
  

Patch

diff -- a/drivers/of/Kconfig b/drivers/of/Kconfig
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -80,7 +80,8 @@  config OF_ADDRESS
 
 config OF_IRQ
 	def_bool y
-	depends on !SPARC && IRQ_DOMAIN
+	depends on !SPARC
+	select IRQ_DOMAIN
 
 config OF_RESERVED_MEM
 	def_bool OF_EARLY_FLATTREE