There were seven years of plenteous harvests in Egypt, to be followed by seven years of famine (Genesis 41). Joseph was placed in charge of storing food from the plenty for use during the famine. But the famine years were not only in Egypt: Canaan had famine also (42:5). Two years into the famine in Egypt (45:11), Jacob came down to settle there, and, as Rashi (47:13, :19) describes,
since Jacob came to Egypt, blessing came with him[1] and they started to plant and the famine was ended. Thus we learned in Tosefta of Sota.
So why was there famine in Canaan before Jacob left?
(Someone suggested to me that the famine ended in Egypt when Jacob arrived because God's purpose in bringing a famine was to orchestrate Jacob's descent to Egypt and that purpose was filled on his arrival there. But that doesn't seem correct to me, as Rashi's language seems to imply that the famine ended not because there was no use for it any longer but specifically because Jacob brought "blessing" with him; the context in the Tosefta (Sota 10:3) seems to imply this even more strongly.)
[1] My translation of "באה ברכה לרגליו" as "blessing came with him" is per Rashi to 30:30.