ath79: Speed up caldata/eeprom handling
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Thu, 7 Mar 2019 08:40:07 +0000 (09:40 +0100)
committerChristian Lamparter <chunkeey@gmail.com>
Wed, 13 Mar 2019 15:27:41 +0000 (16:27 +0100)
Reading and writing to and from flash storage is slowed down
enormously by some functions which use a block size of 1.

This patch reworks the extraction scripts to be much faster and
efficient by reading and writing in possibly one big block.

This is based on the initial commit a69e101 for ipq40xx by
Christian Lamparter <chunkeey@gmail.com>.

Speed comparison @ UBNT AC-Mesh (just manually) results
in a time reduction by three orders of magnitude (99.9 %).

> time dd if=/dev/mtd6 of=/lib/firmware/test-slow bs=1 count=4096 skip=4096
4096+0 records in
4096+0 records out
real    0m 16.84s
user    0m 0.07s
sys     0m 13.54s

> time dd if=/dev/mtd6 of=/lib/firmware/test-fast bs=4096 count=1 skip=4096 iflag=skip_bytes
1+0 records in
1+0 records out
real    0m 0.02s
user    0m 0.00s
sys     0m 0.02s

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Rosen Penev <rosenp@gmail.com>
target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata

index 4061aa67eb12915028ed1f7db8a750b3ed031b24..72a768c554f347d9a3675e20416767aabe91a30a 100644 (file)
@@ -81,7 +81,7 @@ ath9k_patch_fw_mac() {
                        dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
        }
 
-       macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6
+       macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=$mac_offset count=1
 }
 
 ath9k_patch_fw_mac_crc() {
index cf8dcde7110b54b60ca9400499b26db27ff64e12..8651c97099be1464e76e370df356558d4b0b1b48 100644 (file)
@@ -28,7 +28,7 @@ ath10kcal_from_file() {
        local offset=$2
        local count=$3
 
-       dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
+       dd if=$source of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
                ath10kcal_die "failed to extract calibration data from $source"
 }
 
@@ -42,7 +42,7 @@ ath10kcal_extract() {
        [ -n "$mtd" ] || \
                ath10kcal_die "no mtd device found for partition $part"
 
-       dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
+       dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
                ath10kcal_die "failed to extract calibration data from $mtd"
 }
 
@@ -51,7 +51,7 @@ ath10kcal_patch_mac() {
 
        [ -z "$mac" ] && return
 
-       macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
+       macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=6 count=1
 }
 
 ath10kcal_patch_mac_crc() {