Re: [PATCH kvm-unit-tests v2 08/17] pci: provide pci_scan_bars()

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

 



On Thu, Nov 10, 2016 at 08:24:19PM +0100, Andrew Jones wrote:

[...]

> > +void pci_scan_bars(struct pci_dev *dev)
> > +{
> > +	int i = 0;
> > +
> > +	for (i = 0; i < PCI_BAR_NUM; i++) {
> > +		if (!pci_bar_is_valid(dev, i))
> > +			continue;
> > +		dev->bar[i] = pci_bar_get_addr(dev, i);
> 
> What happens when you get_addr a 64-bit bar in the middle?
> Shouldn't we skip that?

Hmm yes... Do you like this?

---------8<----------

diff --git a/lib/pci.c b/lib/pci.c
index 0593699..2a58b30 100644
--- a/lib/pci.c
+++ b/lib/pci.c
@@ -230,11 +230,15 @@ void pci_print(void)

 void pci_scan_bars(struct pci_dev *dev)
 {
-       int i = 0;
+       int i;
+
+       memset(&dev->bar[0], 0, sizeof(dev->bar));

        for (i = 0; i < PCI_BAR_NUM; i++) {
                if (!pci_bar_is_valid(dev, i))
                        continue;
                dev->bar[i] = pci_bar_get_addr(dev, i);
+               if (pci_bar_is64(dev, i))
+                       i++;
        }
 }

--------->8----------

pci_bar_is64() is called twice per bar, but I think it's okay here
since it's during init and the whole scan is called only once for 6
bars.

Thanks,

-- peterx
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux