Hey
As per your complain you feel pain when you chew food.If your upper tooth has a cavity and it’s deep enough then it’s sure that you are having the pain because of that.
When you chew food the food goes to the cavity and it creates a pressure to the underlying structure.
Next Steps
You should go for an x ray iopar. If your pain is not continuous then there is no sign of infection around the root of the tooth. or if you have pain which is continuous then there may be any infection beyond the root.
Health Tips
Better you go to your near by dentist and ask him what to do. or else you can do an xay and contact here, or even you can book an appointment here.
Lastly I would like to say that don’t let the the cavity filled with food debris.Brush it and remove all the residuals. If you left it untreated in future it will hamper you and you might have to undergo for a Root Canal treatment.
Thank you