It would probably help to define what exactly the Soviet terms for “victory” would be. Turning Afghanistan into a so-called “normal” country, with a central government in complete control of the entire country, would probably require an investment of men, material, money, and time that I doubt Moscow would be willing to make. On the other hand, a long-term military mission, with an Afghan government on close terms with the Soviet Union, might actually be workable given the correct circumstances.
There’s actually an interesting little scenario with this premise in Tsouras’ Cold War Hot anthology. The POD involves Carter refusing to launch a rescue operation for the Tehran hostages (thereby alienating Brzezinski), instead negotiating for their successful release in October 1979, giving him a last-minute push to electoral victory against Reagan. Over his second term, Carter’s policy shifts away from confrontation to repairing détente, the end result being that Afghanistan is seen as a Soviet victory, and of little interest to America. (Ironically, the author of the scenario notes that the foreign policies of Carter’s second term are actually comparable to Reagan’s during the same period, with the primary difference being in the ideas driving those policies.) Military aid to the mujahadeen remains at a slow trickle, and there are no exchanges of advanced equipment. At the same time, Carter’s focus on human rights actually causes an erosion of American standing throughout the Muslim world, due to the lack of effort towards liberating Afghanistan, and the lack of American response to the combined Soviet-Indian attack on Pakistan in 1984 (brought on by a Soviet desire to shut down Afghan rebel bases along the western frontier, and Indian fear of Pakistan’s nuclear program, and a sense that the Americans would do nothing in response to such an event.)
The end result of the scenario is that by the late 1980s the Middle East is shifting towards the Soviets again, with Pakistan is drifting towards an accommodation with Moscow and the war in Afghanistan itself at a low ebb. While Gorbachev comes to power in 1985, there a sense in the leadership that immediate radical reform is not necessary, and that maintenance of the state combined with technology transfers from the West can shore up the Soviet state more effectively. At the same time, the prestige of the military and security organs has been raised by the recent conflicts, allowing the carrot-and-stick approach to continue in the Union and Eastern Europe. For the time being, the Soviet Union is still a going concern.