From: Li Qiang <liq3ea@gmail.com>
To: Jason Wang <jasowang@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Dmitry Fleytman" <dmitry.fleytman@gmail.com>,
"Daniel P. Berrange" <berrange@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Li Qiang" <liq3ea@163.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Qemu Developers" <qemu-devel@nongnu.org>,
"Alexander Bulekov" <alxndr@bu.edu>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [RFC 1/4] memory: add memory_region_init_io_with_dev interface
Date: Wed, 9 Sep 2020 12:45:43 +0800 [thread overview]
Message-ID: <CAKXe6S+=s9D+EbQeb11f308VzrdCyTzXTLHqc6+ron5nE0ioUg@mail.gmail.com> (raw)
In-Reply-To: <48a99ece-d808-f860-2551-0fec05ec5b01@redhat.com>
Jason Wang <jasowang@redhat.com> 于2020年9月9日周三 上午10:16写道:
>
>
> On 2020/9/9 上午12:41, Li Qiang wrote:
> > Currently the MR is not explicitly connecting with its device instead of
> > a opaque. In most situation this opaque is the deivce but it is not an
> > enforcement. This patch adds a DeviceState member of to MemoryRegion
> > we will use it in later patch.
>
>
> I don't have a deep investigation. But I wonder whether we could make
> sure of owner instead of adding a new field here.
I have did some investigation.
void memory_region_init_io(MemoryRegion *mr,
struct Object *owner,
const MemoryRegionOps *ops,
void *opaque,
const char *name,
uint64_t size);
memory_region_init_io now mostly connects to the device with an opaque member.
But it has no guaranteen that this should be true. So we can't assume this.
The 'owner' is just in the 'object' context.
For the MR itself, MR may have sub-MR and alias. This will complicated
the issue.
As the device emulation and MR has a clear relation. I think add such
field is reasonable.
Thanks,
Li Qiang
>
> Thanks
>
>
> >
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> > ---
> > include/exec/memory.h | 9 +++++++++
> > softmmu/memory.c | 15 +++++++++++++++
> > 2 files changed, 24 insertions(+)
> >
> > diff --git a/include/exec/memory.h b/include/exec/memory.h
> > index 0cfe987ab4..620fb12d9b 100644
> > --- a/include/exec/memory.h
> > +++ b/include/exec/memory.h
> > @@ -404,6 +404,7 @@ struct MemoryRegion {
> > const char *name;
> > unsigned ioeventfd_nb;
> > MemoryRegionIoeventfd *ioeventfds;
> > + DeviceState *dev;
> > };
> >
> > struct IOMMUMemoryRegion {
> > @@ -794,6 +795,14 @@ void memory_region_init_io(MemoryRegion *mr,
> > const char *name,
> > uint64_t size);
> >
> > +void memory_region_init_io_with_dev(MemoryRegion *mr,
> > + struct Object *owner,
> > + const MemoryRegionOps *ops,
> > + void *opaque,
> > + const char *name,
> > + uint64_t size,
> > + DeviceState *dev);
> > +
> > /**
> > * memory_region_init_ram_nomigrate: Initialize RAM memory region. Accesses
> > * into the region will modify memory
> > diff --git a/softmmu/memory.c b/softmmu/memory.c
> > index 70b93104e8..2628c9d2d9 100644
> > --- a/softmmu/memory.c
> > +++ b/softmmu/memory.c
> > @@ -1490,6 +1490,21 @@ void memory_region_init_io(MemoryRegion *mr,
> > mr->terminates = true;
> > }
> >
> > +void memory_region_init_io_with_dev(MemoryRegion *mr,
> > + Object *owner,
> > + const MemoryRegionOps *ops,
> > + void *opaque,
> > + const char *name,
> > + uint64_t size,
> > + DeviceState *dev)
> > +{
> > + memory_region_init(mr, owner, name, size);
> > + mr->ops = ops ? ops : &unassigned_mem_ops;
> > + mr->opaque = opaque;
> > + mr->terminates = true;
> > + mr->dev = dev;
> > +}
> > +
> > void memory_region_init_ram_nomigrate(MemoryRegion *mr,
> > Object *owner,
> > const char *name,
>
next prev parent reply other threads:[~2020-09-09 4:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-08 16:41 [RFC 0/4] Add a 'in_mmio' device flag to avoid the DMA to MMIO Li Qiang
2020-09-08 16:41 ` [RFC 1/4] memory: add memory_region_init_io_with_dev interface Li Qiang
2020-09-09 2:15 ` Jason Wang
2020-09-09 4:45 ` Li Qiang [this message]
2020-09-09 4:48 ` Gerd Hoffmann
2020-09-09 4:58 ` Li Qiang
2020-09-09 14:28 ` Alexander Bulekov
2020-09-10 14:37 ` Li Qiang
2020-09-14 2:37 ` Jason Wang
2020-09-20 7:55 ` Paolo Bonzini
2020-09-08 16:41 ` [RFC 2/4] memory: avoid reenter the device's MMIO handler while processing MMIO Li Qiang
2020-09-08 16:41 ` [RFC 3/4] e1000e: use the new memory_region_init_io_with_dev interface Li Qiang
2020-09-08 16:41 ` [RFC 4/4] hcd-xhci: " Li Qiang
2020-09-09 2:16 ` [RFC 0/4] Add a 'in_mmio' device flag to avoid the DMA to MMIO Jason Wang
2020-09-09 4:39 ` Li Qiang
2020-09-20 7:56 ` Paolo Bonzini
2020-09-20 20:24 ` Peter Maydell
2020-09-21 4:39 ` Li Qiang
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='CAKXe6S+=s9D+EbQeb11f308VzrdCyTzXTLHqc6+ron5nE0ioUg@mail.gmail.com' \
--to=liq3ea@gmail.com \
--cc=alxndr@bu.edu \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dmitry.fleytman@gmail.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=jasowang@redhat.com \
--cc=kraxel@redhat.com \
--cc=liq3ea@163.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.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).