From nobody Fri Nov 7 04:05:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545473337499971.2485877138473; Sat, 22 Dec 2018 02:08:57 -0800 (PST) Received: from localhost ([::1]:59574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaeDH-00036K-W7 for importer@patchew.org; Sat, 22 Dec 2018 05:08:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gadw9-0006Rj-2o for qemu-devel@nongnu.org; Sat, 22 Dec 2018 04:51:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gadw8-0006Z5-05 for qemu-devel@nongnu.org; Sat, 22 Dec 2018 04:51:13 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54152) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gadw7-0006Xx-97 for qemu-devel@nongnu.org; Sat, 22 Dec 2018 04:51:11 -0500 Received: by mail-wm1-x341.google.com with SMTP id d15so7372055wmb.3 for ; Sat, 22 Dec 2018 01:51:11 -0800 (PST) Received: from localhost.localdomain ([176.228.155.165]) by smtp.gmail.com with ESMTPSA id s3sm9557371wmj.23.2018.12.22.01.51.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Dec 2018 01:51:09 -0800 (PST) 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; bh=WF1jbwT1EVIB5mRe/xkEJebbweTWCBO5STWVa7iEoQk=; b=buSfzkeQG4b8fs0DYIHD7yLlHebeSy9EUB7WsVKHQw6HrlyahtMgJL6qCFqETwW2M9 c3MYew8iB9kxuz0dNaKSAMYs827HpcODpVOSKP2UHJXVwGgk4lVKM9bjvS1vzM1e8S9A d9j2r7m9VfMdMS28mANy218AzWNjz1IvgEGd4qJERrMKTC9t/DuOJlpChWfL8tuMPo7w L70HbcbRwf+W7XcoZB6p9N4O+hvxNaD4HrPdeu/FyN+K4gtZVLFM/0WVJ3S1/+brD3mF 6VCF13clg0yCMPKkroo9ycDcN6UmO+c5sdRN4PC7VramzBxe94pmEQH7qdSy+vdkkk5Q S6mA== 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; bh=WF1jbwT1EVIB5mRe/xkEJebbweTWCBO5STWVa7iEoQk=; b=f5ieBUmyJgqWC/OYY9YrdcB5pbo1AxJukgmGsjvee0Xh6A0o4yGF98n9nFhGGAqZbM 28LDzkZX+BswCjE068rqtwh/JZ16QkzL5C7wl7A0pCtLB00KKWjzthpEQ0JBnU+eBujc WgFOsssjMphTg7WTEmGPmfHNN6frbbLRAFgreBaSpa2Gi+ZOxYeSPcZO1qgRjKLCk0jQ oLTug2Y1AUjmdaK7EOzURVprdS39l1wDqWWD1TtzWZLuQfDVoWqeN6HOhVdpXm46xHIS J7mRjrh9a4XGAnKEOKAaR+ic75Is6MocxvAHsIiXc6Z0TrJtaLorhpNRYXhK9VwppLPh 6IYQ== X-Gm-Message-State: AA+aEWahvJQIttgT4G+XxbFq0sig33Hr40H8+mIq9TWELBQpDHGUViC2 aG/jz9ryB5NIRgNr5/YfWvwTbfND X-Google-Smtp-Source: AFSGD/Vnoy9HCsCl1F413hjEwT24A5X9xmlrCErb6IbznE/XQ09f+zCRe6bsKq4EAZXrUWyeA58CKA== X-Received: by 2002:a1c:864f:: with SMTP id i76mr5829761wmd.83.1545472270011; Sat, 22 Dec 2018 01:51:10 -0800 (PST) From: Marcel Apfelbaum To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Sat, 22 Dec 2018 11:50:26 +0200 Message-Id: <20181222095036.29743-22-marcel.apfelbaum@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181222095036.29743-1-marcel.apfelbaum@gmail.com> References: <20181222095036.29743-1-marcel.apfelbaum@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH PULL 21/31] hw/pvrdma: Clean device's resource when system is shutdown 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: yuval.shaia@oracle.com, pjp@fedoraproject.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Yuval Shaia In order to clean some external resources such as GIDs, QPs etc, register to receive notification when VM is shutdown. Signed-off-by: Yuval Shaia Reviewed-by: Marcel Apfelbaum Signed-off-by: Marcel Apfelbaum --- hw/rdma/vmw/pvrdma.h | 2 ++ hw/rdma/vmw/pvrdma_main.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/hw/rdma/vmw/pvrdma.h b/hw/rdma/vmw/pvrdma.h index 10a3c4fb7c..ffae36986e 100644 --- a/hw/rdma/vmw/pvrdma.h +++ b/hw/rdma/vmw/pvrdma.h @@ -17,6 +17,7 @@ #define PVRDMA_PVRDMA_H =20 #include "qemu/units.h" +#include "qemu/notify.h" #include "hw/pci/pci.h" #include "hw/pci/msix.h" #include "chardev/char-fe.h" @@ -87,6 +88,7 @@ typedef struct PVRDMADev { RdmaDeviceResources rdma_dev_res; CharBackend mad_chr; VMXNET3State *func0; + Notifier shutdown_notifier; } PVRDMADev; #define PVRDMA_DEV(dev) OBJECT_CHECK(PVRDMADev, (dev), PVRDMA_HW_NAME) =20 diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index 150404dfa6..23dc9926e3 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -24,6 +24,7 @@ #include "hw/qdev-properties.h" #include "cpu.h" #include "trace.h" +#include "sysemu/sysemu.h" =20 #include "../rdma_rm.h" #include "../rdma_backend.h" @@ -334,6 +335,9 @@ static void pvrdma_fini(PCIDevice *pdev) if (msix_enabled(pdev)) { uninit_msix(pdev, RDMA_MAX_INTRS); } + + pr_dbg("Device %s %x.%x is down\n", pdev->name, PCI_SLOT(pdev->devfn), + PCI_FUNC(pdev->devfn)); } =20 static void pvrdma_stop(PVRDMADev *dev) @@ -559,6 +563,14 @@ static int pvrdma_check_ram_shared(Object *obj, void *= opaque) return 0; } =20 +static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) +{ + PVRDMADev *dev =3D container_of(n, PVRDMADev, shutdown_notifier); + PCIDevice *pci_dev =3D PCI_DEVICE(dev); + + pvrdma_fini(pci_dev); +} + static void pvrdma_realize(PCIDevice *pdev, Error **errp) { int rc; @@ -632,6 +644,9 @@ static void pvrdma_realize(PCIDevice *pdev, Error **err= p) goto out; } =20 + dev->shutdown_notifier.notify =3D pvrdma_shutdown_notifier; + qemu_register_shutdown_notifier(&dev->shutdown_notifier); + out: if (rc) { error_append_hint(errp, "Device fail to load\n"); --=20 2.17.1