The classic 'wastegate rattle' on the n54 turbo's is a clearance matter on the guide bushings of the wastegate pins (so the bushings that go into the turbo housing where through the wastegate actuator rod goes).
The wastegate rattle can cause the wastegate to seal imporpely, causing loss of power, bad gas mileage and engine codes.
There are kits for this to repair this but fitting this is definately a specialist job (specialist as in turbo specialist, not a normal auto mechanic).
The bushing has to be drilled and hammered out an a new one has to be pressed in (including fitting new valve, lever etc). So thats quite a job. (just getting the turbo's out is quite a job, modifying even more, but it beats having to buy £3000 in bmw parts)
Repair kit: https://www.ecstuning.com/b-vargas-turbo-technologies-parts/wastegate-rattle-fix-repair-kit/vtt-n54-wf2~vtt/
More on the rattle and worn bushings:
[youtube]VQD6tITYH7k[/youtube]
So I hope you dont have this.