From nobody Sat May 18 19:12:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1603090803; cv=none; d=zohomail.com; s=zohoarc; b=IyxB7dTzPds4s1UGJRGzyXuyyZPyG2PIfL/uudIAVMTU6bO2+VenUYNL0TXqII4ZElTSSsVUf+xtxejfdRYnmplY/K4Za8ZjOr1o572txC9oaxT2IdluttrcTZbEb69vUpDsv0ZiQ4xzK8tFEbLqcMJBddh9xwKgKYCy6WKnxmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603090803; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=IP8peYGBr3Br/xkSXq0bO0Pvz+rTWZvadOVhfYbAKXc=; b=Plgg6UHVZ1Zdxhi6CI6EKH6mhaFcc19s2ggxgUlsZTBfQxxJpjpDCkWYSt687A1JUMzHoxjK5tqbf2AZQIUyw6fduYhXwc1HLez6zq6Tl2q4Qu31St/W2+4TYraNWNge+nkTUuy5YJ+gNOpLUK1tgySbmopad8Zsy+n4jew5d5Q= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603090803572787.7790320532959; Mon, 19 Oct 2020 00:00:03 -0700 (PDT) Received: from localhost ([::1]:43370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUP9F-0003n7-JF for importer@patchew.org; Mon, 19 Oct 2020 03:00:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUP3v-0001j5-Ij; Mon, 19 Oct 2020 02:54:31 -0400 Received: from wnew1-smtp.messagingengine.com ([64.147.123.26]:34667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUP3s-000445-S6; Mon, 19 Oct 2020 02:54:31 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 0BBE5A57; Mon, 19 Oct 2020 02:54:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 19 Oct 2020 02:54:22 -0400 Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id D0DD33064610; Mon, 19 Oct 2020 02:54:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=IP8peYGBr3Br/xkSXq0bO0Pvz+ rTWZvadOVhfYbAKXc=; b=EWeu/MVQg5kPG+YO9X0fmVvvn0DAP7Wi/1F1GeX3vl 2hoyuWy2HI2PeAM4N6bOb9Og3bcOIZNP25zjmKswZfEj32m9aPL61PxnIDNT65Ix Knqao/24vC5k8X+KlKyPP3vPW/ALaPXyoCw3hfEygmEff/A8AKYggni4Qw6D0zAZ A6q4Uasriqgiok1PHQixFDoCLPt3qM00J2Dg89wxrmkF36Zv6ZUIASU7nw61QDxt eF3/N7ORXhHsAp3tn7lOWiSHEgKdpr27r1Z79BWFLc8ULuKlGFUvqS0LElNsKrck 71R61KDBwa1Zt9JrxWEwrT/36BbvpUWnczMw8c/Cg41w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=IP8peYGBr3Br/xkSX q0bO0Pvz+rTWZvadOVhfYbAKXc=; b=c4aN0K/sS4DYH4EfhYIExcq8Q81WQTQo1 Es6ClgUsSH9e4whwm0dYNQzH3PzpafvZJyfsAMjRcuXO0RscY0FQc81HfC50vn5R xmxscCzb+RH2a2asDfdAPH/5fEljaoncLCrYw4Dh8PdCen6kqkVjLikggmd8qLTf WTI6xwCJSt7hNtudDQ8KtF8oLUDdByo31ruVEdsuDeclMiFT2CQ7CkqfrqmJTAtn GVHfJapEJsf0TU8JELb8CSD2BBm31exRSeJQOULl7vjdDO4ccW2x6F0eOUNYpgen SGTuywWBhg8nHe+L4ZTryI+JLiOVHclQ290w2CywY/7cW2F8AUJlg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrjedtgdduuddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhsucfl vghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtthgvrh hnpeefveelvdeikeduueffteeggeefhedvffffjeeuueeludehvdegjeevjefhtdetheen ucfkphepkedtrdduieejrdelkedrudeltdenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH] hw/block/nvme: fix aer logic Date: Mon, 19 Oct 2020 08:54:16 +0200 Message-Id: <20201019065416.34638-1-its@irrelevant.dk> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=64.147.123.26; envelope-from=its@irrelevant.dk; helo=wnew1-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 02:54:23 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Dmitry Fomichev , Klaus Jensen , Max Reitz , Klaus Jensen , Keith Busch , Maxim Levitsky Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Klaus Jensen Fix same flawed logic in the handling of event masking. Before this patch the device would erroneously a) queue up events even though that event type is masked b) issue AERs for queued events in response to events getting cleared c) respond to new AERs with queued events even though the event was already cleared Fix this by moving the mask check to nvme_enqueue_event() and replace the nvme_process_aers() call with a pruning of queued events when the event type is cleared. Fixes: 5d5a53302b95 ("hw/block/nvme: add support for the asynchronous event= request command") Cc: Maxim Levitsky Cc: Dmitry Fomichev Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 22 ++++++++++++++-------- hw/block/trace-events | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 9d30ca69dcf1..b18a310d9271 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -805,12 +805,6 @@ static void nvme_process_aers(void *opaque) break; } =20 - /* ignore if masked (cqe posted, but event not cleared) */ - if (n->aer_mask & (1 << event->result.event_type)) { - trace_pci_nvme_aer_masked(event->result.event_type, n->aer_mas= k); - continue; - } - QTAILQ_REMOVE(&n->aer_queue, event, entry); n->aer_queued--; =20 @@ -844,6 +838,12 @@ static void nvme_enqueue_event(NvmeCtrl *n, uint8_t ev= ent_type, return; } =20 + /* ignore if masked (cqe posted, but event not cleared) */ + if (n->aer_mask & (1 << event_type)) { + trace_pci_nvme_aer_masked(event_type, n->aer_mask); + return; + } + event =3D g_new(NvmeAsyncEvent, 1); event->result =3D (NvmeAerResult) { .event_type =3D event_type, @@ -859,9 +859,15 @@ static void nvme_enqueue_event(NvmeCtrl *n, uint8_t ev= ent_type, =20 static void nvme_clear_events(NvmeCtrl *n, uint8_t event_type) { + NvmeAsyncEvent *event, *next; + n->aer_mask &=3D ~(1 << event_type); - if (!QTAILQ_EMPTY(&n->aer_queue)) { - nvme_process_aers(n); + + QTAILQ_FOREACH_SAFE(event, &n->aer_queue, entry, next) { + if (event->result.event_type =3D=3D event_type) { + QTAILQ_REMOVE(&n->aer_queue, event, entry); + n->aer_queued--; + } } } =20 diff --git a/hw/block/trace-events b/hw/block/trace-events index cab9913b1f2d..11bad6ae6a11 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -67,7 +67,7 @@ pci_nvme_aer_post_cqe(uint8_t typ, uint8_t info, uint8_t = log_page) "type 0x%"PRI pci_nvme_enqueue_event(uint8_t typ, uint8_t info, uint8_t log_page) "type = 0x%"PRIx8" info 0x%"PRIx8" lid 0x%"PRIx8"" pci_nvme_enqueue_event_noqueue(int queued) "queued %d" pci_nvme_enqueue_event_masked(uint8_t typ) "type 0x%"PRIx8"" -pci_nvme_no_outstanding_aers(void) "ignoring event; no outstanding AERs" +pci_nvme_no_outstanding_aers(void) "no outstanding aers" pci_nvme_enqueue_req_completion(uint16_t cid, uint16_t cqid, uint16_t stat= us) "cid %"PRIu16" cqid %"PRIu16" status 0x%"PRIx16"" pci_nvme_mmio_read(uint64_t addr) "addr 0x%"PRIx64"" pci_nvme_mmio_write(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" data 0= x%"PRIx64"" --=20 2.28.0