* [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge
@ 2012-03-19 15:29 Jan Kiszka
2012-03-19 15:29 ` [PATCH 1/5] qemu-kvm: i8254/pcspk: Remove unused bits to make PC speaker kvm-aware Jan Kiszka
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Jan Kiszka @ 2012-03-19 15:29 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm
Some preparation patches to arrange qemu-kvm for merging in latest qemu
with its own in-kernel PIT support. Later on, we can switch to that
version without losing features on the way, even just temporarily.
Jan Kiszka (5):
qemu-kvm: i8254/pcspk: Remove unused bits to make PC speaker
kvm-aware
qemu-kvm: i8254: Reset broken pit_load_old to upstream version
qemu-kvm: i8254: Revert pit_load_count to upstream version
qemu-kvm: i8254: Drop bogus irq_disabled clearing in pit_reset
qemu-kvm: i8254: Reorganize i8254-kvm code
Makefile.objs | 2 +-
Makefile.target | 5 +-
hw/i8254-kvm.c | 12 ++----
hw/i8254.c | 112 ++++++++++++++++++++++++-------------------------------
hw/i8254.h | 49 +-----------------------
hw/pcspk.c | 6 ---
6 files changed, 58 insertions(+), 128 deletions(-)
--
1.7.3.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] qemu-kvm: i8254/pcspk: Remove unused bits to make PC speaker kvm-aware
2012-03-19 15:29 [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Jan Kiszka
@ 2012-03-19 15:29 ` Jan Kiszka
2012-03-19 15:29 ` [PATCH 2/5] qemu-kvm: i8254: Reset broken pit_load_old to upstream version Jan Kiszka
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2012-03-19 15:29 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm
Due to old-style-only creation of the in-kernel PIT (became broken long
ago during refactorings), the kernel always handled the speaker port in
qemu-kvm for a long while. Thus all bits that try to make the user space
speaker emulating kvm-aware are actually unused. Upstream will come with
fully-working speaker emulation even while the in-kernel PIT is enabled,
so let's drop the dead bits from qemu-kvm to ease merging with upstream.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
Makefile.objs | 2 +-
Makefile.target | 4 ++--
hw/i8254.c | 44 --------------------------------------------
hw/pcspk.c | 6 ------
4 files changed, 3 insertions(+), 53 deletions(-)
diff --git a/Makefile.objs b/Makefile.objs
index c33c0f2..39791ac 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -212,7 +212,7 @@ hw-obj-$(CONFIG_SERIAL) += serial.o
hw-obj-$(CONFIG_PARALLEL) += parallel.o
# Moved back to Makefile.target due to #include qemu-kvm.h:
#hw-obj-$(CONFIG_I8254) += i8254.o
-#hw-obj-$(CONFIG_PCSPK) += pcspk.o
+hw-obj-$(CONFIG_PCSPK) += pcspk.o
hw-obj-$(CONFIG_PCKBD) += pckbd.o
hw-obj-$(CONFIG_USB_UHCI) += usb-uhci.o
hw-obj-$(CONFIG_USB_OHCI) += usb-ohci.o
diff --git a/Makefile.target b/Makefile.target
index ae04331..5f6b963 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -250,7 +250,7 @@ obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o
obj-i386-y += testdev.o
obj-i386-y += acpi.o acpi_piix4.o
-obj-i386-y += pcspk.o i8254.o
+obj-i386-y += i8254.o
obj-i386-$(CONFIG_KVM_PIT) += i8254-kvm.o
obj-i386-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
@@ -308,7 +308,7 @@ obj-lm32-y += milkymist-vgafb.o
obj-lm32-y += framebuffer.o
obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
-obj-mips-y += pcspk.o i8254.o
+obj-mips-y += i8254.o
obj-mips-y += acpi.o acpi_piix4.o
obj-mips-y += mips_addr.o mips_timer.o mips_int.o
obj-mips-y += gt64xxx.o mc146818rtc.o
diff --git a/hw/i8254.c b/hw/i8254.c
index 33d94e1..8925139 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -176,55 +176,11 @@ void pit_set_gate(ISADevice *dev, int channel, int val)
s->gate = val;
}
-#ifdef CONFIG_KVM_PIT
-static void kvm_get_pit_ch2(ISADevice *dev,
- struct kvm_pit_state *inkernel_state)
-{
- struct PITState *pit = DO_UPCAST(struct PITState, dev, dev);
- struct kvm_pit_state pit_state;
-
- if (kvm_enabled() && kvm_irqchip_in_kernel()) {
- kvm_get_pit(kvm_state, &pit_state);
- pit->channels[2].mode = pit_state.channels[2].mode;
- pit->channels[2].count = pit_state.channels[2].count;
- pit->channels[2].count_load_time = pit_state.channels[2].count_load_time;
- pit->channels[2].gate = pit_state.channels[2].gate;
- if (inkernel_state) {
- memcpy(inkernel_state, &pit_state, sizeof(*inkernel_state));
- }
- }
-}
-
-#if 0
-static void kvm_set_pit_ch2(ISADevice *dev,
- struct kvm_pit_state *inkernel_state)
-{
- struct PITState *pit = DO_UPCAST(struct PITState, dev, dev);
-
- if (kvm_enabled() && kvm_irqchip_in_kernel()) {
- inkernel_state->channels[2].mode = pit->channels[2].mode;
- inkernel_state->channels[2].count = pit->channels[2].count;
- inkernel_state->channels[2].count_load_time =
- pit->channels[2].count_load_time;
- inkernel_state->channels[2].gate = pit->channels[2].gate;
- kvm_set_pit(kvm_state, inkernel_state);
- }
-}
-#endif
-#else
-static inline void kvm_get_pit_ch2(ISADevice *dev,
- struct kvm_pit_state *inkernel_state) { }
-static inline void kvm_set_pit_ch2(ISADevice *dev,
- struct kvm_pit_state *inkernel_state) { }
-#endif
-
void pit_get_channel_info(ISADevice *dev, int channel, PITChannelInfo *info)
{
PITState *pit = DO_UPCAST(PITState, dev, dev);
PITChannelState *s = &pit->channels[channel];
- kvm_get_pit_ch2(dev, NULL);
-
info->gate = s->gate;
info->mode = s->mode;
info->initial_count = s->count;
diff --git a/hw/pcspk.c b/hw/pcspk.c
index bb25ffb..e430324 100644
--- a/hw/pcspk.c
+++ b/hw/pcspk.c
@@ -29,7 +29,6 @@
#include "qemu-timer.h"
#include "i8254.h"
#include "pcspk.h"
-#include "qemu-kvm.h"
#define PCSPK_BUF_LEN 1792
#define PCSPK_SAMPLE_RATE 32000
@@ -141,9 +140,6 @@ static void pcspk_io_write(void *opaque, target_phys_addr_t addr, uint64_t val,
{
PCSpkState *s = opaque;
const int gate = val & 1;
- PITChannelInfo ch;
-
- pit_get_channel_info(s->pit, 2, &ch);
s->data_on = (val >> 1) & 1;
pit_set_gate(s->pit, 2, gate);
@@ -152,8 +148,6 @@ static void pcspk_io_write(void *opaque, target_phys_addr_t addr, uint64_t val,
s->play_pos = 0;
AUD_set_active_out(s->voice, gate & s->data_on);
}
-
- /* kvm_set_pit_ch2(s->pit, &inkernel_state); ?? */
}
static const MemoryRegionOps pcspk_io_ops = {
--
1.7.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] qemu-kvm: i8254: Reset broken pit_load_old to upstream version
2012-03-19 15:29 [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Jan Kiszka
2012-03-19 15:29 ` [PATCH 1/5] qemu-kvm: i8254/pcspk: Remove unused bits to make PC speaker kvm-aware Jan Kiszka
@ 2012-03-19 15:29 ` Jan Kiszka
2012-03-19 15:29 ` [PATCH 3/5] qemu-kvm: i8254: Revert pit_load_count " Jan Kiszka
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2012-03-19 15:29 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm
pit_load_old is only called with version_id == 1, but
PIT_SAVEVM_VERSION is 2. So this function is broken in qemu_kvm for
ages, and also the dummy qemu_get_be32 is pointless. Revert to upstream.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/i8254.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/hw/i8254.c b/hw/i8254.c
index 8925139..7089832 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -390,10 +390,9 @@ static int pit_load_old(QEMUFile *f, void *opaque, int version_id)
PITChannelState *s;
int i;
- if (version_id != PIT_SAVEVM_VERSION)
+ if (version_id != 1)
return -EINVAL;
- (void)qemu_get_be32(f);
for(i = 0; i < 3; i++) {
s = &pit->channels[i];
s->count=qemu_get_be32(f);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] qemu-kvm: i8254: Revert pit_load_count to upstream version
2012-03-19 15:29 [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Jan Kiszka
2012-03-19 15:29 ` [PATCH 1/5] qemu-kvm: i8254/pcspk: Remove unused bits to make PC speaker kvm-aware Jan Kiszka
2012-03-19 15:29 ` [PATCH 2/5] qemu-kvm: i8254: Reset broken pit_load_old to upstream version Jan Kiszka
@ 2012-03-19 15:29 ` Jan Kiszka
2012-03-19 15:29 ` [PATCH 4/5] qemu-kvm: i8254: Drop bogus irq_disabled clearing in pit_reset Jan Kiszka
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2012-03-19 15:29 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm
pit_irq_timer_update now checks generically if a channel IRQ is
disabled, so we can drop the hacks from qemu-kvm.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/i8254.c | 19 +++++++------------
1 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/hw/i8254.c b/hw/i8254.c
index 7089832..befad05 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -187,18 +187,13 @@ void pit_get_channel_info(ISADevice *dev, int channel, PITChannelInfo *info)
info->out = pit_get_out(s, qemu_get_clock_ns(vm_clock));
}
-static inline void pit_load_count(PITState *s, int val, int chan)
+static inline void pit_load_count(PITChannelState *s, int val)
{
if (val == 0)
val = 0x10000;
- s->channels[chan].count_load_time = qemu_get_clock_ns(vm_clock);
- s->channels[chan].count = val;
-#ifdef TARGET_I386
- if (chan == 0 && s->channels[0].irq_disabled) {
- return;
- }
-#endif
- pit_irq_timer_update(&s->channels[chan], s->channels[chan].count_load_time);
+ s->count_load_time = qemu_get_clock_ns(vm_clock);
+ s->count = val;
+ pit_irq_timer_update(s, s->count_load_time);
}
/* if already latched, do not latch again */
@@ -260,17 +255,17 @@ static void pit_ioport_write(void *opaque, uint32_t addr, uint32_t val)
switch(s->write_state) {
default:
case RW_STATE_LSB:
- pit_load_count(pit, val, addr);
+ pit_load_count(s, val);
break;
case RW_STATE_MSB:
- pit_load_count(pit, val << 8, addr);
+ pit_load_count(s, val << 8);
break;
case RW_STATE_WORD0:
s->write_latch = val;
s->write_state = RW_STATE_WORD1;
break;
case RW_STATE_WORD1:
- pit_load_count(pit, s->write_latch | (val << 8), addr);
+ pit_load_count(s, s->write_latch | (val << 8));
s->write_state = RW_STATE_WORD0;
break;
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] qemu-kvm: i8254: Drop bogus irq_disabled clearing in pit_reset
2012-03-19 15:29 [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Jan Kiszka
` (2 preceding siblings ...)
2012-03-19 15:29 ` [PATCH 3/5] qemu-kvm: i8254: Revert pit_load_count " Jan Kiszka
@ 2012-03-19 15:29 ` Jan Kiszka
2012-03-19 15:29 ` [PATCH 5/5] qemu-kvm: i8254: Reorganize i8254-kvm code Jan Kiszka
2012-03-21 13:12 ` [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Avi Kivity
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2012-03-19 15:29 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm
The IRQ output line is reset along with the HPET (via signaling a new
state on the corresponding GPIO line), not the PIT itself.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/i8254.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/hw/i8254.c b/hw/i8254.c
index befad05..ca24ab9 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -432,9 +432,6 @@ static void pit_reset(DeviceState *dev)
PITChannelState *s;
int i;
-#ifdef TARGET_I386
- pit->channels[0].irq_disabled = 0;
-#endif
for(i = 0;i < 3; i++) {
s = &pit->channels[i];
s->mode = 3;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] qemu-kvm: i8254: Reorganize i8254-kvm code
2012-03-19 15:29 [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Jan Kiszka
` (3 preceding siblings ...)
2012-03-19 15:29 ` [PATCH 4/5] qemu-kvm: i8254: Drop bogus irq_disabled clearing in pit_reset Jan Kiszka
@ 2012-03-19 15:29 ` Jan Kiszka
2012-03-21 13:12 ` [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Avi Kivity
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2012-03-19 15:29 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm
Include i8254-kvm.c instead of building it as a separate module. This
allows to reduce the diff to upstream and will help with merging the
latter.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
Makefile.target | 1 -
hw/i8254-kvm.c | 12 ++++--------
hw/i8254.c | 43 +++++++++++++++++++++++++++++++++++++++++--
hw/i8254.h | 49 ++-----------------------------------------------
4 files changed, 47 insertions(+), 58 deletions(-)
diff --git a/Makefile.target b/Makefile.target
index 5f6b963..24386a4 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -251,7 +251,6 @@ obj-i386-y += testdev.o
obj-i386-y += acpi.o acpi_piix4.o
obj-i386-y += i8254.o
-obj-i386-$(CONFIG_KVM_PIT) += i8254-kvm.o
obj-i386-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
# shared objects
diff --git a/hw/i8254-kvm.c b/hw/i8254-kvm.c
index 7316111..e2aa4d6 100644
--- a/hw/i8254-kvm.c
+++ b/hw/i8254-kvm.c
@@ -21,14 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "hw.h"
-#include "pc.h"
-#include "isa.h"
-#include "qemu-timer.h"
-#include "i8254.h"
-#include "qemu-kvm.h"
-extern VMStateDescription vmstate_pit;
+#ifdef CONFIG_KVM_PIT
static void kvm_pit_pre_save(void *opaque)
{
@@ -103,7 +97,7 @@ static void dummy_timer(void *opaque)
{
}
-void kvm_pit_init(PITState *pit)
+static void qemu_kvm_pit_init(PITState *pit)
{
PITChannelState *s;
@@ -116,3 +110,5 @@ void kvm_pit_init(PITState *pit)
vmstate_pit.post_load = kvm_pit_post_load;
return;
}
+
+#endif
diff --git a/hw/i8254.c b/hw/i8254.c
index ca24ab9..a8e20cb 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -30,8 +30,45 @@
//#define DEBUG_PIT
+#define RW_STATE_LSB 1
+#define RW_STATE_MSB 2
+#define RW_STATE_WORD0 3
+#define RW_STATE_WORD1 4
+
+typedef struct PITChannelState {
+ int count; /* can be 65536 */
+ uint16_t latched_count;
+ uint8_t count_latched;
+ uint8_t status_latched;
+ uint8_t status;
+ uint8_t read_state;
+ uint8_t write_state;
+ uint8_t write_latch;
+ uint8_t rw_mode;
+ uint8_t mode;
+ uint8_t bcd; /* not supported */
+ uint8_t gate; /* timer start */
+ int64_t count_load_time;
+ /* irq handling */
+ int64_t next_transition_time;
+ QEMUTimer *irq_timer;
+ qemu_irq irq;
+ uint32_t irq_disabled;
+} PITChannelState;
+
+typedef struct PITState {
+ ISADevice dev;
+ MemoryRegion ioports;
+ uint32_t iobase;
+ PITChannelState channels[3];
+} PITState;
+
static void pit_irq_timer_update(PITChannelState *s, int64_t current_time);
+#ifdef CONFIG_KVM_PIT
+static void qemu_kvm_pit_init(PITState *pit);
+#endif
+
static int pit_get_count(PITChannelState *s)
{
uint64_t d;
@@ -412,7 +449,7 @@ static int pit_load_old(QEMUFile *f, void *opaque, int version_id)
return 0;
}
-VMStateDescription vmstate_pit = {
+static VMStateDescription vmstate_pit = {
.name = "i8254",
.version_id = 3,
.minimum_version_id = 2,
@@ -482,7 +519,7 @@ static int pit_initfn(ISADevice *dev)
#ifdef CONFIG_KVM_PIT
if (kvm_enabled() && kvm_irqchip_in_kernel()) {
- kvm_pit_init(pit);
+ qemu_kvm_pit_init(pit);
return 0;
}
#endif
@@ -531,3 +568,5 @@ static void pit_register_types(void)
}
type_init(pit_register_types)
+
+#include "i8254-kvm.c"
diff --git a/hw/i8254.h b/hw/i8254.h
index 3313662..47b2570 100644
--- a/hw/i8254.h
+++ b/hw/i8254.h
@@ -25,55 +25,10 @@
#ifndef HW_I8254_H
#define HW_I8254_H
+#include "hw.h"
+#include "isa.h"
#include "kvm.h"
-#define PIT_SAVEVM_NAME "i8254"
-#define PIT_SAVEVM_VERSION 2
-
-#define RW_STATE_LSB 1
-#define RW_STATE_MSB 2
-#define RW_STATE_WORD0 3
-#define RW_STATE_WORD1 4
-
-#define PIT_FLAGS_HPET_LEGACY 1
-
-typedef struct PITChannelState {
- int count; /* can be 65536 */
- uint16_t latched_count;
- uint8_t count_latched;
- uint8_t status_latched;
- uint8_t status;
- uint8_t read_state;
- uint8_t write_state;
- uint8_t write_latch;
- uint8_t rw_mode;
- uint8_t mode;
- uint8_t bcd; /* not supported */
- uint8_t gate; /* timer start */
- int64_t count_load_time;
- /* irq handling */
- int64_t next_transition_time;
- QEMUTimer *irq_timer;
- qemu_irq irq;
- uint32_t irq_disabled;
-} PITChannelState;
-
-struct PITState {
- ISADevice dev;
- MemoryRegion ioports;
- uint32_t iobase;
- PITChannelState channels[3];
-};
-
-void pit_save(QEMUFile *f, void *opaque);
-
-int pit_load(QEMUFile *f, void *opaque, int version_id);
-
-typedef struct PITState PITState;
-
-/* i8254-kvm.c */
-void kvm_pit_init(PITState *pit);
-
#define PIT_FREQ 1193182
typedef struct PITChannelInfo {
--
1.7.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge
2012-03-19 15:29 [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Jan Kiszka
` (4 preceding siblings ...)
2012-03-19 15:29 ` [PATCH 5/5] qemu-kvm: i8254: Reorganize i8254-kvm code Jan Kiszka
@ 2012-03-21 13:12 ` Avi Kivity
5 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2012-03-21 13:12 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Marcelo Tosatti, kvm
On 03/19/2012 05:29 PM, Jan Kiszka wrote:
> Some preparation patches to arrange qemu-kvm for merging in latest qemu
> with its own in-kernel PIT support. Later on, we can switch to that
> version without losing features on the way, even just temporarily.
>
Thanks, applied.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-03-21 13:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-19 15:29 [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Jan Kiszka
2012-03-19 15:29 ` [PATCH 1/5] qemu-kvm: i8254/pcspk: Remove unused bits to make PC speaker kvm-aware Jan Kiszka
2012-03-19 15:29 ` [PATCH 2/5] qemu-kvm: i8254: Reset broken pit_load_old to upstream version Jan Kiszka
2012-03-19 15:29 ` [PATCH 3/5] qemu-kvm: i8254: Revert pit_load_count " Jan Kiszka
2012-03-19 15:29 ` [PATCH 4/5] qemu-kvm: i8254: Drop bogus irq_disabled clearing in pit_reset Jan Kiszka
2012-03-19 15:29 ` [PATCH 5/5] qemu-kvm: i8254: Reorganize i8254-kvm code Jan Kiszka
2012-03-21 13:12 ` [PATCH 0/5] qemu-kvm: Prepare kvm PIT for upstream merge Avi Kivity
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.