From patchwork Tue Mar 3 17:43:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 229932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB8A6C3F2D1 for ; Tue, 3 Mar 2020 18:06:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E6D0214DB for ; Tue, 3 Mar 2020 18:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583258793; bh=17gVuyQ1l3tn5XxQiYJeWbGZ1+R3HWDG6NBZT0iJcxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=a2k7h2RWZByKCSOpoXBe0ZeDahivZFuVfVPN3b8DRnDK6QTCf/P5tos56uyf2jWJ9 Sj2PNDPJ1f02FWTsRLQ8Tgh30LFXpB8WbRUVsouuC5WLz0mNVHW/Du8W4OpmI5fwDU GgJKQoAXMjAdntB7nRExPLBcLI3h8dadx7nZRls4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732892AbgCCR4Z (ORCPT ); Tue, 3 Mar 2020 12:56:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:38566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732863AbgCCR4Y (ORCPT ); Tue, 3 Mar 2020 12:56:24 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C2DDA20656; Tue, 3 Mar 2020 17:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583258184; bh=17gVuyQ1l3tn5XxQiYJeWbGZ1+R3HWDG6NBZT0iJcxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WfeIO7hj3gm3jN4E5I84Ufru1xbYH6/nOtxDuWgdG97yK6LFkaXQePi5AKXL421GJ GDs5IgDJ2POaljJEc5GZTHP1PLhZHTN2bCEbdbA6lm0rbHkHWwB2+VNKtZjaxTVwwI O3qg0pTg3wA8ij2ODl563xzy+PMvMLlPBaT4Rbss= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bijan Mottahedeh , Sagi Grimberg , Jens Axboe , Keith Busch Subject: [PATCH 5.4 104/152] nvme-pci: Hold cq_poll_lock while completing CQEs Date: Tue, 3 Mar 2020 18:43:22 +0100 Message-Id: <20200303174314.420132252@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174302.523080016@linuxfoundation.org> References: <20200303174302.523080016@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bijan Mottahedeh commit 9515743bfb39c61aaf3d4f3219a645c8d1fe9a0e upstream. Completions need to consumed in the same order the controller submitted them, otherwise future completion entries may overwrite ones we haven't handled yet. Hold the nvme queue's poll lock while completing new CQEs to prevent another thread from freeing command tags for reuse out-of-order. Fixes: dabcefab45d3 ("nvme: provide optimized poll function for separate poll queues") Signed-off-by: Bijan Mottahedeh Reviewed-by: Sagi Grimberg Reviewed-by: Jens Axboe Signed-off-by: Keith Busch Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1084,9 +1084,9 @@ static int nvme_poll(struct blk_mq_hw_ct spin_lock(&nvmeq->cq_poll_lock); found = nvme_process_cq(nvmeq, &start, &end, -1); + nvme_complete_cqes(nvmeq, start, end); spin_unlock(&nvmeq->cq_poll_lock); - nvme_complete_cqes(nvmeq, start, end); return found; }