mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-15 06:01:58 -06:00
xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom()
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. Acked-by: Anthony PERARD <anthony.perard@citrix.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
b8d880ba6d
commit
6dad8260e8
3 changed files with 5 additions and 5 deletions
|
@ -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,
|
extern void *pci_assign_dev_load_option_rom(PCIDevice *dev,
|
||||||
struct Object *owner, int *size,
|
int *size,
|
||||||
unsigned int domain,
|
unsigned int domain,
|
||||||
unsigned int bus, unsigned int slot,
|
unsigned int bus, unsigned int slot,
|
||||||
unsigned int function);
|
unsigned int function);
|
||||||
|
|
|
@ -132,7 +132,7 @@ int xen_pt_unregister_vga_regions(XenHostPCIDevice *dev)
|
||||||
static void *get_vgabios(XenPCIPassthroughState *s, int *size,
|
static void *get_vgabios(XenPCIPassthroughState *s, int *size,
|
||||||
XenHostPCIDevice *dev)
|
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->domain, dev->bus,
|
||||||
dev->dev, dev->func);
|
dev->dev, dev->func);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* load the corresponding ROM data to RAM. If an error occurs while loading an
|
* 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.
|
* 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,
|
int *size, unsigned int domain,
|
||||||
unsigned int bus, unsigned int slot,
|
unsigned int bus, unsigned int slot,
|
||||||
unsigned int function)
|
unsigned int function)
|
||||||
|
@ -29,6 +29,7 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, struct Object *owner,
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
void *ptr = NULL;
|
void *ptr = NULL;
|
||||||
|
Object *owner = OBJECT(dev);
|
||||||
|
|
||||||
/* If loading ROM from file, pci handles it */
|
/* If loading ROM from file, pci handles it */
|
||||||
if (dev->romfile || !dev->rom_bar) {
|
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);
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s.rom", object_get_typename(owner));
|
snprintf(name, sizeof(name), "%s.rom", object_get_typename(owner));
|
||||||
memory_region_init_ram_nomigrate(&dev->rom, owner, name, st.st_size, &error_abort);
|
memory_region_init_ram(&dev->rom, owner, name, st.st_size, &error_abort);
|
||||||
vmstate_register_ram(&dev->rom, &dev->qdev);
|
|
||||||
ptr = memory_region_get_ram_ptr(&dev->rom);
|
ptr = memory_region_get_ram_ptr(&dev->rom);
|
||||||
memset(ptr, 0xff, st.st_size);
|
memset(ptr, 0xff, st.st_size);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue