Re: [kvm-unit-tests PATCH v7 06/13] pci: Rework pci_bar_addr()

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

 



On Fri, Sep 23, 2016 at 03:14:04PM +0800, Peter Xu wrote:
> > -unsigned long pci_bar_addr(pcidevaddr_t dev, int bar_num)
> > +phys_addr_t pci_bar_addr(pcidevaddr_t dev, int bar_num)
> >  {
> >  	uint32_t bar = pci_bar_get(dev, bar_num);
> > +	uint32_t mask = pci_bar_mask(bar);
> > +	uint64_t addr = bar & mask;
> >  
> > -	if (bar & PCI_BASE_ADDRESS_SPACE_IO)
> > -		return bar & PCI_BASE_ADDRESS_IO_MASK;
> > -	else
> > -		return bar & PCI_BASE_ADDRESS_MEM_MASK;
> > +	if (pci_bar_is64(dev, bar_num))
> > +		addr |= (uint64_t)pci_bar_get(dev, bar_num + 1) << 32;
> > +
> > +	return pci_translate_addr(dev, addr);
> 
> Raw question: do we need to translate bar addresses as well?

I believe, yes.

Unless we always have identity mapping between PCI address space and
CPU physical address space I can not realize how could it be done
otherwise. But even if we were, I would leave the translation routine
for clarity.

> [...]
> 
> > +static inline
> > +phys_addr_t pci_translate_addr(pcidevaddr_t dev __unused, uint64_t addr)
> > +{
> > +    return addr;
> > +}
> > +
> 
> We are not using dev here (and in following patches), I don't know
> ARM, but at least x86 will need this to translate IOVA into PA (in
> other words, each device can have its own IO address space). If this
> codes are for common, shall we consider that as well?

Could this function be extended or the prototype blocks the proper
implementation? (I guess, I will get the answer once I look into your
works).

> 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