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 18:25:44 +0100 [thread overview]
Message-ID: <20161105172543.GC10472@agordeev.lab.eng.brq.redhat.com> (raw)
In-Reply-To: <20161104170741.4wpcvde6eq7uqcyk@kamzik.brq.redhat.com>
On Fri, Nov 04, 2016 at 06:07:41PM +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
> > 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.
>
> Another note on this PCI_COMMAND write. Why is it safe [correct?] to
> use writel? This is a 16-bit register according to the comment in
> lib/linux/pci_regs.h. Don't we need to introduce a pci_config_writew
> and use that? If so, then you should grab Peter Xu's patch that
> introduces pci_config_writeb/w.
You are right, this is cleanly a bug.
However, I can not put Peter's patch neither before nor after mine,
since pci_config_write*() are both introduced and used in this patch.
As Peter's patch needs a refreshment anyway (see my comment on it)
I will add pci_config_writew() to this patch. Hope, that works for
everyone.
> >
> > > + }
> > > +
> > > + return true;
> > > +}
> > Thanks,
> > drew
next prev parent reply other threads:[~2016-11-05 17:17 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 [this message]
2016-11-07 8:44 ` Andrew Jones
2016-11-07 15:43 ` Peter Xu
2016-11-05 9:56 ` Alexander Gordeev
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=20161105172543.GC10472@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).