Is this function related to low power mode? Are you using tickless idle? Jus to narrow down, can you check if the problem happens when you disable tickless idle?
Just make sure to check the return value to see if the operation succeeded or timed out.