Please when you post provide as much information as you can.
Bad idle means what?
Idle is too high, idle goes up and down
Idle is too low?
See what I mean?
Typically on our M3 the bad idle is caused by:
Idle control valve dirty or shot, typically they get dirty and can be cleaned with teflon safe throttle body cleaner
You have a crack in the boot from the MAP to the throttle body allowing unmetere air to enter
Other vacuum leak caused by a bad hose (could be the one from the boot to the idle control valve)
I would check those.
If you don't know what I am talking about take a look at bmwfans.com or realoem.com and see the exploded views there to locate the parts I mentioned.
More info really helps locate your issue...