I have had a CEL and code P0300 pop up a couple times in the manner the OP mentioned, the local Mazda service rep says its most likely the EGR. The EGR is still covered under warranty if the car is less than 7 years old (in Canada at least). If I pay the diagnostic fee they will scan the car...