Quoting Bharata B Rao (2015-02-27 03:52:09) > On Fri, Feb 27, 2015 at 8:41 AM, Michael Roth <mdr...@linux.vnet.ibm.com> > wrote: > > +static void attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt, > > + int fdt_start_offset, bool coldplug, Error **errp) > > +{ > > + DPRINTFN("drc: %x, attach", get_index(drc)); > > + > > + if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) { > > + error_setg(errp, "an attached device is still awaiting release"); > > + return; > > + } > > + g_assert(drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE); > > + g_assert(fdt || coldplug); > > + > > + /* NOTE: setting initial isolation state to UNISOLATED means we can't > > + * detach unless guest has a userspace/kernel that moves this state > > + * back to ISOLATED in response to an unplug event, or this is done > > + * manually by the admin prior. if we force things while the guest > > + * may be accessing the device, we can easily crash the guest, so we > > + * we defer completion of removal in such cases to the reset() hook. > > + */ > > + drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED; > > + drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE; > > BTW shouldn't isolation_state and allocation_state be set to > UNISOLATED and USABLE in response to guest's rtas-set-indicator calls > ? At least, that is how it is done/expected for CPU hotplug case. Ref:
Well, for PCI we always start in USABLE (state diagram in PAPR+ 13.4), and stay there. So set_allocation_state() should actually be a no-op for PCI; there's no valid transition to UNUSABLE (or EXCHANGE/RECOVER). For non-PCI, it looks like we should start in UNUSABLE, and let RTAS take it from there. It also looks like the resource removal shouldn't be finalized until there's a transition from ISOLATED/USABLE to ISOLATED/UNUSABLE. I just pushed a patch here that I'm hoping will fix the non-PCI cases. Can you give it a spin and let me know? https://github.com/mdroth/qemu/commit/d91b0c6d6f794292e384cf129368aaae90294f5b > kernel code arch/powerpc/platforms/pseries/dlpar.c: > dlpar_acquire[release]_drc(). > > Same question for detach(). > > Regards, > Bharata.