From patchwork Mon Jun 27 14:47:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 641090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rdXVl5D5Mz9sp7 for ; Tue, 28 Jun 2016 01:12:47 +1000 (AEST) Received: from localhost ([::1]:59243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHYDN-0002rO-Jh for incoming@patchwork.ozlabs.org; Mon, 27 Jun 2016 11:12:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHXpZ-0006Zr-Lf for qemu-devel@nongnu.org; Mon, 27 Jun 2016 10:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHXpV-0000M0-EW for qemu-devel@nongnu.org; Mon, 27 Jun 2016 10:48:08 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:4428 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHXpU-0000J1-Vb for qemu-devel@nongnu.org; Mon, 27 Jun 2016 10:48:05 -0400 Received: from irbis.sw.ru ([10.24.38.119]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id u5RElnUL018065; Mon, 27 Jun 2016 17:47:57 +0300 (MSK) From: "Denis V. Lunev" To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Mon, 27 Jun 2016 17:47:48 +0300 Message-Id: <1467038869-11538-3-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1467038869-11538-1-git-send-email-den@openvz.org> References: <1467038869-11538-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH v4 2/3] ide: ignore retry_unit check for non-retry operation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , Evgeny Yakovlev , Max Reitz , Stefan Hajnoczi , den@openvz.org, John Snow Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Evgeny Yakovlev The following sequence of tests discovered a problem in IDE emulation: 1. Send DMA write to IDE device 0 2. Send CMD_FLUSH_CACHE to same IDE device which will be failed by block layer using blkdebug script in tests/ide-test:test_retry_flush When doing DMA request ide/core.c will set s->retry_unit to s->unit in ide_start_dma. When dma completes ide_set_inactive sets retry_unit to -1. After that ide_flush_cache runs and fails thanks to blkdebug. ide_flush_cb calls ide_handle_rw_error which asserts that s->retry_unit == s->unit. But s->retry_unit is still -1 after previous DMA completion and flush does not use anything related to retry. This patch restricts retry unit assertion only to ops that actually use retry logic. Signed-off-by: Evgeny Yakovlev Signed-off-by: Denis V. Lunev CC: Kevin Wolf CC: Max Reitz CC: Stefan Hajnoczi CC: Fam Zheng CC: John Snow --- hw/ide/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 029f6b9..17f884b 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -779,7 +779,8 @@ int ide_handle_rw_error(IDEState *s, int error, int op) BlockErrorAction action = blk_get_error_action(s->blk, is_read, error); if (action == BLOCK_ERROR_ACTION_STOP) { - assert(s->bus->retry_unit == s->unit); + assert(!(IS_IDE_RETRY_DMA(op) || IS_IDE_RETRY_PIO(op)) + || s->bus->retry_unit == s->unit); s->bus->error_status = op; } else if (action == BLOCK_ERROR_ACTION_REPORT) { block_acct_failed(blk_get_stats(s->blk), &s->acct);