# \[PATCH v2\] powerpc: iommu: fix build when neither PCI or IBMVIO is set

- Status: LANDED (b27dadecdf91 · 2021-04-08 11:17)
- Landed in mainline as b27dadecdf91 on 2021-04-08.
- List: linuxppc-dev
- 4 messages, 3 authors
- Page: https://ratatoskr.run/linuxppc-dev/2021/04/6326201/t

## \[PATCH v2\] powerpc: iommu: fix build when neither PCI or IBMVIO is set

- From: Randy Dunlap \<rdunlap@infradead.org\>
- Date: 2021-04-04 19:26:55 
- Message: https://ratatoskr.run/linuxppc-dev/2021/04/6326201.md

```text
When neither CONFIG_PCI nor CONFIG_IBMVIO is set/enabled, iommu.c has a
build error. The fault injection code is not useful in that kernel config,
so make the FAIL_IOMMU option depend on PCI || IBMVIO.

Prevents this build error (warning escalated to error):
../arch/powerpc/kernel/iommu.c:178:30: error: 'fail_iommu_bus_notifier' defined but not used [-Werror=unused-variable]
  178 | static struct notifier_block fail_iommu_bus_notifier = {

Fixes: d6b9a81b2a45 ("powerpc: IOMMU fault injection")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kernel test robot <redacted>
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: <redacted>
Cc: Anton Blanchard <redacted>
---
I was supposed to update this about one month ago, but then I lost
some email and also took a break for a few weeks, then I remembered,
so here it is.

 arch/powerpc/Kconfig.debug |    1 +
 1 file changed, 1 insertion(+)

--- lnx-512-rc1.orig/arch/powerpc/Kconfig.debug
+++ lnx-512-rc1/arch/powerpc/Kconfig.debug
@@ -353,6 +353,7 @@ config PPC_EARLY_DEBUG_CPM_ADDR
 config FAIL_IOMMU
 	bool "Fault-injection capability for IOMMU"
 	depends on FAULT_INJECTION
+	depends on PCI || IBMVIO
 	help
 	  Provide fault-injection capability for IOMMU. Each device can
 	  be selectively enabled via the fail_iommu property.
```

## Re: \[PATCH v2\] powerpc: iommu: fix build when neither PCI or IBMVIO is set

- From: Christophe Leroy \<hidden\>
- Date: 2021-04-05 09:07:06 
- Message: https://ratatoskr.run/linuxppc-dev/2021/04/6326596.md

```text


Le 04/04/2021 à 21:26, Randy Dunlap a écrit :
> When neither CONFIG_PCI nor CONFIG_IBMVIO is set/enabled, iommu.c has a
> build error. The fault injection code is not useful in that kernel config,
> so make the FAIL_IOMMU option depend on PCI || IBMVIO.
>
> Prevents this build error (warning escalated to error):
> ../arch/powerpc/kernel/iommu.c:178:30: error: 'fail_iommu_bus_notifier' defined but not used [-Werror=unused-variable]
>    178 | static struct notifier_block fail_iommu_bus_notifier = {
>
> Fixes: d6b9a81b2a45 ("powerpc: IOMMU fault injection")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Reported-by: kernel test robot <redacted>
> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: <redacted>
> Cc: Anton Blanchard <redacted>
> ---
> I was supposed to update this about one month ago, but then I lost
> some email and also took a break for a few weeks, then I remembered,
> so here it is.
>
>   arch/powerpc/Kconfig.debug |    1 +
>   1 file changed, 1 insertion(+)

Wouldn't it be cleaner to get rid of those two horid #ifdefs ?
Of course we can do both.

diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 216871414434..d691afa8acf8 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -180,12 +180,10 @@ static struct notifier_block fail_iommu_bus_notifier = {

 static int __init fail_iommu_setup(void)
 {
-#ifdef CONFIG_PCI
-	bus_register_notifier(&pci_bus_type, &fail_iommu_bus_notifier);
-#endif
-#ifdef CONFIG_IBMVIO
-	bus_register_notifier(&vio_bus_type, &fail_iommu_bus_notifier);
-#endif
+	if (IS_ENABLED(CONFIG_PCI))
+		bus_register_notifier(&pci_bus_type, &fail_iommu_bus_notifier);
+	if (IS_ENABLED(CONFIG_IBMVIO))
+		bus_register_notifier(&vio_bus_type, &fail_iommu_bus_notifier);

 	return 0;
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 86c799c97b77..361f4f255911 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -964,6 +964,8 @@ enum {
 #define PCI_IRQ_MSIX		(1 << 2) /* Allow MSI-X interrupts */
 #define PCI_IRQ_AFFINITY	(1 << 3) /* Auto-assign affinity */

+extern struct bus_type pci_bus_type;
+
 /* These external functions are only available when PCI support is enabled */
 #ifdef CONFIG_PCI

@@ -986,8 +988,6 @@ enum pcie_bus_config_types {

 extern enum pcie_bus_config_types pcie_bus_config;

-extern struct bus_type pci_bus_type;
-
 /* Do NOT directly access these two variables, unless you are arch-specific PCI
  * code, or PCI core code. */
 extern struct list_head pci_root_buses;	/* List of all known PCI buses */
```

