From: David Edmondson <david.edmondson@oracle.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
qemu-block@nongnu.org, "Xu Yandong" <xuyandong2@huawei.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Max Reitz" <mreitz@redhat.com>,
"Zheng Xiang" <zhengxiang9@huawei.com>,
haibinzhang <haibinzhang@tencent.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Stefano Garzarella" <sgarzare@redhat.com>
Subject: Re: [RFC PATCH 2/3] hw/block/pflash: Move code around
Date: Fri, 26 Feb 2021 08:21:34 +0000 [thread overview]
Message-ID: <m2lfbbb5o1.fsf@oracle.com> (raw)
In-Reply-To: <20210225230238.3719051-3-philmd@redhat.com>
On Friday, 2021-02-26 at 00:02:37 +01, Philippe Mathieu-Daudé wrote:
> First do the block checks, so we know if it is read-only or not.
> Then create the MemoryRegion. This will allow optimization in
> the next commit.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
> ---
> hw/block/pflash_cfi01.c | 24 ++++++++++++------------
> hw/block/pflash_cfi02.c | 18 +++++++++---------
> 2 files changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
> index 22287a1522e..a5fa8d8b74a 100644
> --- a/hw/block/pflash_cfi01.c
> +++ b/hw/block/pflash_cfi01.c
> @@ -731,18 +731,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
> }
> device_len = sector_len_per_device * blocks_per_device;
>
> - memory_region_init_rom_device(
> - &pfl->mem, OBJECT(dev),
> - &pflash_cfi01_ops,
> - pfl,
> - pfl->name, total_len, errp);
> - if (*errp) {
> - return;
> - }
> -
> - pfl->storage = memory_region_get_ram_ptr(&pfl->mem);
> - sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);
> -
> if (pfl->blk) {
> uint64_t perm;
> pfl->ro = !blk_supports_write_perm(pfl->blk);
> @@ -755,6 +743,18 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
> pfl->ro = 0;
> }
>
> + memory_region_init_rom_device(
> + &pfl->mem, OBJECT(dev),
> + &pflash_cfi01_ops,
> + pfl,
> + pfl->name, total_len, errp);
> + if (*errp) {
> + return;
> + }
> +
> + pfl->storage = memory_region_get_ram_ptr(&pfl->mem);
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);
> +
> if (pfl->blk) {
> if (!blk_check_size_and_read_all(pfl->blk, pfl->storage, total_len,
> errp)) {
> diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
> index 7962cff7455..4f62ce8917d 100644
> --- a/hw/block/pflash_cfi02.c
> +++ b/hw/block/pflash_cfi02.c
> @@ -791,15 +791,6 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
> return;
> }
>
> - memory_region_init_rom_device(&pfl->orig_mem, OBJECT(pfl),
> - &pflash_cfi02_ops, pfl, pfl->name,
> - pfl->chip_len, errp);
> - if (*errp) {
> - return;
> - }
> -
> - pfl->storage = memory_region_get_ram_ptr(&pfl->orig_mem);
> -
> if (pfl->blk) {
> uint64_t perm;
> pfl->ro = !blk_supports_write_perm(pfl->blk);
> @@ -812,6 +803,15 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
> pfl->ro = 0;
> }
>
> + memory_region_init_rom_device(&pfl->orig_mem, OBJECT(pfl),
> + &pflash_cfi02_ops, pfl, pfl->name,
> + pfl->chip_len, errp);
> + if (*errp) {
> + return;
> + }
> +
> + pfl->storage = memory_region_get_ram_ptr(&pfl->orig_mem);
> +
> if (pfl->blk) {
> if (!blk_check_size_and_read_all(pfl->blk, pfl->storage,
> pfl->chip_len, errp)) {
> --
> 2.26.2
dme.
--
She's as sweet as Tupelo honey, she's an angel of the first degree.
next prev parent reply other threads:[~2021-02-26 8:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 23:02 [RFC PATCH 0/3] hw/block/pflash: Mmap read-only backend files with MAP_SHARED Philippe Mathieu-Daudé
2021-02-25 23:02 ` [RFC PATCH 1/3] exec/memory: Introduce memory_region_init_rom_device_from_file() Philippe Mathieu-Daudé
2021-03-01 11:53 ` Stefano Garzarella
2021-03-01 11:59 ` Philippe Mathieu-Daudé
2021-02-25 23:02 ` [RFC PATCH 2/3] hw/block/pflash: Move code around Philippe Mathieu-Daudé
2021-02-26 8:21 ` David Edmondson [this message]
2021-02-25 23:02 ` [RFC PATCH 3/3] hw/block/pflash: use memory_region_init_rom_device_from_file() Philippe Mathieu-Daudé
2021-02-26 8:23 ` David Edmondson
2021-03-01 11:50 ` Philippe Mathieu-Daudé
2021-03-01 13:38 ` David Edmondson
2021-03-01 13:58 ` Philippe Mathieu-Daudé
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=m2lfbbb5o1.fsf@oracle.com \
--to=david.edmondson@oracle.com \
--cc=armbru@redhat.com \
--cc=haibinzhang@tencent.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=xuyandong2@huawei.com \
--cc=zhengxiang9@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.