samsung: pm-check: Make checksum algorithm more configurable and add sum
There are good reasons for using different checksums in pm-check. Add
'sum' and generalize mechanism for switching checksum algorithms.
The 'sum' algorithm is now the default.
BUG=chrome-os-partner:15655
TEST=Put code in to do a bogus corruption of address
0x71735644 to 0xBADC0DE1. Then:
1. Do a suspend/resume and see sum algorithm (0xffffffff + 0xbadc0de1):
s3c_pm_check: Restore CRC error at
71734000 (
badc0de0 vs
ffffffff)
bitfix_recover_chunk: Attempting recovery at
71734000
...fixed 0x71735644 from 0xbadc0de1 to 0x00000000
2. Switch to xor:
echo -n xor > /sys/module/pm_check/parameters/pm_check_checksum_type
3. Do suspend/resume again and see xor algorithm (0xffffffff ^ 0xbadc0de1)
s3c_pm_check: Restore CRC error at
71734000 (
4523f21e vs
ffffffff)
bitfix_recover_chunk: Attempting recovery at
71734000
...fixed 0x71735644 from 0xbadc0de1 to 0x00000000
4. Switch to CRC:
echo -n crc > /sys/module/pm_check/parameters/pm_check_checksum_type
5. Do suspend/resume again and see crc algorithm
s3c_pm_check: Restore CRC error at
71734000 (
57243536 vs
270b666b)
bitfix_recover_chunk: Attempting recovery at
71734000
...fixed 0x71735644 from 0xbadc0de1 to 0x00000000
TEST=Time by doing this for sum:
echo Y > /sys/module/pm_check/parameters/pm_check_print_timings
suspend_stress_test --noerrors_fatal --backup_rtc \
--suspend_min 15 --suspend_max 15 -c2
dmesg | grep 'memory scan'
...and saw this, which is same as xor:
s3c_pm_check: Suspend memory scan took
4519985 usecs
s3c_pm_check: Resume memory scan took
1181126 usecs
s3c_pm_check: Suspend memory scan took
4596896 usecs
s3c_pm_check: Resume memory scan took
1184638 usecs
...note that the above includes bitfix, which is why suspend is 4.5
seconds.
Change-Id: Ifd20c5d3f6da5069634360057120b63e232f8a77
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/37592
Reviewed-by: Jon Kliegman <kliegs@chromium.org>