Phosphorus comprises about 0.1% by mass of the average rock you find walking around, the only thing that’s running out is the extremely high concentrations you find in specific areas.
What we are mining is essentially areas of ocean floor lifted up to the surface. We could also either mine other areas still on the ocean floor that also have high concentrations, or almost anywhere else at lower though still significant concentrations.
When we run out of P, mining asteroids is always an option. How much of a viable realistic option...I don’t know.
I think there are two other viable solutions:
1. Synthesize food in labs using fermentation techniques to feed the world population.
2. Genetically modify Homo sapiens to synthesis food and tinker with metabolism.
Both the above seem more practical and likely feasible than destroying the planet with Ag for marginal benefits.