Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp405932pxu; Tue, 1 Dec 2020 14:27:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTzTdQIPW8zqLI+JpJsaI/oEGW21kypRimpcW3stIooN8nbpUXEsBejQseKBkL3+0I/8os X-Received: by 2002:a05:6402:1646:: with SMTP id s6mr5295204edx.319.1606861630552; Tue, 01 Dec 2020 14:27:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861630; cv=none; d=google.com; s=arc-20160816; b=ymLHsXU29baJ40tncWJrjNR/jZze6W1EVQIwHjYxN7cvT5j67JFlck1MIIl67vptth 995NusDVad/ngP7BKZdcJaTvjcZihdhH6s7O+SH5o/F0A8bhjJdkkJX9g7BIUL6qeWRn l+kTx9jckmP7FuQNhW/gZ7NC+aa7kB9f3vytr7Wp04bEk/sfliUvb6xiIVuh8tvsYDWF hiFAPCocClZ9WTRJCWo6NQAbw4lC0KsatWSo89ewfzE9BWgOZABay/9WG/GC2ZeUP3Y4 0402BmrZbIZcLrHgr33IJzxv1l5HaeEXAdX0N8yt0dP5Vb5dQdKZWeJ79T9/mKjJshBf wPWQ== 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=B/dcpj6K34dBkmACQhlTZTDTZ1Cf6Bfjy3lwEhkyxu4=; b=yrdN0IF2W/ghRBP8MrA2pDUJ1GP80H1/bNwF2c8tcgQlM3eHnS5PIavuQ8DtjGCj4r YxtdnAI9+NUV621yEyCZfw9yIb+C8TgYyoEgkhSZYmk/No8HLkgbeBFomx7S5N+Wkm0I hD42OqFtrBMc+9UZo9l/B02+UVidYgQzJX0yIhfevcmKemqFg0sxm9Zeoe5Eo3E+0ehn AitsZMcDDkFnyZwaQhWcF6pq61MaY32ii3uq9mTvVOPz4DT0523mhV8NH5T1IM3w+1bS PnsBalU5Ho9aGOglr1ILnUODiYm1lquSbZkgwoXZ6DNXxk9leDCwlMZjsEzseboqUTij A9uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jhu0HsLZ; 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 hp33si815775ejc.250.2020.12.01.14.26.47; Tue, 01 Dec 2020 14:27:10 -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=jhu0HsLZ; 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 S2389655AbgLAJKO (ORCPT + 99 others); Tue, 1 Dec 2020 04:10:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:47692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389644AbgLAJKJ (ORCPT ); Tue, 1 Dec 2020 04:10:09 -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 287BE21D7A; Tue, 1 Dec 2020 09:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813768; bh=oWJaho/gHzQdr2VXxpGnYFO4lgkJY6XVJcmPdo4Qeas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jhu0HsLZUKzBapVW9EgjXbgE6nDvfIL959YVL/eMUzPzYxppSP7D0cHSTWRQUoTKK ZoeAI5BsyCM05yfhZzKgxCwJLKCLNtsyOrfOV3y0SYXYGtdlYI/9TnKhuH4szfmp80 LeSRyNGl6jida7vfDXXzZQDpwLHWRZivyK1oHyyE= 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 5.9 053/152] nvme: free sq/cq dbbuf pointers when dbbuf set fails Date: Tue, 1 Dec 2020 09:52:48 +0100 Message-Id: <20201201084718.879366589@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@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 a6af96aaa0eb7..3448f7ac209a0 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -292,9 +292,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; @@ -308,6 +320,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