[SOLVED] [Jetson-TK1] EBUSY while fast switching CPU cluster

I have an issue that I get EBUSY error when I try to switch between LP and G cluster as per description here: http://elinux.org/Jetson/Performance. The issue happens relatively often also when I just try to do it from the command line.

pwerr_e set_cluster(cpu_cluster_e cluster){

    int ret;
    int retries = 0;

    if(cpuclst_fd == -1){
        return POWER_NOT_INITIALISED;
    }

    if(cluster == CLUSTER_LP){

retry_switch_g_lp:
        ret = write(cpuclst_fd, "LP", 3);
        if(ret == -1){
            if(errno == EBUSY){
                if(retries == 3)
                    return POWER_SUCCESS;
                retries++;
                goto retry_switch_g_lp;
            }
            fprintf(stderr, "(G->LP) Could not write (%s, %d)\n", strerror(errno), errno);
            return POWER_ERROR;       
        }

    }else if(cluster == CLUSTER_HP){
retry_switch_lp_g:
        ret = write(cpuclst_fd, "G", 2);
        if(ret == -1){
            if(errno == EBUSY){
                if(retries == 3)
                    return POWER_SUCCESS;
                retries++;
                goto retry_switch_lp_g;
            }
            fprintf(stderr, "(LP->G) Could not write (%s, %d)\n", strerror(errno), errno);
            return POWER_ERROR;       
        }

}else{
        fprintf(stderr, "Unknown cluster enum\n");
        return POWER_ERROR;
    }

    return POWER_SUCCESS;
}

dmesg output:

root@jetson:/sys# dmesg | tail -n 40
[1328015.750287] cluster/active: request failed (-16)
[1328015.750469] cluster/active -> LP
[1328015.751015] tegra12_cpu_cmplx_clk_set_parent: Failed to switch cpu mode to cpu_lp
[1328015.766300] tegra12_cpu_cmplx_clk_set_parent: aborted switch from cpu_g to cpu_lp
[1328015.785045] cluster/active: request failed (-16)
[1328015.785670] cluster/active -> G
[1328015.820064] cluster/active -> LP
[1328015.820549] tegra12_cpu_cmplx_clk_set_parent: Failed to switch cpu mode to cpu_lp
[1328015.835240] tegra12_cpu_cmplx_clk_set_parent: aborted switch from cpu_g to cpu_lp
[1328015.853913] cluster/active: request failed (-16)
[1328015.854413] cluster/active -> LP
[1328015.854891] tegra12_cpu_cmplx_clk_set_parent: Failed to switch cpu mode to cpu_lp
[1328015.872338] tegra12_cpu_cmplx_clk_set_parent: aborted switch from cpu_g to cpu_lp
[1328015.891095] cluster/active: request failed (-16)
[1328015.891574] cluster/active -> LP
[1328015.892149] tegra12_cpu_cmplx_clk_set_parent: Failed to switch cpu mode to cpu_lp
[1328015.909598] tegra12_cpu_cmplx_clk_set_parent: aborted switch from cpu_g to cpu_lp
[1328015.928289] cluster/active: request failed (-16)
[1328015.928497] cluster/active -> LP
[1328015.929172] tegra12_cpu_cmplx_clk_set_parent: Failed to switch cpu mode to cpu_lp
[1328015.944297] tegra12_cpu_cmplx_clk_set_parent: aborted switch from cpu_g to cpu_lp
[1328015.963005] cluster/active: request failed (-16)
[1328015.964239] cluster/active -> G
[1328015.998527] cluster/active -> LP
[1328015.999025] tegra12_cpu_cmplx_clk_set_parent: Failed to switch cpu mode to cpu_lp
[1328016.013718] tegra12_cpu_cmplx_clk_set_parent: aborted switch from cpu_g to cpu_lp
[1328016.032360] cluster/active: request failed (-16)
[1328016.032550] cluster/active -> LP
[1328016.033038] tegra12_cpu_cmplx_clk_set_parent: Failed to switch cpu mode to cpu_lp
[1328016.048232] tegra12_cpu_cmplx_clk_set_parent: aborted switch from cpu_g to cpu_lp
[1328016.066927] cluster/active: request failed (-16)
[1328016.067403] cluster/active -> LP
[1328016.067891] tegra12_cpu_cmplx_clk_set_parent: Failed to switch cpu mode to cpu_lp
[1328016.085325] tegra12_cpu_cmplx_clk_set_parent: aborted switch from cpu_g to cpu_lp
[1328016.104088] cluster/active: request failed (-16)
[1328016.104494] cluster/active -> LP
[1328016.105148] tegra12_cpu_cmplx_clk_set_parent: Failed to switch cpu mode to cpu_lp
[1328016.119876] tegra12_cpu_cmplx_clk_set_parent: aborted switch from cpu_g to cpu_lp
[1328016.138616] cluster/active: request failed (-16)
[1328016.139611] cluster/active -> G

Any ideas?

dummy

This was an issue because you need to disable the three extra cores before changing cluster.