Re: Write to srvio_numvfs triggers kernel panic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 09, 2022 at 11:39:30PM -0700, Christoph Hellwig wrote:
> On Mon, May 09, 2022 at 10:58:57AM -0600, Alex Williamson wrote:
> > is_physfn = 0, is_virtfn = 0: A non-SR-IOV function
> > is_physfn = 1, is_virtfn = 0: An SR-IOV PF
> > is_physfn = 0, is_virtfn = 1: An SR-IOV VF
> > 
> > As implemented with bit fields this is 2 bits, which is more space
> > efficient than an enum.  Thanks,
> 
> A two-bit bitfield with explicit constants for the values would probably
> still much eaiser to understand.
> 
> And there is some code that seems to intepret is_physfn a bit odd, e.g.:
> 
> arch/powerpc/kernel/eeh_sysfs.c:        np = pci_device_to_OF_node(pdev->is_physfn ? pdev : pdev->physfn);
> arch/powerpc/kernel/eeh_sysfs.c:        np = pci_device_to_OF_node(pdev->is_physfn ? pdev : pdev->physfn);

"dev->sriov != NULL" and "dev->is_physfn" are basically the same and
many of the dev->is_physfn uses in drivers/pci would end up being
simpler if replaced with dev->sriov, e.g.,

  int pci_iov_virtfn_bus(struct pci_dev *dev, int vf_id)
  {
    if (!dev->is_physfn)
      return -EINVAL;
    return dev->bus->number + ((dev->devfn + dev->sriov->offset +
				dev->sriov->stride * vf_id) >> 8);
  }

would be more obvious as:

  if (dev->sriov)
    return dev->bus->number + ((dev->devfn + dev->sriov->offset +
				dev->sriov->stride * vf_id) >> 8);
  return -EINVAL;



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux