Skip to content

RFC atapi: change unlimited recursion to while loop

Paolo Bonzini qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5ide: push call to end_transfer_func out of start_transfer callbackhw/ide/ahci.c hw/ide/core.c include/hw/ide/internal.h+13 -42 replies
2/5ide: push end_transfer callback to ide_transfer_halthw/ide/ahci.c hw/ide/core.c+9 -133 replies
3/5ide: do not set s->end_transfer_func to ide_transfer_cancelhw/ide/core.c+4 -51 reply
4/5atapi: call ide_set_irq before ide_transfer_starthw/ide/atapi.c+2 -22 replies
5/5ide: introduce ide_transfer_start_norecursehw/ide/atapi.c hw/ide/core.c include/hw/ide/internal.h+33 -200 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [Qemu-devel] [RFC PATCH 0/5] atapi: change unlimited recursion to while loop

Real hardware doesn't have an unlimited stack, so the unlimited recursion in the ATAPI code smells a bit. In fact, the call to ide_transfer_start easily becomes a tail call with a small change to the code (patch 4). The remaining four patches move code around so as to the turn the call back to ide_atapi_cmd_reply_end into another tail call, and then convert the (double) tail recursion into a while loop.

I'm not sure how this can be tested, apart from adding a READ CD test to ahci-test (which I don't really have time for now, hence the RFC tag). The existing AHCI tests still pass, so patches 1-3 aren't complete crap.

Paolo

Paolo Bonzini (5):
ide: push call to end_transfer_func out of start_transfer callback
ide: push end_transfer callback to ide_transfer_halt
ide: make ide_transfer_stop idempotent
atapi: call ide_set_irq before ide_transfer_start
ide: introduce ide_transfer_start_norecurse

 hw/ide/ahci.c             | 12 +++++++-----
 hw/ide/atapi.c            | 37 ++++++++++++++++++++-----------------
 hw/ide/core.c             | 37 +++++++++++++++++++++++--------------
 include/hw/ide/internal.h |  3 +++
 4 files changed, 53 insertions(+), 36 deletions(-)
Signature · 1 line
2.14.3