From: Alexander Gordeev <agordeev@redhat.com>
To: Andrew Jones <drjones@redhat.com>
Cc: kvm@vger.kernel.org, Thomas Huth <thuth@redhat.com>,
Peter Xu <peterx@redhat.com>
Subject: Re: [kvm-unit-tests PATCH v9 10/12] pci: Add generic ECAM host support
Date: Sat, 5 Nov 2016 10:56:26 +0100 [thread overview]
Message-ID: <20161105095625.GA10472@agordeev.lab.eng.brq.redhat.com> (raw)
In-Reply-To: <20161104143352.gakhitj32hoojsfh@kamzik.brq.redhat.com>
On Fri, Nov 04, 2016 at 03:33:52PM +0100, Andrew Jones wrote:
> > +bool pci_probe(void)
> > +{
> > + pcidevaddr_t dev;
> > + u8 header;
> > + u32 cmd;
> > + int i;
> > +
> > + assert(!pci_host_bridge);
> > + pci_host_bridge = pci_dt_probe();
> > + if (!pci_host_bridge)
> > + return false;
> > +
> > + for (dev = 0; dev < 256; dev++) {
> > + if (!pci_dev_exists(dev))
> > + continue;
> > +
> > + /* We are only interested in normal PCI devices */
> > + header = pci_config_readb(dev, PCI_HEADER_TYPE);
> > + if ((header & PCI_HEADER_TYPE_MASK) != PCI_HEADER_TYPE_NORMAL)
> > + continue;
> > +
> > + cmd = PCI_COMMAND_SERR;
> > +
> > + for (i = 0; i < 6; i++) {
> > + u64 addr;
> > +
> > + if (pci_alloc_resource(dev, i, &addr)) {
> > + pci_bar_set_addr(dev, i, addr);
> > +
> > + if (pci_bar_is_memory(dev, i))
> > + cmd |= PCI_COMMAND_MEMORY;
> > + else
> > + cmd |= PCI_COMMAND_IO;
> > + }
> > +
> > + if (pci_bar_is64(dev, i))
> > + i++;
> > + }
> > +
> > + pci_config_writel(dev, PCI_COMMAND, cmd);
>
> As I asked in the last review, is this PCI_COMMAND_SERR safe/desired
> to write, even when no resources are allocated? If not, then above
Yes, it allows a device to report grave PCI bus errors. Moreover,
I think I should have enabled parity errors check as well.
I assume we want to notice such errors, including the case no
resources were assigned. That would be more troubling even.
In Linux it is up to device drivers to enable these, but I
would just let all devices scream loudly by default.
> we need to capture the return value of pci_alloc_resource, add
> an 'else break', and then check the return value here before doing
> the write.
>
> > + }
> > +
> > + return true;
> > +}
> Thanks,
> drew
next prev parent reply other threads:[~2016-11-05 9:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-03 16:19 [kvm-unit-tests PATCH v9 00/12] PCI bus support Alexander Gordeev
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 01/12] pci: Fix coding style in generic PCI files Alexander Gordeev
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 02/12] pci: x86: Rename pci_config_read() to pci_config_readl() Alexander Gordeev
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 03/12] pci: Add 'extern' to public function declarations Alexander Gordeev
2016-11-03 20:30 ` Christoph Hellwig
2016-11-04 7:36 ` Thomas Huth
2016-11-04 8:18 ` Andrew Jones
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 04/12] pci: x86: Add remaining PCI configuration space accessors Alexander Gordeev
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 05/12] pci: Factor out pci_bar_get() Alexander Gordeev
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 06/12] pci: Rework pci_bar_addr() Alexander Gordeev
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 07/12] pci: Add pci_bar_set_addr() Alexander Gordeev
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 08/12] pci: Add pci_dev_exists() Alexander Gordeev
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 09/12] pci: Add pci_print() Alexander Gordeev
2016-11-04 14:25 ` Andrew Jones
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 10/12] pci: Add generic ECAM host support Alexander Gordeev
2016-11-04 14:33 ` Andrew Jones
2016-11-04 17:07 ` Andrew Jones
2016-11-05 17:25 ` Alexander Gordeev
2016-11-07 8:44 ` Andrew Jones
2016-11-07 15:43 ` Peter Xu
2016-11-05 9:56 ` Alexander Gordeev [this message]
2016-11-05 17:20 ` [kvm-unit-tests PATCH v10 " Alexander Gordeev
2016-11-07 8:03 ` Alexander Gordeev
2016-11-07 7:56 ` Alexander Gordeev
2016-11-07 8:52 ` Andrew Jones
2016-11-07 9:32 ` Andrew Jones
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 11/12] pci: Add pci-testdev PCI bus test device Alexander Gordeev
2016-11-03 16:19 ` [kvm-unit-tests PATCH v9 12/12] arm/arm64: pci: Add pci-testdev PCI device operation test Alexander Gordeev
2016-11-04 15:44 ` [kvm-unit-tests PATCH v9 00/12] PCI bus support Andrew Jones
2016-11-05 17:30 ` 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=20161105095625.GA10472@agordeev.lab.eng.brq.redhat.com \
--to=agordeev@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=peterx@redhat.com \
--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).