From patchwork Sun Nov 25 23:03:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10697185 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 DE49E13BF for ; Sun, 25 Nov 2018 23:04:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4D9B28E04 for ; Sun, 25 Nov 2018 23:04:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B81C728EC7; Sun, 25 Nov 2018 23:04:52 +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=-6.1 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,URIBL_SBL 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 44FC528E04 for ; Sun, 25 Nov 2018 23:04:52 +0000 (UTC) Received: from localhost ([::1]:33398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gR3SN-0007Yo-Hl for patchwork-qemu-devel@patchwork.kernel.org; Sun, 25 Nov 2018 18:04:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gR3Re-0007FK-3k for qemu-devel@nongnu.org; Sun, 25 Nov 2018 18:04:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gR3Rc-0001zu-Uo for qemu-devel@nongnu.org; Sun, 25 Nov 2018 18:04:06 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:39129) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gR3Ra-0001yV-5c; Sun, 25 Nov 2018 18:04:02 -0500 Received: by mail-pl1-x643.google.com with SMTP id 101so6635295pld.6; Sun, 25 Nov 2018 15:03:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=CJweXxiKgoQ8l5NrOBq3FAZ8bG9yUbfcRILellV7qVw=; b=LKDIefFkUDYNcLCIVHKqUSTUlViddv4ZYoOd+LFgvdbIiOH/z4hQPao5U2H4jeUECw Wo14EMWkNUsxwohfP8gGCcnHEBnyfYrgVjf0pUdRfNlmYqhngH7yHvGX5qKbFtjOtjxT 7smD5dfVTkklDV+ETVlj8NQnUIoH0RAn0kuk0Zja6HaosrkbQqo8NKY9sOVi8m5VReYZ kfXriyb0DatPtm9QoEmE12rB5xlEJnNNf6nZDE52FaE7yXG0YpJKYrHfAtaIiz7Mdsf7 oNtGh5JmQycD5ODkR+B7hhOdm4W51zXfSb3q004/Mg0U1ehyB13sHa76jIEJueoZ5qAz VNUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=CJweXxiKgoQ8l5NrOBq3FAZ8bG9yUbfcRILellV7qVw=; b=ZyRClQz9rXRv2nIuficvvKxGHcjt1vNc0f2vVDxGbeiW1nZHVWO//bkb1eTtnyXJDt iPg8SNPWt1N/J6BJ1YrEr3KHGa4EJVn7SNjd+zQWfVDql/Ic8io+fvnVs8+spc/UIEjH THKof0Yjgp7/7DdT2HCffw4anJX7HoJ6lJjxigXbWEhllnqggOejTFvuxPxEcMm92OKd GJ/1U9CvKSgu5V967EI5z49IIo7w+hjrO8QY1pmEqNzBGhEqlXFVlTBrk2hAnxMbbB3Y tv2CD6XIJDV0AwJkbSteN7MqptWIRBhqjWWa+N8DCAChxng39zxrV2OG/pb9EDqvO2EA WmSw== X-Gm-Message-State: AA+aEWZQReq8GJ3MmBAHgKAdUY+WvYgwwSmKPFyddvcTvj2MwELD3bll EHCTSDN7xOc4WHxpJO/rnkU= X-Google-Smtp-Source: AFSGD/WP5J+yXN9Z9hqkWzh7G8S6VduDfzm/jMFySdzphl4oOGh5YWnfMIpeqHfO1Rxu66it1UR4kQ== X-Received: by 2002:a17:902:b112:: with SMTP id q18mr8439844plr.255.1543187038257; Sun, 25 Nov 2018 15:03:58 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id l16sm59364967pfg.161.2018.11.25.15.03.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 15:03:57 -0800 (PST) From: Guenter Roeck To: Keith Busch Date: Sun, 25 Nov 2018 15:03:55 -0800 Message-Id: <1543187035-32757-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH] nvme: Only generate interupt if warranted 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: Kevin Wolf , Guenter Roeck , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP So far the code generates interrupts even if it doesn't pass any new information to the user. This can result in spurious interrupts as sometimes observed with Linux. Only generate interrupts if warranted, ie if anything new is passed to the emulated code. Signed-off-by: Guenter Roeck --- hw/block/nvme.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 9fbe567..c543c01 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -252,6 +252,7 @@ static void nvme_post_cqes(void *opaque) NvmeCQueue *cq = opaque; NvmeCtrl *n = cq->ctrl; NvmeRequest *req, *next; + bool assert_irq = false; QTAILQ_FOREACH_SAFE(req, &cq->req_list, entry, next) { NvmeSQueue *sq; @@ -271,8 +272,11 @@ static void nvme_post_cqes(void *opaque) pci_dma_write(&n->parent_obj, addr, (void *)&req->cqe, sizeof(req->cqe)); QTAILQ_INSERT_TAIL(&sq->req_list, req, entry); + assert_irq = true; + } + if (assert_irq) { + nvme_irq_assert(n, cq); } - nvme_irq_assert(n, cq); } static void nvme_enqueue_req_completion(NvmeCQueue *cq, NvmeRequest *req)