From patchwork Mon Dec 3 00:05:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 1006615 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 437QJ45mqWz9s8F for ; Mon, 3 Dec 2018 11:05:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 437QJ44RMjzDqXP for ; Mon, 3 Dec 2018 11:05:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=stewart@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 437QHz0d8VzDqXB for ; Mon, 3 Dec 2018 11:05:50 +1100 (AEDT) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wB302iFD145294 for ; Sun, 2 Dec 2018 19:05:48 -0500 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2p4skn84d3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 02 Dec 2018 19:05:48 -0500 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Dec 2018 00:05:47 -0000 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 3 Dec 2018 00:05:46 -0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wB305jPk17301732 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 3 Dec 2018 00:05:45 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1BD92C605A for ; Mon, 3 Dec 2018 00:05:45 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8787C6055 for ; Mon, 3 Dec 2018 00:05:44 +0000 (GMT) Received: from birb.localdomain (unknown [9.185.142.99]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP for ; Mon, 3 Dec 2018 00:05:44 +0000 (GMT) Received: by birb.localdomain (Postfix, from userid 1000) id 612944EC65C; Mon, 3 Dec 2018 11:05:43 +1100 (AEDT) From: Stewart Smith To: skiboot@lists.ozlabs.org Date: Mon, 3 Dec 2018 11:05:42 +1100 X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181202235921.18425-1-stewart@linux.ibm.com> References: <20181202235921.18425-1-stewart@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18120300-0004-0000-0000-000014BC1F38 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010161; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01126111; UDB=6.00584812; IPR=6.00906246; MB=3.00024419; MTD=3.00000008; XFM=3.00000015; UTC=2018-12-03 00:05:47 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18120300-0005-0000-0000-000089B7AEF8 Message-Id: <20181203000542.23224-1-stewart@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-12-02_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812020231 Subject: [Skiboot] [PATCH v2] libflash/file: greatly increase perf of file_erase() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Do 4096 byte chunks not 8 byte chunks. A ffspart invocation constructing a 64MB PNOR goes from a couple of seconds to ~0.1seconds with this patch. Signed-off-by: Stewart Smith Reviewed-by: Samuel Mendoza-Jonas --- v2: use git properly you git (i.e. don't remove a file) libflash/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libflash/file.c b/libflash/file.c index 49f61778e946..72765b5777f9 100644 --- a/libflash/file.c +++ b/libflash/file.c @@ -117,15 +117,17 @@ static int file_write(struct blocklevel_device *bl, uint64_t dst, const void *sr */ static int file_erase(struct blocklevel_device *bl, uint64_t dst, uint64_t len) { - unsigned long long int d = ULLONG_MAX; + char buf[4096]; int i = 0; int rc; + memset(buf, ~0, sizeof(buf)); + while (len - i > 0) { - rc = file_write(bl, dst + i, &d, len - i > sizeof(d) ? sizeof(d) : len - i); + rc = file_write(bl, dst + i, buf, len - i > sizeof(buf) ? sizeof(buf) : len - i); if (rc) return rc; - i += len - i > sizeof(d) ? sizeof(d) : len - i; + i += (len - i > sizeof(buf)) ? sizeof(buf) : len - i; } return 0;