Re: [PATCH v4 02/11] PCI: liveupdate: Track outgoing preserved PCI devices

David Matlack
2026-04-30T20:36:46Z

On 2026-04-30 11:25 AM, Vipin Sharma wrote:
> On Tue, Apr 28, 2026 at 02:12:13PM -0700, David Matlack wrote:
> > On Tue, Apr 28, 2026 at 1:20 PM Vipin Sharma <vipinsh@google.com> wrote:
> > >
> > > On Thu, Apr 23, 2026 at 09:23:06PM +0000, David Matlack wrote:
> > > > +int pci_liveupdate_preserve(struct pci_dev *dev)
> > > > +{

> > > > + if (ser->nr_devices == ser->max_nr_devices)
> > > > + return -ENOSPC;
> > > > +
> > > > + for (i = 0; i < ser->max_nr_devices; i++) {
> > > > + /*
> > > > + * Start searching at index ser->nr_devices. This should result
> > > > + * in a constant time search under expected conditions (devices
> > > > + * are not getting unpreserved).
> > > > + */
> > > > + int index = (ser->nr_devices + i) % ser->max_nr_devices;
> > > > + struct pci_dev_ser *dev_ser = &ser->devices[index];
> > > > +
> > > > + if (dev_ser->refcount)
> > > > + continue;
> > > > +
> > > > + pci_info(dev, "Device will be preserved across next Live Update\n");
> > > > + ser->nr_devices++;
> > > > +
> > > > + dev_ser->domain = pci_domain_nr(dev->bus);
> > > > + dev_ser->bdf = pci_dev_id(dev);
> > > > + dev_ser->refcount = 1;
> > > > +
> > > > + dev->liveupdate_outgoing = dev_ser;
> > > > + return 0;
> > > > + }
> > > > +
> > > > + return -ENOSPC;
> > >
> > > Since it is executing under a mutex, and we already failed
> > > 'if (ser->nr_devices == ser->max_nr_devices) check above, will we ever reach
> > > here and return -ENOSPC?
> >
> > Yeah I wouldn't expect to ever reach here.
>
> Will you be removing it or want to keep it just in case scenario?

I'm not sure how I would remove it. The code doesn't not compile without
a return.