1. Disconnect the negative battery cable.
2. Remove the headliner.
3. Disconnect the connector.
4. Remove the screws, and then remove the sunroof motor.

Sunroof unit disassembly/assembly
Sunroof motor installationMazda 6 Service Manual: Mazda Radar Cruise Control (MRCC) (Some models)
The Mazda Radar Cruise Control (MRCC) system is designed to maintain headway
control*1 according to the vehicle speed using a radar sensor (front) to detect
the distance to a vehicle ahead, and by presetting the vehicle speed between 30
km/h (19 mph) and 145 km/h (90 mph), the driver is freed ...
Mazda 6 Service Manual: Dtc table
DTCs are common for present and past malfunction diagnosis.
Note
When DTCs not shown in the DTC table are displayed, replace
the SAS unit.
If the air bag system warning light does not illuminate or
remains illuminated when the ignition switch is turned to ON position,
i ...