From patchwork Sun Jan 24 19:44:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 43602 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0A235B7BF3 for ; Mon, 25 Jan 2010 06:48:26 +1100 (EST) Received: from localhost ([127.0.0.1]:40859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZ8PN-0002qV-Om for incoming@patchwork.ozlabs.org; Sun, 24 Jan 2010 14:46:05 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZ8O5-0002pm-6q for qemu-devel@nongnu.org; Sun, 24 Jan 2010 14:44:45 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZ8O0-0002ne-Hm for qemu-devel@nongnu.org; Sun, 24 Jan 2010 14:44:44 -0500 Received: from [199.232.76.173] (port=57675 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZ8O0-0002nX-An for qemu-devel@nongnu.org; Sun, 24 Jan 2010 14:44:40 -0500 Received: from mail-ew0-f227.google.com ([209.85.219.227]:55279) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZ8Nz-0000mo-Q3 for qemu-devel@nongnu.org; Sun, 24 Jan 2010 14:44:40 -0500 Received: by ewy27 with SMTP id 27so3587338ewy.16 for ; Sun, 24 Jan 2010 11:44:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:date:from:to:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=jJTz6q56eHT7EULTz/3sPsdF73QvQZnMM4vENQkoqNs=; b=KYf8p6YIE0P3mUdE4yUT+e1CAkBPn/uQEN6nqz5y87Am+o0LhtesIRfeoS7fSyEj15 dYeQmEPWZ4jvegLaNvCx2burOJCd5qe3xQFQGYxBjhIBt2a60Wmv8hnI2AqZ0PfH6FMo G1wfQqSUUcLuaB2wBJRpKTs7+B66+xvoDaOuM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=efXWtgoghyU/xDu0LuY+/4kqHz6G0itKp/GuSEFC7SUz/Uidq1n6SeeaWHaMS0HDwD /X4E0+3g3d9ZLCVzyx/mK1t7gdyyx7xSegfEYQn5r6aN0AdxnxZeJJT1XxD2ypNbVLe2 lQXGPv0czuJ06pNbFfUQjj8Q58B8WzbDnqy14= Received: by 10.213.100.165 with SMTP id y37mr2703760ebn.71.1264362277722; Sun, 24 Jan 2010 11:44:37 -0800 (PST) Received: from edgar.iglesias@gmail.com (c83-249-212-190.bredband.comhem.se [83.249.212.190]) by mx.google.com with ESMTPS id 13sm3933540ewy.5.2010.01.24.11.44.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 24 Jan 2010 11:44:37 -0800 (PST) Received: by edgar.iglesias@gmail.com (sSMTP sendmail emulation); Sun, 24 Jan 2010 20:44:34 +0100 Date: Sun, 24 Jan 2010 20:44:34 +0100 From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Message-ID: <20100124194434.GA14889@laped.iglesias.mooo.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH] pflash: Buffer block writes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, Does anyone disagree or have any comments on this? Thanks, Edgar commit 9029c47f883306bc75afe881a08504e9b906485f Author: Edgar E. Iglesias Date: Sun Jan 24 20:38:29 2010 +0100 pflash: Buffer block writes Buffer block writes to avoid flushing every word access onto backing storage device. This significantly speeds up flash emulation for flashes connected through an 8 or 16-bit bus combined with backing storage (-pflash). Signed-off-by: Edgar E. Iglesias diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index d9e30d9..95b406b 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -72,6 +72,7 @@ struct pflash_t { uint8_t cfi_len; uint8_t cfi_table[0x52]; target_phys_addr_t counter; + unsigned int writeblock_size; QEMUTimer *timer; ram_addr_t off; int fl_mem; @@ -206,7 +207,6 @@ static inline void pflash_data_write(pflash_t *pfl, target_phys_addr_t offset, switch (width) { case 1: p[offset] = value; - pflash_update(pfl, offset, 1); break; case 2: #if defined(TARGET_WORDS_BIGENDIAN) @@ -216,7 +216,6 @@ static inline void pflash_data_write(pflash_t *pfl, target_phys_addr_t offset, p[offset] = value; p[offset + 1] = value >> 8; #endif - pflash_update(pfl, offset, 2); break; case 4: #if defined(TARGET_WORDS_BIGENDIAN) @@ -230,7 +229,6 @@ static inline void pflash_data_write(pflash_t *pfl, target_phys_addr_t offset, p[offset + 2] = value >> 16; p[offset + 3] = value >> 24; #endif - pflash_update(pfl, offset, 4); break; } @@ -307,6 +305,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset, case 0x40: /* Single Byte Program */ DPRINTF("%s: Single Byte Program\n", __func__); pflash_data_write(pfl, offset, value, width); + pflash_update(pfl, offset, width); pfl->status |= 0x80; /* Ready! */ pfl->wcycle = 0; break; @@ -359,8 +358,13 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset, pfl->status |= 0x80; if (!pfl->counter) { + target_phys_addr_t mask = pfl->writeblock_size - 1; + mask = ~mask; + DPRINTF("%s: block write finished\n", __func__); pfl->wcycle++; + /* Flush the entire write buffer onto backing storage. */ + pflash_update(pfl, offset & mask, pfl->writeblock_size); } pfl->counter--; @@ -606,6 +610,8 @@ pflash_t *pflash_cfi01_register(target_phys_addr_t base, ram_addr_t off, } else { pfl->cfi_table[0x2A] = 0x0B; } + pfl->writeblock_size = 1 << pfl->cfi_table[0x2A]; + pfl->cfi_table[0x2B] = 0x00; /* Number of erase block regions (uniform) */ pfl->cfi_table[0x2C] = 0x01;