From: Gonglei <arei.gonglei@huawei.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, <qemu-devel@nongnu.org>
Cc: pbonzini@redhat.com, Markus Armbruster <armbru@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH RFC 3/3] pci-testdev: add RO pages for ioeventfd
Date: Sun, 30 Aug 2015 17:44:30 +0800 [thread overview]
Message-ID: <55E2D07E.2010306@huawei.com> (raw)
In-Reply-To: <1440926395-23540-4-git-send-email-mst@redhat.com>
On 2015/8/30 17:20, Michael S. Tsirkin wrote:
> This seems hackish - would it be better to create this region
> automatically within kvm? Suggestions are welcome.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/misc/pci-testdev.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c
> index 94141a3..55efc32 100644
> --- a/hw/misc/pci-testdev.c
> +++ b/hw/misc/pci-testdev.c
> @@ -21,6 +21,7 @@
> #include "hw/pci/pci.h"
> #include "qemu/event_notifier.h"
> #include "qemu/osdep.h"
> +#include <sys/mman.h>
>
> typedef struct PCITestDevHdr {
> uint8_t test;
> @@ -82,11 +83,13 @@ typedef struct PCITestDevState {
> PCIDevice parent_obj;
> /*< public >*/
>
> + MemoryRegion zeromr;
> MemoryRegion mmio;
> MemoryRegion mbar;
> MemoryRegion portio;
> IOTest *tests;
> int current;
> + void *zero;
> } PCITestDevState;
>
> #define TYPE_PCI_TEST_DEV "pci-testdev"
> @@ -242,6 +245,11 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp)
> uint8_t *pci_conf;
> char *name;
> int r, i;
> + d->zero = mmap(NULL, IOTEST_MEMSIZE * 2, PROT_READ,
> + MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> +
Do we need think about hotplugging pci-testdev ? If yes, then we should release some resources
when hot-unplug a pci-testdev device:
munmap(d->zero, ...)
memory_region_del_subregion(&d->mbar, &d->mmio)
...
Regards,
-Gonglei
> + memory_region_init_ram_ptr(&d->zeromr, OBJECT(d), "pci-testdev-zero", 0x1000, d->zero);
> + memory_region_set_readonly(&d->zeromr, true);
>
> pci_conf = pci_dev->config;
>
> @@ -286,6 +294,11 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp)
> test->hasnotifier = false;
> continue;
> }
> +
> + if (test->hasnotifier && !test->size) {
> + memory_region_add_subregion_overlap(&d->mbar, le32_to_cpu(test->hdr->offset),
> + &d->zeromr, 2 /* prio */);
> + }
> r = event_notifier_init(&test->notifier, 0);
> assert(r >= 0);
> test->hasnotifier = true;
>
WARNING: multiple messages have this Message-ID (diff)
From: Gonglei <arei.gonglei@huawei.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, Markus Armbruster <armbru@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH RFC 3/3] pci-testdev: add RO pages for ioeventfd
Date: Sun, 30 Aug 2015 17:44:30 +0800 [thread overview]
Message-ID: <55E2D07E.2010306@huawei.com> (raw)
In-Reply-To: <1440926395-23540-4-git-send-email-mst@redhat.com>
On 2015/8/30 17:20, Michael S. Tsirkin wrote:
> This seems hackish - would it be better to create this region
> automatically within kvm? Suggestions are welcome.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/misc/pci-testdev.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c
> index 94141a3..55efc32 100644
> --- a/hw/misc/pci-testdev.c
> +++ b/hw/misc/pci-testdev.c
> @@ -21,6 +21,7 @@
> #include "hw/pci/pci.h"
> #include "qemu/event_notifier.h"
> #include "qemu/osdep.h"
> +#include <sys/mman.h>
>
> typedef struct PCITestDevHdr {
> uint8_t test;
> @@ -82,11 +83,13 @@ typedef struct PCITestDevState {
> PCIDevice parent_obj;
> /*< public >*/
>
> + MemoryRegion zeromr;
> MemoryRegion mmio;
> MemoryRegion mbar;
> MemoryRegion portio;
> IOTest *tests;
> int current;
> + void *zero;
> } PCITestDevState;
>
> #define TYPE_PCI_TEST_DEV "pci-testdev"
> @@ -242,6 +245,11 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp)
> uint8_t *pci_conf;
> char *name;
> int r, i;
> + d->zero = mmap(NULL, IOTEST_MEMSIZE * 2, PROT_READ,
> + MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> +
Do we need think about hotplugging pci-testdev ? If yes, then we should release some resources
when hot-unplug a pci-testdev device:
munmap(d->zero, ...)
memory_region_del_subregion(&d->mbar, &d->mmio)
...
Regards,
-Gonglei
> + memory_region_init_ram_ptr(&d->zeromr, OBJECT(d), "pci-testdev-zero", 0x1000, d->zero);
> + memory_region_set_readonly(&d->zeromr, true);
>
> pci_conf = pci_dev->config;
>
> @@ -286,6 +294,11 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp)
> test->hasnotifier = false;
> continue;
> }
> +
> + if (test->hasnotifier && !test->size) {
> + memory_region_add_subregion_overlap(&d->mbar, le32_to_cpu(test->hdr->offset),
> + &d->zeromr, 2 /* prio */);
> + }
> r = event_notifier_init(&test->notifier, 0);
> assert(r >= 0);
> test->hasnotifier = true;
>
next prev parent reply other threads:[~2015-08-30 9:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-30 9:20 [PATCH RFC 0/3] pci-testdev add support for kvm ioeventfd pf Michael S. Tsirkin
2015-08-30 9:20 ` [Qemu-devel] " Michael S. Tsirkin
2015-08-30 9:20 ` [PATCH RFC 1/3] pci-testdev: separate page for each mmio test Michael S. Tsirkin
2015-08-30 9:20 ` [Qemu-devel] " Michael S. Tsirkin
2015-08-30 9:20 ` [PATCH RFC 2/3] pci-testdev: add subregion Michael S. Tsirkin
2015-08-30 9:20 ` [Qemu-devel] " Michael S. Tsirkin
2015-08-30 9:20 ` [PATCH RFC 3/3] pci-testdev: add RO pages for ioeventfd Michael S. Tsirkin
2015-08-30 9:20 ` [Qemu-devel] " Michael S. Tsirkin
2015-08-30 9:44 ` Gonglei [this message]
2015-08-30 9:44 ` Gonglei
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=55E2D07E.2010306@huawei.com \
--to=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.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 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.