## Re: \[PATCH v2\] powerpc: iommu: fix build when neither PCI or IBMVIO is set

- From: Randy Dunlap \<rdunlap@infradead.org\>
- Date: 2021-04-05 16:32:22 
- Message: https://ratatoskr.run/linuxppc-dev/2021/04/6327194.md

```text
On 4/5/21 2:04 AM, Christophe Leroy wrote:
> 
> 
> Le 04/04/2021 à 21:26, Randy Dunlap a écrit :
>> When neither CONFIG_PCI nor CONFIG_IBMVIO is set/enabled, iommu.c has a
>> build error. The fault injection code is not useful in that kernel config,
>> so make the FAIL_IOMMU option depend on PCI || IBMVIO.
>>
>> Prevents this build error (warning escalated to error):
>> ../arch/powerpc/kernel/iommu.c:178:30: error: 'fail_iommu_bus_notifier' defined but not used [-Werror=unused-variable]
>>    178 | static struct notifier_block fail_iommu_bus_notifier = {
>>
>> Fixes: d6b9a81b2a45 ("powerpc: IOMMU fault injection")
>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
>> Reported-by: kernel test robot <redacted>
>> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: <redacted>
>> Cc: Anton Blanchard <redacted>
>> ---
>> I was supposed to update this about one month ago, but then I lost
>> some email and also took a break for a few weeks, then I remembered,
>> so here it is.
>>
>>   arch/powerpc/Kconfig.debug |    1 +
>>   1 file changed, 1 insertion(+)
> 
> Wouldn't it be cleaner to get rid of those two horid #ifdefs ?
> Of course we can do both.

Sure, that works. Thanks.

Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested


> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index 216871414434..d691afa8acf8 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -180,12 +180,10 @@ static struct notifier_block fail_iommu_bus_notifier = {
> 
>  static int __init fail_iommu_setup(void)
>  {
> -#ifdef CONFIG_PCI
> -    bus_register_notifier(&pci_bus_type, &fail_iommu_bus_notifier);
> -#endif
> -#ifdef CONFIG_IBMVIO
> -    bus_register_notifier(&vio_bus_type, &fail_iommu_bus_notifier);
> -#endif
> +    if (IS_ENABLED(CONFIG_PCI))
> +        bus_register_notifier(&pci_bus_type, &fail_iommu_bus_notifier);
> +    if (IS_ENABLED(CONFIG_IBMVIO))
> +        bus_register_notifier(&vio_bus_type, &fail_iommu_bus_notifier);
> 
>      return 0;
>  }
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 86c799c97b77..361f4f255911 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -964,6 +964,8 @@ enum {
>  #define PCI_IRQ_MSIX        (1 << 2) /* Allow MSI-X interrupts */
>  #define PCI_IRQ_AFFINITY    (1 << 3) /* Auto-assign affinity */
> 
> +extern struct bus_type pci_bus_type;
> +
>  /* These external functions are only available when PCI support is enabled */
>  #ifdef CONFIG_PCI
> 
> @@ -986,8 +988,6 @@ enum pcie_bus_config_types {
> 
>  extern enum pcie_bus_config_types pcie_bus_config;
> 
> -extern struct bus_type pci_bus_type;
> -
>  /* Do NOT directly access these two variables, unless you are arch-specific PCI
>   * code, or PCI core code. */
>  extern struct list_head pci_root_buses;    /* List of all known PCI buses */


-- 
~Randy

```

## Re: \[PATCH v2\] powerpc: iommu: fix build when neither PCI or IBMVIO is set

- From: Michael Ellerman \<hidden\>
- Date: 2021-04-10 14:29:47 
- Message: https://ratatoskr.run/linuxppc-dev/2021/04/6334064.md

```text
On Sun, 4 Apr 2021 12:26:23 -0700, Randy Dunlap wrote:
> When neither CONFIG_PCI nor CONFIG_IBMVIO is set/enabled, iommu.c has a
> build error. The fault injection code is not useful in that kernel config,
> so make the FAIL_IOMMU option depend on PCI || IBMVIO.
> 
> Prevents this build error (warning escalated to error):
> ../arch/powerpc/kernel/iommu.c:178:30: error: 'fail_iommu_bus_notifier' defined but not used [-Werror=unused-variable]
>   178 | static struct notifier_block fail_iommu_bus_notifier = {

Applied to powerpc/next.

[1/1] powerpc: iommu: fix build when neither PCI or IBMVIO is set
      https://git.kernel.org/powerpc/c/b27dadecdf9102838331b9a0b41ffc1cfe288154

cheers
```
