hw/audio/intel-hda: Don't use device_legacy_reset()
cover hw/audio/intel-hda: Don't use device_legacy_reset()
This patchset removes a use of device_legacy_reset() from the intel-hda audio device, and removes a duplicated reset of the codec devices.
Currently the intel-hda device has a reset method which manually resets all the codecs by calling device_legacy_reset() on them. This means they get reset twice, once because child devices on a qbus get reset before the parent device's reset method is called, and then again because we're manually resetting them.
Patch 1 drops the manual reset call. To ensure that codecs are still reset when the guest does a reset via ICH6_GCTL_RESET we make that codepath call device_cold_reset() on the HDA device (which resets all the devices on the qbus as well as the device itself) instead of making a direct call to the reset function.
This is a slight ordering change because the (only) codec reset now happens before the controller registers etc are reset, rather than once before and then once after, but the codec reset function hda_audio_reset() doesn't care.
Patch 2 is a trivial cleanup I noticed while I was there.
The patchset has been tested with 'make check' and 'make check-avocado' (and a little bit of use of gdb to confirm that the reset functions still get called as expected).
thanks
-- PMM
Peter Maydell (2):
hw/audio/intel-hda: don't reset codecs twice
hw/audio/intel-hda: Drop unnecessary prototype
hw/audio/intel-hda.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 hw/audio/intel-hda: don't reset codecs twice
Currently the intel-hda device has a reset method which manually resets all the codecs by calling device_legacy_reset() on them. This means they get reset twice, once because child devices on a qbus get reset before the parent device's reset method is called, and then again because we're manually resetting them.
Drop the manual reset call, and ensure that codecs are still reset when the guest does a reset via ICH6_GCTL_RESET by using device_cold_reset() (which resets all the devices on the qbus as well as the device itself) instead of a direct call to the reset function.
This is a slight ordering change because the (only) codec reset now happens before the controller registers etc are reset, rather than once before and then once after, but the codec reset function hda_audio_reset() doesn't care.
This lets us drop a use of device_legacy_reset(), which is deprecated.
--- hw/audio/intel-hda.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/audio/intel-hda.c +1 -3
@@ -516,7 +516,7 @@ static void intel_hda_notify_codecs(IntelHDAState *d, uint32_t stream, bool runnstatic void intel_hda_set_g_ctl (IntelHDAState *d,const IntelHDAReg *reg,uint32_t old) {if ((d->g_ctl &ICH6_GCTL_RESET ) ==0 ) { -intel_hda_reset (DEVICE (d)); +device_cold_reset (DEVICE (d)); } }
@@ -1083,11 +1083,9 @@ static void intel_hda_reset(DeviceState *dev)intel_hda_regs_reset (d); d->wall_base_ns =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); -/* reset codecs */ QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) {DeviceState *qdev = kid->child; cdev =HDA_CODEC_DEVICE (qdev); -device_legacy_reset (DEVICE (cdev)); d->state_sts |= (1 << cdev->cad); }intel_hda_update_irq (d);
Signature · 1 line
2.25.1
Re: [PATCH 1/2] hw/audio/intel-hda: don't reset codecs twice
Quoted 16 lines · Peter Maydell
Currently the intel-hda device has a reset method which manually resets all the codecs by calling
device_legacy_reset()on them. This means they get reset twice, once because child devices on a qbus get reset before the parent device's reset method is called, and then again because we're manually resetting them.Drop the manual reset call, and ensure that codecs are still reset when the guest does a reset via
ICH6_GCTL_RESETby usingdevice_cold_reset()(which resets all the devices on the qbus as well as the device itself) instead of a direct call to the reset function.This is a slight ordering change because the (only) codec reset now happens before the controller registers etc are reset, rather than once before and then once after, but the codec reset function
hda_audio_reset()doesn't care.
Quoted 7 lines
This lets us drop a use of
device_legacy_reset(), which is deprecated.Signed-off-by Peter Maydell <[email protected]>--- hw/audio/intel-hda.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
PATCH 2/2 hw/audio/intel-hda: Drop unnecessary prototype
In reply to Peter MaydellThe only use of intel_hda_reset() is after its definition, so we don't need to separately declare its prototype at the top of the file; drop the unnecessary line.
--- hw/audio/intel-hda.c | 2 -- 1 file changed, 2 deletions(-)
hw/audio/intel-hda.c +0 -2
@@ -220,8 +220,6 @@ struct IntelHDAReg {void (*rhandler)(IntelHDAState *d,const IntelHDAReg *reg); }; -static void intel_hda_reset (DeviceState *dev); -/* --------------------------------------------------------------------- */ static hwaddr intel_hda_addr (uint32_t lbase,uint32_t ubase)
Signature · 1 line
2.25.1
Re: [PATCH 2/2] hw/audio/intel-hda: Drop unnecessary prototype
Quoted 8 lines · Peter Maydell
The only use of
intel_hda_reset()is after its definition, so we don't need to separately declare its prototype at the top of the file; drop the unnecessary line.Signed-off-by Peter Maydell <[email protected]>--- hw/audio/intel-hda.c | 2 -- 1 file changed, 2 deletions(-)