From 7d855acd071381eea9d3ba2961b05cb285dc45eb Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Tue, 20 Sep 2022 07:21:12 +0200 Subject: [PATCH] util_arch: Fix max HSA size for Z16 machine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The machine types are not strictly increasing anymore since Z16, therefore, we cannot use numerical comparison to find out the correct HSA size of a machine. Fixes: 2515832469f6 ("util_arch: Add IBM z16 as known machine") Signed-off-by: Alexander Egorenkov Reviewed-by: Jan Höppner Signed-off-by: Jan Höppner --- libutil/util_arch.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libutil/util_arch.c b/libutil/util_arch.c index 0b9208e1..d7825389 100644 --- a/libutil/util_arch.c +++ b/libutil/util_arch.c @@ -107,13 +107,12 @@ const char *util_arch_machine_type_to_str(int type) */ unsigned long util_arch_hsa_maxsize(void) { - unsigned long size = HSA_SIZE_32M; - int type; - - type = util_arch_machine_type(); - if (type != UTIL_ARCH_MACHINE_TYPE_UNKNOWN && - type >= UTIL_ARCH_MACHINE_TYPE_Z15) - size = HSA_SIZE_512M; - - return size; + switch (util_arch_machine_type()) { + case UTIL_ARCH_MACHINE_TYPE_Z15: + case UTIL_ARCH_MACHINE_TYPE_Z15_T02: + case UTIL_ARCH_MACHINE_TYPE_Z16: + return HSA_SIZE_512M; + default: + return HSA_SIZE_32M; + } }