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 v3 3/6] pci: Accomodate 64 bit BARs in pci_dev::resource[]
Date: Tue, 28 Feb 2017 15:02:25 +0800 [thread overview]
Message-ID: <20170228070225.GK10022@pxdev.xzpeter.org> (raw)
In-Reply-To: <dafbe2f41f0db41ec09bcc4c35ae873892ced877.1488204259.git.agordeev@redhat.com>
On Mon, Feb 27, 2017 at 03:12:34PM +0100, Alexander Gordeev wrote:
> Array pci_dev::resource[] is ambiguous wrt what is
> actually stored in its elements and how to interpret
> the index into the array.
>
> It is simple in case a device has only 32-bit BARs -
> an element pci_dev::resource[bar_num] contains the
> decoded address of BAR # bar_num.
>
> But what if a device has 64-bit BAR starting at bar_num?
>
> Curretnly pci_dev::resource[bar_num] contains the decoded
> address of the BAR, while pci_dev::resource[bar_num + 1]
> contains 0. That makes meaning of (bar_num + 1) index
> difficult to understand.
>
> On the one hand it is an index of high 32-bit part of
> the 64-bit address in the device itself. But why then
> the element contains 0, not the high part of the address
> or INVALID_PHYS_ADDRESS for example?
>
> By placing the same 64-bit address in both bar_num and
> (bar_num + 1) elements the ambiguity is less striking,
> since:
> - the meaning of bar_num kept consistent with the rest
> of the functions (where it refers 32-bit BAR in terms
> of the device configuration address space);
> - pci_dev::resource[bar_num + 1] contains a valid address
> rather than vague value of 0.
> - both bar_num and (bar_num + 1) indexes refer to the
> same 64-bit BAR and therefore return the same address;
> The notion of low and high parts of a 64-bit address
> is ignored, but that is fine, since pci_dev::resource[]
> contain only full addresses;
IIUC for a general PCI device driver, it should know which bars are
used for specific device, the type of the bar (whether it would be
64bit), for what purpose, etc.. Then, the driver should just avoid
touching the other bar (in our case, bar_num+1). So here I don't quite
catch why we need to explicitly have res[bar_num+1] contain the same
content as res[bar_num]. Do we really have a use case?
And, looks like this patch has just overwritten previous patch (patch
2). IMHO I would slightly prefer that one since INVALID_PHYS_ADDR at
least showed that we fetched something wrong.
Thanks,
-- peterx
next prev parent reply other threads:[~2017-02-28 7:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-27 14:12 [kvm-unit-tests PATCH v3 0/6] pci: Complete conversion of PCI API to struct pci_dev Alexander Gordeev
2017-02-27 14:12 ` [kvm-unit-tests PATCH v3 1/6] pci: pci-host-generic: Use INVALID_PHYS_ADDR instead of ~0 Alexander Gordeev
2017-02-27 14:12 ` [kvm-unit-tests PATCH v3 2/6] pci: Do not use 0 for unimplemented BARs in pci_dev::resource[] Alexander Gordeev
2017-02-27 14:12 ` [kvm-unit-tests PATCH v3 3/6] pci: Accomodate 64 bit " Alexander Gordeev
2017-02-28 7:02 ` Peter Xu [this message]
2017-02-28 9:02 ` Andrew Jones
2017-02-28 9:31 ` Peter Xu
2017-02-28 9:48 ` Andrew Jones
2017-02-28 9:51 ` Alexander Gordeev
2017-02-28 9:55 ` Peter Xu
2017-02-28 10:22 ` Alexander Gordeev
2017-02-28 10:40 ` Peter Xu
2017-02-28 10:41 ` Peter Xu
2017-02-28 11:11 ` Alexander Gordeev
2017-02-28 11:56 ` Andrew Jones
2017-02-27 14:12 ` [kvm-unit-tests PATCH v3 4/6] pci: Turn struct pci_dev into device handle for PCI functions Alexander Gordeev
2017-02-27 18:35 ` Andrew Jones
2017-02-27 14:12 ` [kvm-unit-tests PATCH v3 5/6] pci: Rework pci_bar_is_valid() Alexander Gordeev
2017-02-27 14:12 ` [kvm-unit-tests PATCH v3 6/6] pci: Make PCI API consistent wrt using struct pci_dev Alexander Gordeev
2017-02-27 18:37 ` [kvm-unit-tests PATCH v3 0/6] pci: Complete conversion of PCI API to " Andrew Jones
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=20170228070225.GK10022@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.