Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2042314imm; Mon, 16 Jul 2018 00:44:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeXtE+e8QTGmhdAoWx19SsFXwxzS2vtVXMbhfLHuv1O4BlY/d/XsXPA13V/AP23JLVGxq1T X-Received: by 2002:a17:902:184:: with SMTP id b4-v6mr15922863plb.340.1531727076550; Mon, 16 Jul 2018 00:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531727076; cv=none; d=google.com; s=arc-20160816; b=VR3M6CHPKfENoQ2yFCxtTAN/DnmH4ohlqRXCVH/DwMZvE2HKR9vMuw6xTAJ3KsAGn/ qGV7eUkgH2O1mAKUw966S4GIF7nQJGvQ/nx7imt2sxc8ylGHq5Pq05HhOSnmKbRLK41H 4jowRlyDpIgoMqFWhfNs+M2HlZlWcPq8+1NrCCH5FfNA9w3MIcbb5bmC3fda5VWEzFvp lhZTIYYKpauabzs1rAgX/3N2g2pr+9llZX5n87DvcOZVk1CebNdWJ7/CFecUWz8aXuRr W92v5xRlTMDNxIOH0EpZaimAIYiFbBAlB5LIIEZXnHe0jB1SBb1Z9BFYDG48E5DjemGq 5n9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=tEctW6TfC7qtAoUYI7rQ6oyLIyJ0LcYtL96AguxE+Oc=; b=Eqyg4uaYFikVosxMcPsdPYLlpUHfvzHfsghmA48OUIsSh/CcM0XnPbudbAYy74/sNd DY9OJct/FhzHv6F+TUM7ArX13i1iTFdaA8XM0Jzpm2weizwYUiQSozoSeMwexa8bNGvz hBrwvRMZKMKve6NlKpKLaWJosg+zcCeH0MylDrTMqkAeRq1ioMRdS1vHc8XVC4SJOMi9 b0HteY7bTaTBlQ2QdOUWv2Hf4xfJWfDUXjlsxHYLgnWsAQLC9CnZQ4gywv2sQBbCYnBN aRwFj/r7zPYqXJ2JulsizlIiEy3UCiOqxiodsANtY9N/g4LZq7ftC7pppLIkJ21rSdLJ vxpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11-v6si15060148pgo.278.2018.07.16.00.44.21; Mon, 16 Jul 2018 00:44:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388954AbeGPIJM (ORCPT + 99 others); Mon, 16 Jul 2018 04:09:12 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47932 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730161AbeGPIJL (ORCPT ); Mon, 16 Jul 2018 04:09:11 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id F0778C03; Mon, 16 Jul 2018 07:43:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Black , Jon Derrick , Keith Busch , Christoph Hellwig , Scott Bauer Subject: [PATCH 4.9 25/32] nvme-pci: Remap CMB SQ entries on every controller reset Date: Mon, 16 Jul 2018 09:36:33 +0200 Message-Id: <20180716073507.676609755@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073504.433996952@linuxfoundation.org> References: <20180716073504.433996952@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Keith Busch commit 815c6704bf9f1c59f3a6be380a4032b9c57b12f1 upstream. The controller memory buffer is remapped into a kernel address on each reset, but the driver was setting the submission queue base address only on the very first queue creation. The remapped address is likely to change after a reset, so accessing the old address will hit a kernel bug. This patch fixes that by setting the queue's CMB base address each time the queue is created. Fixes: f63572dff1421 ("nvme: unmap CMB and remove sysfs file in reset path") Reported-by: Christian Black Cc: Jon Derrick Cc: # 4.9+ Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig Signed-off-by: Scott Bauer Reviewed-by: Jon Derrick Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/pci.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1034,17 +1034,15 @@ static int nvme_cmb_qdepth(struct nvme_d static int nvme_alloc_sq_cmds(struct nvme_dev *dev, struct nvme_queue *nvmeq, int qid, int depth) { - if (qid && dev->cmb && use_cmb_sqes && NVME_CMB_SQS(dev->cmbsz)) { - unsigned offset = (qid - 1) * roundup(SQ_SIZE(depth), - dev->ctrl.page_size); - nvmeq->sq_dma_addr = dev->cmb_bus_addr + offset; - nvmeq->sq_cmds_io = dev->cmb + offset; - } else { - nvmeq->sq_cmds = dma_alloc_coherent(dev->dev, SQ_SIZE(depth), - &nvmeq->sq_dma_addr, GFP_KERNEL); - if (!nvmeq->sq_cmds) - return -ENOMEM; - } + + /* CMB SQEs will be mapped before creation */ + if (qid && dev->cmb && use_cmb_sqes && NVME_CMB_SQS(dev->cmbsz)) + return 0; + + nvmeq->sq_cmds = dma_alloc_coherent(dev->dev, SQ_SIZE(depth), + &nvmeq->sq_dma_addr, GFP_KERNEL); + if (!nvmeq->sq_cmds) + return -ENOMEM; return 0; } @@ -1117,6 +1115,13 @@ static int nvme_create_queue(struct nvme struct nvme_dev *dev = nvmeq->dev; int result; + if (qid && dev->cmb && use_cmb_sqes && NVME_CMB_SQS(dev->cmbsz)) { + unsigned offset = (qid - 1) * roundup(SQ_SIZE(nvmeq->q_depth), + dev->ctrl.page_size); + nvmeq->sq_dma_addr = dev->cmb_bus_addr + offset; + nvmeq->sq_cmds_io = dev->cmb + offset; + } + nvmeq->cq_vector = qid - 1; result = adapter_alloc_cq(dev, qid, nvmeq); if (result < 0)