Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1597655ybv; Fri, 21 Feb 2020 00:01:21 -0800 (PST) X-Google-Smtp-Source: APXvYqyStZ1cRcvGKyJwv65FhqEfnIoz8yqE04lJ0bI7Awdrfln2wC5lDswdJM69+t60h/ieAILQ X-Received: by 2002:a9d:4c14:: with SMTP id l20mr26801731otf.125.1582272081738; Fri, 21 Feb 2020 00:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582272081; cv=none; d=google.com; s=arc-20160816; b=YRxq+3xmKX6YVIZyd/GENG6m2SQYih64zce5iBzxD1yB6U1c3qVDorU3P/YuhlHddW ovgT58V57hzqjEsrrTAxRCuhz2Tb2F5Tu3Bfe9oQUM50LkQ3SOnGj0lU4y+UxXSq1N97 QRworqWtuA1LXtQ0VHD93ZfX+5+9ZK1/WewFrv3miI7R51JtblqQ8p7LpwXxTJhcjLe6 fUSEELDuyhhMMgcnW49rckgfLSaQPRGelKmghkJB5LmgEoMdEGlJFQsyXj0+BIAZ7K+V LLQxNqUcNjW/2s5VkiIbdBYt2bUIjrQ7nN2NrM0bnvj+oGvMA2yzkjqH4Thv4YKn1jnQ pS9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6kOXJtgzTZUCSaKLoWZv4roPOyJcW2Ss/fVst6QFutI=; b=cW6r9s4jf+Na95TB0c2Fhsh8qr4/iXbqrIXXsZESXpEAce1r9KKWLkKaZk6v5R1L2g GZT5yPLgtRcj5bQfyz9OYVnNSJBLjWteedC2vJPT1CpfgL9PIwVjL+ZjjOznKXpqrBXb /M260412Cb2Ny17tuCx3ExN1XoPFjlb6st6n2RxU/pqModYADp244KrMqHuxCARijP7v gze7N/mRiTPj8tw0Ntyh6q/gScZ46CKqFjuWuEVDBw1uO4jMSAxoBupSX9szWZ9bcayB 4QJYraxuc21qoYhidmxBHd5oXMvSIDgfZqevNcAAIbnjUxMlt65COi2v14h3Wy5jfyRa i2mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KHsFgXKL; 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 w7si1077444otq.250.2020.02.21.00.01.09; Fri, 21 Feb 2020 00:01:21 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=KHsFgXKL; 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 S1731004AbgBUIAE (ORCPT + 99 others); Fri, 21 Feb 2020 03:00:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:60336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730993AbgBUIAD (ORCPT ); Fri, 21 Feb 2020 03:00:03 -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 488892073A; Fri, 21 Feb 2020 08:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582272002; bh=9Ctd1fmVcttbjX+dX5w5TzwYoyTQbQ9VFRC0ZOZZ1FI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KHsFgXKLecNCJhlS0ezmM1kQdQJYUiEhz9gd5Us6T4b+G2kPF+pZkhXKIuDAm9dWO y5Aoj3dGaIc6J/ZxVhZPjd+wKJtN8os5TW5ti4ZUEJnGvekLP7328mUcAYhsnlxM2Q KeeenxnDy+h+KKaUMllM6fpkHK0/HgFkWABFgpQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Edmund Nadolski , Christoph Hellwig , Keith Busch , Sasha Levin Subject: [PATCH 5.5 379/399] nvme-pci: remove nvmeq->tags Date: Fri, 21 Feb 2020 08:41:44 +0100 Message-Id: <20200221072437.090349283@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig [ Upstream commit cfa27356f835dc7755192e7b941d4f4851acbcc7 ] There is no real need to have a pointer to the tagset in struct nvme_queue, as we only need it in a single place, and that place can derive the used tagset from the device and qid trivially. This fixes a problem with stale pointer exposure when tagsets are reset, and also shrinks the nvme_queue structure. It also matches what most other transports have done since day 1. Reported-by: Edmund Nadolski Signed-off-by: Christoph Hellwig Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 365a2ddbeaa76..da392b50f73e7 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -167,7 +167,6 @@ struct nvme_queue { /* only used for poll queues: */ spinlock_t cq_poll_lock ____cacheline_aligned_in_smp; volatile struct nvme_completion *cqes; - struct blk_mq_tags **tags; dma_addr_t sq_dma_addr; dma_addr_t cq_dma_addr; u32 __iomem *q_db; @@ -376,29 +375,17 @@ static int nvme_admin_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, WARN_ON(hctx_idx != 0); WARN_ON(dev->admin_tagset.tags[0] != hctx->tags); - WARN_ON(nvmeq->tags); hctx->driver_data = nvmeq; - nvmeq->tags = &dev->admin_tagset.tags[0]; return 0; } -static void nvme_admin_exit_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx) -{ - struct nvme_queue *nvmeq = hctx->driver_data; - - nvmeq->tags = NULL; -} - static int nvme_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, unsigned int hctx_idx) { struct nvme_dev *dev = data; struct nvme_queue *nvmeq = &dev->queues[hctx_idx + 1]; - if (!nvmeq->tags) - nvmeq->tags = &dev->tagset.tags[hctx_idx]; - WARN_ON(dev->tagset.tags[hctx_idx] != hctx->tags); hctx->driver_data = nvmeq; return 0; @@ -948,6 +935,13 @@ static inline void nvme_ring_cq_doorbell(struct nvme_queue *nvmeq) writel(head, nvmeq->q_db + nvmeq->dev->db_stride); } +static inline struct blk_mq_tags *nvme_queue_tagset(struct nvme_queue *nvmeq) +{ + if (!nvmeq->qid) + return nvmeq->dev->admin_tagset.tags[0]; + return nvmeq->dev->tagset.tags[nvmeq->qid - 1]; +} + static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx) { volatile struct nvme_completion *cqe = &nvmeq->cqes[idx]; @@ -972,7 +966,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx) return; } - req = blk_mq_tag_to_rq(*nvmeq->tags, cqe->command_id); + req = blk_mq_tag_to_rq(nvme_queue_tagset(nvmeq), cqe->command_id); trace_nvme_sq(req, cqe->sq_head, nvmeq->sq_tail); nvme_end_request(req, cqe->status, cqe->result); } @@ -1572,7 +1566,6 @@ static const struct blk_mq_ops nvme_mq_admin_ops = { .queue_rq = nvme_queue_rq, .complete = nvme_pci_complete_rq, .init_hctx = nvme_admin_init_hctx, - .exit_hctx = nvme_admin_exit_hctx, .init_request = nvme_init_request, .timeout = nvme_timeout, }; -- 2.20.1