[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [XEN PATCH v10 1/5] xen/vpci: Clear all vpci status of device
On 19.06.2024 05:39, Chen, Jiqian wrote: > On 2024/6/18 16:33, Jan Beulich wrote: >> On 18.06.2024 08:25, Chen, Jiqian wrote: >>> On 2024/6/17 22:17, Jan Beulich wrote: >>>> On 17.06.2024 11:00, Jiqian Chen wrote: >>>>> --- a/xen/drivers/pci/physdev.c >>>>> +++ b/xen/drivers/pci/physdev.c >>>>> @@ -2,11 +2,17 @@ >>>>> #include <xen/guest_access.h> >>>>> #include <xen/hypercall.h> >>>>> #include <xen/init.h> >>>>> +#include <xen/vpci.h> >>>>> >>>>> #ifndef COMPAT >>>>> typedef long ret_t; >>>>> #endif >>>>> >>>>> +static const struct pci_device_state_reset_method >>>>> + pci_device_state_reset_methods[] = { >>>>> + [ DEVICE_RESET_FLR ].reset_fn = vpci_reset_device_state, >>>>> +}; >>>> >>>> What about the other three DEVICE_RESET_*? In particular ... >>> I don't know how to implement the other three types of reset. >>> This is a design form so that corresponding processing functions can be >>> added later if necessary. Do I need to set them to NULL pointers in this >>> array? >> >> No. >> >>> Does this form conform to your previous suggestion of using only one >>> hypercall to handle all types of resets? >> >> Yes, at least in principle. Question here is: To be on the safe side, >> wouldn't we better reset state for all forms of reset, leaving possible >> relaxation of that for later? At which point the function wouldn't need >> calling indirectly, and instead would be passed the reset type as an >> argument. > If I understood correctly, next version should be? > Use macros to represent different reset types. > Add switch cases in PHYSDEVOP_pci_device_state_reset to handle different > reset functions. > Add reset_type as a function parameter to vpci_reset_device_state for > possible future use. > > + case PHYSDEVOP_pci_device_state_reset: > + { > + struct pci_device_state_reset dev_reset; > + struct pci_dev *pdev; > + pci_sbdf_t sbdf; > + > + if ( !is_pci_passthrough_enabled() ) > + return -EOPNOTSUPP; > + > + ret = -EFAULT; > + if ( copy_from_guest(&dev_reset, arg, 1) != 0 ) > + break; > + > + sbdf = PCI_SBDF(dev_reset.dev.seg, > + dev_reset.dev.bus, > + dev_reset.dev.evfn); > + > + ret = xsm_resource_setup_pci(XSM_PRIV, sbdf.sbdf); > + if ( ret ) > + break; > + > + pcidevs_lock(); > + pdev = pci_get_pdev(NULL, sbdf); > + if ( !pdev ) > + { > + pcidevs_unlock(); > + ret = -ENODEV; > + break; > + } > + > + write_lock(&pdev->domain->pci_lock); > + pcidevs_unlock(); > + /* Implement FLR, other reset types may be implemented in future */ > + switch ( dev_reset.reset_type ) > + { > + case PCI_DEVICE_STATE_RESET_COLD: > + case PCI_DEVICE_STATE_RESET_WARM: > + case PCI_DEVICE_STATE_RESET_HOT: > + case PCI_DEVICE_STATE_RESET_FLR: > + ret = vpci_reset_device_state(pdev, dev_reset.reset_type); > + break; > + } If you use a switch() here, then there wants to be a default case returning e.g. -EOPNOTSUPP or -EINVAL. Else the switch wants dropping. I'm not sure which one's better in this specific case, I'm only slightly tending towards the former. In any event the comment (if any) wants to reflect what the actual code does. Jan
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |