From nobody Sun May 5 12:23:30 2024 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; dkim=fail; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1567002363; cv=none; d=zoho.com; s=zohoarc; b=VLxYG1HM4W0kqhNTof+ybBOWXZkgXORn5ETENPvpuaa2v/ytlJWLQe4c6QmfDhXkkvvHuG+0tHEzROY8C+3P3AlwAJ4xUVdkEFJEpRIT7N1MLHNHAUZjX8K3GLCXRsoNPUqI62rjEQJZm3YFeb4MZMkjvPoXezYe3hCyW14gXU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567002363; 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=YfW1aH+Wpw10vSj+L0zxMi7E9GI7IXk5GtJx8ieye+k=; b=C6emaozPvXXkyOj4ZwMxekvD1M95KasJW3KRP5FW1vzr9WJWPi1NVST2N2YNJb0YTT+AF1C/YTuFU8lY29z+l7zeiwROmYWojj54sxil3jQ2BWL795yKrmlQDLZtURxYGcia4MvojQzvClQa9WeCl/qjmst7vyostH8VdzQ8CTo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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 1567002363489623.1606407221389; Wed, 28 Aug 2019 07:26:03 -0700 (PDT) Received: from localhost ([::1]:37040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2yte-0003e8-78 for importer@patchew.org; Wed, 28 Aug 2019 10:26:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54594) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2yrl-0002CH-RR for qemu-devel@nongnu.org; Wed, 28 Aug 2019 10:24:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2yrk-0000Wq-RH for qemu-devel@nongnu.org; Wed, 28 Aug 2019 10:24:05 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:37383) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2yrk-0000WN-M3 for qemu-devel@nongnu.org; Wed, 28 Aug 2019 10:24:04 -0400 Received: by mail-pl1-x643.google.com with SMTP id bj8so66669plb.4 for ; Wed, 28 Aug 2019 07:24:04 -0700 (PDT) Received: from beta.it.iitb.ac.in ([2405:204:2200:9180:9ba0:a3d7:637f:11ad]) by smtp.gmail.com with ESMTPSA id g1sm3180742pgg.27.2019.08.28.07.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 07:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YfW1aH+Wpw10vSj+L0zxMi7E9GI7IXk5GtJx8ieye+k=; b=SZoiTlBsARlRkWmePEB0YRUZKHm8vQQDlmJH5gHYiu/sdu+hv6jlgDj1r8+DNQoi/c 4M1tl4yh/xQzT5Sz/flSgtUX0wHF+ybmR3UkQ+lVINVGr/xSyG1EfuBuajblNNaWnxfK qnCukfXupBGasrzzGg16pa49yWEB7wQrutNrtgeR86J5BwfNRXBnb0vVcBpe5ouH69zj 9eih51sjy+z80+9J0jMbjEwEUoUbDZ/cd9lQenymiY+7jdudm4sGHQ7pfBUS5dQYetRb 0txZNfSvFLtGwaSahPd+ThILckkDodegm6NnoSkQ8Xy6QtcdQagwr0khGB7Z6ebnJwlF afvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YfW1aH+Wpw10vSj+L0zxMi7E9GI7IXk5GtJx8ieye+k=; b=VPrOxIUjQljh8XSMjwqs8zZAppXoP0IN3jfdF2+O0v76bZVXrJFtt7zRsFIOXAV/3R +gAzXqC35eSUIH+Ap1mDsQrPrV1urrBq63JzHygrDgRi/RpbQSwQzLqs14ew3Y/2x0aI ikrpoCQ8U7kVpZfCcuxP8OHqVEwCbUodXZYuJFdo8lzqsCbb84h6TJ8hF6XIldpZT01S DHgxjKKbhQIERDC/qmQBs1RVgBqsb1lcT6b8KyFrMCvPGNs8yDeWJz5H6l2gEP8SX/TW vwdCCJmEI4Xc31QxdrLVGEWvlS9t4W0f4dQMHwlvsY74g+pWM+sc9hbxkEexN297Osw2 En+w== X-Gm-Message-State: APjAAAVg4Cj4UiebYtMLVIlwGfavN6O+/Z3sQdIrMKO0kgnEBFlfIZuc Gd3neSXQ2hbG3JqL2AkVDeXaug0C X-Google-Smtp-Source: APXvYqy4OM4urpTGoQsfnlcBTVXhIO7v1ed9lwhWvJlBxFRMq0FJOx2RQAQQCN7yUSlpSxyZemLBeA== X-Received: by 2002:a17:902:1e8:: with SMTP id b95mr4658930plb.28.1567002243174; Wed, 28 Aug 2019 07:24:03 -0700 (PDT) From: Sukrit Bhatnagar To: qemu-devel@nongnu.org Date: Wed, 28 Aug 2019 19:53:27 +0530 Message-Id: <20190828142328.24561-2-skrtbhtngr@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190828142328.24561-1-skrtbhtngr@gmail.com> References: <20190828142328.24561-1-skrtbhtngr@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v1 1/2] hw/pvrdma: make DSR mapping idempotent in load_dsr() 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: Yuval Shaia 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" Map to DSR only when there is no mapping done already i.e., when dev->dsr_info.dsr is NULL. This allows the rest of mappings and ring inits to be done by calling load_dsr() when DSR has already been mapped to, somewhere else. Move free_dsr() out of load_dsr() and call it before the latter as and when needed. This aids the case where load_dsr() is called having DSR mapping already done, but the rest of map and init operations are pending, and prevents an unmap of the DSR. Cc: Marcel Apfelbaum Cc: Yuval Shaia Signed-off-by: Sukrit Bhatnagar Reviewed-by: Marcel Apfelbaum Reviewed-by: Yuval Shaia --- hw/rdma/vmw/pvrdma_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index adcf79cd63..6c90db96f9 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -172,15 +172,15 @@ static int load_dsr(PVRDMADev *dev) DSRInfo *dsr_info; struct pvrdma_device_shared_region *dsr; =20 - free_dsr(dev); - - /* Map to DSR */ - dev->dsr_info.dsr =3D rdma_pci_dma_map(pci_dev, dev->dsr_info.dma, - sizeof(struct pvrdma_device_shared_region)); if (!dev->dsr_info.dsr) { - rdma_error_report("Failed to map to DSR"); - rc =3D -ENOMEM; - goto out; + /* Map to DSR */ + dev->dsr_info.dsr =3D rdma_pci_dma_map(pci_dev, dev->dsr_info.dma, + sizeof(struct pvrdma_device_shared_regio= n)); + if (!dev->dsr_info.dsr) { + rdma_error_report("Failed to map to DSR"); + rc =3D -ENOMEM; + goto out; + } } =20 /* Shortcuts */ @@ -402,6 +402,7 @@ static void pvrdma_regs_write(void *opaque, hwaddr addr= , uint64_t val, case PVRDMA_REG_DSRHIGH: trace_pvrdma_regs_write(addr, val, "DSRHIGH", ""); dev->dsr_info.dma |=3D val << 32; + free_dsr(dev); load_dsr(dev); init_dsr_dev_caps(dev); break; --=20 2.21.0 From nobody Sun May 5 12:23:30 2024 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; dkim=fail; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1567002374; cv=none; d=zoho.com; s=zohoarc; b=OBawiG89smWsw30KHbAP6A24QkUxspvN/2/8XXXAo0guaG86UO/MhfU+Mxi/eL9LenzKH5k4AMb0Tkow6DmhOvtrHId5SaD1oG5yMFqK9kFpxFPvp0c8/dqKvOYhzFxT/VxxmLEXkYcjgstGODTq8SkoCcJws7lhjlu2DaGjfZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567002374; 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=o3w6rrLptWsFl8HE0mEgf9b9opUynwdbAv9zKRjY76s=; b=KeKorp9Ckq+eRNxaik2D6NQr76ZHga82lZ1yQ6mh55oRzXR/KZsJsSA7H2yPuNmC0gA+rDoKWDvvqvxaIUVEPIPu1e5rXroUbcvYaa5mpl59xqfvEvK1SlaVjtDsYxZgwBCwa7IDTVxE2TSM3Y4QPe8xnWTM84PQC9tMT17Mx9I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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 1567002374102362.1674116170602; Wed, 28 Aug 2019 07:26:14 -0700 (PDT) Received: from localhost ([::1]:37042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2yto-0003nP-PM for importer@patchew.org; Wed, 28 Aug 2019 10:26:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54630) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2yrp-0002G1-Ki for qemu-devel@nongnu.org; Wed, 28 Aug 2019 10:24:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2yro-0000aI-Hi for qemu-devel@nongnu.org; Wed, 28 Aug 2019 10:24:09 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:35513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2yro-0000a1-C8 for qemu-devel@nongnu.org; Wed, 28 Aug 2019 10:24:08 -0400 Received: by mail-pf1-x441.google.com with SMTP id d85so1848025pfd.2 for ; Wed, 28 Aug 2019 07:24:08 -0700 (PDT) Received: from beta.it.iitb.ac.in ([2405:204:2200:9180:9ba0:a3d7:637f:11ad]) by smtp.gmail.com with ESMTPSA id g1sm3180742pgg.27.2019.08.28.07.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 07:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o3w6rrLptWsFl8HE0mEgf9b9opUynwdbAv9zKRjY76s=; b=C1TOLL70Bbbrw4z3o1ggTJAQzG23iiFszFlaEpNvJOnfuijwHaOKAQJizlhLP7yXMV uiQgD59DzTxVm0qLTp/mAztp9DqowRF1/X+iTLQ9URxaKo490LZXvpw7es8nSszgSOGc fNqwwCCTT74dENmdJWl7urAmsxkrRkJPxIVHK/C3P7dzHRGFzxlEoqdfC48DabfwrW6o 2ec07kGoQeTj4G2vWX1MVw87jmDJY4Qjr1cmyiuGl33Iokjhd3GFhbfOewMYCRv5IQUg YRT+nFfKkIaGBtZ32TZvNyMlSLfatF0w6Z9f+3sDVMT70CmD9lcNUJF2146kPmS3HN3L xM8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o3w6rrLptWsFl8HE0mEgf9b9opUynwdbAv9zKRjY76s=; b=evea9kSEWToE2/GGw6hUXQSVUdOU1K14N7wwy4HD3+ugdZC4PeJGYU0L34S7R0ZjSG SzQZ37x1Ub73wOe8t8OiFEy6vg08jTLNFzrkeTAzbjsfTioqe9q8ZIMWz6tdpWmz6Qyo sFELyC7Pp65f3tTfd/uuEhKQBENSVx6A1uO0rihmysYM8epKpx2XlvqpdXme7Unh3QZU Z/9okRAVR1yzvn/PIsP/wwoChf0u89OXijmHs2z4w2rIaRGIKhTGGUcSe6fUH99i0tEL D07Jm/6NLw1YDyfM0o+2d5mpgJWR16oZ6NFZtxTma7wRVWr4717cgxqhx2bYu2QJVIgt IxHw== X-Gm-Message-State: APjAAAWXdo2mEYriyrhcTkaObc7ckeEzPJTvvKTrcith/nUaqPX6IVhs smeA6FfofaEs0pcEmxUzBuh7QNdb X-Google-Smtp-Source: APXvYqxofj04wFpXvYD02jC2e+JAxfMsCOOb6/4d6RsBUe96hbmN/BQoNLgHhZL8bTyvOZG2+I0gSw== X-Received: by 2002:a17:90a:6d43:: with SMTP id z61mr4607130pjj.32.1567002247071; Wed, 28 Aug 2019 07:24:07 -0700 (PDT) From: Sukrit Bhatnagar To: qemu-devel@nongnu.org Date: Wed, 28 Aug 2019 19:53:28 +0530 Message-Id: <20190828142328.24561-3-skrtbhtngr@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190828142328.24561-1-skrtbhtngr@gmail.com> References: <20190828142328.24561-1-skrtbhtngr@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v1 2/2] hw/pvrdma: add live migration support 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: Yuval Shaia 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" vmstate_pvrdma describes the PCI and MSIX states as well as the dma address for dsr and the gid table of device. vmstate_pvrdma_gids describes each gid in the gid table. pvrdma_post_save() does the job of unregistering gid entries from the backend device in the source host. pvrdma_post_load() maps to dsr using the loaded dma address, registers each loaded gid into the backend device, and finally calls load_dsr() to perform other mappings and ring init operations. Cc: Marcel Apfelbaum Cc: Yuval Shaia Signed-off-by: Sukrit Bhatnagar --- hw/rdma/vmw/pvrdma_main.c | 77 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index 6c90db96f9..6f8b56dea3 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -28,6 +28,7 @@ #include "sysemu/sysemu.h" #include "monitor/monitor.h" #include "hw/rdma/rdma.h" +#include "migration/register.h" =20 #include "../rdma_rm.h" #include "../rdma_backend.h" @@ -593,6 +594,81 @@ static void pvrdma_shutdown_notifier(Notifier *n, void= *opaque) pvrdma_fini(pci_dev); } =20 +static int pvrdma_post_save(void *opaque) +{ + int i, rc; + PVRDMADev *dev =3D opaque; + + for (i =3D 0; i < MAX_GIDS; i++) { + + if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) { + continue; + } + rc =3D rdma_backend_del_gid(&dev->backend_dev, + dev->backend_eth_device_name, + &dev->rdma_dev_res.port.gid_tbl[i].gid); + if (rc) { + return -EINVAL; + } + } + + return 0; +} + +static int pvrdma_post_load(void *opaque, int version_id) +{ + int i, rc; + PVRDMADev *dev =3D opaque; + PCIDevice *pci_dev =3D PCI_DEVICE(dev); + DSRInfo *dsr_info =3D &dev->dsr_info; + + dsr_info->dsr =3D rdma_pci_dma_map(pci_dev, dsr_info->dma, + sizeof(struct pvrdma_device_shared_region)= ); + if (!dsr_info->dsr) { + rdma_error_report("Failed to map to DSR"); + return -ENOMEM; + } + + for (i =3D 0; i < MAX_GIDS; i++) { + + if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) { + continue; + } + + rc =3D rdma_backend_add_gid(&dev->backend_dev, + dev->backend_eth_device_name, + &dev->rdma_dev_res.port.gid_tbl[i].gid); + if (rc) { + return -EINVAL; + } + } + + return load_dsr(dev); +} + +static const VMStateDescription vmstate_pvrdma_gids =3D { + .name =3D "pvrdma-gids", + .fields =3D (VMStateField[]) { + VMSTATE_UINT8_ARRAY_V(gid.raw, RdmaRmGid, 16, 0), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_pvrdma =3D { + .name =3D PVRDMA_HW_NAME, + .post_save =3D pvrdma_post_save, + .post_load =3D pvrdma_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_PCI_DEVICE(parent_obj, PVRDMADev), + VMSTATE_MSIX(parent_obj, PVRDMADev), + VMSTATE_UINT64(dsr_info.dma, PVRDMADev), + VMSTATE_STRUCT_ARRAY(rdma_dev_res.port.gid_tbl, PVRDMADev, + MAX_PORT_GIDS, 0, vmstate_pvrdma_gids, + RdmaRmGid), + VMSTATE_END_OF_LIST() + } +}; + static void pvrdma_realize(PCIDevice *pdev, Error **errp) { int rc =3D 0; @@ -688,6 +764,7 @@ static void pvrdma_class_init(ObjectClass *klass, void = *data) =20 dc->desc =3D "RDMA Device"; dc->props =3D pvrdma_dev_properties; + dc->vmsd =3D &vmstate_pvrdma; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); =20 ir->print_statistics =3D pvrdma_print_statistics; --=20 2.21.0