Skip to contentSkip to conversation

x86/mmcfg/drhd: Move acpi_mmcfg_init() before calling acpi_parse_dmar()

PATCH Superseded Zhenzhong Duan 2 participants 8 messages Aug 16, 2018 – Aug 17, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mmcfg/drhd: Move acpi_mmcfg_init() before calling acpi_parse_dmar()

On a multiple pci segment system such as HPE Superdome-Flex, pci config space from nonzero segment is accessed with mmcfg during acpi parsing DMAR region.

We need to setup mmcfg mapping before that or else drhd isn't correctly setup and devices under it fail to load in dom0.

---
 xen/arch/x86/setup.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
xen/arch/x86/setup.c +4 -4
index 8301de8..9af7426 100644
@@ -1493,6 +1493,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
     generic_apic_probe();
 
+    pt_pci_init();
+
+    acpi_mmcfg_init();
+
     acpi_boot_init();
 
     if ( smp_found_config )
@@ -1596,12 +1600,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
     local_irq_enable();
 
-    pt_pci_init();
-
     vesa_mtrr_init();
 
-    acpi_mmcfg_init();
-
     early_msi_init();
 
     iommu_setup();    /* setup iommu if available */
Signature · 6 lines
1.7.3

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 16.08.18 at 07:10, <[email protected]> wrote:

On a multiple pci segment system such as HPE Superdome-Flex, pci config space from nonzero segment is accessed with mmcfg during acpi parsing DMAR region.

First of all - can you please write a little more helpful (to reviewers) patch description. I had to hunt down the config space accesses instead of you clearly saying where they are (and why they are unavoidably there).

Furthermore you also move the invocation of pt_pci_init(), with no explanation at all. I did not want to invest the time to understand why that's needed.

Quoted 2 lines

We need to setup mmcfg mapping before that or else drhd isn't correctly setup and devices under it fail to load in dom0.

That's the improvement side of the change. Mind also saying a word on why the reordering won't break any other dependencies? After all you move up the functions across dozens of other ones, not the least far ahead of the point where IRQs get enabled the first time.

Have you investigated the alternative of deferring acpi_dmar_init() to a later point, or at least the part of it that needs to do PCI config space accesses? I'm not currently convinced the device scope parsing needs to happen that early: Neither iommu_supports_eim() nor iommu_enable_x2apic_IR() look to depend on that information at the first glance, and I think these are the routines that require (part of) the DMAR parsing to happen early.

xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long mbi_p) · line 1500

Quoted 11 lines
xen/arch/x86/setup.c +4 -0
@@ -1493,6 +1493,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
     generic_apic_probe();
 
+    pt_pci_init();
+
+    acpi_mmcfg_init();
+
     acpi_boot_init();

With the dependency being _in_ acpi_boot_init(), the invocation of acpi_mmcfg_init() should now be moved there.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 8 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 16.08.18 at 07:10, <[email protected]> wrote:

On a multiple pci segment system such as HPE Superdome-Flex, pci config space from nonzero segment is accessed with mmcfg during acpi parsing DMAR region.

First of all - can you please write a little more helpful (to reviewers) patch description. I had to hunt down the config space accesses instead of you clearly saying where they are (and why they are unavoidably there).

Sorry, I'll improve it in v2

Quoted 4 lines

Furthermore you also move the invocation of pt_pci_init(), with no explanation at all. I did not want to invest the time to understand why that's needed.

I'll add it in v2. I moved pt_pci_init() ahead because pci_add_segment() depending on pci_segments radix tree being initialized. acpi_mmcfg_init
->acpi_parse_mcfg

    ->pci_add_segment
Quoted 8 lines
Quoted 3 lines

We need to setup mmcfg mapping before that or else drhd isn't correctly setup and devices under it fail to load in dom0.

That's the improvement side of the change. Mind also saying a word on why the reordering won't break any other dependencies? After all you move up the functions across dozens of other ones, not the least far ahead of the point where IRQs get enabled the first time.

pt_pci_init() initialize pci_segments radix tree, acpi_mmcfg_init() initialize pci_mmcfg_virt[] and setup mmcfg mapping in pci_mmcfg_virt[idx].virt. I thought it's ok to just have these structures initialzed earlier.

Quoted 8 lines

Have you investigated the alternative of deferring acpi_dmar_init() to a later point, or at least the part of it that needs to do PCI config space accesses? I'm not currently convinced the device scope parsing needs to happen that early: Neither iommu_supports_eim() nor iommu_enable_x2apic_IR() look to depend on that information at the first glance, and I think these are the routines that require (part of) the DMAR parsing to happen early.

