From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Hervé Poussineau" <hpoussin@reactos.org>
Cc: "Isaku Yamahata" <yamahata@valinux.co.jp>,
"Andreas Färber" <andreas.faerber@web.de>,
"qemu-devel Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH, RFC] pci: allow PCI devices to fix address space
Date: Sun, 12 Jun 2011 22:59:46 +0300 [thread overview]
Message-ID: <20110612195946.GB20615@redhat.com> (raw)
In-Reply-To: <4DF51895.4030302@reactos.org>
On Sun, Jun 12, 2011 at 09:50:45PM +0200, Hervé Poussineau wrote:
> Michael S. Tsirkin a écrit :
> >On Sun, Jun 12, 2011 at 02:40:35PM +0200, Hervé Poussineau wrote:
> >>Andreas,
> >>
> >>Andreas Färber a écrit :
> >>>Hervé,
> >>>
> >>>Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
> >>>
> >>>>On Wed, Dec 22, 2010 at 07:30:33AM +0100, Hervé Poussineau wrote:
> >>>>>Isaku Yamahata a écrit :
> >>>>>>On Wed, Dec 22, 2010 at 12:20:23AM +0100, Andreas Färber wrote:
> >>>>>>>From: Hervé Poussineau <hpoussin@reactos.org>
> >>>>>>>
> >>>>>>>v1:
> >>>>>>>* Rebased.
> >>>>>>>
> >>>>>>>Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> >>>>>>>Cc: Michael S. Tsirkin <mst@redhat.com>
> >>>>>>>Signed-off-by: Andreas Färber <andreas.faerber@web.de>
> >>>>>>>---
> >>>>>>>Hello Michael,
> >>>>>>>Could you please take a look at this? I'm out of my field here.
> >>>>>>>The intention of the first part appears to be to save (val & ~mask),
> >>>>>>>whereas the inline helper would've returned (val & mask).
> >>>>>>Such behavior is intended.
> >>>>>>The returned value is just discarded in this case.
> >>>>>>test-and-clear means
> >>>>>> clear the bits
> >>>>>> return if those cleared bits were really set.
> >>>>>>
> >>>>What about this first chunk? Is it necessary.
> >>>>
> >>>>>>>The second part makes existing code conditional on that value.
> >>>>>>What issue are you addressing?
> >>>>>>Although the spec doesn't says about the default value of
> >>>>>>BAR registers
> >>>>>>after reset, the current code assumes that almost all the
> >>>>>>pci devices clear
> >>>>>>those registers.
> >>>>>>Anyway after cold/warm reset firmware sets up BARs, so it
> >>>>>>doesn't matter.
> >>>>>>You, however, seem to want to keep BARs over resets.
> >>>>>>
> >>>>>>thanks,
> >>>>>>
> >>>>>>
> >>>>>As you have seen, the intend here is to be able to keep BARs
> >>>>>over resets.
> >>>>>It is required for some really specific devices, like a PCI to ISA
> >>>>>bridge, where MMIO is always at the same address.
> >>>>>In that case, the device keeps PCI_COMMAND_MEMORY and/or
> >>>>>PCI_COMMAND_IO flags as read-only.
> >>>>>
> >>>>>Hervé
> >>>>Aha. Are the BARs still writeable? If not maybe that's the right thing
> >>>>to check? If yes maybe the device simply should have a reset
> >>>>handler to rewrite them?
> >>>I haven't noticed a follow-up patch of yours.
> >>>
> >>>Since I don't know what to do here, I'll have to take this out of
> >>>the PReP queue for now.
> >>>Without this patch, I get to at least the second bootloader icon,
> >>>the PCI graphics still work. What particular symptoms did you
> >>>observe wrt the i82378 that we can reproduce?
> >>>
> >>>Thanks,
> >>>Andreas
> >>>
> >>Try do do info qtree with and without this patch, and check the
> >>i82378 device
> >>With this patch, I have:
> >> bar 0: mem at 0x80000000 [0x8000ffff]
> >> bar 1: mem at 0xc0000000 [0xc0ffffff]
> >>
> >>Without it, I have:
> >> bar 0: mem at 0xffffffffffffffff [0xfffe]
> >> bar 1: mem at 0xffffffffffffffff [0xfffffe]
> >>
> >>I think that firmware doesn't initialize BARs for this device.
> >
> >Interesting. So what set the BARs to these values (0x80000000
> >and 0xc0000000)
> Currently, those default values are stored in qdev properties of device,
> and device fills in BARs addresses in its init function
>
> +static int pci_i82378_init(PCIDevice *pci_dev)
> ...
> + /* Make addresses read only */
> + pci_set_word(pci_dev->wmask + PCI_COMMAND,
> + PCI_COMMAND_SPECIAL);
> + pci_set_long(pci_conf + PCI_BASE_ADDRESS_0 + 0 * 4, pci->isa_io_base);
> + pci_set_long(pci_conf + PCI_BASE_ADDRESS_0 + 1 * 4, pci->isa_mem_base);
>
> Regards
>
> Hervé
>
I see. So the right thing to do wrt BARs is probably
to restore these values on system reset as well?
It might be a good idea to replace 'Make addresses read only'
with 'only special cycle enable bit is writeable'.
--
MST
prev parent reply other threads:[~2011-06-12 19:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-21 23:20 [Qemu-devel] [PATCH, RFC] pci: allow PCI devices to fix address space Andreas Färber
2010-12-22 2:50 ` Isaku Yamahata
2010-12-22 6:24 ` Michael S. Tsirkin
2010-12-22 6:30 ` Hervé Poussineau
2010-12-22 6:49 ` Michael S. Tsirkin
2011-06-12 11:36 ` Andreas Färber
2011-06-12 12:40 ` Hervé Poussineau
2011-06-12 14:20 ` Andreas Färber
2011-06-12 18:28 ` Hervé Poussineau
2011-06-12 19:35 ` Michael S. Tsirkin
2011-06-12 19:53 ` Michael S. Tsirkin
2011-06-12 19:33 ` Michael S. Tsirkin
2011-06-12 19:50 ` Hervé Poussineau
2011-06-12 19:59 ` Michael S. Tsirkin [this message]
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=20110612195946.GB20615@redhat.com \
--to=mst@redhat.com \
--cc=andreas.faerber@web.de \
--cc=hpoussin@reactos.org \
--cc=qemu-devel@nongnu.org \
--cc=yamahata@valinux.co.jp \
/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).