kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Alexander Gordeev <agordeev@redhat.com>
Cc: kvm@vger.kernel.org, Thomas Huth <thuth@redhat.com>,
	Andrew Jones <drjones@redhat.com>
Subject: Re: [kvm-unit-tests PATCH v7 06/13] pci: Rework pci_bar_addr()
Date: Wed, 19 Oct 2016 11:46:41 +0800	[thread overview]
Message-ID: <20161019034641.GA15168@pxdev.xzpeter.org> (raw)
In-Reply-To: <20161014123725.GA8396@agordeev.lab.eng.brq.redhat.com>

On Fri, Oct 14, 2016 at 02:37:25PM +0200, Alexander Gordeev wrote:

[...]

> So pci-host-generic.c is "BIOS or something" in this context. There is
> no contradiction with the your excerpt. Please note "Figure 1-2: PCI
> System Block Diagram" in the spec. The CPU and PCI busses are two
> physically different busses interconnected by a bridge.
> 
> A CPU data access to PCI devices initiates data access on a PCI bus,
> but adresses seen by the CPU and PCI devices do not necessarily match.
> 
> So in case of x86 they do (lib/x86/asm/pci.h):
> 
> static inline
> phys_addr_t pci_translate_addr(pcidevaddr_t dev __unused, uint64_t addr)
> {
> 	return addr;
> }
> 
> But in case of ARM they might not (lib/asm-generic/pci-host-bridge.h):
> 
> static inline
> phys_addr_t pci_translate_addr(pcidevaddr_t dev __unused, uint64_t addr)
> {
> 	/*
> 	 * Assume we only have single PCI host bridge in a system.
> 	 */
> 	return pci_host_bridge_get_paddr(addr);
> }
> 
> > If you see PCI Local Bus Spec Rev 3.0, chap 6.2.5.1:
> > 
> >     Power-up software needs to build a consistent address map before
> >     booting the machine to an operating system. This means it has to
> >     determine how much memory is in the system, and how much address
> >     space the I/O controllers in the system require. After determining
> >     this information, power-up software can map the I/O controllers
> >     into reasonable locations and proceed with system boot. In order
> >     to do this mapping in a device independent manner, the base
> >     registers for this mapping are placed in the predefined header
> >     portion of Configuration Space.
> > 
> > BARs for each PCI devices should be pre-allocated during power-up
> > software, and a consistent map is built with the knowledge of existing
> > RAM in the system.
> 
> Yep, see how pci_probe() / pci_alloc_resource() allocate and assign
> BARs to each device. It is the case for PPC/ARM but in case of x86
> it is BIOS who does it.
> 
> > If you boot a VM with/without IOMMU, you'll see that BAR addresses
> > won't change before/after enabling IOMMU.
> 
> BAR addresses are in PCI bus address space. It sounds quite logical.
> (I am not experienced with IOMMU address translation, though).

Thank you for the thorough explanation. I am still not sure I fully
understand the whole thing, but looks like the translation here is not
the same as x86 IOMMU address translations, and x86 is special in this
case (BAR addresses should be the same as physical addresses in x86,
while not for ARM/PPC).

I am sorry for the noise. Looking forward to your next version. Thanks!

-- peterx

  reply	other threads:[~2016-10-19  3:46 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-17 12:07 [kvm-unit-tests PATCH v7 00/13] PCI bus support Alexander Gordeev
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 01/13] pci: Fix coding style in generic PCI files Alexander Gordeev
2016-08-18 11:37   ` Thomas Huth
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 02/13] pci: x86: Rename pci_config_read() to pci_config_readl() Alexander Gordeev
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 03/13] pci: Add 'extern' to public function declarations Alexander Gordeev
2016-08-17 13:49   ` Andrew Jones
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 04/13] pci: x86: Add remaining PCI configuration space accessors Alexander Gordeev
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 05/13] pci: Factor out pci_bar_get() Alexander Gordeev
2016-08-18 11:39   ` Thomas Huth
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 06/13] pci: Rework pci_bar_addr() Alexander Gordeev
2016-09-23  7:14   ` Peter Xu
2016-09-23  8:51     ` Andrew Jones
2016-09-23  8:58       ` Peter Xu
2016-10-12 14:37     ` Alexander Gordeev
2016-10-13  6:40       ` Peter Xu
2016-10-13 14:16         ` Alexander Gordeev
2016-10-14  6:23           ` Peter Xu
2016-10-14  6:55             ` Andrew Jones
2016-10-14  9:09               ` Peter Xu
2016-10-14 12:37             ` Alexander Gordeev
2016-10-19  3:46               ` Peter Xu [this message]
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 07/13] pci: Add pci_bar_set_addr() Alexander Gordeev
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 08/13] pci: Add pci_dev_exists() Alexander Gordeev
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 09/13] pci: Add pci_print() Alexander Gordeev
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 10/13] pci: Add generic ECAM host support Alexander Gordeev
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 11/13] arm/arm64: pci: Add PCI bus operation test Alexander Gordeev
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 12/13] pci: Add pci-testdev PCI bus test device Alexander Gordeev
2016-08-17 14:03   ` Andrew Jones
2016-09-23  7:25   ` Peter Xu
2016-09-23  8:55     ` Andrew Jones
2016-10-12 16:54     ` Alexander Gordeev
2016-10-13  6:52       ` Peter Xu
2016-10-13 13:16         ` Alexander Gordeev
2016-10-14  5:01           ` Peter Xu
2016-10-14  7:07             ` Andrew Jones
2016-10-14  9:14               ` Peter Xu
2016-08-17 12:07 ` [kvm-unit-tests PATCH v7 13/13] arm/arm64: pci: Add pci-testdev PCI device operation test Alexander Gordeev
2016-08-17 14:26 ` [kvm-unit-tests PATCH v7 00/13] PCI bus support Andrew Jones
2016-08-23 18:28   ` Alexander Gordeev
2016-09-22 11:10     ` Andrew Jones
2016-09-28  6:33       ` Peter Xu
2016-10-12  8:00         ` Alexander Gordeev
2016-10-12 10:59           ` Peter Xu
2016-10-12 14:35       ` Alexander Gordeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161019034641.GA15168@pxdev.xzpeter.org \
    --to=peterx@redhat.com \
    --cc=agordeev@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).