Skip to content
Snippets Groups Projects
  1. May 04, 2021
  2. May 02, 2021
  3. Apr 30, 2021
  4. Apr 12, 2021
    • Daniel Henrique Barboza's avatar
      spapr.c: always pulse guest IRQ in spapr_core_unplug_request() · 2b18fc79
      Daniel Henrique Barboza authored
      
      Commit 47c8c915 fixed a problem where multiple spapr_drc_detach()
      requests were breaking QEMU. The solution was to just spapr_drc_detach()
      once, and use spapr_drc_unplug_requested() to filter whether we already
      detached it or not. The commit also tied the hotplug request to the
      guest in the same condition.
      
      Turns out that there is a reliable way for a CPU hotunplug to fail. If a
      guest with one CPU hotplugs a CPU1, then offline CPU0s via 'echo 0 >
      /sys/devices/system/cpu/cpu0/online', then attempts to hotunplug CPU1,
      the kernel will refuse it because it's the last online CPU of the
      system. Given that we're pulsing the IRQ only in the first try, in a
      failed attempt, all other CPU1 hotunplug attempts will fail, regardless
      of the online state of CPU1 in the kernel, because we're simply not
      letting the guest know that we want to hotunplug the device.
      
      Let's move spapr_hotplug_req_remove_by_index() back out of the "if
      (!spapr_drc_unplug_requested(drc))" conditional, allowing for multiple
      'device_del' requests to the same CPU core to reach the guest, in case
      the CPU core didn't fully hotunplugged previously.
      
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210401000437.131140-3-danielhb413@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      2b18fc79
    • Daniel Henrique Barboza's avatar
      spapr: rollback 'unplug timeout' for CPU hotunplugs · d522cb52
      Daniel Henrique Barboza authored
      The pseries machines introduced the concept of 'unplug timeout' for CPU
      hotunplugs. The idea was to circunvent a deficiency in the pSeries
      specification (PAPR), that currently does not define a proper way for
      the hotunplug to fail. If the guest refuses to release the CPU (see [1]
      for an example) there is no way for QEMU to detect the failure.
      
      Further discussions about how to send a QAPI event to inform about the
      hotunplug timeout [2] exposed problems that weren't predicted back when
      the idea was developed. Other QEMU machines don't have any type of
      hotunplug timeout mechanism for any device, e.g. ACPI based machines
      have a way to make hotunplug errors visible to the hypervisor. This
      would make this timeout mechanism exclusive to pSeries, which is not
      ideal.
      
      The real problem is that a QAPI event that reports hotunplug timeouts
      puts the management layer (namely Libvirt) in a weird spot. We're not
      telling that the hotunplug failed, because we can't be 100% sure of
      that, and yet we're resetting the unplug state back, preventing any
      DEVICE_DEL events to reach out in case the guest decides to release the
      device. Libvirt would need to inspect the guest itself to see if the
      device was released or not, otherwise the internal domain states will be
      inconsistent.  Moreover, Libvirt already has an 'unplug timeout'
      concept, and a QEMU side timeout would need to be juggled together with
      the existing Libvirt timeout.
      
      All this considered, this solution ended up creating more trouble than
      it solved. This patch reverts the 3 commits that introduced the timeout
      mechanism for CPU hotplugs in pSeries machines.
      
      This reverts commit 4515a5f7
      "qemu_timer.c: add timer_deadline_ms() helper"
      
      This reverts commit d1c2e3ce
      "spapr_drc.c: add hotunplug timeout for CPUs"
      
      This reverts commit 51254ffb
      "spapr_drc.c: introduce unplug_timeout_timer"
      
      [1] https://bugzilla.redhat.com/show_bug.cgi?id=1911414
      [2] https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg04682.html
      
      
      
      CC: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210401000437.131140-2-danielhb413@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      d522cb52
  5. Apr 06, 2021
    • Peter Maydell's avatar
      hw/ppc/e500plat: Only try to add valid dynamic sysbus devices to platform bus · e7e0d52d
      Peter Maydell authored
      
      The e500plat machine device plug callback currently calls
      platform_bus_link_device() for any sysbus device.  This is overly
      broad, because platform_bus_link_device() will unconditionally grab
      the IRQs and MMIOs of the device it is passed, whether it was
      intended for the platform bus or not.  Restrict hotpluggability of
      sysbus devices to only those devices on the dynamic sysbus allowlist.
      
      We were mostly getting away with this because the board creates the
      platform bus as the last device it creates, and so the hotplug
      callback did not do anything for all the sysbus devices created by
      the board itself.  However if the user plugged in a device which
      itself uses a sysbus device internally we would have mishandled this
      and probably asserted. An example of this is:
       qemu-system-ppc64 -M ppce500 -device macio-oldworld
      
      This isn't a sensible command because the macio-oldworld device
      is really specific to the 'g3beige' machine, but we now fail
      with a reasonable error message rather than asserting:
      qemu-system-ppc64: Device heathrow is not supported by this machine yet.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Reviewed-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      Reviewed-by: default avatarEric Auger <eric.auger@redhat.com>
      Acked-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Message-id: 20210325153310.9131-5-peter.maydell@linaro.org
      e7e0d52d
  6. Mar 31, 2021
  7. Mar 18, 2021
  8. Mar 16, 2021
  9. Mar 09, 2021
    • Philippe Mathieu-Daudé's avatar
      sysemu: Let VMChangeStateHandler take boolean 'running' argument · 538f0497
      Philippe Mathieu-Daudé authored
      
      The 'running' argument from VMChangeStateHandler does not require
      other value than 0 / 1. Make it a plain boolean.
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Acked-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20210111152020.1422021-3-philmd@redhat.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      538f0497
    • Daniel Henrique Barboza's avatar
      spapr.c: send QAPI event when memory hotunplug fails · eb7f80fd
      Daniel Henrique Barboza authored
      
      Recent changes allowed the pSeries machine to rollback the hotunplug
      process for the DIMM when the guest kernel signals, via a
      reconfiguration of the DR connector, that it's not going to release the
      LMBs.
      
      Let's also warn QAPI listerners about it. One place to do it would be
      right after the unplug state is cleaned up,
      spapr_clear_pending_dimm_unplug_state(). This would mean that the
      function is now doing more than cleaning up the pending dimm state
      though.
      
      This patch does the following changes in spapr.c:
      
      - send a QAPI event to inform that we experienced a failure in the
        hotunplug of the DIMM;
      
      - rename spapr_clear_pending_dimm_unplug_state() to
        spapr_memory_unplug_rollback(). This is a better fit for what the
        function is now doing, and it makes callers care more about what the
        function goal is and less about spapr.c internals such as clearing
        the pending dimm unplug state.
      
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210302141019.153729-3-danielhb413@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      eb7f80fd
    • Daniel Henrique Barboza's avatar
      spapr.c: remove duplicated assert in spapr_memory_unplug_request() · 41c8ad3d
      Daniel Henrique Barboza authored
      
      We are asserting the existence of the first DRC LMB after sending unplug
      requests to all LMBs of the DIMM, where every DRC is being asserted
      inside the loop. This means that the first DRC is being asserted twice.
      
      Remove the duplicated assert.
      
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210302141019.153729-2-danielhb413@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      41c8ad3d
    • Daniel Henrique Barboza's avatar
      qemu_timer.c: add timer_deadline_ms() helper · 4515a5f7
      Daniel Henrique Barboza authored
      
      The pSeries machine is using QEMUTimer internals to return the timeout
      in seconds for a timer object, in hw/ppc/spapr.c, function
      spapr_drc_unplug_timeout_remaining_sec().
      
      Create a helper in qemu-timer.c to retrieve the deadline for a QEMUTimer
      object, in ms, to avoid exposing timer internals to the PPC code.
      
      CC: Paolo Bonzini <pbonzini@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210301124133.23800-2-danielhb413@gmail.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      4515a5f7
    • Daniel Henrique Barboza's avatar
      spapr_pci.c: add 'unplug already in progress' message for PCI unplug · e35dfbd2
      Daniel Henrique Barboza authored
      
      Hotunplug for all other devices are warning the user when the hotunplug
      is already in progress. Do the same for PCI devices in
      spapr_pci_unplug_request().
      
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210226163301.419727-5-danielhb413@gmail.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      e35dfbd2
    • Daniel Henrique Barboza's avatar
      spapr.c: add 'unplug already in progress' message for PHB unplug · 7420033e
      Daniel Henrique Barboza authored
      
      Both CPU hotunplug and PC_DIMM unplug reports an user warning,
      mentioning that the hotunplug is in progress, if consecutive
      'device_del' are issued in quick succession.
      
      Do the same for PHBs in spapr_phb_unplug_request().
      
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210226163301.419727-4-danielhb413@gmail.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      7420033e
    • Bin Meng's avatar
      hw/ppc: e500: Add missing <ranges> in the eTSEC node · e5943b00
      Bin Meng authored
      The eTSEC node should provide an empty <ranges> property in the
      eTSEC node, otherwise of_translate_address() in the Linux kernel
      fails to get the eTSEC register base, reporting:
      
        OF: ** translation for device /platform@f00000000/ethernet@0/queue-group **
        OF: bus is default (na=1, ns=1) on /platform@f00000000/ethernet@0
        OF: translating address: 00000000
        OF: parent bus is default (na=1, ns=1) on /platform@f00000000
        OF: no ranges; cannot translate
      
      Per devicetree spec v0.3 [1] chapter 2.3.8:
      
        If the property is not present in a bus node, it is assumed that
        no mapping exists between children of the node and the parent
        address space.
      
      This is why of_translate_address() aborts the address translation.
      Apparently U-Boot devicetree parser seems to be tolerant with
      missing <ranges> as this was not noticed when testing with U-Boot.
      The empty <ranges> property is present in all kernel shipped dtsi
      files for eTSEC, Let's add it to conform with the spec.
      
      [1] https://github.com/devicetree-org/devicetree-specification/releases/download/v0.3/devicetree-specification-v0.3.pdf
      
      
      
      Fixes: fdfb7f2c ("e500: Add support for eTSEC in device tree")
      Signed-off-by: default avatarBin Meng <bin.meng@windriver.com>
      Message-Id: <1614158919-9473-1-git-send-email-bmeng.cn@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      e5943b00
    • Daniel Henrique Barboza's avatar
      spapr_drc.c: use DRC reconfiguration to cleanup DIMM unplug state · fe1831ef
      Daniel Henrique Barboza authored
      
      Handling errors in memory hotunplug in the pSeries machine is more
      complex than any other device type, because there are all the
      complications that other devices has, and more.
      
      For instance, determining a timeout for a DIMM hotunplug must consider
      if it's a Hash-MMU or a Radix-MMU guest, because Hash guests takes
      longer to hotunplug DIMMs. The size of the DIMM is also a factor, given
      that longer DIMMs naturally takes longer to be hotunplugged from the
      kernel. And there's also the guest memory usage to be considered: if
      there's a process that is consuming memory that would be lost by the
      DIMM unplug, the kernel will postpone the unplug process until the
      process finishes, and then initiate the regular hotunplug process. The
      first two considerations are manageable, but the last one is a deal
      breaker.
      
      There is no sane way for the pSeries machine to determine the memory
      load in the guest when attempting a DIMM hotunplug - and even if there
      was a way, the guest can start using all the RAM in the middle of the
      unplug process and invalidate our previous assumptions - and in result
      we can't even begin to calculate a timeout for the operation. This means
      that we can't implement a viable timeout mechanism for memory unplug in
      pSeries.
      
      Going back to why we would consider an unplug timeout, the reason is
      that we can't know if the kernel is giving up the unplug. Turns out
      that, sometimes, we can. Consider a failed memory hotunplug attempt
      where the kernel will error out with the following message:
      
      'pseries-hotplug-mem: Memory indexed-count-remove failed, adding any
      removed LMBs'
      
      This happens when there is a LMB that the kernel gave up in removing,
      and the LMBs previously marked for removal are now being added back.
      This happens in the pseries kernel in [1], dlpar_memory_remove_by_ic()
      into dlpar_add_lmb(), and after that update_lmb_associativity_index().
      In this function, the kernel is configuring the LMB DRC connector again.
      Note that this is a valid usage in LOPAR, as stated in section
      "ibm,configure-connector RTAS Call":
      
      'A subsequent sequence of calls to ibm,configure-connector with the same
      entry from the “ibm,drc-indexes” or “ibm,drc-info” property will restart
      the configuration of devices which were not completely configured.'
      
      We can use this kernel behavior in our favor. If a DRC connector
      reconfiguration for a LMB that we marked as unplug pending happens, this
      indicates that the kernel changed its mind about the unplug and is
      reasserting that it will keep using all the LMBs of the DIMM. In this
      case, it's safe to assume that the whole DIMM device unplug was
      cancelled.
      
      This patch hops into rtas_ibm_configure_connector() and, in the scenario
      described above, clear the unplug state for the DIMM device. This will
      not solve all the problems we still have with memory unplug, but it will
      cover this case where the kernel reconfigures LMBs after a failed
      unplug. We are a bit more resilient, without using an unreliable
      timeout, and we didn't make the remaining error cases any worse.
      
      [1] arch/powerpc/platforms/pseries/hotplug-memory.c
      
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210222194531.62717-6-danielhb413@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      fe1831ef
    • Daniel Henrique Barboza's avatar
      spapr_drc.c: add hotunplug timeout for CPUs · d1c2e3ce
      Daniel Henrique Barboza authored
      There is a reliable way to make a CPU hotunplug fail in the pseries
      machine. Hotplug a CPU A, then offline all other CPUs inside the guest
      but A. When trying to hotunplug A the guest kernel will refuse to do it,
      because A is now the last online CPU of the guest. PAPR has no 'error
      callback' in this situation to report back to the platform, so the guest
      kernel will deny the unplug in silent and QEMU will never know what
      happened. The unplug pending state of A will remain until the guest is
      shutdown or rebooted.
      
      Previous attempts of fixing it (see [1] and [2]) were aimed at trying to
      mitigate the effects of the problem. In [1] we were trying to guess
      which guest CPUs were online to forbid hotunplug of the last online CPU
      in the QEMU layer, avoiding the scenario described above because QEMU is
      now failing in behalf of the guest. This is not robust because the last
      online CPU of the guest can change while we're in the middle of the
      unplug process, and our initial assumptions are now invalid. In [2] we
      were accepting that our unplug process is uncertain and the user should
      be allowed to spam the IRQ hotunplug queue of the guest in case the CPU
      hotunplug fails.
      
      This patch presents another alternative, using the timeout
      infrastructure introduced in the previous patch. CPU hotunplugs in the
      pSeries machine will now timeout after 15 seconds. This is a long time
      for a single CPU unplug to occur, regardless of guest load - although
      the user is *strongly* encouraged to *not* hotunplug devices from a
      guest under high load - and we can be sure that something went wrong if
      it takes longer than that for the guest to release the CPU (the same
      can't be said about memory hotunplug - more on that in the next patch).
      
      Timing out the unplug operation will reset the unplug state of the CPU
      and allow the user to try it again, regardless of the error situation
      that prevented the hotunplug to occur. Of all the not so pretty
      fixes/mitigations for CPU hotunplug errors in pSeries, timing out the
      operation is an admission that we have no control in the process, and
      must assume the worst case if the operation doesn't succeed in a
      sensible time frame.
      
      [1] https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg03353.html
      [2] https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg04400.html
      
      
      
      Reported-by: default avatarXujun Ma <xuma@redhat.com>
      Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1911414
      
      
      Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210222194531.62717-5-danielhb413@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      d1c2e3ce
    • Daniel Henrique Barboza's avatar
      spapr_drc.c: introduce unplug_timeout_timer · 51254ffb
      Daniel Henrique Barboza authored
      
      The LoPAR spec provides no way for the guest kernel to report failure of
      hotplug/hotunplug events. This wouldn't be bad if those operations were
      granted to always succeed, but that's far for the reality.
      
      What ends up happening is that, in the case of a failed hotunplug,
      regardless of whether it was a QEMU error or a guest misbehavior, the
      pSeries machine is retaining the unplug state of the device in the
      running guest.  This state is cleanup in machine reset, where it is
      assumed that this state represents a device that is pending unplug, and
      the device is hotunpluged from the board. Until the reset occurs, any
      hotunplug operation of the same device is forbid because there is a
      pending unplug state.
      
      This behavior has at least one undesirable side effect. A long standing
      pending unplug state is, more often than not, the result of a hotunplug
      error. The user had to dealt with it, since retrying to unplug the
      device is noy allowed, and then in the machine reset we're removing the
      device from the guest. This means that we're failing the user twice -
      failed to hotunplug when asked, then hotunplugged without notice.
      
      Solutions to this problem range between trying to predict when the
      hotunplug will fail and forbid the operation from the QEMU layer, from
      opening up the IRQ queue to allow for multiple hotunplug attempts, from
      telling the users to 'reboot the machine if something goes wrong'. The
      first solution is flawed because we can't fully predict guest behavior
      from QEMU, the second solution is a trial and error remediation that
      counts on a hope that the unplug will eventually succeed, and the third
      is ... well.
      
      This patch introduces a crude, but effective solution to hotunplug
      errors in the pSeries machine. For each unplug done, we'll timeout after
      some time. If a certain amount of time passes, we'll cleanup the
      hotunplug state from the machine.  During the timeout period, any unplug
      operations in the same device will still be blocked. After that, we'll
      assume that the guest failed the operation, and allow the user to try
      again. If the timeout is too short we'll prevent legitimate hotunplug
      situations to occur, so we'll need to overestimate the regular time an
      unplug operation takes to succeed to account that.
      
      The true solution for the hotunplug errors in the pSeries machines is a
      PAPR change to allow for the guest to warn the platform about it. For
      now, the work done in this timeout design can be used for the new PAPR
      'abort hcall' in the future, given that for both cases we'll need code
      to cleanup the existing unplug states of the DRCs.
      
      At this moment we're adding the basic wiring of the timer into the DRC.
      Next patch will use the timer to timeout failed CPU hotunplugs.
      
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210222194531.62717-4-danielhb413@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      51254ffb
    • Daniel Henrique Barboza's avatar
      spapr: rename spapr_drc_detach() to spapr_drc_unplug_request() · a03509cd
      Daniel Henrique Barboza authored
      
      spapr_drc_detach() is not the best name for what the function does. The
      function does not detach the DRC, it makes an uncommited attempt to do
      it.  It'll mark the DRC as pending unplug, via the 'unplug_request'
      flag, and only if the DRC state is drck->empty_state it will detach the
      DRC, via spapr_drc_release().
      
      This is a contrast with its pair spapr_drc_attach(), where the function
      is indeed creating the DRC QOM object. If you know what
      spapr_drc_attach() does, you can be misled into thinking that
      spapr_drc_detach() is removing the DRC from QEMU internal state, which
      isn't true.
      
      The current role of this function is better described as a request for
      detach, since there's no guarantee that we're going to detach the DRC in
      the end.  Rename the function to spapr_drc_unplug_request to reflect
      what is is doing.
      
      The initial idea was to change the name to spapr_drc_detach_request(),
      and later on change the unplug_request flag to detach_request. However,
      unplug_request is a migratable boolean for a long time now and renaming
      it is not worth the trouble. spapr_drc_unplug_request() setting
      drc->unplug_request is more natural than spapr_drc_detach_request
      setting drc->unplug_request.
      
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210222194531.62717-3-danielhb413@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      a03509cd
    • Daniel Henrique Barboza's avatar
      spapr_drc.c: use spapr_drc_release() in isolate_physical/set_unusable · 66d10d32
      Daniel Henrique Barboza authored
      
      When moving a physical DRC to "Available", drc_isolate_physical() will
      move the DRC state to STATE_PHYSICAL_POWERON and, if the DRC is marked
      for unplug, call spapr_drc_detach(). For physical DRCs,
      drck->empty_state is STATE_PHYSICAL_POWERON, meaning that we're sure
      that spapr_drc_detach() will end up calling spapr_drc_release() in the
      end.
      
      Likewise, for logical DRCs, drc_set_unusable will move the DRC to
      "Unusable" state, setting drc->state to STATE_LOGICAL_UNUSABLE, which is
      the drck->empty_state for logical DRCs. spapr_drc_detach() will call
      spapr_drc_release() in this case as well.
      
      In both scenarios, spapr_drc_detach() is being used as a
      spapr_drc_release(), wrapper, where we also set unplug_requested (which
      is already true, otherwise spapr_drc_detach() wouldn't be called in the
      first place) and check if drc->state == drck->empty_state, which we also
      know it's guaranteed to be true because we just set it.
      
      Just use spapr_drc_release() in these functions to be clear of our
      intentions in both these functions.
      
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210222194531.62717-2-danielhb413@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      66d10d32
    • Daniel Henrique Barboza's avatar
      spapr_drc.c: do not call spapr_drc_detach() in drc_isolate_logical() · 382907b1
      Daniel Henrique Barboza authored
      
      drc_isolate_logical() is used to move the DRC from the "Configured" to
      the "Available" state, erroring out if the DRC is in the unexpected
      "Unisolate" state and doing nothing (with RTAS_OUT_SUCCESS) if the DRC
      is already in "Available" or in "Unusable" state.
      
      When moving from "Configured" to "Available", the DRC is moved to the
      LOGICAL_AVAILABLE state, a drc->unplug_requested check is done and, if
      true, spapr_drc_detach() is called.
      
      What spapr_drc_detach() does then is:
      
      - set drc->unplug_requested to true. In fact, this is the only place
      where unplug_request is set to true;
      - does nothing else if drc->state != drck->empty_state. If the DRC
      state is equal to drck->empty_state, spapr_drc_release() is
      called. For logical DRCs, drck->empty_state = LOGICAL_UNUSABLE.
      
      In short, calling spapr_drc_detach() in drc_isolate_logical() does
      nothing. It'll set unplug_request to true again ('again' since it was
      already true - otherwise the function wouldn't be called), and will
      return without calling spapr_drc_release() because the DRC is not in
      LOGICAL_UNUSABLE, since drc_isolate_logical() just moved it to
      LOGICAL_AVAILABLE. The only place where the logical DRC is released is
      when called from drc_set_unusable(), when it is moved to the
      "Unusable" state.  As it should, according to PAPR.
      
      Even though calling spapr_drc_detach() in drc_isolate_logical() is
      benign, removing it will avoid further thought about the matter. So
      let's go ahead and do that.
      
      As a note, this logic was introduced in commit bbf5c878. Since
      then, the DRC handling code was refactored and enhanced, and PAPR
      itself went through some changes in the DRC area as well. It is
      expected that some assumptions we had back then are now deprecated.
      
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Message-Id: <20210211225246.17315-2-danielhb413@gmail.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      382907b1
    • Philippe Mathieu-Daudé's avatar
      exec/memory: Use struct Object typedef · d32335e8
      Philippe Mathieu-Daudé authored
      
      We forward-declare Object typedef in "qemu/typedefs.h" since commit
      ca27b5eb ("qom/object: Move Object typedef to 'qemu/typedefs.h'").
      Use it everywhere to make the code simpler.
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Acked-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20210225182003.3629342-1-philmd@redhat.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      d32335e8
Loading