From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Blue Swirl <blauwirbel@gmail.com>,
Isaku Yamahata <yamahata@valinux.co.jp>,
Gerd Hoffmann <kraxel@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: [PATCH] pci: initialize header type register.
Date: Mon, 8 Feb 2010 23:01:47 +0200 [thread overview]
Message-ID: <20100208210147.GA17248@redhat.com> (raw)
In-Reply-To: <4B707A00.2000706@codemonkey.ws>
On Mon, Feb 08, 2010 at 02:54:24PM -0600, Anthony Liguori wrote:
> On 02/08/2010 02:34 PM, Michael S. Tsirkin wrote:
>> On Mon, Feb 08, 2010 at 02:32:26PM -0600, Anthony Liguori wrote:
>>
>>> On 02/08/2010 02:19 PM, Michael S. Tsirkin wrote:
>>>
>>>> On Mon, Feb 08, 2010 at 08:55:58PM +0100, Gerd Hoffmann wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>>
>>>>>
>>>>>> This still means we have two copies of same data
>>>>>> and need to maintain code that keeps them in sync,
>>>>>> even if that is called just at init time.
>>>>>>
>>>>>>
>>>>> No. There is nothing to keep in sync. And there is no extra copy of data.
>>>>>
>>>>> Today you have pci_set_*() calls somewhere in PCIDeviceInfo->init().
>>>>> I'd like to see them replaced with PCIDeviceInfo->$field + setup in
>>>>> common code. The information that device $foo has vendor id 42 and
>>>>> device id 4711 (and other properties) just moves from code to data.
>>>>>
>>>>>
>>>> We still need it in config array which is read by guest.
>>>> So that is two places.
>>>>
>>>>
>>> There's no reason that we couldn't make the config space read like all
>>> of the other spaces we support. IOW, instead of using an array to store
>>> the data, store each element in a structure, and have a big switch().
>>>
>>> I'm not sure one's better than the other though TBH.
>>>
>> Yea. So the solution that needs less code is better.
>>
>>
>>> I think just universally moving to a set of accessors that took a
>>> PCIDevice as an argument in the form of pci_device_set_vendor() would be
>>> a big improvement.
>>>
>>> Regards,
>>>
>>> Anthony Liguori
>>>
>> Not sure it's such a *big* improvement, but I won't object to that.
>>
>
> Sorry, but:
>
> versatile_pci.c: d->config[0x04] = 0x00;
> versatile_pci.c: d->config[0x05] = 0x00;
> versatile_pci.c: d->config[0x06] = 0x20;
> versatile_pci.c: d->config[0x07] = 0x02;
>
> To:
>
> pci_config_set_command(d, 0);
> pci_config_set_status(d, PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_66MHZ);
>
> Is a huge improvement.
Yes but
pci_set_word(d->config + PCI_COMMAND, 0);
pci_set_word(d->config + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_66MHZ);
is not much worse, and that API is already there.
And advatage is it uses macros from linux which have
higher chance to be correct than what we come up with.
> I'm staring at a PCI config space diagram right
> now and I'm *still* not even sure I'm interpreting the versatile_pci
> code correctly :-)
I spent time cleaning up devices, just did not get to bridges.
What I did is write patches and verify that compiled code
did not change at all. This guarantees no breakage.
Care to volunteer to complete that work?
Separately people that are familiar with device can clean it up.
> Having a nice structure with:
>
> { .command = 0,
> .status = PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_66MHZ,
> }
>
> would be nice but I can live without it.
>
> Regards,
>
> Anthony Liguori
>
next prev parent reply other threads:[~2010-02-08 21:05 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-08 6:41 [Qemu-devel] [PATCH] pci: initialize header type register Isaku Yamahata
2010-02-08 10:17 ` [Qemu-devel] " Michael S. Tsirkin
2010-02-08 11:14 ` Gerd Hoffmann
2010-02-08 11:16 ` Michael S. Tsirkin
2010-02-08 12:45 ` Gerd Hoffmann
2010-02-08 16:27 ` Michael S. Tsirkin
2010-02-08 17:24 ` Gerd Hoffmann
2010-02-08 17:32 ` Michael S. Tsirkin
2010-02-08 17:37 ` Gerd Hoffmann
2010-02-08 17:37 ` Michael S. Tsirkin
2010-02-08 17:43 ` Gerd Hoffmann
2010-02-08 18:23 ` Michael S. Tsirkin
2010-02-08 17:56 ` Blue Swirl
2010-02-08 18:26 ` Michael S. Tsirkin
2010-02-08 19:32 ` Blue Swirl
2010-02-08 19:44 ` Michael S. Tsirkin
2010-02-08 19:55 ` Gerd Hoffmann
2010-02-08 20:19 ` Michael S. Tsirkin
2010-02-08 20:32 ` Anthony Liguori
2010-02-08 20:34 ` Michael S. Tsirkin
2010-02-08 20:54 ` Anthony Liguori
2010-02-08 21:01 ` Michael S. Tsirkin [this message]
2010-02-08 21:56 ` Anthony Liguori
2010-02-08 21:58 ` Michael S. Tsirkin
2010-02-08 22:25 ` Anthony Liguori
2010-02-09 12:11 ` Michael S. Tsirkin
2010-02-09 8:21 ` Markus Armbruster
2010-02-09 3:42 ` Isaku Yamahata
2010-02-08 14:19 ` Michael S. Tsirkin
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=20100208210147.GA17248@redhat.com \
--to=mst@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=blauwirbel@gmail.com \
--cc=kraxel@redhat.com \
--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).