FreeBSD-13.0-CURRENT on Baikal-m(aarch64) SoC

Sleep Walker <[email protected]>
Newsgroups gmane.os.freebsd.devel.arm
Message-ID <CAHa8N890iPFJsSuRRQU-aOcC2qBbcwE7QGk38fP2EVkDuwpDyA@mail.gmail.com>
Hi!

I am trying to add support for the new SoC Baikal-M in FreeBSD.
https://www.baikalelectronics.com/products/338/
https://www.cnx-software.com/2021/08/10/desktop-and-all-in-one-arm-linux-computers-launched-with-baikal-m-processor/

The system is already starting in multi-user mode, but only one core out of
eight is detected.
To find out the reason, I slightly changed the code by adding the output of
the error code.
sys/arm64/arm64/mp_machdep.c
-------------------------------------------------------------------------------------------------------------------------
        printf("Starting CPU %u (%lx)\n", cpuid, target_cpu);
        pa = pmap_extract(kernel_pmap, (vm_offset_t)mpentry);
        err = psci_cpu_on(target_cpu, pa, cpuid);

        if (err != PSCI_RETVAL_SUCCESS) {
                printf("Starting CPU %u (%lx) psci_cpu_on return (%d)\n",
cpuid, target_cpu, err);
                /*
                 * Panic here if INVARIANTS are enabled and PSCI failed to
                 * start the requested CPU.  psci_cpu_on() returns
PSCI_MISSING
                 * to indicate we are unable to use it to start the given
CPU.
                 */
                KASSERT(err == PSCI_MISSING ||
                    (mp_quirks & MP_QUIRK_CPULIST) == MP_QUIRK_CPULIST,
                    ("Failed to start CPU %u (%lx), error %d\n",
                    cpuid, target_cpu, err));
                pcpu_destroy(pcpup);
                kmem_free((vm_offset_t)dpcpu[cpuid - 1], DPCPU_SIZE);
                dpcpu[cpuid - 1] = NULL;
                kmem_free((vm_offset_t)bootstacks[cpuid], PAGE_SIZE);
                bootstacks[cpuid] = NULL;
                mp_ncpus--;
                return (false);
        }
--------------------------------------------------------------------------------------------------------------------------
I got the following log
---------------------------------
Starting CPU 1 (1)
Starting psci_cpu_on(1, f22008c8, 1)
Starting CPU 1 (1) psci_cpu_on return (-9)
Starting CPU 1 (100)
Starting psci_cpu_on(100, f22008c8, 1)
Starting CPU 1 (100) psci_cpu_on return (-9)
Starting CPU 1 (101)
......
----------------------------------

This document describes return codes
https://developer.arm.com/documentation/den0022/latest

5.2.2 Return error codes
Table 6 defines the values for error codes used with PSCI functions.
All errors are 32-bit signed integers.

SUCCESS 0
NOT_SUPPORTED             -1
INVALID_PARAMETERS  -2
DENIED                                -3
ALREADY_ON                    -4
ON_PENDING                     -5
INTERNAL_FAILURE        -6
NOT_PRESENT                   -7
DISABLED                           -8
INVALID_ADDRESS          -9

But in kernel sources in the file  sys/dev/psci/psci.h
no definition of INVALID_ADDRESS !!!!!
/*
 * PSCI return codes.
 */
#define PSCI_RETVAL_SUCCESS                       0
#define PSCI_RETVAL_NOT_SUPPORTED       -1
#define PSCI_RETVAL_INVALID_PARAMS      -2
#define PSCI_RETVAL_DENIED                          -3
#define PSCI_RETVAL_ALREADY_ON              -4
#define PSCI_RETVAL_ON_PENDING                -5
#define PSCI_RETVAL_INTERNAL_FAILURE    -6
#define PSCI_RETVAL_NOT_PRESENT               -7
#define PSCI_RETVAL_DISABLED                       -8

That is, no one expected the return code -9 to appear.
What do you think is the reason for this error?
Maybe someone has already encountered this behavior psci_cpu_on ?

The DT files say the following.

 	psci {

		compatible = "arm,psci-1.0", "arm,psci-0.2";
		method = "smc";
	};

Full DT files can be viewed here https://personalbsd.org/download/baikal/dts/

The complete system startup log can be viewed here.
https://dmesgd.nycbug.org/index.cgi?do=view&id=6236

---
Sergey Tyuryukanov.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.