Sounds like a throttle body issue to me. High idle and revving can be caused by the throttle position sensor or the idle air control system. I'm not well versed in the implementation details of the Mazda throttle body but I'd start there.
Did you have the throttle body cleaned or anything like that done recently?
Did you have the throttle body cleaned or anything like that done recently?