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 2E24BC433F5 for ; Thu, 17 Feb 2022 18:01:36 +0000 (UTC) Received: from localhost ([::1]:51678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKl5z-00008z-8J for qemu-devel@archiver.kernel.org; Thu, 17 Feb 2022 13:01:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKksg-0003JZ-Jj; Thu, 17 Feb 2022 12:47:50 -0500 Received: from mga12.intel.com ([192.55.52.136]:31713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKkse-0007HU-RD; Thu, 17 Feb 2022 12:47:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645120069; x=1676656069; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7yQaZFAuGoDwDPKICv8STUE6x+vSOzyc+1Mlaq+cK1Q=; b=ewuC9puK+uhjONXsjY5lCp98oJk2OJL/++2sB4rh+PXvjtpvAnkP1K1n dZ20tPg4YvP/e/MuFhuM2BxJOU+Xv/boQRoQFvH/cVFbnda0RVy2/YabW V6TuoenLbC41FZzHoNH0AEhssM0uA9WY3yQGqk8YA/sEwRBq3/gWzz3Yz g4l4VXBJsd+mwsUjMwH5svxqpBG0nI5Ukv2WPnuEVrcobdelw1g49VRHc 99Vfux4i2d4icKlG5HEiFPYRFF5Ix1LWNRMtPp3EBy17/IcLdAEZ5/Fh5 cONevqDje706XTou7p1sKbwRfv/PEKbHWOIZ/AwGD99MxYGlngtPilQ8V A==; X-IronPort-AV: E=McAfee;i="6200,9189,10261"; a="230894140" X-IronPort-AV: E=Sophos;i="5.88,376,1635231600"; d="scan'208";a="230894140" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 09:47:23 -0800 X-IronPort-AV: E=Sophos;i="5.88,376,1635231600"; d="scan'208";a="545746326" Received: from lmaniak-dev.igk.intel.com ([10.55.249.72]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 09:47:21 -0800 From: Lukasz Maniak To: qemu-devel@nongnu.org Subject: [PATCH v5 15/15] hw/nvme: Update the initalization place for the AER queue Date: Thu, 17 Feb 2022 18:45:04 +0100 Message-Id: <20220217174504.1051716-16-lukasz.maniak@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217174504.1051716-1-lukasz.maniak@linux.intel.com> References: <20220217174504.1051716-1-lukasz.maniak@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=192.55.52.136; envelope-from=lukasz.maniak@linux.intel.com; helo=mga12.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: Klaus Jensen , Keith Busch , Lukasz Maniak , qemu-block@nongnu.org, =?UTF-8?q?=C5=81ukasz=20Gieryk?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Łukasz Gieryk This patch updates the initialization place for the AER queue, so it’s initialized once, at controller initialization, and not every time controller is enabled. While the original version works for a non-SR-IOV device, as it’s hard to interact with the controller if it’s not enabled, the multiple reinitialization is not necessarily correct. With the SR/IOV feature enabled a segfault can happen: a VF can have its controller disabled, while a namespace can still be attached to the controller through the parent PF. An event generated in such case ends up on an uninitialized queue. While it’s an interesting question whether a VF should support AER in the first place, I don’t think it must be answered today. Signed-off-by: Łukasz Gieryk --- hw/nvme/ctrl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index a9742cf5051..ae41fced596 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -6182,8 +6182,6 @@ static int nvme_start_ctrl(NvmeCtrl *n) nvme_set_timestamp(n, 0ULL); - QTAILQ_INIT(&n->aer_queue); - nvme_select_iocs(n); return 0; @@ -6844,6 +6842,7 @@ static void nvme_init_state(NvmeCtrl *n) n->features.temp_thresh_hi = NVME_TEMPERATURE_WARNING; n->starttime_ms = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); n->aer_reqs = g_new0(NvmeRequest *, n->params.aerl + 1); + QTAILQ_INIT(&n->aer_queue); list->numcntl = cpu_to_le16(max_vfs); for (i = 0; i < max_vfs; i++) { -- 2.25.1