I have had the same on my 2.8 M104. Exchanged the plugs, wires tec. didn't help. Exchanged the Air mass meter and the OVP, didn't help. In the end it turned out to be a broken wire running from the air mass meter to the ecu. There is a cable running from the air mass meter the is held in a clip at the side end of the block itself. If you have to work on the cables coilds or plugs you need to remove the cover. While removing this cover you twist the cable I am talking about if you leave it in the clip. Do this enough times and the cable will break and give idle issues or stall the car at idle. Have that cable tested.