From patchwork Mon Nov 18 10:14:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 13878372 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 CA76DD49205 for ; Mon, 18 Nov 2024 10:16:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tCymt-0005MQ-Oo; Mon, 18 Nov 2024 05:15:21 -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 1tCyml-0005KH-0c; Mon, 18 Nov 2024 05:15:11 -0500 Received: from fout-b4-smtp.messagingengine.com ([202.12.124.147]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tCymj-0008JJ-0E; Mon, 18 Nov 2024 05:15:10 -0500 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id D84AE114019B; Mon, 18 Nov 2024 05:15:06 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Mon, 18 Nov 2024 05:15:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm2; t=1731924906; x=1732011306; bh=eoIJIsnvFSmFZxfkto+eSSz3zEqn6zFD 3WOe+enxcsk=; b=AbI5Eh5gsxlXDeeJxVLVe8MqoKTBLKSlM2F347mvpNLAtDMS g0aBQjUOYn2IdGXY6vj9bmun2xzoDnqqiMNPWfSG1twKdPa2Hz1PEG8M+twbQ8NB L9KgvhmWnsUThvEV8yE1dtbPoTthnSbCbCOh2AA65Ewi2Txwu0sdXlCXp9fVsUCd N87r8dF0Yx0bkNdOqfV6CvRHwLzWd373E+LeBiiTIWoc3aYqnbMZxghLWie+6NV2 U/MZAQy9YrCvUy0C1/9GFChuu8S2yAjnOoNDug0pKOwC5yjja5wTWlCqkjisBVBN 5LixriF+Yxhc4tK51d/4fmESEzSY4n1Z+Qj4MA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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=fm3; t=1731924906; x= 1732011306; bh=eoIJIsnvFSmFZxfkto+eSSz3zEqn6zFD3WOe+enxcsk=; b=N vTVA9TvHGCI7Il99oiyx1jQC9Yzt4u6Kdp+PQp8dTbWwEmvDDmgR6Sqa+FlxbEfx yutUu2ZofJBEhbGrR031JLsGmjzWeaS2opAPdnfvr4kHtJPVYFrNR2SG/8ps4EV+ r7AeVwCa9rHluWOelfSM5ooZ5ZoxWf0Alg5fIwY4mwvKhgVgiiq7XTD4rLObRNjl wXDXmpzPke2ugbHqQCT3Mq18wg7qrl/Z1tgGv96H3h/wtnMsmAPlRMu2Vl6naV7k YoX6aVoTseJ7Hem7Oymzmy+zgs27QgGwZTLaJr3S8YLZauCRKqDqUAzeGozY5HOH XTq3rtk0oqT5mNwBzsagA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfedtgdduvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeen ucfhrhhomhepmfhlrghushculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrd gukheqnecuggftrfgrthhtvghrnhepkeeivddtueehffefuddtleefkefhiedttdduveeg gfffieetveffhfehgfeghfffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukhdpnhgspghrtghpthht ohepjedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepfhhoshhsseguvghfmhgrtg hrohdrihhtpdhrtghpthhtohepihhtshesihhrrhgvlhgvvhgrnhhtrdgukhdprhgtphht thhopehqvghmuhdqshhtrggslhgvsehnohhnghhnuhdrohhrghdprhgtphhtthhopehqvg hmuhdqsghlohgtkhesnhhonhhgnhhurdhorhhgpdhrtghpthhtohepkhgsuhhstghhsehk vghrnhgvlhdrohhrghdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurd horhhgpdhrtghpthhtohepkhdrjhgvnhhsvghnsehsrghmshhunhhgrdgtohhm X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 18 Nov 2024 05:15:05 -0500 (EST) From: Klaus Jensen Date: Mon, 18 Nov 2024 11:14:17 +0100 Subject: [PATCH for-9.2 1/4] hw/nvme: fix msix_uninit with exclusive bar MIME-Version: 1.0 Message-Id: <20241118-nvme-fixes-v1-1-02d107dbdcc0@samsung.com> References: <20241118-nvme-fixes-v1-0-02d107dbdcc0@samsung.com> In-Reply-To: <20241118-nvme-fixes-v1-0-02d107dbdcc0@samsung.com> To: Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Klaus Jensen , qemu-stable@nongnu.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1120; i=k.jensen@samsung.com; h=from:subject:message-id; bh=luAZmVRl988Fk2UCy4nTP3G7adYdvITDIx52Hx/vg+M=; b=LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgpvd0o0bkFGdEFaTCtrQTBEQUFvQlRlR3ZNV zFQRGVrQnl5WmlBR2M3RTZUaHFKYzZRcnRWV1BDWnNlby9sQVVDCjFtdjllS3gxNTUwd3JkNFVG UlIrZzRrQk13UUFBUW9BSFJZaEJGSW9NNnAxNHR6bW9rZG13RTNocnpGdFR3M3AKQlFKbk94T2t BQW9KRUUzaHJ6RnRUdzNwTEtzSUFMSUs4QWZ0ME9pTGh4bzhRazI3RWxhWXVqK2JLdnpNaE14bw pNZnhIRjV6TFJjRXNNVTB0cHZTYUpaMnF5UktmQ2FzdGtETFB0OUtPb2MvNWdjK1lmZk9TSlhuN 0tFQW9qVC9jClY3Rlg0ZCtxZVR1Uk1saUQ1bGY1V1B3QWk5OW15M01pVzV6MzB5dGEzRjdWQWtN WkswYVBBNkU1S0dkTy9aNTcKcHVzV1FLazNOUG9CUzlPRGM3eGpkZjkvM2xwNVpscnRKNGxJSit KZTd5OGFDUmgwTlJyUWt4S2pUZGVmUDNnVAoxd0QyNldlVE9lZGhvbVVFQzlXT2NGN3JlQVNocW F2OWF3Z0pMVGIwdmJCODFoOVhZaVpsWHV1d3ZMcmVOWkFsCkxNMVlQVDZkZGpsSWp6U1Q0MTF0d FpKNy8vZlRGbDlXV3JNU2wwUzQ3TlZ6Z2hacFRLZW9wS1pVCj04cGgzCi0tLS0tRU5EIFBHUCBN RVNTQUdFLS0tLS0K X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=202.12.124.147; envelope-from=its@irrelevant.dk; helo=fout-b4-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_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 Commit fa905f65c554 introduced a machine compatibility parameter to enable an exclusive bar for msix. It failed to account for this when cleaning up. Make sure that if an exclusive bar is enabled, we use the proper cleanup routine. Cc: qemu-stable@nongnu.org Fixes: fa905f65c554 ("hw/nvme: add machine compatibility parameter to enable msix exclusive bar") Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 69bce20f6692b48ae162ad948b1a3eef31d69ebd..13898d58278ed2155d45a9120fc07ea60bc64a32 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8904,7 +8904,12 @@ static void nvme_exit(PCIDevice *pci_dev) pcie_sriov_pf_exit(pci_dev); } - msix_uninit(pci_dev, &n->bar0, &n->bar0); + if (n->params.msix_exclusive_bar && !pci_is_vf(pci_dev)) { + msix_uninit_exclusive_bar(pci_dev); + } else { + msix_uninit(pci_dev, &n->bar0, &n->bar0); + } + memory_region_del_subregion(&n->bar0, &n->iomem); } From patchwork Mon Nov 18 10:14:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 13878375 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 CE524D49209 for ; Mon, 18 Nov 2024 10:16:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tCynT-0005Xp-3u; Mon, 18 Nov 2024 05:15:55 -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 1tCymm-0005LQ-GE; Mon, 18 Nov 2024 05:15:12 -0500 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tCymk-0008Jf-OC; Mon, 18 Nov 2024 05:15:12 -0500 Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id F0DE32540169; Mon, 18 Nov 2024 05:15:08 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Mon, 18 Nov 2024 05:15:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm2; t=1731924908; x=1732011308; bh=wn0FDtj1v/m1iBQtnIW92oDW3NoKo76q 4MrOju+Mbr0=; b=JzQ9NbbT8OW0x+wdQFqnyESdyyVXe6iR+fp7HVhbHxdtw8ar 8/97tqEq+xqEHn2/Pn/9TmiWuvAo74fEu7MiFjEj004D/MiIhEfM6HHLFzhLTVyP dX87Mf7HkHNcmoHRZ5Qq7Xsy6vrJ2GnA49/xnG2LLbgDWTkBOOpnwX9htEA4zPzq P2z+lg6uS7vSzspYQtQUEtTPTSE/3J3rnu/TeskfWM36hKyKr3NMzOsYfn1VIUHw jQrenlr5IOec1P3jVgyChrIoFthU26RKAFIAB7d00yuZL9p88H8bB3gt/CHuVmJW nruOb/xSMvbsHXTGbMVzqojmIACoI8qINv6ljw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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=fm3; t=1731924908; x= 1732011308; bh=wn0FDtj1v/m1iBQtnIW92oDW3NoKo76q4MrOju+Mbr0=; b=c HsS0V70ytWvozQpu8jobdBhl2fvPs6OZgrmALwP4OZC9N39OapauRoiNi77ZyABk 2rwRMWjTfX4s18hk6K2MiRMvlg8lVycRQFBH0xgbDY9ZvlHB3+YyzQ2v8fAMDvvd V8LQ/DyS0gZK285NRU2m/qIdT7zhgAurJsws/rhaZo6l9FA3OnLJI01lOt6/BqDW UEZwT3cwNOumCR9j7xs/LFRdsnfQekguvQdR+KrBABJ5ptlm3oH7tf2nM4BSIZI4 biC2LwrN5Hc8AyV3ZEZkU1tjJ/wXXb5sJ1pzjAPltrkA7dhTPm4QJDTJNB727Nyw D9lptUfR8Nvp4fn+y+HPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfedtgdduvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeen ucfhrhhomhepmfhlrghushculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrd gukheqnecuggftrfgrthhtvghrnhepkeeivddtueehffefuddtleefkefhiedttdduveeg gfffieetveffhfehgfeghfffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukhdpnhgspghrtghpthht ohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepfhhoshhsseguvghfmhgrtg hrohdrihhtpdhrtghpthhtohepihhtshesihhrrhgvlhgvvhgrnhhtrdgukhdprhgtphht thhopehqvghmuhdqsghlohgtkhesnhhonhhgnhhurdhorhhgpdhrtghpthhtohepkhgsuh hstghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhho nhhgnhhurdhorhhgpdhrtghpthhtohepkhdrjhgvnhhsvghnsehsrghmshhunhhgrdgtoh hm X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 18 Nov 2024 05:15:07 -0500 (EST) From: Klaus Jensen Date: Mon, 18 Nov 2024 11:14:18 +0100 Subject: [PATCH for-9.2 2/4] hw/nvme: fix use/unuse of msix vectors MIME-Version: 1.0 Message-Id: <20241118-nvme-fixes-v1-2-02d107dbdcc0@samsung.com> References: <20241118-nvme-fixes-v1-0-02d107dbdcc0@samsung.com> In-Reply-To: <20241118-nvme-fixes-v1-0-02d107dbdcc0@samsung.com> To: Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Klaus Jensen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1122; i=k.jensen@samsung.com; h=from:subject:message-id; bh=On2tnR5FtbLyphu7V88G7B3jZ5QwBKDAjv+OiR4JC0E=; b=LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgpvd0o0bkFGdEFaTCtrQTBEQUFvQlRlR3ZNV zFQRGVrQnl5WmlBR2M3RTZYZnhubUJhUnBIU0lmVEZIa3VnSGd6CmRFQzFQendibXBWdGc1OHBa cjcxVzRrQk13UUFBUW9BSFJZaEJGSW9NNnAxNHR6bW9rZG13RTNocnpGdFR3M3AKQlFKbk94T2x BQW9KRUUzaHJ6RnRUdzNwQi9jSUFKYWdoUEFyb3FCRllyc3Qwb0d2SVpWakowUWR4S2RxdVZtVw pHZ1BJOXFpMmNHd1YwT2FqNXRRcitKUEJrMHJLM0pZQkhqNVVMR3NtVUlRUHdxMkVqd2w1b3VMR XNJbi9FVDZwCkNhVGtsTHRtd1lDenVob3YzNDZuQTVtOE9lZU9EUnZtMlBqZGxIMlR4Smh4RWph cU9meUlyTkx3NDBMdzB0YzgKTEpESTlJbFJLYmVQYXprY3NRdUl0N0VJeTBzWkgzdTYwUTN1czh TaE0wcjR3OWNhdW5EQ1ZYb0VTc2pJdmVUTApLSUY0T1Jqdi9xTVE0OU8yVHdab1c0S0NTbVh1QT lEbTZXNEtDb01EOEY1V1N2LzE0YlR3blo0bGN2K2RnTlYxClkxRnZ2SHRYdWs1NTJTNVNaSWx6S TdQTkNDTGNrVzlOYmxUeFFRN21tTmVWVEpoQkhyT0FSS3daCj12SFp6Ci0tLS0tRU5EIFBHUCBN RVNTQUdFLS0tLS0K X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=202.12.124.157; envelope-from=its@irrelevant.dk; helo=fhigh-b6-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_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 Only call msix_{un,}use_vector() when interrupts are actually enabled for a completion queue. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 13898d58278ed2155d45a9120fc07ea60bc64a32..a38f460a78599bc191c17a2a376e865a74744e58 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -5423,7 +5423,7 @@ static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n) event_notifier_set_handler(&cq->notifier, NULL); event_notifier_cleanup(&cq->notifier); } - if (msix_enabled(pci)) { + if (msix_enabled(pci) && cq->irq_enabled) { msix_vector_unuse(pci, cq->vector); } if (cq->cqid) { @@ -5464,9 +5464,10 @@ static void nvme_init_cq(NvmeCQueue *cq, NvmeCtrl *n, uint64_t dma_addr, { PCIDevice *pci = PCI_DEVICE(n); - if (msix_enabled(pci)) { + if (msix_enabled(pci) && irq_enabled) { msix_vector_use(pci, vector); } + cq->ctrl = n; cq->cqid = cqid; cq->size = size; From patchwork Mon Nov 18 10:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 13878374 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 20F5FD49205 for ; Mon, 18 Nov 2024 10:16:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tCync-0005pr-35; Mon, 18 Nov 2024 05:16:04 -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 1tCymq-0005M4-Jq; Mon, 18 Nov 2024 05:15:17 -0500 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tCyml-0008K5-UB; Mon, 18 Nov 2024 05:15:13 -0500 Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id B5AC925400B8; Mon, 18 Nov 2024 05:15:10 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Mon, 18 Nov 2024 05:15:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm2; t=1731924910; x=1732011310; bh=eKPdc+0xnhbS9XwqwCCdNQo8FgV2Dtc/ tstz7c+G7PI=; b=frESxbxM3N9pCMrmmoqERJizZG+wlAVdG1mqNOOiy0PbvUsW /ieidBnBVaDcJzMMBxFrAmOqCWvf1ZpyN4lDjGLhkQiE/ODHSZxQ9EzsdiP3VoJg YGh88IpiudOAKZdTTrUxnph9R0ZTIFnZaDfcVHRS2Ot6HliSjQ3OetUAH4qcrIl2 dCPv3w9V2g3hWAfZgg/5YwxvhMc8VJMFb5/HO878iXrB33IQYBlOtBAfUwApBRPJ 0PDcsK6jarzYS+oa8kfY/5UvaP0k3lRnOypNquR3mlmxBXYngAq4CHmn4q0wvyv3 19oTdq0ICFYIrGJWu3tgeY9hOnTY5Spa2xptBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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=fm3; t=1731924910; x= 1732011310; bh=eKPdc+0xnhbS9XwqwCCdNQo8FgV2Dtc/tstz7c+G7PI=; b=J Z5LOCcbkjXV7YB2/F9AIHUAXJuGQt5GFlq6ArmeWQDsT3QcxenbdtcbapQQ39NY8 v3fXx6mdQACMsYCZemjj0Wd5fgyrpp1wjI5qTx5QPBZPmXq0clT4JX5noHh7VGOG IkNY5CXIEsJ450ColAthPmpK7CuVAe5bCmLBYb8co4fEKs6VDsHa2wdQ2LPGqa7B LX3UQ/9S9LX3s9xRKUg5WwqtQ/UJwV3ujxUXDU31C3U4gsJmSziQ57oV21hGAjwj fesN8yjb0B1MRFhbK6WJ9WBAf2YaVXUnz/sD9rg3MrkJ6rJQueWACfyiKnzB+5Hw 5STUoJ1vaMMnsHqPqZmmQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfedtgdduvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeen ucfhrhhomhepmfhlrghushculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrd gukheqnecuggftrfgrthhtvghrnhepkeeivddtueehffefuddtleefkefhiedttdduveeg gfffieetveffhfehgfeghfffnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpe hmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukhdpnhgspghrtghpthht ohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepfhhoshhsseguvghfmhgrtg hrohdrihhtpdhrtghpthhtohepihhtshesihhrrhgvlhgvvhgrnhhtrdgukhdprhgtphht thhopehqvghmuhdqsghlohgtkhesnhhonhhgnhhurdhorhhgpdhrtghpthhtohepkhgsuh hstghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhho nhhgnhhurdhorhhgpdhrtghpthhtohepkhdrjhgvnhhsvghnsehsrghmshhunhhgrdgtoh hm X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 18 Nov 2024 05:15:09 -0500 (EST) From: Klaus Jensen Date: Mon, 18 Nov 2024 11:14:19 +0100 Subject: [PATCH for-9.2 3/4] hw/nvme: SR-IOV VFs must hardwire pci interrupt pin register to zero MIME-Version: 1.0 Message-Id: <20241118-nvme-fixes-v1-3-02d107dbdcc0@samsung.com> References: <20241118-nvme-fixes-v1-0-02d107dbdcc0@samsung.com> In-Reply-To: <20241118-nvme-fixes-v1-0-02d107dbdcc0@samsung.com> To: Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Klaus Jensen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1121; i=k.jensen@samsung.com; h=from:subject:message-id; bh=8FsyptW+qB1cLIkS6SNQ7iw7y55WO0Fxsme0yttl0wY=; b=LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgpvd0o0bkFGdEFaTCtrQTBEQUFvQlRlR3ZNV zFQRGVrQnl5WmlBR2M3RTZYSnZ6S2NueXdRN1pEemJsY3A1RDg2Cld0YS9xbEgyTEtWYy9xVlMy SThhd1lrQk13UUFBUW9BSFJZaEJGSW9NNnAxNHR6bW9rZG13RTNocnpGdFR3M3AKQlFKbk94T2x BQW9KRUUzaHJ6RnRUdzNweURrSC8wNnJidlhQcC9OV3BBTmhOVVU4NkNVVGRFSUVKWUk3a25TWg pGb1FWd2toWmRsV05sZ1doTXVibGZmK0RwVHRUSlJ6VVlIOWRxUmFnb1BPc0RZaWJEMUhLTmtJN zhWaVR1UUtaCnlMZ0lzU0hmdkZVZ0lsV3Q0Q3ZvcVo4NHM4eVZiNk5OZzQ1RFo4ckg2SXQxQ2xU N1VqcTRobnlua1ZkYkU2QVAKUUoxRUlMWWpNTFFxT3EzZ2JtamFKMXBXbWFuejNLVzBjcDZmWVN nQUZNa0xKY1RqZ0pvaGg3c2xZcmJZMHZkVAowR05RYzZmUWZvVHlnZUNkMkpqTng2ck1iN3pQc3 hjTUpqd1RPd3E5WVcrTzRZYm1iMHRWS0k4Qi9sMnJMQWZaCjN6SXJRNkMrRjAzZ0NNa1BzMUVyY lFWcWJyVHB4cDBvckJneUlBbXBacnZnQ1ltN2NDdjhFNlNSCj1kU1pSCi0tLS0tRU5EIFBHUCBN RVNTQUdFLS0tLS0K X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=202.12.124.157; envelope-from=its@irrelevant.dk; helo=fhigh-b6-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_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 The PCI Interrupt Pin Register does not apply to VFs and MUST be hardwired to zero. Fixes: 44c2c09488db ("hw/nvme: Add support for SR-IOV") Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index a38f460a78599bc191c17a2a376e865a74744e58..61c114c66d1565696430589aeb27d7c4a5d2220a 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -656,6 +656,12 @@ static void nvme_irq_check(NvmeCtrl *n) if (msix_enabled(pci)) { return; } + + /* vfs does not implement intx */ + if (pci_is_vf(pci)) { + return; + } + if (~intms & n->irq_status) { pci_irq_assert(pci); } else { @@ -8544,7 +8550,7 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) unsigned nr_vectors; int ret; - pci_conf[PCI_INTERRUPT_PIN] = 1; + pci_conf[PCI_INTERRUPT_PIN] = pci_is_vf(pci_dev) ? 0 : 1; pci_config_set_prog_interface(pci_conf, 0x2); if (n->params.use_intel_id) { From patchwork Mon Nov 18 10:14:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 13878376 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 7901CD49205 for ; Mon, 18 Nov 2024 10:16:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tCynb-0005oG-Sx; Mon, 18 Nov 2024 05:16:03 -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 1tCyms-0005MU-BF; Mon, 18 Nov 2024 05:15:19 -0500 Received: from fout-b4-smtp.messagingengine.com ([202.12.124.147]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tCymq-0008KU-PA; Mon, 18 Nov 2024 05:15:18 -0500 Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id 96C59114019B; Mon, 18 Nov 2024 05:15:12 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Mon, 18 Nov 2024 05:15:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm2; t=1731924912; x=1732011312; bh=fIdnaVMp0/2z9dMrnCl/TLqQ5Ylu2ihk ckUe2/tOJXs=; b=ZFsYwbLSHD9xCLvCe9b7tqn9R9Zq1K70VKhXc5WG/o90fcWy R+b9T58FTIuEy+DR2N/Hqf9wd+gT3Tpob9Y14/IDeQBo1DcruLRLurjBt68EO4Kv ZL4BDJEgGDmZXHe19GpyPPvTFu5DYlDGjf9Evj6w+drwPm2bvRySAUW0a2crSm+k QQmDojha0YUvASzkc1XM3ELK/Z44LLtBIub9OiI8mdDhM+7UL3+eGk09AN5reBPy 19FWb4Sj/K0d/gnNtTAMnBm9I41pIWKm3EMCe9+5P9Z4FDg4YB/6KOKvWTfQchbr jy92QYEMoU3i43AmpU7nwg+q3WdjxUIKpjZ9Yg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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=fm3; t=1731924912; x= 1732011312; bh=fIdnaVMp0/2z9dMrnCl/TLqQ5Ylu2ihkckUe2/tOJXs=; b=I Qh9kPxKrFxOCHpzilOnolWCgAl+UwMvUUNHxymWWzVgHvy8MJBBS0SSOQ7CBOJZm R+OyQCkcDXqJoKAFvYEdePx78BPFdXGJtmOGkmwidT+plIKkpvKgWC2ol8eO0cq2 AC7HIfYb9pu6gAY+pHf9FBCdGfv722ihOarkh9wVqQAIMKvrgeQrkwYKkq1JLWFQ 4VLT3aso4vchSjqtE5msYhqkrRSMfW5dwngNHSxJsi3itM2YxcQ+3PtNiPjflQHx YvawEHWDiMoTU8fhiYxcxWbkKv7Mny7LlaMcZ4RTnvcdWJnkNMJCSMRRYJpd12XF 4jcMx87spLSHIzBaIH3RQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfedtgdduvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeen ucfhrhhomhepmfhlrghushculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrd gukheqnecuggftrfgrthhtvghrnhepkeeivddtueehffefuddtleefkefhiedttdduveeg gfffieetveffhfehgfeghfffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukhdpnhgspghrtghpthht ohepjedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepfhhoshhsseguvghfmhgrtg hrohdrihhtpdhrtghpthhtohepihhtshesihhrrhgvlhgvvhgrnhhtrdgukhdprhgtphht thhopehqvghmuhdqshhtrggslhgvsehnohhnghhnuhdrohhrghdprhgtphhtthhopehqvg hmuhdqsghlohgtkhesnhhonhhgnhhurdhorhhgpdhrtghpthhtohepkhgsuhhstghhsehk vghrnhgvlhdrohhrghdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurd horhhgpdhrtghpthhtohepkhdrjhgvnhhsvghnsehsrghmshhunhhgrdgtohhm X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 18 Nov 2024 05:15:11 -0500 (EST) From: Klaus Jensen Date: Mon, 18 Nov 2024 11:14:20 +0100 Subject: [PATCH for-9.2 4/4] hw/nvme: take a reference on the subsystem on vf realization MIME-Version: 1.0 Message-Id: <20241118-nvme-fixes-v1-4-02d107dbdcc0@samsung.com> References: <20241118-nvme-fixes-v1-0-02d107dbdcc0@samsung.com> In-Reply-To: <20241118-nvme-fixes-v1-0-02d107dbdcc0@samsung.com> To: Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Klaus Jensen , qemu-stable@nongnu.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1430; i=k.jensen@samsung.com; h=from:subject:message-id; bh=U8nYbfifAWFGsbALmvnqAi+L4a04ZKCu8fQJt4ne/+0=; b=LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgpvd0o0bkFGdEFaTCtrQTBEQUFvQlRlR3ZNV zFQRGVrQnl5WmlBR2M3RTZaVUFtLzI4eG9NMHlNaEZkUE8zb0ZpCk04Z29PYzJ6Mk9hMERWTkNP dVpPSllrQk13UUFBUW9BSFJZaEJGSW9NNnAxNHR6bW9rZG13RTNocnpGdFR3M3AKQlFKbk94T21 BQW9KRUUzaHJ6RnRUdzNwclBVSC9SeUV1bUx6b0hkUllUakl6bUdpSlphU0RFQWV3LzA2RnJ0OA pYWEdUaFhHTlNVWU13VjRDMTJYKzNPaDhQa0hhOVgzTEFlWXZ2VU0rRUx2MWRJeVBYeGF4ZmNCU GFNalJUTlp5CkVlM3ZESUNmMnV2aGQxT0dlM3dxODFDYmtZVGcxTVNaMkxsdDB6cHMya2N0UnNa ZW9CZmM4U2R1UHhKbk41UTIKbHFpaUpiTjNhWVY2cUwwT1ROQ0h0bG9wcnhqdGlEV3lqK0syNFE 1Nkh5T0phVTBFMGJwUDNncmQrWmN4VGVIVwo2ZDZER3ZKMDNNWitIS0owQXlhQkxPRWxFd2JWb1 pjaUM3ZjAwS2F4Tm8yYmt6eVU4WTVEU3orWjBVV0VESytICkcwdEhkZ0NmZHRpVTdXM05tMnVLc m1rKzFMWDlvZFUyZDlBOU5iZnk5dkZ3MEdma3N4MEsxSzBKCj1vKzdnCi0tLS0tRU5EIFBHUCBN RVNTQUdFLS0tLS0K X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=202.12.124.147; envelope-from=its@irrelevant.dk; helo=fout-b4-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_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") 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 61c114c66d1565696430589aeb27d7c4a5d2220a..ec754195669598082dd573ff1237dbbfb9b8aff5 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)) {