The gas cap symbol has been on since I purchased my used Mazda a year ago. Now the gas cap light and engine light both came on. I had the computer re-set and the gas cap symbol stayed off but the engine light came back on.
You should be able to take to AutoZone and they will attach a scanner and tell you what the code(s) are, bring that info back to here and we will try to help.
RepairPal Certified shops can diagnose and repair your 2007 Mazda CX-9. They provide transparent pricing with a minimum 12-month or 12,000-mile warranty on repairs and services.
Thanks and happy New Year to you