Re: [PATCH v10 4/7] PCI: add SR-IOV API for Physical Function driver

Greg KH
2009-03-07T02:40:06Z

On Fri, Mar 06, 2009 at 01:37:18PM -0700, Matthew Wilcox wrote:
> On Fri, Feb 20, 2009 at 02:54:45PM +0800, Yu Zhao wrote:
> > + virtfn->sysdata = dev->bus->sysdata;
> > + virtfn->dev.parent = dev->dev.parent;
> > + virtfn->dev.bus = dev->dev.bus;
> > + virtfn->devfn = devfn;
> > + virtfn->hdr_type = PCI_HEADER_TYPE_NORMAL;
> > + virtfn->cfg_size = PCI_CFG_SPACE_EXP_SIZE;
> > + virtfn->error_state = pci_channel_io_normal;
> > + virtfn->current_state = PCI_UNKNOWN;
> > + virtfn->is_pcie = 1;
> > + virtfn->pcie_type = PCI_EXP_TYPE_ENDPOINT;
> > + virtfn->dma_mask = 0xffffffff;
> > + virtfn->vendor = dev->vendor;
> > + virtfn->subsystem_vendor = dev->subsystem_vendor;
> > + virtfn->class = dev->class;
>
> There seems to be a certain amount of commonality between this and
> pci_scan_device(). Have you considered trying to make a common helper
> function, or does it not work out well?
>
> > + pci_device_add(virtfn, virtfn->bus);
>
> Greg is probably going to ding you here for adding the device, then
> creating the symlinks. I believe it's now best practice to create the
> symlinks first, so there's no window where userspace can get confused.

If the uevent gets sent before the symlinks are created, it's a bug.

thanks,

greg k-h