From nobody Tue Apr 15 02:15:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562595670; cv=none; d=zoho.com; s=zohoarc; b=hvGXkE+UIF3l4jY/v4j662t8nO2HOF7u5GHoz/Dmzicn+OJhbODYk3BA/6UmFTEd06qZqc6/WWXCwJLKj9aQFpj/hogCvE/9EO9zRA9/K1kelbUjWIN8uSh/8gkSbfKoN9iJUgFxzukcxTMxlX14pmg7BZssQOJss8LNzzD095A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562595670; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9AOS3pTW12RP+LzbHbTvUUBO+MmutUoJLxRqdEm3FHM=; b=KQhd3vihO1Pd64tk9PPR8Hc8Ef9Gfe9590xEMSdoF8UwNfvbUiwxpC+lauoBAgeW+xItWPAkNwtPOZrOR88ELZibFELHUWtZkNyvfbNCWhWNjK0CpzVHgPcWoVoLIMZ+2olpQ84YcoYCMrEaaupRvnJNjVqcB6oZIPzN9cbfbu0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1562595670252939.1051160496257; Mon, 8 Jul 2019 07:21:10 -0700 (PDT) Received: from localhost ([::1]:42138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkUVx-0003zc-B0 for importer@patchew.org; Mon, 08 Jul 2019 10:21:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39910) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkUTc-0001po-Ol for qemu-devel@nongnu.org; Mon, 08 Jul 2019 10:18:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkUTb-0008V3-MJ for qemu-devel@nongnu.org; Mon, 08 Jul 2019 10:18:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39178) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hkUTZ-0008No-A1; Mon, 08 Jul 2019 10:18:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEF3730860AE; Mon, 8 Jul 2019 14:18:30 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-116-204.ams2.redhat.com [10.36.116.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98C092B18D; Mon, 8 Jul 2019 14:18:26 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 8 Jul 2019 16:18:09 +0200 Message-Id: <20190708141812.3974-4-kwolf@redhat.com> In-Reply-To: <20190708141812.3974-1-kwolf@redhat.com> References: <20190708141812.3974-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 08 Jul 2019 14:18:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/6] virtio-scsi: restart DMA after iothread X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi When the 'cont' command resumes guest execution the vm change state handlers are invoked. Unfortunately there is no explicit ordering between classic qemu_add_vm_change_state_handler() callbacks. When two layers of code both use vm change state handlers, we don't control which handler runs first. virtio-scsi with iothreads hits a deadlock when a failed SCSI command is restarted and completes before the iothread is re-initialized. This patch uses the new qdev_add_vm_change_state_handler() API to guarantee that virtio-scsi's virtio change state handler executes before the SCSI bus children. This way DMA is restarted after the iothread has re-initialized. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- hw/scsi/scsi-bus.c | 4 ++-- hw/virtio/virtio.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 196136a307..fdc3a0e4e0 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -207,8 +207,8 @@ static void scsi_qdev_realize(DeviceState *qdev, Error = **errp) error_propagate(errp, local_err); return; } - dev->vmsentry =3D qemu_add_vm_change_state_handler(scsi_dma_restart_cb, - dev); + dev->vmsentry =3D qdev_add_vm_change_state_handler(DEVICE(dev), + scsi_dma_restart_cb, dev); } =20 static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 18f9f4c372..a94ea18a9c 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2362,8 +2362,8 @@ void virtio_init(VirtIODevice *vdev, const char *name, } else { vdev->config =3D NULL; } - vdev->vmstate =3D qemu_add_vm_change_state_handler(virtio_vmstate_chan= ge, - vdev); + vdev->vmstate =3D qdev_add_vm_change_state_handler(DEVICE(vdev), + virtio_vmstate_change, vdev); vdev->device_endian =3D virtio_default_endian(); vdev->use_guest_notifier_mask =3D true; } --=20 2.20.1