From patchwork Wed Feb 27 22:18:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1049168 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="MF+Zq4Oj"; 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 448qpm64ypz9sBF for ; Thu, 28 Feb 2019 09:19:12 +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=ACQkwbxBSFJNGMiCTSN6a3uUFHJPkimCzkHADhpvD5s=; b=MF+Zq4Oj9nWatoDYM/vDDdZc8P 0aP71n148SsDm4KuJHKC+qX6AHMN/4JB9a2MtQTeigZo7/zxAHZDg+3ARRu10s8LJjPlLRMsPp8uN /6TyHnAR+iQEAT7cQnY4VksfqecO9bUX4lxT/kiRULzxHq2m2h5G2dQ09c4SfRBDZd1U8G0qkM99f /+eCtbNP/XU2hMNRezqQ+JYSt8fSnIngVEOqkuc16iq7rML1IC/+4UV1ts5r0Styu5t33lCGQ5ycJ T6LI5aMdrbvs9QO7mkxNv1aBrcbh4gb5DZJKf3RE/C6cjcFTLCbc0oietOExNazfwH679lm7QugZN RcHce1Bg==; 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 1gz7Xe-0004x4-Vq; Wed, 27 Feb 2019 22:19:06 +0000 Received: from mout.kundenserver.de ([217.72.192.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gz7Wr-0003o2-BI for openwrt-devel@lists.openwrt.org; Wed, 27 Feb 2019 22:18:20 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MadC8-1ha6Ax18IM-00c7eI for ; Wed, 27 Feb 2019 23:18:13 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Wed, 27 Feb 2019 23:18:05 +0100 Message-Id: <20190227221809.1697-3-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190227221809.1697-1-freifunk@adrianschmutzler.de> References: <20190227221809.1697-1-freifunk@adrianschmutzler.de> X-Provags-ID: V03:K1:LwAWgj8c11vahFPxWi/G7QzhavVxNXrhPhf+TnNOyLuFCjr0YFt ZkZEOwLsFI/IVwNNvcFOJwj6NBJFPYNOPA5RX6ld2ThLWlvS9OSKMbR2NuMAN4IEs7oGc54 11CFFMfrLct883K7mqQO33H5xnu02skB20GF72bzIbPGdbTXKj0xaTk4/4lRWigDvtiY2Z0 XOKkgZi5/yHIKeBM9lYdw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Z5HgcOGWw2M=:vrDxiUr28xBFWQ1em1ACHR q4/VPQaZxpkgVZRHXY3iwe2aowYanvejlW7uthkgOMUGnQnXEe80H5igACjhcV5urq0othMQ/ m7BPnQjQNwobB+nLNTumpig+7K/N+DkMZIoXvJcm700idPm4+4TEiCDxySpqH8YLMvJ8LEWQo oUeLIN9jRpBdAQ0MZ9piydF6NcD45f+LTUymM5Xb7TMiwQ+OvjnrOzaNwxgPiVG+8k+B9TbWs 40pxQ+L9/E0daOJWiSon/4b+JB7Q/Lg5XRqJqFUfCGE4V3xJ0wLa5dQ1fX7NatMed+gX8gAph QJmf3S5rvdVvKICfF3l6zeAU4l0qcp9ZsT2lpaz5YsU+Mztr+incxQ7Jijv5QtuObljvSUVO9 FI1xGXRT5h/mp7lzx1YvI+nIxuQ7uHedSKaOMUdxcMpej/8MEzz6b+lqsNI2Jzvc+w1zkOF3m irvljRg0Oxx/NLsZ+naFlH4F384LvCiVSNJssGn0JtGxdUnkpmOUNbuEhqiphBdcDYe/ZznKr 33rhiIe19AnxFQYEspnQnctryx6zqCPpITFjPsaEK7RQoLFT8TjzaEPHlynzhkjafbGYnyXBU FjHpk6/jiEbdYGTyBwR/YcWLJTUD0VHXaOI09Td2WqQHX9g+6CUi9gdOv6jQtTkMjPFeUno0m lcvJzoxbi0ELqm34nAKwauz9+qM27+csnUBbLHYLd04LyHYHJFGHtgEWNSeDVKrvFMupwz6gl CcsGIkgyC1y1lCmCyOGDflpANiIgU0aCCwxLPiBmDogBLJt+uZ1wfqjawgc= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190227_141817_693312_D311C84A X-CRM114-Status: GOOD ( 12.89 ) 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 http://www.dnswl.org/, no trust [217.72.192.74 listed in list.dnswl.org] Subject: [OpenWrt-Devel] [PATCH v3 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 --- .../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