qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hw/timer/imx_gpt.c: Switch to transaction-based ptimer API

Switch the imx_epit.c code away from bottom-half based ptimers to
the new transaction-based ptimer API. This just requires adding
begin/commit calls around the various places that modify the ptimer
state, and using the new ptimer_init() function to create the timer.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20191008171740.9679-19-peter.maydell@linaro.org

+17 -4
+17 -4
hw/timer/imx_gpt.c
··· 16 16 #include "hw/irq.h" 17 17 #include "hw/timer/imx_gpt.h" 18 18 #include "migration/vmstate.h" 19 - #include "qemu/main-loop.h" 20 19 #include "qemu/module.h" 21 20 #include "qemu/log.h" 22 21 ··· 127 126 CLK_NONE, /* 111 not defined */ 128 127 }; 129 128 129 + /* Must be called from within ptimer_transaction_begin/commit block */ 130 130 static void imx_gpt_set_freq(IMXGPTState *s) 131 131 { 132 132 uint32_t clksrc = extract32(s->cr, GPT_CR_CLKSRC_SHIFT, 3); ··· 167 167 return timeout; 168 168 } 169 169 170 + /* Must be called from within ptimer_transaction_begin/commit block */ 170 171 static void imx_gpt_compute_next_timeout(IMXGPTState *s, bool event) 171 172 { 172 173 uint32_t timeout = GPT_TIMER_MAX; ··· 313 314 314 315 static void imx_gpt_reset_common(IMXGPTState *s, bool is_soft_reset) 315 316 { 317 + ptimer_transaction_begin(s->timer); 316 318 /* stop timer */ 317 319 ptimer_stop(s->timer); 318 320 ··· 350 352 if (s->freq && (s->cr & GPT_CR_EN)) { 351 353 ptimer_run(s->timer, 1); 352 354 } 355 + ptimer_transaction_commit(s->timer); 353 356 } 354 357 355 358 static void imx_gpt_soft_reset(DeviceState *dev) ··· 382 385 imx_gpt_soft_reset(DEVICE(s)); 383 386 } else { 384 387 /* set our freq, as the source might have changed */ 388 + ptimer_transaction_begin(s->timer); 385 389 imx_gpt_set_freq(s); 386 390 387 391 if ((oldreg ^ s->cr) & GPT_CR_EN) { ··· 397 401 ptimer_stop(s->timer); 398 402 } 399 403 } 404 + ptimer_transaction_commit(s->timer); 400 405 } 401 406 break; 402 407 403 408 case 1: /* Prescaler */ 404 409 s->pr = value & 0xfff; 410 + ptimer_transaction_begin(s->timer); 405 411 imx_gpt_set_freq(s); 412 + ptimer_transaction_commit(s->timer); 406 413 break; 407 414 408 415 case 2: /* SR */ ··· 414 421 s->ir = value & 0x3f; 415 422 imx_gpt_update_int(s); 416 423 424 + ptimer_transaction_begin(s->timer); 417 425 imx_gpt_compute_next_timeout(s, false); 426 + ptimer_transaction_commit(s->timer); 418 427 419 428 break; 420 429 421 430 case 4: /* OCR1 -- output compare register */ 422 431 s->ocr1 = value; 423 432 433 + ptimer_transaction_begin(s->timer); 424 434 /* In non-freerun mode, reset count when this register is written */ 425 435 if (!(s->cr & GPT_CR_FRR)) { 426 436 s->next_timeout = GPT_TIMER_MAX; ··· 429 439 430 440 /* compute the new timeout */ 431 441 imx_gpt_compute_next_timeout(s, false); 442 + ptimer_transaction_commit(s->timer); 432 443 433 444 break; 434 445 ··· 436 447 s->ocr2 = value; 437 448 438 449 /* compute the new timeout */ 450 + ptimer_transaction_begin(s->timer); 439 451 imx_gpt_compute_next_timeout(s, false); 452 + ptimer_transaction_commit(s->timer); 440 453 441 454 break; 442 455 ··· 444 457 s->ocr3 = value; 445 458 446 459 /* compute the new timeout */ 460 + ptimer_transaction_begin(s->timer); 447 461 imx_gpt_compute_next_timeout(s, false); 462 + ptimer_transaction_commit(s->timer); 448 463 449 464 break; 450 465 ··· 484 499 { 485 500 IMXGPTState *s = IMX_GPT(dev); 486 501 SysBusDevice *sbd = SYS_BUS_DEVICE(dev); 487 - QEMUBH *bh; 488 502 489 503 sysbus_init_irq(sbd, &s->irq); 490 504 memory_region_init_io(&s->iomem, OBJECT(s), &imx_gpt_ops, s, TYPE_IMX_GPT, 491 505 0x00001000); 492 506 sysbus_init_mmio(sbd, &s->iomem); 493 507 494 - bh = qemu_bh_new(imx_gpt_timeout, s); 495 - s->timer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT); 508 + s->timer = ptimer_init(imx_gpt_timeout, s, PTIMER_POLICY_DEFAULT); 496 509 } 497 510 498 511 static void imx_gpt_class_init(ObjectClass *klass, void *data)