1. 08 6月, 2017 3 次提交
    • D
      spapr: Change DRC attach & detach methods to functions · 0be4e886
      David Gibson 提交于
      DRC objects have attach & detach methods, but there's only one
      implementation.  Although there are some differences in its behaviour for
      different DRC types, the overall structure is the same, so while we might
      want different method implementations for some parts, we're unlikely to
      want them for the top-level functions.
      
      So, replace them with direct function calls.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Acked-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      0be4e886
    • D
      spapr: Clean up handling of DR-indicator · cd74d27e
      David Gibson 提交于
      There are 3 types of "indicator" associated with hotplug in the PAPR spec
      the "allocation state", "isolation state" and "DR-indicator".  The first
      two are intimately tied to the various state transitions associated with
      hotplug.  The DR-indicator, however, is different and simpler.
      
      It's basically just a guest controlled variable which can be used by the
      guest to flag state or problems associated with a device.  The idea is that
      the hypervisor can use it to present information back on management
      consoles (on some machines with PowerVM it may even control physical LEDs
      on the machine case associated with the relevant device).
      
      For that reason, there's only ever likely to be a single update
      implementation so the set_indicator_state method isn't useful.  Replace it
      with a direct function call.
      
      While we're there, make some small associated cleanups:
        * PAPR doesn't use the term "indicator state", just "DR-indicator" and
      the allocation state and isolation state are also considered "indicators".
      Rename things to be less confusing
        * Fold set_indicator_state() and rtas_set_indicator_state() into a single
      rtas_set_dr_indicator() function.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Acked-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      cd74d27e
    • D
      spapr: Clean up DR entity sense handling · f224d35b
      David Gibson 提交于
      DRC classes have an entity_sense method to determine (in a specific PAPR
      sense) the presence or absence of a device plugged into a DRC.  However,
      we only have one implementation of the method, which explicitly tests for
      different DRC types.  This changes it to instead have different method
      implementations for the two cases: "logical" and "physical" DRCs.
      
      While we're at it, the entity sense method always returns RTAS_OUT_SUCCESS,
      and the interesting value is returned via pass-by-reference.  Simplify this
      to directly return the value we care about
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Acked-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      f224d35b
  2. 06 6月, 2017 7 次提交
  3. 25 5月, 2017 1 次提交
    • D
      hw/ppc: removing drc->detach_cb and drc->detach_cb_opaque · 31834723
      Daniel Henrique Barboza 提交于
      The pointer drc->detach_cb is being used as a way of informing
      the detach() function inside spapr_drc.c which cb to execute. This
      information can also be retrieved simply by checking drc->type and
      choosing the right callback based on it. In this context, detach_cb
      is redundant information that must be managed.
      
      After the previous spapr_lmb_release change, no detach_cb_opaques
      are being used by any of the three callbacks functions. This is
      yet another information that is now unused and, on top of that, can't
      be migrated either.
      
      This patch makes the following changes:
      
      - removal of detach_cb_opaque. the 'opaque' argument was removed from
      the callbacks and from the detach() function of sPAPRConnectorClass. The
      attribute detach_cb_opaque of sPAPRConnector was removed.
      
      - removal of detach_cb from the detach() call. The function pointer
      detach_cb of sPAPRConnector was removed. detach() now uses a
      switch(drc->type) to execute the apropriate callback. To achieve this,
      spapr_core_release, spapr_lmb_release and spapr_phb_remove_pci_device_cb
      callbacks were made public to be visible inside detach().
      Signed-off-by: NDaniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      31834723
  4. 29 3月, 2017 1 次提交
    • L
      spapr: fix memory hot-unplugging · fe6824d1
      Laurent Vivier 提交于
      If, once the kernel has booted, we try to remove a memory
      hotplugged while the kernel was not started, QEMU crashes on
      an assert:
      
          qemu-system-ppc64: hw/virtio/vhost.c:651:
                             vhost_commit: Assertion `r >= 0' failed.
          ...
          #4  in vhost_commit
          #5  in memory_region_transaction_commit
          #6  in pc_dimm_memory_unplug
          #7  in spapr_memory_unplug
          #8  spapr_machine_device_unplug
          #9  in hotplug_handler_unplug
          #10 in spapr_lmb_release
          #11 in detach
          #12 in set_allocation_state
          #13 in rtas_set_indicator
          ...
      
      If we take a closer look to the guest kernel log, we can see when
      we try to unplug the memory:
      
          pseries-hotplug-mem: Attempting to hot-add 4 LMB(s)
      
      What happens:
      
          1- The kernel has ignored the memory hotplug event because
             it was not started when it was generated.
      
          2- When we hot-unplug the memory,
             QEMU starts to remove the memory,
                  generates an hot-unplug event,
              and signals the kernel of the incoming new event
      
          3- as the kernel is started, on the QEMU signal, it reads
             the event list, decodes the hotplug event and tries to
             finish the hotplugging.
      
          4- QEMU receive the the hotplug notification while it
             is trying to hot-unplug the memory. This moves the memory
             DRC to an invalid state
      
      This patch prevents this by not allowing to set the allocation
      state to USABLE while the DRC is awaiting release.
      
      RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1432382Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      fe6824d1
  5. 12 7月, 2016 2 次提交
  6. 17 6月, 2016 1 次提交
  7. 05 4月, 2016 1 次提交
    • M
      spapr_drc: enable immediate detach for unsignalled devices · f40eb921
      Michael Roth 提交于
      Currently spapr doesn't support "aborting" hotplug of PCI
      devices by allowing device_del to immediately remove the
      device if we haven't signalled the presence of the device
      to the guest.
      
      In the past this wasn't an issue, since we always immediately
      signalled device attach and simply relied on full guest-aware
      add->remove path for device removal. However, as of 788d2599,
      we now defer signalling for PCI functions until function 0
      is attached, so now we need to deal with these "abort" operations
      for cases where a user hotplugs a non-0 function, then opts to
      remove it prior hotplugging function 0. Currently they'd have to
      reboot before the unplug completed. PCIe multifunction hotplug
      does not have this requirement however, so from a management
      implementation perspective it would be good to address this within
      the same release as 788d2599.
      
      We accomplish this by simply adding a 'signalled' flag to track
      whether a device hotplug event has been sent to the guest. If it
      hasn't, we allow immediate removal under the assumption that the
      guest will not be using the device. Devices present at boot/reset
      time are also assumed to be 'signalled'.
      
      For CPU/memory/etc, signalling will still happen immediately
      as part of device_add, so only PCI functions should be affected.
      
      Cc: bharata@linux.vnet.ibm.com
      Cc: david@gibson.dropbear.id.au
      Cc: sbhat@linux.vnet.ibm.com
      Cc: qemu-ppc@nongnu.org
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      [dwg: This fixes a regression where an incorrect hot-add of a non-zero
            function can no longer be backed out until function 0 is added]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      f40eb921
  8. 23 9月, 2015 2 次提交
  9. 04 6月, 2015 2 次提交
    • M
      spapr_drc: add spapr_drc_populate_dt() · e4b798bb
      Michael Roth 提交于
      This function handles generation of ibm,drc-* array device tree
      properties to describe DRC topology to guests. This will by used
      by the guest to direct RTAS calls to manage any dynamic resources
      we associate with a particular DR Connector as part of
      hotplug/unplug.
      
      Since general management of boot-time device trees are handled
      outside of sPAPRDRConnector, we insert these values blindly given
      an FDT and offset. A mask of sPAPRDRConnector types is given to
      instruct us on what types of connectors entries should be generated
      for, since descriptions for different connectors may live in
      different parts of the device tree.
      
      Based on code originally written by Nathan Fontenot.
      Signed-off-by: NNathan Fontenot <nfont@linux.vnet.ibm.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      e4b798bb
    • M
      spapr_drc: initial implementation of sPAPRDRConnector device · bbf5c878
      Michael Roth 提交于
      This device emulates a firmware abstraction used by pSeries guests to
      manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
      memory, and CPUs. It is conceptually similar to an SHPC device,
      complete with LED indicators to identify individual slots to physical
      physical users and indicate when it is safe to remove a device. In
      some cases it is also used to manage virtualized resources, such a
      memory, CPUs, and physical-host bridges, which in the case of pSeries
      guests are virtualized resources where the physical components are
      managed by the host.
      
      Guests communicate with these DR Connectors using RTAS calls,
      generally by addressing the unique DRC index associated with a
      particular connector for a particular resource. For introspection
      purposes we expose this state initially as QOM properties, and
      in subsequent patches will introduce the RTAS calls that make use of
      it. This constitutes to the 'guest' interface.
      
      On the QEMU side we provide an attach/detach interface to associate
      or cleanup a DeviceState with a particular sPAPRDRConnector in
      response to hotplug/unplug, respectively. This constitutes the
      'physical' interface to the DR Connector.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      bbf5c878