pci: initialize header type register.
PATCH 1/1 pci: initialize header type register.
initialize header type register in pci generic code.
--- hw/pci.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
hw/pci.c +1 -0
@@ -603,6 +603,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, pci_dev->irq_state =0 ;pci_config_alloc (pci_dev); + pci_dev->config[PCI_HEADER_TYPE ] = header_type; header_type &= ~PCI_HEADER_TYPE_MULTI_FUNCTION ;if (header_type ==PCI_HEADER_TYPE_NORMAL ) {pci_set_default_subsystem_id (pci_dev);
Signature · 1 line
1.6.6.1
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Signed-off-by Isaku Yamahata <[email protected]>
No objections here, I am assuming this will be followed by patches removing header type init from bridges?
Quoted 1 line
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?
I queued this one, let's wait a bit for comments from interested people.
Quoted 18 lines
--- hw/pci.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)hw/pci.c +1
-0@@ -603,6 +603,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, pci_dev->irq_state =0 ;pci_config_alloc (pci_dev); + pci_dev->config[PCI_HEADER_TYPE ] = header_type; header_type &= ~PCI_HEADER_TYPE_MULTI_FUNCTION ;if (header_type ==PCI_HEADER_TYPE_NORMAL ) {pci_set_default_subsystem_id (pci_dev);Signature · 1 line
1.6.6.1
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?
From a qdev perspective it would make *alot* of sense to move a bunch of pci config stuff (including, but not limited to header type) into PCIDeviceInfo.
cheers,
Gerd
Quoted 13 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?
Quoted 6 lines
From a qdev perspective it would make *alot* of sense to move a bunch of pci config stuff (including, but not limited to header type) into PCIDeviceInfo.
cheers,
Gerd
It's an Ack then?
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?
Quoted 8 lines
Quoted 6 lines
From a qdev perspective it would make *alot* of sense to move a bunch of
pci config stuff (including, but not limited to header type) into PCIDeviceInfo.cheers,
GerdIt's an Ack then?
Yes, count it as ack. It is a move into the right direction, and the fact that more cleanups can/should be done here shouldn't hold it up.
cheers,
Gerd
Quoted 13 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?
Quoted 6 lines
From a qdev perspective it would make *alot* of sense to move a bunch of pci config stuff (including, but not limited to header type) into PCIDeviceInfo.
cheers,
Gerd
Actually - won't this make it possible to create broken configurations by tweaking properties from command-line?
And generally, it sounds bad to have header type duplicated in qdev and in config. Why do we want it in qdev?
Isaku Yamahata, could you please clarify?
Signature · 1 line
MT
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?From a qdev perspective it would make *alot* of sense to move a bunch of
pci config stuff (including, but not limited to header type) into PCIDeviceInfo.
Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo e1000_info = {
[ stuff which is here right now ]
.vendor_id = PCI_VENDOR_ID_INTEL,
.device_id = E1000_DEVID,
.class = PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}
Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
cheers,
Gerd
Quoted 35 lines · Gerd Hoffmann
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?From a qdev perspective it would make *alot* of sense to move a bunch of
pci config stuff (including, but not limited to header type) into PCIDeviceInfo.Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo
e1000_info= {
[ stuff which is here right now ]
.vendor_id =PCI_VENDOR_ID_INTEL,
.device_id =E1000_DEVID,
.class =PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}
Quoted 5 lines
Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
cheers,
Gerd
We still end up with class, vendor etc duplicated in 2 places. Why do we want stuff like vendor id in PCIDeviceInfo at all? Why can't everyone just use pci_config_set/get calls?
Signature · 1 line
MST
Quoted 36 lines · Michael S. Tsirkin
Quoted 35 lines · Gerd Hoffmann
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?From a qdev perspective it would make *alot* of sense to move a bunch of
pci config stuff (including, but not limited to header type) into PCIDeviceInfo.Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo
e1000_info= {
[ stuff which is here right now ]
.vendor_id =PCI_VENDOR_ID_INTEL,
.device_id =E1000_DEVID,
.class =PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}
Quoted 7 lines
Quoted 5 lines
Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
cheers,
GerdWe still end up with class, vendor etc duplicated in 2 places.
No. The info should be *only* in PCIDeviceInfo then.
Quoted 3 lines
Why do
we want stuff like vendor id in PCIDeviceInfo at all? Why can't everyone just use pci_config_set/get calls?
You can do nice stuff like printing vendor/device IDs in the '-device ?' list then.
cheers,
Gerd
Quoted 40 lines · Gerd Hoffmann
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Gerd Hoffmann
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?From a qdev perspective it would make *alot* of sense to move a bunch of
pci config stuff (including, but not limited to header type) into PCIDeviceInfo.Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo
e1000_info= {
[ stuff which is here right now ]
.vendor_id =PCI_VENDOR_ID_INTEL,
.device_id =E1000_DEVID,
.class =PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
cheers,
GerdWe still end up with class, vendor etc duplicated in 2 places.
No. The info should be *only* in PCIDeviceInfo then.
That would put a lot of code in pci config cycle path. A single array mirroring the whole config space is much cleaner.
Quoted 6 lines
Quoted 3 lines
Why do
we want stuff like vendor id in PCIDeviceInfo at all? Why can't everyone just use pci_config_set/get calls?You can do nice stuff like printing vendor/device IDs in the '-device ?' list then.
That should use pci functions as well.
Quoted 2 lines
cheers,
Gerd
Quoted 44 lines · Michael S. Tsirkin
Quoted 43 lines · Gerd Hoffmann
Quoted 42 lines · Michael S. Tsirkin
Quoted 40 lines · Gerd Hoffmann
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges? From qdev perspective, it is probably cleaner to make multifunction bit a separate qdev property though, right?
From a qdev perspective it would make *alot* of sense to move a bunch of pci config stuff (including, but not limited to header type) into PCIDeviceInfo.
Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo
e1000_info= {
[ stuff which is here right now ]
.vendor_id =PCI_VENDOR_ID_INTEL,
.device_id =E1000_DEVID,
.class =PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
cheers,
Gerd
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
We still end up with class, vendor etc duplicated in 2 places.
No. The info should be *only* in PCIDeviceInfo then.
That would put a lot of code in pci config cycle path. A single array mirroring the whole config space is much cleaner.
I'd suppose the arrays would remain as they are now, they just would be initialized (using the pci functions) based on PCIDeviceInfo structure. This would simplify the device code a lot.
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Why do
we want stuff like vendor id in PCIDeviceInfo at all? Why can't everyone just use pci_config_set/get calls?You can do nice stuff like printing vendor/device IDs in the '-device ?' list then.
That should use pci functions as well.
Quoted 2 lines
cheers,
Gerd
Quoted 47 lines · Blue Swirl
Quoted 46 lines · Michael S. Tsirkin
Quoted 45 lines · Gerd Hoffmann
Quoted 43 lines · Michael S. Tsirkin
Quoted 35 lines · Gerd Hoffmann
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges? From qdev perspective, it is probably cleaner to make multifunction bit a separate qdev property though, right?
From a qdev perspective it would make *alot* of sense to move a bunch of pci config stuff (including, but not limited to header type) into PCIDeviceInfo.
Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo
e1000_info= {
[ stuff which is here right now ]
.vendor_id =PCI_VENDOR_ID_INTEL,
.device_id =E1000_DEVID,
.class =PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}Quoted 5 lines
Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
cheers,
GerdWe still end up with class, vendor etc duplicated in 2 places.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
No. The info should be *only* in PCIDeviceInfo then.
That would put a lot of code in pci config cycle path. A single array mirroring the whole config space is much cleaner.
I'd suppose the arrays would remain as they are now, they just would be initialized (using the pci functions) based on PCIDeviceInfo structure.
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.
Quoted 1 line
This would simplify the device code a lot.
Well, I think
pci_set_class(pci_dev, PCI_CLASS_NETWORK_ETHERNET)
is simpler than
.class = PCI_CLASS_NETWORK_ETHERNET
and some magic that copies that to pci config.
Quoted 12 lines
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Why do
we want stuff like vendor id in PCIDeviceInfo at all? Why can't everyone just use pci_config_set/get calls?You can do nice stuff like printing vendor/device IDs in the '-device ?' list then.
That should use pci functions as well.
Quoted 2 lines
cheers,
Gerd
Quoted 65 lines · Michael S. Tsirkin
Quoted 47 lines · Blue Swirl
Quoted 46 lines · Michael S. Tsirkin
Quoted 45 lines · Gerd Hoffmann
Quoted 43 lines · Michael S. Tsirkin
Quoted 35 lines · Gerd Hoffmann
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges? From qdev perspective, it is probably cleaner to make multifunction bit a separate qdev property though, right?
From a qdev perspective it would make *alot* of sense to move a bunch of pci config stuff (including, but not limited to header type) into PCIDeviceInfo.
Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo
e1000_info= {
[ stuff which is here right now ]
.vendor_id =PCI_VENDOR_ID_INTEL,
.device_id =E1000_DEVID,
.class =PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}Quoted 5 lines
Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
cheers,
GerdWe still end up with class, vendor etc duplicated in 2 places.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
No. The info should be *only* in PCIDeviceInfo then.
That would put a lot of code in pci config cycle path. A single array mirroring the whole config space is much cleaner.
I'd suppose the arrays would remain as they are now, they just would be initialized (using the pci functions) based on PCIDeviceInfo structure.
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.
Quoted 1 line
This would simplify the device code a lot.
Well, I think
Quoted 7 lines
pci_set_class(pci_dev, PCI_CLASS_NETWORK_ETHERNET)is simpler than
.class =
PCI_CLASS_NETWORK_ETHERNETand some magic that copies that to pci config.
The advantage is that if the code happens to change, only the magic (which is in one place) needs to be changed. Similar process has happened with savevm.
Quoted 70 lines · Blue Swirl
Quoted 69 lines · Michael S. Tsirkin
Quoted 47 lines · Blue Swirl
Quoted 46 lines · Michael S. Tsirkin
Quoted 45 lines · Gerd Hoffmann
Quoted 43 lines · Michael S. Tsirkin
Quoted 35 lines · Gerd Hoffmann
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges? From qdev perspective, it is probably cleaner to make multifunction bit a separate qdev property though, right?
From a qdev perspective it would make *alot* of sense to move a bunch of pci config stuff (including, but not limited to header type) into PCIDeviceInfo.
Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo
e1000_info= {
[ stuff which is here right now ]
.vendor_id =PCI_VENDOR_ID_INTEL,
.device_id =E1000_DEVID,
.class =PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}Quoted 5 lines
Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
cheers,
GerdWe still end up with class, vendor etc duplicated in 2 places.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
No. The info should be *only* in PCIDeviceInfo then.
That would put a lot of code in pci config cycle path. A single array mirroring the whole config space is much cleaner.
I'd suppose the arrays would remain as they are now, they just would be initialized (using the pci functions) based on PCIDeviceInfo structure.
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.
Quoted 1 line
This would simplify the device code a lot.
Well, I think
pci_set_class(pci_dev, PCI_CLASS_NETWORK_ETHERNET)is simpler than
Quoted 7 lines
Quoted 3 lines
.class =
PCI_CLASS_NETWORK_ETHERNETand some magic that copies that to pci config.
The advantage is that if the code happens to change, only the magic (which is in one place) needs to be changed. Similar process has happened with savevm.
Yes, one place is good. But magic is bad. What's wrong with pci_set_header type or something like that? Why do we need header type in qdev?
Signature · 1 line
MST
Hi,
Quoted 3 lines
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.
It is static information, it should be static data. And having the information in a well defined place in a data structure instead of hidden somewhere in the ->init() code makes it alot easier to reuse the information for something else. That is the whole point.
cheers,
Gerd
Quoted 6 lines · Gerd Hoffmann
Hi,
Quoted 3 lines
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.
Quoted 6 lines
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.
Quoted 7 lines
It is static information, it should be static data. And having the information in a well defined place in a data structure instead of hidden somewhere in the ->init() code makes it alot easier to reuse the information for something else. That is the whole point.
cheers,
Gerd
more important IMO is making code easier to follow.
Signature · 1 line
MST
Quoted 11 lines · Michael S. Tsirkin
Quoted 9 lines · Gerd Hoffmann
Hi,Quoted 4 lines
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.
Quoted 8 lines
Quoted 5 lines
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.
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
Quoted 21 lines · Anthony Liguori
Quoted 11 lines · Michael S. Tsirkin
Quoted 9 lines · Gerd Hoffmann
Hi,Quoted 4 lines
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.
Quoted 8 lines
Quoted 5 lines
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.
Quoted 5 lines
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.
Quoted 7 lines
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.
Signature · 1 line
MST
Quoted 41 lines · Michael S. Tsirkin
Quoted 26 lines · Anthony Liguori
Quoted 14 lines · Michael S. Tsirkin
Quoted 11 lines · Gerd Hoffmann
Hi,Quoted 5 lines
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.
Quoted 10 lines
Quoted 6 lines
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.
Quoted 6 lines
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.
Quoted 4 lines
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.
Quoted 6 lines
Quoted 4 lines
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. 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 :-)
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
Quoted 56 lines · Anthony Liguori
Quoted 41 lines · Michael S. Tsirkin
Quoted 26 lines · Anthony Liguori
Quoted 14 lines · Michael S. Tsirkin
Quoted 11 lines · Gerd Hoffmann
Hi,Quoted 5 lines
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.
Quoted 10 lines
Quoted 6 lines
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.
Quoted 6 lines
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.
Quoted 4 lines
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.Quoted 6 lines
Quoted 4 lines
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;
Quoted 6 lines
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.
Quoted 3 lines
I'm staring at a PCI config space diagram right
now and I'm *still* not even sure I'm interpreting theversatile_pcicode 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.
Quoted 12 lines
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
Quoted 15 lines · Michael S. Tsirkin
Quoted 7 lines
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;Quoted 7 lines
To:
pci_config_set_command(d, 0);pci_config_set_status(d, PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_66MHZ);Is a huge improvement.
Quoted 9 lines
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.
Oh, pci_set_word() is certainly an improvement. Personally, I prefer passing the PCIDevice as a context and adding individual accessors but anything is better than open coded config.
Quoted 10 lines
Quoted 4 lines
I'm staring at a PCI config space diagram right
now and I'm *still* not even sure I'm interpreting theversatile_pcicode 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.
It's on my radar but I've got another PCI series in flight. I've got a branch pci-cleanup on staging that's a work in progress for adding a proper region API along with PCI memory accessors.
Once I find a little more time to finish converting VGA devices, I'll post.
Regards,
Anthony Liguori
Quoted 34 lines · Anthony Liguori
Quoted 15 lines · Michael S. Tsirkin
Quoted 7 lines
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;Quoted 7 lines
To:
pci_config_set_command(d, 0);pci_config_set_status(d, PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_66MHZ);Is a huge improvement.
Quoted 9 lines
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.
Oh,
pci_set_word()is certainly an improvement. Personally, I prefer passing the PCIDevice as a context and adding individual accessors but anything is better than open coded config.Quoted 4 lines
Quoted 4 lines
I'm staring at a PCI config space diagram right
now and I'm *still* not even sure I'm interpreting theversatile_pcicode correctly :-)
Quoted 8 lines
Quoted 6 lines
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.It's on my radar
Just converted versatile_pci, with some nudging I might do others :)
Quoted 9 lines
but I've got another PCI series in flight. I've got a branch pci-cleanup on staging that's a work in progress for adding a proper region API along with PCI memory accessors.
Once I find a little more time to finish converting VGA devices, I'll post.
Regards,
Anthony Liguori
Great! That's required for proper spec compliance. VGA devices are definitely the main pain point here.
Signature · 1 line
MST
Quoted 3 lines · Michael S. Tsirkin
Just converted
versatile_pci, with some nudging I might do others :)
*nudge* :-)
Quoted 4 lines
Quoted 4 lines
but I've got another PCI series in flight. I've got a branch pci-cleanup on staging that's a work in progress for adding a proper region API along with PCI memory accessors.
Quoted 9 lines
Quoted 6 lines
Once I find a little more time to finish converting VGA devices, I'll post.
Regards,
Anthony Liguori
Great! That's required for proper spec compliance. VGA devices are definitely the main pain point here.
The KVM LFB optimization makes it challenging. Need to find some time to figure out the best way to do it. Suggestions are certainly appreciated.
Regards,
Anthony Liguori
Quoted 6 lines · Anthony Liguori
Quoted 3 lines · Michael S. Tsirkin
Just converted
versatile_pci, with some nudging I might do others :)*nudge* :-)
which files do you care most about?
Quoted 22 lines
Quoted 4 lines
Quoted 4 lines
but I've got another PCI series in flight. I've got a branch pci-cleanup on staging that's a work in progress for adding a proper region API along with PCI memory accessors.
Quoted 9 lines
Quoted 6 lines
Once I find a little more time to finish converting VGA devices, I'll post.
Regards,
Anthony Liguori
Great! That's required for proper spec compliance. VGA devices are definitely the main pain point here.
The KVM LFB optimization makes it challenging. Need to find some time to figure out the best way to do it. Suggestions are certainly appreciated.
Regards,
Anthony Liguori
Quoted 13 lines · Gerd Hoffmann
Hi,
Quoted 3 lines
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.
Quoted 4 lines
It is static information, it should be static data. And having the information in a well defined place in a data structure instead of hidden somewhere in the ->init() code makes it alot easier to reuse the information for something else. That is the whole point.
ACK
Quoted 51 lines · Michael S. Tsirkin
Quoted 40 lines · Gerd Hoffmann
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Gerd Hoffmann
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?From a qdev perspective it would make *alot* of sense to move a bunch of
pci config stuff (including, but not limited to header type) into PCIDeviceInfo.Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo
e1000_info= {
[ stuff which is here right now ]
.vendor_id =PCI_VENDOR_ID_INTEL,
.device_id =E1000_DEVID,
.class =PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
cheers,
GerdWe still end up with class, vendor etc duplicated in 2 places.
No. The info should be *only* in PCIDeviceInfo then.
That would put a lot of code in pci config cycle path. A single array mirroring the whole config space is much cleaner.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Why do
we want stuff like vendor id in PCIDeviceInfo at all? Why can't everyone just use pci_config_set/get calls?You can do nice stuff like printing vendor/device IDs in the '-device ?' list then.
That should use pci functions as well.
Hmm, do you mix up PCIDevice and PCIDeviceInfo structs?
cheers,
Gerd
Quoted 59 lines · Gerd Hoffmann
Quoted 58 lines · Michael S. Tsirkin
Quoted 40 lines · Gerd Hoffmann
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Gerd Hoffmann
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?From a qdev perspective it would make *alot* of sense to move a bunch of
pci config stuff (including, but not limited to header type) into PCIDeviceInfo.Quoted 5 lines
Quoted 2 lines
cheers,
GerdActually - won't this make it possible to create broken configurations by tweaking properties from command-line?
Not as property, as struct element in PCIDeviceInfo. i.e.
static PCIDeviceInfo
e1000_info= {
[ stuff which is here right now ]
.vendor_id =PCI_VENDOR_ID_INTEL,
.device_id =E1000_DEVID,
.class =PCI_CLASS_NETWORK_ETHERNET,
[ probably more stuff which makes sense ]
}Then setup this in generic pci code instead of having each driver doing a bunch of pci_config_set_*() calls.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
cheers,
GerdWe still end up with class, vendor etc duplicated in 2 places.
No. The info should be *only* in PCIDeviceInfo then.
That would put a lot of code in pci config cycle path. A single array mirroring the whole config space is much cleaner.
Quoted 6 lines
Quoted 3 lines
Why do
we want stuff like vendor id in PCIDeviceInfo at all? Why can't everyone just use pci_config_set/get calls?You can do nice stuff like printing vendor/device IDs in the '-device ?' list then.
Quoted 6 lines
Quoted 1 line
That should use pci functions as well.
Hmm, do you mix up PCIDevice and PCIDeviceInfo structs?
cheers,
Gerd
OK. OTOH, I don't think we need to out print header type in -device ? so what good is it there?
Quoted 21 lines · Michael S. Tsirkin
Quoted 13 lines · Gerd Hoffmann
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl<[email protected]>Cc "Michael S. Tsirkin"<[email protected]>Signed-off-by Isaku Yamahata<[email protected]>No objections here, I am assuming this will be followed by patches removing header type init from bridges?
From qdev perspective, it is probably cleaner to make
multifunction bit a separate qdev property though, right?Quoted 6 lines
From a qdev perspective it would make *alot* of sense to move a bunch of pci config stuff (including, but not limited to header type) into PCIDeviceInfo.
cheers,
Gerd
Quoted 6 lines
Actually - won't this make it possible to create broken configurations by tweaking properties from command-line?
And generally, it sounds bad to have header type duplicated in qdev and in config. Why do we want it in qdev?Isaku Yamahata, could you please clarify?
My idea behind the patch is that making configuration space initialization a sort of table driven (in long term?) like Gerd and Blue already stated it.
If there is a consensus to go for it, I'm willing to create patches. However it seems that we haven't reached the conclusion yet. I'm not sure it's worth while to allow user to tweak config space.
Signature · 1 line
yamahata
Michael S. Tsirkin
AppliedQuoted 5 lines · Isaku Yamahata
initialize header type register in pci generic code.
Cc Blue Swirl <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Signed-off-by Isaku Yamahata <[email protected]>
Applied, thanks.
Quoted 18 lines
--- hw/pci.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)hw/pci.c +1
-0@@ -603,6 +603,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, pci_dev->irq_state =0 ;pci_config_alloc (pci_dev); + pci_dev->config[PCI_HEADER_TYPE ] = header_type; header_type &= ~PCI_HEADER_TYPE_MULTI_FUNCTION ;if (header_type ==PCI_HEADER_TYPE_NORMAL ) {pci_set_default_subsystem_id (pci_dev);Signature · 1 line
1.6.6.1