DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] config/arm: avoid mcpu and march conflicts
@ 2024-01-21  9:36 pbhagavatula
  2024-01-21  9:36 ` [PATCH 2/2] config/arm: add support for fallback march pbhagavatula
                   ` (3 more replies)
  0 siblings, 4 replies; 65+ messages in thread
From: pbhagavatula @ 2024-01-21  9:36 UTC (permalink / raw)
  To: jerinj, Ruifeng.Wang, nd, Ruifeng Wang, Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

The compiler options march and mtune are a subset
of mcpu and will lead to conflicts if improper march
is chosen for a given mcpu.
To avoid conflicts, force part number march when
mcpu is available and is supported by the compiler.

Example:
	march = armv9-a
	mcpu = neoverse-n2

	mcpu supported, march supported
	machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']

	mcpu supported, march not supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu not supported, march supported
	machine_args = ['-march=armv9-a']

	mcpu not supported, march not supported
	machine_args = ['-march=armv8.6-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 config/arm/meson.build | 109 +++++++++++++++++++++++++----------------
 1 file changed, 67 insertions(+), 42 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 36f21d2259..8c8cfccca0 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -58,18 +58,18 @@ implementer_generic = {
 }
 
 part_number_config_arm = {
-    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
-    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
-    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
-    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
-    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
-    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
+    '0xd03': {'mcpu': 'cortex-a53'},
+    '0xd04': {'mcpu': 'cortex-a35'},
+    '0xd05': {'mcpu': 'cortex-a55'},
+    '0xd07': {'mcpu': 'cortex-a57'},
+    '0xd08': {'mcpu': 'cortex-a72'},
+    '0xd09': {'mcpu': 'cortex-a73'},
+    '0xd0a': {'mcpu': 'cortex-a75'},
+    '0xd0b': {'mcpu': 'cortex-a76'},
     '0xd0c': {
         'march': 'armv8.2-a',
         'march_features': ['crypto', 'rcpc'],
-        'compiler_options':  ['-mcpu=neoverse-n1'],
+        'mcpu': 'neoverse-n1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -81,7 +81,7 @@ part_number_config_arm = {
     '0xd40': {
         'march': 'armv8.4-a',
         'march_features': ['sve'],
-        'compiler_options':  ['-mcpu=neoverse-v1'],
+        'mcpu': 'neoverse-v1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-v1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -92,8 +92,9 @@ part_number_config_arm = {
         'march': 'armv8.4-a',
     },
     '0xd49': {
+        'march': 'armv9-a',
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-n2'],
+        'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,21 +128,22 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'compiler_options': ['-mcpu=thunderxt88'],
+            'mcpu': 'thunderxt88',
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'compiler_options': ['-mcpu=thunderxt81'],
+            'mcpu': 'thunderxt81',
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
+            'mcpu': 'thunderxt83',
+            'compiler_options': ['-march=armv8-a+crc'],
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
             'march': 'armv8.1-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options': ['-mcpu=thunderx2t99'],
+            'mcpu': 'thunderx2t99',
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -153,7 +155,7 @@ implementer_cavium = {
         '0xb2': {
             'march': 'armv8.2-a',
             'march_features': ['crc', 'crypto', 'lse'],
-            'compiler_options': ['-mcpu=octeontx2'],
+            'mcpu': 'octeontx2',
             'flags': [
                 ['RTE_MACHINE', '"cn9k"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -176,7 +178,7 @@ implementer_ampere = {
         '0x0': {
             'march': 'armv8-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mtune=emag'],
+            'mcpu': 'emag',
             'flags': [
                 ['RTE_MACHINE', '"eMAG"'],
                 ['RTE_MAX_LCORE', 32],
@@ -186,7 +188,7 @@ implementer_ampere = {
         '0xac3': {
             'march': 'armv8.6-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mcpu=ampere1'],
+            'mcpu': 'ampere1',
             'flags': [
                 ['RTE_MACHINE', '"AmpereOne"'],
                 ['RTE_MAX_LCORE', 320],
@@ -206,7 +208,7 @@ implementer_hisilicon = {
         '0xd01': {
             'march': 'armv8.2-a',
             'march_features': ['crypto'],
-            'compiler_options': ['-mtune=tsv110'],
+            'mcpu': 'tsv110',
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -695,11 +697,23 @@ if update_flags
 
     machine_args = [] # Clear previous machine args
 
+    candidate_mcpu = ''
+    support_mcpu = false
+    if part_number_config.has_key('mcpu')
+        mcpu = part_number_config['mcpu']
+        if (cc.has_argument('-mcpu=' + mcpu))
+            candidate_mcpu = mcpu
+            support_mcpu = true
+        endif
+    endif
+
     # probe supported archs and their features
     candidate_march = ''
     if part_number_config.has_key('march')
-        if part_number_config.get('force_march', false)
-            candidate_march = part_number_config['march']
+        if part_number_config.get('force_march', false) or support_mcpu
+            if cc.has_argument('-march=' +  part_number_config['march'])
+                candidate_march = part_number_config['march']
+            endif
         else
             supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
@@ -717,32 +731,43 @@ if update_flags
                 endif
             endforeach
         endif
-        if candidate_march == ''
-            error('No suitable armv8 march version found.')
-        endif
+
         if candidate_march != part_number_config['march']
-            warning('Configuration march version is ' +
-                    '@0@, but the compiler supports only @1@.'
-                    .format(part_number_config['march'], candidate_march))
+            warning('Configuration march version is @0@, not supported.'
+                    .format(part_number_config['march']))
+            if candidate_march != ''
+                warning('Using march version @0@.'.format(candidate_march))
+            endif
         endif
-        candidate_march = '-march=' + candidate_march
 
-        march_features = []
-        if part_number_config.has_key('march_features')
-            march_features += part_number_config['march_features']
+        if candidate_march == '' and candidate_mcpu == ''
+            error('No suitable ARM march/mcpu version found.')
         endif
-        if soc_config.has_key('extra_march_features')
-            march_features += soc_config['extra_march_features']
-        endif
-        foreach feature: march_features
-            if cc.has_argument('+'.join([candidate_march, feature]))
-                candidate_march = '+'.join([candidate_march, feature])
-            else
-                warning('The compiler does not support feature @0@'
-                    .format(feature))
+
+        if candidate_march != ''
+            candidate_march = '-march=' + candidate_march
+            march_features = []
+            if part_number_config.has_key('march_features')
+                march_features += part_number_config['march_features']
             endif
-        endforeach
-        machine_args += candidate_march
+            if soc_config.has_key('extra_march_features')
+                march_features += soc_config['extra_march_features']
+            endif
+            foreach feature: march_features
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    warning('The compiler does not support feature @0@'
+                        .format(feature))
+                endif
+            endforeach
+            machine_args += candidate_march
+        endif
+    endif
+
+    if candidate_mcpu != ''
+        candidate_mcpu = '-mcpu=' + candidate_mcpu
+        machine_args += candidate_mcpu
     endif
 
     # apply supported compiler options
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 2/2] config/arm: add support for fallback march
  2024-01-21  9:36 [PATCH 1/2] config/arm: avoid mcpu and march conflicts pbhagavatula
@ 2024-01-21  9:36 ` pbhagavatula
  2024-01-22  6:30   ` Ruifeng Wang
  2024-01-22 11:04   ` Juraj Linkeš
  2024-01-22  6:29 ` [PATCH 1/2] config/arm: avoid mcpu and march conflicts Ruifeng Wang
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 65+ messages in thread
From: pbhagavatula @ 2024-01-21  9:36 UTC (permalink / raw)
  To: jerinj, Ruifeng.Wang, nd, Ruifeng Wang, Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some ARM CPUs have specific march requirements and
are not compatible with the supported march list.
Add fallback march in case the mcpu and the march
advertised in the part_number_config are not supported
by the compiler.

Example
	mcpu = neoverse-n2
	march = armv9-a
	fallback_march = armv8.5-a

	mcpu, march not supported
	machine_args = ['-march=armv8.5-a']

	mcpu, march, fallback_march not supported
	least march supported = armv8-a

	machine_args = ['-march=armv8-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 config/arm/meson.build | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 8c8cfccca0..2aaf78a81a 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -94,6 +94,7 @@ part_number_config_arm = {
     '0xd49': {
         'march': 'armv9-a',
         'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
         'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
@@ -709,14 +710,14 @@ if update_flags

     # probe supported archs and their features
     candidate_march = ''
+    supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a',
+                        'armv8.3-a', 'armv8.2-a', 'armv8.1-a', 'armv8-a']
     if part_number_config.has_key('march')
         if part_number_config.get('force_march', false) or support_mcpu
             if cc.has_argument('-march=' +  part_number_config['march'])
                 candidate_march = part_number_config['march']
             endif
         else
-            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
-                                'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
                 if supported_march == part_number_config['march']
@@ -733,6 +734,16 @@ if update_flags
         endif

         if candidate_march != part_number_config['march']
+            if part_number_config.has_key('fallback_march') and not support_mcpu
+                fallback_march = part_number_config['fallback_march']
+                foreach supported_march: supported_marchs
+                    if (supported_march == fallback_march
+                        and cc.has_argument('-march=' + supported_march))
+                        candidate_march = supported_march
+                        break
+                    endif
+                endforeach
+            endif
             warning('Configuration march version is @0@, not supported.'
                     .format(part_number_config['march']))
             if candidate_march != ''
--
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 1/2] config/arm: avoid mcpu and march conflicts
  2024-01-21  9:36 [PATCH 1/2] config/arm: avoid mcpu and march conflicts pbhagavatula
  2024-01-21  9:36 ` [PATCH 2/2] config/arm: add support for fallback march pbhagavatula
@ 2024-01-22  6:29 ` Ruifeng Wang
  2024-01-22 10:55 ` Juraj Linkeš
  2024-02-01 21:57 ` [PATCH v2 1/3] " pbhagavatula
  3 siblings, 0 replies; 65+ messages in thread
From: Ruifeng Wang @ 2024-01-22  6:29 UTC (permalink / raw)
  To: pbhagavatula, jerinj, Bruce Richardson, juraj.linkes,
	Honnappa Nagarahalli
  Cc: dev, nd

+Cc

On 2024/1/21 5:36 PM, pbhagavatula@marvell.com wrote:
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> The compiler options march and mtune are a subset
> of mcpu and will lead to conflicts if improper march
> is chosen for a given mcpu.
> To avoid conflicts, force part number march when
> mcpu is available and is supported by the compiler.
> 
> Example:
> 	march = armv9-a
> 	mcpu = neoverse-n2
> 
> 	mcpu supported, march supported
> 	machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> 
> 	mcpu supported, march not supported
> 	machine_args = ['-mcpu=neoverse-n2']
> 
> 	mcpu not supported, march supported
> 	machine_args = ['-march=armv9-a']
> 
> 	mcpu not supported, march not supported
> 	machine_args = ['-march=armv8.6-a']
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>   config/arm/meson.build | 109 +++++++++++++++++++++++++----------------
>   1 file changed, 67 insertions(+), 42 deletions(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 36f21d2259..8c8cfccca0 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -58,18 +58,18 @@ implementer_generic = {
>   }
>   
>   part_number_config_arm = {
> -    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
> -    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
> -    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
> -    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
> -    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
> -    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
> -    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
> -    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
> +    '0xd03': {'mcpu': 'cortex-a53'},
> +    '0xd04': {'mcpu': 'cortex-a35'},
> +    '0xd05': {'mcpu': 'cortex-a55'},
> +    '0xd07': {'mcpu': 'cortex-a57'},
> +    '0xd08': {'mcpu': 'cortex-a72'},
> +    '0xd09': {'mcpu': 'cortex-a73'},
> +    '0xd0a': {'mcpu': 'cortex-a75'},
> +    '0xd0b': {'mcpu': 'cortex-a76'},
>       '0xd0c': {
>           'march': 'armv8.2-a',
>           'march_features': ['crypto', 'rcpc'],
> -        'compiler_options':  ['-mcpu=neoverse-n1'],
> +        'mcpu': 'neoverse-n1',
>           'flags': [
>               ['RTE_MACHINE', '"neoverse-n1"'],
>               ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -81,7 +81,7 @@ part_number_config_arm = {
>       '0xd40': {
>           'march': 'armv8.4-a',
>           'march_features': ['sve'],
> -        'compiler_options':  ['-mcpu=neoverse-v1'],
> +        'mcpu': 'neoverse-v1',
>           'flags': [
>               ['RTE_MACHINE', '"neoverse-v1"'],
>               ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -92,8 +92,9 @@ part_number_config_arm = {
>           'march': 'armv8.4-a',
>       },
>       '0xd49': {
> +        'march': 'armv9-a',
>           'march_features': ['sve2'],
> -        'compiler_options': ['-mcpu=neoverse-n2'],
> +        'mcpu': 'neoverse-n2',
>           'flags': [
>               ['RTE_MACHINE', '"neoverse-n2"'],
>               ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -127,21 +128,22 @@ implementer_cavium = {
>       ],
>       'part_number_config': {
>           '0xa1': {
> -            'compiler_options': ['-mcpu=thunderxt88'],
> +            'mcpu': 'thunderxt88',
>               'flags': flags_part_number_thunderx
>           },
>           '0xa2': {
> -            'compiler_options': ['-mcpu=thunderxt81'],
> +            'mcpu': 'thunderxt81',
>               'flags': flags_part_number_thunderx
>           },
>           '0xa3': {
> -            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
> +            'mcpu': 'thunderxt83',
> +            'compiler_options': ['-march=armv8-a+crc'],
>               'flags': flags_part_number_thunderx
>           },
>           '0xaf': {
>               'march': 'armv8.1-a',
>               'march_features': ['crc', 'crypto'],
> -            'compiler_options': ['-mcpu=thunderx2t99'],
> +            'mcpu': 'thunderx2t99',
>               'flags': [
>                   ['RTE_MACHINE', '"thunderx2"'],
>                   ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -153,7 +155,7 @@ implementer_cavium = {
>           '0xb2': {
>               'march': 'armv8.2-a',
>               'march_features': ['crc', 'crypto', 'lse'],
> -            'compiler_options': ['-mcpu=octeontx2'],
> +            'mcpu': 'octeontx2',
>               'flags': [
>                   ['RTE_MACHINE', '"cn9k"'],
>                   ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -176,7 +178,7 @@ implementer_ampere = {
>           '0x0': {
>               'march': 'armv8-a',
>               'march_features': ['crc', 'crypto'],
> -            'compiler_options':  ['-mtune=emag'],
> +            'mcpu': 'emag',
>               'flags': [
>                   ['RTE_MACHINE', '"eMAG"'],
>                   ['RTE_MAX_LCORE', 32],
> @@ -186,7 +188,7 @@ implementer_ampere = {
>           '0xac3': {
>               'march': 'armv8.6-a',
>               'march_features': ['crc', 'crypto'],
> -            'compiler_options':  ['-mcpu=ampere1'],
> +            'mcpu': 'ampere1',
>               'flags': [
>                   ['RTE_MACHINE', '"AmpereOne"'],
>                   ['RTE_MAX_LCORE', 320],
> @@ -206,7 +208,7 @@ implementer_hisilicon = {
>           '0xd01': {
>               'march': 'armv8.2-a',
>               'march_features': ['crypto'],
> -            'compiler_options': ['-mtune=tsv110'],
> +            'mcpu': 'tsv110',
>               'flags': [
>                   ['RTE_MACHINE', '"Kunpeng 920"'],
>                   ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -695,11 +697,23 @@ if update_flags
>   
>       machine_args = [] # Clear previous machine args
>   
> +    candidate_mcpu = ''
> +    support_mcpu = false
> +    if part_number_config.has_key('mcpu')
> +        mcpu = part_number_config['mcpu']
> +        if (cc.has_argument('-mcpu=' + mcpu))
> +            candidate_mcpu = mcpu
> +            support_mcpu = true
> +        endif
> +    endif
> +
>       # probe supported archs and their features
>       candidate_march = ''
>       if part_number_config.has_key('march')
> -        if part_number_config.get('force_march', false)
> -            candidate_march = part_number_config['march']
> +        if part_number_config.get('force_march', false) or support_mcpu
> +            if cc.has_argument('-march=' +  part_number_config['march'])
> +                candidate_march = part_number_config['march']
> +            endif
>           else
>               supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
>                                   'armv8.2-a', 'armv8.1-a', 'armv8-a']
> @@ -717,32 +731,43 @@ if update_flags
>                   endif
>               endforeach
>           endif
> -        if candidate_march == ''
> -            error('No suitable armv8 march version found.')
> -        endif
> +
>           if candidate_march != part_number_config['march']
> -            warning('Configuration march version is ' +
> -                    '@0@, but the compiler supports only @1@.'
> -                    .format(part_number_config['march'], candidate_march))
> +            warning('Configuration march version is @0@, not supported.'
> +                    .format(part_number_config['march']))
> +            if candidate_march != ''
> +                warning('Using march version @0@.'.format(candidate_march))
> +            endif
>           endif
> -        candidate_march = '-march=' + candidate_march
>   
> -        march_features = []
> -        if part_number_config.has_key('march_features')
> -            march_features += part_number_config['march_features']
> +        if candidate_march == '' and candidate_mcpu == ''
> +            error('No suitable ARM march/mcpu version found.')
>           endif
> -        if soc_config.has_key('extra_march_features')
> -            march_features += soc_config['extra_march_features']
> -        endif
> -        foreach feature: march_features
> -            if cc.has_argument('+'.join([candidate_march, feature]))
> -                candidate_march = '+'.join([candidate_march, feature])
> -            else
> -                warning('The compiler does not support feature @0@'
> -                    .format(feature))
> +
> +        if candidate_march != ''
> +            candidate_march = '-march=' + candidate_march
> +            march_features = []
> +            if part_number_config.has_key('march_features')
> +                march_features += part_number_config['march_features']
>               endif
> -        endforeach
> -        machine_args += candidate_march
> +            if soc_config.has_key('extra_march_features')
> +                march_features += soc_config['extra_march_features']
> +            endif
> +            foreach feature: march_features
> +                if cc.has_argument('+'.join([candidate_march, feature]))
> +                    candidate_march = '+'.join([candidate_march, feature])
> +                else
> +                    warning('The compiler does not support feature @0@'
> +                        .format(feature))
> +                endif
> +            endforeach
> +            machine_args += candidate_march
> +        endif
> +    endif
> +
> +    if candidate_mcpu != ''
> +        candidate_mcpu = '-mcpu=' + candidate_mcpu
> +        machine_args += candidate_mcpu
>       endif
>   
>       # apply supported compiler options

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 2/2] config/arm: add support for fallback march
  2024-01-21  9:36 ` [PATCH 2/2] config/arm: add support for fallback march pbhagavatula
@ 2024-01-22  6:30   ` Ruifeng Wang
  2024-01-22 11:04   ` Juraj Linkeš
  1 sibling, 0 replies; 65+ messages in thread
From: Ruifeng Wang @ 2024-01-22  6:30 UTC (permalink / raw)
  To: pbhagavatula, jerinj, Bruce Richardson, juraj.linkes,
	Honnappa Nagarahalli
  Cc: dev, nd

+Cc

On 2024/1/21 5:36 PM, pbhagavatula@marvell.com wrote:
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Some ARM CPUs have specific march requirements and
> are not compatible with the supported march list.
> Add fallback march in case the mcpu and the march
> advertised in the part_number_config are not supported
> by the compiler.
> 
> Example
> 	mcpu = neoverse-n2
> 	march = armv9-a
> 	fallback_march = armv8.5-a
> 
> 	mcpu, march not supported
> 	machine_args = ['-march=armv8.5-a']
> 
> 	mcpu, march, fallback_march not supported
> 	least march supported = armv8-a
> 
> 	machine_args = ['-march=armv8-a']
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>   config/arm/meson.build | 15 +++++++++++++--
>   1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 8c8cfccca0..2aaf78a81a 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -94,6 +94,7 @@ part_number_config_arm = {
>       '0xd49': {
>           'march': 'armv9-a',
>           'march_features': ['sve2'],
> +        'fallback_march': 'armv8.5-a',
>           'mcpu': 'neoverse-n2',
>           'flags': [
>               ['RTE_MACHINE', '"neoverse-n2"'],
> @@ -709,14 +710,14 @@ if update_flags
> 
>       # probe supported archs and their features
>       candidate_march = ''
> +    supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> +                        'armv8.3-a', 'armv8.2-a', 'armv8.1-a', 'armv8-a']
>       if part_number_config.has_key('march')
>           if part_number_config.get('force_march', false) or support_mcpu
>               if cc.has_argument('-march=' +  part_number_config['march'])
>                   candidate_march = part_number_config['march']
>               endif
>           else
> -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
> -                                'armv8.2-a', 'armv8.1-a', 'armv8-a']
>               check_compiler_support = false
>               foreach supported_march: supported_marchs
>                   if supported_march == part_number_config['march']
> @@ -733,6 +734,16 @@ if update_flags
>           endif
> 
>           if candidate_march != part_number_config['march']
> +            if part_number_config.has_key('fallback_march') and not support_mcpu
> +                fallback_march = part_number_config['fallback_march']
> +                foreach supported_march: supported_marchs
> +                    if (supported_march == fallback_march
> +                        and cc.has_argument('-march=' + supported_march))
> +                        candidate_march = supported_march
> +                        break
> +                    endif
> +                endforeach
> +            endif
>               warning('Configuration march version is @0@, not supported.'
>                       .format(part_number_config['march']))
>               if candidate_march != ''
> --
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 1/2] config/arm: avoid mcpu and march conflicts
  2024-01-21  9:36 [PATCH 1/2] config/arm: avoid mcpu and march conflicts pbhagavatula
  2024-01-21  9:36 ` [PATCH 2/2] config/arm: add support for fallback march pbhagavatula
  2024-01-22  6:29 ` [PATCH 1/2] config/arm: avoid mcpu and march conflicts Ruifeng Wang
@ 2024-01-22 10:55 ` Juraj Linkeš
  2024-01-22 11:54   ` [EXT] " Pavan Nikhilesh Bhagavatula
  2024-02-01 21:57 ` [PATCH v2 1/3] " pbhagavatula
  3 siblings, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-01-22 10:55 UTC (permalink / raw)
  To: pbhagavatula; +Cc: jerinj, Ruifeng.Wang, nd, Bruce Richardson, dev

On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> The compiler options march and mtune are a subset
> of mcpu and will lead to conflicts if improper march
> is chosen for a given mcpu.
> To avoid conflicts, force part number march when
> mcpu is available and is supported by the compiler.
>
> Example:
>         march = armv9-a
>         mcpu = neoverse-n2
>
>         mcpu supported, march supported
>         machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
>
>         mcpu supported, march not supported
>         machine_args = ['-mcpu=neoverse-n2']
>
>         mcpu not supported, march supported
>         machine_args = ['-march=armv9-a']
>
>         mcpu not supported, march not supported
>         machine_args = ['-march=armv8.6-a']
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  config/arm/meson.build | 109 +++++++++++++++++++++++++----------------
>  1 file changed, 67 insertions(+), 42 deletions(-)
>
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 36f21d2259..8c8cfccca0 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
<snip>
> @@ -127,21 +128,22 @@ implementer_cavium = {
>      ],
>      'part_number_config': {
>          '0xa1': {
> -            'compiler_options': ['-mcpu=thunderxt88'],
> +            'mcpu': 'thunderxt88',
>              'flags': flags_part_number_thunderx
>          },
>          '0xa2': {
> -            'compiler_options': ['-mcpu=thunderxt81'],
> +            'mcpu': 'thunderxt81',
>              'flags': flags_part_number_thunderx
>          },
>          '0xa3': {
> -            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
> +            'mcpu': 'thunderxt83',
> +            'compiler_options': ['-march=armv8-a+crc'],

Let's unify this with the rest and specify 'march': 'armv8-a+crc'
instead of having it under compiler_options.

>              'flags': flags_part_number_thunderx
>          },
>          '0xaf': {
>              'march': 'armv8.1-a',
>              'march_features': ['crc', 'crypto'],
> -            'compiler_options': ['-mcpu=thunderx2t99'],
> +            'mcpu': 'thunderx2t99',
>              'flags': [
>                  ['RTE_MACHINE', '"thunderx2"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -153,7 +155,7 @@ implementer_cavium = {
>          '0xb2': {
>              'march': 'armv8.2-a',
>              'march_features': ['crc', 'crypto', 'lse'],
> -            'compiler_options': ['-mcpu=octeontx2'],
> +            'mcpu': 'octeontx2',
>              'flags': [
>                  ['RTE_MACHINE', '"cn9k"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -176,7 +178,7 @@ implementer_ampere = {
>          '0x0': {
>              'march': 'armv8-a',
>              'march_features': ['crc', 'crypto'],
> -            'compiler_options':  ['-mtune=emag'],
> +            'mcpu': 'emag',

We're changing mtune to mcpu, is this equivalent?

>              'flags': [
>                  ['RTE_MACHINE', '"eMAG"'],
>                  ['RTE_MAX_LCORE', 32],
> @@ -186,7 +188,7 @@ implementer_ampere = {
>          '0xac3': {
>              'march': 'armv8.6-a',
>              'march_features': ['crc', 'crypto'],
> -            'compiler_options':  ['-mcpu=ampere1'],
> +            'mcpu': 'ampere1',
>              'flags': [
>                  ['RTE_MACHINE', '"AmpereOne"'],
>                  ['RTE_MAX_LCORE', 320],
> @@ -206,7 +208,7 @@ implementer_hisilicon = {
>          '0xd01': {
>              'march': 'armv8.2-a',
>              'march_features': ['crypto'],
> -            'compiler_options': ['-mtune=tsv110'],
> +            'mcpu': 'tsv110',
>              'flags': [
>                  ['RTE_MACHINE', '"Kunpeng 920"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -695,11 +697,23 @@ if update_flags
>
>      machine_args = [] # Clear previous machine args
>
> +    candidate_mcpu = ''
> +    support_mcpu = false
> +    if part_number_config.has_key('mcpu')
> +        mcpu = part_number_config['mcpu']
> +        if (cc.has_argument('-mcpu=' + mcpu))
> +            candidate_mcpu = mcpu
> +            support_mcpu = true
> +        endif
> +    endif
> +
>      # probe supported archs and their features
>      candidate_march = ''
>      if part_number_config.has_key('march')
> -        if part_number_config.get('force_march', false)
> -            candidate_march = part_number_config['march']
> +        if part_number_config.get('force_march', false) or support_mcpu

Instead of using the extra "support_mcpu" variable, we could do the
same check as with candidate march (if candidate_mcpu != '', which we
actually do below in the last lines of the patch).

If I understand the logic correctly, we don't want to do the march
fallback if mcpu is specified - either the march works with the given
mcpu or we do without it (because we don't actually need it with
mcpu). Is that correct?

> +            if cc.has_argument('-march=' +  part_number_config['march'])

Now that we've added mcpu into the mix, is this still the right
condition? Can the below happen?

This check finds that machine_args = ['-march=armv9-a'] is supported.

But taken together with mcpu (machine_args = ['-mcpu=neoverse-n2',
'-march=armv9-a']), it is not supported? In this case we'll end up
with invalid configuration.

> +                candidate_march = part_number_config['march']
> +            endif
>          else
>              supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
>                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 2/2] config/arm: add support for fallback march
  2024-01-21  9:36 ` [PATCH 2/2] config/arm: add support for fallback march pbhagavatula
  2024-01-22  6:30   ` Ruifeng Wang
@ 2024-01-22 11:04   ` Juraj Linkeš
  2024-01-22 12:16     ` [EXT] " Pavan Nikhilesh Bhagavatula
  1 sibling, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-01-22 11:04 UTC (permalink / raw)
  To: pbhagavatula; +Cc: jerinj, Ruifeng.Wang, nd, Bruce Richardson, dev

On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Some ARM CPUs have specific march requirements and
> are not compatible with the supported march list.
> Add fallback march in case the mcpu and the march
> advertised in the part_number_config are not supported
> by the compiler.
>

It's not clear to me what this patch adds. We already have a fallback
mechanism and this basically does the same thing, but there's some
extra logic that's not clear to me. Looks like there are some extra
conditions around mcpu. In that case, all of the mcpu/march processing
should be done first and then we should do a common fallback.

> Example
>         mcpu = neoverse-n2
>         march = armv9-a
>         fallback_march = armv8.5-a
>
>         mcpu, march not supported
>         machine_args = ['-march=armv8.5-a']
>
>         mcpu, march, fallback_march not supported
>         least march supported = armv8-a
>
>         machine_args = ['-march=armv8-a']
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  config/arm/meson.build | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 8c8cfccca0..2aaf78a81a 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -94,6 +94,7 @@ part_number_config_arm = {
>      '0xd49': {
>          'march': 'armv9-a',
>          'march_features': ['sve2'],
> +        'fallback_march': 'armv8.5-a',
>          'mcpu': 'neoverse-n2',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'],
> @@ -709,14 +710,14 @@ if update_flags
>
>      # probe supported archs and their features
>      candidate_march = ''
> +    supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> +                        'armv8.3-a', 'armv8.2-a', 'armv8.1-a', 'armv8-a']
>      if part_number_config.has_key('march')
>          if part_number_config.get('force_march', false) or support_mcpu
>              if cc.has_argument('-march=' +  part_number_config['march'])
>                  candidate_march = part_number_config['march']
>              endif
>          else
> -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
> -                                'armv8.2-a', 'armv8.1-a', 'armv8-a']
>              check_compiler_support = false
>              foreach supported_march: supported_marchs
>                  if supported_march == part_number_config['march']
> @@ -733,6 +734,16 @@ if update_flags
>          endif
>
>          if candidate_march != part_number_config['march']
> +            if part_number_config.has_key('fallback_march') and not support_mcpu
> +                fallback_march = part_number_config['fallback_march']
> +                foreach supported_march: supported_marchs
> +                    if (supported_march == fallback_march
> +                        and cc.has_argument('-march=' + supported_march))
> +                        candidate_march = supported_march
> +                        break
> +                    endif
> +                endforeach
> +            endif
>              warning('Configuration march version is @0@, not supported.'
>                      .format(part_number_config['march']))
>              if candidate_march != ''
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march conflicts
  2024-01-22 10:55 ` Juraj Linkeš
@ 2024-01-22 11:54   ` Pavan Nikhilesh Bhagavatula
  2024-01-22 16:26     ` Juraj Linkeš
  0 siblings, 1 reply; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-01-22 11:54 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: Jerin Jacob, Ruifeng.Wang, nd, Bruce Richardson, dev

> On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com> wrote:
> >
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > The compiler options march and mtune are a subset
> > of mcpu and will lead to conflicts if improper march
> > is chosen for a given mcpu.
> > To avoid conflicts, force part number march when
> > mcpu is available and is supported by the compiler.
> >
> > Example:
> >         march = armv9-a
> >         mcpu = neoverse-n2
> >
> >         mcpu supported, march supported
> >         machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> >
> >         mcpu supported, march not supported
> >         machine_args = ['-mcpu=neoverse-n2']
> >
> >         mcpu not supported, march supported
> >         machine_args = ['-march=armv9-a']
> >
> >         mcpu not supported, march not supported
> >         machine_args = ['-march=armv8.6-a']
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> >  config/arm/meson.build | 109 +++++++++++++++++++++++++--------------
> --
> >  1 file changed, 67 insertions(+), 42 deletions(-)
> >
> > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > index 36f21d2259..8c8cfccca0 100644
> > --- a/config/arm/meson.build
> > +++ b/config/arm/meson.build
> <snip>
> > @@ -127,21 +128,22 @@ implementer_cavium = {
> >      ],
> >      'part_number_config': {
> >          '0xa1': {
> > -            'compiler_options': ['-mcpu=thunderxt88'],
> > +            'mcpu': 'thunderxt88',
> >              'flags': flags_part_number_thunderx
> >          },
> >          '0xa2': {
> > -            'compiler_options': ['-mcpu=thunderxt81'],
> > +            'mcpu': 'thunderxt81',
> >              'flags': flags_part_number_thunderx
> >          },
> >          '0xa3': {
> > -            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
> > +            'mcpu': 'thunderxt83',
> > +            'compiler_options': ['-march=armv8-a+crc'],
> 
> Let's unify this with the rest and specify 'march': 'armv8-a+crc'
> instead of having it under compiler_options.

Ack.

> 
> >              'flags': flags_part_number_thunderx
> >          },
> >          '0xaf': {
> >              'march': 'armv8.1-a',
> >              'march_features': ['crc', 'crypto'],
> > -            'compiler_options': ['-mcpu=thunderx2t99'],
> > +            'mcpu': 'thunderx2t99',
> >              'flags': [
> >                  ['RTE_MACHINE', '"thunderx2"'],
> >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > @@ -153,7 +155,7 @@ implementer_cavium = {
> >          '0xb2': {
> >              'march': 'armv8.2-a',
> >              'march_features': ['crc', 'crypto', 'lse'],
> > -            'compiler_options': ['-mcpu=octeontx2'],
> > +            'mcpu': 'octeontx2',
> >              'flags': [
> >                  ['RTE_MACHINE', '"cn9k"'],
> >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > @@ -176,7 +178,7 @@ implementer_ampere = {
> >          '0x0': {
> >              'march': 'armv8-a',
> >              'march_features': ['crc', 'crypto'],
> > -            'compiler_options':  ['-mtune=emag'],
> > +            'mcpu': 'emag',
> 
> We're changing mtune to mcpu, is this equivalent?
> 

Both march and mtune are a subset of mcpu.

> >              'flags': [
> >                  ['RTE_MACHINE', '"eMAG"'],
> >                  ['RTE_MAX_LCORE', 32],
> > @@ -186,7 +188,7 @@ implementer_ampere = {
> >          '0xac3': {
> >              'march': 'armv8.6-a',
> >              'march_features': ['crc', 'crypto'],
> > -            'compiler_options':  ['-mcpu=ampere1'],
> > +            'mcpu': 'ampere1',
> >              'flags': [
> >                  ['RTE_MACHINE', '"AmpereOne"'],
> >                  ['RTE_MAX_LCORE', 320],
> > @@ -206,7 +208,7 @@ implementer_hisilicon = {
> >          '0xd01': {
> >              'march': 'armv8.2-a',
> >              'march_features': ['crypto'],
> > -            'compiler_options': ['-mtune=tsv110'],
> > +            'mcpu': 'tsv110',
> >              'flags': [
> >                  ['RTE_MACHINE', '"Kunpeng 920"'],
> >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > @@ -695,11 +697,23 @@ if update_flags
> >
> >      machine_args = [] # Clear previous machine args
> >
> > +    candidate_mcpu = ''
> > +    support_mcpu = false
> > +    if part_number_config.has_key('mcpu')
> > +        mcpu = part_number_config['mcpu']
> > +        if (cc.has_argument('-mcpu=' + mcpu))
> > +            candidate_mcpu = mcpu
> > +            support_mcpu = true
> > +        endif
> > +    endif
> > +
> >      # probe supported archs and their features
> >      candidate_march = ''
> >      if part_number_config.has_key('march')
> > -        if part_number_config.get('force_march', false)
> > -            candidate_march = part_number_config['march']
> > +        if part_number_config.get('force_march', false) or support_mcpu
> 
> Instead of using the extra "support_mcpu" variable, we could do the
> same check as with candidate march (if candidate_mcpu != '', which we
> actually do below in the last lines of the patch).
> 

Ack.

> If I understand the logic correctly, we don't want to do the march
> fallback if mcpu is specified - either the march works with the given
> mcpu or we do without it (because we don't actually need it with
> mcpu). Is that correct?
> 

Yes, but still exact march defined in part_number_config should be present for setting extra_march_features.
specially for expressing crypto support. 

> > +            if cc.has_argument('-march=' +  part_number_config['march'])
> 
> Now that we've added mcpu into the mix, is this still the right
> condition? Can the below happen?
> 
> This check finds that machine_args = ['-march=armv9-a'] is supported.
> 
> But taken together with mcpu (machine_args = ['-mcpu=neoverse-n2',
> '-march=armv9-a']), it is not supported? In this case we'll end up
> with invalid configuration.

This is the only correct option and evolves into -march=armv9-a+sve2+crypto for cn10k
whereas other neoverse-n2 might only have -march=armv9-a+sve2.

Example:

Good:
#aarch64-linux-gnu-gcc  -march=armv9-a+sve2+crypto -mcpu=neoverse-n2 shrn.c
#aarch64-linux-gnu-gcc  -march=armv9-a+sve2 -mcpu=neoverse-n2 shrn.c 
#aarch64-linux-gnu-gcc  -march=armv9-a -mcpu=neoverse-n2 shrn.c

Bad:
#aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8-a shrn.c 
cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8-a' switch
#aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.1-a shrn.c
cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.1-a' switch
#aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.2-a shrn.c
cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.2-a' switch
#aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.3-a shrn.c
cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.3-a' switch
#aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.4-a shrn.c     
cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.4-a' switch
#aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.5-a shrn.c
cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.5-a' switch
#aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.6-a' switch
#aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.7-a shrn.c
cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.7-a' switch

> 
> > +                candidate_march = part_number_config['march']
> > +            endif
> >          else
> >              supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-
> a',
> >                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']

^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [EXT] Re: [PATCH 2/2] config/arm: add support for fallback march
  2024-01-22 11:04   ` Juraj Linkeš
@ 2024-01-22 12:16     ` Pavan Nikhilesh Bhagavatula
  2024-01-22 16:29       ` Juraj Linkeš
  0 siblings, 1 reply; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-01-22 12:16 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: Jerin Jacob, Ruifeng.Wang, nd, Bruce Richardson, dev

> On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com> wrote:
> >
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > Some ARM CPUs have specific march requirements and
> > are not compatible with the supported march list.
> > Add fallback march in case the mcpu and the march
> > advertised in the part_number_config are not supported
> > by the compiler.
> >
> 
> It's not clear to me what this patch adds. We already have a fallback
> mechanism and this basically does the same thing, but there's some
> extra logic that's not clear to me. Looks like there are some extra
> conditions around mcpu. In that case, all of the mcpu/march processing
> should be done first and then we should do a common fallback.
> 

The current fallback does a simple reverse compatibility check with the compiler
when force march is not enabled. 
But this is not true for neoverse-n2 case, as it is based on armv9-a which is a super set of 
armv8.5-a and other features[1]
In the current fallback path if both march neoverse-n2 and mcpu armv9-a are not supported
then it would fallback to armv8.6-a but this not correct as neoverse-n2 is not based on armv8.5-a

The fallback march armv8.5-a kicks in (if supported) when neoverse-n2 and armv9-a are not supported.


[1] https://github.com/gcc-mirror/gcc/blob/615e25c82de97acc17ab438f88d6788cf7ffe1d6/gcc/config/arm/arm-cpus.in#L306
 

> > Example
> >         mcpu = neoverse-n2
> >         march = armv9-a
> >         fallback_march = armv8.5-a
> >
> >         mcpu, march not supported
> >         machine_args = ['-march=armv8.5-a']
> >
> >         mcpu, march, fallback_march not supported
> >         least march supported = armv8-a
> >
> >         machine_args = ['-march=armv8-a']
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> >  config/arm/meson.build | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > index 8c8cfccca0..2aaf78a81a 100644
> > --- a/config/arm/meson.build
> > +++ b/config/arm/meson.build
> > @@ -94,6 +94,7 @@ part_number_config_arm = {
> >      '0xd49': {
> >          'march': 'armv9-a',
> >          'march_features': ['sve2'],
> > +        'fallback_march': 'armv8.5-a',
> >          'mcpu': 'neoverse-n2',
> >          'flags': [
> >              ['RTE_MACHINE', '"neoverse-n2"'],
> > @@ -709,14 +710,14 @@ if update_flags
> >
> >      # probe supported archs and their features
> >      candidate_march = ''
> > +    supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> > +                        'armv8.3-a', 'armv8.2-a', 'armv8.1-a', 'armv8-a']
> >      if part_number_config.has_key('march')
> >          if part_number_config.get('force_march', false) or support_mcpu
> >              if cc.has_argument('-march=' +  part_number_config['march'])
> >                  candidate_march = part_number_config['march']
> >              endif
> >          else
> > -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-
> a',
> > -                                'armv8.2-a', 'armv8.1-a', 'armv8-a']
> >              check_compiler_support = false
> >              foreach supported_march: supported_marchs
> >                  if supported_march == part_number_config['march']
> > @@ -733,6 +734,16 @@ if update_flags
> >          endif
> >
> >          if candidate_march != part_number_config['march']
> > +            if part_number_config.has_key('fallback_march') and not
> support_mcpu
> > +                fallback_march = part_number_config['fallback_march']
> > +                foreach supported_march: supported_marchs
> > +                    if (supported_march == fallback_march
> > +                        and cc.has_argument('-march=' + supported_march))
> > +                        candidate_march = supported_march
> > +                        break
> > +                    endif
> > +                endforeach
> > +            endif
> >              warning('Configuration march version is @0@, not supported.'
> >                      .format(part_number_config['march']))
> >              if candidate_march != ''
> > --
> > 2.25.1
> >

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march conflicts
  2024-01-22 11:54   ` [EXT] " Pavan Nikhilesh Bhagavatula
@ 2024-01-22 16:26     ` Juraj Linkeš
  2024-01-24 15:21       ` Pavan Nikhilesh Bhagavatula
  0 siblings, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-01-22 16:26 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula
  Cc: Jerin Jacob, Ruifeng.Wang, nd, Bruce Richardson, dev

On Mon, Jan 22, 2024 at 12:54 PM Pavan Nikhilesh Bhagavatula
<pbhagavatula@marvell.com> wrote:
>
> > On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com> wrote:
> > >
> > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > >
> > > The compiler options march and mtune are a subset
> > > of mcpu and will lead to conflicts if improper march
> > > is chosen for a given mcpu.
> > > To avoid conflicts, force part number march when
> > > mcpu is available and is supported by the compiler.
> > >
> > > Example:
> > >         march = armv9-a
> > >         mcpu = neoverse-n2
> > >
> > >         mcpu supported, march supported
> > >         machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> > >
> > >         mcpu supported, march not supported
> > >         machine_args = ['-mcpu=neoverse-n2']
> > >
> > >         mcpu not supported, march supported
> > >         machine_args = ['-march=armv9-a']
> > >
> > >         mcpu not supported, march not supported
> > >         machine_args = ['-march=armv8.6-a']
> > >
> > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > ---
> > >  config/arm/meson.build | 109 +++++++++++++++++++++++++--------------
> > --
> > >  1 file changed, 67 insertions(+), 42 deletions(-)
> > >
> > > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > index 36f21d2259..8c8cfccca0 100644
> > > --- a/config/arm/meson.build
> > > +++ b/config/arm/meson.build
> > <snip>
> > > @@ -127,21 +128,22 @@ implementer_cavium = {
> > >      ],
> > >      'part_number_config': {
> > >          '0xa1': {
> > > -            'compiler_options': ['-mcpu=thunderxt88'],
> > > +            'mcpu': 'thunderxt88',
> > >              'flags': flags_part_number_thunderx
> > >          },
> > >          '0xa2': {
> > > -            'compiler_options': ['-mcpu=thunderxt81'],
> > > +            'mcpu': 'thunderxt81',
> > >              'flags': flags_part_number_thunderx
> > >          },
> > >          '0xa3': {
> > > -            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
> > > +            'mcpu': 'thunderxt83',
> > > +            'compiler_options': ['-march=armv8-a+crc'],
> >
> > Let's unify this with the rest and specify 'march': 'armv8-a+crc'
> > instead of having it under compiler_options.
>
> Ack.
>
> >
> > >              'flags': flags_part_number_thunderx
> > >          },
> > >          '0xaf': {
> > >              'march': 'armv8.1-a',
> > >              'march_features': ['crc', 'crypto'],
> > > -            'compiler_options': ['-mcpu=thunderx2t99'],
> > > +            'mcpu': 'thunderx2t99',
> > >              'flags': [
> > >                  ['RTE_MACHINE', '"thunderx2"'],
> > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > @@ -153,7 +155,7 @@ implementer_cavium = {
> > >          '0xb2': {
> > >              'march': 'armv8.2-a',
> > >              'march_features': ['crc', 'crypto', 'lse'],
> > > -            'compiler_options': ['-mcpu=octeontx2'],
> > > +            'mcpu': 'octeontx2',
> > >              'flags': [
> > >                  ['RTE_MACHINE', '"cn9k"'],
> > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > @@ -176,7 +178,7 @@ implementer_ampere = {
> > >          '0x0': {
> > >              'march': 'armv8-a',
> > >              'march_features': ['crc', 'crypto'],
> > > -            'compiler_options':  ['-mtune=emag'],
> > > +            'mcpu': 'emag',
> >
> > We're changing mtune to mcpu, is this equivalent?
> >
>
> Both march and mtune are a subset of mcpu.
>

Sure, but we replaced '-mtune=emag' with '-mcpu=emag'. Are these two
builds going to be different or the same?

> > >              'flags': [
> > >                  ['RTE_MACHINE', '"eMAG"'],
> > >                  ['RTE_MAX_LCORE', 32],
> > > @@ -186,7 +188,7 @@ implementer_ampere = {
> > >          '0xac3': {
> > >              'march': 'armv8.6-a',
> > >              'march_features': ['crc', 'crypto'],
> > > -            'compiler_options':  ['-mcpu=ampere1'],
> > > +            'mcpu': 'ampere1',
> > >              'flags': [
> > >                  ['RTE_MACHINE', '"AmpereOne"'],
> > >                  ['RTE_MAX_LCORE', 320],
> > > @@ -206,7 +208,7 @@ implementer_hisilicon = {
> > >          '0xd01': {
> > >              'march': 'armv8.2-a',
> > >              'march_features': ['crypto'],
> > > -            'compiler_options': ['-mtune=tsv110'],
> > > +            'mcpu': 'tsv110',
> > >              'flags': [
> > >                  ['RTE_MACHINE', '"Kunpeng 920"'],
> > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > @@ -695,11 +697,23 @@ if update_flags
> > >
> > >      machine_args = [] # Clear previous machine args
> > >
> > > +    candidate_mcpu = ''
> > > +    support_mcpu = false
> > > +    if part_number_config.has_key('mcpu')
> > > +        mcpu = part_number_config['mcpu']
> > > +        if (cc.has_argument('-mcpu=' + mcpu))
> > > +            candidate_mcpu = mcpu
> > > +            support_mcpu = true
> > > +        endif
> > > +    endif
> > > +
> > >      # probe supported archs and their features
> > >      candidate_march = ''
> > >      if part_number_config.has_key('march')
> > > -        if part_number_config.get('force_march', false)
> > > -            candidate_march = part_number_config['march']
> > > +        if part_number_config.get('force_march', false) or support_mcpu
> >
> > Instead of using the extra "support_mcpu" variable, we could do the
> > same check as with candidate march (if candidate_mcpu != '', which we
> > actually do below in the last lines of the patch).
> >
>
> Ack.
>
> > If I understand the logic correctly, we don't want to do the march
> > fallback if mcpu is specified - either the march works with the given
> > mcpu or we do without it (because we don't actually need it with
> > mcpu). Is that correct?
> >
>
> Yes, but still exact march defined in part_number_config should be present for setting extra_march_features.
> specially for expressing crypto support.
>

Ok, thanks.

> > > +            if cc.has_argument('-march=' +  part_number_config['march'])
> >
> > Now that we've added mcpu into the mix, is this still the right
> > condition? Can the below happen?
> >
> > This check finds that machine_args = ['-march=armv9-a'] is supported.
> >
> > But taken together with mcpu (machine_args = ['-mcpu=neoverse-n2',
> > '-march=armv9-a']), it is not supported? In this case we'll end up
> > with invalid configuration.
>
> This is the only correct option and evolves into -march=armv9-a+sve2+crypto for cn10k
> whereas other neoverse-n2 might only have -march=armv9-a+sve2.
>

Maybe I should rephrase my question a bit:

The correct options are ['-mcpu=neoverse-n2', '-march=armv9-a']. Is it
possible that the compiler will say:

['-mcpu=neoverse-n2', '-march=armv9-a'] is supported
['-mcpu=neoverse-n2'] is supported
['-march=armv9-a'] is not supported

So basically the question is are we risking that the compiler will say
it supports both options only when both are passed while also saying
it doesn't support one or both of them when checked alone. We've seen
this behavior with newer compilers in aarch32 builds
(-march=armv8-a+simd -mfpu=auto are supported when both are passed,
but -march=armv8-a is not supported alone), so I wanted to be sure.

> Example:
>
> Good:
> #aarch64-linux-gnu-gcc  -march=armv9-a+sve2+crypto -mcpu=neoverse-n2 shrn.c
> #aarch64-linux-gnu-gcc  -march=armv9-a+sve2 -mcpu=neoverse-n2 shrn.c
> #aarch64-linux-gnu-gcc  -march=armv9-a -mcpu=neoverse-n2 shrn.c
>
> Bad:
> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8-a shrn.c
> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8-a' switch
> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.1-a shrn.c
> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.1-a' switch
> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.2-a shrn.c
> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.2-a' switch
> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.3-a shrn.c
> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.3-a' switch
> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.4-a shrn.c
> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.4-a' switch
> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.5-a shrn.c
> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.5-a' switch
> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.6-a' switch
> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.7-a shrn.c
> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.7-a' switch
>
> >
> > > +                candidate_march = part_number_config['march']
> > > +            endif
> > >          else
> > >              supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-
> > a',
> > >                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [EXT] Re: [PATCH 2/2] config/arm: add support for fallback march
  2024-01-22 12:16     ` [EXT] " Pavan Nikhilesh Bhagavatula
@ 2024-01-22 16:29       ` Juraj Linkeš
  2024-01-24 15:25         ` Pavan Nikhilesh Bhagavatula
  0 siblings, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-01-22 16:29 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula
  Cc: Jerin Jacob, Ruifeng.Wang, nd, Bruce Richardson, dev

On Mon, Jan 22, 2024 at 1:16 PM Pavan Nikhilesh Bhagavatula
<pbhagavatula@marvell.com> wrote:
>
> > On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com> wrote:
> > >
> > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > >
> > > Some ARM CPUs have specific march requirements and
> > > are not compatible with the supported march list.
> > > Add fallback march in case the mcpu and the march
> > > advertised in the part_number_config are not supported
> > > by the compiler.
> > >
> >
> > It's not clear to me what this patch adds. We already have a fallback
> > mechanism and this basically does the same thing, but there's some
> > extra logic that's not clear to me. Looks like there are some extra
> > conditions around mcpu. In that case, all of the mcpu/march processing
> > should be done first and then we should do a common fallback.
> >
>
> The current fallback does a simple reverse compatibility check with the compiler
> when force march is not enabled.
> But this is not true for neoverse-n2 case, as it is based on armv9-a which is a super set of
> armv8.5-a and other features[1]
> In the current fallback path if both march neoverse-n2 and mcpu armv9-a are not supported
> then it would fallback to armv8.6-a but this not correct as neoverse-n2 is not based on armv8.5-a
>
> The fallback march armv8.5-a kicks in (if supported) when neoverse-n2 and armv9-a are not supported.
>

Can the two fallback mechanisms be combined? They seem very similar.

>
> [1] https://github.com/gcc-mirror/gcc/blob/615e25c82de97acc17ab438f88d6788cf7ffe1d6/gcc/config/arm/arm-cpus.in#L306
>
>
> > > Example
> > >         mcpu = neoverse-n2
> > >         march = armv9-a
> > >         fallback_march = armv8.5-a
> > >
> > >         mcpu, march not supported
> > >         machine_args = ['-march=armv8.5-a']
> > >
> > >         mcpu, march, fallback_march not supported
> > >         least march supported = armv8-a
> > >
> > >         machine_args = ['-march=armv8-a']
> > >
> > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > ---
> > >  config/arm/meson.build | 15 +++++++++++++--
> > >  1 file changed, 13 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > index 8c8cfccca0..2aaf78a81a 100644
> > > --- a/config/arm/meson.build
> > > +++ b/config/arm/meson.build
> > > @@ -94,6 +94,7 @@ part_number_config_arm = {
> > >      '0xd49': {
> > >          'march': 'armv9-a',
> > >          'march_features': ['sve2'],
> > > +        'fallback_march': 'armv8.5-a',
> > >          'mcpu': 'neoverse-n2',
> > >          'flags': [
> > >              ['RTE_MACHINE', '"neoverse-n2"'],
> > > @@ -709,14 +710,14 @@ if update_flags
> > >
> > >      # probe supported archs and their features
> > >      candidate_march = ''
> > > +    supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> > > +                        'armv8.3-a', 'armv8.2-a', 'armv8.1-a', 'armv8-a']
> > >      if part_number_config.has_key('march')
> > >          if part_number_config.get('force_march', false) or support_mcpu
> > >              if cc.has_argument('-march=' +  part_number_config['march'])
> > >                  candidate_march = part_number_config['march']
> > >              endif
> > >          else
> > > -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-
> > a',
> > > -                                'armv8.2-a', 'armv8.1-a', 'armv8-a']
> > >              check_compiler_support = false
> > >              foreach supported_march: supported_marchs
> > >                  if supported_march == part_number_config['march']
> > > @@ -733,6 +734,16 @@ if update_flags
> > >          endif
> > >
> > >          if candidate_march != part_number_config['march']
> > > +            if part_number_config.has_key('fallback_march') and not
> > support_mcpu
> > > +                fallback_march = part_number_config['fallback_march']
> > > +                foreach supported_march: supported_marchs
> > > +                    if (supported_march == fallback_march
> > > +                        and cc.has_argument('-march=' + supported_march))
> > > +                        candidate_march = supported_march
> > > +                        break
> > > +                    endif
> > > +                endforeach
> > > +            endif
> > >              warning('Configuration march version is @0@, not supported.'
> > >                      .format(part_number_config['march']))
> > >              if candidate_march != ''
> > > --
> > > 2.25.1
> > >

^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march conflicts
  2024-01-22 16:26     ` Juraj Linkeš
@ 2024-01-24 15:21       ` Pavan Nikhilesh Bhagavatula
  2024-01-29  8:44         ` Juraj Linkeš
  0 siblings, 1 reply; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-01-24 15:21 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: Jerin Jacob, Ruifeng.Wang, nd, Bruce Richardson, dev



> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Monday, January 22, 2024 9:57 PM
> To: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> Cc: Jerin Jacob <jerinj@marvell.com>; Ruifeng.Wang@arm.com;
> nd@arm.com; Bruce Richardson <bruce.richardson@intel.com>;
> dev@dpdk.org
> Subject: Re: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march
> conflicts
> 
> On Mon, Jan 22, 2024 at 12:54 PM Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com> wrote:
> >
> > > On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com> wrote:
> > > >
> > > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > >
> > > > The compiler options march and mtune are a subset
> > > > of mcpu and will lead to conflicts if improper march
> > > > is chosen for a given mcpu.
> > > > To avoid conflicts, force part number march when
> > > > mcpu is available and is supported by the compiler.
> > > >
> > > > Example:
> > > >         march = armv9-a
> > > >         mcpu = neoverse-n2
> > > >
> > > >         mcpu supported, march supported
> > > >         machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> > > >
> > > >         mcpu supported, march not supported
> > > >         machine_args = ['-mcpu=neoverse-n2']
> > > >
> > > >         mcpu not supported, march supported
> > > >         machine_args = ['-march=armv9-a']
> > > >
> > > >         mcpu not supported, march not supported
> > > >         machine_args = ['-march=armv8.6-a']
> > > >
> > > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > > ---
> > > >  config/arm/meson.build | 109 +++++++++++++++++++++++++---------
> -----
> > > --
> > > >  1 file changed, 67 insertions(+), 42 deletions(-)
> > > >
> > > > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > > index 36f21d2259..8c8cfccca0 100644
> > > > --- a/config/arm/meson.build
> > > > +++ b/config/arm/meson.build
> > > <snip>
> > > > @@ -127,21 +128,22 @@ implementer_cavium = {
> > > >      ],
> > > >      'part_number_config': {
> > > >          '0xa1': {
> > > > -            'compiler_options': ['-mcpu=thunderxt88'],
> > > > +            'mcpu': 'thunderxt88',
> > > >              'flags': flags_part_number_thunderx
> > > >          },
> > > >          '0xa2': {
> > > > -            'compiler_options': ['-mcpu=thunderxt81'],
> > > > +            'mcpu': 'thunderxt81',
> > > >              'flags': flags_part_number_thunderx
> > > >          },
> > > >          '0xa3': {
> > > > -            'compiler_options': ['-march=armv8-a+crc', '-
> mcpu=thunderxt83'],
> > > > +            'mcpu': 'thunderxt83',
> > > > +            'compiler_options': ['-march=armv8-a+crc'],
> > >
> > > Let's unify this with the rest and specify 'march': 'armv8-a+crc'
> > > instead of having it under compiler_options.
> >
> > Ack.
> >
> > >
> > > >              'flags': flags_part_number_thunderx
> > > >          },
> > > >          '0xaf': {
> > > >              'march': 'armv8.1-a',
> > > >              'march_features': ['crc', 'crypto'],
> > > > -            'compiler_options': ['-mcpu=thunderx2t99'],
> > > > +            'mcpu': 'thunderx2t99',
> > > >              'flags': [
> > > >                  ['RTE_MACHINE', '"thunderx2"'],
> > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > @@ -153,7 +155,7 @@ implementer_cavium = {
> > > >          '0xb2': {
> > > >              'march': 'armv8.2-a',
> > > >              'march_features': ['crc', 'crypto', 'lse'],
> > > > -            'compiler_options': ['-mcpu=octeontx2'],
> > > > +            'mcpu': 'octeontx2',
> > > >              'flags': [
> > > >                  ['RTE_MACHINE', '"cn9k"'],
> > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > @@ -176,7 +178,7 @@ implementer_ampere = {
> > > >          '0x0': {
> > > >              'march': 'armv8-a',
> > > >              'march_features': ['crc', 'crypto'],
> > > > -            'compiler_options':  ['-mtune=emag'],
> > > > +            'mcpu': 'emag',
> > >
> > > We're changing mtune to mcpu, is this equivalent?
> > >
> >
> > Both march and mtune are a subset of mcpu.
> >
> 
> Sure, but we replaced '-mtune=emag' with '-mcpu=emag'. Are these two
> builds going to be different or the same?
> 

Yeah, I believe both are same.

> > > >              'flags': [
> > > >                  ['RTE_MACHINE', '"eMAG"'],
> > > >                  ['RTE_MAX_LCORE', 32],
> > > > @@ -186,7 +188,7 @@ implementer_ampere = {
> > > >          '0xac3': {
> > > >              'march': 'armv8.6-a',
> > > >              'march_features': ['crc', 'crypto'],
> > > > -            'compiler_options':  ['-mcpu=ampere1'],
> > > > +            'mcpu': 'ampere1',
> > > >              'flags': [
> > > >                  ['RTE_MACHINE', '"AmpereOne"'],
> > > >                  ['RTE_MAX_LCORE', 320],
> > > > @@ -206,7 +208,7 @@ implementer_hisilicon = {
> > > >          '0xd01': {
> > > >              'march': 'armv8.2-a',
> > > >              'march_features': ['crypto'],
> > > > -            'compiler_options': ['-mtune=tsv110'],
> > > > +            'mcpu': 'tsv110',
> > > >              'flags': [
> > > >                  ['RTE_MACHINE', '"Kunpeng 920"'],
> > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > @@ -695,11 +697,23 @@ if update_flags
> > > >
> > > >      machine_args = [] # Clear previous machine args
> > > >
> > > > +    candidate_mcpu = ''
> > > > +    support_mcpu = false
> > > > +    if part_number_config.has_key('mcpu')
> > > > +        mcpu = part_number_config['mcpu']
> > > > +        if (cc.has_argument('-mcpu=' + mcpu))
> > > > +            candidate_mcpu = mcpu
> > > > +            support_mcpu = true
> > > > +        endif
> > > > +    endif
> > > > +
> > > >      # probe supported archs and their features
> > > >      candidate_march = ''
> > > >      if part_number_config.has_key('march')
> > > > -        if part_number_config.get('force_march', false)
> > > > -            candidate_march = part_number_config['march']
> > > > +        if part_number_config.get('force_march', false) or support_mcpu
> > >
> > > Instead of using the extra "support_mcpu" variable, we could do the
> > > same check as with candidate march (if candidate_mcpu != '', which we
> > > actually do below in the last lines of the patch).
> > >
> >
> > Ack.
> >
> > > If I understand the logic correctly, we don't want to do the march
> > > fallback if mcpu is specified - either the march works with the given
> > > mcpu or we do without it (because we don't actually need it with
> > > mcpu). Is that correct?
> > >
> >
> > Yes, but still exact march defined in part_number_config should be present
> for setting extra_march_features.
> > specially for expressing crypto support.
> >
> 
> Ok, thanks.
> 
> > > > +            if cc.has_argument('-march=' +  part_number_config['march'])
> > >
> > > Now that we've added mcpu into the mix, is this still the right
> > > condition? Can the below happen?
> > >
> > > This check finds that machine_args = ['-march=armv9-a'] is supported.
> > >
> > > But taken together with mcpu (machine_args = ['-mcpu=neoverse-n2',
> > > '-march=armv9-a']), it is not supported? In this case we'll end up
> > > with invalid configuration.
> >
> > This is the only correct option and evolves into -march=armv9-
> a+sve2+crypto for cn10k
> > whereas other neoverse-n2 might only have -march=armv9-a+sve2.
> >
> 
> Maybe I should rephrase my question a bit:
> 
> The correct options are ['-mcpu=neoverse-n2', '-march=armv9-a']. Is it
> possible that the compiler will say:
> 
> ['-mcpu=neoverse-n2', '-march=armv9-a'] is supported
> ['-mcpu=neoverse-n2'] is supported
> ['-march=armv9-a'] is not supported
> 

Yes, this is possible.

> So basically the question is are we risking that the compiler will say
> it supports both options only when both are passed while also saying
> it doesn't support one or both of them when checked alone. We've seen
> this behavior with newer compilers in aarch32 builds
> (-march=armv8-a+simd -mfpu=auto are supported when both are passed,
> but -march=armv8-a is not supported alone), so I wanted to be sure.
> 
> > Example:
> >
> > Good:
> > #aarch64-linux-gnu-gcc  -march=armv9-a+sve2+crypto -mcpu=neoverse-n2
> shrn.c
> > #aarch64-linux-gnu-gcc  -march=armv9-a+sve2 -mcpu=neoverse-n2 shrn.c
> > #aarch64-linux-gnu-gcc  -march=armv9-a -mcpu=neoverse-n2 shrn.c
> >
> > Bad:
> > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8-a shrn.c
> > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8-a'
> switch
> > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.1-a shrn.c
> > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.1-a'
> switch
> > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.2-a shrn.c
> > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.2-a'
> switch
> > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.3-a shrn.c
> > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.3-a'
> switch
> > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.4-a shrn.c
> > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.4-a'
> switch
> > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.5-a shrn.c
> > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.5-a'
> switch
> > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
> > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.6-a'
> switch
> > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.7-a shrn.c
> > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.7-a'
> switch
> >
> > >
> > > > +                candidate_march = part_number_config['march']
> > > > +            endif
> > > >          else
> > > >              supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> 'armv8.3-
> > > a',
> > > >                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']

^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [EXT] Re: [PATCH 2/2] config/arm: add support for fallback march
  2024-01-22 16:29       ` Juraj Linkeš
@ 2024-01-24 15:25         ` Pavan Nikhilesh Bhagavatula
  0 siblings, 0 replies; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-01-24 15:25 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: Jerin Jacob, Ruifeng.Wang, nd, Bruce Richardson, dev



> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Monday, January 22, 2024 9:59 PM
> To: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> Cc: Jerin Jacob <jerinj@marvell.com>; Ruifeng.Wang@arm.com;
> nd@arm.com; Bruce Richardson <bruce.richardson@intel.com>;
> dev@dpdk.org
> Subject: Re: [EXT] Re: [PATCH 2/2] config/arm: add support for fallback march
> 
> On Mon, Jan 22, 2024 at 1:16 PM Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com> wrote:
> >
> > > On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com> wrote:
> > > >
> > > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > >
> > > > Some ARM CPUs have specific march requirements and
> > > > are not compatible with the supported march list.
> > > > Add fallback march in case the mcpu and the march
> > > > advertised in the part_number_config are not supported
> > > > by the compiler.
> > > >
> > >
> > > It's not clear to me what this patch adds. We already have a fallback
> > > mechanism and this basically does the same thing, but there's some
> > > extra logic that's not clear to me. Looks like there are some extra
> > > conditions around mcpu. In that case, all of the mcpu/march processing
> > > should be done first and then we should do a common fallback.
> > >
> >
> > The current fallback does a simple reverse compatibility check with the
> compiler
> > when force march is not enabled.
> > But this is not true for neoverse-n2 case, as it is based on armv9-a which is a
> super set of
> > armv8.5-a and other features[1]
> > In the current fallback path if both march neoverse-n2 and mcpu armv9-a
> are not supported
> > then it would fallback to armv8.6-a but this not correct as neoverse-n2 is
> not based on armv8.5-a
> >
> > The fallback march armv8.5-a kicks in (if supported) when neoverse-n2 and
> armv9-a are not supported.
> >
> 
> Can the two fallback mechanisms be combined? They seem very similar.

I will try to combine them in the next version.

Thanks,
Pavan.

> 
> >
> > [1] https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__github.com_gcc-
> 2Dmirror_gcc_blob_615e25c82de97acc17ab438f88d6788cf7ffe1d6_gcc_confi
> g_arm_arm-2Dcpus.in-
> 23L306&d=DwIFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=E3SgYMjtKCMVsB-
> fmvgGV3o-g_fjLhk5Pupi9ijohpc&m=-
> Xknjo5NapybFKTREn10YXl4HKVFwvwF7ZNL_2ks7_DxKC9Xynna3Ms2DLynVO
> Fh&s=o_Pt0fUjpeoar7QSgqshIXDxOZVUSNQYcCtRJWhNS8I&e=
> >
> >
> > > > Example
> > > >         mcpu = neoverse-n2
> > > >         march = armv9-a
> > > >         fallback_march = armv8.5-a
> > > >
> > > >         mcpu, march not supported
> > > >         machine_args = ['-march=armv8.5-a']
> > > >
> > > >         mcpu, march, fallback_march not supported
> > > >         least march supported = armv8-a
> > > >
> > > >         machine_args = ['-march=armv8-a']
> > > >
> > > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > > ---
> > > >  config/arm/meson.build | 15 +++++++++++++--
> > > >  1 file changed, 13 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > > index 8c8cfccca0..2aaf78a81a 100644
> > > > --- a/config/arm/meson.build
> > > > +++ b/config/arm/meson.build
> > > > @@ -94,6 +94,7 @@ part_number_config_arm = {
> > > >      '0xd49': {
> > > >          'march': 'armv9-a',
> > > >          'march_features': ['sve2'],
> > > > +        'fallback_march': 'armv8.5-a',
> > > >          'mcpu': 'neoverse-n2',
> > > >          'flags': [
> > > >              ['RTE_MACHINE', '"neoverse-n2"'],
> > > > @@ -709,14 +710,14 @@ if update_flags
> > > >
> > > >      # probe supported archs and their features
> > > >      candidate_march = ''
> > > > +    supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> > > > +                        'armv8.3-a', 'armv8.2-a', 'armv8.1-a', 'armv8-a']
> > > >      if part_number_config.has_key('march')
> > > >          if part_number_config.get('force_march', false) or support_mcpu
> > > >              if cc.has_argument('-march=' +  part_number_config['march'])
> > > >                  candidate_march = part_number_config['march']
> > > >              endif
> > > >          else
> > > > -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> 'armv8.3-
> > > a',
> > > > -                                'armv8.2-a', 'armv8.1-a', 'armv8-a']
> > > >              check_compiler_support = false
> > > >              foreach supported_march: supported_marchs
> > > >                  if supported_march == part_number_config['march']
> > > > @@ -733,6 +734,16 @@ if update_flags
> > > >          endif
> > > >
> > > >          if candidate_march != part_number_config['march']
> > > > +            if part_number_config.has_key('fallback_march') and not
> > > support_mcpu
> > > > +                fallback_march = part_number_config['fallback_march']
> > > > +                foreach supported_march: supported_marchs
> > > > +                    if (supported_march == fallback_march
> > > > +                        and cc.has_argument('-march=' + supported_march))
> > > > +                        candidate_march = supported_march
> > > > +                        break
> > > > +                    endif
> > > > +                endforeach
> > > > +            endif
> > > >              warning('Configuration march version is @0@, not supported.'
> > > >                      .format(part_number_config['march']))
> > > >              if candidate_march != ''
> > > > --
> > > > 2.25.1
> > > >

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march conflicts
  2024-01-24 15:21       ` Pavan Nikhilesh Bhagavatula
@ 2024-01-29  8:44         ` Juraj Linkeš
  2024-01-30 16:16           ` Pavan Nikhilesh Bhagavatula
  0 siblings, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-01-29  8:44 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula
  Cc: Jerin Jacob, Ruifeng.Wang, nd, Bruce Richardson, dev

On Wed, Jan 24, 2024 at 4:22 PM Pavan Nikhilesh Bhagavatula
<pbhagavatula@marvell.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Sent: Monday, January 22, 2024 9:57 PM
> > To: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> > Cc: Jerin Jacob <jerinj@marvell.com>; Ruifeng.Wang@arm.com;
> > nd@arm.com; Bruce Richardson <bruce.richardson@intel.com>;
> > dev@dpdk.org
> > Subject: Re: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march
> > conflicts
> >
> > On Mon, Jan 22, 2024 at 12:54 PM Pavan Nikhilesh Bhagavatula
> > <pbhagavatula@marvell.com> wrote:
> > >
> > > > On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com> wrote:
> > > > >
> > > > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > > >
> > > > > The compiler options march and mtune are a subset
> > > > > of mcpu and will lead to conflicts if improper march
> > > > > is chosen for a given mcpu.
> > > > > To avoid conflicts, force part number march when
> > > > > mcpu is available and is supported by the compiler.
> > > > >
> > > > > Example:
> > > > >         march = armv9-a
> > > > >         mcpu = neoverse-n2
> > > > >
> > > > >         mcpu supported, march supported
> > > > >         machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> > > > >
> > > > >         mcpu supported, march not supported
> > > > >         machine_args = ['-mcpu=neoverse-n2']
> > > > >
> > > > >         mcpu not supported, march supported
> > > > >         machine_args = ['-march=armv9-a']
> > > > >
> > > > >         mcpu not supported, march not supported
> > > > >         machine_args = ['-march=armv8.6-a']
> > > > >
> > > > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > > > ---
> > > > >  config/arm/meson.build | 109 +++++++++++++++++++++++++---------
> > -----
> > > > --
> > > > >  1 file changed, 67 insertions(+), 42 deletions(-)
> > > > >
> > > > > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > > > index 36f21d2259..8c8cfccca0 100644
> > > > > --- a/config/arm/meson.build
> > > > > +++ b/config/arm/meson.build
> > > > <snip>
> > > > > @@ -127,21 +128,22 @@ implementer_cavium = {
> > > > >      ],
> > > > >      'part_number_config': {
> > > > >          '0xa1': {
> > > > > -            'compiler_options': ['-mcpu=thunderxt88'],
> > > > > +            'mcpu': 'thunderxt88',
> > > > >              'flags': flags_part_number_thunderx
> > > > >          },
> > > > >          '0xa2': {
> > > > > -            'compiler_options': ['-mcpu=thunderxt81'],
> > > > > +            'mcpu': 'thunderxt81',
> > > > >              'flags': flags_part_number_thunderx
> > > > >          },
> > > > >          '0xa3': {
> > > > > -            'compiler_options': ['-march=armv8-a+crc', '-
> > mcpu=thunderxt83'],
> > > > > +            'mcpu': 'thunderxt83',
> > > > > +            'compiler_options': ['-march=armv8-a+crc'],
> > > >
> > > > Let's unify this with the rest and specify 'march': 'armv8-a+crc'
> > > > instead of having it under compiler_options.
> > >
> > > Ack.
> > >
> > > >
> > > > >              'flags': flags_part_number_thunderx
> > > > >          },
> > > > >          '0xaf': {
> > > > >              'march': 'armv8.1-a',
> > > > >              'march_features': ['crc', 'crypto'],
> > > > > -            'compiler_options': ['-mcpu=thunderx2t99'],
> > > > > +            'mcpu': 'thunderx2t99',
> > > > >              'flags': [
> > > > >                  ['RTE_MACHINE', '"thunderx2"'],
> > > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > > @@ -153,7 +155,7 @@ implementer_cavium = {
> > > > >          '0xb2': {
> > > > >              'march': 'armv8.2-a',
> > > > >              'march_features': ['crc', 'crypto', 'lse'],
> > > > > -            'compiler_options': ['-mcpu=octeontx2'],
> > > > > +            'mcpu': 'octeontx2',
> > > > >              'flags': [
> > > > >                  ['RTE_MACHINE', '"cn9k"'],
> > > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > > @@ -176,7 +178,7 @@ implementer_ampere = {
> > > > >          '0x0': {
> > > > >              'march': 'armv8-a',
> > > > >              'march_features': ['crc', 'crypto'],
> > > > > -            'compiler_options':  ['-mtune=emag'],
> > > > > +            'mcpu': 'emag',
> > > >
> > > > We're changing mtune to mcpu, is this equivalent?
> > > >
> > >
> > > Both march and mtune are a subset of mcpu.
> > >
> >
> > Sure, but we replaced '-mtune=emag' with '-mcpu=emag'. Are these two
> > builds going to be different or the same?
> >
>
> Yeah, I believe both are same.
>

Ok, the change is fine then.

> > > > >              'flags': [
> > > > >                  ['RTE_MACHINE', '"eMAG"'],
> > > > >                  ['RTE_MAX_LCORE', 32],
> > > > > @@ -186,7 +188,7 @@ implementer_ampere = {
> > > > >          '0xac3': {
> > > > >              'march': 'armv8.6-a',
> > > > >              'march_features': ['crc', 'crypto'],
> > > > > -            'compiler_options':  ['-mcpu=ampere1'],
> > > > > +            'mcpu': 'ampere1',
> > > > >              'flags': [
> > > > >                  ['RTE_MACHINE', '"AmpereOne"'],
> > > > >                  ['RTE_MAX_LCORE', 320],
> > > > > @@ -206,7 +208,7 @@ implementer_hisilicon = {
> > > > >          '0xd01': {
> > > > >              'march': 'armv8.2-a',
> > > > >              'march_features': ['crypto'],
> > > > > -            'compiler_options': ['-mtune=tsv110'],
> > > > > +            'mcpu': 'tsv110',
> > > > >              'flags': [
> > > > >                  ['RTE_MACHINE', '"Kunpeng 920"'],
> > > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > > @@ -695,11 +697,23 @@ if update_flags
> > > > >
> > > > >      machine_args = [] # Clear previous machine args
> > > > >
> > > > > +    candidate_mcpu = ''
> > > > > +    support_mcpu = false
> > > > > +    if part_number_config.has_key('mcpu')
> > > > > +        mcpu = part_number_config['mcpu']
> > > > > +        if (cc.has_argument('-mcpu=' + mcpu))
> > > > > +            candidate_mcpu = mcpu
> > > > > +            support_mcpu = true
> > > > > +        endif
> > > > > +    endif
> > > > > +
> > > > >      # probe supported archs and their features
> > > > >      candidate_march = ''
> > > > >      if part_number_config.has_key('march')
> > > > > -        if part_number_config.get('force_march', false)
> > > > > -            candidate_march = part_number_config['march']
> > > > > +        if part_number_config.get('force_march', false) or support_mcpu
> > > >
> > > > Instead of using the extra "support_mcpu" variable, we could do the
> > > > same check as with candidate march (if candidate_mcpu != '', which we
> > > > actually do below in the last lines of the patch).
> > > >
> > >
> > > Ack.
> > >
> > > > If I understand the logic correctly, we don't want to do the march
> > > > fallback if mcpu is specified - either the march works with the given
> > > > mcpu or we do without it (because we don't actually need it with
> > > > mcpu). Is that correct?
> > > >
> > >
> > > Yes, but still exact march defined in part_number_config should be present
> > for setting extra_march_features.
> > > specially for expressing crypto support.
> > >
> >
> > Ok, thanks.
> >
> > > > > +            if cc.has_argument('-march=' +  part_number_config['march'])
> > > >
> > > > Now that we've added mcpu into the mix, is this still the right
> > > > condition? Can the below happen?
> > > >
> > > > This check finds that machine_args = ['-march=armv9-a'] is supported.
> > > >
> > > > But taken together with mcpu (machine_args = ['-mcpu=neoverse-n2',
> > > > '-march=armv9-a']), it is not supported? In this case we'll end up
> > > > with invalid configuration.
> > >
> > > This is the only correct option and evolves into -march=armv9-
> > a+sve2+crypto for cn10k
> > > whereas other neoverse-n2 might only have -march=armv9-a+sve2.
> > >
> >
> > Maybe I should rephrase my question a bit:
> >
> > The correct options are ['-mcpu=neoverse-n2', '-march=armv9-a']. Is it
> > possible that the compiler will say:
> >
> > ['-mcpu=neoverse-n2', '-march=armv9-a'] is supported
> > ['-mcpu=neoverse-n2'] is supported
> > ['-march=armv9-a'] is not supported
> >
>
> Yes, this is possible.
>

Ok, do we want to make sure it's possible to configure the options in
this way? But maybe that's out of scope of this patch.

> > So basically the question is are we risking that the compiler will say
> > it supports both options only when both are passed while also saying
> > it doesn't support one or both of them when checked alone. We've seen
> > this behavior with newer compilers in aarch32 builds
> > (-march=armv8-a+simd -mfpu=auto are supported when both are passed,
> > but -march=armv8-a is not supported alone), so I wanted to be sure.
> >
> > > Example:
> > >
> > > Good:
> > > #aarch64-linux-gnu-gcc  -march=armv9-a+sve2+crypto -mcpu=neoverse-n2
> > shrn.c
> > > #aarch64-linux-gnu-gcc  -march=armv9-a+sve2 -mcpu=neoverse-n2 shrn.c
> > > #aarch64-linux-gnu-gcc  -march=armv9-a -mcpu=neoverse-n2 shrn.c
> > >
> > > Bad:
> > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8-a shrn.c
> > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8-a'
> > switch
> > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.1-a shrn.c
> > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.1-a'
> > switch
> > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.2-a shrn.c
> > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.2-a'
> > switch
> > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.3-a shrn.c
> > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.3-a'
> > switch
> > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.4-a shrn.c
> > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.4-a'
> > switch
> > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.5-a shrn.c
> > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.5-a'
> > switch
> > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
> > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.6-a'
> > switch
> > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.7-a shrn.c
> > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.7-a'
> > switch
> > >
> > > >
> > > > > +                candidate_march = part_number_config['march']
> > > > > +            endif
> > > > >          else
> > > > >              supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> > 'armv8.3-
> > > > a',
> > > > >                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']

^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march conflicts
  2024-01-29  8:44         ` Juraj Linkeš
@ 2024-01-30 16:16           ` Pavan Nikhilesh Bhagavatula
  2024-01-31  9:03             ` Juraj Linkeš
  0 siblings, 1 reply; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-01-30 16:16 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: Jerin Jacob, Ruifeng.Wang, nd, Bruce Richardson, dev



> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Monday, January 29, 2024 2:15 PM
> To: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> Cc: Jerin Jacob <jerinj@marvell.com>; Ruifeng.Wang@arm.com;
> nd@arm.com; Bruce Richardson <bruce.richardson@intel.com>;
> dev@dpdk.org
> Subject: Re: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march
> conflicts
> 
> On Wed, Jan 24, 2024 at 4:22 PM Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com> wrote:
> >
> >
> >
> > > -----Original Message-----
> > > From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > Sent: Monday, January 22, 2024 9:57 PM
> > > To: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> > > Cc: Jerin Jacob <jerinj@marvell.com>; Ruifeng.Wang@arm.com;
> > > nd@arm.com; Bruce Richardson <bruce.richardson@intel.com>;
> > > dev@dpdk.org
> > > Subject: Re: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march
> > > conflicts
> > >
> > > On Mon, Jan 22, 2024 at 12:54 PM Pavan Nikhilesh Bhagavatula
> > > <pbhagavatula@marvell.com> wrote:
> > > >
> > > > > On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com>
> wrote:
> > > > > >
> > > > > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > > > >
> > > > > > The compiler options march and mtune are a subset
> > > > > > of mcpu and will lead to conflicts if improper march
> > > > > > is chosen for a given mcpu.
> > > > > > To avoid conflicts, force part number march when
> > > > > > mcpu is available and is supported by the compiler.
> > > > > >
> > > > > > Example:
> > > > > >         march = armv9-a
> > > > > >         mcpu = neoverse-n2
> > > > > >
> > > > > >         mcpu supported, march supported
> > > > > >         machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> > > > > >
> > > > > >         mcpu supported, march not supported
> > > > > >         machine_args = ['-mcpu=neoverse-n2']
> > > > > >
> > > > > >         mcpu not supported, march supported
> > > > > >         machine_args = ['-march=armv9-a']
> > > > > >
> > > > > >         mcpu not supported, march not supported
> > > > > >         machine_args = ['-march=armv8.6-a']
> > > > > >
> > > > > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > > > > ---
> > > > > >  config/arm/meson.build | 109 +++++++++++++++++++++++++-----
> ----
> > > -----
> > > > > --
> > > > > >  1 file changed, 67 insertions(+), 42 deletions(-)
> > > > > >
> > > > > > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > > > > index 36f21d2259..8c8cfccca0 100644
> > > > > > --- a/config/arm/meson.build
> > > > > > +++ b/config/arm/meson.build
> > > > > <snip>
> > > > > > @@ -127,21 +128,22 @@ implementer_cavium = {
> > > > > >      ],
> > > > > >      'part_number_config': {
> > > > > >          '0xa1': {
> > > > > > -            'compiler_options': ['-mcpu=thunderxt88'],
> > > > > > +            'mcpu': 'thunderxt88',
> > > > > >              'flags': flags_part_number_thunderx
> > > > > >          },
> > > > > >          '0xa2': {
> > > > > > -            'compiler_options': ['-mcpu=thunderxt81'],
> > > > > > +            'mcpu': 'thunderxt81',
> > > > > >              'flags': flags_part_number_thunderx
> > > > > >          },
> > > > > >          '0xa3': {
> > > > > > -            'compiler_options': ['-march=armv8-a+crc', '-
> > > mcpu=thunderxt83'],
> > > > > > +            'mcpu': 'thunderxt83',
> > > > > > +            'compiler_options': ['-march=armv8-a+crc'],
> > > > >
> > > > > Let's unify this with the rest and specify 'march': 'armv8-a+crc'
> > > > > instead of having it under compiler_options.
> > > >
> > > > Ack.
> > > >
> > > > >
> > > > > >              'flags': flags_part_number_thunderx
> > > > > >          },
> > > > > >          '0xaf': {
> > > > > >              'march': 'armv8.1-a',
> > > > > >              'march_features': ['crc', 'crypto'],
> > > > > > -            'compiler_options': ['-mcpu=thunderx2t99'],
> > > > > > +            'mcpu': 'thunderx2t99',
> > > > > >              'flags': [
> > > > > >                  ['RTE_MACHINE', '"thunderx2"'],
> > > > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > > > @@ -153,7 +155,7 @@ implementer_cavium = {
> > > > > >          '0xb2': {
> > > > > >              'march': 'armv8.2-a',
> > > > > >              'march_features': ['crc', 'crypto', 'lse'],
> > > > > > -            'compiler_options': ['-mcpu=octeontx2'],
> > > > > > +            'mcpu': 'octeontx2',
> > > > > >              'flags': [
> > > > > >                  ['RTE_MACHINE', '"cn9k"'],
> > > > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > > > @@ -176,7 +178,7 @@ implementer_ampere = {
> > > > > >          '0x0': {
> > > > > >              'march': 'armv8-a',
> > > > > >              'march_features': ['crc', 'crypto'],
> > > > > > -            'compiler_options':  ['-mtune=emag'],
> > > > > > +            'mcpu': 'emag',
> > > > >
> > > > > We're changing mtune to mcpu, is this equivalent?
> > > > >
> > > >
> > > > Both march and mtune are a subset of mcpu.
> > > >
> > >
> > > Sure, but we replaced '-mtune=emag' with '-mcpu=emag'. Are these two
> > > builds going to be different or the same?
> > >
> >
> > Yeah, I believe both are same.
> >
> 
> Ok, the change is fine then.
> 
> > > > > >              'flags': [
> > > > > >                  ['RTE_MACHINE', '"eMAG"'],
> > > > > >                  ['RTE_MAX_LCORE', 32],
> > > > > > @@ -186,7 +188,7 @@ implementer_ampere = {
> > > > > >          '0xac3': {
> > > > > >              'march': 'armv8.6-a',
> > > > > >              'march_features': ['crc', 'crypto'],
> > > > > > -            'compiler_options':  ['-mcpu=ampere1'],
> > > > > > +            'mcpu': 'ampere1',
> > > > > >              'flags': [
> > > > > >                  ['RTE_MACHINE', '"AmpereOne"'],
> > > > > >                  ['RTE_MAX_LCORE', 320],
> > > > > > @@ -206,7 +208,7 @@ implementer_hisilicon = {
> > > > > >          '0xd01': {
> > > > > >              'march': 'armv8.2-a',
> > > > > >              'march_features': ['crypto'],
> > > > > > -            'compiler_options': ['-mtune=tsv110'],
> > > > > > +            'mcpu': 'tsv110',
> > > > > >              'flags': [
> > > > > >                  ['RTE_MACHINE', '"Kunpeng 920"'],
> > > > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > > > @@ -695,11 +697,23 @@ if update_flags
> > > > > >
> > > > > >      machine_args = [] # Clear previous machine args
> > > > > >
> > > > > > +    candidate_mcpu = ''
> > > > > > +    support_mcpu = false
> > > > > > +    if part_number_config.has_key('mcpu')
> > > > > > +        mcpu = part_number_config['mcpu']
> > > > > > +        if (cc.has_argument('-mcpu=' + mcpu))
> > > > > > +            candidate_mcpu = mcpu
> > > > > > +            support_mcpu = true
> > > > > > +        endif
> > > > > > +    endif
> > > > > > +
> > > > > >      # probe supported archs and their features
> > > > > >      candidate_march = ''
> > > > > >      if part_number_config.has_key('march')
> > > > > > -        if part_number_config.get('force_march', false)
> > > > > > -            candidate_march = part_number_config['march']
> > > > > > +        if part_number_config.get('force_march', false) or
> support_mcpu
> > > > >
> > > > > Instead of using the extra "support_mcpu" variable, we could do the
> > > > > same check as with candidate march (if candidate_mcpu != '', which we
> > > > > actually do below in the last lines of the patch).
> > > > >
> > > >
> > > > Ack.
> > > >
> > > > > If I understand the logic correctly, we don't want to do the march
> > > > > fallback if mcpu is specified - either the march works with the given
> > > > > mcpu or we do without it (because we don't actually need it with
> > > > > mcpu). Is that correct?
> > > > >
> > > >
> > > > Yes, but still exact march defined in part_number_config should be
> present
> > > for setting extra_march_features.
> > > > specially for expressing crypto support.
> > > >
> > >
> > > Ok, thanks.
> > >
> > > > > > +            if cc.has_argument('-march=' +  part_number_config['march'])
> > > > >
> > > > > Now that we've added mcpu into the mix, is this still the right
> > > > > condition? Can the below happen?
> > > > >
> > > > > This check finds that machine_args = ['-march=armv9-a'] is supported.
> > > > >
> > > > > But taken together with mcpu (machine_args = ['-mcpu=neoverse-n2',
> > > > > '-march=armv9-a']), it is not supported? In this case we'll end up
> > > > > with invalid configuration.
> > > >
> > > > This is the only correct option and evolves into -march=armv9-
> > > a+sve2+crypto for cn10k
> > > > whereas other neoverse-n2 might only have -march=armv9-a+sve2.
> > > >
> > >
> > > Maybe I should rephrase my question a bit:
> > >
> > > The correct options are ['-mcpu=neoverse-n2', '-march=armv9-a']. Is it
> > > possible that the compiler will say:
> > >
> > > ['-mcpu=neoverse-n2', '-march=armv9-a'] is supported
> > > ['-mcpu=neoverse-n2'] is supported
> > > ['-march=armv9-a'] is not supported
> > >
> >
> > Yes, this is possible.
> >
> 
> Ok, do we want to make sure it's possible to configure the options in
> this way? But maybe that's out of scope of this patch.
> 

This patch already handles those conditions, this is the case 2 mentioned in the example.

	march = armv9-a
	mcpu = neoverse-n2

	[1] mcpu supported, march supported
	machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']

	[2] mcpu supported, march not supported
	machine_args = ['-mcpu=neoverse-n2']

	[3] mcpu not supported, march supported
	machine_args = ['-march=armv9-a']

	[4] mcpu not supported, march not supported
	machine_args = ['-march=armv8.6-a']

> > > So basically the question is are we risking that the compiler will say
> > > it supports both options only when both are passed while also saying
> > > it doesn't support one or both of them when checked alone. We've seen
> > > this behavior with newer compilers in aarch32 builds
> > > (-march=armv8-a+simd -mfpu=auto are supported when both are passed,
> > > but -march=armv8-a is not supported alone), so I wanted to be sure.
> > >
> > > > Example:
> > > >
> > > > Good:
> > > > #aarch64-linux-gnu-gcc  -march=armv9-a+sve2+crypto -mcpu=neoverse-
> n2
> > > shrn.c
> > > > #aarch64-linux-gnu-gcc  -march=armv9-a+sve2 -mcpu=neoverse-n2
> shrn.c
> > > > #aarch64-linux-gnu-gcc  -march=armv9-a -mcpu=neoverse-n2 shrn.c
> > > >
> > > > Bad:
> > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8-a shrn.c
> > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8-
> a'
> > > switch
> > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.1-a shrn.c
> > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> march=armv8.1-a'
> > > switch
> > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.2-a shrn.c
> > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> march=armv8.2-a'
> > > switch
> > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.3-a shrn.c
> > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> march=armv8.3-a'
> > > switch
> > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.4-a shrn.c
> > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> march=armv8.4-a'
> > > switch
> > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.5-a shrn.c
> > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> march=armv8.5-a'
> > > switch
> > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
> > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> march=armv8.6-a'
> > > switch
> > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.7-a shrn.c
> > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> march=armv8.7-a'
> > > switch
> > > >
> > > > >
> > > > > > +                candidate_march = part_number_config['march']
> > > > > > +            endif
> > > > > >          else
> > > > > >              supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> > > 'armv8.3-
> > > > > a',
> > > > > >                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march conflicts
  2024-01-30 16:16           ` Pavan Nikhilesh Bhagavatula
@ 2024-01-31  9:03             ` Juraj Linkeš
  0 siblings, 0 replies; 65+ messages in thread
From: Juraj Linkeš @ 2024-01-31  9:03 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula
  Cc: Jerin Jacob, Ruifeng.Wang, nd, Bruce Richardson, dev

On Tue, Jan 30, 2024 at 5:16 PM Pavan Nikhilesh Bhagavatula
<pbhagavatula@marvell.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Sent: Monday, January 29, 2024 2:15 PM
> > To: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> > Cc: Jerin Jacob <jerinj@marvell.com>; Ruifeng.Wang@arm.com;
> > nd@arm.com; Bruce Richardson <bruce.richardson@intel.com>;
> > dev@dpdk.org
> > Subject: Re: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march
> > conflicts
> >
> > On Wed, Jan 24, 2024 at 4:22 PM Pavan Nikhilesh Bhagavatula
> > <pbhagavatula@marvell.com> wrote:
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > > Sent: Monday, January 22, 2024 9:57 PM
> > > > To: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> > > > Cc: Jerin Jacob <jerinj@marvell.com>; Ruifeng.Wang@arm.com;
> > > > nd@arm.com; Bruce Richardson <bruce.richardson@intel.com>;
> > > > dev@dpdk.org
> > > > Subject: Re: [EXT] Re: [PATCH 1/2] config/arm: avoid mcpu and march
> > > > conflicts
> > > >
> > > > On Mon, Jan 22, 2024 at 12:54 PM Pavan Nikhilesh Bhagavatula
> > > > <pbhagavatula@marvell.com> wrote:
> > > > >
> > > > > > On Sun, Jan 21, 2024 at 10:37 AM <pbhagavatula@marvell.com>
> > wrote:
> > > > > > >
> > > > > > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > > > > >
> > > > > > > The compiler options march and mtune are a subset
> > > > > > > of mcpu and will lead to conflicts if improper march
> > > > > > > is chosen for a given mcpu.
> > > > > > > To avoid conflicts, force part number march when
> > > > > > > mcpu is available and is supported by the compiler.
> > > > > > >
> > > > > > > Example:
> > > > > > >         march = armv9-a
> > > > > > >         mcpu = neoverse-n2
> > > > > > >
> > > > > > >         mcpu supported, march supported
> > > > > > >         machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> > > > > > >
> > > > > > >         mcpu supported, march not supported
> > > > > > >         machine_args = ['-mcpu=neoverse-n2']
> > > > > > >
> > > > > > >         mcpu not supported, march supported
> > > > > > >         machine_args = ['-march=armv9-a']
> > > > > > >
> > > > > > >         mcpu not supported, march not supported
> > > > > > >         machine_args = ['-march=armv8.6-a']
> > > > > > >
> > > > > > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > > > > > ---
> > > > > > >  config/arm/meson.build | 109 +++++++++++++++++++++++++-----
> > ----
> > > > -----
> > > > > > --
> > > > > > >  1 file changed, 67 insertions(+), 42 deletions(-)
> > > > > > >
> > > > > > > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > > > > > index 36f21d2259..8c8cfccca0 100644
> > > > > > > --- a/config/arm/meson.build
> > > > > > > +++ b/config/arm/meson.build
> > > > > > <snip>
> > > > > > > @@ -127,21 +128,22 @@ implementer_cavium = {
> > > > > > >      ],
> > > > > > >      'part_number_config': {
> > > > > > >          '0xa1': {
> > > > > > > -            'compiler_options': ['-mcpu=thunderxt88'],
> > > > > > > +            'mcpu': 'thunderxt88',
> > > > > > >              'flags': flags_part_number_thunderx
> > > > > > >          },
> > > > > > >          '0xa2': {
> > > > > > > -            'compiler_options': ['-mcpu=thunderxt81'],
> > > > > > > +            'mcpu': 'thunderxt81',
> > > > > > >              'flags': flags_part_number_thunderx
> > > > > > >          },
> > > > > > >          '0xa3': {
> > > > > > > -            'compiler_options': ['-march=armv8-a+crc', '-
> > > > mcpu=thunderxt83'],
> > > > > > > +            'mcpu': 'thunderxt83',
> > > > > > > +            'compiler_options': ['-march=armv8-a+crc'],
> > > > > >
> > > > > > Let's unify this with the rest and specify 'march': 'armv8-a+crc'
> > > > > > instead of having it under compiler_options.
> > > > >
> > > > > Ack.
> > > > >
> > > > > >
> > > > > > >              'flags': flags_part_number_thunderx
> > > > > > >          },
> > > > > > >          '0xaf': {
> > > > > > >              'march': 'armv8.1-a',
> > > > > > >              'march_features': ['crc', 'crypto'],
> > > > > > > -            'compiler_options': ['-mcpu=thunderx2t99'],
> > > > > > > +            'mcpu': 'thunderx2t99',
> > > > > > >              'flags': [
> > > > > > >                  ['RTE_MACHINE', '"thunderx2"'],
> > > > > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > > > > @@ -153,7 +155,7 @@ implementer_cavium = {
> > > > > > >          '0xb2': {
> > > > > > >              'march': 'armv8.2-a',
> > > > > > >              'march_features': ['crc', 'crypto', 'lse'],
> > > > > > > -            'compiler_options': ['-mcpu=octeontx2'],
> > > > > > > +            'mcpu': 'octeontx2',
> > > > > > >              'flags': [
> > > > > > >                  ['RTE_MACHINE', '"cn9k"'],
> > > > > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > > > > @@ -176,7 +178,7 @@ implementer_ampere = {
> > > > > > >          '0x0': {
> > > > > > >              'march': 'armv8-a',
> > > > > > >              'march_features': ['crc', 'crypto'],
> > > > > > > -            'compiler_options':  ['-mtune=emag'],
> > > > > > > +            'mcpu': 'emag',
> > > > > >
> > > > > > We're changing mtune to mcpu, is this equivalent?
> > > > > >
> > > > >
> > > > > Both march and mtune are a subset of mcpu.
> > > > >
> > > >
> > > > Sure, but we replaced '-mtune=emag' with '-mcpu=emag'. Are these two
> > > > builds going to be different or the same?
> > > >
> > >
> > > Yeah, I believe both are same.
> > >
> >
> > Ok, the change is fine then.
> >
> > > > > > >              'flags': [
> > > > > > >                  ['RTE_MACHINE', '"eMAG"'],
> > > > > > >                  ['RTE_MAX_LCORE', 32],
> > > > > > > @@ -186,7 +188,7 @@ implementer_ampere = {
> > > > > > >          '0xac3': {
> > > > > > >              'march': 'armv8.6-a',
> > > > > > >              'march_features': ['crc', 'crypto'],
> > > > > > > -            'compiler_options':  ['-mcpu=ampere1'],
> > > > > > > +            'mcpu': 'ampere1',
> > > > > > >              'flags': [
> > > > > > >                  ['RTE_MACHINE', '"AmpereOne"'],
> > > > > > >                  ['RTE_MAX_LCORE', 320],
> > > > > > > @@ -206,7 +208,7 @@ implementer_hisilicon = {
> > > > > > >          '0xd01': {
> > > > > > >              'march': 'armv8.2-a',
> > > > > > >              'march_features': ['crypto'],
> > > > > > > -            'compiler_options': ['-mtune=tsv110'],
> > > > > > > +            'mcpu': 'tsv110',
> > > > > > >              'flags': [
> > > > > > >                  ['RTE_MACHINE', '"Kunpeng 920"'],
> > > > > > >                  ['RTE_ARM_FEATURE_ATOMICS', true],
> > > > > > > @@ -695,11 +697,23 @@ if update_flags
> > > > > > >
> > > > > > >      machine_args = [] # Clear previous machine args
> > > > > > >
> > > > > > > +    candidate_mcpu = ''
> > > > > > > +    support_mcpu = false
> > > > > > > +    if part_number_config.has_key('mcpu')
> > > > > > > +        mcpu = part_number_config['mcpu']
> > > > > > > +        if (cc.has_argument('-mcpu=' + mcpu))
> > > > > > > +            candidate_mcpu = mcpu
> > > > > > > +            support_mcpu = true
> > > > > > > +        endif
> > > > > > > +    endif
> > > > > > > +
> > > > > > >      # probe supported archs and their features
> > > > > > >      candidate_march = ''
> > > > > > >      if part_number_config.has_key('march')
> > > > > > > -        if part_number_config.get('force_march', false)
> > > > > > > -            candidate_march = part_number_config['march']
> > > > > > > +        if part_number_config.get('force_march', false) or
> > support_mcpu
> > > > > >
> > > > > > Instead of using the extra "support_mcpu" variable, we could do the
> > > > > > same check as with candidate march (if candidate_mcpu != '', which we
> > > > > > actually do below in the last lines of the patch).
> > > > > >
> > > > >
> > > > > Ack.
> > > > >
> > > > > > If I understand the logic correctly, we don't want to do the march
> > > > > > fallback if mcpu is specified - either the march works with the given
> > > > > > mcpu or we do without it (because we don't actually need it with
> > > > > > mcpu). Is that correct?
> > > > > >
> > > > >
> > > > > Yes, but still exact march defined in part_number_config should be
> > present
> > > > for setting extra_march_features.
> > > > > specially for expressing crypto support.
> > > > >
> > > >
> > > > Ok, thanks.
> > > >
> > > > > > > +            if cc.has_argument('-march=' +  part_number_config['march'])
> > > > > >
> > > > > > Now that we've added mcpu into the mix, is this still the right
> > > > > > condition? Can the below happen?
> > > > > >
> > > > > > This check finds that machine_args = ['-march=armv9-a'] is supported.
> > > > > >
> > > > > > But taken together with mcpu (machine_args = ['-mcpu=neoverse-n2',
> > > > > > '-march=armv9-a']), it is not supported? In this case we'll end up
> > > > > > with invalid configuration.
> > > > >
> > > > > This is the only correct option and evolves into -march=armv9-
> > > > a+sve2+crypto for cn10k
> > > > > whereas other neoverse-n2 might only have -march=armv9-a+sve2.
> > > > >
> > > >
> > > > Maybe I should rephrase my question a bit:
> > > >
> > > > The correct options are ['-mcpu=neoverse-n2', '-march=armv9-a']. Is it
> > > > possible that the compiler will say:
> > > >
> > > > ['-mcpu=neoverse-n2', '-march=armv9-a'] is supported
> > > > ['-mcpu=neoverse-n2'] is supported
> > > > ['-march=armv9-a'] is not supported
> > > >
> > >
> > > Yes, this is possible.
> > >
> >
> > Ok, do we want to make sure it's possible to configure the options in
> > this way? But maybe that's out of scope of this patch.
> >
>
> This patch already handles those conditions, this is the case 2 mentioned in the example.
>
>         march = armv9-a
>         mcpu = neoverse-n2
>
>         [1] mcpu supported, march supported
>         machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
>
>         [2] mcpu supported, march not supported
>         machine_args = ['-mcpu=neoverse-n2']
>
>         [3] mcpu not supported, march supported
>         machine_args = ['-march=armv9-a']
>
>         [4] mcpu not supported, march not supported
>         machine_args = ['-march=armv8.6-a']
>

Ok, that sounds great, thanks.

> > > > So basically the question is are we risking that the compiler will say
> > > > it supports both options only when both are passed while also saying
> > > > it doesn't support one or both of them when checked alone. We've seen
> > > > this behavior with newer compilers in aarch32 builds
> > > > (-march=armv8-a+simd -mfpu=auto are supported when both are passed,
> > > > but -march=armv8-a is not supported alone), so I wanted to be sure.
> > > >
> > > > > Example:
> > > > >
> > > > > Good:
> > > > > #aarch64-linux-gnu-gcc  -march=armv9-a+sve2+crypto -mcpu=neoverse-
> > n2
> > > > shrn.c
> > > > > #aarch64-linux-gnu-gcc  -march=armv9-a+sve2 -mcpu=neoverse-n2
> > shrn.c
> > > > > #aarch64-linux-gnu-gcc  -march=armv9-a -mcpu=neoverse-n2 shrn.c
> > > > >
> > > > > Bad:
> > > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8-a shrn.c
> > > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8-
> > a'
> > > > switch
> > > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.1-a shrn.c
> > > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> > march=armv8.1-a'
> > > > switch
> > > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.2-a shrn.c
> > > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> > march=armv8.2-a'
> > > > switch
> > > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.3-a shrn.c
> > > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> > march=armv8.3-a'
> > > > switch
> > > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.4-a shrn.c
> > > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> > march=armv8.4-a'
> > > > switch
> > > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.5-a shrn.c
> > > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> > march=armv8.5-a'
> > > > switch
> > > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
> > > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> > march=armv8.6-a'
> > > > switch
> > > > > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.7-a shrn.c
> > > > > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-
> > march=armv8.7-a'
> > > > switch
> > > > >
> > > > > >
> > > > > > > +                candidate_march = part_number_config['march']
> > > > > > > +            endif
> > > > > > >          else
> > > > > > >              supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> > > > 'armv8.3-
> > > > > > a',
> > > > > > >                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v2 1/3] config/arm: avoid mcpu and march conflicts
  2024-01-21  9:36 [PATCH 1/2] config/arm: avoid mcpu and march conflicts pbhagavatula
                   ` (2 preceding siblings ...)
  2024-01-22 10:55 ` Juraj Linkeš
@ 2024-02-01 21:57 ` pbhagavatula
  2024-02-01 21:57   ` [PATCH v2 2/3] config/arm: add support for fallback march pbhagavatula
                     ` (2 more replies)
  3 siblings, 3 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-01 21:57 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

The compiler options march and mtune are a subset
of mcpu and will lead to conflicts if improper march
is chosen for a given mcpu.
To avoid conflicts, force part number march when
mcpu is available and is supported by the compiler.

Example:
	march = armv9-a
	mcpu = neoverse-n2

	mcpu supported, march supported
	machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']

	mcpu supported, march not supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu not supported, march supported
	machine_args = ['-march=armv9-a']

	mcpu not supported, march not supported
	machine_args = ['-march=armv8.6-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
v2 Changes:
- Cleanup march inconsistencies. (Juraj Linkes)
- Unify fallback march selection. (Juraj Linkes)
- Tag along ARM WFE patch.

 config/arm/meson.build | 108 +++++++++++++++++++++++++----------------
 1 file changed, 66 insertions(+), 42 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 36f21d2259..ba859bd060 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -58,18 +58,18 @@ implementer_generic = {
 }

 part_number_config_arm = {
-    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
-    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
-    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
-    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
-    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
-    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
+    '0xd03': {'mcpu': 'cortex-a53'},
+    '0xd04': {'mcpu': 'cortex-a35'},
+    '0xd05': {'mcpu': 'cortex-a55'},
+    '0xd07': {'mcpu': 'cortex-a57'},
+    '0xd08': {'mcpu': 'cortex-a72'},
+    '0xd09': {'mcpu': 'cortex-a73'},
+    '0xd0a': {'mcpu': 'cortex-a75'},
+    '0xd0b': {'mcpu': 'cortex-a76'},
     '0xd0c': {
         'march': 'armv8.2-a',
         'march_features': ['crypto', 'rcpc'],
-        'compiler_options':  ['-mcpu=neoverse-n1'],
+        'mcpu': 'neoverse-n1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -81,7 +81,7 @@ part_number_config_arm = {
     '0xd40': {
         'march': 'armv8.4-a',
         'march_features': ['sve'],
-        'compiler_options':  ['-mcpu=neoverse-v1'],
+        'mcpu': 'neoverse-v1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-v1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -92,8 +92,9 @@ part_number_config_arm = {
         'march': 'armv8.4-a',
     },
     '0xd49': {
+        'march': 'armv9-a',
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-n2'],
+        'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,21 +128,23 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'compiler_options': ['-mcpu=thunderxt88'],
+            'mcpu': 'thunderxt88',
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'compiler_options': ['-mcpu=thunderxt81'],
+            'mcpu': 'thunderxt81',
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'mcpu': 'thunderxt83',
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
             'march': 'armv8.1-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options': ['-mcpu=thunderx2t99'],
+            'mcpu': 'thunderx2t99',
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -153,7 +156,7 @@ implementer_cavium = {
         '0xb2': {
             'march': 'armv8.2-a',
             'march_features': ['crc', 'crypto', 'lse'],
-            'compiler_options': ['-mcpu=octeontx2'],
+            'mcpu': 'octeontx2',
             'flags': [
                 ['RTE_MACHINE', '"cn9k"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -176,7 +179,7 @@ implementer_ampere = {
         '0x0': {
             'march': 'armv8-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mtune=emag'],
+            'mcpu': 'emag',
             'flags': [
                 ['RTE_MACHINE', '"eMAG"'],
                 ['RTE_MAX_LCORE', 32],
@@ -186,7 +189,7 @@ implementer_ampere = {
         '0xac3': {
             'march': 'armv8.6-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mcpu=ampere1'],
+            'mcpu': 'ampere1',
             'flags': [
                 ['RTE_MACHINE', '"AmpereOne"'],
                 ['RTE_MAX_LCORE', 320],
@@ -206,7 +209,7 @@ implementer_hisilicon = {
         '0xd01': {
             'march': 'armv8.2-a',
             'march_features': ['crypto'],
-            'compiler_options': ['-mtune=tsv110'],
+            'mcpu': 'tsv110',
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -695,11 +698,21 @@ if update_flags

     machine_args = [] # Clear previous machine args

+    candidate_mcpu = ''
+    if part_number_config.has_key('mcpu')
+        mcpu = part_number_config['mcpu']
+        if (cc.has_argument('-mcpu=' + mcpu))
+            candidate_mcpu = mcpu
+        endif
+    endif
+
     # probe supported archs and their features
     candidate_march = ''
     if part_number_config.has_key('march')
-        if part_number_config.get('force_march', false)
-            candidate_march = part_number_config['march']
+        if part_number_config.get('force_march', false) or candidate_mcpu != ''
+            if cc.has_argument('-march=' +  part_number_config['march'])
+                candidate_march = part_number_config['march']
+            endif
         else
             supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
@@ -717,32 +730,43 @@ if update_flags
                 endif
             endforeach
         endif
-        if candidate_march == ''
-            error('No suitable armv8 march version found.')
-        endif
+
         if candidate_march != part_number_config['march']
-            warning('Configuration march version is ' +
-                    '@0@, but the compiler supports only @1@.'
-                    .format(part_number_config['march'], candidate_march))
+            warning('Configuration march version is @0@, not supported.'
+                    .format(part_number_config['march']))
+            if candidate_march != ''
+                warning('Using march version @0@.'.format(candidate_march))
+            endif
         endif
-        candidate_march = '-march=' + candidate_march

-        march_features = []
-        if part_number_config.has_key('march_features')
-            march_features += part_number_config['march_features']
-        endif
-        if soc_config.has_key('extra_march_features')
-            march_features += soc_config['extra_march_features']
+        if candidate_march == '' and candidate_mcpu == ''
+            error('No suitable ARM march/mcpu version found.')
         endif
-        foreach feature: march_features
-            if cc.has_argument('+'.join([candidate_march, feature]))
-                candidate_march = '+'.join([candidate_march, feature])
-            else
-                warning('The compiler does not support feature @0@'
-                    .format(feature))
+
+        if candidate_march != ''
+            candidate_march = '-march=' + candidate_march
+            march_features = []
+            if part_number_config.has_key('march_features')
+                march_features += part_number_config['march_features']
             endif
-        endforeach
-        machine_args += candidate_march
+            if soc_config.has_key('extra_march_features')
+                march_features += soc_config['extra_march_features']
+            endif
+            foreach feature: march_features
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    warning('The compiler does not support feature @0@'
+                        .format(feature))
+                endif
+            endforeach
+            machine_args += candidate_march
+        endif
+    endif
+
+    if candidate_mcpu != ''
+        candidate_mcpu = '-mcpu=' + candidate_mcpu
+        machine_args += candidate_mcpu
     endif

     # apply supported compiler options
--
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v2 2/3] config/arm: add support for fallback march
  2024-02-01 21:57 ` [PATCH v2 1/3] " pbhagavatula
@ 2024-02-01 21:57   ` pbhagavatula
  2024-02-01 21:57   ` [PATCH v2 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
  2024-02-02  8:50   ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
  2 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-01 21:57 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some ARM CPUs have specific march requirements and
are not compatible with the supported march list.
Add fallback march in case the mcpu and the march
advertised in the part_number_config are not supported
by the compiler.

Example
        mcpu = neoverse-n2
        march = armv9-a
        fallback_march = armv8.5-a

        mcpu, march not supported
        machine_args = ['-march=armv8.5-a']

        mcpu, march, fallback_march not supported
        least march supported = armv8-a

        machine_args = ['-march=armv8-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 config/arm/meson.build | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index ba859bd060..6f2308f2fa 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -94,6 +94,7 @@ part_number_config_arm = {
     '0xd49': {
         'march': 'armv9-a',
         'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
         'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
@@ -708,6 +709,7 @@ if update_flags
 
     # probe supported archs and their features
     candidate_march = ''
+    fallback_march = ''
     if part_number_config.has_key('march')
         if part_number_config.get('force_march', false) or candidate_mcpu != ''
             if cc.has_argument('-march=' +  part_number_config['march'])
@@ -728,10 +730,17 @@ if update_flags
                     # highest supported march version found
                     break
                 endif
+                if (supported_march == part_number_config['fallback_march']
+                    and cc.has_argument('-march=' + supported_march))
+                    fallback_march = supported_march
+                endif
             endforeach
         endif
 
         if candidate_march != part_number_config['march']
+            if fallback_march != ''
+                candidate_march = fallback_march
+            endif
             warning('Configuration march version is @0@, not supported.'
                     .format(part_number_config['march']))
             if candidate_march != ''
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v2 3/3] config/arm: allow WFE to be enabled config time
  2024-02-01 21:57 ` [PATCH v2 1/3] " pbhagavatula
  2024-02-01 21:57   ` [PATCH v2 2/3] config/arm: add support for fallback march pbhagavatula
@ 2024-02-01 21:57   ` pbhagavatula
  2024-02-07  2:55     ` Honnappa Nagarahalli
  2024-02-02  8:50   ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
  2 siblings, 1 reply; 65+ messages in thread
From: pbhagavatula @ 2024-02-01 21:57 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson
  Cc: dev, Pavan Nikhilesh, Chengwen Feng

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Allow RTE_ARM_USE_WFE to be enabled at meson configuration
time by passing it via c_args instead of modifying
`config/arm/meson.build`.

Example usage:
 meson build -Dc_args='-DRTE_ARM_USE_WFE' \
	--cross-file config/arm/arm64_cn10k_linux_gcc

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 config/arm/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 6f2308f2fa..3467bef466 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -17,7 +17,9 @@ flags_common = [
         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
 
-        ['RTE_ARM_USE_WFE', false],
+        # Enable use of ARM wait for event instruction.
+        # ['RTE_ARM_USE_WFE', false],
+
         ['RTE_ARCH_ARM64', true],
         ['RTE_CACHE_LINE_SIZE', 128]
 ]
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-01 21:57 ` [PATCH v2 1/3] " pbhagavatula
  2024-02-01 21:57   ` [PATCH v2 2/3] config/arm: add support for fallback march pbhagavatula
  2024-02-01 21:57   ` [PATCH v2 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
@ 2024-02-02  8:50   ` pbhagavatula
  2024-02-02  8:50     ` [PATCH v3 2/3] config/arm: add support for fallback march pbhagavatula
                       ` (3 more replies)
  2 siblings, 4 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-02  8:50 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

The compiler options march and mtune are a subset
of mcpu and will lead to conflicts if improper march
is chosen for a given mcpu.
To avoid conflicts, force part number march when
mcpu is available and is supported by the compiler.

Example:
	march = armv9-a
	mcpu = neoverse-n2

	mcpu supported, march supported
	machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']

	mcpu supported, march not supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu not supported, march supported
	machine_args = ['-march=armv9-a']

	mcpu not supported, march not supported
	machine_args = ['-march=armv8.6-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
v2 Changes:
- Cleanup march inconsistencies. (Juraj Linkes)
- Unify fallback march selection. (Juraj Linkes)
- Tag along ARM WFE patch.
v3 Changes:
- Fix missing 'fallback_march' key check.

 config/arm/meson.build | 108 +++++++++++++++++++++++++----------------
 1 file changed, 66 insertions(+), 42 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 36f21d22599a..ba859bd060b5 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -58,18 +58,18 @@ implementer_generic = {
 }

 part_number_config_arm = {
-    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
-    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
-    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
-    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
-    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
-    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
+    '0xd03': {'mcpu': 'cortex-a53'},
+    '0xd04': {'mcpu': 'cortex-a35'},
+    '0xd05': {'mcpu': 'cortex-a55'},
+    '0xd07': {'mcpu': 'cortex-a57'},
+    '0xd08': {'mcpu': 'cortex-a72'},
+    '0xd09': {'mcpu': 'cortex-a73'},
+    '0xd0a': {'mcpu': 'cortex-a75'},
+    '0xd0b': {'mcpu': 'cortex-a76'},
     '0xd0c': {
         'march': 'armv8.2-a',
         'march_features': ['crypto', 'rcpc'],
-        'compiler_options':  ['-mcpu=neoverse-n1'],
+        'mcpu': 'neoverse-n1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -81,7 +81,7 @@ part_number_config_arm = {
     '0xd40': {
         'march': 'armv8.4-a',
         'march_features': ['sve'],
-        'compiler_options':  ['-mcpu=neoverse-v1'],
+        'mcpu': 'neoverse-v1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-v1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -92,8 +92,9 @@ part_number_config_arm = {
         'march': 'armv8.4-a',
     },
     '0xd49': {
+        'march': 'armv9-a',
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-n2'],
+        'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,21 +128,23 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'compiler_options': ['-mcpu=thunderxt88'],
+            'mcpu': 'thunderxt88',
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'compiler_options': ['-mcpu=thunderxt81'],
+            'mcpu': 'thunderxt81',
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'mcpu': 'thunderxt83',
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
             'march': 'armv8.1-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options': ['-mcpu=thunderx2t99'],
+            'mcpu': 'thunderx2t99',
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -153,7 +156,7 @@ implementer_cavium = {
         '0xb2': {
             'march': 'armv8.2-a',
             'march_features': ['crc', 'crypto', 'lse'],
-            'compiler_options': ['-mcpu=octeontx2'],
+            'mcpu': 'octeontx2',
             'flags': [
                 ['RTE_MACHINE', '"cn9k"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -176,7 +179,7 @@ implementer_ampere = {
         '0x0': {
             'march': 'armv8-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mtune=emag'],
+            'mcpu': 'emag',
             'flags': [
                 ['RTE_MACHINE', '"eMAG"'],
                 ['RTE_MAX_LCORE', 32],
@@ -186,7 +189,7 @@ implementer_ampere = {
         '0xac3': {
             'march': 'armv8.6-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mcpu=ampere1'],
+            'mcpu': 'ampere1',
             'flags': [
                 ['RTE_MACHINE', '"AmpereOne"'],
                 ['RTE_MAX_LCORE', 320],
@@ -206,7 +209,7 @@ implementer_hisilicon = {
         '0xd01': {
             'march': 'armv8.2-a',
             'march_features': ['crypto'],
-            'compiler_options': ['-mtune=tsv110'],
+            'mcpu': 'tsv110',
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -695,11 +698,21 @@ if update_flags

     machine_args = [] # Clear previous machine args

+    candidate_mcpu = ''
+    if part_number_config.has_key('mcpu')
+        mcpu = part_number_config['mcpu']
+        if (cc.has_argument('-mcpu=' + mcpu))
+            candidate_mcpu = mcpu
+        endif
+    endif
+
     # probe supported archs and their features
     candidate_march = ''
     if part_number_config.has_key('march')
-        if part_number_config.get('force_march', false)
-            candidate_march = part_number_config['march']
+        if part_number_config.get('force_march', false) or candidate_mcpu != ''
+            if cc.has_argument('-march=' +  part_number_config['march'])
+                candidate_march = part_number_config['march']
+            endif
         else
             supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
@@ -717,32 +730,43 @@ if update_flags
                 endif
             endforeach
         endif
-        if candidate_march == ''
-            error('No suitable armv8 march version found.')
-        endif
+
         if candidate_march != part_number_config['march']
-            warning('Configuration march version is ' +
-                    '@0@, but the compiler supports only @1@.'
-                    .format(part_number_config['march'], candidate_march))
+            warning('Configuration march version is @0@, not supported.'
+                    .format(part_number_config['march']))
+            if candidate_march != ''
+                warning('Using march version @0@.'.format(candidate_march))
+            endif
         endif
-        candidate_march = '-march=' + candidate_march

-        march_features = []
-        if part_number_config.has_key('march_features')
-            march_features += part_number_config['march_features']
-        endif
-        if soc_config.has_key('extra_march_features')
-            march_features += soc_config['extra_march_features']
+        if candidate_march == '' and candidate_mcpu == ''
+            error('No suitable ARM march/mcpu version found.')
         endif
-        foreach feature: march_features
-            if cc.has_argument('+'.join([candidate_march, feature]))
-                candidate_march = '+'.join([candidate_march, feature])
-            else
-                warning('The compiler does not support feature @0@'
-                    .format(feature))
+
+        if candidate_march != ''
+            candidate_march = '-march=' + candidate_march
+            march_features = []
+            if part_number_config.has_key('march_features')
+                march_features += part_number_config['march_features']
             endif
-        endforeach
-        machine_args += candidate_march
+            if soc_config.has_key('extra_march_features')
+                march_features += soc_config['extra_march_features']
+            endif
+            foreach feature: march_features
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    warning('The compiler does not support feature @0@'
+                        .format(feature))
+                endif
+            endforeach
+            machine_args += candidate_march
+        endif
+    endif
+
+    if candidate_mcpu != ''
+        candidate_mcpu = '-mcpu=' + candidate_mcpu
+        machine_args += candidate_mcpu
     endif

     # apply supported compiler options
--
2.43.0


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v3 2/3] config/arm: add support for fallback march
  2024-02-02  8:50   ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
@ 2024-02-02  8:50     ` pbhagavatula
  2024-02-07 20:24       ` Wathsala Wathawana Vithanage
  2024-02-02  8:50     ` [PATCH v3 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 65+ messages in thread
From: pbhagavatula @ 2024-02-02  8:50 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some ARM CPUs have specific march requirements and
are not compatible with the supported march list.
Add fallback march in case the mcpu and the march
advertised in the part_number_config are not supported
by the compiler.

Example
        mcpu = neoverse-n2
        march = armv9-a
        fallback_march = armv8.5-a

        mcpu, march not supported
        machine_args = ['-march=armv8.5-a']

        mcpu, march, fallback_march not supported
        least march supported = armv8-a

        machine_args = ['-march=armv8-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 config/arm/meson.build | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index ba859bd060b5..4e44d1850bae 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -94,6 +94,7 @@ part_number_config_arm = {
     '0xd49': {
         'march': 'armv9-a',
         'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
         'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
@@ -708,6 +709,7 @@ if update_flags
 
     # probe supported archs and their features
     candidate_march = ''
+    fallback_march = ''
     if part_number_config.has_key('march')
         if part_number_config.get('force_march', false) or candidate_mcpu != ''
             if cc.has_argument('-march=' +  part_number_config['march'])
@@ -728,10 +730,18 @@ if update_flags
                     # highest supported march version found
                     break
                 endif
+                if (part_number_config.has_key('fallback_march') and
+                    supported_march == part_number_config['fallback_march'] and
+                    cc.has_argument('-march=' + supported_march))
+                    fallback_march = supported_march
+                endif
             endforeach
         endif
 
         if candidate_march != part_number_config['march']
+            if fallback_march != ''
+                candidate_march = fallback_march
+            endif
             warning('Configuration march version is @0@, not supported.'
                     .format(part_number_config['march']))
             if candidate_march != ''
-- 
2.43.0


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v3 3/3] config/arm: allow WFE to be enabled config time
  2024-02-02  8:50   ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
  2024-02-02  8:50     ` [PATCH v3 2/3] config/arm: add support for fallback march pbhagavatula
@ 2024-02-02  8:50     ` pbhagavatula
  2024-02-10 16:56       ` Honnappa Nagarahalli
  2024-02-12 19:21       ` Wathsala Wathawana Vithanage
  2024-02-06  4:10     ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts Wathsala Wathawana Vithanage
  2024-02-21 20:20     ` [PATCH v4 " pbhagavatula
  3 siblings, 2 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-02  8:50 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson
  Cc: dev, Pavan Nikhilesh, Chengwen Feng

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Allow RTE_ARM_USE_WFE to be enabled at meson configuration
time by passing it via c_args instead of modifying
`config/arm/meson.build`.

Example usage:
 meson build -Dc_args='-DRTE_ARM_USE_WFE' \
	--cross-file config/arm/arm64_cn10k_linux_gcc

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 config/arm/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 4e44d1850bae..01870a23328a 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -17,7 +17,9 @@ flags_common = [
         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
 
-        ['RTE_ARM_USE_WFE', false],
+        # Enable use of ARM wait for event instruction.
+        # ['RTE_ARM_USE_WFE', false],
+
         ['RTE_ARCH_ARM64', true],
         ['RTE_CACHE_LINE_SIZE', 128]
 ]
-- 
2.43.0


^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-02  8:50   ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
  2024-02-02  8:50     ` [PATCH v3 2/3] config/arm: add support for fallback march pbhagavatula
  2024-02-02  8:50     ` [PATCH v3 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
@ 2024-02-06  4:10     ` Wathsala Wathawana Vithanage
  2024-02-06  4:44       ` Honnappa Nagarahalli
  2024-02-21 20:20     ` [PATCH v4 " pbhagavatula
  3 siblings, 1 reply; 65+ messages in thread
From: Wathsala Wathawana Vithanage @ 2024-02-06  4:10 UTC (permalink / raw)
  To: pbhagavatula, jerinj, juraj.linkes, Ruifeng Wang, Bruce Richardson
  Cc: dev, Honnappa Nagarahalli, nd, nd

Hi Pavan,

> The compiler options march and mtune are a subset of mcpu and will lead to
> conflicts if improper march is chosen for a given mcpu.
> To avoid conflicts, force part number march when mcpu is available and is
> supported by the compiler.

Why would one force the march specified in the part number when mcpu for
that part number is also available and supported by the compiler?

> 
> Example:
> 	march = armv9-a
> 	mcpu = neoverse-n2
> 
> 	mcpu supported, march supported
> 	machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']

-march restricts the compiler to baseline architecture of the -mcpu.
For instance, Neoverse-n1's baseline architecture is armv8.2-a, 
but it has some extensions from armv8.3-a, armv8.4-a, and armv8.5-a. 
By setting -march to armv8.2-a the compiler will strictly omit extensions
from 8.3, 8.4 and 8.5 resulting in a suboptimal outcome.

> 
> 	mcpu supported, march not supported
> 	machine_args = ['-mcpu=neoverse-n2']

This will result in the best outcome.

> 
> 	mcpu not supported, march supported
> 	machine_args = ['-march=armv9-a']

This too may result in a suboptimal outcome as optimization space
is limited to the given march (not using extensions from later 
architectures when available).

> 
> 	mcpu not supported, march not supported
> 	machine_args = ['-march=armv8.6-a']

Compiler knows nothing about the target CPU or the architecture.
I think it's better to exit the build process with an error. 

> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
> v2 Changes:
> - Cleanup march inconsistencies. (Juraj Linkes)
> - Unify fallback march selection. (Juraj Linkes)
> - Tag along ARM WFE patch.
> v3 Changes:
> - Fix missing 'fallback_march' key check.
> 
>  config/arm/meson.build | 108 +++++++++++++++++++++++++---------------
> -
>  1 file changed, 66 insertions(+), 42 deletions(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> 36f21d22599a..ba859bd060b5 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -58,18 +58,18 @@ implementer_generic = {  }
> 
>  part_number_config_arm = {
> -    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
> -    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
> -    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
> -    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
> -    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
> -    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
> -    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
> -    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
> +    '0xd03': {'mcpu': 'cortex-a53'},
> +    '0xd04': {'mcpu': 'cortex-a35'},
> +    '0xd05': {'mcpu': 'cortex-a55'},
> +    '0xd07': {'mcpu': 'cortex-a57'},
> +    '0xd08': {'mcpu': 'cortex-a72'},
> +    '0xd09': {'mcpu': 'cortex-a73'},
> +    '0xd0a': {'mcpu': 'cortex-a75'},
> +    '0xd0b': {'mcpu': 'cortex-a76'},
>      '0xd0c': {
>          'march': 'armv8.2-a',
>          'march_features': ['crypto', 'rcpc'],
> -        'compiler_options':  ['-mcpu=neoverse-n1'],
> +        'mcpu': 'neoverse-n1',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n1"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true], @@ -81,7 +81,7 @@
> part_number_config_arm = {
>      '0xd40': {
>          'march': 'armv8.4-a',
>          'march_features': ['sve'],
> -        'compiler_options':  ['-mcpu=neoverse-v1'],
> +        'mcpu': 'neoverse-v1',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-v1"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true], @@ -92,8 +92,9 @@
> part_number_config_arm = {
>          'march': 'armv8.4-a',
>      },
>      '0xd49': {
> +        'march': 'armv9-a',
>          'march_features': ['sve2'],
> -        'compiler_options': ['-mcpu=neoverse-n2'],
> +        'mcpu': 'neoverse-n2',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true], @@ -127,21 +128,23 @@
> implementer_cavium = {
>      ],
>      'part_number_config': {
>          '0xa1': {
> -            'compiler_options': ['-mcpu=thunderxt88'],
> +            'mcpu': 'thunderxt88',
>              'flags': flags_part_number_thunderx
>          },
>          '0xa2': {
> -            'compiler_options': ['-mcpu=thunderxt81'],
> +            'mcpu': 'thunderxt81',
>              'flags': flags_part_number_thunderx
>          },
>          '0xa3': {
> -            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
> +            'march': 'armv8-a',
> +            'march_features': ['crc'],
> +            'mcpu': 'thunderxt83',
>              'flags': flags_part_number_thunderx
>          },
>          '0xaf': {
>              'march': 'armv8.1-a',
>              'march_features': ['crc', 'crypto'],
> -            'compiler_options': ['-mcpu=thunderx2t99'],
> +            'mcpu': 'thunderx2t99',
>              'flags': [
>                  ['RTE_MACHINE', '"thunderx2"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -153,7 +156,7 @@
> implementer_cavium = {
>          '0xb2': {
>              'march': 'armv8.2-a',
>              'march_features': ['crc', 'crypto', 'lse'],
> -            'compiler_options': ['-mcpu=octeontx2'],
> +            'mcpu': 'octeontx2',
>              'flags': [
>                  ['RTE_MACHINE', '"cn9k"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -176,7 +179,7 @@
> implementer_ampere = {
>          '0x0': {
>              'march': 'armv8-a',
>              'march_features': ['crc', 'crypto'],
> -            'compiler_options':  ['-mtune=emag'],
> +            'mcpu': 'emag',
>              'flags': [
>                  ['RTE_MACHINE', '"eMAG"'],
>                  ['RTE_MAX_LCORE', 32],
> @@ -186,7 +189,7 @@ implementer_ampere = {
>          '0xac3': {
>              'march': 'armv8.6-a',
>              'march_features': ['crc', 'crypto'],
> -            'compiler_options':  ['-mcpu=ampere1'],
> +            'mcpu': 'ampere1',
>              'flags': [
>                  ['RTE_MACHINE', '"AmpereOne"'],
>                  ['RTE_MAX_LCORE', 320], @@ -206,7 +209,7 @@
> implementer_hisilicon = {
>          '0xd01': {
>              'march': 'armv8.2-a',
>              'march_features': ['crypto'],
> -            'compiler_options': ['-mtune=tsv110'],
> +            'mcpu': 'tsv110',
>              'flags': [
>                  ['RTE_MACHINE', '"Kunpeng 920"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -695,11 +698,21 @@ if
> update_flags
> 
>      machine_args = [] # Clear previous machine args
> 
> +    candidate_mcpu = ''
> +    if part_number_config.has_key('mcpu')
> +        mcpu = part_number_config['mcpu']
> +        if (cc.has_argument('-mcpu=' + mcpu))
> +            candidate_mcpu = mcpu
> +        endif
> +    endif
> +
>      # probe supported archs and their features
>      candidate_march = ''
>      if part_number_config.has_key('march')
> -        if part_number_config.get('force_march', false)
> -            candidate_march = part_number_config['march']
> +        if part_number_config.get('force_march', false) or candidate_mcpu != ''
> +            if cc.has_argument('-march=' +  part_number_config['march'])
> +                candidate_march = part_number_config['march']
> +            endif
>          else
>              supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-
> a',
>                                  'armv8.2-a', 'armv8.1-a', 'armv8-a'] @@ -717,32 +730,43
> @@ if update_flags
>                  endif
>              endforeach
>          endif
> -        if candidate_march == ''
> -            error('No suitable armv8 march version found.')
> -        endif
> +
>          if candidate_march != part_number_config['march']
> -            warning('Configuration march version is ' +
> -                    '@0@, but the compiler supports only @1@.'
> -                    .format(part_number_config['march'], candidate_march))
> +            warning('Configuration march version is @0@, not supported.'
> +                    .format(part_number_config['march']))
> +            if candidate_march != ''
> +                warning('Using march version @0@.'.format(candidate_march))
> +            endif
>          endif
> -        candidate_march = '-march=' + candidate_march
> 
> -        march_features = []
> -        if part_number_config.has_key('march_features')
> -            march_features += part_number_config['march_features']
> -        endif
> -        if soc_config.has_key('extra_march_features')
> -            march_features += soc_config['extra_march_features']
> +        if candidate_march == '' and candidate_mcpu == ''
> +            error('No suitable ARM march/mcpu version found.')
>          endif
> -        foreach feature: march_features
> -            if cc.has_argument('+'.join([candidate_march, feature]))
> -                candidate_march = '+'.join([candidate_march, feature])
> -            else
> -                warning('The compiler does not support feature @0@'
> -                    .format(feature))
> +
> +        if candidate_march != ''
> +            candidate_march = '-march=' + candidate_march
> +            march_features = []
> +            if part_number_config.has_key('march_features')
> +                march_features += part_number_config['march_features']
>              endif
> -        endforeach
> -        machine_args += candidate_march
> +            if soc_config.has_key('extra_march_features')
> +                march_features += soc_config['extra_march_features']
> +            endif
> +            foreach feature: march_features
> +                if cc.has_argument('+'.join([candidate_march, feature]))
> +                    candidate_march = '+'.join([candidate_march, feature])
> +                else
> +                    warning('The compiler does not support feature @0@'
> +                        .format(feature))
> +                endif
> +            endforeach
> +            machine_args += candidate_march
> +        endif
> +    endif
> +
> +    if candidate_mcpu != ''
> +        candidate_mcpu = '-mcpu=' + candidate_mcpu
> +        machine_args += candidate_mcpu
>      endif
> 
>      # apply supported compiler options
> --
> 2.43.0


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-06  4:10     ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts Wathsala Wathawana Vithanage
@ 2024-02-06  4:44       ` Honnappa Nagarahalli
  2024-02-06 10:21         ` Pavan Nikhilesh Bhagavatula
  0 siblings, 1 reply; 65+ messages in thread
From: Honnappa Nagarahalli @ 2024-02-06  4:44 UTC (permalink / raw)
  To: Wathsala Wathawana Vithanage
  Cc: pbhagavatula, jerinj, juraj.linkes, Ruifeng Wang,
	Bruce Richardson, dev, nd



> On Feb 5, 2024, at 10:10 PM, Wathsala Wathawana Vithanage <wathsala.vithanage@arm.com> wrote:
> 
> Hi Pavan,
> 
>> The compiler options march and mtune are a subset of mcpu and will lead to
>> conflicts if improper march is chosen for a given mcpu.
>> To avoid conflicts, force part number march when mcpu is available and is
>> supported by the compiler.
> 
> Why would one force the march specified in the part number when mcpu for
> that part number is also available and supported by the compiler?
> 
It would be good to explain the use case or the problem being faced.

>> 
>> Example:
>> march = armv9-a
>> mcpu = neoverse-n2
>> 
>> mcpu supported, march supported
>> machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> 
> -march restricts the compiler to baseline architecture of the -mcpu.
> For instance, Neoverse-n1's baseline architecture is armv8.2-a, 
> but it has some extensions from armv8.3-a, armv8.4-a, and armv8.5-a. 
> By setting -march to armv8.2-a the compiler will strictly omit extensions
> from 8.3, 8.4 and 8.5 resulting in a suboptimal outcome.
> 
>> 
>> mcpu supported, march not supported
>> machine_args = ['-mcpu=neoverse-n2']
> 
> This will result in the best outcome.
> 
>> 
>> mcpu not supported, march supported
>> machine_args = ['-march=armv9-a']
> 
> This too may result in a suboptimal outcome as optimization space
> is limited to the given march (not using extensions from later 
> architectures when available).
> 
>> 
>> mcpu not supported, march not supported
>> machine_args = ['-march=armv8.6-a']
> 
> Compiler knows nothing about the target CPU or the architecture.
> I think it's better to exit the build process with an error. 
> 
>> 
>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>> ---
>> v2 Changes:
>> - Cleanup march inconsistencies. (Juraj Linkes)
>> - Unify fallback march selection. (Juraj Linkes)
>> - Tag along ARM WFE patch.
>> v3 Changes:
>> - Fix missing 'fallback_march' key check.
>> 
>> config/arm/meson.build | 108 +++++++++++++++++++++++++---------------
>> -
>> 1 file changed, 66 insertions(+), 42 deletions(-)
>> 
>> diff --git a/config/arm/meson.build b/config/arm/meson.build index
>> 36f21d22599a..ba859bd060b5 100644
>> --- a/config/arm/meson.build
>> +++ b/config/arm/meson.build
>> @@ -58,18 +58,18 @@ implementer_generic = {  }
>> 
>> part_number_config_arm = {
>> -    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
>> -    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
>> -    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
>> -    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
>> -    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
>> -    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
>> -    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
>> -    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
>> +    '0xd03': {'mcpu': 'cortex-a53'},
>> +    '0xd04': {'mcpu': 'cortex-a35'},
>> +    '0xd05': {'mcpu': 'cortex-a55'},
>> +    '0xd07': {'mcpu': 'cortex-a57'},
>> +    '0xd08': {'mcpu': 'cortex-a72'},
>> +    '0xd09': {'mcpu': 'cortex-a73'},
>> +    '0xd0a': {'mcpu': 'cortex-a75'},
>> +    '0xd0b': {'mcpu': 'cortex-a76'},
>>     '0xd0c': {
>>         'march': 'armv8.2-a',
>>         'march_features': ['crypto', 'rcpc'],
>> -        'compiler_options':  ['-mcpu=neoverse-n1'],
>> +        'mcpu': 'neoverse-n1',
>>         'flags': [
>>             ['RTE_MACHINE', '"neoverse-n1"'],
>>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -81,7 +81,7 @@
>> part_number_config_arm = {
>>     '0xd40': {
>>         'march': 'armv8.4-a',
>>         'march_features': ['sve'],
>> -        'compiler_options':  ['-mcpu=neoverse-v1'],
>> +        'mcpu': 'neoverse-v1',
>>         'flags': [
>>             ['RTE_MACHINE', '"neoverse-v1"'],
>>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -92,8 +92,9 @@
>> part_number_config_arm = {
>>         'march': 'armv8.4-a',
>>     },
>>     '0xd49': {
>> +        'march': 'armv9-a',
>>         'march_features': ['sve2'],
>> -        'compiler_options': ['-mcpu=neoverse-n2'],
>> +        'mcpu': 'neoverse-n2',
>>         'flags': [
>>             ['RTE_MACHINE', '"neoverse-n2"'],
>>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -127,21 +128,23 @@
>> implementer_cavium = {
>>     ],
>>     'part_number_config': {
>>         '0xa1': {
>> -            'compiler_options': ['-mcpu=thunderxt88'],
>> +            'mcpu': 'thunderxt88',
>>             'flags': flags_part_number_thunderx
>>         },
>>         '0xa2': {
>> -            'compiler_options': ['-mcpu=thunderxt81'],
>> +            'mcpu': 'thunderxt81',
>>             'flags': flags_part_number_thunderx
>>         },
>>         '0xa3': {
>> -            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
>> +            'march': 'armv8-a',
>> +            'march_features': ['crc'],
>> +            'mcpu': 'thunderxt83',
>>             'flags': flags_part_number_thunderx
>>         },
>>         '0xaf': {
>>             'march': 'armv8.1-a',
>>             'march_features': ['crc', 'crypto'],
>> -            'compiler_options': ['-mcpu=thunderx2t99'],
>> +            'mcpu': 'thunderx2t99',
>>             'flags': [
>>                 ['RTE_MACHINE', '"thunderx2"'],
>>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -153,7 +156,7 @@
>> implementer_cavium = {
>>         '0xb2': {
>>             'march': 'armv8.2-a',
>>             'march_features': ['crc', 'crypto', 'lse'],
>> -            'compiler_options': ['-mcpu=octeontx2'],
>> +            'mcpu': 'octeontx2',
>>             'flags': [
>>                 ['RTE_MACHINE', '"cn9k"'],
>>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -176,7 +179,7 @@
>> implementer_ampere = {
>>         '0x0': {
>>             'march': 'armv8-a',
>>             'march_features': ['crc', 'crypto'],
>> -            'compiler_options':  ['-mtune=emag'],
>> +            'mcpu': 'emag',
>>             'flags': [
>>                 ['RTE_MACHINE', '"eMAG"'],
>>                 ['RTE_MAX_LCORE', 32],
>> @@ -186,7 +189,7 @@ implementer_ampere = {
>>         '0xac3': {
>>             'march': 'armv8.6-a',
>>             'march_features': ['crc', 'crypto'],
>> -            'compiler_options':  ['-mcpu=ampere1'],
>> +            'mcpu': 'ampere1',
>>             'flags': [
>>                 ['RTE_MACHINE', '"AmpereOne"'],
>>                 ['RTE_MAX_LCORE', 320], @@ -206,7 +209,7 @@
>> implementer_hisilicon = {
>>         '0xd01': {
>>             'march': 'armv8.2-a',
>>             'march_features': ['crypto'],
>> -            'compiler_options': ['-mtune=tsv110'],
>> +            'mcpu': 'tsv110',
>>             'flags': [
>>                 ['RTE_MACHINE', '"Kunpeng 920"'],
>>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -695,11 +698,21 @@ if
>> update_flags
>> 
>>     machine_args = [] # Clear previous machine args
>> 
>> +    candidate_mcpu = ''
>> +    if part_number_config.has_key('mcpu')
>> +        mcpu = part_number_config['mcpu']
>> +        if (cc.has_argument('-mcpu=' + mcpu))
>> +            candidate_mcpu = mcpu
>> +        endif
>> +    endif
>> +
>>     # probe supported archs and their features
>>     candidate_march = ''
>>     if part_number_config.has_key('march')
>> -        if part_number_config.get('force_march', false)
>> -            candidate_march = part_number_config['march']
>> +        if part_number_config.get('force_march', false) or candidate_mcpu != ''
>> +            if cc.has_argument('-march=' +  part_number_config['march'])
>> +                candidate_march = part_number_config['march']
>> +            endif
>>         else
>>             supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-
>> a',
>>                                 'armv8.2-a', 'armv8.1-a', 'armv8-a'] @@ -717,32 +730,43
>> @@ if update_flags
>>                 endif
>>             endforeach
>>         endif
>> -        if candidate_march == ''
>> -            error('No suitable armv8 march version found.')
>> -        endif
>> +
>>         if candidate_march != part_number_config['march']
>> -            warning('Configuration march version is ' +
>> -                    '@0@, but the compiler supports only @1@.'
>> -                    .format(part_number_config['march'], candidate_march))
>> +            warning('Configuration march version is @0@, not supported.'
>> +                    .format(part_number_config['march']))
>> +            if candidate_march != ''
>> +                warning('Using march version @0@.'.format(candidate_march))
>> +            endif
>>         endif
>> -        candidate_march = '-march=' + candidate_march
>> 
>> -        march_features = []
>> -        if part_number_config.has_key('march_features')
>> -            march_features += part_number_config['march_features']
>> -        endif
>> -        if soc_config.has_key('extra_march_features')
>> -            march_features += soc_config['extra_march_features']
>> +        if candidate_march == '' and candidate_mcpu == ''
>> +            error('No suitable ARM march/mcpu version found.')
>>         endif
>> -        foreach feature: march_features
>> -            if cc.has_argument('+'.join([candidate_march, feature]))
>> -                candidate_march = '+'.join([candidate_march, feature])
>> -            else
>> -                warning('The compiler does not support feature @0@'
>> -                    .format(feature))
>> +
>> +        if candidate_march != ''
>> +            candidate_march = '-march=' + candidate_march
>> +            march_features = []
>> +            if part_number_config.has_key('march_features')
>> +                march_features += part_number_config['march_features']
>>             endif
>> -        endforeach
>> -        machine_args += candidate_march
>> +            if soc_config.has_key('extra_march_features')
>> +                march_features += soc_config['extra_march_features']
>> +            endif
>> +            foreach feature: march_features
>> +                if cc.has_argument('+'.join([candidate_march, feature]))
>> +                    candidate_march = '+'.join([candidate_march, feature])
>> +                else
>> +                    warning('The compiler does not support feature @0@'
>> +                        .format(feature))
>> +                endif
>> +            endforeach
>> +            machine_args += candidate_march
>> +        endif
>> +    endif
>> +
>> +    if candidate_mcpu != ''
>> +        candidate_mcpu = '-mcpu=' + candidate_mcpu
>> +        machine_args += candidate_mcpu
>>     endif
>> 
>>     # apply supported compiler options
>> --
>> 2.43.0
> 


^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-06  4:44       ` Honnappa Nagarahalli
@ 2024-02-06 10:21         ` Pavan Nikhilesh Bhagavatula
  2024-02-07  0:01           ` Wathsala Wathawana Vithanage
  0 siblings, 1 reply; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-02-06 10:21 UTC (permalink / raw)
  To: Honnappa Nagarahalli, Wathsala Wathawana Vithanage
  Cc: Jerin Jacob, juraj.linkes, Ruifeng Wang, Bruce Richardson, dev, nd

> > On Feb 5, 2024, at 10:10 PM, Wathsala Wathawana Vithanage
> <wathsala.vithanage@arm.com> wrote:
> >
> > Hi Pavan,
> >
> >> The compiler options march and mtune are a subset of mcpu and will lead
> to
> >> conflicts if improper march is chosen for a given mcpu.
> >> To avoid conflicts, force part number march when mcpu is available and is
> >> supported by the compiler.
> >
> > Why would one force the march specified in the part number when mcpu for
> > that part number is also available and supported by the compiler?
> >
> It would be good to explain the use case or the problem being faced.
> 

The idea of this patchset is to avoid mcpu and march conflicts that can happen with the current build flow. 

#aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.6-a'

In some versions of GCC mcpu=neoverse-n2 is supported but -march=armv9-a is not so, current build flow
will choose the next supported march which is armv8.6-a and report a conflict.

> >>
> >> Example:
> >> march = armv9-a
> >> mcpu = neoverse-n2
> >>
> >> mcpu supported, march supported
> >> machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> >
> > -march restricts the compiler to baseline architecture of the -mcpu.
> > For instance, Neoverse-n1's baseline architecture is armv8.2-a,
> > but it has some extensions from armv8.3-a, armv8.4-a, and armv8.5-a.
> > By setting -march to armv8.2-a the compiler will strictly omit extensions
> > from 8.3, 8.4 and 8.5 resulting in a suboptimal outcome.

What if compiler only supports armv8.2-a?
Are you suggesting we don’t use march at all when mcpu is supported?
If so how do you express extensions that the SoC supports?
Neoverse-n2 has optional support for crypto and can only be enabled by 
expressing it through march='armv9-a+crypto'

> >
> >>
> >> mcpu supported, march not supported
> >> machine_args = ['-mcpu=neoverse-n2']
> >
> > This will result in the best outcome.

Isn't -mcpu=neoverse-n2 -march=armv9-a+sve2+crypto also the best outcome?

> >
> >>
> >> mcpu not supported, march supported
> >> machine_args = ['-march=armv9-a']
> >
> > This too may result in a suboptimal outcome as optimization space
> > is limited to the given march (not using extensions from later
> > architectures when available).
> >

What if compiler doesn’t support mcpu=neoverse-n2 and only supports march=armv9-a

> >>
> >> mcpu not supported, march not supported
> >> machine_args = ['-march=armv8.6-a']
> >
> > Compiler knows nothing about the target CPU or the architecture.
> > I think it's better to exit the build process with an error.
> >

Then we would need to mark all old GCC versions as not supported by a newer SoC
I don’t think that’s needed since the binaries still run but not optimally, currently we have 
a warning in place for march mismatch.

> >>
> >> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >> ---
> >> v2 Changes:
> >> - Cleanup march inconsistencies. (Juraj Linkes)
> >> - Unify fallback march selection. (Juraj Linkes)
> >> - Tag along ARM WFE patch.
> >> v3 Changes:
> >> - Fix missing 'fallback_march' key check.
> >>
> >> config/arm/meson.build | 108 +++++++++++++++++++++++++-------------
> --
> >> -
> >> 1 file changed, 66 insertions(+), 42 deletions(-)
> >>
> >> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> >> 36f21d22599a..ba859bd060b5 100644
> >> --- a/config/arm/meson.build
> >> +++ b/config/arm/meson.build
> >> @@ -58,18 +58,18 @@ implementer_generic = {  }
> >>
> >> part_number_config_arm = {
> >> -    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
> >> -    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
> >> -    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
> >> -    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
> >> -    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
> >> -    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
> >> -    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
> >> -    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
> >> +    '0xd03': {'mcpu': 'cortex-a53'},
> >> +    '0xd04': {'mcpu': 'cortex-a35'},
> >> +    '0xd05': {'mcpu': 'cortex-a55'},
> >> +    '0xd07': {'mcpu': 'cortex-a57'},
> >> +    '0xd08': {'mcpu': 'cortex-a72'},
> >> +    '0xd09': {'mcpu': 'cortex-a73'},
> >> +    '0xd0a': {'mcpu': 'cortex-a75'},
> >> +    '0xd0b': {'mcpu': 'cortex-a76'},
> >>     '0xd0c': {
> >>         'march': 'armv8.2-a',
> >>         'march_features': ['crypto', 'rcpc'],
> >> -        'compiler_options':  ['-mcpu=neoverse-n1'],
> >> +        'mcpu': 'neoverse-n1',
> >>         'flags': [
> >>             ['RTE_MACHINE', '"neoverse-n1"'],
> >>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -81,7 +81,7 @@
> >> part_number_config_arm = {
> >>     '0xd40': {
> >>         'march': 'armv8.4-a',
> >>         'march_features': ['sve'],
> >> -        'compiler_options':  ['-mcpu=neoverse-v1'],
> >> +        'mcpu': 'neoverse-v1',
> >>         'flags': [
> >>             ['RTE_MACHINE', '"neoverse-v1"'],
> >>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -92,8 +92,9 @@
> >> part_number_config_arm = {
> >>         'march': 'armv8.4-a',
> >>     },
> >>     '0xd49': {
> >> +        'march': 'armv9-a',
> >>         'march_features': ['sve2'],
> >> -        'compiler_options': ['-mcpu=neoverse-n2'],
> >> +        'mcpu': 'neoverse-n2',
> >>         'flags': [
> >>             ['RTE_MACHINE', '"neoverse-n2"'],
> >>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -127,21 +128,23 @@
> >> implementer_cavium = {
> >>     ],
> >>     'part_number_config': {
> >>         '0xa1': {
> >> -            'compiler_options': ['-mcpu=thunderxt88'],
> >> +            'mcpu': 'thunderxt88',
> >>             'flags': flags_part_number_thunderx
> >>         },
> >>         '0xa2': {
> >> -            'compiler_options': ['-mcpu=thunderxt81'],
> >> +            'mcpu': 'thunderxt81',
> >>             'flags': flags_part_number_thunderx
> >>         },
> >>         '0xa3': {
> >> -            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
> >> +            'march': 'armv8-a',
> >> +            'march_features': ['crc'],
> >> +            'mcpu': 'thunderxt83',
> >>             'flags': flags_part_number_thunderx
> >>         },
> >>         '0xaf': {
> >>             'march': 'armv8.1-a',
> >>             'march_features': ['crc', 'crypto'],
> >> -            'compiler_options': ['-mcpu=thunderx2t99'],
> >> +            'mcpu': 'thunderx2t99',
> >>             'flags': [
> >>                 ['RTE_MACHINE', '"thunderx2"'],
> >>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -153,7 +156,7 @@
> >> implementer_cavium = {
> >>         '0xb2': {
> >>             'march': 'armv8.2-a',
> >>             'march_features': ['crc', 'crypto', 'lse'],
> >> -            'compiler_options': ['-mcpu=octeontx2'],
> >> +            'mcpu': 'octeontx2',
> >>             'flags': [
> >>                 ['RTE_MACHINE', '"cn9k"'],
> >>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -176,7 +179,7 @@
> >> implementer_ampere = {
> >>         '0x0': {
> >>             'march': 'armv8-a',
> >>             'march_features': ['crc', 'crypto'],
> >> -            'compiler_options':  ['-mtune=emag'],
> >> +            'mcpu': 'emag',
> >>             'flags': [
> >>                 ['RTE_MACHINE', '"eMAG"'],
> >>                 ['RTE_MAX_LCORE', 32],
> >> @@ -186,7 +189,7 @@ implementer_ampere = {
> >>         '0xac3': {
> >>             'march': 'armv8.6-a',
> >>             'march_features': ['crc', 'crypto'],
> >> -            'compiler_options':  ['-mcpu=ampere1'],
> >> +            'mcpu': 'ampere1',
> >>             'flags': [
> >>                 ['RTE_MACHINE', '"AmpereOne"'],
> >>                 ['RTE_MAX_LCORE', 320], @@ -206,7 +209,7 @@
> >> implementer_hisilicon = {
> >>         '0xd01': {
> >>             'march': 'armv8.2-a',
> >>             'march_features': ['crypto'],
> >> -            'compiler_options': ['-mtune=tsv110'],
> >> +            'mcpu': 'tsv110',
> >>             'flags': [
> >>                 ['RTE_MACHINE', '"Kunpeng 920"'],
> >>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -695,11 +698,21 @@
> if
> >> update_flags
> >>
> >>     machine_args = [] # Clear previous machine args
> >>
> >> +    candidate_mcpu = ''
> >> +    if part_number_config.has_key('mcpu')
> >> +        mcpu = part_number_config['mcpu']
> >> +        if (cc.has_argument('-mcpu=' + mcpu))
> >> +            candidate_mcpu = mcpu
> >> +        endif
> >> +    endif
> >> +
> >>     # probe supported archs and their features
> >>     candidate_march = ''
> >>     if part_number_config.has_key('march')
> >> -        if part_number_config.get('force_march', false)
> >> -            candidate_march = part_number_config['march']
> >> +        if part_number_config.get('force_march', false) or candidate_mcpu !=
> ''
> >> +            if cc.has_argument('-march=' +  part_number_config['march'])
> >> +                candidate_march = part_number_config['march']
> >> +            endif
> >>         else
> >>             supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> 'armv8.3-
> >> a',
> >>                                 'armv8.2-a', 'armv8.1-a', 'armv8-a'] @@ -717,32 +730,43
> >> @@ if update_flags
> >>                 endif
> >>             endforeach
> >>         endif
> >> -        if candidate_march == ''
> >> -            error('No suitable armv8 march version found.')
> >> -        endif
> >> +
> >>         if candidate_march != part_number_config['march']
> >> -            warning('Configuration march version is ' +
> >> -                    '@0@, but the compiler supports only @1@.'
> >> -                    .format(part_number_config['march'], candidate_march))
> >> +            warning('Configuration march version is @0@, not supported.'
> >> +                    .format(part_number_config['march']))
> >> +            if candidate_march != ''
> >> +                warning('Using march version @0@.'.format(candidate_march))
> >> +            endif
> >>         endif
> >> -        candidate_march = '-march=' + candidate_march
> >>
> >> -        march_features = []
> >> -        if part_number_config.has_key('march_features')
> >> -            march_features += part_number_config['march_features']
> >> -        endif
> >> -        if soc_config.has_key('extra_march_features')
> >> -            march_features += soc_config['extra_march_features']
> >> +        if candidate_march == '' and candidate_mcpu == ''
> >> +            error('No suitable ARM march/mcpu version found.')
> >>         endif
> >> -        foreach feature: march_features
> >> -            if cc.has_argument('+'.join([candidate_march, feature]))
> >> -                candidate_march = '+'.join([candidate_march, feature])
> >> -            else
> >> -                warning('The compiler does not support feature @0@'
> >> -                    .format(feature))
> >> +
> >> +        if candidate_march != ''
> >> +            candidate_march = '-march=' + candidate_march
> >> +            march_features = []
> >> +            if part_number_config.has_key('march_features')
> >> +                march_features += part_number_config['march_features']
> >>             endif
> >> -        endforeach
> >> -        machine_args += candidate_march
> >> +            if soc_config.has_key('extra_march_features')
> >> +                march_features += soc_config['extra_march_features']
> >> +            endif
> >> +            foreach feature: march_features
> >> +                if cc.has_argument('+'.join([candidate_march, feature]))
> >> +                    candidate_march = '+'.join([candidate_march, feature])
> >> +                else
> >> +                    warning('The compiler does not support feature @0@'
> >> +                        .format(feature))
> >> +                endif
> >> +            endforeach
> >> +            machine_args += candidate_march
> >> +        endif
> >> +    endif
> >> +
> >> +    if candidate_mcpu != ''
> >> +        candidate_mcpu = '-mcpu=' + candidate_mcpu
> >> +        machine_args += candidate_mcpu
> >>     endif
> >>
> >>     # apply supported compiler options
> >> --
> >> 2.43.0
> >


^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-06 10:21         ` Pavan Nikhilesh Bhagavatula
@ 2024-02-07  0:01           ` Wathsala Wathawana Vithanage
  2024-02-10  6:49             ` Pavan Nikhilesh Bhagavatula
  0 siblings, 1 reply; 65+ messages in thread
From: Wathsala Wathawana Vithanage @ 2024-02-07  0:01 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula, Honnappa Nagarahalli
  Cc: jerinj, juraj.linkes, Bruce Richardson, dev, nd, nd

> > <wathsala.vithanage@arm.com> wrote:
> > >
> > > Hi Pavan,
> > >
> > >> The compiler options march and mtune are a subset of mcpu and will
> > >> lead
> > to
> > >> conflicts if improper march is chosen for a given mcpu.
> > >> To avoid conflicts, force part number march when mcpu is available
> > >> and is supported by the compiler.
> > >
> > > Why would one force the march specified in the part number when mcpu
> > > for that part number is also available and supported by the compiler?
> > >
> > It would be good to explain the use case or the problem being faced.
> >
> 
> The idea of this patchset is to avoid mcpu and march conflicts that can happen
> with the current build flow.
> 
> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.6-a'
> 
> In some versions of GCC mcpu=neoverse-n2 is supported but -march=armv9-
> a is not so, current build flow will choose the next supported march which is
> armv8.6-a and report a conflict.
> 
If compiler support is available for a certain CPU, then it is safe to assume that the
Compiler knows the best architecture to use.
Therefore, in such cases the best practice is to not provide -march.

> > >>
> > >> Example:
> > >> march = armv9-a
> > >> mcpu = neoverse-n2
> > >>
> > >> mcpu supported, march supported
> > >> machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> > >
> > > -march restricts the compiler to baseline architecture of the -mcpu.
> > > For instance, Neoverse-n1's baseline architecture is armv8.2-a, but
> > > it has some extensions from armv8.3-a, armv8.4-a, and armv8.5-a.
> > > By setting -march to armv8.2-a the compiler will strictly omit
> > > extensions from 8.3, 8.4 and 8.5 resulting in a suboptimal outcome.
> 
> What if compiler only supports armv8.2-a?
> Are you suggesting we don’t use march at all when mcpu is supported?
> If so how do you express extensions that the SoC supports?
> Neoverse-n2 has optional support for crypto and can only be enabled by
> expressing it through march='armv9-a+crypto'
> 
March extensions also works with mcpu, use mcpu=neoverse-n2+crypto
instead of march.  It's documented in "-march and -mcpu Feature Modifiers"
section in gcc manual.

> > >
> > >>
> > >> mcpu supported, march not supported machine_args =
> > >> ['-mcpu=neoverse-n2']
> > >
> > > This will result in the best outcome.
> 
> Isn't -mcpu=neoverse-n2 -march=armv9-a+sve2+crypto also the best
> outcome?
> 
Here also we can append feature modifiers like sve2 and crypto to CPU in
-mcpu and drop -march arg.
If the compiler supports neoverse-n2 but not armv9-a it will pick the next
best architecture. 
-mcpu=neoverse-n2+sve2+crypto can replace - march=armv9-a+sve2+crypto

> > >
> > >>
> > >> mcpu not supported, march supported machine_args =
> > >> ['-march=armv9-a']
> > >
> > > This too may result in a suboptimal outcome as optimization space is
> > > limited to the given march (not using extensions from later
> > > architectures when available).
> > >
> 
> What if compiler doesn’t support mcpu=neoverse-n2 and only supports
> march=armv9-a
> 
I agree there can be such corner cases where CPU enablement isn't done.
Such cases can be handled with a new meson build parameter like 
-Dplatform=generic-armv9 to build armv9-a binaries (similar to 
-Dplatform=generic that builds armv8-a binaries today).
Having such parameter forces the user to make a conscious decision rather 
than build system doing it for them.
It also comes with the added benefit of having a simpler build system.

> > >>
> > >> mcpu not supported, march not supported machine_args =
> > >> ['-march=armv8.6-a']
> > >
> > > Compiler knows nothing about the target CPU or the architecture.
> > > I think it's better to exit the build process with an error.
> > >
> 
> Then we would need to mark all old GCC versions as not supported by a newer
> SoC I don’t think that’s needed since the binaries still run but not optimally,
> currently we have a warning in place for march mismatch.
> 
We don't have to deprecate older versions of GCC.
I'm suggesting two options to let the user have greater autonomy on
the kind of the binary they want rather than ending up with a binary
the build system forced on them.
Today -Dplatform=generic does something similar to this with armv8,
it simply directs the build system to output an armv8 without any extras. 
First suggestion is that we simply have a -Dplatform=generic-armv9 that
does the same but for armv9.
The second suggestion is to empower a sophisticated user even further
to override everything in the build system including generics via two 
parameters -Dmarch and -Dmcpu to set an arbitrary architecture and a cpu.
Second option works as a catch-all for every unorthodox request that may
come our way. Both these features can be suggested when build exits due
to compiler not knowing the target CPU or the architecture.
I think these parameters keep user in charge with a simpler build system.

> > >>
> > >> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > >> ---
> > >> v2 Changes:
> > >> - Cleanup march inconsistencies. (Juraj Linkes)
> > >> - Unify fallback march selection. (Juraj Linkes)
> > >> - Tag along ARM WFE patch.
> > >> v3 Changes:
> > >> - Fix missing 'fallback_march' key check.
> > >>
> > >> config/arm/meson.build | 108 +++++++++++++++++++++++++-----------
> --
> > --
> > >> -
> > >> 1 file changed, 66 insertions(+), 42 deletions(-)
> > >>
> > >> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> > >> 36f21d22599a..ba859bd060b5 100644
> > >> --- a/config/arm/meson.build
> > >> +++ b/config/arm/meson.build
> > >> @@ -58,18 +58,18 @@ implementer_generic = {  }
> > >>
> > >> part_number_config_arm = {
> > >> -    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
> > >> -    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
> > >> -    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
> > >> -    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
> > >> -    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
> > >> -    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
> > >> -    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
> > >> -    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
> > >> +    '0xd03': {'mcpu': 'cortex-a53'},
> > >> +    '0xd04': {'mcpu': 'cortex-a35'},
> > >> +    '0xd05': {'mcpu': 'cortex-a55'},
> > >> +    '0xd07': {'mcpu': 'cortex-a57'},
> > >> +    '0xd08': {'mcpu': 'cortex-a72'},
> > >> +    '0xd09': {'mcpu': 'cortex-a73'},
> > >> +    '0xd0a': {'mcpu': 'cortex-a75'},
> > >> +    '0xd0b': {'mcpu': 'cortex-a76'},
> > >>     '0xd0c': {
> > >>         'march': 'armv8.2-a',
> > >>         'march_features': ['crypto', 'rcpc'],
> > >> -        'compiler_options':  ['-mcpu=neoverse-n1'],
> > >> +        'mcpu': 'neoverse-n1',
> > >>         'flags': [
> > >>             ['RTE_MACHINE', '"neoverse-n1"'],
> > >>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -81,7 +81,7 @@
> > >> part_number_config_arm = {
> > >>     '0xd40': {
> > >>         'march': 'armv8.4-a',
> > >>         'march_features': ['sve'],
> > >> -        'compiler_options':  ['-mcpu=neoverse-v1'],
> > >> +        'mcpu': 'neoverse-v1',
> > >>         'flags': [
> > >>             ['RTE_MACHINE', '"neoverse-v1"'],
> > >>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -92,8 +92,9 @@
> > >> part_number_config_arm = {
> > >>         'march': 'armv8.4-a',
> > >>     },
> > >>     '0xd49': {
> > >> +        'march': 'armv9-a',
> > >>         'march_features': ['sve2'],
> > >> -        'compiler_options': ['-mcpu=neoverse-n2'],
> > >> +        'mcpu': 'neoverse-n2',
> > >>         'flags': [
> > >>             ['RTE_MACHINE', '"neoverse-n2"'],
> > >>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -127,21 +128,23
> > >> @@ implementer_cavium = {
> > >>     ],
> > >>     'part_number_config': {
> > >>         '0xa1': {
> > >> -            'compiler_options': ['-mcpu=thunderxt88'],
> > >> +            'mcpu': 'thunderxt88',
> > >>             'flags': flags_part_number_thunderx
> > >>         },
> > >>         '0xa2': {
> > >> -            'compiler_options': ['-mcpu=thunderxt81'],
> > >> +            'mcpu': 'thunderxt81',
> > >>             'flags': flags_part_number_thunderx
> > >>         },
> > >>         '0xa3': {
> > >> -            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
> > >> +            'march': 'armv8-a',
> > >> +            'march_features': ['crc'],
> > >> +            'mcpu': 'thunderxt83',
> > >>             'flags': flags_part_number_thunderx
> > >>         },
> > >>         '0xaf': {
> > >>             'march': 'armv8.1-a',
> > >>             'march_features': ['crc', 'crypto'],
> > >> -            'compiler_options': ['-mcpu=thunderx2t99'],
> > >> +            'mcpu': 'thunderx2t99',
> > >>             'flags': [
> > >>                 ['RTE_MACHINE', '"thunderx2"'],
> > >>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -153,7 +156,7
> > >> @@ implementer_cavium = {
> > >>         '0xb2': {
> > >>             'march': 'armv8.2-a',
> > >>             'march_features': ['crc', 'crypto', 'lse'],
> > >> -            'compiler_options': ['-mcpu=octeontx2'],
> > >> +            'mcpu': 'octeontx2',
> > >>             'flags': [
> > >>                 ['RTE_MACHINE', '"cn9k"'],
> > >>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -176,7 +179,7
> > >> @@ implementer_ampere = {
> > >>         '0x0': {
> > >>             'march': 'armv8-a',
> > >>             'march_features': ['crc', 'crypto'],
> > >> -            'compiler_options':  ['-mtune=emag'],
> > >> +            'mcpu': 'emag',
> > >>             'flags': [
> > >>                 ['RTE_MACHINE', '"eMAG"'],
> > >>                 ['RTE_MAX_LCORE', 32], @@ -186,7 +189,7 @@
> > >> implementer_ampere = {
> > >>         '0xac3': {
> > >>             'march': 'armv8.6-a',
> > >>             'march_features': ['crc', 'crypto'],
> > >> -            'compiler_options':  ['-mcpu=ampere1'],
> > >> +            'mcpu': 'ampere1',
> > >>             'flags': [
> > >>                 ['RTE_MACHINE', '"AmpereOne"'],
> > >>                 ['RTE_MAX_LCORE', 320], @@ -206,7 +209,7 @@
> > >> implementer_hisilicon = {
> > >>         '0xd01': {
> > >>             'march': 'armv8.2-a',
> > >>             'march_features': ['crypto'],
> > >> -            'compiler_options': ['-mtune=tsv110'],
> > >> +            'mcpu': 'tsv110',
> > >>             'flags': [
> > >>                 ['RTE_MACHINE', '"Kunpeng 920"'],
> > >>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -695,11
> > >> +698,21 @@
> > if
> > >> update_flags
> > >>
> > >>     machine_args = [] # Clear previous machine args
> > >>
> > >> +    candidate_mcpu = ''
> > >> +    if part_number_config.has_key('mcpu')
> > >> +        mcpu = part_number_config['mcpu']
> > >> +        if (cc.has_argument('-mcpu=' + mcpu))
> > >> +            candidate_mcpu = mcpu
> > >> +        endif
> > >> +    endif
> > >> +
> > >>     # probe supported archs and their features
> > >>     candidate_march = ''
> > >>     if part_number_config.has_key('march')
> > >> -        if part_number_config.get('force_march', false)
> > >> -            candidate_march = part_number_config['march']
> > >> +        if part_number_config.get('force_march', false) or
> > >> + candidate_mcpu !=
> > ''
> > >> +            if cc.has_argument('-march=' +  part_number_config['march'])
> > >> +                candidate_march = part_number_config['march']
> > >> +            endif
> > >>         else
> > >>             supported_marchs = ['armv8.6-a', 'armv8.5-a',
> > >> 'armv8.4-a',
> > 'armv8.3-
> > >> a',
> > >>                                 'armv8.2-a', 'armv8.1-a',
> > >> 'armv8-a'] @@ -717,32 +730,43 @@ if update_flags
> > >>                 endif
> > >>             endforeach
> > >>         endif
> > >> -        if candidate_march == ''
> > >> -            error('No suitable armv8 march version found.')
> > >> -        endif
> > >> +
> > >>         if candidate_march != part_number_config['march']
> > >> -            warning('Configuration march version is ' +
> > >> -                    '@0@, but the compiler supports only @1@.'
> > >> -                    .format(part_number_config['march'], candidate_march))
> > >> +            warning('Configuration march version is @0@, not supported.'
> > >> +                    .format(part_number_config['march']))
> > >> +            if candidate_march != ''
> > >> +                warning('Using march version @0@.'.format(candidate_march))
> > >> +            endif
> > >>         endif
> > >> -        candidate_march = '-march=' + candidate_march
> > >>
> > >> -        march_features = []
> > >> -        if part_number_config.has_key('march_features')
> > >> -            march_features += part_number_config['march_features']
> > >> -        endif
> > >> -        if soc_config.has_key('extra_march_features')
> > >> -            march_features += soc_config['extra_march_features']
> > >> +        if candidate_march == '' and candidate_mcpu == ''
> > >> +            error('No suitable ARM march/mcpu version found.')
> > >>         endif
> > >> -        foreach feature: march_features
> > >> -            if cc.has_argument('+'.join([candidate_march, feature]))
> > >> -                candidate_march = '+'.join([candidate_march, feature])
> > >> -            else
> > >> -                warning('The compiler does not support feature @0@'
> > >> -                    .format(feature))
> > >> +
> > >> +        if candidate_march != ''
> > >> +            candidate_march = '-march=' + candidate_march
> > >> +            march_features = []
> > >> +            if part_number_config.has_key('march_features')
> > >> +                march_features +=
> > >> + part_number_config['march_features']
> > >>             endif
> > >> -        endforeach
> > >> -        machine_args += candidate_march
> > >> +            if soc_config.has_key('extra_march_features')
> > >> +                march_features += soc_config['extra_march_features']
> > >> +            endif
> > >> +            foreach feature: march_features
> > >> +                if cc.has_argument('+'.join([candidate_march, feature]))
> > >> +                    candidate_march = '+'.join([candidate_march, feature])
> > >> +                else
> > >> +                    warning('The compiler does not support feature @0@'
> > >> +                        .format(feature))
> > >> +                endif
> > >> +            endforeach
> > >> +            machine_args += candidate_march
> > >> +        endif
> > >> +    endif
> > >> +
> > >> +    if candidate_mcpu != ''
> > >> +        candidate_mcpu = '-mcpu=' + candidate_mcpu
> > >> +        machine_args += candidate_mcpu
> > >>     endif
> > >>
> > >>     # apply supported compiler options
> > >> --
> > >> 2.43.0
> > >


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 3/3] config/arm: allow WFE to be enabled config time
  2024-02-01 21:57   ` [PATCH v2 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
@ 2024-02-07  2:55     ` Honnappa Nagarahalli
  2024-02-10  6:47       ` Pavan Nikhilesh Bhagavatula
  0 siblings, 1 reply; 65+ messages in thread
From: Honnappa Nagarahalli @ 2024-02-07  2:55 UTC (permalink / raw)
  To: pbhagavatula
  Cc: jerinj, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson, dev,
	Chengwen Feng, Wathsala Wathawana Vithanage, Dhruv Tripathi



> On Feb 1, 2024, at 3:57 PM, pbhagavatula@marvell.com wrote:
> 
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Allow RTE_ARM_USE_WFE to be enabled at meson configuration
> time by passing it via c_args instead of modifying
> `config/arm/meson.build`.
> 
> Example usage:
> meson build -Dc_args='-DRTE_ARM_USE_WFE' \
> --cross-file config/arm/arm64_cn10k_linux_gcc
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> Acked-by: Chengwen Feng <fengchengwen@huawei.com>
> Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---
> config/arm/meson.build | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 6f2308f2fa..3467bef466 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -17,7 +17,9 @@ flags_common = [
>         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
>         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
> 
> -        ['RTE_ARM_USE_WFE', false],
> +        # Enable use of ARM wait for event instruction.
> +        # ['RTE_ARM_USE_WFE', false],
> +
So, what is the default value for RTE_ARM_USE_WFE if the user does not pass the flag at the command line?

Can we do it such a way that the flag passed on the command line takes precedence?

>         ['RTE_ARCH_ARM64', true],
>         ['RTE_CACHE_LINE_SIZE', 128]
> ]
> -- 
> 2.25.1
> 


^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [PATCH v3 2/3] config/arm: add support for fallback march
  2024-02-02  8:50     ` [PATCH v3 2/3] config/arm: add support for fallback march pbhagavatula
@ 2024-02-07 20:24       ` Wathsala Wathawana Vithanage
  0 siblings, 0 replies; 65+ messages in thread
From: Wathsala Wathawana Vithanage @ 2024-02-07 20:24 UTC (permalink / raw)
  To: pbhagavatula, jerinj, juraj.linkes, Bruce Richardson
  Cc: dev, Honnappa Nagarahalli, nd, nd



> 
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Some ARM CPUs have specific march requirements and are not compatible
> with the supported march list.
> Add fallback march in case the mcpu and the march advertised in the
> part_number_config are not supported by the compiler.
> 
> Example
>         mcpu = neoverse-n2
>         march = armv9-a
>         fallback_march = armv8.5-a
> 
>         mcpu, march not supported
>         machine_args = ['-march=armv8.5-a']
> 
>         mcpu, march, fallback_march not supported
>         least march supported = armv8-a
> 
>         machine_args = ['-march=armv8-a']
> 

Similar to "[v3,1/3] config/arm: avoid mcpu and march conflicts" here
also we can avoid selecting march if it's not supported by the compiler.
Ideally, we should exit the build with an error saying march/mcpu is not
supported and suggest further actions (like trying again with 
-Dmarch -Dmcpu or -Dplatform=generic-armv9 as discussed in [v3,1/3])

> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  config/arm/meson.build | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> ba859bd060b5..4e44d1850bae 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -94,6 +94,7 @@ part_number_config_arm = {
>      '0xd49': {
>          'march': 'armv9-a',
>          'march_features': ['sve2'],
> +        'fallback_march': 'armv8.5-a',
>          'mcpu': 'neoverse-n2',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'], @@ -708,6 +709,7 @@ if
> update_flags
> 
>      # probe supported archs and their features
>      candidate_march = ''
> +    fallback_march = ''
>      if part_number_config.has_key('march')
>          if part_number_config.get('force_march', false) or candidate_mcpu != ''
>              if cc.has_argument('-march=' +  part_number_config['march']) @@ -
> 728,10 +730,18 @@ if update_flags
>                      # highest supported march version found
>                      break
>                  endif
> +                if (part_number_config.has_key('fallback_march') and
> +                    supported_march == part_number_config['fallback_march'] and
> +                    cc.has_argument('-march=' + supported_march))
> +                    fallback_march = supported_march
> +                endif
>              endforeach
>          endif
> 
>          if candidate_march != part_number_config['march']
> +            if fallback_march != ''
> +                candidate_march = fallback_march
> +            endif
>              warning('Configuration march version is @0@, not supported.'
>                      .format(part_number_config['march']))
>              if candidate_march != ''
> --
> 2.43.0


^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [PATCH v2 3/3] config/arm: allow WFE to be enabled config time
  2024-02-07  2:55     ` Honnappa Nagarahalli
@ 2024-02-10  6:47       ` Pavan Nikhilesh Bhagavatula
  2024-02-10 16:36         ` Honnappa Nagarahalli
  0 siblings, 1 reply; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-02-10  6:47 UTC (permalink / raw)
  To: Honnappa Nagarahalli
  Cc: Jerin Jacob, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson,
	dev, Chengwen Feng, Wathsala Wathawana Vithanage, Dhruv Tripathi

> > On Feb 1, 2024, at 3:57 PM, pbhagavatula@marvell.com wrote:
> >
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > Allow RTE_ARM_USE_WFE to be enabled at meson configuration
> > time by passing it via c_args instead of modifying
> > `config/arm/meson.build`.
> >
> > Example usage:
> > meson build -Dc_args='-DRTE_ARM_USE_WFE' \
> > --cross-file config/arm/arm64_cn10k_linux_gcc
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > Acked-by: Chengwen Feng <fengchengwen@huawei.com>
> > Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > ---
> > config/arm/meson.build | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > index 6f2308f2fa..3467bef466 100644
> > --- a/config/arm/meson.build
> > +++ b/config/arm/meson.build
> > @@ -17,7 +17,9 @@ flags_common = [
> >         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
> >         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
> >
> > -        ['RTE_ARM_USE_WFE', false],
> > +        # Enable use of ARM wait for event instruction.
> > +        # ['RTE_ARM_USE_WFE', false],
> > +
> So, what is the default value for RTE_ARM_USE_WFE if the user does not pass
> the flag at the command line?
> 

All the checks related to RTE_ARM_USE_WFE see if it is defined or not

#rg "RTE_ARM_USE_WFE"                     
config/arm/meson.build
20:        ['RTE_ARM_USE_WFE', false],
lib/eal/arm/rte_cpuflags.c
166:#ifdef RTE_ARM_USE_WFE
lib/eal/arm/include/rte_pause_64.h
15:#ifdef RTE_ARM_USE_WFE
lib/eal/arm/rte_power_intrinsics.c
20:#ifdef RTE_ARM_USE_WFE
84:#ifdef RTE_ARM_USE_WFE

So default value would be not-defined.

> Can we do it such a way that the flag passed on the command line takes
> precedence?

No, we can't have checks based on flags passed via -Dc_args with the current meson(needs build_options() from 1.1.0).
Only option is to add via meson_option.txt which is not optimal for arch settings.

> 
> >         ['RTE_ARCH_ARM64', true],
> >         ['RTE_CACHE_LINE_SIZE', 128]
> > ]
> > --
> > 2.25.1
> >


^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-07  0:01           ` Wathsala Wathawana Vithanage
@ 2024-02-10  6:49             ` Pavan Nikhilesh Bhagavatula
  2024-02-10 15:20               ` Honnappa Nagarahalli
  0 siblings, 1 reply; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-02-10  6:49 UTC (permalink / raw)
  To: Wathsala Wathawana Vithanage, Honnappa Nagarahalli
  Cc: Jerin Jacob, juraj.linkes, Bruce Richardson, dev, nd, nd


> > > <wathsala.vithanage@arm.com> wrote:
> > > >
> > > > Hi Pavan,
> > > >
> > > >> The compiler options march and mtune are a subset of mcpu and will
> > > >> lead
> > > to
> > > >> conflicts if improper march is chosen for a given mcpu.
> > > >> To avoid conflicts, force part number march when mcpu is available
> > > >> and is supported by the compiler.
> > > >
> > > > Why would one force the march specified in the part number when mcpu
> > > > for that part number is also available and supported by the compiler?
> > > >
> > > It would be good to explain the use case or the problem being faced.
> > >
> >
> > The idea of this patchset is to avoid mcpu and march conflicts that can
> happen
> > with the current build flow.
> >
> > #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
> > cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.6-a'
> >
> > In some versions of GCC mcpu=neoverse-n2 is supported but -
> march=armv9-
> > a is not so, current build flow will choose the next supported march which is
> > armv8.6-a and report a conflict.
> >
> If compiler support is available for a certain CPU, then it is safe to assume that
> the
> Compiler knows the best architecture to use.
> Therefore, in such cases the best practice is to not provide -march.
> 

Ok, this deviates a lot from the current build flow, I will rework and send a v4. 

> > > >>
> > > >> Example:
> > > >> march = armv9-a
> > > >> mcpu = neoverse-n2
> > > >>
> > > >> mcpu supported, march supported
> > > >> machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
> > > >
> > > > -march restricts the compiler to baseline architecture of the -mcpu.
> > > > For instance, Neoverse-n1's baseline architecture is armv8.2-a, but
> > > > it has some extensions from armv8.3-a, armv8.4-a, and armv8.5-a.
> > > > By setting -march to armv8.2-a the compiler will strictly omit
> > > > extensions from 8.3, 8.4 and 8.5 resulting in a suboptimal outcome.
> >
> > What if compiler only supports armv8.2-a?
> > Are you suggesting we don’t use march at all when mcpu is supported?
> > If so how do you express extensions that the SoC supports?
> > Neoverse-n2 has optional support for crypto and can only be enabled by
> > expressing it through march='armv9-a+crypto'
> >
> March extensions also works with mcpu, use mcpu=neoverse-n2+crypto
> instead of march.  It's documented in "-march and -mcpu Feature Modifiers"
> section in gcc manual.
> 
> > > >
> > > >>
> > > >> mcpu supported, march not supported machine_args =
> > > >> ['-mcpu=neoverse-n2']
> > > >
> > > > This will result in the best outcome.
> >
> > Isn't -mcpu=neoverse-n2 -march=armv9-a+sve2+crypto also the best
> > outcome?
> >
> Here also we can append feature modifiers like sve2 and crypto to CPU in
> -mcpu and drop -march arg.
> If the compiler supports neoverse-n2 but not armv9-a it will pick the next
> best architecture.
> -mcpu=neoverse-n2+sve2+crypto can replace - march=armv9-a+sve2+crypto
> 
> > > >
> > > >>
> > > >> mcpu not supported, march supported machine_args =
> > > >> ['-march=armv9-a']
> > > >
> > > > This too may result in a suboptimal outcome as optimization space is
> > > > limited to the given march (not using extensions from later
> > > > architectures when available).
> > > >
> >
> > What if compiler doesn’t support mcpu=neoverse-n2 and only supports
> > march=armv9-a
> >
> I agree there can be such corner cases where CPU enablement isn't done.
> Such cases can be handled with a new meson build parameter like
> -Dplatform=generic-armv9 to build armv9-a binaries (similar to
> -Dplatform=generic that builds armv8-a binaries today).
> Having such parameter forces the user to make a conscious decision rather
> than build system doing it for them.
> It also comes with the added benefit of having a simpler build system.
> 
> > > >>
> > > >> mcpu not supported, march not supported machine_args =
> > > >> ['-march=armv8.6-a']
> > > >
> > > > Compiler knows nothing about the target CPU or the architecture.
> > > > I think it's better to exit the build process with an error.
> > > >
> >
> > Then we would need to mark all old GCC versions as not supported by a
> newer
> > SoC I don’t think that’s needed since the binaries still run but not optimally,
> > currently we have a warning in place for march mismatch.
> >
> We don't have to deprecate older versions of GCC.
> I'm suggesting two options to let the user have greater autonomy on
> the kind of the binary they want rather than ending up with a binary
> the build system forced on them.
> Today -Dplatform=generic does something similar to this with armv8,
> it simply directs the build system to output an armv8 without any extras.
> First suggestion is that we simply have a -Dplatform=generic-armv9 that
> does the same but for armv9.
> The second suggestion is to empower a sophisticated user even further
> to override everything in the build system including generics via two
> parameters -Dmarch and -Dmcpu to set an arbitrary architecture and a cpu.
> Second option works as a catch-all for every unorthodox request that may
> come our way. Both these features can be suggested when build exits due
> to compiler not knowing the target CPU or the architecture.
> I think these parameters keep user in charge with a simpler build system.
> 
> > > >>
> > > >> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > >> ---
> > > >> v2 Changes:
> > > >> - Cleanup march inconsistencies. (Juraj Linkes)
> > > >> - Unify fallback march selection. (Juraj Linkes)
> > > >> - Tag along ARM WFE patch.
> > > >> v3 Changes:
> > > >> - Fix missing 'fallback_march' key check.
> > > >>
> > > >> config/arm/meson.build | 108 +++++++++++++++++++++++++---------
> --
> > --
> > > --
> > > >> -
> > > >> 1 file changed, 66 insertions(+), 42 deletions(-)
> > > >>
> > > >> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> > > >> 36f21d22599a..ba859bd060b5 100644
> > > >> --- a/config/arm/meson.build
> > > >> +++ b/config/arm/meson.build
> > > >> @@ -58,18 +58,18 @@ implementer_generic = {  }
> > > >>
> > > >> part_number_config_arm = {
> > > >> -    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
> > > >> -    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
> > > >> -    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
> > > >> -    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
> > > >> -    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
> > > >> -    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
> > > >> -    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
> > > >> -    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
> > > >> +    '0xd03': {'mcpu': 'cortex-a53'},
> > > >> +    '0xd04': {'mcpu': 'cortex-a35'},
> > > >> +    '0xd05': {'mcpu': 'cortex-a55'},
> > > >> +    '0xd07': {'mcpu': 'cortex-a57'},
> > > >> +    '0xd08': {'mcpu': 'cortex-a72'},
> > > >> +    '0xd09': {'mcpu': 'cortex-a73'},
> > > >> +    '0xd0a': {'mcpu': 'cortex-a75'},
> > > >> +    '0xd0b': {'mcpu': 'cortex-a76'},
> > > >>     '0xd0c': {
> > > >>         'march': 'armv8.2-a',
> > > >>         'march_features': ['crypto', 'rcpc'],
> > > >> -        'compiler_options':  ['-mcpu=neoverse-n1'],
> > > >> +        'mcpu': 'neoverse-n1',
> > > >>         'flags': [
> > > >>             ['RTE_MACHINE', '"neoverse-n1"'],
> > > >>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -81,7 +81,7 @@
> > > >> part_number_config_arm = {
> > > >>     '0xd40': {
> > > >>         'march': 'armv8.4-a',
> > > >>         'march_features': ['sve'],
> > > >> -        'compiler_options':  ['-mcpu=neoverse-v1'],
> > > >> +        'mcpu': 'neoverse-v1',
> > > >>         'flags': [
> > > >>             ['RTE_MACHINE', '"neoverse-v1"'],
> > > >>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -92,8 +92,9 @@
> > > >> part_number_config_arm = {
> > > >>         'march': 'armv8.4-a',
> > > >>     },
> > > >>     '0xd49': {
> > > >> +        'march': 'armv9-a',
> > > >>         'march_features': ['sve2'],
> > > >> -        'compiler_options': ['-mcpu=neoverse-n2'],
> > > >> +        'mcpu': 'neoverse-n2',
> > > >>         'flags': [
> > > >>             ['RTE_MACHINE', '"neoverse-n2"'],
> > > >>             ['RTE_ARM_FEATURE_ATOMICS', true], @@ -127,21 +128,23
> > > >> @@ implementer_cavium = {
> > > >>     ],
> > > >>     'part_number_config': {
> > > >>         '0xa1': {
> > > >> -            'compiler_options': ['-mcpu=thunderxt88'],
> > > >> +            'mcpu': 'thunderxt88',
> > > >>             'flags': flags_part_number_thunderx
> > > >>         },
> > > >>         '0xa2': {
> > > >> -            'compiler_options': ['-mcpu=thunderxt81'],
> > > >> +            'mcpu': 'thunderxt81',
> > > >>             'flags': flags_part_number_thunderx
> > > >>         },
> > > >>         '0xa3': {
> > > >> -            'compiler_options': ['-march=armv8-a+crc', '-
> mcpu=thunderxt83'],
> > > >> +            'march': 'armv8-a',
> > > >> +            'march_features': ['crc'],
> > > >> +            'mcpu': 'thunderxt83',
> > > >>             'flags': flags_part_number_thunderx
> > > >>         },
> > > >>         '0xaf': {
> > > >>             'march': 'armv8.1-a',
> > > >>             'march_features': ['crc', 'crypto'],
> > > >> -            'compiler_options': ['-mcpu=thunderx2t99'],
> > > >> +            'mcpu': 'thunderx2t99',
> > > >>             'flags': [
> > > >>                 ['RTE_MACHINE', '"thunderx2"'],
> > > >>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -153,7 +156,7
> > > >> @@ implementer_cavium = {
> > > >>         '0xb2': {
> > > >>             'march': 'armv8.2-a',
> > > >>             'march_features': ['crc', 'crypto', 'lse'],
> > > >> -            'compiler_options': ['-mcpu=octeontx2'],
> > > >> +            'mcpu': 'octeontx2',
> > > >>             'flags': [
> > > >>                 ['RTE_MACHINE', '"cn9k"'],
> > > >>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -176,7 +179,7
> > > >> @@ implementer_ampere = {
> > > >>         '0x0': {
> > > >>             'march': 'armv8-a',
> > > >>             'march_features': ['crc', 'crypto'],
> > > >> -            'compiler_options':  ['-mtune=emag'],
> > > >> +            'mcpu': 'emag',
> > > >>             'flags': [
> > > >>                 ['RTE_MACHINE', '"eMAG"'],
> > > >>                 ['RTE_MAX_LCORE', 32], @@ -186,7 +189,7 @@
> > > >> implementer_ampere = {
> > > >>         '0xac3': {
> > > >>             'march': 'armv8.6-a',
> > > >>             'march_features': ['crc', 'crypto'],
> > > >> -            'compiler_options':  ['-mcpu=ampere1'],
> > > >> +            'mcpu': 'ampere1',
> > > >>             'flags': [
> > > >>                 ['RTE_MACHINE', '"AmpereOne"'],
> > > >>                 ['RTE_MAX_LCORE', 320], @@ -206,7 +209,7 @@
> > > >> implementer_hisilicon = {
> > > >>         '0xd01': {
> > > >>             'march': 'armv8.2-a',
> > > >>             'march_features': ['crypto'],
> > > >> -            'compiler_options': ['-mtune=tsv110'],
> > > >> +            'mcpu': 'tsv110',
> > > >>             'flags': [
> > > >>                 ['RTE_MACHINE', '"Kunpeng 920"'],
> > > >>                 ['RTE_ARM_FEATURE_ATOMICS', true], @@ -695,11
> > > >> +698,21 @@
> > > if
> > > >> update_flags
> > > >>
> > > >>     machine_args = [] # Clear previous machine args
> > > >>
> > > >> +    candidate_mcpu = ''
> > > >> +    if part_number_config.has_key('mcpu')
> > > >> +        mcpu = part_number_config['mcpu']
> > > >> +        if (cc.has_argument('-mcpu=' + mcpu))
> > > >> +            candidate_mcpu = mcpu
> > > >> +        endif
> > > >> +    endif
> > > >> +
> > > >>     # probe supported archs and their features
> > > >>     candidate_march = ''
> > > >>     if part_number_config.has_key('march')
> > > >> -        if part_number_config.get('force_march', false)
> > > >> -            candidate_march = part_number_config['march']
> > > >> +        if part_number_config.get('force_march', false) or
> > > >> + candidate_mcpu !=
> > > ''
> > > >> +            if cc.has_argument('-march=' +  part_number_config['march'])
> > > >> +                candidate_march = part_number_config['march']
> > > >> +            endif
> > > >>         else
> > > >>             supported_marchs = ['armv8.6-a', 'armv8.5-a',
> > > >> 'armv8.4-a',
> > > 'armv8.3-
> > > >> a',
> > > >>                                 'armv8.2-a', 'armv8.1-a',
> > > >> 'armv8-a'] @@ -717,32 +730,43 @@ if update_flags
> > > >>                 endif
> > > >>             endforeach
> > > >>         endif
> > > >> -        if candidate_march == ''
> > > >> -            error('No suitable armv8 march version found.')
> > > >> -        endif
> > > >> +
> > > >>         if candidate_march != part_number_config['march']
> > > >> -            warning('Configuration march version is ' +
> > > >> -                    '@0@, but the compiler supports only @1@.'
> > > >> -                    .format(part_number_config['march'], candidate_march))
> > > >> +            warning('Configuration march version is @0@, not supported.'
> > > >> +                    .format(part_number_config['march']))
> > > >> +            if candidate_march != ''
> > > >> +                warning('Using march version
> @0@.'.format(candidate_march))
> > > >> +            endif
> > > >>         endif
> > > >> -        candidate_march = '-march=' + candidate_march
> > > >>
> > > >> -        march_features = []
> > > >> -        if part_number_config.has_key('march_features')
> > > >> -            march_features += part_number_config['march_features']
> > > >> -        endif
> > > >> -        if soc_config.has_key('extra_march_features')
> > > >> -            march_features += soc_config['extra_march_features']
> > > >> +        if candidate_march == '' and candidate_mcpu == ''
> > > >> +            error('No suitable ARM march/mcpu version found.')
> > > >>         endif
> > > >> -        foreach feature: march_features
> > > >> -            if cc.has_argument('+'.join([candidate_march, feature]))
> > > >> -                candidate_march = '+'.join([candidate_march, feature])
> > > >> -            else
> > > >> -                warning('The compiler does not support feature @0@'
> > > >> -                    .format(feature))
> > > >> +
> > > >> +        if candidate_march != ''
> > > >> +            candidate_march = '-march=' + candidate_march
> > > >> +            march_features = []
> > > >> +            if part_number_config.has_key('march_features')
> > > >> +                march_features +=
> > > >> + part_number_config['march_features']
> > > >>             endif
> > > >> -        endforeach
> > > >> -        machine_args += candidate_march
> > > >> +            if soc_config.has_key('extra_march_features')
> > > >> +                march_features += soc_config['extra_march_features']
> > > >> +            endif
> > > >> +            foreach feature: march_features
> > > >> +                if cc.has_argument('+'.join([candidate_march, feature]))
> > > >> +                    candidate_march = '+'.join([candidate_march, feature])
> > > >> +                else
> > > >> +                    warning('The compiler does not support feature @0@'
> > > >> +                        .format(feature))
> > > >> +                endif
> > > >> +            endforeach
> > > >> +            machine_args += candidate_march
> > > >> +        endif
> > > >> +    endif
> > > >> +
> > > >> +    if candidate_mcpu != ''
> > > >> +        candidate_mcpu = '-mcpu=' + candidate_mcpu
> > > >> +        machine_args += candidate_mcpu
> > > >>     endif
> > > >>
> > > >>     # apply supported compiler options
> > > >> --
> > > >> 2.43.0
> > > >


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-10  6:49             ` Pavan Nikhilesh Bhagavatula
@ 2024-02-10 15:20               ` Honnappa Nagarahalli
  2024-02-10 17:21                 ` Honnappa Nagarahalli
  0 siblings, 1 reply; 65+ messages in thread
From: Honnappa Nagarahalli @ 2024-02-10 15:20 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula
  Cc: Wathsala Wathawana Vithanage, jerinj, juraj.linkes,
	Bruce Richardson, dev, nd



> On Feb 10, 2024, at 12:49 AM, Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com> wrote:
> 
> 
>>>> <wathsala.vithanage@arm.com> wrote:
>>>>> 
>>>>> Hi Pavan,
>>>>> 
>>>>>> The compiler options march and mtune are a subset of mcpu and will
>>>>>> lead
>>>> to
>>>>>> conflicts if improper march is chosen for a given mcpu.
>>>>>> To avoid conflicts, force part number march when mcpu is available
>>>>>> and is supported by the compiler.
>>>>> 
>>>>> Why would one force the march specified in the part number when mcpu
>>>>> for that part number is also available and supported by the compiler?
>>>>> 
>>>> It would be good to explain the use case or the problem being faced.
>>>> 
>>> 
>>> The idea of this patchset is to avoid mcpu and march conflicts that can
>> happen
>>> with the current build flow.
>>> 
>>> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
>>> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.6-a'
>>> 
>>> In some versions of GCC mcpu=neoverse-n2 is supported but -
>> march=armv9-
>>> a is not so, current build flow will choose the next supported march which is
>>> armv8.6-a and report a conflict.
>>> 
>> If compiler support is available for a certain CPU, then it is safe to assume that
>> the
>> Compiler knows the best architecture to use.
>> Therefore, in such cases the best practice is to not provide -march.
>> 
> 
> Ok, this deviates a lot from the current build flow, I will rework and send a v4. 
> 
The overall goal is to ensure the user knows that they are making suboptimal choices. We will do some canned build configurations as follows:

1) Architecture build configurations - generic, generic-v9
2) Core configurations - n2, v2 etc
3) SoC configurations - Octeon 10, Bluefield 3 etc

These will provide flexibility on portability and performance.

Outside of these, there will be a lot of permutations/combinations of architecture flags supported by compiler and CPU. It does not make sense to support all of them.

However, we have to provide a method to the users to use whatever flags they want. We will do that by using the command line parameters as overrides.

Please let us know if you see problems in this approach. We also need to ensure we are not breaking any backward compatibility here.

We (Arm) will document this in the linux guide.

>>>>>> 
>>>>>> Example:
>>>>>> march = armv9-a
>>>>>> mcpu = neoverse-n2
>>>>>> 
>>>>>> mcpu supported, march supported
>>>>>> machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
>>>>> 
>>>>> -march restricts the compiler to baseline architecture of the -mcpu.
>>>>> For instance, Neoverse-n1's baseline architecture is armv8.2-a, but
>>>>> it has some extensions from armv8.3-a, armv8.4-a, and armv8.5-a.
>>>>> By setting -march to armv8.2-a the compiler will strictly omit
>>>>> extensions from 8.3, 8.4 and 8.5 resulting in a suboptimal outcome.
>>> 
>>> What if compiler only supports armv8.2-a?
>>> Are you suggesting we don’t use march at all when mcpu is supported?
>>> If so how do you express extensions that the SoC supports?
>>> Neoverse-n2 has optional support for crypto and can only be enabled by
>>> expressing it through march='armv9-a+crypto'
>>> 
>> March extensions also works with mcpu, use mcpu=neoverse-n2+crypto
>> instead of march.  It's documented in "-march and -mcpu Feature Modifiers"
>> section in gcc manual.
>> 
>>>>> 
>>>>>> 
>>>>>> mcpu supported, march not supported machine_args =
>>>>>> ['-mcpu=neoverse-n2']
>>>>> 
>>>>> This will result in the best outcome.
>>> 
>>> Isn't -mcpu=neoverse-n2 -march=armv9-a+sve2+crypto also the best
>>> outcome?
>>> 
>> Here also we can append feature modifiers like sve2 and crypto to CPU in
>> -mcpu and drop -march arg.
>> If the compiler supports neoverse-n2 but not armv9-a it will pick the next
>> best architecture.
>> -mcpu=neoverse-n2+sve2+crypto can replace - march=armv9-a+sve2+crypto
>> 
>>>>> 
>>>>>> 
>>>>>> mcpu not supported, march supported machine_args =
>>>>>> ['-march=armv9-a']
>>>>> 
>>>>> This too may result in a suboptimal outcome as optimization space is
>>>>> limited to the given march (not using extensions from later
>>>>> architectures when available).
>>>>> 
>>> 
>>> What if compiler doesn’t support mcpu=neoverse-n2 and only supports
>>> march=armv9-a
>>> 
>> I agree there can be such corner cases where CPU enablement isn't done.
>> Such cases can be handled with a new meson build parameter like
>> -Dplatform=generic-armv9 to build armv9-a binaries (similar to
>> -Dplatform=generic that builds armv8-a binaries today).
>> Having such parameter forces the user to make a conscious decision rather
>> than build system doing it for them.
>> It also comes with the added benefit of having a simpler build system.
>> 
>>>>>> 
>>>>>> mcpu not supported, march not supported machine_args =
>>>>>> ['-march=armv8.6-a']
>>>>> 
>>>>> Compiler knows nothing about the target CPU or the architecture.
>>>>> I think it's better to exit the build process with an error.
>>>>> 
>>> 
>>> Then we would need to mark all old GCC versions as not supported by a
>> newer
>>> SoC I don’t think that’s needed since the binaries still run but not optimally,
>>> currently we have a warning in place for march mismatch.
>>> 
>> We don't have to deprecate older versions of GCC.
>> I'm suggesting two options to let the user have greater autonomy on
>> the kind of the binary they want rather than ending up with a binary
>> the build system forced on them.
>> Today -Dplatform=generic does something similar to this with armv8,
>> it simply directs the build system to output an armv8 without any extras.
>> First suggestion is that we simply have a -Dplatform=generic-armv9 that
>> does the same but for armv9.
>> The second suggestion is to empower a sophisticated user even further
>> to override everything in the build system including generics via two
>> parameters -Dmarch and -Dmcpu to set an arbitrary architecture and a cpu.
>> Second option works as a catch-all for every unorthodox request that may
>> come our way. Both these features can be suggested when build exits due
>> to compiler not knowing the target CPU or the architecture.
>> I think these parameters keep user in charge with a simpler build system.
>> 
>>>>>> 
>>>>>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>>>>> ---
>>>>>> v2 Changes:
>>>>>> - Cleanup march inconsistencies. (Juraj Linkes)
>>>>>> - Unify fallback march selection. (Juraj Linkes)
>>>>>> - Tag along ARM WFE patch.
>>>>>> v3 Changes:
>>>>>> - Fix missing 'fallback_march' key check.
>>>>>> 
>>>>>> config/arm/meson.build | 108 +++++++++++++++++++++++++---------
>> --
>>> --
>>>> --
>>>>>> -
>>>>>> 1 file changed, 66 insertions(+), 42 deletions(-)
>>>>>> 
>>>>>> diff --git a/config/arm/meson.build b/config/arm/meson.build index
>>>>>> 36f21d22599a..ba859bd060b5 100644
>>>>>> --- a/config/arm/meson.build
>>>>>> +++ b/config/arm/meson.build
>>>>>> @@ -58,18 +58,18 @@ implementer_generic = {  }
>>>>>> 
>>>>>> part_number_config_arm = {
>>>>>> -    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
>>>>>> -    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
>>>>>> -    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
>>>>>> -    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
>>>>>> -    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
>>>>>> -    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
>>>>>> -    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
>>>>>> -    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
>>>>>> +    '0xd03': {'mcpu': 'cortex-a53'},
>>>>>> +    '0xd04': {'mcpu': 'cortex-a35'},
>>>>>> +    '0xd05': {'mcpu': 'cortex-a55'},
>>>>>> +    '0xd07': {'mcpu': 'cortex-a57'},
>>>>>> +    '0xd08': {'mcpu': 'cortex-a72'},
>>>>>> +    '0xd09': {'mcpu': 'cortex-a73'},
>>>>>> +    '0xd0a': {'mcpu': 'cortex-a75'},
>>>>>> +    '0xd0b': {'mcpu': 'cortex-a76'},
>>>>>>    '0xd0c': {
>>>>>>        'march': 'armv8.2-a',
>>>>>>        'march_features': ['crypto', 'rcpc'],
>>>>>> -        'compiler_options':  ['-mcpu=neoverse-n1'],
>>>>>> +        'mcpu': 'neoverse-n1',
>>>>>>        'flags': [
>>>>>>            ['RTE_MACHINE', '"neoverse-n1"'],
>>>>>>            ['RTE_ARM_FEATURE_ATOMICS', true], @@ -81,7 +81,7 @@
>>>>>> part_number_config_arm = {
>>>>>>    '0xd40': {
>>>>>>        'march': 'armv8.4-a',
>>>>>>        'march_features': ['sve'],
>>>>>> -        'compiler_options':  ['-mcpu=neoverse-v1'],
>>>>>> +        'mcpu': 'neoverse-v1',
>>>>>>        'flags': [
>>>>>>            ['RTE_MACHINE', '"neoverse-v1"'],
>>>>>>            ['RTE_ARM_FEATURE_ATOMICS', true], @@ -92,8 +92,9 @@
>>>>>> part_number_config_arm = {
>>>>>>        'march': 'armv8.4-a',
>>>>>>    },
>>>>>>    '0xd49': {
>>>>>> +        'march': 'armv9-a',
>>>>>>        'march_features': ['sve2'],
>>>>>> -        'compiler_options': ['-mcpu=neoverse-n2'],
>>>>>> +        'mcpu': 'neoverse-n2',
>>>>>>        'flags': [
>>>>>>            ['RTE_MACHINE', '"neoverse-n2"'],
>>>>>>            ['RTE_ARM_FEATURE_ATOMICS', true], @@ -127,21 +128,23
>>>>>> @@ implementer_cavium = {
>>>>>>    ],
>>>>>>    'part_number_config': {
>>>>>>        '0xa1': {
>>>>>> -            'compiler_options': ['-mcpu=thunderxt88'],
>>>>>> +            'mcpu': 'thunderxt88',
>>>>>>            'flags': flags_part_number_thunderx
>>>>>>        },
>>>>>>        '0xa2': {
>>>>>> -            'compiler_options': ['-mcpu=thunderxt81'],
>>>>>> +            'mcpu': 'thunderxt81',
>>>>>>            'flags': flags_part_number_thunderx
>>>>>>        },
>>>>>>        '0xa3': {
>>>>>> -            'compiler_options': ['-march=armv8-a+crc', '-
>> mcpu=thunderxt83'],
>>>>>> +            'march': 'armv8-a',
>>>>>> +            'march_features': ['crc'],
>>>>>> +            'mcpu': 'thunderxt83',
>>>>>>            'flags': flags_part_number_thunderx
>>>>>>        },
>>>>>>        '0xaf': {
>>>>>>            'march': 'armv8.1-a',
>>>>>>            'march_features': ['crc', 'crypto'],
>>>>>> -            'compiler_options': ['-mcpu=thunderx2t99'],
>>>>>> +            'mcpu': 'thunderx2t99',
>>>>>>            'flags': [
>>>>>>                ['RTE_MACHINE', '"thunderx2"'],
>>>>>>                ['RTE_ARM_FEATURE_ATOMICS', true], @@ -153,7 +156,7
>>>>>> @@ implementer_cavium = {
>>>>>>        '0xb2': {
>>>>>>            'march': 'armv8.2-a',
>>>>>>            'march_features': ['crc', 'crypto', 'lse'],
>>>>>> -            'compiler_options': ['-mcpu=octeontx2'],
>>>>>> +            'mcpu': 'octeontx2',
>>>>>>            'flags': [
>>>>>>                ['RTE_MACHINE', '"cn9k"'],
>>>>>>                ['RTE_ARM_FEATURE_ATOMICS', true], @@ -176,7 +179,7
>>>>>> @@ implementer_ampere = {
>>>>>>        '0x0': {
>>>>>>            'march': 'armv8-a',
>>>>>>            'march_features': ['crc', 'crypto'],
>>>>>> -            'compiler_options':  ['-mtune=emag'],
>>>>>> +            'mcpu': 'emag',
>>>>>>            'flags': [
>>>>>>                ['RTE_MACHINE', '"eMAG"'],
>>>>>>                ['RTE_MAX_LCORE', 32], @@ -186,7 +189,7 @@
>>>>>> implementer_ampere = {
>>>>>>        '0xac3': {
>>>>>>            'march': 'armv8.6-a',
>>>>>>            'march_features': ['crc', 'crypto'],
>>>>>> -            'compiler_options':  ['-mcpu=ampere1'],
>>>>>> +            'mcpu': 'ampere1',
>>>>>>            'flags': [
>>>>>>                ['RTE_MACHINE', '"AmpereOne"'],
>>>>>>                ['RTE_MAX_LCORE', 320], @@ -206,7 +209,7 @@
>>>>>> implementer_hisilicon = {
>>>>>>        '0xd01': {
>>>>>>            'march': 'armv8.2-a',
>>>>>>            'march_features': ['crypto'],
>>>>>> -            'compiler_options': ['-mtune=tsv110'],
>>>>>> +            'mcpu': 'tsv110',
>>>>>>            'flags': [
>>>>>>                ['RTE_MACHINE', '"Kunpeng 920"'],
>>>>>>                ['RTE_ARM_FEATURE_ATOMICS', true], @@ -695,11
>>>>>> +698,21 @@
>>>> if
>>>>>> update_flags
>>>>>> 
>>>>>>    machine_args = [] # Clear previous machine args
>>>>>> 
>>>>>> +    candidate_mcpu = ''
>>>>>> +    if part_number_config.has_key('mcpu')
>>>>>> +        mcpu = part_number_config['mcpu']
>>>>>> +        if (cc.has_argument('-mcpu=' + mcpu))
>>>>>> +            candidate_mcpu = mcpu
>>>>>> +        endif
>>>>>> +    endif
>>>>>> +
>>>>>>    # probe supported archs and their features
>>>>>>    candidate_march = ''
>>>>>>    if part_number_config.has_key('march')
>>>>>> -        if part_number_config.get('force_march', false)
>>>>>> -            candidate_march = part_number_config['march']
>>>>>> +        if part_number_config.get('force_march', false) or
>>>>>> + candidate_mcpu !=
>>>> ''
>>>>>> +            if cc.has_argument('-march=' +  part_number_config['march'])
>>>>>> +                candidate_march = part_number_config['march']
>>>>>> +            endif
>>>>>>        else
>>>>>>            supported_marchs = ['armv8.6-a', 'armv8.5-a',
>>>>>> 'armv8.4-a',
>>>> 'armv8.3-
>>>>>> a',
>>>>>>                                'armv8.2-a', 'armv8.1-a',
>>>>>> 'armv8-a'] @@ -717,32 +730,43 @@ if update_flags
>>>>>>                endif
>>>>>>            endforeach
>>>>>>        endif
>>>>>> -        if candidate_march == ''
>>>>>> -            error('No suitable armv8 march version found.')
>>>>>> -        endif
>>>>>> +
>>>>>>        if candidate_march != part_number_config['march']
>>>>>> -            warning('Configuration march version is ' +
>>>>>> -                    '@0@, but the compiler supports only @1@.'
>>>>>> -                    .format(part_number_config['march'], candidate_march))
>>>>>> +            warning('Configuration march version is @0@, not supported.'
>>>>>> +                    .format(part_number_config['march']))
>>>>>> +            if candidate_march != ''
>>>>>> +                warning('Using march version
>> @0@.'.format(candidate_march))
>>>>>> +            endif
>>>>>>        endif
>>>>>> -        candidate_march = '-march=' + candidate_march
>>>>>> 
>>>>>> -        march_features = []
>>>>>> -        if part_number_config.has_key('march_features')
>>>>>> -            march_features += part_number_config['march_features']
>>>>>> -        endif
>>>>>> -        if soc_config.has_key('extra_march_features')
>>>>>> -            march_features += soc_config['extra_march_features']
>>>>>> +        if candidate_march == '' and candidate_mcpu == ''
>>>>>> +            error('No suitable ARM march/mcpu version found.')
>>>>>>        endif
>>>>>> -        foreach feature: march_features
>>>>>> -            if cc.has_argument('+'.join([candidate_march, feature]))
>>>>>> -                candidate_march = '+'.join([candidate_march, feature])
>>>>>> -            else
>>>>>> -                warning('The compiler does not support feature @0@'
>>>>>> -                    .format(feature))
>>>>>> +
>>>>>> +        if candidate_march != ''
>>>>>> +            candidate_march = '-march=' + candidate_march
>>>>>> +            march_features = []
>>>>>> +            if part_number_config.has_key('march_features')
>>>>>> +                march_features +=
>>>>>> + part_number_config['march_features']
>>>>>>            endif
>>>>>> -        endforeach
>>>>>> -        machine_args += candidate_march
>>>>>> +            if soc_config.has_key('extra_march_features')
>>>>>> +                march_features += soc_config['extra_march_features']
>>>>>> +            endif
>>>>>> +            foreach feature: march_features
>>>>>> +                if cc.has_argument('+'.join([candidate_march, feature]))
>>>>>> +                    candidate_march = '+'.join([candidate_march, feature])
>>>>>> +                else
>>>>>> +                    warning('The compiler does not support feature @0@'
>>>>>> +                        .format(feature))
>>>>>> +                endif
>>>>>> +            endforeach
>>>>>> +            machine_args += candidate_march
>>>>>> +        endif
>>>>>> +    endif
>>>>>> +
>>>>>> +    if candidate_mcpu != ''
>>>>>> +        candidate_mcpu = '-mcpu=' + candidate_mcpu
>>>>>> +        machine_args += candidate_mcpu
>>>>>>    endif
>>>>>> 
>>>>>>    # apply supported compiler options
>>>>>> --
>>>>>> 2.43.0
>>>>> 
> 


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 3/3] config/arm: allow WFE to be enabled config time
  2024-02-10  6:47       ` Pavan Nikhilesh Bhagavatula
@ 2024-02-10 16:36         ` Honnappa Nagarahalli
  2024-02-10 16:40           ` Pavan Nikhilesh Bhagavatula
  0 siblings, 1 reply; 65+ messages in thread
From: Honnappa Nagarahalli @ 2024-02-10 16:36 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula
  Cc: jerinj, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson, dev,
	Chengwen Feng, Wathsala Wathawana Vithanage, Dhruv Tripathi



> On Feb 10, 2024, at 12:47 AM, Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com> wrote:
> 
>>> On Feb 1, 2024, at 3:57 PM, pbhagavatula@marvell.com wrote:
>>> 
>>> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>> 
>>> Allow RTE_ARM_USE_WFE to be enabled at meson configuration
>>> time by passing it via c_args instead of modifying
>>> `config/arm/meson.build`.
>>> 
>>> Example usage:
>>> meson build -Dc_args='-DRTE_ARM_USE_WFE' \
>>> --cross-file config/arm/arm64_cn10k_linux_gcc
>>> 
>>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>> Acked-by: Chengwen Feng <fengchengwen@huawei.com>
>>> Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
>>> ---
>>> config/arm/meson.build | 4 +++-
>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/config/arm/meson.build b/config/arm/meson.build
>>> index 6f2308f2fa..3467bef466 100644
>>> --- a/config/arm/meson.build
>>> +++ b/config/arm/meson.build
>>> @@ -17,7 +17,9 @@ flags_common = [
>>>        #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
>>>        #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
>>> 
>>> -        ['RTE_ARM_USE_WFE', false],
>>> +        # Enable use of ARM wait for event instruction.
>>> +        # ['RTE_ARM_USE_WFE', false],
>>> +
>> So, what is the default value for RTE_ARM_USE_WFE if the user does not pass
>> the flag at the command line?
>> 
> 
> All the checks related to RTE_ARM_USE_WFE see if it is defined or not
> 
> #rg "RTE_ARM_USE_WFE"                     
> config/arm/meson.build
> 20:        ['RTE_ARM_USE_WFE', false],
> lib/eal/arm/rte_cpuflags.c
> 166:#ifdef RTE_ARM_USE_WFE
> lib/eal/arm/include/rte_pause_64.h
> 15:#ifdef RTE_ARM_USE_WFE
> lib/eal/arm/rte_power_intrinsics.c
> 20:#ifdef RTE_ARM_USE_WFE
> 84:#ifdef RTE_ARM_USE_WFE
> 
> So default value would be not-defined.
> 
>> Can we do it such a way that the flag passed on the command line takes
>> precedence?
> 
> No, we can't have checks based on flags passed via -Dc_args with the current meson(needs build_options() from 1.1.0).
> Only option is to add via meson_option.txt which is not optimal for arch settings.

Ack
Do you expect the users to enable this flag by default for cn10k?

> 
>> 
>>>        ['RTE_ARCH_ARM64', true],
>>>        ['RTE_CACHE_LINE_SIZE', 128]
>>> ]
>>> --
>>> 2.25.1
>>> 
> 


^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [PATCH v2 3/3] config/arm: allow WFE to be enabled config time
  2024-02-10 16:36         ` Honnappa Nagarahalli
@ 2024-02-10 16:40           ` Pavan Nikhilesh Bhagavatula
  0 siblings, 0 replies; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-02-10 16:40 UTC (permalink / raw)
  To: Honnappa Nagarahalli
  Cc: Jerin Jacob, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson,
	dev, Chengwen Feng, Wathsala Wathawana Vithanage, Dhruv Tripathi



> -----Original Message-----
> From: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> Sent: Saturday, February 10, 2024 10:07 PM
> To: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> Cc: Jerin Jacob <jerinj@marvell.com>; juraj.linkes@pantheon.tech; nd
> <nd@arm.com>; Ruifeng Wang <Ruifeng.Wang@arm.com>; Bruce Richardson
> <bruce.richardson@intel.com>; dev@dpdk.org; Chengwen Feng
> <fengchengwen@huawei.com>; Wathsala Wathawana Vithanage
> <wathsala.vithanage@arm.com>; Dhruv Tripathi <Dhruv.Tripathi@arm.com>
> Subject: [EXT] Re: [PATCH v2 3/3] config/arm: allow WFE to be enabled config
> time
> 
> External Email
> 
> ----------------------------------------------------------------------
> 
> 
> > On Feb 10, 2024, at 12:47 AM, Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com> wrote:
> >
> >>> On Feb 1, 2024, at 3:57 PM, pbhagavatula@marvell.com wrote:
> >>>
> >>> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >>>
> >>> Allow RTE_ARM_USE_WFE to be enabled at meson configuration
> >>> time by passing it via c_args instead of modifying
> >>> `config/arm/meson.build`.
> >>>
> >>> Example usage:
> >>> meson build -Dc_args='-DRTE_ARM_USE_WFE' \
> >>> --cross-file config/arm/arm64_cn10k_linux_gcc
> >>>
> >>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >>> Acked-by: Chengwen Feng <fengchengwen@huawei.com>
> >>> Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
> >>> ---
> >>> config/arm/meson.build | 4 +++-
> >>> 1 file changed, 3 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/config/arm/meson.build b/config/arm/meson.build
> >>> index 6f2308f2fa..3467bef466 100644
> >>> --- a/config/arm/meson.build
> >>> +++ b/config/arm/meson.build
> >>> @@ -17,7 +17,9 @@ flags_common = [
> >>>        #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
> >>>        #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
> >>>
> >>> -        ['RTE_ARM_USE_WFE', false],
> >>> +        # Enable use of ARM wait for event instruction.
> >>> +        # ['RTE_ARM_USE_WFE', false],
> >>> +
> >> So, what is the default value for RTE_ARM_USE_WFE if the user does not
> pass
> >> the flag at the command line?
> >>
> >
> > All the checks related to RTE_ARM_USE_WFE see if it is defined or not
> >
> > #rg "RTE_ARM_USE_WFE"
> > config/arm/meson.build
> > 20:        ['RTE_ARM_USE_WFE', false],
> > lib/eal/arm/rte_cpuflags.c
> > 166:#ifdef RTE_ARM_USE_WFE
> > lib/eal/arm/include/rte_pause_64.h
> > 15:#ifdef RTE_ARM_USE_WFE
> > lib/eal/arm/rte_power_intrinsics.c
> > 20:#ifdef RTE_ARM_USE_WFE
> > 84:#ifdef RTE_ARM_USE_WFE
> >
> > So default value would be not-defined.
> >
> >> Can we do it such a way that the flag passed on the command line takes
> >> precedence?
> >
> > No, we can't have checks based on flags passed via -Dc_args with the current
> meson(needs build_options() from 1.1.0).
> > Only option is to add via meson_option.txt which is not optimal for arch
> settings.
> 
> Ack
> Do you expect the users to enable this flag by default for cn10k?
> 

No, AFAIK only certain users are going to enable it, mostly L1.

> >
> >>
> >>>        ['RTE_ARCH_ARM64', true],
> >>>        ['RTE_CACHE_LINE_SIZE', 128]
> >>> ]
> >>> --
> >>> 2.25.1
> >>>
> >


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v3 3/3] config/arm: allow WFE to be enabled config time
  2024-02-02  8:50     ` [PATCH v3 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
@ 2024-02-10 16:56       ` Honnappa Nagarahalli
  2024-02-12 19:21       ` Wathsala Wathawana Vithanage
  1 sibling, 0 replies; 65+ messages in thread
From: Honnappa Nagarahalli @ 2024-02-10 16:56 UTC (permalink / raw)
  To: pbhagavatula
  Cc: jerinj, juraj.linkes, nd, Ruifeng Wang, Bruce Richardson, dev,
	Chengwen Feng



> On Feb 2, 2024, at 2:50 AM, pbhagavatula@marvell.com wrote:
> 
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Allow RTE_ARM_USE_WFE to be enabled at meson configuration
> time by passing it via c_args instead of modifying
> `config/arm/meson.build`.
> 
> Example usage:
> meson build -Dc_args='-DRTE_ARM_USE_WFE' \
> --cross-file config/arm/arm64_cn10k_linux_gcc
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> Acked-by: Chengwen Feng <fengchengwen@huawei.com>
> Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

---
> config/arm/meson.build | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 4e44d1850bae..01870a23328a 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -17,7 +17,9 @@ flags_common = [
>         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
>         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
> 
> -        ['RTE_ARM_USE_WFE', false],
> +        # Enable use of ARM wait for event instruction.
> +        # ['RTE_ARM_USE_WFE', false],
> +
>         ['RTE_ARCH_ARM64', true],
>         ['RTE_CACHE_LINE_SIZE', 128]
> ]
> -- 
> 2.43.0
> 


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-10 15:20               ` Honnappa Nagarahalli
@ 2024-02-10 17:21                 ` Honnappa Nagarahalli
  0 siblings, 0 replies; 65+ messages in thread
From: Honnappa Nagarahalli @ 2024-02-10 17:21 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula
  Cc: Wathsala Wathawana Vithanage, jerinj, juraj.linkes,
	Bruce Richardson, dev, nd, Ruifeng Wang



> On Feb 10, 2024, at 9:20 AM, Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com> wrote:
> 
> 
> 
>> On Feb 10, 2024, at 12:49 AM, Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com> wrote:
>> 
>> 
>>>>> <wathsala.vithanage@arm.com> wrote:
>>>>>> 
>>>>>> Hi Pavan,
>>>>>> 
>>>>>>> The compiler options march and mtune are a subset of mcpu and will
>>>>>>> lead
>>>>> to
>>>>>>> conflicts if improper march is chosen for a given mcpu.
>>>>>>> To avoid conflicts, force part number march when mcpu is available
>>>>>>> and is supported by the compiler.
>>>>>> 
>>>>>> Why would one force the march specified in the part number when mcpu
>>>>>> for that part number is also available and supported by the compiler?
>>>>>> 
>>>>> It would be good to explain the use case or the problem being faced.
>>>>> 
>>>> 
>>>> The idea of this patchset is to avoid mcpu and march conflicts that can
>>> happen
>>>> with the current build flow.
>>>> 
>>>> #aarch64-linux-gnu-gcc -mcpu=neoverse-n2 -march=armv8.6-a shrn.c
>>>> cc1: warning: switch '-mcpu=neoverse-n2' conflicts with '-march=armv8.6-a'
>>>> 
>>>> In some versions of GCC mcpu=neoverse-n2 is supported but -
>>> march=armv9-
>>>> a is not so, current build flow will choose the next supported march which is
>>>> armv8.6-a and report a conflict.
>>>> 
>>> If compiler support is available for a certain CPU, then it is safe to assume that
>>> the
>>> Compiler knows the best architecture to use.
>>> Therefore, in such cases the best practice is to not provide -march.
>>> 
>> 
>> Ok, this deviates a lot from the current build flow, I will rework and send a v4. 
>> 
> The overall goal is to ensure the user knows that they are making suboptimal choices. We will do some canned build configurations as follows:
> 
> 1) Architecture build configurations - generic, generic-v9
> 2) Core configurations - n2, v2 etc
> 3) SoC configurations - Octeon 10, Bluefield 3 etc
> 
> These will provide flexibility on portability and performance.
> 
> Outside of these, there will be a lot of permutations/combinations of architecture flags supported by compiler and CPU. It does not make sense to support all of them.
> 
> However, we have to provide a method to the users to use whatever flags they want. We will do that by using the command line parameters as overrides.
> 
> Please let us know if you see problems in this approach. We also need to ensure we are not breaking any backward compatibility here.
> 
> We (Arm) will document this in the linux guide.

Currently, we are displaying warnings when there is a mismatch between the platform the user chooses and what the compiler supports. For ex: if the user wants to compile for N2 (-Dplatform=n2) and the compiler does not support -mcpu=neoverse-n2, we display a warning and the build continues. I think we need to change this to error forcing the user to update the compiler or building for a generic v8 or generic-v9 or asking them to provide options at the command line.

> 
>>>>>>> 
>>>>>>> Example:
>>>>>>> march = armv9-a
>>>>>>> mcpu = neoverse-n2
>>>>>>> 
>>>>>>> mcpu supported, march supported
>>>>>>> machine_args = ['-mcpu=neoverse-n2', '-march=armv9-a']
>>>>>> 
>>>>>> -march restricts the compiler to baseline architecture of the -mcpu.
>>>>>> For instance, Neoverse-n1's baseline architecture is armv8.2-a, but
>>>>>> it has some extensions from armv8.3-a, armv8.4-a, and armv8.5-a.
>>>>>> By setting -march to armv8.2-a the compiler will strictly omit
>>>>>> extensions from 8.3, 8.4 and 8.5 resulting in a suboptimal outcome.
>>>> 
>>>> What if compiler only supports armv8.2-a?
>>>> Are you suggesting we don’t use march at all when mcpu is supported?
>>>> If so how do you express extensions that the SoC supports?
>>>> Neoverse-n2 has optional support for crypto and can only be enabled by
>>>> expressing it through march='armv9-a+crypto'
>>>> 
>>> March extensions also works with mcpu, use mcpu=neoverse-n2+crypto
>>> instead of march.  It's documented in "-march and -mcpu Feature Modifiers"
>>> section in gcc manual.
>>> 
>>>>>> 
>>>>>>> 
>>>>>>> mcpu supported, march not supported machine_args =
>>>>>>> ['-mcpu=neoverse-n2']
>>>>>> 
>>>>>> This will result in the best outcome.
>>>> 
>>>> Isn't -mcpu=neoverse-n2 -march=armv9-a+sve2+crypto also the best
>>>> outcome?
>>>> 
>>> Here also we can append feature modifiers like sve2 and crypto to CPU in
>>> -mcpu and drop -march arg.
>>> If the compiler supports neoverse-n2 but not armv9-a it will pick the next
>>> best architecture.
>>> -mcpu=neoverse-n2+sve2+crypto can replace - march=armv9-a+sve2+crypto
>>> 
>>>>>> 
>>>>>>> 
>>>>>>> mcpu not supported, march supported machine_args =
>>>>>>> ['-march=armv9-a']
>>>>>> 
>>>>>> This too may result in a suboptimal outcome as optimization space is
>>>>>> limited to the given march (not using extensions from later
>>>>>> architectures when available).
>>>>>> 
>>>> 
>>>> What if compiler doesn’t support mcpu=neoverse-n2 and only supports
>>>> march=armv9-a
>>>> 
>>> I agree there can be such corner cases where CPU enablement isn't done.
>>> Such cases can be handled with a new meson build parameter like
>>> -Dplatform=generic-armv9 to build armv9-a binaries (similar to
>>> -Dplatform=generic that builds armv8-a binaries today).
>>> Having such parameter forces the user to make a conscious decision rather
>>> than build system doing it for them.
>>> It also comes with the added benefit of having a simpler build system.
>>> 
>>>>>>> 
>>>>>>> mcpu not supported, march not supported machine_args =
>>>>>>> ['-march=armv8.6-a']
>>>>>> 
>>>>>> Compiler knows nothing about the target CPU or the architecture.
>>>>>> I think it's better to exit the build process with an error.
>>>>>> 
>>>> 
>>>> Then we would need to mark all old GCC versions as not supported by a
>>> newer
>>>> SoC I don’t think that’s needed since the binaries still run but not optimally,
>>>> currently we have a warning in place for march mismatch.
>>>> 
>>> We don't have to deprecate older versions of GCC.
>>> I'm suggesting two options to let the user have greater autonomy on
>>> the kind of the binary they want rather than ending up with a binary
>>> the build system forced on them.
>>> Today -Dplatform=generic does something similar to this with armv8,
>>> it simply directs the build system to output an armv8 without any extras.
>>> First suggestion is that we simply have a -Dplatform=generic-armv9 that
>>> does the same but for armv9.
>>> The second suggestion is to empower a sophisticated user even further
>>> to override everything in the build system including generics via two
>>> parameters -Dmarch and -Dmcpu to set an arbitrary architecture and a cpu.
>>> Second option works as a catch-all for every unorthodox request that may
>>> come our way. Both these features can be suggested when build exits due
>>> to compiler not knowing the target CPU or the architecture.
>>> I think these parameters keep user in charge with a simpler build system.
>>> 
>>>>>>> 
>>>>>>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>>>>>> ---
>>>>>>> v2 Changes:
>>>>>>> - Cleanup march inconsistencies. (Juraj Linkes)
>>>>>>> - Unify fallback march selection. (Juraj Linkes)
>>>>>>> - Tag along ARM WFE patch.
>>>>>>> v3 Changes:
>>>>>>> - Fix missing 'fallback_march' key check.
>>>>>>> 
>>>>>>> config/arm/meson.build | 108 +++++++++++++++++++++++++---------
>>> --
>>>> --
>>>>> --
>>>>>>> -
>>>>>>> 1 file changed, 66 insertions(+), 42 deletions(-)
>>>>>>> 
>>>>>>> diff --git a/config/arm/meson.build b/config/arm/meson.build index
>>>>>>> 36f21d22599a..ba859bd060b5 100644
>>>>>>> --- a/config/arm/meson.build
>>>>>>> +++ b/config/arm/meson.build
>>>>>>> @@ -58,18 +58,18 @@ implementer_generic = {  }
>>>>>>> 
>>>>>>> part_number_config_arm = {
>>>>>>> -    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
>>>>>>> -    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
>>>>>>> -    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
>>>>>>> -    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
>>>>>>> -    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
>>>>>>> -    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
>>>>>>> -    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
>>>>>>> -    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
>>>>>>> +    '0xd03': {'mcpu': 'cortex-a53'},
>>>>>>> +    '0xd04': {'mcpu': 'cortex-a35'},
>>>>>>> +    '0xd05': {'mcpu': 'cortex-a55'},
>>>>>>> +    '0xd07': {'mcpu': 'cortex-a57'},
>>>>>>> +    '0xd08': {'mcpu': 'cortex-a72'},
>>>>>>> +    '0xd09': {'mcpu': 'cortex-a73'},
>>>>>>> +    '0xd0a': {'mcpu': 'cortex-a75'},
>>>>>>> +    '0xd0b': {'mcpu': 'cortex-a76'},
>>>>>>>   '0xd0c': {
>>>>>>>       'march': 'armv8.2-a',
>>>>>>>       'march_features': ['crypto', 'rcpc'],
>>>>>>> -        'compiler_options':  ['-mcpu=neoverse-n1'],
>>>>>>> +        'mcpu': 'neoverse-n1',
>>>>>>>       'flags': [
>>>>>>>           ['RTE_MACHINE', '"neoverse-n1"'],
>>>>>>>           ['RTE_ARM_FEATURE_ATOMICS', true], @@ -81,7 +81,7 @@
>>>>>>> part_number_config_arm = {
>>>>>>>   '0xd40': {
>>>>>>>       'march': 'armv8.4-a',
>>>>>>>       'march_features': ['sve'],
>>>>>>> -        'compiler_options':  ['-mcpu=neoverse-v1'],
>>>>>>> +        'mcpu': 'neoverse-v1',
>>>>>>>       'flags': [
>>>>>>>           ['RTE_MACHINE', '"neoverse-v1"'],
>>>>>>>           ['RTE_ARM_FEATURE_ATOMICS', true], @@ -92,8 +92,9 @@
>>>>>>> part_number_config_arm = {
>>>>>>>       'march': 'armv8.4-a',
>>>>>>>   },
>>>>>>>   '0xd49': {
>>>>>>> +        'march': 'armv9-a',
>>>>>>>       'march_features': ['sve2'],
>>>>>>> -        'compiler_options': ['-mcpu=neoverse-n2'],
>>>>>>> +        'mcpu': 'neoverse-n2',
>>>>>>>       'flags': [
>>>>>>>           ['RTE_MACHINE', '"neoverse-n2"'],
>>>>>>>           ['RTE_ARM_FEATURE_ATOMICS', true], @@ -127,21 +128,23
>>>>>>> @@ implementer_cavium = {
>>>>>>>   ],
>>>>>>>   'part_number_config': {
>>>>>>>       '0xa1': {
>>>>>>> -            'compiler_options': ['-mcpu=thunderxt88'],
>>>>>>> +            'mcpu': 'thunderxt88',
>>>>>>>           'flags': flags_part_number_thunderx
>>>>>>>       },
>>>>>>>       '0xa2': {
>>>>>>> -            'compiler_options': ['-mcpu=thunderxt81'],
>>>>>>> +            'mcpu': 'thunderxt81',
>>>>>>>           'flags': flags_part_number_thunderx
>>>>>>>       },
>>>>>>>       '0xa3': {
>>>>>>> -            'compiler_options': ['-march=armv8-a+crc', '-
>>> mcpu=thunderxt83'],
>>>>>>> +            'march': 'armv8-a',
>>>>>>> +            'march_features': ['crc'],
>>>>>>> +            'mcpu': 'thunderxt83',
>>>>>>>           'flags': flags_part_number_thunderx
>>>>>>>       },
>>>>>>>       '0xaf': {
>>>>>>>           'march': 'armv8.1-a',
>>>>>>>           'march_features': ['crc', 'crypto'],
>>>>>>> -            'compiler_options': ['-mcpu=thunderx2t99'],
>>>>>>> +            'mcpu': 'thunderx2t99',
>>>>>>>           'flags': [
>>>>>>>               ['RTE_MACHINE', '"thunderx2"'],
>>>>>>>               ['RTE_ARM_FEATURE_ATOMICS', true], @@ -153,7 +156,7
>>>>>>> @@ implementer_cavium = {
>>>>>>>       '0xb2': {
>>>>>>>           'march': 'armv8.2-a',
>>>>>>>           'march_features': ['crc', 'crypto', 'lse'],
>>>>>>> -            'compiler_options': ['-mcpu=octeontx2'],
>>>>>>> +            'mcpu': 'octeontx2',
>>>>>>>           'flags': [
>>>>>>>               ['RTE_MACHINE', '"cn9k"'],
>>>>>>>               ['RTE_ARM_FEATURE_ATOMICS', true], @@ -176,7 +179,7
>>>>>>> @@ implementer_ampere = {
>>>>>>>       '0x0': {
>>>>>>>           'march': 'armv8-a',
>>>>>>>           'march_features': ['crc', 'crypto'],
>>>>>>> -            'compiler_options':  ['-mtune=emag'],
>>>>>>> +            'mcpu': 'emag',
>>>>>>>           'flags': [
>>>>>>>               ['RTE_MACHINE', '"eMAG"'],
>>>>>>>               ['RTE_MAX_LCORE', 32], @@ -186,7 +189,7 @@
>>>>>>> implementer_ampere = {
>>>>>>>       '0xac3': {
>>>>>>>           'march': 'armv8.6-a',
>>>>>>>           'march_features': ['crc', 'crypto'],
>>>>>>> -            'compiler_options':  ['-mcpu=ampere1'],
>>>>>>> +            'mcpu': 'ampere1',
>>>>>>>           'flags': [
>>>>>>>               ['RTE_MACHINE', '"AmpereOne"'],
>>>>>>>               ['RTE_MAX_LCORE', 320], @@ -206,7 +209,7 @@
>>>>>>> implementer_hisilicon = {
>>>>>>>       '0xd01': {
>>>>>>>           'march': 'armv8.2-a',
>>>>>>>           'march_features': ['crypto'],
>>>>>>> -            'compiler_options': ['-mtune=tsv110'],
>>>>>>> +            'mcpu': 'tsv110',
>>>>>>>           'flags': [
>>>>>>>               ['RTE_MACHINE', '"Kunpeng 920"'],
>>>>>>>               ['RTE_ARM_FEATURE_ATOMICS', true], @@ -695,11
>>>>>>> +698,21 @@
>>>>> if
>>>>>>> update_flags
>>>>>>> 
>>>>>>>   machine_args = [] # Clear previous machine args
>>>>>>> 
>>>>>>> +    candidate_mcpu = ''
>>>>>>> +    if part_number_config.has_key('mcpu')
>>>>>>> +        mcpu = part_number_config['mcpu']
>>>>>>> +        if (cc.has_argument('-mcpu=' + mcpu))
>>>>>>> +            candidate_mcpu = mcpu
>>>>>>> +        endif
>>>>>>> +    endif
>>>>>>> +
>>>>>>>   # probe supported archs and their features
>>>>>>>   candidate_march = ''
>>>>>>>   if part_number_config.has_key('march')
>>>>>>> -        if part_number_config.get('force_march', false)
>>>>>>> -            candidate_march = part_number_config['march']
>>>>>>> +        if part_number_config.get('force_march', false) or
>>>>>>> + candidate_mcpu !=
>>>>> ''
>>>>>>> +            if cc.has_argument('-march=' +  part_number_config['march'])
>>>>>>> +                candidate_march = part_number_config['march']
>>>>>>> +            endif
>>>>>>>       else
>>>>>>>           supported_marchs = ['armv8.6-a', 'armv8.5-a',
>>>>>>> 'armv8.4-a',
>>>>> 'armv8.3-
>>>>>>> a',
>>>>>>>                               'armv8.2-a', 'armv8.1-a',
>>>>>>> 'armv8-a'] @@ -717,32 +730,43 @@ if update_flags
>>>>>>>               endif
>>>>>>>           endforeach
>>>>>>>       endif
>>>>>>> -        if candidate_march == ''
>>>>>>> -            error('No suitable armv8 march version found.')
>>>>>>> -        endif
>>>>>>> +
>>>>>>>       if candidate_march != part_number_config['march']
>>>>>>> -            warning('Configuration march version is ' +
>>>>>>> -                    '@0@, but the compiler supports only @1@.'
>>>>>>> -                    .format(part_number_config['march'], candidate_march))
>>>>>>> +            warning('Configuration march version is @0@, not supported.'
>>>>>>> +                    .format(part_number_config['march']))
>>>>>>> +            if candidate_march != ''
>>>>>>> +                warning('Using march version
>>> @0@.'.format(candidate_march))
>>>>>>> +            endif
>>>>>>>       endif
>>>>>>> -        candidate_march = '-march=' + candidate_march
>>>>>>> 
>>>>>>> -        march_features = []
>>>>>>> -        if part_number_config.has_key('march_features')
>>>>>>> -            march_features += part_number_config['march_features']
>>>>>>> -        endif
>>>>>>> -        if soc_config.has_key('extra_march_features')
>>>>>>> -            march_features += soc_config['extra_march_features']
>>>>>>> +        if candidate_march == '' and candidate_mcpu == ''
>>>>>>> +            error('No suitable ARM march/mcpu version found.')
>>>>>>>       endif
>>>>>>> -        foreach feature: march_features
>>>>>>> -            if cc.has_argument('+'.join([candidate_march, feature]))
>>>>>>> -                candidate_march = '+'.join([candidate_march, feature])
>>>>>>> -            else
>>>>>>> -                warning('The compiler does not support feature @0@'
>>>>>>> -                    .format(feature))
>>>>>>> +
>>>>>>> +        if candidate_march != ''
>>>>>>> +            candidate_march = '-march=' + candidate_march
>>>>>>> +            march_features = []
>>>>>>> +            if part_number_config.has_key('march_features')
>>>>>>> +                march_features +=
>>>>>>> + part_number_config['march_features']
>>>>>>>           endif
>>>>>>> -        endforeach
>>>>>>> -        machine_args += candidate_march
>>>>>>> +            if soc_config.has_key('extra_march_features')
>>>>>>> +                march_features += soc_config['extra_march_features']
>>>>>>> +            endif
>>>>>>> +            foreach feature: march_features
>>>>>>> +                if cc.has_argument('+'.join([candidate_march, feature]))
>>>>>>> +                    candidate_march = '+'.join([candidate_march, feature])
>>>>>>> +                else
>>>>>>> +                    warning('The compiler does not support feature @0@'
>>>>>>> +                        .format(feature))
>>>>>>> +                endif
>>>>>>> +            endforeach
>>>>>>> +            machine_args += candidate_march
>>>>>>> +        endif
>>>>>>> +    endif
>>>>>>> +
>>>>>>> +    if candidate_mcpu != ''
>>>>>>> +        candidate_mcpu = '-mcpu=' + candidate_mcpu
>>>>>>> +        machine_args += candidate_mcpu
>>>>>>>   endif
>>>>>>> 
>>>>>>>   # apply supported compiler options
>>>>>>> --
>>>>>>> 2.43.0
>>>>>> 
>> 
> 


^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [PATCH v3 3/3] config/arm: allow WFE to be enabled config time
  2024-02-02  8:50     ` [PATCH v3 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
  2024-02-10 16:56       ` Honnappa Nagarahalli
@ 2024-02-12 19:21       ` Wathsala Wathawana Vithanage
  1 sibling, 0 replies; 65+ messages in thread
From: Wathsala Wathawana Vithanage @ 2024-02-12 19:21 UTC (permalink / raw)
  To: pbhagavatula, jerinj, juraj.linkes, Ruifeng Wang, Bruce Richardson
  Cc: dev, Chengwen Feng, nd, nd

> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Allow RTE_ARM_USE_WFE to be enabled at meson configuration time by
> passing it via c_args instead of modifying `config/arm/meson.build`.
> 
> Example usage:
>  meson build -Dc_args='-DRTE_ARM_USE_WFE' \
> 	--cross-file config/arm/arm64_cn10k_linux_gcc
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> Acked-by: Chengwen Feng <fengchengwen@huawei.com>
> Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
> ---
>  config/arm/meson.build | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> 4e44d1850bae..01870a23328a 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -17,7 +17,9 @@ flags_common = [
>          #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
>          #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
> 
> -        ['RTE_ARM_USE_WFE', false],
> +        # Enable use of ARM wait for event instruction.
> +        # ['RTE_ARM_USE_WFE', false],
> +
>          ['RTE_ARCH_ARM64', true],
>          ['RTE_CACHE_LINE_SIZE', 128]
>  ]
> --
> 2.43.0


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v4 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-02  8:50   ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
                       ` (2 preceding siblings ...)
  2024-02-06  4:10     ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts Wathsala Wathawana Vithanage
@ 2024-02-21 20:20     ` pbhagavatula
  2024-02-21 20:20       ` [PATCH v4 2/3] config/arm: add support for fallback march pbhagavatula
                         ` (3 more replies)
  3 siblings, 4 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-21 20:20 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

The compiler options march and mtune are a subset
of mcpu and will lead to conflicts if improper march
is chosen for a given mcpu.
To avoid conflicts, discard part number march when
mcpu is available and is supported by the compiler.

Example:
	march = armv9-a
	mcpu = neoverse-n2

	mcpu supported, march supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu supported, march not supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu not supported, march supported
	machine_args = ['-march=armv9-a']

	mcpu not supported, march not supported
	machine_args = ['-march=armv8.6-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
v2 Changes:
- Cleanup march inconsistencies. (Juraj Linkes)
- Unify fallback march selection. (Juraj Linkes)
- Tag along ARM WFE patch.
v3 Changes:
- Fix missing 'fallback_march' key check.
v4 Changes:
- Discard march when mcpu is supported.

 config/arm/meson.build | 107 +++++++++++++++++++++++++++--------------
 1 file changed, 70 insertions(+), 37 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 36f21d2259..e77b696d8e 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -58,18 +58,18 @@ implementer_generic = {
 }

 part_number_config_arm = {
-    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
-    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
-    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
-    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
-    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
-    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
+    '0xd03': {'mcpu': 'cortex-a53'},
+    '0xd04': {'mcpu': 'cortex-a35'},
+    '0xd05': {'mcpu': 'cortex-a55'},
+    '0xd07': {'mcpu': 'cortex-a57'},
+    '0xd08': {'mcpu': 'cortex-a72'},
+    '0xd09': {'mcpu': 'cortex-a73'},
+    '0xd0a': {'mcpu': 'cortex-a75'},
+    '0xd0b': {'mcpu': 'cortex-a76'},
     '0xd0c': {
         'march': 'armv8.2-a',
         'march_features': ['crypto', 'rcpc'],
-        'compiler_options':  ['-mcpu=neoverse-n1'],
+        'mcpu': 'neoverse-n1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -81,7 +81,7 @@ part_number_config_arm = {
     '0xd40': {
         'march': 'armv8.4-a',
         'march_features': ['sve'],
-        'compiler_options':  ['-mcpu=neoverse-v1'],
+        'mcpu': 'neoverse-v1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-v1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -92,8 +92,9 @@ part_number_config_arm = {
         'march': 'armv8.4-a',
     },
     '0xd49': {
+        'march': 'armv9-a',
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-n2'],
+        'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,21 +128,23 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'compiler_options': ['-mcpu=thunderxt88'],
+            'mcpu': 'thunderxt88',
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'compiler_options': ['-mcpu=thunderxt81'],
+            'mcpu': 'thunderxt81',
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'mcpu': 'thunderxt83',
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
             'march': 'armv8.1-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options': ['-mcpu=thunderx2t99'],
+            'mcpu': 'thunderx2t99',
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -153,7 +156,7 @@ implementer_cavium = {
         '0xb2': {
             'march': 'armv8.2-a',
             'march_features': ['crc', 'crypto', 'lse'],
-            'compiler_options': ['-mcpu=octeontx2'],
+            'mcpu': 'octeontx2',
             'flags': [
                 ['RTE_MACHINE', '"cn9k"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -176,7 +179,7 @@ implementer_ampere = {
         '0x0': {
             'march': 'armv8-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mtune=emag'],
+            'mcpu': 'emag',
             'flags': [
                 ['RTE_MACHINE', '"eMAG"'],
                 ['RTE_MAX_LCORE', 32],
@@ -186,7 +189,7 @@ implementer_ampere = {
         '0xac3': {
             'march': 'armv8.6-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mcpu=ampere1'],
+            'mcpu': 'ampere1',
             'flags': [
                 ['RTE_MACHINE', '"AmpereOne"'],
                 ['RTE_MAX_LCORE', 320],
@@ -206,7 +209,7 @@ implementer_hisilicon = {
         '0xd01': {
             'march': 'armv8.2-a',
             'march_features': ['crypto'],
-            'compiler_options': ['-mtune=tsv110'],
+            'mcpu': 'tsv110',
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -695,13 +698,31 @@ if update_flags

     machine_args = [] # Clear previous machine args

+    candidate_mcpu = ''
+    if part_number_config.has_key('mcpu')
+        mcpu = part_number_config['mcpu']
+        if (cc.has_argument('-mcpu=' + mcpu))
+            candidate_mcpu = mcpu
+        endif
+    endif
+
+    march_features = []
+    if part_number_config.has_key('march_features')
+        march_features += part_number_config['march_features']
+    endif
+    if soc_config.has_key('extra_march_features')
+        march_features += soc_config['extra_march_features']
+    endif
+
     # probe supported archs and their features
     candidate_march = ''
-    if part_number_config.has_key('march')
+    if part_number_config.has_key('march') and candidate_mcpu == ''
         if part_number_config.get('force_march', false)
-            candidate_march = part_number_config['march']
+            if cc.has_argument('-march=' +  part_number_config['march'])
+                candidate_march = part_number_config['march']
+            endif
         else
-            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
@@ -717,32 +738,44 @@ if update_flags
                 endif
             endforeach
         endif
-        if candidate_march == ''
-            error('No suitable armv8 march version found.')
-        endif
+
         if candidate_march != part_number_config['march']
-            warning('Configuration march version is ' +
-                    '@0@, but the compiler supports only @1@.'
-                    .format(part_number_config['march'], candidate_march))
+            warning('Configuration march version is @0@, not supported.'
+                    .format(part_number_config['march']))
+            if candidate_march != ''
+                warning('Using march version @0@.'.format(candidate_march))
+            endif
         endif
-        candidate_march = '-march=' + candidate_march

-        march_features = []
-        if part_number_config.has_key('march_features')
-            march_features += part_number_config['march_features']
+        if candidate_march == '' and candidate_mcpu == ''
+            error('No suitable ARM march/mcpu version found.')
         endif
-        if soc_config.has_key('extra_march_features')
-            march_features += soc_config['extra_march_features']
+
+        if candidate_march != ''
+            candidate_march = '-march=' + candidate_march
+            foreach feature: march_features
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    warning('The compiler does not support feature @0@'
+                        .format(feature))
+                endif
+            endforeach
+            machine_args += candidate_march
         endif
+    endif
+
+    if candidate_mcpu != ''
+        candidate_mcpu = '-mcpu=' + candidate_mcpu
         foreach feature: march_features
-            if cc.has_argument('+'.join([candidate_march, feature]))
-                candidate_march = '+'.join([candidate_march, feature])
+            if cc.has_argument('+'.join([candidate_mcpu, feature]))
+                candidate_mcpu = '+'.join([candidate_mcpu, feature])
             else
                 warning('The compiler does not support feature @0@'
                     .format(feature))
             endif
         endforeach
-        machine_args += candidate_march
+        machine_args += candidate_mcpu
     endif

     # apply supported compiler options
--
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v4 2/3] config/arm: add support for fallback march
  2024-02-21 20:20     ` [PATCH v4 " pbhagavatula
@ 2024-02-21 20:20       ` pbhagavatula
  2024-02-22 10:47         ` Juraj Linkeš
  2024-02-21 20:20       ` [PATCH v4 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 65+ messages in thread
From: pbhagavatula @ 2024-02-21 20:20 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some ARM CPUs have specific march requirements and
are not compatible with the supported march list.
Add fallback march in case the mcpu and the march
advertised in the part_number_config are not supported
by the compiler.

Example
        mcpu = neoverse-n2
        march = armv9-a
        fallback_march = armv8.5-a

        mcpu, march not supported
        machine_args = ['-march=armv8.5-a']

        mcpu, march, fallback_march not supported
        least march supported = armv8-a

        machine_args = ['-march=armv8-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 config/arm/meson.build | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index e77b696d8e..f6521653c8 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -94,6 +94,7 @@ part_number_config_arm = {
     '0xd49': {
         'march': 'armv9-a',
         'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
         'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
@@ -716,6 +717,7 @@ if update_flags
 
     # probe supported archs and their features
     candidate_march = ''
+    fallback_march = ''
     if part_number_config.has_key('march') and candidate_mcpu == ''
         if part_number_config.get('force_march', false)
             if cc.has_argument('-march=' +  part_number_config['march'])
@@ -736,10 +738,18 @@ if update_flags
                     # highest supported march version found
                     break
                 endif
+                if (part_number_config.has_key('fallback_march') and
+                    supported_march == part_number_config['fallback_march'] and
+                    cc.has_argument('-march=' + supported_march))
+                    fallback_march = supported_march
+                endif
             endforeach
         endif
 
         if candidate_march != part_number_config['march']
+            if fallback_march != ''
+                candidate_march = fallback_march
+            endif
             warning('Configuration march version is @0@, not supported.'
                     .format(part_number_config['march']))
             if candidate_march != ''
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v4 3/3] config/arm: allow WFE to be enabled config time
  2024-02-21 20:20     ` [PATCH v4 " pbhagavatula
  2024-02-21 20:20       ` [PATCH v4 2/3] config/arm: add support for fallback march pbhagavatula
@ 2024-02-21 20:20       ` pbhagavatula
  2024-02-22  9:37       ` [PATCH v4 1/3] config/arm: avoid mcpu and march conflicts Juraj Linkeš
  2024-02-22 12:45       ` [PATCH v5 " pbhagavatula
  3 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-21 20:20 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh, Chengwen Feng, Honnappa Nagarahalli

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Allow RTE_ARM_USE_WFE to be enabled at meson configuration
time by passing it via c_args instead of modifying
`config/arm/meson.build`.

Example usage:
 meson build -Dc_args='-DRTE_ARM_USE_WFE' \
	--cross-file config/arm/arm64_cn10k_linux_gcc

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
---
 config/arm/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index f6521653c8..78e80f6699 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -17,7 +17,9 @@ flags_common = [
         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
 
-        ['RTE_ARM_USE_WFE', false],
+        # Enable use of ARM wait for event instruction.
+        # ['RTE_ARM_USE_WFE', false],
+
         ['RTE_ARCH_ARM64', true],
         ['RTE_CACHE_LINE_SIZE', 128]
 ]
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v4 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-21 20:20     ` [PATCH v4 " pbhagavatula
  2024-02-21 20:20       ` [PATCH v4 2/3] config/arm: add support for fallback march pbhagavatula
  2024-02-21 20:20       ` [PATCH v4 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
@ 2024-02-22  9:37       ` Juraj Linkeš
  2024-02-22  9:49         ` [EXT] " Pavan Nikhilesh Bhagavatula
  2024-02-22 12:45       ` [PATCH v5 " pbhagavatula
  3 siblings, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-02-22  9:37 UTC (permalink / raw)
  To: pbhagavatula
  Cc: jerinj, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 36f21d2259..e77b696d8e 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
<snip>
> @@ -695,13 +698,31 @@ if update_flags
>
>      machine_args = [] # Clear previous machine args
>
> +    candidate_mcpu = ''
> +    if part_number_config.has_key('mcpu')
> +        mcpu = part_number_config['mcpu']
> +        if (cc.has_argument('-mcpu=' + mcpu))
> +            candidate_mcpu = mcpu
> +        endif
> +    endif
> +
> +    march_features = []
> +    if part_number_config.has_key('march_features')
> +        march_features += part_number_config['march_features']
> +    endif
> +    if soc_config.has_key('extra_march_features')
> +        march_features += soc_config['extra_march_features']
> +    endif
> +
>      # probe supported archs and their features
>      candidate_march = ''
> -    if part_number_config.has_key('march')
> +    if part_number_config.has_key('march') and candidate_mcpu == ''

If we reorganize the code a bit it would read better I think:
if candidate_mcpu != ''
    <mcpu code>
elif part_number_config.has_key('march')
    <march code>
else
    error(no mcpu and no march) # not sure whether this is needed or
wanted though

This would also match the order before - first process mcpu, then
march. Come to think of it, maybe we should put the march_features
code before the candidate_mcpu code since that is common code and
would thus also read a bit better (common, then mcpu, then march).

>          if part_number_config.get('force_march', false)
> -            candidate_march = part_number_config['march']
> +            if cc.has_argument('-march=' +  part_number_config['march'])
> +                candidate_march = part_number_config['march']
> +            endif
>          else
> -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
> +            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
>                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']
>              check_compiler_support = false
>              foreach supported_march: supported_marchs

^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [EXT] Re: [PATCH v4 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-22  9:37       ` [PATCH v4 1/3] config/arm: avoid mcpu and march conflicts Juraj Linkeš
@ 2024-02-22  9:49         ` Pavan Nikhilesh Bhagavatula
  0 siblings, 0 replies; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-02-22  9:49 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: Jerin Jacob, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

> > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > index 36f21d2259..e77b696d8e 100644
> > --- a/config/arm/meson.build
> > +++ b/config/arm/meson.build
> <snip>
> > @@ -695,13 +698,31 @@ if update_flags
> >
> >      machine_args = [] # Clear previous machine args
> >
> > +    candidate_mcpu = ''
> > +    if part_number_config.has_key('mcpu')
> > +        mcpu = part_number_config['mcpu']
> > +        if (cc.has_argument('-mcpu=' + mcpu))
> > +            candidate_mcpu = mcpu
> > +        endif
> > +    endif
> > +
> > +    march_features = []
> > +    if part_number_config.has_key('march_features')
> > +        march_features += part_number_config['march_features']
> > +    endif
> > +    if soc_config.has_key('extra_march_features')
> > +        march_features += soc_config['extra_march_features']
> > +    endif
> > +
> >      # probe supported archs and their features
> >      candidate_march = ''
> > -    if part_number_config.has_key('march')
> > +    if part_number_config.has_key('march') and candidate_mcpu == ''
> 
> If we reorganize the code a bit it would read better I think:
> if candidate_mcpu != ''
>     <mcpu code>
> elif part_number_config.has_key('march')
>     <march code>
> else
>     error(no mcpu and no march) # not sure whether this is needed or
> wanted though
> 
> This would also match the order before - first process mcpu, then
> march. Come to think of it, maybe we should put the march_features
> code before the candidate_mcpu code since that is common code and
> would thus also read a bit better (common, then mcpu, then march).

Ack, I will reorganize in v5.

Thanks,
Pavan. 

> 
> >          if part_number_config.get('force_march', false)
> > -            candidate_march = part_number_config['march']
> > +            if cc.has_argument('-march=' +  part_number_config['march'])
> > +                candidate_march = part_number_config['march']
> > +            endif
> >          else
> > -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-
> a',
> > +            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-
> a', 'armv8.3-a',
> >                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']
> >              check_compiler_support = false
> >              foreach supported_march: supported_marchs

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v4 2/3] config/arm: add support for fallback march
  2024-02-21 20:20       ` [PATCH v4 2/3] config/arm: add support for fallback march pbhagavatula
@ 2024-02-22 10:47         ` Juraj Linkeš
  2024-02-22 12:32           ` [EXT] " Pavan Nikhilesh Bhagavatula
  0 siblings, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-02-22 10:47 UTC (permalink / raw)
  To: pbhagavatula
  Cc: jerinj, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

On Wed, Feb 21, 2024 at 9:20 PM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Some ARM CPUs have specific march requirements and
> are not compatible with the supported march list.
> Add fallback march in case the mcpu and the march
> advertised in the part_number_config are not supported
> by the compiler.
>
> Example
>         mcpu = neoverse-n2
>         march = armv9-a
>         fallback_march = armv8.5-a
>
>         mcpu, march not supported
>         machine_args = ['-march=armv8.5-a']
>
>         mcpu, march, fallback_march not supported
>         least march supported = armv8-a
>
>         machine_args = ['-march=armv8-a']
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  config/arm/meson.build | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index e77b696d8e..f6521653c8 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -94,6 +94,7 @@ part_number_config_arm = {
>      '0xd49': {
>          'march': 'armv9-a',
>          'march_features': ['sve2'],
> +        'fallback_march': 'armv8.5-a',
>          'mcpu': 'neoverse-n2',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'],
> @@ -716,6 +717,7 @@ if update_flags
>
>      # probe supported archs and their features
>      candidate_march = ''
> +    fallback_march = ''
>      if part_number_config.has_key('march') and candidate_mcpu == ''
>          if part_number_config.get('force_march', false)
>              if cc.has_argument('-march=' +  part_number_config['march'])
> @@ -736,10 +738,18 @@ if update_flags
>                      # highest supported march version found
>                      break
>                  endif
> +                if (part_number_config.has_key('fallback_march') and
> +                    supported_march == part_number_config['fallback_march'] and
> +                    cc.has_argument('-march=' + supported_march))
> +                    fallback_march = supported_march
> +                endif

I'm trying to wrap my head around this. If I understand this
correctly, fallback_march is going to be set only if fallback_march >
part_number_config['march'] (fallback_march must be higher than the
one in part_number_config, otherwise the loop will end with break
before setting fallback_march).

The added fallback_march configuration above is the opposite
(fallback_march < part_number_config['march']) so I'm not sure what
we're trying to accomplish here. Is the intention to specify a
fallback_march that's lower than the one the original fallback
mechanism would find? If so, we'll need to remove the break (and
probably set check_compiler_support to false) so that the loop could
continue.

>              endforeach
>          endif
>
>          if candidate_march != part_number_config['march']
> +            if fallback_march != ''
> +                candidate_march = fallback_march
> +            endif
>              warning('Configuration march version is @0@, not supported.'
>                      .format(part_number_config['march']))
>              if candidate_march != ''
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [EXT] Re: [PATCH v4 2/3] config/arm: add support for fallback march
  2024-02-22 10:47         ` Juraj Linkeš
@ 2024-02-22 12:32           ` Pavan Nikhilesh Bhagavatula
  0 siblings, 0 replies; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-02-22 12:32 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: Jerin Jacob, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

> On Wed, Feb 21, 2024 at 9:20 PM <pbhagavatula@marvell.com> wrote:
> >
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > Some ARM CPUs have specific march requirements and
> > are not compatible with the supported march list.
> > Add fallback march in case the mcpu and the march
> > advertised in the part_number_config are not supported
> > by the compiler.
> >
> > Example
> >         mcpu = neoverse-n2
> >         march = armv9-a
> >         fallback_march = armv8.5-a
> >
> >         mcpu, march not supported
> >         machine_args = ['-march=armv8.5-a']
> >
> >         mcpu, march, fallback_march not supported
> >         least march supported = armv8-a
> >
> >         machine_args = ['-march=armv8-a']
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> >  config/arm/meson.build | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > index e77b696d8e..f6521653c8 100644
> > --- a/config/arm/meson.build
> > +++ b/config/arm/meson.build
> > @@ -94,6 +94,7 @@ part_number_config_arm = {
> >      '0xd49': {
> >          'march': 'armv9-a',
> >          'march_features': ['sve2'],
> > +        'fallback_march': 'armv8.5-a',
> >          'mcpu': 'neoverse-n2',
> >          'flags': [
> >              ['RTE_MACHINE', '"neoverse-n2"'],
> > @@ -716,6 +717,7 @@ if update_flags
> >
> >      # probe supported archs and their features
> >      candidate_march = ''
> > +    fallback_march = ''
> >      if part_number_config.has_key('march') and candidate_mcpu == ''
> >          if part_number_config.get('force_march', false)
> >              if cc.has_argument('-march=' +  part_number_config['march'])
> > @@ -736,10 +738,18 @@ if update_flags
> >                      # highest supported march version found
> >                      break
> >                  endif
> > +                if (part_number_config.has_key('fallback_march') and
> > +                    supported_march == part_number_config['fallback_march'] and
> > +                    cc.has_argument('-march=' + supported_march))
> > +                    fallback_march = supported_march
> > +                endif
> 
> I'm trying to wrap my head around this. If I understand this
> correctly, fallback_march is going to be set only if fallback_march >
> part_number_config['march'] (fallback_march must be higher than the
> one in part_number_config, otherwise the loop will end with break
> before setting fallback_march).
> 

Fallback_march will always be < part_number_config['march'].
If part_number_config['march'] is supported by the compiler then we don’t need
fallback march.

> The added fallback_march configuration above is the opposite
> (fallback_march < part_number_config['march']) so I'm not sure what
> we're trying to accomplish here. Is the intention to specify a
> fallback_march that's lower than the one the original fallback
> mechanism would find? If so, we'll need to remove the break

I missed the break part, will add that in along with candidate_march == '' check.

> (and
> probably set check_compiler_support to false) so that the loop could
> continue.
> 
> >              endforeach
> >          endif
> >
> >          if candidate_march != part_number_config['march']
> > +            if fallback_march != ''
> > +                candidate_march = fallback_march
> > +            endif
> >              warning('Configuration march version is @0@, not supported.'
> >                      .format(part_number_config['march']))
> >              if candidate_march != ''
> > --
> > 2.25.1
> >

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v5 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-21 20:20     ` [PATCH v4 " pbhagavatula
                         ` (2 preceding siblings ...)
  2024-02-22  9:37       ` [PATCH v4 1/3] config/arm: avoid mcpu and march conflicts Juraj Linkeš
@ 2024-02-22 12:45       ` pbhagavatula
  2024-02-22 12:45         ` [PATCH v5 2/3] config/arm: add support for fallback march pbhagavatula
                           ` (3 more replies)
  3 siblings, 4 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-22 12:45 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

The compiler options march and mtune are a subset
of mcpu and will lead to conflicts if improper march
is chosen for a given mcpu.
To avoid conflicts, discard part number march when
mcpu is available and is supported by the compiler.

Example:
	march = armv9-a
	mcpu = neoverse-n2

	mcpu supported, march supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu supported, march not supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu not supported, march supported
	machine_args = ['-march=armv9-a']

	mcpu not supported, march not supported
	machine_args = ['-march=armv8.6-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
v2 Changes:
- Cleanup march inconsistencies. (Juraj Linkes)
- Unify fallback march selection. (Juraj Linkes)
- Tag along ARM WFE patch.
v3 Changes:
- Fix missing 'fallback_march' key check.
v4 Changes:
- Discard march when mcpu is supported.
v5 Changes:
- Consolidate mcpu and march checks. (Juraj Linkes)
- Fix unintentionally skipping fallback march (Juraj Linkes)

 config/arm/meson.build | 116 +++++++++++++++++++++++++----------------
 1 file changed, 71 insertions(+), 45 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 36f21d2259..d05d54b564 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -58,18 +58,18 @@ implementer_generic = {
 }

 part_number_config_arm = {
-    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
-    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
-    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
-    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
-    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
-    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
+    '0xd03': {'mcpu': 'cortex-a53'},
+    '0xd04': {'mcpu': 'cortex-a35'},
+    '0xd05': {'mcpu': 'cortex-a55'},
+    '0xd07': {'mcpu': 'cortex-a57'},
+    '0xd08': {'mcpu': 'cortex-a72'},
+    '0xd09': {'mcpu': 'cortex-a73'},
+    '0xd0a': {'mcpu': 'cortex-a75'},
+    '0xd0b': {'mcpu': 'cortex-a76'},
     '0xd0c': {
         'march': 'armv8.2-a',
         'march_features': ['crypto', 'rcpc'],
-        'compiler_options':  ['-mcpu=neoverse-n1'],
+        'mcpu': 'neoverse-n1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -81,7 +81,7 @@ part_number_config_arm = {
     '0xd40': {
         'march': 'armv8.4-a',
         'march_features': ['sve'],
-        'compiler_options':  ['-mcpu=neoverse-v1'],
+        'mcpu': 'neoverse-v1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-v1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -92,8 +92,9 @@ part_number_config_arm = {
         'march': 'armv8.4-a',
     },
     '0xd49': {
+        'march': 'armv9-a',
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-n2'],
+        'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,21 +128,23 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'compiler_options': ['-mcpu=thunderxt88'],
+            'mcpu': 'thunderxt88',
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'compiler_options': ['-mcpu=thunderxt81'],
+            'mcpu': 'thunderxt81',
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'mcpu': 'thunderxt83',
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
             'march': 'armv8.1-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options': ['-mcpu=thunderx2t99'],
+            'mcpu': 'thunderx2t99',
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -153,7 +156,7 @@ implementer_cavium = {
         '0xb2': {
             'march': 'armv8.2-a',
             'march_features': ['crc', 'crypto', 'lse'],
-            'compiler_options': ['-mcpu=octeontx2'],
+            'mcpu': 'octeontx2',
             'flags': [
                 ['RTE_MACHINE', '"cn9k"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -176,7 +179,7 @@ implementer_ampere = {
         '0x0': {
             'march': 'armv8-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mtune=emag'],
+            'mcpu': 'emag',
             'flags': [
                 ['RTE_MACHINE', '"eMAG"'],
                 ['RTE_MAX_LCORE', 32],
@@ -186,7 +189,7 @@ implementer_ampere = {
         '0xac3': {
             'march': 'armv8.6-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mcpu=ampere1'],
+            'mcpu': 'ampere1',
             'flags': [
                 ['RTE_MACHINE', '"AmpereOne"'],
                 ['RTE_MAX_LCORE', 320],
@@ -206,7 +209,7 @@ implementer_hisilicon = {
         '0xd01': {
             'march': 'armv8.2-a',
             'march_features': ['crypto'],
-            'compiler_options': ['-mtune=tsv110'],
+            'mcpu': 'tsv110',
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -695,13 +698,37 @@ if update_flags

     machine_args = [] # Clear previous machine args

-    # probe supported archs and their features
+    march_features = []
+    if part_number_config.has_key('march_features')
+        march_features += part_number_config['march_features']
+    endif
+    if soc_config.has_key('extra_march_features')
+        march_features += soc_config['extra_march_features']
+    endif
+
+    candidate_mcpu = ''
     candidate_march = ''
-    if part_number_config.has_key('march')
+
+    if part_number_config.has_key('mcpu') and
+       cc.has_argument('-mcpu=' + part_number_config['mcpu'])
+        candidate_mcpu = '-mcpu=' + part_number_config['mcpu']
+        foreach feature: march_features
+            if cc.has_argument('+'.join([candidate_mcpu, feature]))
+                candidate_mcpu = '+'.join([candidate_mcpu, feature])
+            else
+                warning('The compiler does not support feature @0@'
+                    .format(feature))
+            endif
+        endforeach
+        machine_args += candidate_mcpu
+    elif part_number_config.has_key('march')
+        # probe supported archs and their features
         if part_number_config.get('force_march', false)
-            candidate_march = part_number_config['march']
+            if cc.has_argument('-march=' +  part_number_config['march'])
+                candidate_march = part_number_config['march']
+            endif
         else
-            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
@@ -717,32 +744,31 @@ if update_flags
                 endif
             endforeach
         endif
-        if candidate_march == ''
-            error('No suitable armv8 march version found.')
-        endif
+
         if candidate_march != part_number_config['march']
-            warning('Configuration march version is ' +
-                    '@0@, but the compiler supports only @1@.'
-                    .format(part_number_config['march'], candidate_march))
+            warning('Configuration march version is @0@, not supported.'
+                    .format(part_number_config['march']))
+            if candidate_march != ''
+                warning('Using march version @0@.'.format(candidate_march))
+            endif
         endif
-        candidate_march = '-march=' + candidate_march

-        march_features = []
-        if part_number_config.has_key('march_features')
-            march_features += part_number_config['march_features']
-        endif
-        if soc_config.has_key('extra_march_features')
-            march_features += soc_config['extra_march_features']
+        if candidate_march != ''
+            candidate_march = '-march=' + candidate_march
+            foreach feature: march_features
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    warning('The compiler does not support feature @0@'
+                        .format(feature))
+                endif
+            endforeach
+            machine_args += candidate_march
         endif
-        foreach feature: march_features
-            if cc.has_argument('+'.join([candidate_march, feature]))
-                candidate_march = '+'.join([candidate_march, feature])
-            else
-                warning('The compiler does not support feature @0@'
-                    .format(feature))
-            endif
-        endforeach
-        machine_args += candidate_march
+    endif
+
+    if candidate_mcpu == '' and candidate_march == ''
+        error('No suitable ARM march/mcpu version found.')
     endif

     # apply supported compiler options
--
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v5 2/3] config/arm: add support for fallback march
  2024-02-22 12:45       ` [PATCH v5 " pbhagavatula
@ 2024-02-22 12:45         ` pbhagavatula
  2024-02-23 11:49           ` Juraj Linkeš
  2024-02-22 12:45         ` [PATCH v5 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 65+ messages in thread
From: pbhagavatula @ 2024-02-22 12:45 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some ARM CPUs have specific march requirements and
are not compatible with the supported march list.
Add fallback march in case the mcpu and the march
advertised in the part_number_config are not supported
by the compiler.

Example
        mcpu = neoverse-n2
        march = armv9-a
        fallback_march = armv8.5-a

        mcpu, march not supported
        machine_args = ['-march=armv8.5-a']

        mcpu, march, fallback_march not supported
        least march supported = armv8-a

        machine_args = ['-march=armv8-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 config/arm/meson.build | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index d05d54b564..87ff5039f6 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -94,6 +94,7 @@ part_number_config_arm = {
     '0xd49': {
         'march': 'armv9-a',
         'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
         'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
@@ -708,6 +709,7 @@ if update_flags
 
     candidate_mcpu = ''
     candidate_march = ''
+    fallback_march = ''
 
     if part_number_config.has_key('mcpu') and
        cc.has_argument('-mcpu=' + part_number_config['mcpu'])
@@ -736,16 +738,22 @@ if update_flags
                     # start checking from this version downwards
                     check_compiler_support = true
                 endif
-                if (check_compiler_support and
+                if (check_compiler_support and candidate_march == '' and
                     cc.has_argument('-march=' + supported_march))
                     candidate_march = supported_march
-                    # highest supported march version found
-                    break
+                endif
+                if (part_number_config.has_key('fallback_march') and
+                    supported_march == part_number_config['fallback_march'] and
+                    cc.has_argument('-march=' + supported_march))
+                    fallback_march = supported_march
                 endif
             endforeach
         endif
 
         if candidate_march != part_number_config['march']
+            if fallback_march != ''
+                candidate_march = fallback_march
+            endif
             warning('Configuration march version is @0@, not supported.'
                     .format(part_number_config['march']))
             if candidate_march != ''
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v5 3/3] config/arm: allow WFE to be enabled config time
  2024-02-22 12:45       ` [PATCH v5 " pbhagavatula
  2024-02-22 12:45         ` [PATCH v5 2/3] config/arm: add support for fallback march pbhagavatula
@ 2024-02-22 12:45         ` pbhagavatula
  2024-02-23 11:19         ` [PATCH v5 1/3] config/arm: avoid mcpu and march conflicts Juraj Linkeš
  2024-02-26  7:38         ` [PATCH v6 " pbhagavatula
  3 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-22 12:45 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh, Chengwen Feng, Honnappa Nagarahalli

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Allow RTE_ARM_USE_WFE to be enabled at meson configuration
time by passing it via c_args instead of modifying
`config/arm/meson.build`.

Example usage:
 meson build -Dc_args='-DRTE_ARM_USE_WFE' \
	--cross-file config/arm/arm64_cn10k_linux_gcc

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
---
 config/arm/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 87ff5039f6..c26b8fb975 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -17,7 +17,9 @@ flags_common = [
         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
 
-        ['RTE_ARM_USE_WFE', false],
+        # Enable use of ARM wait for event instruction.
+        # ['RTE_ARM_USE_WFE', false],
+
         ['RTE_ARCH_ARM64', true],
         ['RTE_CACHE_LINE_SIZE', 128]
 ]
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v5 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-22 12:45       ` [PATCH v5 " pbhagavatula
  2024-02-22 12:45         ` [PATCH v5 2/3] config/arm: add support for fallback march pbhagavatula
  2024-02-22 12:45         ` [PATCH v5 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
@ 2024-02-23 11:19         ` Juraj Linkeš
  2024-02-26  7:08           ` [EXT] " Pavan Nikhilesh Bhagavatula
  2024-02-26  7:38         ` [PATCH v6 " pbhagavatula
  3 siblings, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-02-23 11:19 UTC (permalink / raw)
  To: pbhagavatula
  Cc: jerinj, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

Other than the one point below,
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>

> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 36f21d2259..d05d54b564 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
<snip>
> @@ -695,13 +698,37 @@ if update_flags
>
>      machine_args = [] # Clear previous machine args
>
> -    # probe supported archs and their features
> +    march_features = []
> +    if part_number_config.has_key('march_features')
> +        march_features += part_number_config['march_features']
> +    endif
> +    if soc_config.has_key('extra_march_features')
> +        march_features += soc_config['extra_march_features']
> +    endif
> +
> +    candidate_mcpu = ''
>      candidate_march = ''
> -    if part_number_config.has_key('march')
> +
> +    if part_number_config.has_key('mcpu') and
> +       cc.has_argument('-mcpu=' + part_number_config['mcpu'])
> +        candidate_mcpu = '-mcpu=' + part_number_config['mcpu']
> +        foreach feature: march_features
> +            if cc.has_argument('+'.join([candidate_mcpu, feature]))
> +                candidate_mcpu = '+'.join([candidate_mcpu, feature])
> +            else
> +                warning('The compiler does not support feature @0@'
> +                    .format(feature))
> +            endif
> +        endforeach
> +        machine_args += candidate_mcpu
> +    elif part_number_config.has_key('march')
> +        # probe supported archs and their features
>          if part_number_config.get('force_march', false)
> -            candidate_march = part_number_config['march']
> +            if cc.has_argument('-march=' +  part_number_config['march'])
> +                candidate_march = part_number_config['march']
> +            endif

The check was omitted here by design because aarch32 builds with some
compilers don't support -march=armv8-a alone, only with -mfpu= as
well.

>          else
> -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
> +            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
>                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']
>              check_compiler_support = false
>              foreach supported_march: supported_marchs
> @@ -717,32 +744,31 @@ if update_flags
>                  endif
>              endforeach
>          endif
> -        if candidate_march == ''
> -            error('No suitable armv8 march version found.')
> -        endif
> +
>          if candidate_march != part_number_config['march']
> -            warning('Configuration march version is ' +
> -                    '@0@, but the compiler supports only @1@.'
> -                    .format(part_number_config['march'], candidate_march))
> +            warning('Configuration march version is @0@, not supported.'
> +                    .format(part_number_config['march']))
> +            if candidate_march != ''
> +                warning('Using march version @0@.'.format(candidate_march))
> +            endif
>          endif
> -        candidate_march = '-march=' + candidate_march
>
> -        march_features = []
> -        if part_number_config.has_key('march_features')
> -            march_features += part_number_config['march_features']
> -        endif
> -        if soc_config.has_key('extra_march_features')
> -            march_features += soc_config['extra_march_features']
> +        if candidate_march != ''
> +            candidate_march = '-march=' + candidate_march
> +            foreach feature: march_features
> +                if cc.has_argument('+'.join([candidate_march, feature]))
> +                    candidate_march = '+'.join([candidate_march, feature])
> +                else
> +                    warning('The compiler does not support feature @0@'
> +                        .format(feature))
> +                endif
> +            endforeach
> +            machine_args += candidate_march
>          endif
> -        foreach feature: march_features
> -            if cc.has_argument('+'.join([candidate_march, feature]))
> -                candidate_march = '+'.join([candidate_march, feature])
> -            else
> -                warning('The compiler does not support feature @0@'
> -                    .format(feature))
> -            endif
> -        endforeach
> -        machine_args += candidate_march
> +    endif
> +
> +    if candidate_mcpu == '' and candidate_march == ''
> +        error('No suitable ARM march/mcpu version found.')
>      endif
>
>      # apply supported compiler options
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v5 2/3] config/arm: add support for fallback march
  2024-02-22 12:45         ` [PATCH v5 2/3] config/arm: add support for fallback march pbhagavatula
@ 2024-02-23 11:49           ` Juraj Linkeš
  2024-02-26  7:11             ` [EXT] " Pavan Nikhilesh Bhagavatula
  0 siblings, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-02-23 11:49 UTC (permalink / raw)
  To: pbhagavatula
  Cc: jerinj, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

On Thu, Feb 22, 2024 at 1:45 PM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Some ARM CPUs have specific march requirements and
> are not compatible with the supported march list.
> Add fallback march in case the mcpu and the march
> advertised in the part_number_config are not supported
> by the compiler.
>
> Example
>         mcpu = neoverse-n2
>         march = armv9-a
>         fallback_march = armv8.5-a
>
>         mcpu, march not supported
>         machine_args = ['-march=armv8.5-a']
>
>         mcpu, march, fallback_march not supported
>         least march supported = armv8-a
>
>         machine_args = ['-march=armv8-a']
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  config/arm/meson.build | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index d05d54b564..87ff5039f6 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -94,6 +94,7 @@ part_number_config_arm = {
>      '0xd49': {
>          'march': 'armv9-a',
>          'march_features': ['sve2'],
> +        'fallback_march': 'armv8.5-a',
>          'mcpu': 'neoverse-n2',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'],
> @@ -708,6 +709,7 @@ if update_flags
>
>      candidate_mcpu = ''
>      candidate_march = ''
> +    fallback_march = ''
>
>      if part_number_config.has_key('mcpu') and
>         cc.has_argument('-mcpu=' + part_number_config['mcpu'])
> @@ -736,16 +738,22 @@ if update_flags
>                      # start checking from this version downwards
>                      check_compiler_support = true
>                  endif
> -                if (check_compiler_support and
> +                if (check_compiler_support and candidate_march == '' and
>                      cc.has_argument('-march=' + supported_march))
>                      candidate_march = supported_march
> -                    # highest supported march version found
> -                    break
> +                endif
> +                if (part_number_config.has_key('fallback_march') and
> +                    supported_march == part_number_config['fallback_march'] and
> +                    cc.has_argument('-march=' + supported_march))
> +                    fallback_march = supported_march

If both fallback_march and march are supported, fallback_march is
going to be chosen over march. I think this is what we want instead:
Use march if supported,
then use fallback_march if supported,
then use the other fallback marchs.

If the above is indeed what we want, we could just put this after
endforeach (in the original version):

# at this point, candidate march is either
part_number_config['fallback_march'] or some other lower version
if (part_number_config.has_key('fallback_march') and
    candidate_march != part_number_config['march'] and
    cc.has_argument('-march=' + part_number_config['fallback_march']))
    # this overwrites only the lower version with preferred
fallback_march, if supported
    candidate_march = part_number_config['fallback_march']
endif

This way we won't even need the fallback_march variable.

>                  endif
>              endforeach
>          endif
>
>          if candidate_march != part_number_config['march']
> +            if fallback_march != ''
> +                candidate_march = fallback_march
> +            endif
>              warning('Configuration march version is @0@, not supported.'
>                      .format(part_number_config['march']))
>              if candidate_march != ''
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [EXT] Re: [PATCH v5 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-23 11:19         ` [PATCH v5 1/3] config/arm: avoid mcpu and march conflicts Juraj Linkeš
@ 2024-02-26  7:08           ` Pavan Nikhilesh Bhagavatula
  0 siblings, 0 replies; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-02-26  7:08 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: Jerin Jacob, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

> Other than the one point below,
> Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> 
> > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > index 36f21d2259..d05d54b564 100644
> > --- a/config/arm/meson.build
> > +++ b/config/arm/meson.build
> <snip>
> > @@ -695,13 +698,37 @@ if update_flags
> >
> >      machine_args = [] # Clear previous machine args
> >
> > -    # probe supported archs and their features
> > +    march_features = []
> > +    if part_number_config.has_key('march_features')
> > +        march_features += part_number_config['march_features']
> > +    endif
> > +    if soc_config.has_key('extra_march_features')
> > +        march_features += soc_config['extra_march_features']
> > +    endif
> > +
> > +    candidate_mcpu = ''
> >      candidate_march = ''
> > -    if part_number_config.has_key('march')
> > +
> > +    if part_number_config.has_key('mcpu') and
> > +       cc.has_argument('-mcpu=' + part_number_config['mcpu'])
> > +        candidate_mcpu = '-mcpu=' + part_number_config['mcpu']
> > +        foreach feature: march_features
> > +            if cc.has_argument('+'.join([candidate_mcpu, feature]))
> > +                candidate_mcpu = '+'.join([candidate_mcpu, feature])
> > +            else
> > +                warning('The compiler does not support feature @0@'
> > +                    .format(feature))
> > +            endif
> > +        endforeach
> > +        machine_args += candidate_mcpu
> > +    elif part_number_config.has_key('march')
> > +        # probe supported archs and their features
> >          if part_number_config.get('force_march', false)
> > -            candidate_march = part_number_config['march']
> > +            if cc.has_argument('-march=' +  part_number_config['march'])
> > +                candidate_march = part_number_config['march']
> > +            endif
> 
> The check was omitted here by design because aarch32 builds with some
> compilers don't support -march=armv8-a alone, only with -mfpu= as
> well.
> 

I see, I will remove the check in v6, Thanks.

> >          else
> > -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-
> a',
> > +            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-
> a', 'armv8.3-a',
> >                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']
> >              check_compiler_support = false
> >              foreach supported_march: supported_marchs
> > @@ -717,32 +744,31 @@ if update_flags
> >                  endif
> >              endforeach
> >          endif
> > -        if candidate_march == ''
> > -            error('No suitable armv8 march version found.')
> > -        endif
> > +
> >          if candidate_march != part_number_config['march']
> > -            warning('Configuration march version is ' +
> > -                    '@0@, but the compiler supports only @1@.'
> > -                    .format(part_number_config['march'], candidate_march))
> > +            warning('Configuration march version is @0@, not supported.'
> > +                    .format(part_number_config['march']))
> > +            if candidate_march != ''
> > +                warning('Using march version @0@.'.format(candidate_march))
> > +            endif
> >          endif
> > -        candidate_march = '-march=' + candidate_march
> >
> > -        march_features = []
> > -        if part_number_config.has_key('march_features')
> > -            march_features += part_number_config['march_features']
> > -        endif
> > -        if soc_config.has_key('extra_march_features')
> > -            march_features += soc_config['extra_march_features']
> > +        if candidate_march != ''
> > +            candidate_march = '-march=' + candidate_march
> > +            foreach feature: march_features
> > +                if cc.has_argument('+'.join([candidate_march, feature]))
> > +                    candidate_march = '+'.join([candidate_march, feature])
> > +                else
> > +                    warning('The compiler does not support feature @0@'
> > +                        .format(feature))
> > +                endif
> > +            endforeach
> > +            machine_args += candidate_march
> >          endif
> > -        foreach feature: march_features
> > -            if cc.has_argument('+'.join([candidate_march, feature]))
> > -                candidate_march = '+'.join([candidate_march, feature])
> > -            else
> > -                warning('The compiler does not support feature @0@'
> > -                    .format(feature))
> > -            endif
> > -        endforeach
> > -        machine_args += candidate_march
> > +    endif
> > +
> > +    if candidate_mcpu == '' and candidate_march == ''
> > +        error('No suitable ARM march/mcpu version found.')
> >      endif
> >
> >      # apply supported compiler options
> > --
> > 2.25.1
> >

^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [EXT] Re: [PATCH v5 2/3] config/arm: add support for fallback march
  2024-02-23 11:49           ` Juraj Linkeš
@ 2024-02-26  7:11             ` Pavan Nikhilesh Bhagavatula
  2024-02-26  7:31               ` Juraj Linkeš
  0 siblings, 1 reply; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-02-26  7:11 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: Jerin Jacob, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

> On Thu, Feb 22, 2024 at 1:45 PM <pbhagavatula@marvell.com> wrote:
> >
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > Some ARM CPUs have specific march requirements and
> > are not compatible with the supported march list.
> > Add fallback march in case the mcpu and the march
> > advertised in the part_number_config are not supported
> > by the compiler.
> >
> > Example
> >         mcpu = neoverse-n2
> >         march = armv9-a
> >         fallback_march = armv8.5-a
> >
> >         mcpu, march not supported
> >         machine_args = ['-march=armv8.5-a']
> >
> >         mcpu, march, fallback_march not supported
> >         least march supported = armv8-a
> >
> >         machine_args = ['-march=armv8-a']
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> >  config/arm/meson.build | 14 +++++++++++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > index d05d54b564..87ff5039f6 100644
> > --- a/config/arm/meson.build
> > +++ b/config/arm/meson.build
> > @@ -94,6 +94,7 @@ part_number_config_arm = {
> >      '0xd49': {
> >          'march': 'armv9-a',
> >          'march_features': ['sve2'],
> > +        'fallback_march': 'armv8.5-a',
> >          'mcpu': 'neoverse-n2',
> >          'flags': [
> >              ['RTE_MACHINE', '"neoverse-n2"'],
> > @@ -708,6 +709,7 @@ if update_flags
> >
> >      candidate_mcpu = ''
> >      candidate_march = ''
> > +    fallback_march = ''
> >
> >      if part_number_config.has_key('mcpu') and
> >         cc.has_argument('-mcpu=' + part_number_config['mcpu'])
> > @@ -736,16 +738,22 @@ if update_flags
> >                      # start checking from this version downwards
> >                      check_compiler_support = true
> >                  endif
> > -                if (check_compiler_support and
> > +                if (check_compiler_support and candidate_march == '' and
> >                      cc.has_argument('-march=' + supported_march))
> >                      candidate_march = supported_march
> > -                    # highest supported march version found
> > -                    break
> > +                endif
> > +                if (part_number_config.has_key('fallback_march') and
> > +                    supported_march == part_number_config['fallback_march'] and
> > +                    cc.has_argument('-march=' + supported_march))
> > +                    fallback_march = supported_march
> 
> If both fallback_march and march are supported, fallback_march is
> going to be chosen over march.

The current flow still chooses the march

Message: Arm implementer: Arm
Message: Arm part number: 0xd49
Compiler for C supports arguments -march=armv9-a: YES 
Compiler for C supports arguments -march=armv8.5-a: YES 
Compiler for C supports arguments -march=armv9-a+sve2: YES 
Compiler for C supports arguments -march=armv9-a+sve2+crypto: YES 
Message: Using machine args: ['-march=armv9-a+sve2+crypto']


> I think this is what we want instead:
> Use march if supported,
> then use fallback_march if supported,
> then use the other fallback marchs.
> 
> If the above is indeed what we want, we could just put this after
> endforeach (in the original version):
> 
> # at this point, candidate march is either
> part_number_config['fallback_march'] or some other lower version
> if (part_number_config.has_key('fallback_march') and
>     candidate_march != part_number_config['march'] and
>     cc.has_argument('-march=' + part_number_config['fallback_march']))
>     # this overwrites only the lower version with preferred
> fallback_march, if supported
>     candidate_march = part_number_config['fallback_march']
> endif
> 
> This way we won't even need the fallback_march variable.

Sure, I will change remove fallback_march variable, Thanks.

> 
> >                  endif
> >              endforeach
> >          endif
> >
> >          if candidate_march != part_number_config['march']
> > +            if fallback_march != ''
> > +                candidate_march = fallback_march
> > +            endif
> >              warning('Configuration march version is @0@, not supported.'
> >                      .format(part_number_config['march']))
> >              if candidate_march != ''
> > --
> > 2.25.1
> >

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [EXT] Re: [PATCH v5 2/3] config/arm: add support for fallback march
  2024-02-26  7:11             ` [EXT] " Pavan Nikhilesh Bhagavatula
@ 2024-02-26  7:31               ` Juraj Linkeš
  2024-02-26  7:34                 ` Juraj Linkeš
  0 siblings, 1 reply; 65+ messages in thread
From: Juraj Linkeš @ 2024-02-26  7:31 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula
  Cc: Jerin Jacob, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

On Mon, Feb 26, 2024 at 8:11 AM Pavan Nikhilesh Bhagavatula
<pbhagavatula@marvell.com> wrote:
>
> > On Thu, Feb 22, 2024 at 1:45 PM <pbhagavatula@marvell.com> wrote:
> > >
> > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > >
> > > Some ARM CPUs have specific march requirements and
> > > are not compatible with the supported march list.
> > > Add fallback march in case the mcpu and the march
> > > advertised in the part_number_config are not supported
> > > by the compiler.
> > >
> > > Example
> > >         mcpu = neoverse-n2
> > >         march = armv9-a
> > >         fallback_march = armv8.5-a
> > >
> > >         mcpu, march not supported
> > >         machine_args = ['-march=armv8.5-a']
> > >
> > >         mcpu, march, fallback_march not supported
> > >         least march supported = armv8-a
> > >
> > >         machine_args = ['-march=armv8-a']
> > >

Ah, of course, fallback march is only applied if when candidate_march
!= part_number_config['march']. Thanks.

> > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > ---
> > >  config/arm/meson.build | 14 +++++++++++---
> > >  1 file changed, 11 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > index d05d54b564..87ff5039f6 100644
> > > --- a/config/arm/meson.build
> > > +++ b/config/arm/meson.build
> > > @@ -94,6 +94,7 @@ part_number_config_arm = {
> > >      '0xd49': {
> > >          'march': 'armv9-a',
> > >          'march_features': ['sve2'],
> > > +        'fallback_march': 'armv8.5-a',
> > >          'mcpu': 'neoverse-n2',
> > >          'flags': [
> > >              ['RTE_MACHINE', '"neoverse-n2"'],
> > > @@ -708,6 +709,7 @@ if update_flags
> > >
> > >      candidate_mcpu = ''
> > >      candidate_march = ''
> > > +    fallback_march = ''
> > >
> > >      if part_number_config.has_key('mcpu') and
> > >         cc.has_argument('-mcpu=' + part_number_config['mcpu'])
> > > @@ -736,16 +738,22 @@ if update_flags
> > >                      # start checking from this version downwards
> > >                      check_compiler_support = true
> > >                  endif
> > > -                if (check_compiler_support and
> > > +                if (check_compiler_support and candidate_march == '' and
> > >                      cc.has_argument('-march=' + supported_march))
> > >                      candidate_march = supported_march
> > > -                    # highest supported march version found
> > > -                    break
> > > +                endif
> > > +                if (part_number_config.has_key('fallback_march') and
> > > +                    supported_march == part_number_config['fallback_march'] and
> > > +                    cc.has_argument('-march=' + supported_march))
> > > +                    fallback_march = supported_march
> >
> > If both fallback_march and march are supported, fallback_march is
> > going to be chosen over march.
>
> The current flow still chooses the march
>
> Message: Arm implementer: Arm
> Message: Arm part number: 0xd49
> Compiler for C supports arguments -march=armv9-a: YES
> Compiler for C supports arguments -march=armv8.5-a: YES
> Compiler for C supports arguments -march=armv9-a+sve2: YES
> Compiler for C supports arguments -march=armv9-a+sve2+crypto: YES
> Message: Using machine args: ['-march=armv9-a+sve2+crypto']
>
>
> > I think this is what we want instead:
> > Use march if supported,
> > then use fallback_march if supported,
> > then use the other fallback marchs.
> >
> > If the above is indeed what we want, we could just put this after
> > endforeach (in the original version):
> >
> > # at this point, candidate march is either
> > part_number_config['fallback_march'] or some other lower version
> > if (part_number_config.has_key('fallback_march') and
> >     candidate_march != part_number_config['march'] and
> >     cc.has_argument('-march=' + part_number_config['fallback_march']))
> >     # this overwrites only the lower version with preferred
> > fallback_march, if supported
> >     candidate_march = part_number_config['fallback_march']
> > endif
> >
> > This way we won't even need the fallback_march variable.
>
> Sure, I will change remove fallback_march variable, Thanks.
>
> >
> > >                  endif
> > >              endforeach
> > >          endif
> > >
> > >          if candidate_march != part_number_config['march']
> > > +            if fallback_march != ''
> > > +                candidate_march = fallback_march
> > > +            endif
> > >              warning('Configuration march version is @0@, not supported.'
> > >                      .format(part_number_config['march']))
> > >              if candidate_march != ''
> > > --
> > > 2.25.1
> > >

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [EXT] Re: [PATCH v5 2/3] config/arm: add support for fallback march
  2024-02-26  7:31               ` Juraj Linkeš
@ 2024-02-26  7:34                 ` Juraj Linkeš
  0 siblings, 0 replies; 65+ messages in thread
From: Juraj Linkeš @ 2024-02-26  7:34 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula
  Cc: Jerin Jacob, nd, wathsala.vithanage, Ruifeng Wang, Bruce Richardson, dev

I Forgot to add my tag:
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>

On Mon, Feb 26, 2024 at 8:31 AM Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
>
> On Mon, Feb 26, 2024 at 8:11 AM Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com> wrote:
> >
> > > On Thu, Feb 22, 2024 at 1:45 PM <pbhagavatula@marvell.com> wrote:
> > > >
> > > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > >
> > > > Some ARM CPUs have specific march requirements and
> > > > are not compatible with the supported march list.
> > > > Add fallback march in case the mcpu and the march
> > > > advertised in the part_number_config are not supported
> > > > by the compiler.
> > > >
> > > > Example
> > > >         mcpu = neoverse-n2
> > > >         march = armv9-a
> > > >         fallback_march = armv8.5-a
> > > >
> > > >         mcpu, march not supported
> > > >         machine_args = ['-march=armv8.5-a']
> > > >
> > > >         mcpu, march, fallback_march not supported
> > > >         least march supported = armv8-a
> > > >
> > > >         machine_args = ['-march=armv8-a']
> > > >
>
> Ah, of course, fallback march is only applied if when candidate_march
> != part_number_config['march']. Thanks.
>
> > > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > > ---
> > > >  config/arm/meson.build | 14 +++++++++++---
> > > >  1 file changed, 11 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > > index d05d54b564..87ff5039f6 100644
> > > > --- a/config/arm/meson.build
> > > > +++ b/config/arm/meson.build
> > > > @@ -94,6 +94,7 @@ part_number_config_arm = {
> > > >      '0xd49': {
> > > >          'march': 'armv9-a',
> > > >          'march_features': ['sve2'],
> > > > +        'fallback_march': 'armv8.5-a',
> > > >          'mcpu': 'neoverse-n2',
> > > >          'flags': [
> > > >              ['RTE_MACHINE', '"neoverse-n2"'],
> > > > @@ -708,6 +709,7 @@ if update_flags
> > > >
> > > >      candidate_mcpu = ''
> > > >      candidate_march = ''
> > > > +    fallback_march = ''
> > > >
> > > >      if part_number_config.has_key('mcpu') and
> > > >         cc.has_argument('-mcpu=' + part_number_config['mcpu'])
> > > > @@ -736,16 +738,22 @@ if update_flags
> > > >                      # start checking from this version downwards
> > > >                      check_compiler_support = true
> > > >                  endif
> > > > -                if (check_compiler_support and
> > > > +                if (check_compiler_support and candidate_march == '' and
> > > >                      cc.has_argument('-march=' + supported_march))
> > > >                      candidate_march = supported_march
> > > > -                    # highest supported march version found
> > > > -                    break
> > > > +                endif
> > > > +                if (part_number_config.has_key('fallback_march') and
> > > > +                    supported_march == part_number_config['fallback_march'] and
> > > > +                    cc.has_argument('-march=' + supported_march))
> > > > +                    fallback_march = supported_march
> > >
> > > If both fallback_march and march are supported, fallback_march is
> > > going to be chosen over march.
> >
> > The current flow still chooses the march
> >
> > Message: Arm implementer: Arm
> > Message: Arm part number: 0xd49
> > Compiler for C supports arguments -march=armv9-a: YES
> > Compiler for C supports arguments -march=armv8.5-a: YES
> > Compiler for C supports arguments -march=armv9-a+sve2: YES
> > Compiler for C supports arguments -march=armv9-a+sve2+crypto: YES
> > Message: Using machine args: ['-march=armv9-a+sve2+crypto']
> >
> >
> > > I think this is what we want instead:
> > > Use march if supported,
> > > then use fallback_march if supported,
> > > then use the other fallback marchs.
> > >
> > > If the above is indeed what we want, we could just put this after
> > > endforeach (in the original version):
> > >
> > > # at this point, candidate march is either
> > > part_number_config['fallback_march'] or some other lower version
> > > if (part_number_config.has_key('fallback_march') and
> > >     candidate_march != part_number_config['march'] and
> > >     cc.has_argument('-march=' + part_number_config['fallback_march']))
> > >     # this overwrites only the lower version with preferred
> > > fallback_march, if supported
> > >     candidate_march = part_number_config['fallback_march']
> > > endif
> > >
> > > This way we won't even need the fallback_march variable.
> >
> > Sure, I will change remove fallback_march variable, Thanks.
> >
> > >
> > > >                  endif
> > > >              endforeach
> > > >          endif
> > > >
> > > >          if candidate_march != part_number_config['march']
> > > > +            if fallback_march != ''
> > > > +                candidate_march = fallback_march
> > > > +            endif
> > > >              warning('Configuration march version is @0@, not supported.'
> > > >                      .format(part_number_config['march']))
> > > >              if candidate_march != ''
> > > > --
> > > > 2.25.1
> > > >

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v6 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-22 12:45       ` [PATCH v5 " pbhagavatula
                           ` (2 preceding siblings ...)
  2024-02-23 11:19         ` [PATCH v5 1/3] config/arm: avoid mcpu and march conflicts Juraj Linkeš
@ 2024-02-26  7:38         ` pbhagavatula
  2024-02-26  7:38           ` [PATCH v6 2/3] config/arm: add support for fallback march pbhagavatula
                             ` (2 more replies)
  3 siblings, 3 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-26  7:38 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

The compiler options march and mtune are a subset
of mcpu and will lead to conflicts if improper march
is chosen for a given mcpu.
To avoid conflicts, discard part number march when
mcpu is available and is supported by the compiler.

Example:
	march = armv9-a
	mcpu = neoverse-n2

	mcpu supported, march supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu supported, march not supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu not supported, march supported
	machine_args = ['-march=armv9-a']

	mcpu not supported, march not supported
	machine_args = ['-march=armv8.6-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
v2 Changes:
- Cleanup march inconsistencies. (Juraj Linkes)
- Unify fallback march selection. (Juraj Linkes)
- Tag along ARM WFE patch.
v3 Changes:
- Fix missing 'fallback_march' key check.
v4 Changes:
- Discard march when mcpu is supported.
v5 Changes:
- Consolidate mcpu and march checks. (Juraj Linkes)
- Fix unintentionally skipping fallback march (Juraj Linkes)
v6 Changes:
- Remove compiler support check when march is forced. (Juraj Linkes)
- Simplify fallback march configuration.

 config/arm/meson.build | 112 +++++++++++++++++++++++++----------------
 1 file changed, 68 insertions(+), 44 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 36f21d2259..236ad3702d 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -58,18 +58,18 @@ implementer_generic = {
 }

 part_number_config_arm = {
-    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
-    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
-    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
-    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
-    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
-    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
+    '0xd03': {'mcpu': 'cortex-a53'},
+    '0xd04': {'mcpu': 'cortex-a35'},
+    '0xd05': {'mcpu': 'cortex-a55'},
+    '0xd07': {'mcpu': 'cortex-a57'},
+    '0xd08': {'mcpu': 'cortex-a72'},
+    '0xd09': {'mcpu': 'cortex-a73'},
+    '0xd0a': {'mcpu': 'cortex-a75'},
+    '0xd0b': {'mcpu': 'cortex-a76'},
     '0xd0c': {
         'march': 'armv8.2-a',
         'march_features': ['crypto', 'rcpc'],
-        'compiler_options':  ['-mcpu=neoverse-n1'],
+        'mcpu': 'neoverse-n1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -81,7 +81,7 @@ part_number_config_arm = {
     '0xd40': {
         'march': 'armv8.4-a',
         'march_features': ['sve'],
-        'compiler_options':  ['-mcpu=neoverse-v1'],
+        'mcpu': 'neoverse-v1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-v1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -92,8 +92,9 @@ part_number_config_arm = {
         'march': 'armv8.4-a',
     },
     '0xd49': {
+        'march': 'armv9-a',
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-n2'],
+        'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,21 +128,23 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'compiler_options': ['-mcpu=thunderxt88'],
+            'mcpu': 'thunderxt88',
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'compiler_options': ['-mcpu=thunderxt81'],
+            'mcpu': 'thunderxt81',
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'mcpu': 'thunderxt83',
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
             'march': 'armv8.1-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options': ['-mcpu=thunderx2t99'],
+            'mcpu': 'thunderx2t99',
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -153,7 +156,7 @@ implementer_cavium = {
         '0xb2': {
             'march': 'armv8.2-a',
             'march_features': ['crc', 'crypto', 'lse'],
-            'compiler_options': ['-mcpu=octeontx2'],
+            'mcpu': 'octeontx2',
             'flags': [
                 ['RTE_MACHINE', '"cn9k"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -176,7 +179,7 @@ implementer_ampere = {
         '0x0': {
             'march': 'armv8-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mtune=emag'],
+            'mcpu': 'emag',
             'flags': [
                 ['RTE_MACHINE', '"eMAG"'],
                 ['RTE_MAX_LCORE', 32],
@@ -186,7 +189,7 @@ implementer_ampere = {
         '0xac3': {
             'march': 'armv8.6-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mcpu=ampere1'],
+            'mcpu': 'ampere1',
             'flags': [
                 ['RTE_MACHINE', '"AmpereOne"'],
                 ['RTE_MAX_LCORE', 320],
@@ -206,7 +209,7 @@ implementer_hisilicon = {
         '0xd01': {
             'march': 'armv8.2-a',
             'march_features': ['crypto'],
-            'compiler_options': ['-mtune=tsv110'],
+            'mcpu': 'tsv110',
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -695,13 +698,35 @@ if update_flags

     machine_args = [] # Clear previous machine args

-    # probe supported archs and their features
+    march_features = []
+    if part_number_config.has_key('march_features')
+        march_features += part_number_config['march_features']
+    endif
+    if soc_config.has_key('extra_march_features')
+        march_features += soc_config['extra_march_features']
+    endif
+
+    candidate_mcpu = ''
     candidate_march = ''
-    if part_number_config.has_key('march')
+
+    if (part_number_config.has_key('mcpu') and
+        cc.has_argument('-mcpu=' + part_number_config['mcpu']))
+        candidate_mcpu = '-mcpu=' + part_number_config['mcpu']
+        foreach feature: march_features
+            if cc.has_argument('+'.join([candidate_mcpu, feature]))
+                candidate_mcpu = '+'.join([candidate_mcpu, feature])
+            else
+                warning('The compiler does not support feature @0@'
+                    .format(feature))
+            endif
+        endforeach
+        machine_args += candidate_mcpu
+    elif part_number_config.has_key('march')
+        # probe supported archs and their features
         if part_number_config.get('force_march', false)
             candidate_march = part_number_config['march']
         else
-            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
@@ -717,32 +742,31 @@ if update_flags
                 endif
             endforeach
         endif
-        if candidate_march == ''
-            error('No suitable armv8 march version found.')
-        endif
+
         if candidate_march != part_number_config['march']
-            warning('Configuration march version is ' +
-                    '@0@, but the compiler supports only @1@.'
-                    .format(part_number_config['march'], candidate_march))
+            warning('Configuration march version is @0@, not supported.'
+                    .format(part_number_config['march']))
+            if candidate_march != ''
+                warning('Using march version @0@.'.format(candidate_march))
+            endif
         endif
-        candidate_march = '-march=' + candidate_march

-        march_features = []
-        if part_number_config.has_key('march_features')
-            march_features += part_number_config['march_features']
-        endif
-        if soc_config.has_key('extra_march_features')
-            march_features += soc_config['extra_march_features']
+        if candidate_march != ''
+            candidate_march = '-march=' + candidate_march
+            foreach feature: march_features
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    warning('The compiler does not support feature @0@'
+                        .format(feature))
+                endif
+            endforeach
+            machine_args += candidate_march
         endif
-        foreach feature: march_features
-            if cc.has_argument('+'.join([candidate_march, feature]))
-                candidate_march = '+'.join([candidate_march, feature])
-            else
-                warning('The compiler does not support feature @0@'
-                    .format(feature))
-            endif
-        endforeach
-        machine_args += candidate_march
+    endif
+
+    if candidate_mcpu == '' and candidate_march == ''
+        error('No suitable ARM march/mcpu version found.')
     endif

     # apply supported compiler options
--
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v6 2/3] config/arm: add support for fallback march
  2024-02-26  7:38         ` [PATCH v6 " pbhagavatula
@ 2024-02-26  7:38           ` pbhagavatula
  2024-02-26  7:38           ` [PATCH v6 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
  2024-03-06 15:49           ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
  2 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-26  7:38 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some ARM CPUs have specific march requirements and
are not compatible with the supported march list.
Add fallback march in case the mcpu and the march
advertised in the part_number_config are not supported
by the compiler.

Example
        mcpu = neoverse-n2
        march = armv9-a
        fallback_march = armv8.5-a

        mcpu, march not supported
        machine_args = ['-march=armv8.5-a']

        mcpu, march, fallback_march not supported
        least march supported = armv8-a

        machine_args = ['-march=armv8-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 236ad3702d..7f856709ef 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -94,6 +94,7 @@ part_number_config_arm = {
     '0xd49': {
         'march': 'armv9-a',
         'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
         'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
@@ -741,6 +742,11 @@ if update_flags
                     break
                 endif
             endforeach
+            if (part_number_config.has_key('fallback_march') and
+                candidate_march != part_number_config['march'] and
+                cc.has_argument('-march=' + part_number_config['fallback_march']))
+                    candidate_march = part_number_config['fallback_march']
+            endif
         endif

         if candidate_march != part_number_config['march']
--
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v6 3/3] config/arm: allow WFE to be enabled config time
  2024-02-26  7:38         ` [PATCH v6 " pbhagavatula
  2024-02-26  7:38           ` [PATCH v6 2/3] config/arm: add support for fallback march pbhagavatula
@ 2024-02-26  7:38           ` pbhagavatula
  2024-03-06 15:49           ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
  2 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-02-26  7:38 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh, Chengwen Feng, Honnappa Nagarahalli

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Allow RTE_ARM_USE_WFE to be enabled at meson configuration
time by passing it via c_args instead of modifying
`config/arm/meson.build`.

Example usage:
 meson build -Dc_args='-DRTE_ARM_USE_WFE' \
	--cross-file config/arm/arm64_cn10k_linux_gcc

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
---
 config/arm/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 7f856709ef..c1300a8ce8 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -17,7 +17,9 @@ flags_common = [
         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
 
-        ['RTE_ARM_USE_WFE', false],
+        # Enable use of ARM wait for event instruction.
+        # ['RTE_ARM_USE_WFE', false],
+
         ['RTE_ARCH_ARM64', true],
         ['RTE_CACHE_LINE_SIZE', 128]
 ]
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts
  2024-02-26  7:38         ` [PATCH v6 " pbhagavatula
  2024-02-26  7:38           ` [PATCH v6 2/3] config/arm: add support for fallback march pbhagavatula
  2024-02-26  7:38           ` [PATCH v6 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
@ 2024-03-06 15:49           ` pbhagavatula
  2024-03-06 15:49             ` [PATCH v7 2/3] config/arm: add support for fallback march pbhagavatula
                               ` (3 more replies)
  2 siblings, 4 replies; 65+ messages in thread
From: pbhagavatula @ 2024-03-06 15:49 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

The compiler options march and mtune are a subset
of mcpu and will lead to conflicts if improper march
is chosen for a given mcpu.
To avoid conflicts, discard part number march when
mcpu is available and is supported by the compiler.

Example:
	march = armv9-a
	mcpu = neoverse-n2

	mcpu supported, march supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu supported, march not supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu not supported, march supported
	machine_args = ['-march=armv9-a']

	mcpu not supported, march not supported
	machine_args = ['-march=armv8.6-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
v2 Changes:
- Cleanup march inconsistencies. (Juraj Linkes)
- Unify fallback march selection. (Juraj Linkes)
- Tag along ARM WFE patch.
v3 Changes:
- Fix missing 'fallback_march' key check.
v4 Changes:
- Discard march when mcpu is supported.
v5 Changes:
- Consolidate mcpu and march checks. (Juraj Linkes)
- Fix unintentionally skipping fallback march (Juraj Linkes)
v6 Changes:
- Remove compiler support check when march is forced. (Juraj Linkes)
- Simplify fallback march configuration.
v7 Changes:
- Rebase on master.

 config/arm/meson.build | 119 +++++++++++++++++++++++++----------------
 1 file changed, 72 insertions(+), 47 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index dc31fe3d78..472a30f83a 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -58,18 +58,18 @@ implementer_generic = {
 }

 part_number_config_arm = {
-    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
-    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
-    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
-    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
-    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
-    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
+    '0xd03': {'mcpu': 'cortex-a53'},
+    '0xd04': {'mcpu': 'cortex-a35'},
+    '0xd05': {'mcpu': 'cortex-a55'},
+    '0xd07': {'mcpu': 'cortex-a57'},
+    '0xd08': {'mcpu': 'cortex-a72'},
+    '0xd09': {'mcpu': 'cortex-a73'},
+    '0xd0a': {'mcpu': 'cortex-a75'},
+    '0xd0b': {'mcpu': 'cortex-a76'},
     '0xd0c': {
         'march': 'armv8.2-a',
         'march_features': ['crypto', 'rcpc'],
-        'compiler_options':  ['-mcpu=neoverse-n1'],
+        'mcpu': 'neoverse-n1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -81,7 +81,7 @@ part_number_config_arm = {
     '0xd40': {
         'march': 'armv8.4-a',
         'march_features': ['sve'],
-        'compiler_options':  ['-mcpu=neoverse-v1'],
+        'mcpu': 'neoverse-v1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-v1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -92,8 +92,9 @@ part_number_config_arm = {
         'march': 'armv8.4-a',
     },
     '0xd49': {
+        'march': 'armv9-a',
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-n2'],
+        'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -102,8 +103,9 @@ part_number_config_arm = {
         ]
     },
     '0xd4f': {
+        'march' : 'armv9-a',
+        'mcpu' : 'neoverse-v2',
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-v2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-v2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -137,21 +139,23 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'compiler_options': ['-mcpu=thunderxt88'],
+            'mcpu': 'thunderxt88',
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'compiler_options': ['-mcpu=thunderxt81'],
+            'mcpu': 'thunderxt81',
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
+            'march': 'armv8-a',
+            'march_features': ['crc', 'crypto'],
+            'mcpu': 'thunderxt83',
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
             'march': 'armv8.1-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options': ['-mcpu=thunderx2t99'],
+            'mcpu': 'thunderx2t99',
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -163,7 +167,7 @@ implementer_cavium = {
         '0xb2': {
             'march': 'armv8.2-a',
             'march_features': ['crc', 'crypto', 'lse'],
-            'compiler_options': ['-mcpu=octeontx2'],
+            'mcpu': 'octeontx2',
             'flags': [
                 ['RTE_MACHINE', '"cn9k"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -186,7 +190,7 @@ implementer_ampere = {
         '0x0': {
             'march': 'armv8-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mtune=emag'],
+            'mcpu': 'emag',
             'flags': [
                 ['RTE_MACHINE', '"eMAG"'],
                 ['RTE_MAX_LCORE', 32],
@@ -196,7 +200,7 @@ implementer_ampere = {
         '0xac3': {
             'march': 'armv8.6-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mcpu=ampere1'],
+            'mcpu': 'ampere1',
             'flags': [
                 ['RTE_MACHINE', '"AmpereOne"'],
                 ['RTE_MAX_LCORE', 320],
@@ -216,7 +220,7 @@ implementer_hisilicon = {
         '0xd01': {
             'march': 'armv8.2-a',
             'march_features': ['crypto'],
-            'compiler_options': ['-mtune=tsv110'],
+            'mcpu': 'tsv110',
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -258,14 +262,14 @@ implementer_ionic = {
     ],
     'part_number_config': {
         '0xc1': {
-            'compiler_options':  ['-mcpu=cortex-a72'],
+            'mcpu' : 'cortex-a72',
             'flags': [
                 ['RTE_MAX_LCORE', 4],
                 ['RTE_LIBRTE_IONIC_PMD_BARRIER_ERRATA', true],
             ]
         },
         '0xc2': {
-            'compiler_options':  ['-mcpu=cortex-a72'],
+            'mcpu' : 'cortex-a72',
             'flags': [
                 ['RTE_MAX_LCORE', 16],
                 ['RTE_LIBRTE_IONIC_PMD_BARRIER_ERRATA', true],
@@ -782,13 +786,35 @@ if update_flags

     machine_args = [] # Clear previous machine args

-    # probe supported archs and their features
+    march_features = []
+    if part_number_config.has_key('march_features')
+        march_features += part_number_config['march_features']
+    endif
+    if soc_config.has_key('extra_march_features')
+        march_features += soc_config['extra_march_features']
+    endif
+
+    candidate_mcpu = ''
     candidate_march = ''
-    if part_number_config.has_key('march')
+
+    if (part_number_config.has_key('mcpu') and
+        cc.has_argument('-mcpu=' + part_number_config['mcpu']))
+        candidate_mcpu = '-mcpu=' + part_number_config['mcpu']
+        foreach feature: march_features
+            if cc.has_argument('+'.join([candidate_mcpu, feature]))
+                candidate_mcpu = '+'.join([candidate_mcpu, feature])
+            else
+                warning('The compiler does not support feature @0@'
+                    .format(feature))
+            endif
+        endforeach
+        machine_args += candidate_mcpu
+    elif part_number_config.has_key('march')
+        # probe supported archs and their features
         if part_number_config.get('force_march', false)
             candidate_march = part_number_config['march']
         else
-            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
@@ -804,32 +830,31 @@ if update_flags
                 endif
             endforeach
         endif
-        if candidate_march == ''
-            error('No suitable armv8 march version found.')
-        endif
+
         if candidate_march != part_number_config['march']
-            warning('Configuration march version is ' +
-                    '@0@, but the compiler supports only @1@.'
-                    .format(part_number_config['march'], candidate_march))
+            warning('Configuration march version is @0@, not supported.'
+                    .format(part_number_config['march']))
+            if candidate_march != ''
+                warning('Using march version @0@.'.format(candidate_march))
+            endif
         endif
-        candidate_march = '-march=' + candidate_march

-        march_features = []
-        if part_number_config.has_key('march_features')
-            march_features += part_number_config['march_features']
-        endif
-        if soc_config.has_key('extra_march_features')
-            march_features += soc_config['extra_march_features']
+        if candidate_march != ''
+            candidate_march = '-march=' + candidate_march
+            foreach feature: march_features
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    warning('The compiler does not support feature @0@'
+                        .format(feature))
+                endif
+            endforeach
+            machine_args += candidate_march
         endif
-        foreach feature: march_features
-            if cc.has_argument('+'.join([candidate_march, feature]))
-                candidate_march = '+'.join([candidate_march, feature])
-            else
-                warning('The compiler does not support feature @0@'
-                    .format(feature))
-            endif
-        endforeach
-        machine_args += candidate_march
+    endif
+
+    if candidate_mcpu == '' and candidate_march == ''
+        error('No suitable ARM march/mcpu version found.')
     endif

     # apply supported compiler options
--
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v7 2/3] config/arm: add support for fallback march
  2024-03-06 15:49           ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
@ 2024-03-06 15:49             ` pbhagavatula
  2024-03-06 15:49             ` [PATCH v7 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
                               ` (2 subsequent siblings)
  3 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-03-06 15:49 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some ARM CPUs have specific march requirements and
are not compatible with the supported march list.
Add fallback march in case the mcpu and the march
advertised in the part_number_config are not supported
by the compiler.

Example
        mcpu = neoverse-n2
        march = armv9-a
        fallback_march = armv8.5-a

        mcpu, march not supported
        machine_args = ['-march=armv8.5-a']

        mcpu, march, fallback_march not supported
        least march supported = armv8-a

        machine_args = ['-march=armv8-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 472a30f83a..73557bc169 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -94,6 +94,7 @@ part_number_config_arm = {
     '0xd49': {
         'march': 'armv9-a',
         'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
         'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
@@ -829,6 +830,11 @@ if update_flags
                     break
                 endif
             endforeach
+            if (part_number_config.has_key('fallback_march') and
+                candidate_march != part_number_config['march'] and
+                cc.has_argument('-march=' + part_number_config['fallback_march']))
+                    candidate_march = part_number_config['fallback_march']
+            endif
         endif
 
         if candidate_march != part_number_config['march']
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v7 3/3] config/arm: allow WFE to be enabled config time
  2024-03-06 15:49           ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
  2024-03-06 15:49             ` [PATCH v7 2/3] config/arm: add support for fallback march pbhagavatula
@ 2024-03-06 15:49             ` pbhagavatula
  2024-03-07  3:57             ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts Pavan Nikhilesh Bhagavatula
  2024-03-14 11:38             ` [PATCH v8 1/5] " pbhagavatula
  3 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-03-06 15:49 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh, Chengwen Feng, Honnappa Nagarahalli

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Allow RTE_ARM_USE_WFE to be enabled at meson configuration
time by passing it via c_args instead of modifying
`config/arm/meson.build`.

Example usage:
 meson build -Dc_args='-DRTE_ARM_USE_WFE' \
	--cross-file config/arm/arm64_cn10k_linux_gcc

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
---
 config/arm/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 73557bc169..88c17ed566 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -17,7 +17,9 @@ flags_common = [
         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
 
-        ['RTE_ARM_USE_WFE', false],
+        # Enable use of ARM wait for event instruction.
+        # ['RTE_ARM_USE_WFE', false],
+
         ['RTE_ARCH_ARM64', true],
         ['RTE_CACHE_LINE_SIZE', 128]
 ]
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* RE: [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts
  2024-03-06 15:49           ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
  2024-03-06 15:49             ` [PATCH v7 2/3] config/arm: add support for fallback march pbhagavatula
  2024-03-06 15:49             ` [PATCH v7 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
@ 2024-03-07  3:57             ` Pavan Nikhilesh Bhagavatula
  2024-03-14 11:38             ` [PATCH v8 1/5] " pbhagavatula
  3 siblings, 0 replies; 65+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2024-03-07  3:57 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula, Jerin Jacob, juraj.linkes, nd,
	wathsala.vithanage, Ruifeng Wang, Bruce Richardson
  Cc: dev

Recheck-request: iol-unit-amd64-testing

> -----Original Message-----
> From: pbhagavatula@marvell.com <pbhagavatula@marvell.com>
> Sent: Wednesday, March 6, 2024 9:20 PM
> To: Jerin Jacob <jerinj@marvell.com>; juraj.linkes@pantheon.tech;
> nd@arm.com; wathsala.vithanage@arm.com; Ruifeng Wang
> <ruifeng.wang@arm.com>; Bruce Richardson <bruce.richardson@intel.com>
> Cc: dev@dpdk.org; Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com>
> Subject: [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts
> 
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> The compiler options march and mtune are a subset
> of mcpu and will lead to conflicts if improper march
> is chosen for a given mcpu.
> To avoid conflicts, discard part number march when
> mcpu is available and is supported by the compiler.
> 
> Example:
> 	march = armv9-a
> 	mcpu = neoverse-n2
> 
> 	mcpu supported, march supported
> 	machine_args = ['-mcpu=neoverse-n2']
> 
> 	mcpu supported, march not supported
> 	machine_args = ['-mcpu=neoverse-n2']
> 
> 	mcpu not supported, march supported
> 	machine_args = ['-march=armv9-a']
> 
> 	mcpu not supported, march not supported
> 	machine_args = ['-march=armv8.6-a']
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> v2 Changes:
> - Cleanup march inconsistencies. (Juraj Linkes)
> - Unify fallback march selection. (Juraj Linkes)
> - Tag along ARM WFE patch.
> v3 Changes:
> - Fix missing 'fallback_march' key check.
> v4 Changes:
> - Discard march when mcpu is supported.
> v5 Changes:
> - Consolidate mcpu and march checks. (Juraj Linkes)
> - Fix unintentionally skipping fallback march (Juraj Linkes)
> v6 Changes:
> - Remove compiler support check when march is forced. (Juraj Linkes)
> - Simplify fallback march configuration.
> v7 Changes:
> - Rebase on master.
> 
>  config/arm/meson.build | 119 +++++++++++++++++++++++++---------------
> -
>  1 file changed, 72 insertions(+), 47 deletions(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index dc31fe3d78..472a30f83a 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -58,18 +58,18 @@ implementer_generic = {
>  }
> 
>  part_number_config_arm = {
> -    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
> -    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
> -    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
> -    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
> -    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
> -    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
> -    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
> -    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
> +    '0xd03': {'mcpu': 'cortex-a53'},
> +    '0xd04': {'mcpu': 'cortex-a35'},
> +    '0xd05': {'mcpu': 'cortex-a55'},
> +    '0xd07': {'mcpu': 'cortex-a57'},
> +    '0xd08': {'mcpu': 'cortex-a72'},
> +    '0xd09': {'mcpu': 'cortex-a73'},
> +    '0xd0a': {'mcpu': 'cortex-a75'},
> +    '0xd0b': {'mcpu': 'cortex-a76'},
>      '0xd0c': {
>          'march': 'armv8.2-a',
>          'march_features': ['crypto', 'rcpc'],
> -        'compiler_options':  ['-mcpu=neoverse-n1'],
> +        'mcpu': 'neoverse-n1',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n1"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -81,7 +81,7 @@ part_number_config_arm = {
>      '0xd40': {
>          'march': 'armv8.4-a',
>          'march_features': ['sve'],
> -        'compiler_options':  ['-mcpu=neoverse-v1'],
> +        'mcpu': 'neoverse-v1',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-v1"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -92,8 +92,9 @@ part_number_config_arm = {
>          'march': 'armv8.4-a',
>      },
>      '0xd49': {
> +        'march': 'armv9-a',
>          'march_features': ['sve2'],
> -        'compiler_options': ['-mcpu=neoverse-n2'],
> +        'mcpu': 'neoverse-n2',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -102,8 +103,9 @@ part_number_config_arm = {
>          ]
>      },
>      '0xd4f': {
> +        'march' : 'armv9-a',
> +        'mcpu' : 'neoverse-v2',
>          'march_features': ['sve2'],
> -        'compiler_options': ['-mcpu=neoverse-v2'],
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-v2"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -137,21 +139,23 @@ implementer_cavium = {
>      ],
>      'part_number_config': {
>          '0xa1': {
> -            'compiler_options': ['-mcpu=thunderxt88'],
> +            'mcpu': 'thunderxt88',
>              'flags': flags_part_number_thunderx
>          },
>          '0xa2': {
> -            'compiler_options': ['-mcpu=thunderxt81'],
> +            'mcpu': 'thunderxt81',
>              'flags': flags_part_number_thunderx
>          },
>          '0xa3': {
> -            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
> +            'march': 'armv8-a',
> +            'march_features': ['crc', 'crypto'],
> +            'mcpu': 'thunderxt83',
>              'flags': flags_part_number_thunderx
>          },
>          '0xaf': {
>              'march': 'armv8.1-a',
>              'march_features': ['crc', 'crypto'],
> -            'compiler_options': ['-mcpu=thunderx2t99'],
> +            'mcpu': 'thunderx2t99',
>              'flags': [
>                  ['RTE_MACHINE', '"thunderx2"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -163,7 +167,7 @@ implementer_cavium = {
>          '0xb2': {
>              'march': 'armv8.2-a',
>              'march_features': ['crc', 'crypto', 'lse'],
> -            'compiler_options': ['-mcpu=octeontx2'],
> +            'mcpu': 'octeontx2',
>              'flags': [
>                  ['RTE_MACHINE', '"cn9k"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -186,7 +190,7 @@ implementer_ampere = {
>          '0x0': {
>              'march': 'armv8-a',
>              'march_features': ['crc', 'crypto'],
> -            'compiler_options':  ['-mtune=emag'],
> +            'mcpu': 'emag',
>              'flags': [
>                  ['RTE_MACHINE', '"eMAG"'],
>                  ['RTE_MAX_LCORE', 32],
> @@ -196,7 +200,7 @@ implementer_ampere = {
>          '0xac3': {
>              'march': 'armv8.6-a',
>              'march_features': ['crc', 'crypto'],
> -            'compiler_options':  ['-mcpu=ampere1'],
> +            'mcpu': 'ampere1',
>              'flags': [
>                  ['RTE_MACHINE', '"AmpereOne"'],
>                  ['RTE_MAX_LCORE', 320],
> @@ -216,7 +220,7 @@ implementer_hisilicon = {
>          '0xd01': {
>              'march': 'armv8.2-a',
>              'march_features': ['crypto'],
> -            'compiler_options': ['-mtune=tsv110'],
> +            'mcpu': 'tsv110',
>              'flags': [
>                  ['RTE_MACHINE', '"Kunpeng 920"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true],
> @@ -258,14 +262,14 @@ implementer_ionic = {
>      ],
>      'part_number_config': {
>          '0xc1': {
> -            'compiler_options':  ['-mcpu=cortex-a72'],
> +            'mcpu' : 'cortex-a72',
>              'flags': [
>                  ['RTE_MAX_LCORE', 4],
>                  ['RTE_LIBRTE_IONIC_PMD_BARRIER_ERRATA', true],
>              ]
>          },
>          '0xc2': {
> -            'compiler_options':  ['-mcpu=cortex-a72'],
> +            'mcpu' : 'cortex-a72',
>              'flags': [
>                  ['RTE_MAX_LCORE', 16],
>                  ['RTE_LIBRTE_IONIC_PMD_BARRIER_ERRATA', true],
> @@ -782,13 +786,35 @@ if update_flags
> 
>      machine_args = [] # Clear previous machine args
> 
> -    # probe supported archs and their features
> +    march_features = []
> +    if part_number_config.has_key('march_features')
> +        march_features += part_number_config['march_features']
> +    endif
> +    if soc_config.has_key('extra_march_features')
> +        march_features += soc_config['extra_march_features']
> +    endif
> +
> +    candidate_mcpu = ''
>      candidate_march = ''
> -    if part_number_config.has_key('march')
> +
> +    if (part_number_config.has_key('mcpu') and
> +        cc.has_argument('-mcpu=' + part_number_config['mcpu']))
> +        candidate_mcpu = '-mcpu=' + part_number_config['mcpu']
> +        foreach feature: march_features
> +            if cc.has_argument('+'.join([candidate_mcpu, feature]))
> +                candidate_mcpu = '+'.join([candidate_mcpu, feature])
> +            else
> +                warning('The compiler does not support feature @0@'
> +                    .format(feature))
> +            endif
> +        endforeach
> +        machine_args += candidate_mcpu
> +    elif part_number_config.has_key('march')
> +        # probe supported archs and their features
>          if part_number_config.get('force_march', false)
>              candidate_march = part_number_config['march']
>          else
> -            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-
> a',
> +            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a',
> 'armv8.3-a',
>                                  'armv8.2-a', 'armv8.1-a', 'armv8-a']
>              check_compiler_support = false
>              foreach supported_march: supported_marchs
> @@ -804,32 +830,31 @@ if update_flags
>                  endif
>              endforeach
>          endif
> -        if candidate_march == ''
> -            error('No suitable armv8 march version found.')
> -        endif
> +
>          if candidate_march != part_number_config['march']
> -            warning('Configuration march version is ' +
> -                    '@0@, but the compiler supports only @1@.'
> -                    .format(part_number_config['march'], candidate_march))
> +            warning('Configuration march version is @0@, not supported.'
> +                    .format(part_number_config['march']))
> +            if candidate_march != ''
> +                warning('Using march version @0@.'.format(candidate_march))
> +            endif
>          endif
> -        candidate_march = '-march=' + candidate_march
> 
> -        march_features = []
> -        if part_number_config.has_key('march_features')
> -            march_features += part_number_config['march_features']
> -        endif
> -        if soc_config.has_key('extra_march_features')
> -            march_features += soc_config['extra_march_features']
> +        if candidate_march != ''
> +            candidate_march = '-march=' + candidate_march
> +            foreach feature: march_features
> +                if cc.has_argument('+'.join([candidate_march, feature]))
> +                    candidate_march = '+'.join([candidate_march, feature])
> +                else
> +                    warning('The compiler does not support feature @0@'
> +                        .format(feature))
> +                endif
> +            endforeach
> +            machine_args += candidate_march
>          endif
> -        foreach feature: march_features
> -            if cc.has_argument('+'.join([candidate_march, feature]))
> -                candidate_march = '+'.join([candidate_march, feature])
> -            else
> -                warning('The compiler does not support feature @0@'
> -                    .format(feature))
> -            endif
> -        endforeach
> -        machine_args += candidate_march
> +    endif
> +
> +    if candidate_mcpu == '' and candidate_march == ''
> +        error('No suitable ARM march/mcpu version found.')
>      endif
> 
>      # apply supported compiler options
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v8 1/5] config/arm: avoid mcpu and march conflicts
  2024-03-06 15:49           ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
                               ` (2 preceding siblings ...)
  2024-03-07  3:57             ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts Pavan Nikhilesh Bhagavatula
@ 2024-03-14 11:38             ` pbhagavatula
  2024-03-14 11:38               ` [PATCH v8 2/5] config/arm: add armv9-a march support pbhagavatula
                                 ` (4 more replies)
  3 siblings, 5 replies; 65+ messages in thread
From: pbhagavatula @ 2024-03-14 11:38 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

The compiler options march and mtune are a subset
of mcpu and will lead to conflicts if improper march
is chosen for a given mcpu.
To avoid conflicts, discard part number march when
mcpu is available and is supported by the compiler.

Example:
	march = armv9-a
	mcpu = neoverse-n2

	mcpu supported, march supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu supported, march not supported
	machine_args = ['-mcpu=neoverse-n2']

	mcpu not supported, march supported
	machine_args = ['-march=armv9-a']

	mcpu not supported, march not supported
	machine_args = ['-march=armv8.6-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
v2 Changes:
- Cleanup march inconsistencies. (Juraj Linkes)
- Unify fallback march selection. (Juraj Linkes)
- Tag along ARM WFE patch.
v3 Changes:
- Fix missing 'fallback_march' key check.
v4 Changes:
- Discard march when mcpu is supported.
v5 Changes:
- Consolidate mcpu and march checks. (Juraj Linkes)
- Fix unintentionally skipping fallback march (Juraj Linkes)
v6 Changes:
- Remove compiler support check when march is forced. (Juraj Linkes)
- Simplify fallback march configuration.
v7 Changes:
- Rebase on master.
v8 Changes:
- Split patches to be more explicit about changes.

 config/arm/meson.build | 115 ++++++++++++++++++++++++-----------------
 1 file changed, 69 insertions(+), 46 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 9d6fb87d7f..4e7e072053 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -58,18 +58,18 @@ implementer_generic = {
 }

 part_number_config_arm = {
-    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
-    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
-    '0xd05': {'compiler_options':  ['-mcpu=cortex-a55']},
-    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
-    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
-    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
+    '0xd03': {'mcpu': 'cortex-a53'},
+    '0xd04': {'mcpu': 'cortex-a35'},
+    '0xd05': {'mcpu': 'cortex-a55'},
+    '0xd07': {'mcpu': 'cortex-a57'},
+    '0xd08': {'mcpu': 'cortex-a72'},
+    '0xd09': {'mcpu': 'cortex-a73'},
+    '0xd0a': {'mcpu': 'cortex-a75'},
+    '0xd0b': {'mcpu': 'cortex-a76'},
     '0xd0c': {
         'march': 'armv8.2-a',
         'march_features': ['crypto', 'rcpc'],
-        'compiler_options':  ['-mcpu=neoverse-n1'],
+        'mcpu': 'neoverse-n1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -81,7 +81,7 @@ part_number_config_arm = {
     '0xd40': {
         'march': 'armv8.4-a',
         'march_features': ['sve'],
-        'compiler_options':  ['-mcpu=neoverse-v1'],
+        'mcpu': 'neoverse-v1',
         'flags': [
             ['RTE_MACHINE', '"neoverse-v1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -93,7 +93,7 @@ part_number_config_arm = {
     },
     '0xd49': {
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-n2'],
+        'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -103,7 +103,7 @@ part_number_config_arm = {
     },
     '0xd4f': {
         'march_features': ['sve2'],
-        'compiler_options': ['-mcpu=neoverse-v2'],
+        'mcpu' : 'neoverse-v2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-v2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -137,21 +137,23 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'compiler_options': ['-mcpu=thunderxt88'],
+            'mcpu': 'thunderxt88',
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'compiler_options': ['-mcpu=thunderxt81'],
+            'mcpu': 'thunderxt81',
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'compiler_options': ['-march=armv8-a+crc', '-mcpu=thunderxt83'],
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'mcpu': 'thunderxt83',
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
             'march': 'armv8.1-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options': ['-mcpu=thunderx2t99'],
+            'mcpu': 'thunderx2t99',
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -163,7 +165,7 @@ implementer_cavium = {
         '0xb2': {
             'march': 'armv8.2-a',
             'march_features': ['crc', 'crypto', 'lse'],
-            'compiler_options': ['-mcpu=octeontx2'],
+            'mcpu': 'octeontx2',
             'flags': [
                 ['RTE_MACHINE', '"cn9k"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -186,7 +188,7 @@ implementer_ampere = {
         '0x0': {
             'march': 'armv8-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mtune=emag'],
+            'mcpu': 'emag',
             'flags': [
                 ['RTE_MACHINE', '"eMAG"'],
                 ['RTE_MAX_LCORE', 32],
@@ -196,7 +198,7 @@ implementer_ampere = {
         '0xac3': {
             'march': 'armv8.6-a',
             'march_features': ['crc', 'crypto'],
-            'compiler_options':  ['-mcpu=ampere1'],
+            'mcpu': 'ampere1',
             'flags': [
                 ['RTE_MACHINE', '"AmpereOne"'],
                 ['RTE_MAX_LCORE', 320],
@@ -216,7 +218,7 @@ implementer_hisilicon = {
         '0xd01': {
             'march': 'armv8.2-a',
             'march_features': ['crypto'],
-            'compiler_options': ['-mtune=tsv110'],
+            'mcpu': 'tsv110',
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -258,14 +260,14 @@ implementer_ionic = {
     ],
     'part_number_config': {
         '0xc1': {
-            'compiler_options':  ['-mcpu=cortex-a72'],
+            'mcpu' : 'cortex-a72',
             'flags': [
                 ['RTE_MAX_LCORE', 4],
                 ['RTE_LIBRTE_IONIC_PMD_BARRIER_ERRATA', true],
             ]
         },
         '0xc2': {
-            'compiler_options':  ['-mcpu=cortex-a72'],
+            'mcpu' : 'cortex-a72',
             'flags': [
                 ['RTE_MAX_LCORE', 16],
                 ['RTE_LIBRTE_IONIC_PMD_BARRIER_ERRATA', true],
@@ -797,9 +799,31 @@ if update_flags

     machine_args = [] # Clear previous machine args

-    # probe supported archs and their features
+    march_features = []
+    if part_number_config.has_key('march_features')
+        march_features += part_number_config['march_features']
+    endif
+    if soc_config.has_key('extra_march_features')
+        march_features += soc_config['extra_march_features']
+    endif
+
+    candidate_mcpu = ''
     candidate_march = ''
-    if part_number_config.has_key('march')
+
+    if (part_number_config.has_key('mcpu') and
+        cc.has_argument('-mcpu=' + part_number_config['mcpu']))
+        candidate_mcpu = '-mcpu=' + part_number_config['mcpu']
+        foreach feature: march_features
+            if cc.has_argument('+'.join([candidate_mcpu, feature]))
+                candidate_mcpu = '+'.join([candidate_mcpu, feature])
+            else
+                warning('The compiler does not support feature @0@'
+                    .format(feature))
+            endif
+        endforeach
+        machine_args += candidate_mcpu
+    elif part_number_config.has_key('march')
+        # probe supported archs and their features
         if part_number_config.get('force_march', false)
             candidate_march = part_number_config['march']
         else
@@ -819,32 +843,31 @@ if update_flags
                 endif
             endforeach
         endif
-        if candidate_march == ''
-            error('No suitable armv8 march version found.')
-        endif
+
         if candidate_march != part_number_config['march']
-            warning('Configuration march version is ' +
-                    '@0@, but the compiler supports only @1@.'
-                    .format(part_number_config['march'], candidate_march))
+            warning('Configuration march version is @0@, not supported.'
+                    .format(part_number_config['march']))
+            if candidate_march != ''
+                warning('Using march version @0@.'.format(candidate_march))
+            endif
         endif
-        candidate_march = '-march=' + candidate_march

-        march_features = []
-        if part_number_config.has_key('march_features')
-            march_features += part_number_config['march_features']
-        endif
-        if soc_config.has_key('extra_march_features')
-            march_features += soc_config['extra_march_features']
+        if candidate_march != ''
+            candidate_march = '-march=' + candidate_march
+            foreach feature: march_features
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    warning('The compiler does not support feature @0@'
+                        .format(feature))
+                endif
+            endforeach
+            machine_args += candidate_march
         endif
-        foreach feature: march_features
-            if cc.has_argument('+'.join([candidate_march, feature]))
-                candidate_march = '+'.join([candidate_march, feature])
-            else
-                warning('The compiler does not support feature @0@'
-                    .format(feature))
-            endif
-        endforeach
-        machine_args += candidate_march
+    endif
+
+    if candidate_mcpu == '' and candidate_march == ''
+        error('No suitable ARM march/mcpu version found.')
     endif

     # apply supported compiler options
--
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v8 2/5] config/arm: add armv9-a march support
  2024-03-14 11:38             ` [PATCH v8 1/5] " pbhagavatula
@ 2024-03-14 11:38               ` pbhagavatula
  2024-03-14 11:38               ` [PATCH v8 3/5] config/arm: add crypto march feature to thunderxt83 pbhagavatula
                                 ` (3 subsequent siblings)
  4 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-03-14 11:38 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Add armv9-a as supported march flag for ARM neoverse
class of processors.
Update supported march list to include armv9-a.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 config/arm/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 4e7e072053..0e7f54862a 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -92,6 +92,7 @@ part_number_config_arm = {
         'march': 'armv8.4-a',
     },
     '0xd49': {
+        'march': 'armv9-a',
         'march_features': ['sve2'],
         'mcpu': 'neoverse-n2',
         'flags': [
@@ -102,6 +103,7 @@ part_number_config_arm = {
         ]
     },
     '0xd4f': {
+        'march': 'armv9-a',
         'march_features': ['sve2'],
         'mcpu' : 'neoverse-v2',
         'flags': [
@@ -827,7 +829,7 @@ if update_flags
         if part_number_config.get('force_march', false)
             candidate_march = part_number_config['march']
         else
-            supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v8 3/5] config/arm: add crypto march feature to thunderxt83
  2024-03-14 11:38             ` [PATCH v8 1/5] " pbhagavatula
  2024-03-14 11:38               ` [PATCH v8 2/5] config/arm: add armv9-a march support pbhagavatula
@ 2024-03-14 11:38               ` pbhagavatula
  2024-03-14 12:00                 ` Jerin Jacob
  2024-03-14 11:38               ` [PATCH v8 4/5] config/arm: add support for fallback march pbhagavatula
                                 ` (2 subsequent siblings)
  4 siblings, 1 reply; 65+ messages in thread
From: pbhagavatula @ 2024-03-14 11:38 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some older compilers don't recognize crypto march feature
for thunderxt83 mcpu.
Explicitly add it to march feature list.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 config/arm/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 0e7f54862a..45f5db2c58 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -148,7 +148,7 @@ implementer_cavium = {
         },
         '0xa3': {
             'march': 'armv8-a',
-            'march_features': ['crc'],
+            'march_features': ['crc', 'crypto'],
             'mcpu': 'thunderxt83',
             'flags': flags_part_number_thunderx
         },
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v8 4/5] config/arm: add support for fallback march
  2024-03-14 11:38             ` [PATCH v8 1/5] " pbhagavatula
  2024-03-14 11:38               ` [PATCH v8 2/5] config/arm: add armv9-a march support pbhagavatula
  2024-03-14 11:38               ` [PATCH v8 3/5] config/arm: add crypto march feature to thunderxt83 pbhagavatula
@ 2024-03-14 11:38               ` pbhagavatula
  2024-03-14 11:38               ` [PATCH v8 5/5] config/arm: allow WFE to be enabled config time pbhagavatula
  2024-03-15 11:17               ` [PATCH v8 1/5] config/arm: avoid mcpu and march conflicts Thomas Monjalon
  4 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-03-14 11:38 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some ARM CPUs have specific march requirements and
are not compatible with the supported march list.
Add fallback march in case the mcpu and the march
advertised in the part_number_config are not supported
by the compiler.

Example
        mcpu = neoverse-n2
        march = armv9-a
        fallback_march = armv8.5-a

        mcpu, march not supported
        machine_args = ['-march=armv8.5-a']

        mcpu, march, fallback_march not supported
        least march supported = armv8-a

        machine_args = ['-march=armv8-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 45f5db2c58..fd38031308 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -94,6 +94,7 @@ part_number_config_arm = {
     '0xd49': {
         'march': 'armv9-a',
         'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
         'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
@@ -844,6 +845,11 @@ if update_flags
                     break
                 endif
             endforeach
+            if (part_number_config.has_key('fallback_march') and
+                candidate_march != part_number_config['march'] and
+                cc.has_argument('-march=' + part_number_config['fallback_march']))
+                    candidate_march = part_number_config['fallback_march']
+            endif
         endif
 
         if candidate_march != part_number_config['march']
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v8 5/5] config/arm: allow WFE to be enabled config time
  2024-03-14 11:38             ` [PATCH v8 1/5] " pbhagavatula
                                 ` (2 preceding siblings ...)
  2024-03-14 11:38               ` [PATCH v8 4/5] config/arm: add support for fallback march pbhagavatula
@ 2024-03-14 11:38               ` pbhagavatula
  2024-03-15 11:17               ` [PATCH v8 1/5] config/arm: avoid mcpu and march conflicts Thomas Monjalon
  4 siblings, 0 replies; 65+ messages in thread
From: pbhagavatula @ 2024-03-14 11:38 UTC (permalink / raw)
  To: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson
  Cc: dev, Pavan Nikhilesh, Chengwen Feng, Honnappa Nagarahalli

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Allow RTE_ARM_USE_WFE to be enabled at meson configuration
time by passing it via c_args instead of modifying
`config/arm/meson.build`.

Example usage:
 meson build -Dc_args='-DRTE_ARM_USE_WFE' \
	--cross-file config/arm/arm64_cn10k_linux_gcc

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
---
 config/arm/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index fd38031308..883e668c1a 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -17,7 +17,9 @@ flags_common = [
         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
 
-        ['RTE_ARM_USE_WFE', false],
+        # Enable use of ARM wait for event instruction.
+        # ['RTE_ARM_USE_WFE', false],
+
         ['RTE_ARCH_ARM64', true],
         ['RTE_CACHE_LINE_SIZE', 128]
 ]
-- 
2.25.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v8 3/5] config/arm: add crypto march feature to thunderxt83
  2024-03-14 11:38               ` [PATCH v8 3/5] config/arm: add crypto march feature to thunderxt83 pbhagavatula
@ 2024-03-14 12:00                 ` Jerin Jacob
  0 siblings, 0 replies; 65+ messages in thread
From: Jerin Jacob @ 2024-03-14 12:00 UTC (permalink / raw)
  To: pbhagavatula
  Cc: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson, dev

On Thu, Mar 14, 2024 at 5:09 PM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Some older compilers don't recognize crypto march feature
> for thunderxt83 mcpu.
> Explicitly add it to march feature list.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>


> ---
>  config/arm/meson.build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 0e7f54862a..45f5db2c58 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -148,7 +148,7 @@ implementer_cavium = {
>          },
>          '0xa3': {
>              'march': 'armv8-a',
> -            'march_features': ['crc'],
> +            'march_features': ['crc', 'crypto'],
>              'mcpu': 'thunderxt83',
>              'flags': flags_part_number_thunderx
>          },
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v8 1/5] config/arm: avoid mcpu and march conflicts
  2024-03-14 11:38             ` [PATCH v8 1/5] " pbhagavatula
                                 ` (3 preceding siblings ...)
  2024-03-14 11:38               ` [PATCH v8 5/5] config/arm: allow WFE to be enabled config time pbhagavatula
@ 2024-03-15 11:17               ` Thomas Monjalon
  4 siblings, 0 replies; 65+ messages in thread
From: Thomas Monjalon @ 2024-03-15 11:17 UTC (permalink / raw)
  To: Pavan Nikhilesh
  Cc: jerinj, juraj.linkes, nd, wathsala.vithanage, Ruifeng Wang,
	Bruce Richardson, dev

14/03/2024 12:38, pbhagavatula@marvell.com:
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> The compiler options march and mtune are a subset
> of mcpu and will lead to conflicts if improper march
> is chosen for a given mcpu.
> To avoid conflicts, discard part number march when
> mcpu is available and is supported by the compiler.
> 
> Example:
> 	march = armv9-a
> 	mcpu = neoverse-n2
> 
> 	mcpu supported, march supported
> 	machine_args = ['-mcpu=neoverse-n2']
> 
> 	mcpu supported, march not supported
> 	machine_args = ['-mcpu=neoverse-n2']
> 
> 	mcpu not supported, march supported
> 	machine_args = ['-march=armv9-a']
> 
> 	mcpu not supported, march not supported
> 	machine_args = ['-march=armv8.6-a']
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> v2 Changes:
> - Cleanup march inconsistencies. (Juraj Linkes)
> - Unify fallback march selection. (Juraj Linkes)
> - Tag along ARM WFE patch.
> v3 Changes:
> - Fix missing 'fallback_march' key check.
> v4 Changes:
> - Discard march when mcpu is supported.
> v5 Changes:
> - Consolidate mcpu and march checks. (Juraj Linkes)
> - Fix unintentionally skipping fallback march (Juraj Linkes)
> v6 Changes:
> - Remove compiler support check when march is forced. (Juraj Linkes)
> - Simplify fallback march configuration.
> v7 Changes:
> - Rebase on master.
> v8 Changes:
> - Split patches to be more explicit about changes.

Applied, thanks for the split.




^ permalink raw reply	[flat|nested] 65+ messages in thread

end of thread, other threads:[~2024-03-15 11:17 UTC | newest]

Thread overview: 65+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-21  9:36 [PATCH 1/2] config/arm: avoid mcpu and march conflicts pbhagavatula
2024-01-21  9:36 ` [PATCH 2/2] config/arm: add support for fallback march pbhagavatula
2024-01-22  6:30   ` Ruifeng Wang
2024-01-22 11:04   ` Juraj Linkeš
2024-01-22 12:16     ` [EXT] " Pavan Nikhilesh Bhagavatula
2024-01-22 16:29       ` Juraj Linkeš
2024-01-24 15:25         ` Pavan Nikhilesh Bhagavatula
2024-01-22  6:29 ` [PATCH 1/2] config/arm: avoid mcpu and march conflicts Ruifeng Wang
2024-01-22 10:55 ` Juraj Linkeš
2024-01-22 11:54   ` [EXT] " Pavan Nikhilesh Bhagavatula
2024-01-22 16:26     ` Juraj Linkeš
2024-01-24 15:21       ` Pavan Nikhilesh Bhagavatula
2024-01-29  8:44         ` Juraj Linkeš
2024-01-30 16:16           ` Pavan Nikhilesh Bhagavatula
2024-01-31  9:03             ` Juraj Linkeš
2024-02-01 21:57 ` [PATCH v2 1/3] " pbhagavatula
2024-02-01 21:57   ` [PATCH v2 2/3] config/arm: add support for fallback march pbhagavatula
2024-02-01 21:57   ` [PATCH v2 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
2024-02-07  2:55     ` Honnappa Nagarahalli
2024-02-10  6:47       ` Pavan Nikhilesh Bhagavatula
2024-02-10 16:36         ` Honnappa Nagarahalli
2024-02-10 16:40           ` Pavan Nikhilesh Bhagavatula
2024-02-02  8:50   ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
2024-02-02  8:50     ` [PATCH v3 2/3] config/arm: add support for fallback march pbhagavatula
2024-02-07 20:24       ` Wathsala Wathawana Vithanage
2024-02-02  8:50     ` [PATCH v3 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
2024-02-10 16:56       ` Honnappa Nagarahalli
2024-02-12 19:21       ` Wathsala Wathawana Vithanage
2024-02-06  4:10     ` [PATCH v3 1/3] config/arm: avoid mcpu and march conflicts Wathsala Wathawana Vithanage
2024-02-06  4:44       ` Honnappa Nagarahalli
2024-02-06 10:21         ` Pavan Nikhilesh Bhagavatula
2024-02-07  0:01           ` Wathsala Wathawana Vithanage
2024-02-10  6:49             ` Pavan Nikhilesh Bhagavatula
2024-02-10 15:20               ` Honnappa Nagarahalli
2024-02-10 17:21                 ` Honnappa Nagarahalli
2024-02-21 20:20     ` [PATCH v4 " pbhagavatula
2024-02-21 20:20       ` [PATCH v4 2/3] config/arm: add support for fallback march pbhagavatula
2024-02-22 10:47         ` Juraj Linkeš
2024-02-22 12:32           ` [EXT] " Pavan Nikhilesh Bhagavatula
2024-02-21 20:20       ` [PATCH v4 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
2024-02-22  9:37       ` [PATCH v4 1/3] config/arm: avoid mcpu and march conflicts Juraj Linkeš
2024-02-22  9:49         ` [EXT] " Pavan Nikhilesh Bhagavatula
2024-02-22 12:45       ` [PATCH v5 " pbhagavatula
2024-02-22 12:45         ` [PATCH v5 2/3] config/arm: add support for fallback march pbhagavatula
2024-02-23 11:49           ` Juraj Linkeš
2024-02-26  7:11             ` [EXT] " Pavan Nikhilesh Bhagavatula
2024-02-26  7:31               ` Juraj Linkeš
2024-02-26  7:34                 ` Juraj Linkeš
2024-02-22 12:45         ` [PATCH v5 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
2024-02-23 11:19         ` [PATCH v5 1/3] config/arm: avoid mcpu and march conflicts Juraj Linkeš
2024-02-26  7:08           ` [EXT] " Pavan Nikhilesh Bhagavatula
2024-02-26  7:38         ` [PATCH v6 " pbhagavatula
2024-02-26  7:38           ` [PATCH v6 2/3] config/arm: add support for fallback march pbhagavatula
2024-02-26  7:38           ` [PATCH v6 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
2024-03-06 15:49           ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts pbhagavatula
2024-03-06 15:49             ` [PATCH v7 2/3] config/arm: add support for fallback march pbhagavatula
2024-03-06 15:49             ` [PATCH v7 3/3] config/arm: allow WFE to be enabled config time pbhagavatula
2024-03-07  3:57             ` [PATCH v7 1/3] config/arm: avoid mcpu and march conflicts Pavan Nikhilesh Bhagavatula
2024-03-14 11:38             ` [PATCH v8 1/5] " pbhagavatula
2024-03-14 11:38               ` [PATCH v8 2/5] config/arm: add armv9-a march support pbhagavatula
2024-03-14 11:38               ` [PATCH v8 3/5] config/arm: add crypto march feature to thunderxt83 pbhagavatula
2024-03-14 12:00                 ` Jerin Jacob
2024-03-14 11:38               ` [PATCH v8 4/5] config/arm: add support for fallback march pbhagavatula
2024-03-14 11:38               ` [PATCH v8 5/5] config/arm: allow WFE to be enabled config time pbhagavatula
2024-03-15 11:17               ` [PATCH v8 1/5] config/arm: avoid mcpu and march conflicts Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).