I moved acpi_mmcfg_init() ahead of acpi_boot_init() because below code sequence depending on pci_mmcfg_virt being correctly setup. acpi_dmar_init
->acpi_parse_dmar

    ->acpi_parse_one_drhd
      ->acpi_parse_dev_scope
        ->pci_conf_read8
          ->pci_mmcfg_read
            ->pci_dev_base
              ->get_virt
Quoted 7 lines
Quoted 7 lines
xen/arch/x86/setup.c +0 -0
@@ -1493,6 +1493,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
      generic_apic_probe();
 
Quoted 8 lines

xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long mbi_p) · line 1500

Quoted 5 lines
xen/arch/x86/setup.c +4 -0
+    pt_pci_init();
+
+    acpi_mmcfg_init();
+
      acpi_boot_init();

With the dependency being _in_ acpi_boot_init(), the invocation of acpi_mmcfg_init() should now be moved there.

Yes, I feel better to move pt_pci_init() and acpi_mmcfg_init() in acpi_boot_init() before acpi_mmcfg_init(). Any more comments?

Thanks
Zhenzhong

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 14 lines · Zhenzhong Duan
Quoted 14 lines

xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long · line 1499

Quoted 11 lines
xen/arch/x86/setup.c +4 -0
@@ -1493,6 +1493,10 @@ void __init noreturn __start_xen(unsigned long 
 mbi_p)
       generic_apic_probe();
+    pt_pci_init();
+
+    acpi_mmcfg_init();
+
       acpi_boot_init();

With the dependency being _in_ acpi_boot_init(), the invocation of acpi_mmcfg_init() should now be moved there.

Quoted 1 line

Yes, I feel better to move pt_pci_init() and acpi_mmcfg_init() in acpi_boot_init() before acpi_mmcfg_init(). Any more comments?

I see acpi_boot_init() is empty func when CONFIG_ACPI_BOOT isn't set. Do we support disabling this config option? If yes, I think above change will break non-acpi case.

Thanks
Zhenzhong

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 16.08.18 at 11:30, <[email protected]> wrote:
Quoted 13 lines · Zhenzhong Duan
Quoted 13 lines

xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long · line 1499

Quoted 10 lines
xen/arch/x86/setup.c +4 -0
@@ -1493,6 +1493,10 @@ void __init noreturn __start_xen(unsigned long 
 mbi_p)
      generic_apic_probe();
+    pt_pci_init();
+
+    acpi_mmcfg_init();
+
      acpi_boot_init();

With the dependency being _in_ acpi_boot_init(), the invocation of acpi_mmcfg_init() should now be moved there.

Quoted 5 lines
Quoted 2 lines

Yes, I feel better to move pt_pci_init() and acpi_mmcfg_init() in acpi_boot_init() before acpi_mmcfg_init(). Any more comments?

I see acpi_boot_init() is empty func when CONFIG_ACPI_BOOT isn't set. Do we support disabling this config option? If yes, I think above change will break non-acpi case.

I'm sorry, but I'm lost: grep produces no single hit on my tree when looking for ACPI_BOOT. Are you looking at some older tree? Even when considering ACPI - that Kconfig option exists only for ARM's purposes right now. If you were to make it user selectable, I think you'd first have to fix a number of build issues in case it got turned off.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 21 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 16.08.18 at 11:30, <[email protected]> wrote:
Quoted 13 lines · Zhenzhong Duan
Quoted 13 lines

xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long · line 1499

Quoted 10 lines
xen/arch/x86/setup.c +4 -0
@@ -1493,6 +1493,10 @@ void __init noreturn __start_xen(unsigned long
 mbi_p)
       generic_apic_probe();
+    pt_pci_init();
+
+    acpi_mmcfg_init();
+
       acpi_boot_init();

With the dependency being _in_ acpi_boot_init(), the invocation of acpi_mmcfg_init() should now be moved there.

Quoted 5 lines
Quoted 2 lines

Yes, I feel better to move pt_pci_init() and acpi_mmcfg_init() in acpi_boot_init() before acpi_mmcfg_init(). Any more comments?

I see acpi_boot_init() is empty func when CONFIG_ACPI_BOOT isn't set. Do we support disabling this config option? If yes, I think above change will break non-acpi case.

Quoted 6 lines

I'm sorry, but I'm lost: grep produces no single hit on my tree when looking for ACPI_BOOT. Are you looking at some older tree? Even when considering ACPI - that Kconfig option exists only for ARM's purposes right now. If you were to make it user selectable, I think you'd first have to fix a number of build issues in case it got turned off.

