From patchwork Fri Jun 1 17:59:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 137573 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1243775lji; Fri, 1 Jun 2018 10:59:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJh+RcIXC8vGK4SDjQcrQUXfEC/WPcvD4ntccEIRMJbxY1VB/vIxwm9ArCXA1sZ5i9R9NJy X-Received: by 2002:a1c:aa0c:: with SMTP id t12-v6mr3544444wme.56.1527875954858; Fri, 01 Jun 2018 10:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527875954; cv=none; d=google.com; s=arc-20160816; b=R43WX8c0z4r+cY26l0YBMbhzQQo0uBrcJt1w2EKRY5bf7c5HgSJIoM9FpHIu7nz3vz 3A5gje8D0Stw/9X3c9Jh51TvOB6s/wgaZLNHgIacjdNaYURo7AUK72D5vlY0kYYL0IK5 rusNSfS7F8DtmV2vrMqIdwP9MlipZVr1Qu0XMEHrkBU+dWERZYi+n4tC6QE/aVmR+Mjn rduLyhYsaZuPvDiiEexvY624gzVJHUej0PJOCvvMxNaF/brjsB4XnEw/+JvNG8RUXzLu 7r1KKDORAVceMV3ClhfGsj1uQevkPVtJ0shomSY1z5/Tw6zpsNlEYUWRtIz5xQ4fg55b oh+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=9Y0hHHjrifeR6eOhBYbqILrhUIQzKSLFP3tRGq8ZMrY=; b=CEj5jcxAj2VtA5CLjRZyQ+c7qtQUv+IpyZfiy9MOPHCIJ/l+68S+jIR1taoa50ffd8 OfEkQqKek1FgvIynQvX+iNDrPmgRUxmt2sFclZuhc/Th482SXMOKDGl7qdd7Q0vZhkBL 0Q0+uqoF1Tdff3YhV0mYQ0hnakl8ao4vYJcZuG/kmqRa9F+NLCMX4393V2xGJS4PSuY4 lacewL30eqS9s0AucrbvKb236+8/JBiW0RGpHa3XC01Wkct4rnaDqi7XbXbB5Ulc/1Kk 2qVNwKnMvrUIrzuJtNQhbMsNOgLa3ky0VzimSJ3ZKbXdsEoD8tIMvXrEyV6jL8g482bf Trgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id j1-v6si35428124wrj.103.2018.06.01.10.59.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 10:59:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fOoKV-0004GS-MM; Fri, 01 Jun 2018 18:59:11 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefano Stabellini , Anthony Perard , xen-devel@lists.xenproject.org Subject: [RFC] xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom() Date: Fri, 1 Jun 2018 18:59:10 +0100 Message-Id: <20180601175910.28146-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 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 --- 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(-) -- 2.17.1 Acked-by: Anthony PERARD 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);