From patchwork Mon Oct 29 06:29:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10658785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A0581734 for ; Mon, 29 Oct 2018 06:31:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B9B8294E0 for ; Mon, 29 Oct 2018 06:31:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FE77294FB; Mon, 29 Oct 2018 06:31:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73F8F294E4 for ; Mon, 29 Oct 2018 06:31:13 +0000 (UTC) Received: from localhost ([::1]:43744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH14y-0004Cv-NB for patchwork-qemu-devel@patchwork.kernel.org; Mon, 29 Oct 2018 02:31:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH13i-0003Qb-P5 for qemu-devel@nongnu.org; Mon, 29 Oct 2018 02:29:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gH13i-0008M9-5M for qemu-devel@nongnu.org; Mon, 29 Oct 2018 02:29:54 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:46608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gH13e-0008Kr-RB; Mon, 29 Oct 2018 02:29:50 -0400 Received: by mail-pg1-x541.google.com with SMTP id m9-v6so676802pgl.13; Sun, 28 Oct 2018 23:29:50 -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; bh=5byzJzwMzVonn8tTzspZIesx/vv7SCwxTJW13St0uyQ=; b=pmzqvBAm96R1M4YCPJWIvCscGXHAeuIBfLg5aauy+zfoy/dzwcJrEDuqeQOUt+E0g4 d0J82rhllaoJOB1Ex4kzTOY/fDi2/vgA4AsVJIpKFPXoJ6lfgzU5LPAp8EhXxHYdNubx p31yHMdYFAPJmnGAqnVr587yLe33um+4Fkrs4irUvaNv0COgaPCBXzPbObVvTNRGHwLu RAsBdnSixNpCprTK+CSYcuy2e88VIA0jDwBOeQGQh4krd4CUNygeyhCts7u4EyV1SvRy LUuna1Y3Ho1G1UlbjyUudhD4Im68kXfvZuFMvlxaLvH5wdeBELm7ptVY6/wfJuLt1WSE 8n0w== 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=5byzJzwMzVonn8tTzspZIesx/vv7SCwxTJW13St0uyQ=; b=eSaKUTudgH58brGTL6kfHMLiMgGR5f8aw9zIEIGvxeQHRVw5jxh/st8OL2RMSLh80s fbB7TANyPX7qaKtKg5ChugCLndoc9ylBJyqhNL8cS2QvWB3RHy6wf8rkUfjZuUy2z2fm eJQ/A54ynotRhcDN8mJhx3Rx+lNWtMQt0pQ5KxNrcdA/Z7VIzLFMcmH12Rz36cVrhPcb NYDTPpBgmpaImZnOrxPvMRi26WjC8xTNR3d7YJ9BLpTt8m/ws52c55eZSL/OH+aXRgvc 4Bd8vcAxyw5xB03Ssaz6HrTJnzjIPQqRdAZ8ji1WqYcN3/xEyE4sbnBlsZDvbbifSgJG Y/+Q== X-Gm-Message-State: AGRZ1gIe2NAQYq2La3zZDPCkU/eSg1Mtrbqa8r1gav+lM1Sr+m2mjA6j x6PYghCMMO7jfl3w3vAyTrQ= X-Google-Smtp-Source: AJdET5fOGFKutNPrEYxatJe2A0VAKAiArJ/hrFecwjoNVUrO2k3uXLVxbwMjXQD2Sx6KFk3h1UbHrw== X-Received: by 2002:a63:8c0b:: with SMTP id m11-v6mr12685918pgd.422.1540794589897; Sun, 28 Oct 2018 23:29:49 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.101]) by smtp.gmail.com with ESMTPSA id 72-v6sm25734644pfl.126.2018.10.28.23.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Oct 2018 23:29:49 -0700 (PDT) From: Li Qiang To: keith.busch@intel.com, kwolf@redhat.com, mreitz@redhat.com Date: Sun, 28 Oct 2018 23:29:40 -0700 Message-Id: <1540794581-33578-2-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540794581-33578-1-git-send-email-liq3ea@gmail.com> References: <1540794581-33578-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized 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: Li Qiang , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, when hotplug/unhotplug nvme device, it will cause an assert in object.c. Following is the backtrack: ERROR:qom/object.c:981:object_unref: assertion failed: (obj->ref > 0) Thread 2 "qemu-system-x86" received signal SIGABRT, Aborted. [Switching to Thread 0x7fffcbd32700 (LWP 18844)] 0x00007fffdb9e4fff in raise () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) bt /lib/x86_64-linux-gnu/libglib-2.0.so.0 /lib/x86_64-linux-gnu/libglib-2.0.so.0 qom/object.c:981 /home/liqiang02/qemu-upstream/qemu/memory.c:1732 /home/liqiang02/qemu-upstream/qemu/memory.c:285 util/qemu-thread-posix.c:504 /lib/x86_64-linux-gnu/libpthread.so.0 This is caused by memory_region_unref in nvme_exit. Remove it to make the PCIdevice refcount correct. Signed-off-by: Li Qiang Reviewed-by: Igor Mammedov --- hw/block/nvme.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index fc7dacb816..359a06d0ad 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1331,9 +1331,6 @@ static void nvme_exit(PCIDevice *pci_dev) g_free(n->namespaces); g_free(n->cq); g_free(n->sq); - if (n->cmbsz) { - memory_region_unref(&n->ctrl_mem); - } msix_uninit_exclusive_bar(pci_dev); }