Sorry, I wrongly looked into oracle internal branch.
In upstream, it's CONFIG_ACPI. It looks not an issue as you said CONFIG_ACPI is only for ARM.

Thanks
Zhenzhong

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
In reply to Zhenzhong Duan
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 16.08.18 at 11:13, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich

Have you investigated the alternative of deferring acpi_dmar_init() to a later point, or at least the part of it that needs to do PCI config space accesses? I'm not currently convinced the device scope parsing needs to happen that early: Neither iommu_supports_eim() nor iommu_enable_x2apic_IR() look to depend on that information at the first glance, and I think these are the routines that require (part of) the DMAR parsing to happen early.

I moved acpi_mmcfg_init() ahead of acpi_boot_init() because below code sequence depending on pci_mmcfg_virt being correctly setup. acpi_dmar_init
->acpi_parse_dmar

Quoted 6 lines
     ->acpi_parse_one_drhd
       ->acpi_parse_dev_scope
         ->pci_conf_read8
           ->pci_mmcfg_read
             ->pci_dev_base
               ->get_virt

Have you read my previous response in full? I'm specifically asking whether the device scope parsing (i.e. acpi_parse_dev_scope()) really needs to happen as early as it does now. Without that, the dependency on MMCFG accesses working would go away.

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
xen/arch/x86/setup.c +0 -0
@@ -1493,6 +1493,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
      generic_apic_probe();
 
Quoted 8 lines

xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long mbi_p) · line 1500

Quoted 5 lines
xen/arch/x86/setup.c +4 -0
+    pt_pci_init();
+
+    acpi_mmcfg_init();
+
      acpi_boot_init();

With the dependency being _in_ acpi_boot_init(), the invocation of acpi_mmcfg_init() should now be moved there.

Quoted 2 lines

Yes, I feel better to move pt_pci_init() and acpi_mmcfg_init() in acpi_boot_init() before acpi_mmcfg_init().

I didn't say move both, did I?

That said, now having looked at what it actually does, I think you want to rename it if the suggested alternative route can't be used, as in particular the pt_ prefix is quite misleading then. Once that has happened, moving the invocation perhaps even _into_ acpi_mcfg_init() might be reasonable.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw
Quoted 20 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 16.08.18 at 11:13, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich

Have you investigated the alternative of deferring acpi_dmar_init() to a later point, or at least the part of it that needs to do PCI config space accesses? I'm not currently convinced the device scope parsing needs to happen that early: Neither iommu_supports_eim() nor iommu_enable_x2apic_IR() look to depend on that information at the first glance, and I think these are the routines that require (part of) the DMAR parsing to happen early.

I moved acpi_mmcfg_init() ahead of acpi_boot_init() because below code sequence depending on pci_mmcfg_virt being correctly setup. acpi_dmar_init

Quoted 7 lines
    ->acpi_parse_dmar
      ->acpi_parse_one_drhd
        ->acpi_parse_dev_scope
          ->pci_conf_read8
            ->pci_mmcfg_read
              ->pci_dev_base
                ->get_virt
Quoted 4 lines

Have you read my previous response in full? I'm specifically asking whether the device scope parsing (i.e. acpi_parse_dev_scope()) really needs to happen as early as it does now. Without that, the dependency on MMCFG accesses working would go away.

I'll move acpi_dmar_init() to later point to have a test as acpi_parse_one_drhd, acpi_parse_one_rmrr and acpi_parse_one_atsr all called acpi_parse_dev_scope.

Quoted 18 lines
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
xen/arch/x86/setup.c +0 -0
@@ -1493,6 +1493,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
       generic_apic_probe();
 
Quoted 8 lines

xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long mbi_p) · line 1500

Quoted 5 lines
xen/arch/x86/setup.c +4 -0
+    pt_pci_init();
+
+    acpi_mmcfg_init();
+
       acpi_boot_init();

With the dependency being _in_ acpi_boot_init(), the invocation of acpi_mmcfg_init() should now be moved there.

Quoted 2 lines

Yes, I feel better to move pt_pci_init() and acpi_mmcfg_init() in acpi_boot_init() before acpi_mmcfg_init().

Quoted 6 lines

I didn't say move both, did I?

That said, now having looked at what it actually does, I think you want to rename it if the suggested alternative route can't be used, as in particular the pt_ prefix is quite misleading then. Once that has happened, moving the invocation perhaps even _into_ acpi_mcfg_init()

Understood.
Personly I like this way more as pt_pci_init() and acpi_mmcfg_init() only initialized some global variable and harmless to move ahead. Also acpi_mcfg_init from its name is suitable to move in acpi_boot_init()

Thanks
Zhenzhong

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel