From: "Gao,Shiyuan" via <qemu-devel@nongnu.org>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
"Zuo,Boqun" <zuoboqun@baidu.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Gao,Shiyuan" <gaoshiyuan@baidu.com>
Subject: Re: [PATCH V2 1/1] virtio-pci: Add lookup subregion of VirtIOPCIRegion MR
Date: Thu, 29 Aug 2024 13:13:43 +0000 [thread overview]
Message-ID: <9766b5a2ca8c43f3be60b2bfd0fc5226@baidu.com> (raw)
In-Reply-To: <qrb7lbdypu2ctim57dxn7copcbmclpxnb4k2uadnm5v6ehawwc@xzhkhvs46xhw>
> >--- a/hw/virtio/virtio-pci.c
> >+++ b/hw/virtio/virtio-pci.c
> >@@ -610,19 +610,29 @@ static MemoryRegion *virtio_address_space_lookup(VirtIOPCIProxy *proxy,
> > {
> > int i;
> > VirtIOPCIRegion *reg;
> >+ MemoryRegion *mr = NULL;
>
> `mr` looks unused.
>
> >+ MemoryRegionSection mrs;
>
> Please, can you move this declaration in the inner block where it's
> used?
ok, I will move to inner block and remove unused `mr`.
>
> >
> > for (i = 0; i < ARRAY_SIZE(proxy->regs); ++i) {
> > reg = &proxy->regs[i];
> > if (*off >= reg->offset &&
> > *off + len <= reg->offset + reg->size) {
> >- *off -= reg->offset;
> >- return ®->mr;
> >+ mrs = memory_region_find(®->mr, *off - reg->offset,
> >len);
> >+ if (!mrs.mr) {
> >+ error_report("Failed to find memory region for address"
> >+ "0x%" PRIx64 "", *off);
> >+ return NULL;
> >+ }
> >+ *off = mrs.offset_within_region;
> >+ memory_region_unref(mrs.mr);
> >+ return mrs.mr;
> > }
> > }
> >
> > return NULL;
> > }
> >
> >+
>
> Unrelated change.
Perhaps this would be clearer but not universal in Version 1.
Without this patch, Only lookup common/isr/device/notify MR and
exclude their subregions.
When VHOST_USER_PROTOCOL_F_HOST_NOTIFIER enable, the notify MR has
host-notifier subregions and we need use host-notifier MR to
notify the hardware accelerator directly.
Further more, maybe common/isr/device MR also has subregions in
the future, so need memory_region_find for each MR incluing
their subregions and this will be more universal.
@@ -610,13 +610,22 @@ static MemoryRegion *virtio_address_space_lookup(VirtIOPCIProxy *proxy,
{
int i;
VirtIOPCIRegion *reg;
+ MemoryRegion *mr, *submr;
for (i = 0; i < ARRAY_SIZE(proxy->regs); ++i) {
reg = &proxy->regs[i];
if (*off >= reg->offset &&
*off + len <= reg->offset + reg->size) {
*off -= reg->offset;
- return ®->mr;
+ mr = ®->mr;
+ QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
+ if (*off >= submr->addr &&
+ *off + len < submr->addr + submr->size) {
+ *off -= submr->addr;
+ return submr;
+ }
+ }
+ return mr;
}
}
next prev parent reply other threads:[~2024-08-29 13:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 11:56 [PATCH V2 1/1] virtio-pci: Add lookup subregion of VirtIOPCIRegion MR Gao Shiyuan via
2024-08-27 13:41 ` Stefano Garzarella
2024-08-29 13:13 ` Gao,Shiyuan via [this message]
2024-09-03 10:11 ` Stefano Garzarella
2024-09-03 10:19 ` Michael S. Tsirkin
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=9766b5a2ca8c43f3be60b2bfd0fc5226@baidu.com \
--to=qemu-devel@nongnu.org \
--cc=gaoshiyuan@baidu.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=sgarzare@redhat.com \
--cc=zuoboqun@baidu.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 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).