The timings have to match. It's best to use the same ram for all slots.
They do not "need to match" since latency parameters and clock are programmed into the DRAM ICs' memory control registers at boot-time by the BIOS. As long as the BIOS correctly determines the slowest common timings, it will make the DIMMs match by programming them to the correct same latencies as the slowest DIMM and use whatever the fastest clock is for the slowest DIMM. When the BIOS fails to correctly detect speed/timings, you can boot with only one pair installed, adjust timings manually and then install the other DIMMs.
As long as there are no electrical incompatibilities (which would mean at least one of the DIMMs is not compliant with the JEDEC spec), it will work.