Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp408549pxu; Tue, 1 Dec 2020 14:31:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZn0uRLNVF1VlEJpEF+ynRQvaK5SzJXHwtGbtBcD0bSf0Ag/taoqDgsQQAPZbRH9+AUl1X X-Received: by 2002:a05:6402:1155:: with SMTP id g21mr5491136edw.53.1606861906380; Tue, 01 Dec 2020 14:31:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861906; cv=none; d=google.com; s=arc-20160816; b=mekzQXh9uC8ij6CHeeAL1jDRm8F7DGmdrz48Rl+8LgcB1fZpRMMHnDpPoytI9slgP9 /dn6wIE1qOWL9SuxZ3YOEZFgHq+HHen35HBdhJKjGJBu0hsbAey6R3X3q1a7tCQoLOFx +KGZ/J82RNLSrYxReUOqSmnejp5dhfOu95CYYvRwhxuPReaesmKvhtiOjN/jmGMBoHVS B5Bt90WUE9un1hXUEJAJ6fZPQBJpazkhWBrZHCHB6ErQB2aAV9Z/lO7MVoGalTyT/Tnz EFVGRRehH96nYQ+j3IGMWyN3XiHWtpTdixgfXVhFOF2u3BhrgilathFe2JRgPCM8th6q k/ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J+qeB0F02T9UcfXu7XHfxlYv3RLp5nfEDmWI3flZ58s=; b=ESoMgTj9Hl5LdoQy0w9vruyUzu3w4WZn8/8WoNPfaQvq8vA8z/FRwYcrPzszSt4CgJ WRZfMUx/eiLhZx+L92KdjUrcoeJkoT3vwKCCgj8U447IIRInyBDWeGch1MeDA+A7wKda DJpBFMJaAz9xRVplwuZnkhOowRVBVk/DOii3QS5fFJEHdHvsFYnA6p1OLpuKWOpvmfBp wxcYZmdFEntZDK5rva/9qD0WjoqjEc1VsYX6YhqYAHE1kSHky+dx8nISrQrsJq3Y/OWz crRSbC30hlPnrPyGD80wwIpxNBSDTeBP9I48lJYD1W2NoRAwxB1da0oNDEVvFThLma0y r2Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wsCD6AlY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si820150eds.198.2020.12.01.14.31.24; Tue, 01 Dec 2020 14:31:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wsCD6AlY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391023AbgLAJ3Q (ORCPT + 99 others); Tue, 1 Dec 2020 04:29:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:33962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387641AbgLAI7V (ORCPT ); Tue, 1 Dec 2020 03:59:21 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 D16FB217A0; Tue, 1 Dec 2020 08:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813145; bh=0n8jfaMWrlyg/5o+SmqrjEegfZzl9GLztMgGWzfjofw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wsCD6AlYbSl48qj+mkqCt0VwBrKgfPJQQUEnQFckgOtlfjxDao5nO+EECHIcd8FGO icruLpKHwLb+5932C34mxaxVq7QyTREREEoCFzobTEkW1JMpSc992+XsiQ8NTePvvj aAls2tR1REjel/hOYymudwmPNjxcXYJhuFOA56vg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Minwoo Im , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.14 21/50] nvme: free sq/cq dbbuf pointers when dbbuf set fails Date: Tue, 1 Dec 2020 09:53:20 +0100 Message-Id: <20201201084647.730069293@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084644.803812112@linuxfoundation.org> References: <20201201084644.803812112@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Minwoo Im [ Upstream commit 0f0d2c876c96d4908a9ef40959a44bec21bdd6cf ] If Doorbell Buffer Config command fails even 'dev->dbbuf_dbs != NULL' which means OACS indicates that NVME_CTRL_OACS_DBBUF_SUPP is set, nvme_dbbuf_update_and_check_event() will check event even it's not been successfully set. This patch fixes mismatch among dbbuf for sq/cqs in case that dbbuf command fails. Signed-off-by: Minwoo Im Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 3788c053a0b19..540fab9f850dd 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -266,9 +266,21 @@ static void nvme_dbbuf_init(struct nvme_dev *dev, nvmeq->dbbuf_cq_ei = &dev->dbbuf_eis[cq_idx(qid, dev->db_stride)]; } +static void nvme_dbbuf_free(struct nvme_queue *nvmeq) +{ + if (!nvmeq->qid) + return; + + nvmeq->dbbuf_sq_db = NULL; + nvmeq->dbbuf_cq_db = NULL; + nvmeq->dbbuf_sq_ei = NULL; + nvmeq->dbbuf_cq_ei = NULL; +} + static void nvme_dbbuf_set(struct nvme_dev *dev) { struct nvme_command c; + unsigned int i; if (!dev->dbbuf_dbs) return; @@ -282,6 +294,9 @@ static void nvme_dbbuf_set(struct nvme_dev *dev) dev_warn(dev->ctrl.device, "unable to set dbbuf\n"); /* Free memory and continue on */ nvme_dbbuf_dma_free(dev); + + for (i = 1; i <= dev->online_queues; i++) + nvme_dbbuf_free(&dev->queues[i]); } } -- 2.27.0