There are, in real world terms, no such things as "subterranean" plants. Plants imply photosynthesis, of which part of the name is "photo" i.e. "light." Anything you find underground that looks like a plant is going to be a fungus of some sort which do not process CO2 into O2. Other way around really, and more so because they break down and process organic material, so they release more carbon than if they weren't there. And in fact a lot of "real life" caves don't have a whole lot of oxygen. Once you get much past the soil layer, unless you've got a source of above-ground water bringing nutrients from the surface to drive it, any underground biology present will be sulfur-based. Which means that the air in some of these caves is full of sulphur dioxide and sulphuric acid and totally unbreathable without a respirator.
More relevant to this topic though is that there are a lot of plants that already have symbiotic relationships with specific species of fungi, without which they couldn't absorb nearly as much nutrients as they would need to live. The fungi's mycorrhiza1 wrap around the plant's roots and break down the organics for food which also helps feed the plant.2
Let's assume that in the DF world that any underground plants are really "plants" and not fungus, and have the same sort of biology where they break apart CO2 from the air into O2 and use the C to form the complex carbohydrates for food. Instead of photosynthesis they'd use "thermosynthesis", utilizing heat instead of light to drive the process. Considering the ready availability of magma it would be silly for life to not evolve to take advantage of that huge source of free energy.
We already know that the vast caverns in the DF world are populated with giant fungi, so why not also assume that the rest of the underground is just as filled with huge populations of less noticeable species. Underground crop plants have the same kind of symbiotic relationships but absolutely require their presence to help them absorb nutrients to make food. It's likely that underground crop plants don't even have roots, but huge clumps of fungal mycorrhiza instead, anchoring them to the rock and helping them absorb nutrients.
The fungus helps break apart the organics in the mud and are probably capable of dissolving and taking up micronutrients from the rock itself.3 The water from the mud is used as a catalyst for the process, rather than used directly, which is why the mud never dries out. It's also possible that the reaction actually does dissolve the rock, which then mixes with the water and proteins released by the fungus to form a sort of snotty layer over the rock to both retain the water (evolutionary adaptation for an environment with plenty of energy but limited access to moisture...) and protect the fungal side of the symbiote.4
Since we know that a farm plot doesn't dissolve its way through the floor in a few years, and the plants need carbon to make the sugars for food, and CO2 is the easiest place to find carbon, they get the majority of what they need to grow from the air including all kinds of micronutrients from air contaminants. Which means an underground dwarf farm just as effective as an above-ground forest at cleaning junk out of the air!
For each new workshop you build, please plant an extra quarry bush to help save the environment!
Of all the different industries, soapmaker is probably the one that plant life would be least capable of handling, what with all the caustic lye and all. Anything releasing organics like ash or remains or animal waste can be used to feed the plants. Rock dust from the masons is probably helping the plants by making micronutrients more readily available via teeny tiny dust particles instead of having to be extracted directly from the rock! Dyer I don't know, but we know that dwarves use natural dyes from plants so it's probably no big deal at all.
Booze is also involved somehow, but it'll take some more thought to work out those details.
1. Mycorrhiza look like roots, but they are actually the fungus itself. Mushrooms are just the fruiting body.
2. In fact a lot of species of orchids can't germinate at all without first being infested by a suitable species of fungus because baby orchids have no roots at all to absorb nutrients they need to grow.
3. Lichens can actually do this, and lichens are real-world symbiotes of fungus and algae.
4. Those underground bacteria based on sulfur biologies do exactly this. The chemical reactions they use to get energy from Sulfur compounds creates sulfuric acid which dissolves the rock away and creates a goopy snotty pile of goo made of dissolved rock, water, sulfuric acid and kajillions of bacteria. Extremely corrosive bacterial snot, hooray!
....
I just biology-nerded big-time didn't I...