* [Qemu-devel] [RFC] xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom()
@ 2018-06-01 17:59 Peter Maydell
2018-06-05 16:55 ` Anthony PERARD
0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2018-06-01 17:59 UTC (permalink / raw)
To: qemu-devel; +Cc: patches, Stefano Stabellini, Anthony Perard, xen-devel
The xen pci_assign_dev_load_option_rom() currently creates a RAM
memory region with memory_region_init_ram_nomigrate(), and then
manually registers it with vmstate_register_ram(). In fact for
its only callsite, the 'owner' pointer we use for the init call
and the '&dev->qdev' pointer we use for the vmstate_register_ram()
call refer to the same object. Simplify the function to only
take a pointer to the device once instead of twice, and use
memory_region_init_ram() which automatically does the vmstate
register for us.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
This is a fairly trivial no-behaviour-change code cleanup, but
I've marked it as RFC because I don't have a setup for doing
more than just compile-testing Xen related patches.
This was found as part of a sweep through for code using
the _nomigrate versions of functions.
hw/xen/xen_pt.h | 2 +-
hw/xen/xen_pt_graphics.c | 2 +-
hw/xen/xen_pt_load_rom.c | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h
index aa39a9aa5f..dbee3308fd 100644
--- a/hw/xen/xen_pt.h
+++ b/hw/xen/xen_pt.h
@@ -319,7 +319,7 @@ static inline bool xen_pt_has_msix_mapping(XenPCIPassthroughState *s, int bar)
}
extern void *pci_assign_dev_load_option_rom(PCIDevice *dev,
- struct Object *owner, int *size,
+ int *size,
unsigned int domain,
unsigned int bus, unsigned int slot,
unsigned int function);
diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c
index 0f4c8d77e2..135c8df1e7 100644
--- a/hw/xen/xen_pt_graphics.c
+++ b/hw/xen/xen_pt_graphics.c
@@ -132,7 +132,7 @@ int xen_pt_unregister_vga_regions(XenHostPCIDevice *dev)
static void *get_vgabios(XenPCIPassthroughState *s, int *size,
XenHostPCIDevice *dev)
{
- return pci_assign_dev_load_option_rom(&s->dev, OBJECT(&s->dev), size,
+ return pci_assign_dev_load_option_rom(&s->dev, size,
dev->domain, dev->bus,
dev->dev, dev->func);
}
diff --git a/hw/xen/xen_pt_load_rom.c b/hw/xen/xen_pt_load_rom.c
index 71063c4d79..e6a86ca818 100644
--- a/hw/xen/xen_pt_load_rom.c
+++ b/hw/xen/xen_pt_load_rom.c
@@ -19,7 +19,7 @@
* load the corresponding ROM data to RAM. If an error occurs while loading an
* option ROM, we just ignore that option ROM and continue with the next one.
*/
-void *pci_assign_dev_load_option_rom(PCIDevice *dev, struct Object *owner,
+void *pci_assign_dev_load_option_rom(PCIDevice *dev,
int *size, unsigned int domain,
unsigned int bus, unsigned int slot,
unsigned int function)
@@ -29,6 +29,7 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, struct Object *owner,
uint8_t val;
struct stat st;
void *ptr = NULL;
+ Object *owner = OBJECT(dev);
/* If loading ROM from file, pci handles it */
if (dev->romfile || !dev->rom_bar) {
@@ -59,8 +60,7 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, struct Object *owner,
fseek(fp, 0, SEEK_SET);
snprintf(name, sizeof(name), "%s.rom", object_get_typename(owner));
- memory_region_init_ram_nomigrate(&dev->rom, owner, name, st.st_size, &error_abort);
- vmstate_register_ram(&dev->rom, &dev->qdev);
+ memory_region_init_ram(&dev->rom, owner, name, st.st_size, &error_abort);
ptr = memory_region_get_ram_ptr(&dev->rom);
memset(ptr, 0xff, st.st_size);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [RFC] xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom()
2018-06-01 17:59 [Qemu-devel] [RFC] xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom() Peter Maydell
@ 2018-06-05 16:55 ` Anthony PERARD
2018-06-15 10:06 ` Peter Maydell
0 siblings, 1 reply; 5+ messages in thread
From: Anthony PERARD @ 2018-06-05 16:55 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, patches, Stefano Stabellini, xen-devel
On Fri, Jun 01, 2018 at 06:59:10PM +0100, Peter Maydell wrote:
> The xen pci_assign_dev_load_option_rom() currently creates a RAM
> memory region with memory_region_init_ram_nomigrate(), and then
> manually registers it with vmstate_register_ram(). In fact for
> its only callsite, the 'owner' pointer we use for the init call
> and the '&dev->qdev' pointer we use for the vmstate_register_ram()
> call refer to the same object. Simplify the function to only
> take a pointer to the device once instead of twice, and use
> memory_region_init_ram() which automatically does the vmstate
> register for us.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This is a fairly trivial no-behaviour-change code cleanup, but
> I've marked it as RFC because I don't have a setup for doing
> more than just compile-testing Xen related patches.
> This was found as part of a sweep through for code using
> the _nomigrate versions of functions.
That patch looks fine, and seams fine after hacking my way into testing
the change.
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Thanks,
--
Anthony PERARD
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [RFC] xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom()
2018-06-05 16:55 ` Anthony PERARD
@ 2018-06-15 10:06 ` Peter Maydell
2018-06-15 14:42 ` Anthony PERARD
0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2018-06-15 10:06 UTC (permalink / raw)
To: Anthony PERARD
Cc: QEMU Developers, patches@linaro.org, Stefano Stabellini,
open list:X86
On 5 June 2018 at 17:55, Anthony PERARD <anthony.perard@citrix.com> wrote:
> On Fri, Jun 01, 2018 at 06:59:10PM +0100, Peter Maydell wrote:
>> The xen pci_assign_dev_load_option_rom() currently creates a RAM
>> memory region with memory_region_init_ram_nomigrate(), and then
>> manually registers it with vmstate_register_ram(). In fact for
>> its only callsite, the 'owner' pointer we use for the init call
>> and the '&dev->qdev' pointer we use for the vmstate_register_ram()
>> call refer to the same object. Simplify the function to only
>> take a pointer to the device once instead of twice, and use
>> memory_region_init_ram() which automatically does the vmstate
>> register for us.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> This is a fairly trivial no-behaviour-change code cleanup, but
>> I've marked it as RFC because I don't have a setup for doing
>> more than just compile-testing Xen related patches.
>> This was found as part of a sweep through for code using
>> the _nomigrate versions of functions.
>
> That patch looks fine, and seams fine after hacking my way into testing
> the change.
>
> Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Thanks for the review. Stefano, do you want to take it via the
xen subtree?
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [RFC] xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom()
2018-06-15 10:06 ` Peter Maydell
@ 2018-06-15 14:42 ` Anthony PERARD
2018-06-15 15:38 ` Stefano Stabellini
0 siblings, 1 reply; 5+ messages in thread
From: Anthony PERARD @ 2018-06-15 14:42 UTC (permalink / raw)
To: Peter Maydell
Cc: QEMU Developers, patches@linaro.org, Stefano Stabellini,
open list:X86
On Fri, Jun 15, 2018 at 11:06:47AM +0100, Peter Maydell wrote:
> On 5 June 2018 at 17:55, Anthony PERARD <anthony.perard@citrix.com> wrote:
> > On Fri, Jun 01, 2018 at 06:59:10PM +0100, Peter Maydell wrote:
> >> The xen pci_assign_dev_load_option_rom() currently creates a RAM
> >> memory region with memory_region_init_ram_nomigrate(), and then
> >> manually registers it with vmstate_register_ram(). In fact for
> >> its only callsite, the 'owner' pointer we use for the init call
> >> and the '&dev->qdev' pointer we use for the vmstate_register_ram()
> >> call refer to the same object. Simplify the function to only
> >> take a pointer to the device once instead of twice, and use
> >> memory_region_init_ram() which automatically does the vmstate
> >> register for us.
> >>
> >> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> >> ---
> >> This is a fairly trivial no-behaviour-change code cleanup, but
> >> I've marked it as RFC because I don't have a setup for doing
> >> more than just compile-testing Xen related patches.
> >> This was found as part of a sweep through for code using
> >> the _nomigrate versions of functions.
> >
> > That patch looks fine, and seams fine after hacking my way into testing
> > the change.
> >
> > Acked-by: Anthony PERARD <anthony.perard@citrix.com>
>
> Thanks for the review. Stefano, do you want to take it via the
> xen subtree?
Hi Peter,
We don't have any other patch for xen, so feel free to commit this
one.
--
Anthony PERARD
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [RFC] xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom()
2018-06-15 14:42 ` Anthony PERARD
@ 2018-06-15 15:38 ` Stefano Stabellini
0 siblings, 0 replies; 5+ messages in thread
From: Stefano Stabellini @ 2018-06-15 15:38 UTC (permalink / raw)
To: Anthony PERARD
Cc: Peter Maydell, QEMU Developers, patches@linaro.org,
Stefano Stabellini, open list:X86
On Fri, 15 Jun 2018, Anthony PERARD wrote:
> On Fri, Jun 15, 2018 at 11:06:47AM +0100, Peter Maydell wrote:
> > On 5 June 2018 at 17:55, Anthony PERARD <anthony.perard@citrix.com> wrote:
> > > On Fri, Jun 01, 2018 at 06:59:10PM +0100, Peter Maydell wrote:
> > >> The xen pci_assign_dev_load_option_rom() currently creates a RAM
> > >> memory region with memory_region_init_ram_nomigrate(), and then
> > >> manually registers it with vmstate_register_ram(). In fact for
> > >> its only callsite, the 'owner' pointer we use for the init call
> > >> and the '&dev->qdev' pointer we use for the vmstate_register_ram()
> > >> call refer to the same object. Simplify the function to only
> > >> take a pointer to the device once instead of twice, and use
> > >> memory_region_init_ram() which automatically does the vmstate
> > >> register for us.
> > >>
> > >> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > >> ---
> > >> This is a fairly trivial no-behaviour-change code cleanup, but
> > >> I've marked it as RFC because I don't have a setup for doing
> > >> more than just compile-testing Xen related patches.
> > >> This was found as part of a sweep through for code using
> > >> the _nomigrate versions of functions.
> > >
> > > That patch looks fine, and seams fine after hacking my way into testing
> > > the change.
> > >
> > > Acked-by: Anthony PERARD <anthony.perard@citrix.com>
> >
> > Thanks for the review. Stefano, do you want to take it via the
> > xen subtree?
>
> Hi Peter,
>
> We don't have any other patch for xen, so feel free to commit this
> one.
Yep, go ahead
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-15 15:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-01 17:59 [Qemu-devel] [RFC] xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom() Peter Maydell
2018-06-05 16:55 ` Anthony PERARD
2018-06-15 10:06 ` Peter Maydell
2018-06-15 14:42 ` Anthony PERARD
2018-06-15 15:38 ` Stefano Stabellini
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).