You would have to unlock your Xperia P's bootloader first if you haven't done it yet and then just flash the pre rooted file to root your Xperia P.
rootandroid.net