From nobody Tue Feb 10 07:40:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1667948884; cv=none; d=zohomail.com; s=zohoarc; b=g4wqzGD1gwS6s37ymmNfwplyJRZWxKFp6fJeGSswUOEqB4+tRRM0voGATTZP9iUp+rlLMZHl0AWMra1EuIBLjcr706l73fZLF4dBetF1F9GkAimYZY5aTynnt4Bo1w2yjHPfAp+AEske5JOzjmJx3aIeOuFDpWyB9pUYcgt3UlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667948884; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=qGJT0K9hw0PUQvW5p2jfXfMpbDkwHMpTJCiR52y1Ylg=; b=WM2BgWoRN+7pioC67U77DSaKHJ6qLs/7orwEB7qXuL0qSdNfK2s//0Lt+JVH2z7TUPxF0qyPnhqMe/nW3CCwg6j4hD5v9FmXlu64Lca9psmSGOI8WlEfDZ77hsXMWrYgTBgrLGb3Y6Nb7bsVFmgH8seRy+2PY6gGF0gRySXyp5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667948884742691.7209573195921; Tue, 8 Nov 2022 15:08:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osXbl-000515-RC; Tue, 08 Nov 2022 18:02:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osXbf-0004wV-Va for qemu-devel@nongnu.org; Tue, 08 Nov 2022 18:02:12 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osXbY-0003gj-Jr for qemu-devel@nongnu.org; Tue, 08 Nov 2022 18:02:11 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A8MtnV9007240 for ; Tue, 8 Nov 2022 23:01:53 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kqyy18469-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 08 Nov 2022 23:01:52 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2A8LjK6a004437 for ; Tue, 8 Nov 2022 23:01:51 GMT Received: from bruckner.us.oracle.com (dhcp-10-65-143-202.vpn.oracle.com [10.65.143.202]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kpcq2k0b9-22 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 08 Nov 2022 23:01:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=corp-2022-7-12; bh=qGJT0K9hw0PUQvW5p2jfXfMpbDkwHMpTJCiR52y1Ylg=; b=ccPXFz208iRdXW8K6dw2kKh0KHC48TkWZia74KddjsAZYEWrZto7UjMgPMt0XHIl9Ruy 1sc4nBaF7E3ho2pmmvIGmtVT9Wt5PIoAsDQH4NuVdsyfRHZXHZcO5Qh9fQY2PfqgHPUN 5PcsHscdmFiZoemjQkJHuNY4YFtlE515j/MyVIk8JcLhCkGz3OZHqlcSMITwt8RF647c r8yKddIrD4DFjt3R4RQEL4pqKJQ9zHadZgevmSF9r21OS7yaVkEq2uNW/68s91DgEX7K BdTvymzNmmd299meVd+g8DAe0Y1KKdt20exEzY1voL/ypo/GF5VFVLsX9e+sKegY5nTq OA== From: John Johnson To: qemu-devel@nongnu.org Subject: [PATCH v1 21/24] vfio-user: pci reset Date: Tue, 8 Nov 2022 15:13:43 -0800 Message-Id: <04ef8f670f8f7b320831ef2f86479bcec403c0b2.1667542066.git.john.g.johnson@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-07_11,2022-11-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211080151 X-Proofpoint-GUID: pcwt2zYjTnyz9FAoul2PDC2uGWVPzI_0 X-Proofpoint-ORIG-GUID: pcwt2zYjTnyz9FAoul2PDC2uGWVPzI_0 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=205.220.177.32; envelope-from=john.g.johnson@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1667948885807100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message to tell the server to reset the device. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: John Levon --- hw/vfio/pci.c | 15 +++++++++++++++ hw/vfio/user.c | 12 ++++++++++++ hw/vfio/user.h | 1 + 3 files changed, 28 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 559b20d..005fcf8 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3829,6 +3829,20 @@ static void vfio_user_instance_finalize(Object *obj) } } =20 +static void vfio_user_pci_reset(DeviceState *dev) +{ + VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(dev); + VFIODevice *vbasedev =3D &vdev->vbasedev; + + vfio_pci_pre_reset(vdev); + + if (vbasedev->reset_works) { + vfio_user_reset(vbasedev->proxy); + } + + vfio_pci_post_reset(vdev); +} + static Property vfio_user_pci_dev_properties[] =3D { DEFINE_PROP_STRING("socket", VFIOUserPCIDevice, sock_name), DEFINE_PROP_BOOL("secure-dma", VFIOUserPCIDevice, secure_dma, false), @@ -3842,6 +3856,7 @@ static void vfio_user_pci_dev_class_init(ObjectClass = *klass, void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *pdc =3D PCI_DEVICE_CLASS(klass); =20 + dc->reset =3D vfio_user_pci_reset; device_class_set_props(dc, vfio_user_pci_dev_properties); dc->desc =3D "VFIO over socket PCI device assignment"; pdc->realize =3D vfio_user_pci_realize; diff --git a/hw/vfio/user.c b/hw/vfio/user.c index 56b3616..ddf9e13 100644 --- a/hw/vfio/user.c +++ b/hw/vfio/user.c @@ -1580,6 +1580,18 @@ static int vfio_user_region_write(VFIOProxy *proxy, = uint8_t index, off_t offset, return ret; } =20 +void vfio_user_reset(VFIOProxy *proxy) +{ + VFIOUserHdr msg; + + vfio_user_request_msg(&msg, VFIO_USER_DEVICE_RESET, sizeof(msg), 0); + + vfio_user_send_wait(proxy, &msg, NULL, 0, false); + if (msg.flags & VFIO_USER_ERROR) { + error_printf("reset reply error %d\n", msg.error_reply); + } +} + =20 /* * Socket-based io_ops diff --git a/hw/vfio/user.h b/hw/vfio/user.h index 18e3112..d88ffe5 100644 --- a/hw/vfio/user.h +++ b/hw/vfio/user.h @@ -96,6 +96,7 @@ int vfio_user_validate_version(VFIOProxy *proxy, Error **= errp); void vfio_user_send_reply(VFIOProxy *proxy, VFIOUserHdr *hdr, int size); void vfio_user_send_error(VFIOProxy *proxy, VFIOUserHdr *hdr, int error); void vfio_user_putfds(VFIOUserMsg *msg); +void vfio_user_reset(VFIOProxy *proxy); =20 extern VFIODevIO vfio_dev_io_sock; extern VFIOContIO vfio_cont_io_sock; --=20 1.8.3.1