pci: Add pci_device_get_host_irq
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.
Quoted 7 lines
Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the irq_count semantics for this host bridge.
Now I'm facing three possibilities of how to proceed:
1. Give up on the (currently broken) feature to write a vmstate for older QEMU versions.
This will allow to declare the irq_count field in vmstate_pcibus unused, and we would have to restore it on vmload step-wise via the PCI devices. It would also allow to change its semantics for PIIX3, mapping directly to PIC IRQs.
2. Keep writing a legacy irq_count field.
This will require quite a few new APIs so that host bridges that want to change their nirq can still generate a compatible irq_count vmstate field. Namely:
- A function to set up vmstate_irq_count and define a callback that the core will invoke to prepare the vmstate_irq_count before vmsave.
- A function to obtain the IRQ mapping /without/ the final host bridge step. This is required so that the callback above can calculate the old state like in the PIIX3 case.
3. Keep irq_count and nirq as is, introduce additional map_host_irq.
This is simpler than 2 and more compatible than 1. It would also allow to introduce the polarity and masking information more smoothly as we won't have to add it to existing map_irq callbacks then.
Any other suggestions?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Quoted 8 lines
Quoted 2 lines
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.Now I'm facing three possibilities of how to proceed:
They all look OK I think :) Some comments below.
Quoted 7 lines
1. Give up on the (currently broken) feature to write a vmstate for older QEMU versions.
This will allow to declare the
irq_countfield invmstate_pcibusunused, and we would have to restore it on vmload step-wise via the PCI devices. It would also allow to change its semantics for PIIX3, mapping directly to PIC IRQs.
I think that's okay too simply because these things are usually easy to fix after the fact when the rest of the issues are addressed.
Quoted 11 lines
2. Keep writing a legacy
irq_countfield.This will require quite a few new APIs so that host bridges that want to change their nirq can still generate a compatible
irq_countvmstate field. Namely:
- A function to set upvmstate_irq_countand define a callback that the core will invoke to prepare thevmstate_irq_countbefore vmsave.
- A function to obtain the IRQ mapping /without/ the final host bridge step. This is required so that the callback above can calculate the old state like in the PIIX3 case.
Does this really need to be so complex? It seems that we just need pci_get_irq_count(bus, irq) which can use the existing map_irq API, no? Then invoke that before save.
Quoted 6 lines
3. Keep
irq_countand nirq as is, introduce additionalmap_host_irq.This is simpler than 2 and more compatible than 1. It would also allow to introduce the polarity and masking information more smoothly as we won't have to add it to existing
map_irqcallbacks then.
So what does it map, and to what?
Maybe we can make the name imply that somehow.
Quoted 6 lines
Any other suggestions?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 11 lines · Jan Kiszka
Quoted 10 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.
Quoted 8 lines
Quoted 4 lines
Well, it's a bug: this is redundant info we should not have exposed it.
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.
BTW can you post the fixed version please in case
others want to play with it?
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Jan Kiszka
Quoted 14 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
Quoted 6 lines
Quoted 3 lines
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.BTW can you post the fixed version please in case
others want to play with it?
Pushed a snapshot to git://git.kiszka.org/qemu.git queues/pci. That version survived simple tests.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 28 lines · Michael S. Tsirkin
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Quoted 8 lines
Quoted 2 lines
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.Now I'm facing three possibilities of how to proceed:
They all look OK I think :) Some comments below.
Quoted 3 lines
1. Give up on the (currently broken) feature to write a vmstate for older QEMU versions.
Quoted 7 lines
Quoted 4 lines
This will allow to declare the
irq_countfield invmstate_pcibusunused, and we would have to restore it on vmload step-wise via the PCI devices. It would also allow to change its semantics for PIIX3, mapping directly to PIC IRQs.I think that's okay too simply because these things are usually easy to fix after the fact when the rest of the issues are addressed.
Don't get what you mean with "fixed". If we fix the vmstate generation in making it backward-compatible again, we enter option 2. Option 1 is explicitly about giving this up.
Quoted 13 lines
Quoted 12 lines
2. Keep writing a legacy
irq_countfield.This will require quite a few new APIs so that host bridges that want to change their nirq can still generate a compatible
irq_countvmstate field. Namely:
- A function to set upvmstate_irq_countand define a callback that the core will invoke to prepare thevmstate_irq_countbefore vmsave.
- A function to obtain the IRQ mapping /without/ the final host bridge step. This is required so that the callback above can calculate the old state like in the PIIX3 case.
Quoted 3 lines
Does this really need to be so complex? It seems that we just need
pci_get_irq_count(bus, irq)which can use the existingmap_irqAPI, no? Then invoke that before save.
No, because the new map_irq of the PIIX3 bridge will also include the host bridge routing (or masking) according to the PIRQx routoing registers of the PIIX3. Moreover, the fixup of the written legacy irq_count state has to happen in the PCI layer, which therefore has to query the host bridge for fixup information, not the other way around (because the PCI bus vmstate is separate from the PIIX3 host bridge).
Quoted 9 lines
Quoted 7 lines
3. Keep
irq_countand nirq as is, introduce additionalmap_host_irq.This is simpler than 2 and more compatible than 1. It would also allow to introduce the polarity and masking information more smoothly as we won't have to add it to existing
map_irqcallbacks then.So what does it map, and to what?
PCI bus IRQ to *host* IRQ. It is supposed to explore the routing of the host bridge between the root bus and the host's interrupt controller (i.e. the step that is currently missing the cached chain).
Quoted 1 line
Maybe we can make the name imply that somehow.
Better suggestions for this handler and maybe also the existing map_irq are welcome to make the difference clearer.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 34 lines · Jan Kiszka
Quoted 33 lines · Michael S. Tsirkin
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Quoted 8 lines
Quoted 2 lines
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.Now I'm facing three possibilities of how to proceed:
They all look OK I think :) Some comments below.
Quoted 7 lines
1. Give up on the (currently broken) feature to write a vmstate for older QEMU versions.
This will allow to declare the
irq_countfield invmstate_pcibusunused, and we would have to restore it on vmload step-wise via the PCI devices. It would also allow to change its semantics for PIIX3, mapping directly to PIC IRQs.
Quoted 6 lines
Quoted 2 lines
I think that's okay too simply because these things are usually easy to fix after the fact when the rest of the issues are addressed.
Don't get what you mean with "fixed". If we fix the vmstate generation in making it backward-compatible again, we enter option 2. Option 1 is explicitly about giving this up.
What I really mean is I think I see how 2 can be added without much pain. So let's focus on 1 for now and worst case we break migration.
Quoted 38 lines
Quoted 13 lines
Quoted 12 lines
2. Keep writing a legacy
irq_countfield.This will require quite a few new APIs so that host bridges that want to change their nirq can still generate a compatible
irq_countvmstate field. Namely:
- A function to set upvmstate_irq_countand define a callback that the core will invoke to prepare thevmstate_irq_countbefore vmsave.
- A function to obtain the IRQ mapping /without/ the final host bridge step. This is required so that the callback above can calculate the old state like in the PIIX3 case.Quoted 3 lines
Does this really need to be so complex? It seems that we just need
pci_get_irq_count(bus, irq)which can use the existingmap_irqAPI, no? Then invoke that before save.No, because the new
map_irqof the PIIX3 bridge will also include the host bridge routing (or masking) according to the PIRQx routoing registers of the PIIX3. Moreover, the fixup of the written legacyirq_countstate has to happen in the PCI layer, which therefore has to query the host bridge for fixup information, not the other way around (because the PCI bus vmstate is separate from the PIIX3 host bridge).Quoted 9 lines
Quoted 7 lines
3. Keep
irq_countand nirq as is, introduce additionalmap_host_irq.This is simpler than 2 and more compatible than 1. It would also allow to introduce the polarity and masking information more smoothly as we won't have to add it to existing
map_irqcallbacks then.So what does it map, and to what?
PCI bus IRQ to *host* IRQ. It is supposed to explore the routing of the host bridge between the root bus and the host's interrupt controller (i.e. the step that is currently missing the cached chain).
Quoted 6 lines
Quoted 1 line
Maybe we can make the name imply that somehow.
Better suggestions for this handler and maybe also the existing
map_irqare welcome to make the difference clearer.Jan
So I won't object to adding a new API but if we do it properly this won't help compatibility :(
Let's formulate what these do exactly, this will
also help us come up with sensible names.
1. The difference is that pci bridges route interrupt pins. So it gets interrupt pin on device and returns interrupt pin on connector. All attributes are standard PCI. We should remove all mentions of "irq" really.
2. The pci root (yes it's a host bridge but let's not use the term host if we can) routes
an interrupt pin on device to a host irq. It can also do more things like invert polarity.
So yes we can add 2 to piix but we really should
remove 1 from it.
Wrt names - do you object to long names?
How about route_interrupt_pin for 1
and route_interrupt_pin_to_irq for 2?
Quoted 3 lines
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 38 lines · Michael S. Tsirkin
Quoted 37 lines · Jan Kiszka
Quoted 35 lines · Michael S. Tsirkin
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Quoted 8 lines
Quoted 2 lines
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.Now I'm facing three possibilities of how to proceed:
They all look OK I think :) Some comments below.
Quoted 7 lines
1. Give up on the (currently broken) feature to write a vmstate for older QEMU versions.
This will allow to declare the
irq_countfield invmstate_pcibusunused, and we would have to restore it on vmload step-wise via the PCI devices. It would also allow to change its semantics for PIIX3, mapping directly to PIC IRQs.I think that's okay too simply because these things are usually easy to fix after the fact when the rest of the issues are addressed.
Quoted 6 lines
Quoted 3 lines
Don't get what you mean with "fixed". If we fix the vmstate generation in making it backward-compatible again, we enter option 2. Option 1 is explicitly about giving this up.
What I really mean is I think I see how 2 can be added without much pain. So let's focus on 1 for now and worst case we break migration.
I'd like to avoid planing for this worst case as long as there are also statements [1] that this is not acceptable for QEMU in general. It doesn't to create a beautiful architecture initially about which we already know that it will become more complex than alternatives in the end.
Quoted 41 lines
Quoted 41 lines
Quoted 14 lines
Quoted 4 lines
2. Keep writing a legacy
irq_countfield.Quoted 9 lines
This will require quite a few new APIs so that host bridges that want to change their nirq can still generate a compatible
irq_countvmstate field. Namely:
- A function to set upvmstate_irq_countand define a callback that the core will invoke to prepare thevmstate_irq_countbefore vmsave.
- A function to obtain the IRQ mapping /without/ the final host bridge step. This is required so that the callback above can calculate the old state like in the PIIX3 case.Quoted 3 lines
Does this really need to be so complex? It seems that we just need
pci_get_irq_count(bus, irq)which can use the existingmap_irqAPI, no? Then invoke that before save.No, because the new
map_irqof the PIIX3 bridge will also include the host bridge routing (or masking) according to the PIRQx routoing registers of the PIIX3. Moreover, the fixup of the written legacyirq_countstate has to happen in the PCI layer, which therefore has to query the host bridge for fixup information, not the other way around (because the PCI bus vmstate is separate from the PIIX3 host bridge).Quoted 9 lines
Quoted 7 lines
3. Keep
irq_countand nirq as is, introduce additionalmap_host_irq.This is simpler than 2 and more compatible than 1. It would also allow to introduce the polarity and masking information more smoothly as we won't have to add it to existing
map_irqcallbacks then.So what does it map, and to what?
PCI bus IRQ to *host* IRQ. It is supposed to explore the routing of the host bridge between the root bus and the host's interrupt controller (i.e. the step that is currently missing the cached chain).
Quoted 1 line
Maybe we can make the name imply that somehow.
Quoted 7 lines
Quoted 4 lines
Better suggestions for this handler and maybe also the existing
map_irqare welcome to make the difference clearer.Jan
So I won't object to adding a new API but if we do it properly this won't help compatibility :(
It will as this API does not touch the parts that affect the vmstate (ie. semantics of irq_count won't change).
Quoted 15 lines
Let's formulate what these do exactly, this will
also help us come up with sensible names.1. The difference is that pci bridges route interrupt pins. So it gets interrupt pin on device and returns interrupt pin on connector. All attributes are standard PCI. We should remove all mentions of "irq" really.
2. The pci root (yes it's a host bridge but let's not use the term host if we can) routes
an interrupt pin on device to a host irq. It can also do more things like invert polarity.
Quoted 6 lines
So yes we can add 2 to piix but we really should
remove 1 from it.Wrt names - do you object to long names?
How aboutroute_interrupt_pinfor 1
androute_interrupt_pin_to_irqfor 2?
I'm fine with this.
Jan
[1] http://permalink.gmane.org/gmane.comp.emulators.qemu/153357
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 95 lines · Jan Kiszka
Quoted 38 lines · Michael S. Tsirkin
Quoted 37 lines · Jan Kiszka
Quoted 35 lines · Michael S. Tsirkin
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Quoted 8 lines
Quoted 2 lines
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.Now I'm facing three possibilities of how to proceed:
They all look OK I think :) Some comments below.
Quoted 7 lines
1. Give up on the (currently broken) feature to write a vmstate for older QEMU versions.
This will allow to declare the
irq_countfield invmstate_pcibusunused, and we would have to restore it on vmload step-wise via the PCI devices. It would also allow to change its semantics for PIIX3, mapping directly to PIC IRQs.I think that's okay too simply because these things are usually easy to fix after the fact when the rest of the issues are addressed.
Quoted 6 lines
Quoted 3 lines
Don't get what you mean with "fixed". If we fix the vmstate generation in making it backward-compatible again, we enter option 2. Option 1 is explicitly about giving this up.
What I really mean is I think I see how 2 can be added without much pain. So let's focus on 1 for now and worst case we break migration.
I'd like to avoid planing for this worst case as long as there are also statements [1] that this is not acceptable for QEMU in general. It doesn't to create a beautiful architecture initially about which we already know that it will become more complex than alternatives in the end.
Quoted 44 lines
Quoted 44 lines
Quoted 14 lines
Quoted 4 lines
2. Keep writing a legacy
irq_countfield.Quoted 9 lines
This will require quite a few new APIs so that host bridges that want to change their nirq can still generate a compatible
irq_countvmstate field. Namely:
- A function to set upvmstate_irq_countand define a callback that the core will invoke to prepare thevmstate_irq_countbefore vmsave.
- A function to obtain the IRQ mapping /without/ the final host bridge step. This is required so that the callback above can calculate the old state like in the PIIX3 case.Quoted 3 lines
Does this really need to be so complex? It seems that we just need
pci_get_irq_count(bus, irq)which can use the existingmap_irqAPI, no? Then invoke that before save.No, because the new
map_irqof the PIIX3 bridge will also include the host bridge routing (or masking) according to the PIRQx routoing registers of the PIIX3. Moreover, the fixup of the written legacyirq_countstate has to happen in the PCI layer, which therefore has to query the host bridge for fixup information, not the other way around (because the PCI bus vmstate is separate from the PIIX3 host bridge).Quoted 9 lines
Quoted 7 lines
3. Keep
irq_countand nirq as is, introduce additionalmap_host_irq.This is simpler than 2 and more compatible than 1. It would also allow to introduce the polarity and masking information more smoothly as we won't have to add it to existing
map_irqcallbacks then.So what does it map, and to what?
PCI bus IRQ to *host* IRQ. It is supposed to explore the routing of the host bridge between the root bus and the host's interrupt controller (i.e. the step that is currently missing the cached chain).
Quoted 1 line
Maybe we can make the name imply that somehow.
Better suggestions for this handler and maybe also the existing
map_irqare welcome to make the difference clearer.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Jan
So I won't object to adding a new API but if we do it properly this won't help compatibility :(
It will as this API does not touch the parts that affect the vmstate (ie. semantics of
irq_countwon't change).
Yes but irq_count in vmstate is a bug. IMO even if we do not change anything we should ignore irq_count on load and recalculate it from what the devices supply.
Quoted 31 lines
Quoted 15 lines
Let's formulate what these do exactly, this will
also help us come up with sensible names.1. The difference is that pci bridges route interrupt pins. So it gets interrupt pin on device and returns interrupt pin on connector. All attributes are standard PCI. We should remove all mentions of "irq" really.
2. The pci root (yes it's a host bridge but let's not use the term host if we can) routes
an interrupt pin on device to a host irq. It can also do more things like invert polarity.Quoted 6 lines
So yes we can add 2 to piix but we really should
remove 1 from it.Wrt names - do you object to long names?
How aboutroute_interrupt_pinfor 1
androute_interrupt_pin_to_irqfor 2?I'm fine with this.
Jan
[1] http://permalink.gmane.org/gmane.comp.emulators.qemu/153357
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 43 lines · Jan Kiszka
Quoted 42 lines · Michael S. Tsirkin
Quoted 40 lines · Jan Kiszka
Quoted 28 lines · Michael S. Tsirkin
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Quoted 8 lines
Quoted 2 lines
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.Now I'm facing three possibilities of how to proceed:
They all look OK I think :) Some comments below.
Quoted 3 lines
1. Give up on the (currently broken) feature to write a vmstate for older QEMU versions.
Quoted 7 lines
Quoted 4 lines
This will allow to declare the
irq_countfield invmstate_pcibusunused, and we would have to restore it on vmload step-wise via the PCI devices. It would also allow to change its semantics for PIIX3, mapping directly to PIC IRQs.I think that's okay too simply because these things are usually easy to fix after the fact when the rest of the issues are addressed.
Don't get what you mean with "fixed". If we fix the vmstate generation in making it backward-compatible again, we enter option 2. Option 1 is explicitly about giving this up.
Quoted 7 lines
Quoted 2 lines
What I really mean is I think I see how 2 can be added without much pain. So let's focus on 1 for now and worst case we break migration.
I'd like to avoid planing for this worst case as long as there are also statements [1] that this is not acceptable for QEMU in general. It doesn't to create a beautiful architecture initially about which we already know that it will become more complex than alternatives in the end.
1 and 2 are same really except 2 adds a hack for compatibility, no?
Quoted 9 lines · Michael S. Tsirkin
Quoted 5 lines
Quoted 2 lines
So I won't object to adding a new API but if we do it properly this won't help compatibility :(
It will as this API does not touch the parts that affect the vmstate (ie. semantics of
irq_countwon't change).Yes but
irq_countin vmstate is a bug. IMO even if we do not change anything we should ignoreirq_counton load and recalculate it from what the devices supply.
I don't disagree. But this will only allow keeping backward migration support if we preserve the semantics of current map_irq somewhere - to keep the chance of calculating the legacy values for vmsave as well.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 47 lines · Michael S. Tsirkin
Quoted 46 lines · Jan Kiszka
Quoted 44 lines · Michael S. Tsirkin
Quoted 34 lines · Jan Kiszka
Quoted 33 lines · Michael S. Tsirkin
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Quoted 8 lines
Quoted 2 lines
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.Now I'm facing three possibilities of how to proceed:
They all look OK I think :) Some comments below.
Quoted 7 lines
1. Give up on the (currently broken) feature to write a vmstate for older QEMU versions.
This will allow to declare the
irq_countfield invmstate_pcibusunused, and we would have to restore it on vmload step-wise via the PCI devices. It would also allow to change its semantics for PIIX3, mapping directly to PIC IRQs.Quoted 6 lines
Quoted 2 lines
I think that's okay too simply because these things are usually easy to fix after the fact when the rest of the issues are addressed.
Don't get what you mean with "fixed". If we fix the vmstate generation in making it backward-compatible again, we enter option 2. Option 1 is explicitly about giving this up.
What I really mean is I think I see how 2 can be added without much pain. So let's focus on 1 for now and worst case we break migration.
Quoted 6 lines
Quoted 4 lines
I'd like to avoid planing for this worst case as long as there are also statements [1] that this is not acceptable for QEMU in general. It doesn't to create a beautiful architecture initially about which we already know that it will become more complex than alternatives in the end.
1 and 2 are same really except 2 adds a hack for compatibility, no?
Yes, 2 would allow us to maintain irq_count in different ways as well, specifically using it calculate shared output IRQ lines before reporting them to the PIC generically. This approach has both a charming and an ugly face.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 11 lines · Jan Kiszka
Quoted 9 lines · Michael S. Tsirkin
Quoted 5 lines
Quoted 2 lines
So I won't object to adding a new API but if we do it properly this won't help compatibility :(
It will as this API does not touch the parts that affect the vmstate (ie. semantics of
irq_countwon't change).Yes but
irq_countin vmstate is a bug. IMO even if we do not change anything we should ignoreirq_counton load and recalculate it from what the devices supply.
Quoted 5 lines
I don't disagree. But this will only allow keeping backward migration support if we preserve the semantics of current
map_irqsomewhere - to keep the chance of calculating the legacy values for vmsave as well.Jan
We don't need to preserve it, right? We can calculate it before savevm.
Quoted 3 lines
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 107 lines · Michael S. Tsirkin
Quoted 34 lines · Jan Kiszka
Quoted 33 lines · Michael S. Tsirkin
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
Quoted 4 lines
Quoted 2 lines
So we'll just have
PIIX_NUM_PIC_IRQSentries there and useirq_countinstead of thepic_levelsbitmap.Just that this affects generic PCI code, not only PIIX-specific things.
Yes but it's not a problem -
pci_bus_irqssets the map function and nirqs.Quoted 2 lines
And that we need to save/restore some
irq_countfield according to the old semantics.Well, it's a bug: this is redundant info we should not have exposed it.
Quoted 8 lines
Quoted 2 lines
Anyway, let's make the rest work properly and cleanly first, add a FIXME for now, then we'll find a hack making it work for migration.
It remains non-trivial: I got your patch working (a minor init issue), but yet without changing the number of IRQs for PIIX3, so keeping the
irq_countsemantics for this host bridge.Now I'm facing three possibilities of how to proceed:
They all look OK I think :) Some comments below.
Quoted 7 lines
1. Give up on the (currently broken) feature to write a vmstate for older QEMU versions.
This will allow to declare the
irq_countfield invmstate_pcibusunused, and we would have to restore it on vmload step-wise via the PCI devices. It would also allow to change its semantics for PIIX3, mapping directly to PIC IRQs.Quoted 6 lines
Quoted 2 lines
I think that's okay too simply because these things are usually easy to fix after the fact when the rest of the issues are addressed.
Don't get what you mean with "fixed". If we fix the vmstate generation in making it backward-compatible again, we enter option 2. Option 1 is explicitly about giving this up.
What I really mean is I think I see how 2 can be added without much pain. So let's focus on 1 for now and worst case we break migration.
Quoted 38 lines
Quoted 13 lines
Quoted 12 lines
2. Keep writing a legacy
irq_countfield.This will require quite a few new APIs so that host bridges that want to change their nirq can still generate a compatible
irq_countvmstate field. Namely:
- A function to set upvmstate_irq_countand define a callback that the core will invoke to prepare thevmstate_irq_countbefore vmsave.
- A function to obtain the IRQ mapping /without/ the final host bridge step. This is required so that the callback above can calculate the old state like in the PIIX3 case.Quoted 3 lines
Does this really need to be so complex? It seems that we just need
pci_get_irq_count(bus, irq)which can use the existingmap_irqAPI, no? Then invoke that before save.No, because the new
map_irqof the PIIX3 bridge will also include the host bridge routing (or masking) according to the PIRQx routoing registers of the PIIX3. Moreover, the fixup of the written legacyirq_countstate has to happen in the PCI layer, which therefore has to query the host bridge for fixup information, not the other way around (because the PCI bus vmstate is separate from the PIIX3 host bridge).Quoted 9 lines
Quoted 7 lines
3. Keep
irq_countand nirq as is, introduce additionalmap_host_irq.This is simpler than 2 and more compatible than 1. It would also allow to introduce the polarity and masking information more smoothly as we won't have to add it to existing
map_irqcallbacks then.So what does it map, and to what?
PCI bus IRQ to *host* IRQ. It is supposed to explore the routing of the host bridge between the root bus and the host's interrupt controller (i.e. the step that is currently missing the cached chain).
Quoted 6 lines
Quoted 1 line
Maybe we can make the name imply that somehow.
Better suggestions for this handler and maybe also the existing
map_irqare welcome to make the difference clearer.Jan
So I won't object to adding a new API but if we do it properly this won't help compatibility :(
Let's formulate what these do exactly, this will
also help us come up with sensible names.1. The difference is that pci bridges route interrupt pins. So it gets interrupt pin on device and returns interrupt pin on connector. All attributes are standard PCI. We should remove all mentions of "irq" really.
2. The pci root (yes it's a host bridge but let's not use the term host if we can) routes
an interrupt pin on device to a host irq. It can also do more things like invert polarity.
Quoted 6 lines
So yes we can add 2 to piix but we really should
remove 1 from it.Wrt names - do you object to long names?
How aboutroute_interrupt_pinfor 1
androute_interrupt_pin_to_irqfor 2?
A small clarification.
What I tried to say above is that pci bus does not route irqs. pci bridge routes irqs: either host or pci to pci bridge.
But as long as we thought the functionality is roughly the same it made sense to say that bus has this function simply because both bridge types have a bus.
But if not then the clean thing is a callback in p2p bridge and another one in a host bridge. Having both these and one in the bus looks weird.
Quoted 3 lines
Quoted 3 lines
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · Jan Kiszka
Quoted 9 lines · Michael S. Tsirkin
Quoted 5 lines
Quoted 2 lines
So I won't object to adding a new API but if we do it properly this won't help compatibility :(
It will as this API does not touch the parts that affect the vmstate (ie. semantics of
irq_countwon't change).Yes but
irq_countin vmstate is a bug. IMO even if we do not change anything we should ignoreirq_counton load and recalculate it from what the devices supply.
Quoted 8 lines
Quoted 5 lines
I don't disagree. But this will only allow keeping backward migration support if we preserve the semantics of current
map_irqsomewhere - to keep the chance of calculating the legacy values for vmsave as well.Jan
We don't need to preserve it, right? We can calculate it before savevm.
We can't calculate it without something like the additional infrastructure I listed.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux