From patchwork Tue Dec 3 06:31:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 13891759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04D67E6C60C for ; Tue, 3 Dec 2024 06:33:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIMRa-0000Ax-7y; Tue, 03 Dec 2024 01:31:34 -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 1tIMRY-0000Ae-Mc; Tue, 03 Dec 2024 01:31:32 -0500 Received: from fhigh-b1-smtp.messagingengine.com ([202.12.124.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIMRW-0008Dy-VF; Tue, 03 Dec 2024 01:31:32 -0500 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.stl.internal (Postfix) with ESMTP id 395F9254008B; Tue, 3 Dec 2024 01:31:29 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Tue, 03 Dec 2024 01:31:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1733207489; x= 1733293889; bh=uZjMjLzm/+S0ku36xYAPx/8twvAIyV80i/25NBJC6GE=; b=H /dJKjfaLeTEAsRYlkDv/ocy/laATw33BWzEY9AqturCRCryAB04QtB4XtIzxbzSj hnKiT5U+kepWoh4W/nmq+fF/Uc2L9H0rUCaoASC9fYbfM1PMI9jw53/CPqhgu0JA 3N0wyAFJ1qZ+pmbZ/M9Jd+BX/CAgR9blS2Ef5J5dtPhGNJpfuAZL2qzE8E+pelo3 GM1pFuY1mXB+NLGh0HCaVt7HoFEUqJCWk/A2OxXFrXukSRovVOiS+bRUO1aF0/qJ N/B+57//M3k1cNNq2a97KuNoa5rZ9VmAuK3cZSYrCUMFkjUKd+iKrqRYpCmxeTJV OH2P4KTKTu/aRqdzTJBhA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1733207489; x=1733293889; bh=u ZjMjLzm/+S0ku36xYAPx/8twvAIyV80i/25NBJC6GE=; b=RUD3CHAEcczlAZyP2 k0LAOJdMeuXd3vFWWVRJKY8EWn0+Nfe8A/8kCjvuxNi73bF2Oo/oxq8Gqnzb2Hh5 xXskd+lH8WDw/sxRwtQjDQxxhNXAtjgEDWoRfxGrkMmclJWxAw94ynFVk0fPDRWG yY3hUz0shO7SwYD1HNvXCx7Hp6bWSm4UzqoQL7b6XTct6qdnRdGvyVOSGNeQCgj1 8PUOUwZ4qXISEN8bmpYra/SzCz/St/TTiXqLVvSRAulj941NMEc7+UDSo4z20AkJ 5YpFREvDQVJ9L58HbktYrceclv9QKVkYqlrVKL0cYOfTX5MDIBlddGK1w7heFU3e Ufgvw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddriedugddujecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecu hfhrohhmpefmlhgruhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrug hkqeenucggtffrrghtthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheef gfejjeehffefgedujedugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughkpdhnsggprhgtphhtthho peekpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnh honhhgnhhurdhorhhgpdhrtghpthhtohepphgvthgvrhdrmhgrhiguvghllheslhhinhgr rhhordhorhhgpdhrtghpthhtohepkhdrjhgvnhhsvghnsehsrghmshhunhhgrdgtohhmpd hrtghpthhtohepqhgvmhhuqdhsthgrsghlvgesnhhonhhgnhhurdhorhhgpdhrtghpthht ohepfhhoshhsseguvghfmhgrtghrohdrihhtpdhrtghpthhtohepkhgsuhhstghhsehkvg hrnhgvlhdrohhrghdprhgtphhtthhopehithhssehirhhrvghlvghvrghnthdrughkpdhr tghpthhtohepqhgvmhhuqdgslhhotghksehnohhnghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 3 Dec 2024 01:31:27 -0500 (EST) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: Peter Maydell , Klaus Jensen , qemu-stable@nongnu.org, Jesper Wendel Devantier , Keith Busch , Klaus Jensen , qemu-block@nongnu.org Subject: [PULL 4/4] hw/nvme: take a reference on the subsystem on vf realization Date: Tue, 3 Dec 2024 07:31:11 +0100 Message-ID: <20241203063112.9135-5-its@irrelevant.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203063112.9135-1-its@irrelevant.dk> References: <20241203063112.9135-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=202.12.124.152; envelope-from=its@irrelevant.dk; helo=fhigh-b1-smtp.messagingengine.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, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Klaus Jensen Make sure we grab a reference on the subsystem when a VF is realized. Otherwise, the subsytem will be unrealized automatically when the VFs are unregistered and unreffed. This fixes a latent bug but was not exposed until commit 08f632848008 ("pcie: Release references of virtual functions"). This was then fixed (or rather, hidden) by commit c613ad25125b ("pcie_sriov: Do not manually unrealize"), but that was then reverted (due to other issues) in commit b0fdaee5d1ed, exposing the bug yet again. Cc: qemu-stable@nongnu.org Fixes: 08f632848008 ("pcie: Release references of virtual functions") Reviewed-by: Jesper Wendel Devantier Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 61c114c66d15..ec7541956695 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8841,6 +8841,13 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) */ n->params.serial = g_strdup(pn->params.serial); n->subsys = pn->subsys; + + /* + * Assigning this link (strong link) causes an `object_unref` later in + * `object_release_link_property`. Increment the refcount to balance + * this out. + */ + object_ref(OBJECT(pn->subsys)); } if (!nvme_check_params(n, errp)) {