1. 14 3月, 2017 1 次提交
  2. 03 3月, 2017 1 次提交
    • D
      spapr_pci: Advertise access to PCIe extended config space · bb998645
      David Gibson 提交于
      The (paravirtual) PCI host bridge on the 'pseries' machine in most
      regards acts like a regular PCI bus, rather than a PCIe bus.  Despite
      this, though, it does allow access to the PCIe extended config space.
      
      We already implemented the RTAS methods to allow this access.. but
      forgot to put the markers into the device tree so that guest's know it
      is there.  This adds them in.
      
      With this, a pseries guest is able to view extended config space on
      (for example an e1000e device.  This should be enough to allow guests
      to use at least some PCIe devices.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      bb998645
  3. 01 3月, 2017 4 次提交
    • C
    • C
      ppc/xics: store the ICS object under the sPAPR machine · 681bfade
      Cédric Le Goater 提交于
      A list of ICS objects was introduced under the XICS object for the
      PowerNV machine but, for the sPAPR machine, it brings extra complexity
      as there is only a single ICS. To simplify the code, let's add the ICS
      pointer under the sPAPR machine and try to reduce the use of this list
      where possible.
      
      Also, change the xics_spapr_*() routines to use an ICS object instead
      of an XICSState and change their name to reflect that these are
      specific to the sPAPR ICS object.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      681bfade
    • G
      spapr/pci: populate PCI DT in reverse order · a8eeafda
      Greg Kurz 提交于
      Since commit 1d2d9742 "spapr_pci: enumerate and add PCI device tree", QEMU
      populates the PCI device tree in the opposite order compared to SLOF.
      
      Before 1d2d9742:
      
      Populating /pci@800000020000000
                           00 0000 (D) : 1af4 1000    virtio [ net ]
                           00 0800 (D) : 1af4 1001    virtio [ block ]
                           00 1000 (D) : 1af4 1009    virtio [ network ]
      Populating /pci@800000020000000/unknown-legacy-device@2
      
      7e5294b8 :  /pci@800000020000000
      7e52b998 :  |-- ethernet@0
      7e52c0c8 :  |-- scsi@1
      7e52c7e8 :  +-- unknown-legacy-device@2 ok
      
      Since 1d2d9742:
      
      Populating /pci@800000020000000
                           00 1000 (D) : 1af4 1009    virtio [ network ]
      Populating /pci@800000020000000/unknown-legacy-device@2
                           00 0800 (D) : 1af4 1001    virtio [ block ]
                           00 0000 (D) : 1af4 1000    virtio [ net ]
      
      7e5e8118 :  /pci@800000020000000
      7e5ea6a0 :  |-- unknown-legacy-device@2
      7e5eadb8 :  |-- scsi@1
      7e5eb4d8 :  +-- ethernet@0 ok
      
      This behaviour change is not actually a bug since no assumptions should be
      made on DT ordering. But it has no real justification either, other than
      being the consequence of the way fdt_add_subnode() inserts new elements
      to the front of the FDT rather than adding them to the tail.
      
      This patch reverts to the historical SLOF ordering by walking PCI devices
      in reverse order. This reconciles pseries with x86 machine types behavior.
      It is expected to make things easier when porting existing applications to
      power.
      Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Tested-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NNikunj A Dadhania <nikunj@linux.vnet.ibm.com>
      (slight update to the changelog)
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      a8eeafda
    • L
      spapr: generate DT node names · 2530a1a5
      Laurent Vivier 提交于
      When DT node names for PCI devices are generated by SLOF,
      they are generated according to the type of the device
      (for instance, ethernet for virtio-net-pci device).
      
      Node name for hotplugged devices is generated by QEMU.
      This patch adds the mechanic to QEMU to create the node
      name according to the device type too.
      
      The data structure has been roughly copied from OpenBIOS/OpenHackware,
      node names from SLOF.
      
      Example:
      
      Hotplugging some PCI cards with QEMU monitor:
      
      device_add virtio-tablet-pci
      device_add virtio-serial-pci
      device_add virtio-mouse-pci
      device_add virtio-scsi-pci
      device_add virtio-gpu-pci
      device_add ne2k_pci
      device_add nec-usb-xhci
      device_add intel-hda
      
      What we can see in linux device tree:
      
      for dir in /proc/device-tree/pci@800000020000000/*@*/; do
          echo $dir
          cat $dir/name
          echo
      done
      
      WITHOUT this patch:
      
      /proc/device-tree/pci@800000020000000/pci@0/
      pci
      /proc/device-tree/pci@800000020000000/pci@1/
      pci
      /proc/device-tree/pci@800000020000000/pci@2/
      pci
      /proc/device-tree/pci@800000020000000/pci@3/
      pci
      /proc/device-tree/pci@800000020000000/pci@4/
      pci
      /proc/device-tree/pci@800000020000000/pci@5/
      pci
      /proc/device-tree/pci@800000020000000/pci@6/
      pci
      /proc/device-tree/pci@800000020000000/pci@7/
      pci
      
      WITH this patch:
      
      /proc/device-tree/pci@800000020000000/communication-controller@1/
      communication-controller
      /proc/device-tree/pci@800000020000000/display@4/
      display
      /proc/device-tree/pci@800000020000000/ethernet@5/
      ethernet
      /proc/device-tree/pci@800000020000000/input-controller@0/
      input-controller
      /proc/device-tree/pci@800000020000000/mouse@2/
      mouse
      /proc/device-tree/pci@800000020000000/multimedia-device@7/
      multimedia-device
      /proc/device-tree/pci@800000020000000/scsi@3/
      scsi
      /proc/device-tree/pci@800000020000000/usb-xhci@6/
      usb-xhci
      Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      2530a1a5
  4. 23 11月, 2016 2 次提交
    • D
      spapr: Fix 2.7<->2.8 migration of PCI host bridge · 5c4537bd
      David Gibson 提交于
      daa23699 "spapr_pci: Add a 64-bit MMIO window" subtly broke migration
      from qemu-2.7 to the current version.  It split the device's MMIO
      window into two pieces for 32-bit and 64-bit MMIO.
      
      The patch included backwards compatibility code to convert the old
      property into the new format.  However, the property value was also
      transferred in the migration stream and compared with a (probably
      unwise) VMSTATE_EQUAL.  So, the "raw" value from 2.7 is compared to
      the new style converted value from (pre-)2.8 giving a mismatch and
      migration failure.
      
      Along with the actual field that caused the breakage, there are
      several other ill-advised VMSTATE_EQUAL()s.  To fix forwards
      migration, we read the values in the stream into scratch variables and
      ignore them, instead of comparing for equality.  To fix backwards
      migration, we populate those scratch variables in pre_save() with
      adjusted values to match the old behaviour.
      
      To permit the eventual possibility of removing this cruft from the
      stream, we only include these compatibility fields if a new
      'pre-2.8-migration' property is set.  We clear it on the pseries-2.8
      machine type, which obviously can't be migrated backwards, but set it
      on earlier machine type versions.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      5c4537bd
    • D
      Revert "spapr: Fix migration of PCI host bridges from qemu-2.7" · 5a78b821
      David Gibson 提交于
      This reverts commit 9b54ca0b.
      
      The commit above corrected a migration breakage between qemu-2.7 and
      qemu-2.8.  However it did so by advancing the migration version for
      the PCI host bridge, which obviously breaks migration backwards to
      earlier qemu versions.
      
      Although it's not totally essential, we'd like to maintain the
      possibility for backwards migration, so revert the change in
      preparation for a better fix.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      5a78b821
  5. 15 11月, 2016 1 次提交
    • D
      spapr: Fix migration of PCI host bridges from qemu-2.7 · 9b54ca0b
      David Gibson 提交于
      daa23699 "spapr_pci: Add a 64-bit MMIO window" subtly broke migration from
      qemu-2.7 to the current version.  It split the device's MMIO window into
      two pieces for 32-bit and 64-bit MMIO.
      
      The patch included backwards compatibility code to convert the old property
      into the new format.  However, the property value was also transferred in
      the migration stream and compared with a (probably unwise) VMSTATE_EQUAL.
      So, the "raw" value from 2.7 is compared to the new style converted value
      from (pre-)2.8 giving a mismatch and migration failure.
      
      Although it would be technically possible to fix this in a way allowing
      backwards migration, that would leave an ugly legacy around indefinitely.
      This patch takes the simpler approach of bumping the migration version,
      dropping the unwise VMSTATE_EQUAL (and some equally unwise ones around it)
      and ignoring them on an incoming migration.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      9b54ca0b
  6. 28 10月, 2016 1 次提交
    • M
      spapr_pci: advertise explicit numa IDs even when there's 1 node · 4bcfa56c
      Michael Roth 提交于
      With the addition of "numa_node" properties for PHBs we began
      advertising NUMA affinity in cases where nb_numa_nodes > 1.
      
      Since the default on the guest side is to make no assumptions about
      PHB NUMA affinity (defaulting to -1), there is still a valid use-case
      for explicitly defining a PHB's NUMA affinity even when there's just
      one node. In particular, some workloads make faulty assumptions about
      /sys/bus/pci/<devid>/numa_node being >= 0, warranting the use of
      this property as a workaround even if there's just 1 PHB or NUMA
      node.
      
      Enable this use-case by always advertising the PHB's NUMA affinity
      if "numa_node" has been explicitly set.
      
      We could achieve this by relaxing the check to simply be
      nb_numa_nodes > 0, but even safer would be to check
      numa_info[nodeid].present explicitly, and to fail at start time
      for cases where it does not exist.
      
      This has an additional affect of no longer advertising PHB NUMA
      affinity unconditionally if nb_numa_nodes > 1 and "numa_node"
      property is unset/-1, but since the default value on the guest
      side for each PHB is also -1, the behavior should be the same for
      that situation. We could still retain the old behavior if desired,
      but the decision seems arbitrary, so we take the simpler route.
      
      Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
      Cc: Shivaprasad G. Bhat <shivapbh@in.ibm.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      4bcfa56c
  7. 16 10月, 2016 3 次提交
    • D
      spapr: Improved placement of PCI host bridges in guest memory map · 357d1e3b
      David Gibson 提交于
      Currently, the MMIO space for accessing PCI on pseries guests begins at
      1 TiB in guest address space.  Each PCI host bridge (PHB) has a 64 GiB
      chunk of address space in which it places its outbound PIO and 32-bit and
      64-bit MMIO windows.
      
      This scheme as several problems:
        - It limits guest RAM to 1 TiB (though we have a limited fix for this
          now)
        - It limits the total MMIO window to 64 GiB.  This is not always enough
          for some of the large nVidia GPGPU cards
        - Putting all the windows into a single 64 GiB area means that naturally
          aligning things within there will waste more address space.
      In addition there was a miscalculation in some of the defaults, which meant
      that the MMIO windows for each PHB actually slightly overran the 64 GiB
      region for that PHB.  We got away without nasty consequences because
      the overrun fit within an unused area at the beginning of the next PHB's
      region, but it's not pretty.
      
      This patch implements a new scheme which addresses those problems, and is
      also closer to what bare metal hardware and pHyp guests generally use.
      
      Because some guest versions (including most current distro kernels) can't
      access PCI MMIO above 64 TiB, we put all the PCI windows between 32 TiB and
      64 TiB.  This is broken into 1 TiB chunks.  The first 1 TiB contains the
      PIO (64 kiB) and 32-bit MMIO (2 GiB) windows for all of the PHBs.  Each
      subsequent TiB chunk contains a naturally aligned 64-bit MMIO window for
      one PHB each.
      
      This reduces the number of allowed PHBs (without full manual configuration
      of all the windows) from 256 to 31, but this should still be plenty in
      practice.
      
      We also change some of the default window sizes for manually configured
      PHBs to saner values.
      
      Finally we adjust some tests and libqos so that it correctly uses the new
      default locations.  Ideally it would parse the device tree given to the
      guest, but that's a more complex problem for another time.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      357d1e3b
    • D
      spapr_pci: Add a 64-bit MMIO window · daa23699
      David Gibson 提交于
      On real hardware, and under pHyp, the PCI host bridges on Power machines
      typically advertise two outbound MMIO windows from the guest's physical
      memory space to PCI memory space:
        - A 32-bit window which maps onto 2GiB..4GiB in the PCI address space
        - A 64-bit window which maps onto a large region somewhere high in PCI
          address space (traditionally this used an identity mapping from guest
          physical address to PCI address, but that's not always the case)
      
      The qemu implementation in spapr-pci-host-bridge, however, only supports a
      single outbound MMIO window, however.  At least some Linux versions expect
      the two windows however, so we arranged this window to map onto the PCI
      memory space from 2 GiB..~64 GiB, then advertised it as two contiguous
      windows, the "32-bit" window from 2G..4G and the "64-bit" window from
      4G..~64G.
      
      This approach means, however, that the 64G window is not naturally aligned.
      In turn this limits the size of the largest BAR we can map (which does have
      to be naturally aligned) to roughly half of the total window.  With some
      large nVidia GPGPU cards which have huge memory BARs, this is starting to
      be a problem.
      
      This patch adds true support for separate 32-bit and 64-bit outbound MMIO
      windows to the spapr-pci-host-bridge implementation, each of which can
      be independently configured.  The 32-bit window always maps to 2G.. in PCI
      space, but the PCI address of the 64-bit window can be configured (it
      defaults to the same as the guest physical address).
      
      So as not to break possible existing configurations, as long as a 64-bit
      window is not specified, a large single window can be specified.  This
      will appear the same way to the guest as the old approach, although it's
      now implemented by two contiguous memory regions rather than a single one.
      
      For now, this only adds the possibility of 64-bit windows.  The default
      configuration still uses the legacy mode.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      daa23699
    • D
      spapr_pci: Delegate placement of PCI host bridges to machine type · 6737d9ad
      David Gibson 提交于
      The 'spapr-pci-host-bridge' represents the virtual PCI host bridge (PHB)
      for a PAPR guest.  Unlike on x86, it's routine on Power (both bare metal
      and PAPR guests) to have numerous independent PHBs, each controlling a
      separate PCI domain.
      
      There are two ways of configuring the spapr-pci-host-bridge device: first
      it can be done fully manually, specifying the locations and sizes of all
      the IO windows.  This gives the most control, but is very awkward with 6
      mandatory parameters.  Alternatively just an "index" can be specified
      which essentially selects from an array of predefined PHB locations.
      The PHB at index 0 is automatically created as the default PHB.
      
      The current set of default locations causes some problems for guests with
      large RAM (> 1 TiB) or PCI devices with very large BARs (e.g. big nVidia
      GPGPU cards via VFIO).  Obviously, for migration we can only change the
      locations on a new machine type, however.
      
      This is awkward, because the placement is currently decided within the
      spapr-pci-host-bridge code, so it breaks abstraction to look inside the
      machine type version.
      
      So, this patch delegates the "default mode" PHB placement from the
      spapr-pci-host-bridge device back to the machine type via a public method
      in sPAPRMachineClass.  It's still a bit ugly, but it's about the best we
      can do.
      
      For now, this just changes where the calculation is done.  It doesn't
      change the actual location of the host bridges, or any other behaviour.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      6737d9ad
  8. 14 10月, 2016 1 次提交
  9. 23 9月, 2016 1 次提交
  10. 05 7月, 2016 2 次提交
    • A
      spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW) · ae4de14c
      Alexey Kardashevskiy 提交于
      This adds support for Dynamic DMA Windows (DDW) option defined by
      the SPAPR specification which allows to have additional DMA window(s)
      
      The "ddw" property is enabled by default on a PHB but for compatibility
      the pseries-2.6 machine and older disable it.
      This also creates a single DMA window for the older machines to
      maintain backward migration.
      
      This implements DDW for PHB with emulated and VFIO devices. The host
      kernel support is required. The advertised IOMMU page sizes are 4K and
      64K; 16M pages are supported but not advertised by default, in order to
      enable them, the user has to specify "pgsz" property for PHB and
      enable huge pages for RAM.
      
      The existing linux guests try creating one additional huge DMA window
      with 64K or 16MB pages and map the entire guest RAM to. If succeeded,
      the guest switches to dma_direct_ops and never calls TCE hypercalls
      (H_PUT_TCE,...) again. This enables VFIO devices to use the entire RAM
      and not waste time on map/unmap later. This adds a "dma64_win_addr"
      property which is a bus address for the 64bit window and by default
      set to 0x800.0000.0000.0000 as this is what the modern POWER8 hardware
      uses and this allows having emulated and VFIO devices on the same bus.
      
      This adds 4 RTAS handlers:
      * ibm,query-pe-dma-window
      * ibm,create-pe-dma-window
      * ibm,remove-pe-dma-window
      * ibm,reset-pe-dma-window
      These are registered from type_init() callback.
      
      These RTAS handlers are implemented in a separate file to avoid polluting
      spapr_iommu.c with PCI.
      
      This changes sPAPRPHBState::dma_liobn to an array to allow 2 LIOBNs
      and updates all references to dma_liobn. However this does not add
      64bit LIOBN to the migration stream as in fact even 32bit LIOBN is
      rather pointless there (as it is a PHB property and the management
      software can/should pass LIOBNs via CLI) but we keep it for the backward
      migration support.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      ae4de14c
    • A
      spapr_iommu: Realloc guest visible TCE table when starting/stopping listening · 606b5498
      Alexey Kardashevskiy 提交于
      The sPAPR TCE tables manage 2 copies when VFIO is using an IOMMU -
      a guest view of the table and a hardware TCE table. If there is no VFIO
      presense in the address space, then just the guest view is used, if
      this is the case, it is allocated in the KVM. However since there is no
      support yet for VFIO in KVM TCE hypercalls, when we start using VFIO,
      we need to move the guest view from KVM to the userspace; and we need
      to do this for every IOMMU on a bus with VFIO devices.
      
      This implements the callbacks for the sPAPR IOMMU - notify_started()
      reallocated the guest view to the user space, notify_stopped() does
      the opposite.
      
      This removes explicit spapr_tce_set_need_vfio() call from PCI hotplug
      path as the new callbacks do this better - they notify IOMMU at
      the exact moment when the configuration is changed, and this also
      includes the case of PCI hot unplug.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Acked-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      606b5498
  11. 01 7月, 2016 2 次提交
  12. 07 6月, 2016 5 次提交
  13. 27 5月, 2016 2 次提交
  14. 19 5月, 2016 1 次提交
  15. 23 4月, 2016 1 次提交
    • T
      hw/ppc/spapr: Fix crash when specifying bad parameters to spapr-pci-host-bridge · da34fed7
      Thomas Huth 提交于
      QEMU currently crashes when using bad parameters for the
      spapr-pci-host-bridge device:
      
      $ qemu-system-ppc64 -device spapr-pci-host-bridge,buid=0x123,liobn=0x321,mem_win_addr=0x1,io_win_addr=0x10
      Segmentation fault
      
      The problem is that spapr_tce_find_by_liobn() might return NULL, but
      the code in spapr_populate_pci_dt() does not check for this condition
      and then tries to dereference this NULL pointer.
      Apart from that, the return value of spapr_populate_pci_dt() also
      has to be checked for all PCI buses, not only for the last one, to
      make sure we catch all errors.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      da34fed7
  16. 23 3月, 2016 2 次提交
    • P
      hw: explicitly include qemu-common.h and cpu.h · 4771d756
      Paolo Bonzini 提交于
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      4771d756
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  17. 16 3月, 2016 4 次提交
    • D
      spapr_pci: Remove finish_realize hook · a36304fd
      David Gibson 提交于
      Now that spapr-pci-vfio-host-bridge is reduced to just a stub, there is
      only one implementation of the finish_realize hook in sPAPRPHBClass.  So,
      we can fold that implementation into its (single) caller, and remove the
      hook.  That's the last thing left in sPAPRPHBClass, so that can go away as
      well.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      a36304fd
    • D
      spapr_pci: Allow EEH on spapr-pci-host-bridge · c1fa017c
      David Gibson 提交于
      Now that the EEH code is independent of the special
      spapr-vfio-pci-host-bridge device, we can allow it on all spapr PCI
      host bridges instead.  We do this by changing spapr_phb_eeh_available()
      to be based on the vfio_eeh_as_ok() call instead of the host bridge class.
      
      Because the value of vfio_eeh_as_ok() can change with devices being
      hotplugged or unplugged, this can potentially lead to some strange edge
      cases where the guest starts using EEH, then it starts failing because
      of a change in status.
      
      However, it's not really any worse than the current situation.  Cases that
      would have worked previously will still work (i.e. VFIO devices from at
      most one VFIO IOMMU group per vPHB), it's just that it's no longer
      necessary to use spapr-vfio-pci-host-bridge with the groupid pre-specified.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      c1fa017c
    • D
      spapr_pci: Eliminate class callbacks · fbb4e983
      David Gibson 提交于
      The EEH operations in the spapr-vfio-pci-host-bridge no longer rely on the
      special groupid field in sPAPRPHBVFIOState.  So we can simplify, removing
      the class specific callbacks with direct calls based on a simple
      spapr_phb_eeh_enabled() helper.  For now we implement that in terms of
      a boolean in the class, but we'll continue to clean that up later.
      
      On its own this is a rather strange way of doing things, but it's a useful
      intermediate step to further cleanups.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      fbb4e983
    • M
      spapr_pci: fix multifunction hotplug · 788d2599
      Michael Roth 提交于
      Since 3f1e1478, QEMU has adopted a convention of supporting function
      hotplug by deferring hotplug events until func 0 is hotplugged.
      This is likely how management tools like libvirt would expose
      such support going forward.
      
      Since sPAPR guests rely on per-func events rather than
      slot-based, our protocol has been to hotplug func 0 *first* to
      avoid cases where devices appear within guests without func 0
      present to avoid undefined behavior.
      
      To remain compatible with new convention, defer hotplug in a
      similar manner, but then generate events in 0-first order as we
      did in the past. Once func 0 present, fail any attempts to plug
      additional functions (as we do with PCIe).
      
      For unplug, defer unplug operations in a similar manner, but
      generate unplug events such that function 0 is removed last in guest.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      788d2599
  18. 11 3月, 2016 1 次提交
  19. 28 2月, 2016 3 次提交
    • G
      xics: report errors with the QEMU Error API · a005b3ef
      Greg Kurz 提交于
      Using the return value to report errors is error prone:
      - xics_alloc() returns -1 on error but spapr_vio_busdev_realize() errors
        on 0
      - xics_alloc_block() returns the unclear value of ics->offset - 1 on error
        but both rtas_ibm_change_msi() and spapr_phb_realize() error on 0
      
      This patch adds an errp argument to xics_alloc() and xics_alloc_block() to
      report errors. The return value of these functions is a valid IRQ number
      if errp is NULL. It is undefined otherwise.
      
      The corresponding error traces get promotted to error messages. Note that
      the "can't allocate IRQ" error message in spapr_vio_busdev_realize() also
      moves to xics_alloc(). Similar error message consolidation isn't really
      applicable to xics_alloc_block() because callers have extra context (device
      config address, MSI or MSIX).
      
      This fixes the issues mentioned above.
      
      Based on previous work from Brian W. Hart.
      Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      a005b3ef
    • G
      spapr_pci: fix irq leak in RTAS ibm,change-msi · ce266b75
      Greg Kurz 提交于
      This RTAS call is used to request new interrupts or to free all interrupts.
      
      If the driver has already allocated interrupts and asks again for a non-null
      number of irqs, then the rtas_ibm_change_msi() function will silently leak
      the previous interrupts.
      
      It happens because xics_free() is only called when the driver releases all
      interrupts (!req_num case). Note that the previously allocated spapr_pci_msi
      is not leaked because the GHashTable is created with destroy functions and
      g_hash_table_insert() hence frees the old value.
      
      This patch makes sure any previously allocated MSIs are released when a
      new allocation succeeds.
      Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      ce266b75
    • G
      spapr_pci: kill useless variable in rtas_ibm_change_msi() · d4a63ac8
      Greg Kurz 提交于
      The num local variable is initialized to zero and has no writer.
      Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      d4a63ac8
  20. 29 1月, 2016 1 次提交
    • P
      ppc: Clean up includes · 0d75590d
      Peter Maydell 提交于
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1453832250-766-6-git-send-email-peter.maydell@linaro.org
      0d75590d
  21. 23 10月, 2015 1 次提交