From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Peter A. G. Crosthwaite" <peter.crosthwaite@petalogix.com>
Cc: edgar.iglesias@gmail.com, qemu-devel@nongnu.org,
john.williams@petalogix.com, paul@codesourcery.com
Subject: Re: [Qemu-devel] [RFC PATCH v1 2/4] m25p80: initial verion
Date: Tue, 3 Apr 2012 08:03:32 +0100 [thread overview]
Message-ID: <20120403070332.GA27304@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <26d832cdffc1b31cfe1aa6fa9ca50f66d6fb9f71.1333088411.git.peter.crosthwaite@petalogix.com>
On Fri, Mar 30, 2012 at 04:37:11PM +1000, Peter A. G. Crosthwaite wrote:
> +static void flash_sync_page(struct flash *s, int page)
> +{
> + if (s->bdrv) {
> + int bdrv_sector;
> + int offset;
> +
> + bdrv_sector = (page * s->pagesize) / 512;
> + offset = bdrv_sector * 512;
> + bdrv_write(s->bdrv, bdrv_sector,
> + s->storage + offset, (s->pagesize + 511) / 512);
Devices should not use synchronous block I/O interfaces. sd, flash, and
a couple others still do for historical reasons but new devices should
not.
The vcpu, QEMU monitor, and VNC are all blocked while I/O takes place.
This can be avoided by using bdrv_aio_writev() instead.
Can you change this code to use bdrv_aio_writev() or is this flash
device specified to complete operations within certain time constraints?
(The problem is that the image file could be on a slow harddisk or other
media that don't meet those timing requirements.)
> +static int m25p80_init(SPISlave *ss)
> +{
> + DriveInfo *dinfo;
> + struct flash *s = FROM_SPI_SLAVE(struct flash, ss);
> + /* FIXME: This should be handled centrally! */
> + static int mtdblock_idx;
> + dinfo = drive_get(IF_MTD, 0, mtdblock_idx++);
> +
> + DB_PRINT("inited m25p80 device model - dinfo = %p\n", dinfo);
> + /* TODO: parameterize */
> + s->size = 8 * 1024 * 1024;
> + s->pagesize = 256;
> + s->sectorsize = 4 * 1024;
> + s->dirty_page = -1;
> + s->storage = g_malloc0(s->size);
Please use qemu_blockalign(s->bdrv, s->size) to allocate I/O buffers.
It honors memory alignment requirements (necessary for O_DIRECT files).
Stefan
next prev parent reply other threads:[~2012-04-03 8:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-30 6:37 [Qemu-devel] [RFC PATCH v1 0/4] SPI bus support + Xilinx SPI controller Peter A. G. Crosthwaite
2012-03-30 6:37 ` [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support Peter A. G. Crosthwaite
2012-03-30 7:37 ` Peter Maydell
2012-03-30 7:50 ` Peter Crosthwaite
2012-04-02 17:39 ` Peter Maydell
2012-04-02 23:51 ` Peter Crosthwaite
2012-04-03 0:48 ` Peter Crosthwaite
2012-04-03 17:45 ` Paul Brook
2012-04-03 18:08 ` Peter Maydell
2012-04-03 21:22 ` Paul Brook
2012-04-04 0:48 ` Peter Crosthwaite
2012-04-04 16:52 ` Paul Brook
2012-04-05 0:32 ` Peter Crosthwaite
2012-04-05 7:18 ` Peter Maydell
2012-04-02 23:57 ` Peter Crosthwaite
2012-04-03 0:27 ` Andreas Färber
2012-03-30 6:37 ` [Qemu-devel] [RFC PATCH v1 2/4] m25p80: initial verion Peter A. G. Crosthwaite
2012-04-03 7:03 ` Stefan Hajnoczi [this message]
2012-04-04 12:53 ` Andreas Färber
2012-06-05 0:47 ` Peter Crosthwaite
2012-06-05 12:38 ` Andreas Färber
2012-03-30 6:37 ` [Qemu-devel] [RFC PATCH v1 3/4] xilinx_spi: initial version Peter A. G. Crosthwaite
2012-03-30 6:37 ` [Qemu-devel] [RFC PATCH v1 4/4] petalogix-ml605: added spi controller with m25p80 Peter A. G. Crosthwaite
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120403070332.GA27304@stefanha-thinkpad.localdomain \
--to=stefanha@gmail.com \
--cc=edgar.iglesias@gmail.com \
--cc=john.williams@petalogix.com \
--cc=paul@codesourcery.com \
--cc=peter.crosthwaite@petalogix.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).