From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, kwolf@redhat.com,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH v7 14/19] m25p80: Switch to byte-based block access
Date: Fri, 6 May 2016 10:26:40 -0600 [thread overview]
Message-ID: <1462552005-4887-15-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1462552005-4887-1-git-send-email-eblake@redhat.com>
Sector-based blk_read() should die; switch to byte-based
blk_pread() instead.
Likewise for blk_aio_readv() and blk_aio_writev().
Signed-off-by: Eric Blake <eblake@redhat.com>
---
hw/block/m25p80.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 906b712..5d30863 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -358,25 +358,21 @@ static void blk_sync_complete(void *opaque, int ret)
static void flash_sync_page(Flash *s, int page)
{
- int blk_sector, nb_sectors;
QEMUIOVector iov;
if (!s->blk || blk_is_read_only(s->blk)) {
return;
}
- blk_sector = (page * s->pi->page_size) / BDRV_SECTOR_SIZE;
- nb_sectors = DIV_ROUND_UP(s->pi->page_size, BDRV_SECTOR_SIZE);
qemu_iovec_init(&iov, 1);
- qemu_iovec_add(&iov, s->storage + blk_sector * BDRV_SECTOR_SIZE,
- nb_sectors * BDRV_SECTOR_SIZE);
- blk_aio_writev(s->blk, blk_sector, &iov, nb_sectors, blk_sync_complete,
- NULL);
+ qemu_iovec_add(&iov, s->storage + page * s->pi->page_size,
+ s->pi->page_size);
+ blk_aio_pwritev(s->blk, page * s->pi->page_size, &iov, 0,
+ blk_sync_complete, NULL);
}
static inline void flash_sync_area(Flash *s, int64_t off, int64_t len)
{
- int64_t start, end, nb_sectors;
QEMUIOVector iov;
if (!s->blk || blk_is_read_only(s->blk)) {
@@ -384,13 +380,9 @@ static inline void flash_sync_area(Flash *s, int64_t off, int64_t len)
}
assert(!(len % BDRV_SECTOR_SIZE));
- start = off / BDRV_SECTOR_SIZE;
- end = (off + len) / BDRV_SECTOR_SIZE;
- nb_sectors = end - start;
qemu_iovec_init(&iov, 1);
- qemu_iovec_add(&iov, s->storage + (start * BDRV_SECTOR_SIZE),
- nb_sectors * BDRV_SECTOR_SIZE);
- blk_aio_writev(s->blk, start, &iov, nb_sectors, blk_sync_complete, NULL);
+ qemu_iovec_add(&iov, s->storage + off, len);
+ blk_aio_pwritev(s->blk, off, &iov, 0, blk_sync_complete, NULL);
}
static void flash_erase(Flash *s, int offset, FlashCMD cmd)
@@ -907,8 +899,7 @@ static int m25p80_init(SSISlave *ss)
s->storage = blk_blockalign(s->blk, s->size);
/* FIXME: Move to late init */
- if (blk_read(s->blk, 0, s->storage,
- DIV_ROUND_UP(s->size, BDRV_SECTOR_SIZE))) {
+ if (blk_pread(s->blk, 0, s->storage, s->size)) {
fprintf(stderr, "Failed to initialize SPI flash!\n");
return 1;
}
--
2.5.5
next prev parent reply other threads:[~2016-05-06 16:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 16:26 [Qemu-devel] [PATCH v7 00/19] block: kill sector-based blk_write/read Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 01/19] block: Allow BDRV_REQ_FUA through blk_pwrite() Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 02/19] block: Switch blk_read_unthrottled() to byte interface Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 03/19] block: Switch blk_*write_zeroes() " Eric Blake
2016-05-23 15:42 ` Kevin Wolf
2016-05-23 16:03 ` Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 04/19] block: Introduce byte-based aio read/write Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 05/19] ide: Switch to byte-based aio block access Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 06/19] scsi-disk: " Eric Blake
2016-05-10 8:55 ` Kevin Wolf
2016-05-10 12:56 ` Eric Blake
2016-05-10 14:49 ` Kevin Wolf
2016-05-12 11:25 ` Paolo Bonzini
2016-05-12 11:26 ` Paolo Bonzini
2016-05-12 16:58 ` Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 07/19] virtio: " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 08/19] xen_disk: " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 09/19] fdc: Switch to byte-based " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 10/19] nand: " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 11/19] onenand: " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 12/19] pflash: " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 13/19] sd: " Eric Blake
2016-05-06 16:26 ` Eric Blake [this message]
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 15/19] atapi: " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 16/19] nbd: " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 17/19] qemu-img: " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 18/19] qemu-io: " Eric Blake
2016-05-06 16:26 ` [Qemu-devel] [PATCH v7 19/19] block: Kill unused sector-based blk_* functions Eric Blake
2016-05-10 8:56 ` [Qemu-devel] [PATCH v7 00/19] block: kill sector-based blk_write/read Kevin Wolf
2016-05-10 15:06 ` Kevin Wolf
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=1462552005-4887-15-git-send-email-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=crosthwaite.peter@gmail.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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).