Re: [Qemu-devel] [PATCH v6 07/11] intel-hda: change msi property type
On 06/01/2016 04:39 PM, Markus Armbruster wrote: Cao jinwrites: Not covered: static void intel_hda_update_irq(IntelHDAState *d) { -->int msi = d->msi && msi_enabled(>pci); int level; intel_hda_update_int_sts(d); if (d->int_sts & (1U << 31) && d->int_ctl & (1U << 31)) { level = 1; } else { level = 0; } dprint(d, 2, "%s: level %d [%s]\n", __FUNCTION__, level, msi ? "msi" : "intx"); if (msi) { if (level) { msi_notify(>pci, 0); } } else { pci_set_irq(>pci, level); } } This is wrong, because the meaning of the test changes from (user didn't specify msi=off) && (guest enabled MSI) to (user didn't specify msi=on or msi=off) && (guest enabled MSI) Thanks for pointing the error, seems I lost the fact that ON_OFF_AUTO_AUTO equals 0. What about: int msi = msi_enabled(>pci); If I understand it correctly, it can only be true when we added MSI capability, and we do that only when msi=auto (default) or msi=on. I think the modification is ok. -- Yours Sincerely, Cao jin
Re: [Qemu-devel] [PATCH v6 07/11] intel-hda: change msi property type
Cao jinwrites: >>From uint32 to enum OnOffAuto. > > cc: Gerd Hoffmann > cc: Michael S. Tsirkin > cc: Markus Armbruster > cc: Marcel Apfelbaum > > Signed-off-by: Cao jin > --- > hw/audio/intel-hda.c | 7 --- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c > index d372d4a..61362e5 100644 > --- a/hw/audio/intel-hda.c > +++ b/hw/audio/intel-hda.c > @@ -187,7 +187,7 @@ struct IntelHDAState { > > /* properties */ > uint32_t debug; > -uint32_t msi; > +OnOffAuto msi; I'm going to review all uses of this member. > bool old_msi_addr; > }; > > @@ -1142,7 +1142,8 @@ static void intel_hda_realize(PCIDevice *pci, Error > **errp) > memory_region_init_io(>mmio, OBJECT(d), _hda_mmio_ops, d, >"intel-hda", 0x4000); > pci_register_bar(>pci, 0, 0, >mmio); > -if (d->msi) { > +if (d->msi == ON_OFF_AUTO_AUTO || > +d->msi == ON_OFF_AUTO_ON) { > msi_init(>pci, d->old_msi_addr ? 0x50 : 0x60, 1, true, false); Same suggestions as for PATCH 06: * Use the d->msi != ON_OFF_AUTO_OFF * Add /* TODO check for errors */ now, drop it when you add the check in PATCH 11. > } > > @@ -1234,7 +1235,7 @@ static const VMStateDescription vmstate_intel_hda = { > > static Property intel_hda_properties[] = { > DEFINE_PROP_UINT32("debug", IntelHDAState, debug, 0), > -DEFINE_PROP_UINT32("msi", IntelHDAState, msi, 1), > +DEFINE_PROP_ON_OFF_AUTO("msi", IntelHDAState, msi, ON_OFF_AUTO_AUTO), > DEFINE_PROP_BOOL("old_msi_addr", IntelHDAState, old_msi_addr, false), > DEFINE_PROP_END_OF_LIST(), > }; Not covered: static void intel_hda_update_irq(IntelHDAState *d) { -->int msi = d->msi && msi_enabled(>pci); int level; intel_hda_update_int_sts(d); if (d->int_sts & (1U << 31) && d->int_ctl & (1U << 31)) { level = 1; } else { level = 0; } dprint(d, 2, "%s: level %d [%s]\n", __FUNCTION__, level, msi ? "msi" : "intx"); if (msi) { if (level) { msi_notify(>pci, 0); } } else { pci_set_irq(>pci, level); } } This is wrong, because the meaning of the test changes from (user didn't specify msi=off) && (guest enabled MSI) to (user didn't specify msi=on or msi=off) && (guest enabled MSI) What about: int msi = msi_enabled(>pci); If I understand it correctly, it can only be true when we added MSI capability, and we do that only when msi=auto (default) or msi=on.
[Qemu-devel] [PATCH v6 07/11] intel-hda: change msi property type
>From uint32 to enum OnOffAuto. cc: Gerd Hoffmanncc: Michael S. Tsirkin cc: Markus Armbruster cc: Marcel Apfelbaum Signed-off-by: Cao jin --- hw/audio/intel-hda.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index d372d4a..61362e5 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -187,7 +187,7 @@ struct IntelHDAState { /* properties */ uint32_t debug; -uint32_t msi; +OnOffAuto msi; bool old_msi_addr; }; @@ -1142,7 +1142,8 @@ static void intel_hda_realize(PCIDevice *pci, Error **errp) memory_region_init_io(>mmio, OBJECT(d), _hda_mmio_ops, d, "intel-hda", 0x4000); pci_register_bar(>pci, 0, 0, >mmio); -if (d->msi) { +if (d->msi == ON_OFF_AUTO_AUTO || +d->msi == ON_OFF_AUTO_ON) { msi_init(>pci, d->old_msi_addr ? 0x50 : 0x60, 1, true, false); } @@ -1234,7 +1235,7 @@ static const VMStateDescription vmstate_intel_hda = { static Property intel_hda_properties[] = { DEFINE_PROP_UINT32("debug", IntelHDAState, debug, 0), -DEFINE_PROP_UINT32("msi", IntelHDAState, msi, 1), +DEFINE_PROP_ON_OFF_AUTO("msi", IntelHDAState, msi, ON_OFF_AUTO_AUTO), DEFINE_PROP_BOOL("old_msi_addr", IntelHDAState, old_msi_addr, false), DEFINE_PROP_END_OF_LIST(), }; -- 2.1.0