From patchwork Fri Mar 1 14:40:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1050228 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lLHJedhI"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449sY33y5Jz9s4V for ; Sat, 2 Mar 2019 01:40:55 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Icxz+ogaBi9DklhhSvYSOmTqsy8sWeUxZM7Fh1Qpoec=; b=lLHJedhI/UsVtOYflusu5F7Gp0 gqQYALn7hGIStCuWhnC6n2u57UppOa3/wR1cqiApiBQZeVOQ9yA/4AfxIB1HF9L/7gODbwiMrffbn MxWwZFFii6EDZmqorVByqa9xZhkrOHUyxzEzbGiCazlDSNmsJ8pvuiVnfGmTHu3JV14adGRGic3qD FptyTOZlRDveNfKrW9K3FjaCPZIJyfIHqdymyteZGZvR3xEiTw4GqDDNigSk4SpXaij8ZO9ux7e9u ZCMuYPFHiUdObJAXnPgjug04KmI83+54ShN8VBLXiLITOMyHRiasCLEE+gIR5YIVnjcExL2xJBazr PfsHavlQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjL7-0005yj-Ix; Fri, 01 Mar 2019 14:40:41 +0000 Received: from mout.kundenserver.de ([212.227.126.131]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjKx-0005pT-Ot for openwrt-devel@lists.openwrt.org; Fri, 01 Mar 2019 14:40:33 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MLRI3-1giLAu3EsF-00IY4B for ; Fri, 01 Mar 2019 15:40:27 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Fri, 1 Mar 2019 15:40:18 +0100 Message-Id: <20190301144022.1984-3-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190301144022.1984-1-freifunk@adrianschmutzler.de> References: <20190301144022.1984-1-freifunk@adrianschmutzler.de> X-Provags-ID: V03:K1:lUMqmB6iq08JzqguiYz9hYzKmZVtUkTZnOXngxNIzlZtesqO/5+ l42yDi4dY8lhuBeV66sdnjGOAQ1aNDOyEtiqT+eUPQ4RUgH0L1ChdnaQLb3PF2x8P/pvZsW jy/jfzGoK+OU+IkenJHl08cJmqwj33uhsAbxtb/aj/vK+ifSDnIeM5cDyFMhAXHJ6d92cdI kMrCHXH5r8TtIjTGK/Slg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:ZF5VfbJfkmk=:6gvrxrb47gaZzelEkasXli /1S7/D+zOWpH2pw/zgqNXfv2Hs31r8m2KeVovAiySMDo50nUfPmdskp1gNbcKUrEJPTqRUYeq gpyP4aOs3V+OU4d9IYqmq/QJTZvdur4rkCaJ7beR9+3o/XWSG7sRF4qsNvNc1Fni3FNkxL7u6 y0vM0tbou/EXf8gnmTL/wdO7LLHMFYXxCrSjA3AXOA3zVjS4eHoZTq2ejT1L/+Foer30Y2Nlq GQJfN8HhtpP38HYYrwZhIzxzKzjT3hABP18CjukYeXpjZI93tcHQhJXY/sHKfUkPkECIya+mX jgQ4/uNut0mv5YmmmYKcdyhnBeT6cTaotjY/mrPgrzZTfqeAYKUJpyFP0jplEjtzYOE9Ztasv vrYZIJ6q3zykzU2B5AQY4VnAWsBZ/VCi3dZHGnyTiTej/lLBZOuteODOUGRtamvTEW5AuKS9t ffQ1wb8VBekvk/CYjR6J8pEM3LQuE+/3brYgwSXTtECf2WALvIVrUlv6OkqcyEUzoeIS8BM6b Ki+AE0oS4KT9GW6Q2AgOVdB+eq387Q7IZKALwo1iGK0hZPUq8NuRer9+y6RSf36FfI4hNaVKI RwD3UQXu0etKXJOk4epX9C1xDCI1RktgSxRCnLqEacOxQUsE6zjTTENTdt7DkT/Dom8RBTvnG Q3ufonX/3KntQRQcULEmKSjqR2StU9Z8SuqEMIXP3IZSAYVX+OtIuQJA7rmBfhTln12TebrCi tUYYNyZer/iASm9mQyMLjP14lap5gdbv7WUzdfqyxIjRlv1ndhBkqcqiEtA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_064032_117746_918307CB X-CRM114-Status: GOOD ( 11.97 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.131 listed in list.dnswl.org] Subject: [OpenWrt-Devel] [PATCH v4 2/6] ar71xx: Speed up caldata/eeprom handling X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org 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 . Speed comparison @ TP-Link TL-WDR4300 (just manually) results in a time reduction by three orders of magnitude (99.9 %). > time dd if=/dev/mtd3 of=/lib/firmware/test-slow bs=1 count=4096 skip=4096 4096+0 records in 4096+0 records out real 0m 15.85s user 0m 0.06s sys 0m 13.28s > time dd if=/dev/mtd3 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 --- Changed in v3: - Changed position of iflag/oflag to be consistent with ath79 Changed in v4: - Rebased --- .../linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom | 6 +++--- .../ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 94bce7d335..208d5f6bff 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -20,7 +20,7 @@ ath9k_eeprom_extract() { [ -n "$mtd" ] || \ ath9k_eeprom_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 || \ ath9k_eeprom_die "failed to extract from $mtd" } @@ -35,7 +35,7 @@ ath9k_ubi_eeprom_extract() { [ -n "$ubi" ] || \ ath9k_eeprom_die "no UBI volume found for $part" - dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ ath9k_eeprom_die "failed to extract from $ubi" } @@ -62,7 +62,7 @@ ath9k_patch_firmware_mac() { [ -z "$mac" ] && return - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6 + macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=2 count=1 } board=$(board_name) diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 3450819630..cd5c1c2bcb 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -10,7 +10,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" } @@ -30,7 +30,7 @@ ath10kcal_extract() { [ "$count" = "$cal_size" ] || \ ath10kcal_die "no calibration data found in $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" } @@ -39,7 +39,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 } [ -e /lib/firmware/$FIRMWARE ] && exit 0