Hard works like gaming, machine learning or mining cause many problems on Ryzen builds under GNU/Linux operating system. All the distro I have tested suffered that issue and also the latest kernel didn’t provide a solution to it. So, how can we solve it?

Random crashes and freezes. What the gasp?
This problem is annoying but it also has a simple solution. I know you like to edit BIOS parameters to overclock RAM and CPU, I know what you did to improve the performance of your new rig. Yes, I know.
So, I think also you don’t have any problems to modify BIOS parameters in order to make a Ryzen build stable on Linux. No more crashes, no more freezes, only pure speed.
My Ryzen 7 1700 (and also my brand new Athlon 200GE in the HTPC) keeps randomly freezing when going IDLE. It’s a recognized bug and you can find it on Kernel Bugzilla as Bug 196683 – Random Soft Lockup on new Ryzen build.
What did I do to solve this issue and to make my Ryzen build stable under Linux?
On my BIOS motherboards, I went to Advanced Settings and then to the AMD CBS tab. Inside this, I did set the Power Supply Idle Control to Typical Current Idle. I also left the C6 state as the default, untouched.
Some people reported on Reddit that disabling the AMD Cool&Quiet function can help, take a look here for more information.