From nobody Wed Apr 16 17:27:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1612433348; cv=none; d=zohomail.com; s=zohoarc; b=TUKjLKEKd/iJ7ZGhkuSn5NTljGruVVZ5oKVlgi8sYNbfwfgKcSjX6hQwiOaD5CbakYkNHNEn0ygsOqtyxvq+HdWJ2IPoUT8+m/xxib3KC214Ch/whTNYkyqohY4hDoKX4CR4p5pg3rOVAt2uYRLnf19HtMapRDsIBwepv8Qs/Dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612433348; h=Content-Type: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; bh=R2Qvy19eJdC+602G2SjjJETx98iWAlmXaIyusGU/mUY=; b=RAGswSge+ekFlUYdmm3fmjJEwrx6D9C2EFO7T6o2BvXWo3rDfLwJo0e4YrQQkOeabdE2trgR1TB9GZFwAwEgT6yJo3TLIrE3ojfdeQuhbDFLBAL9Xp1acQfDZfVdLhhz4BoXj4dOL9bLd/n0SrBuFdctrV5tre3Von/RS/AtRNs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1612433348513379.9192930903745; Thu, 4 Feb 2021 02:09:08 -0800 (PST) Received: from localhost ([::1]:39524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7bZT-0006bC-Am for importer@patchew.org; Thu, 04 Feb 2021 05:09:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7bTr-0007Ex-12 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 05:03:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7bTl-0002FJ-QO for qemu-devel@nongnu.org; Thu, 04 Feb 2021 05:03:17 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-561-7Oymc28IMF6HzaD_nJIyvQ-1; Thu, 04 Feb 2021 05:03:09 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 84B9D8030B7; Thu, 4 Feb 2021 10:03:07 +0000 (UTC) Received: from localhost (ovpn-115-89.ams2.redhat.com [10.36.115.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0285F5D762; Thu, 4 Feb 2021 10:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612432993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R2Qvy19eJdC+602G2SjjJETx98iWAlmXaIyusGU/mUY=; b=DpWPFAaVZet1y2vxeRl+jYjcPns+mkDe+/vSx0mFb8MAWOw1TUklwT6rz1wnBJsxHe5x3W jUe2hhnB4nw6TD8bsWDoi9mqQ8hlPZjBI9e/D6ZogQ0KAqbix7xpW+4IyFamumuR9Vhp39 lyRgBWRgx0xbRUgYUoZVImqWdUSTG2I= X-MC-Unique: 7Oymc28IMF6HzaD_nJIyvQ-1 From: Stefan Hajnoczi To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 26/27] multi-process: perform device reset in the remote process Date: Thu, 4 Feb 2021 09:58:33 +0000 Message-Id: <20210204095834.345749-27-stefanha@redhat.com> In-Reply-To: <20210204095834.345749-1-stefanha@redhat.com> References: <20210204095834.345749-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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: Elena Ufimtseva , Fam Zheng , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , qemu-block@nongnu.org, John G Johnson , "Denis V. Lunev" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Wainer dos Santos Moschetta , Stefan Hajnoczi , Paolo Bonzini , Igor Mammedov , Jagannathan Raman , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Perform device reset in the remote process when QEMU performs device reset. This is required to reset the internal state (like registers, etc...) of emulated devices Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: Stefan Hajnoczi Message-id: 7cb220a51f565dc0817bd76e2f540e89c2d2b850.1611938319.git.jag.ram= an@oracle.com Signed-off-by: Stefan Hajnoczi --- include/hw/remote/mpqemu-link.h | 1 + hw/remote/message.c | 22 ++++++++++++++++++++++ hw/remote/proxy.c | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/include/hw/remote/mpqemu-link.h b/include/hw/remote/mpqemu-lin= k.h index 71d206f00e..4ec0915885 100644 --- a/include/hw/remote/mpqemu-link.h +++ b/include/hw/remote/mpqemu-link.h @@ -40,6 +40,7 @@ typedef enum { MPQEMU_CMD_BAR_WRITE, MPQEMU_CMD_BAR_READ, MPQEMU_CMD_SET_IRQFD, + MPQEMU_CMD_DEVICE_RESET, MPQEMU_CMD_MAX, } MPQemuCmd; =20 diff --git a/hw/remote/message.c b/hw/remote/message.c index adab040ca1..11d729845c 100644 --- a/hw/remote/message.c +++ b/hw/remote/message.c @@ -19,6 +19,7 @@ #include "exec/memattrs.h" #include "hw/remote/memory.h" #include "hw/remote/iohub.h" +#include "sysemu/reset.h" =20 static void process_config_write(QIOChannel *ioc, PCIDevice *dev, MPQemuMsg *msg, Error **errp); @@ -26,6 +27,8 @@ static void process_config_read(QIOChannel *ioc, PCIDevic= e *dev, MPQemuMsg *msg, Error **errp); static void process_bar_write(QIOChannel *ioc, MPQemuMsg *msg, Error **err= p); static void process_bar_read(QIOChannel *ioc, MPQemuMsg *msg, Error **errp= ); +static void process_device_reset_msg(QIOChannel *ioc, PCIDevice *dev, + Error **errp); =20 void coroutine_fn mpqemu_remote_msg_loop_co(void *data) { @@ -69,6 +72,9 @@ void coroutine_fn mpqemu_remote_msg_loop_co(void *data) case MPQEMU_CMD_SET_IRQFD: process_set_irqfd_msg(pci_dev, &msg); break; + case MPQEMU_CMD_DEVICE_RESET: + process_device_reset_msg(com->ioc, pci_dev, &local_err); + break; default: error_setg(&local_err, "Unknown command (%d) received for device %s" @@ -206,3 +212,19 @@ fail: getpid()); } } + +static void process_device_reset_msg(QIOChannel *ioc, PCIDevice *dev, + Error **errp) +{ + DeviceClass *dc =3D DEVICE_GET_CLASS(dev); + DeviceState *s =3D DEVICE(dev); + MPQemuMsg ret =3D { 0 }; + + if (dc->reset) { + dc->reset(s); + } + + ret.cmd =3D MPQEMU_CMD_RET; + + mpqemu_msg_send(&ret, ioc, errp); +} diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c index a082709881..4fa4be079d 100644 --- a/hw/remote/proxy.c +++ b/hw/remote/proxy.c @@ -26,6 +26,7 @@ #include "util/event_notifier-posix.c" =20 static void probe_pci_info(PCIDevice *dev, Error **errp); +static void proxy_device_reset(DeviceState *dev); =20 static void proxy_intx_update(PCIDevice *pci_dev) { @@ -202,6 +203,8 @@ static void pci_proxy_dev_class_init(ObjectClass *klass= , void *data) k->config_read =3D pci_proxy_read_config; k->config_write =3D pci_proxy_write_config; =20 + dc->reset =3D proxy_device_reset; + device_class_set_props(dc, proxy_properties); } =20 @@ -358,3 +361,19 @@ static void probe_pci_info(PCIDevice *dev, Error **err= p) } } } + +static void proxy_device_reset(DeviceState *dev) +{ + PCIProxyDev *pdev =3D PCI_PROXY_DEV(dev); + MPQemuMsg msg =3D { 0 }; + Error *local_err =3D NULL; + + msg.cmd =3D MPQEMU_CMD_DEVICE_RESET; + msg.size =3D 0; + + mpqemu_msg_send_and_await_reply(&msg, pdev, &local_err); + if (local_err) { + error_report_err(local_err); + } + +} --=20 2.29.2