Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2012866imm; Thu, 24 May 2018 04:30:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZodNk2O3YRtU8Er41FmZTZMlY76hBHcN4teVyLZXDoqBWIkCwEM3CJgzr43QA0c6oJuhqms X-Received: by 2002:a65:60d1:: with SMTP id r17-v6mr5655395pgv.410.1527161450519; Thu, 24 May 2018 04:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161450; cv=none; d=google.com; s=arc-20160816; b=WzkC//yfs2ZIyzUAEw5Ijp3SdSTP1umXGi06NXF6EZh7oS1moFWPUAg6ej/FwL/MDb bLYN4HhoDa/Qw4gtcAH3qor7wTxuWsZrIIkfznNthsd/SuxB2l6TmCy5AbmKWw3enJMJ 2xbPO61ei+1MgRyY0UqmydStcf018PjNYV6JGWSENyCagmL6Vi8VMaKgDtg8HPwTiJiq lWIMK6TpwCaEAqOAqw9nlK2YAyOSNquMs1ZViZYXy7b/DsR05H5YE8jNcELM2Qta+NQZ dAo0XSEz8+hGS/t0Ci+pMTtzdbocXlsElTJ+2T4rxy8o4R+9pcxuY6TYIL8hiFDces6n aDDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=riu7N3JXEsl1AK6JX3x+hUfGJL4C/O3vNXrtVlTXV28=; b=0S3YiHC2fmPAz+7NCND3HvyYDnThkHkbLgVSkCbozGOR8AT6ncjdsQHrkX60GnqBR4 +dlxHaIxGQSlSYHMS8lUpssIXDsfr6zXKjIX1OoB4i2Aa2H0FiD02WiP1ctVbqJHvQfa XOlhNZDGlK0PWQ+Erv4AFXj+rPUl0ebI3eQXpyRdkTP6iDVkWzieBEuMlh3sO2CEmpcb fMr6UKpCmfKE7XH5lwCDFxJG0OoyEpHD5Mv6hV4a2K4N41pogH+SYft7Kc4bAI7ctFsa MK36Z2XZxjKQV8kNzVv9WTFNtoFlfu99EhDsxfOikh4c+LiXY61Xx2I8GG4N4SObo11g JRwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=tRHE0Hwq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l65-v6si20675860pfb.69.2018.05.24.04.30.36; Thu, 24 May 2018 04:30:50 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=tRHE0Hwq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967667AbeEXJvS (ORCPT + 99 others); Thu, 24 May 2018 05:51:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36250 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967312AbeEXJvK (ORCPT ); Thu, 24 May 2018 05:51:10 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4O9oTXw189407; Thu, 24 May 2018 09:50:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2017-10-26; bh=riu7N3JXEsl1AK6JX3x+hUfGJL4C/O3vNXrtVlTXV28=; b=tRHE0Hwqe1VgVA73s5ecvGViBFuCA0UQ22L1RATMTQNgIahfK8z/Z/6ck6h+Q8qnaoM0 nhhbwkp9WdPdx6HB6TtolvQOhwI/lyWT243vzRNXjfpDX9UfwtRU97AuxYCgCbcPb9lV ZZh85P/OYtqrKAsy5ltIZw7kdNcbDYIT6JIJkiT+vsVqycD3uyl7Rv/R4kBFZ00ys+dj r9T1YnanOwLL1L+KtdY21+Sy1umrkx4brtTLi6sBr2xm0BxNznamsJ7Oa60MhEHFFv9N 9sMAu+BrC7qT5CQrNqXg9jQj53QmxA/STDjBrYGtI7ui8BJyb5WhmOLz9llzo7ON/GqG qw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2j4nh7qkvv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 May 2018 09:50:41 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w4O9oeED017878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 May 2018 09:50:40 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w4O9odkD030553; Thu, 24 May 2018 09:50:40 GMT Received: from will-ThinkCentre-M910s.cn.oracle.com (/10.182.70.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 May 2018 02:50:39 -0700 From: Jianchao Wang To: keith.busch@intel.com, axboe@fb.com, hch@lst.de, sagi@grimberg.me Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] nvme-pci: set nvmeq->cq_vector after alloc cq/sq Date: Thu, 24 May 2018 17:51:33 +0800 Message-Id: <1527155494-1891-1-git-send-email-jianchao.w.wang@oracle.com> X-Mailer: git-send-email 2.7.4 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8902 signatures=668700 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805240119 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently nvmeq->cq_vector is set before alloc cq/sq. If the alloc cq/sq command timeout, nvme_suspend_queue will invoke free_irq for the nvmeq because the cq_vector is valid, this will cause warning 'Trying to free already-free IRQ xxx'. set nvmeq->cq_vector after alloc cq/sq successes to fix this. Signed-off-by: Jianchao Wang --- drivers/nvme/host/pci.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 17a0190..70b79f2 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1070,7 +1070,7 @@ static int adapter_delete_queue(struct nvme_dev *dev, u8 opcode, u16 id) } static int adapter_alloc_cq(struct nvme_dev *dev, u16 qid, - struct nvme_queue *nvmeq) + struct nvme_queue *nvmeq, int cq_vector) { struct nvme_command c; int flags = NVME_QUEUE_PHYS_CONTIG | NVME_CQ_IRQ_ENABLED; @@ -1085,7 +1085,7 @@ static int adapter_alloc_cq(struct nvme_dev *dev, u16 qid, c.create_cq.cqid = cpu_to_le16(qid); c.create_cq.qsize = cpu_to_le16(nvmeq->q_depth - 1); c.create_cq.cq_flags = cpu_to_le16(flags); - c.create_cq.irq_vector = cpu_to_le16(nvmeq->cq_vector); + c.create_cq.irq_vector = cpu_to_le16(cq_vector); return nvme_submit_sync_cmd(dev->ctrl.admin_q, &c, NULL, 0); } @@ -1459,6 +1459,7 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) { struct nvme_dev *dev = nvmeq->dev; int result; + int cq_vector; if (dev->cmb && use_cmb_sqes && (dev->cmbsz & NVME_CMBSZ_SQS)) { unsigned offset = (qid - 1) * roundup(SQ_SIZE(nvmeq->q_depth), @@ -1471,15 +1472,21 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) * A queue's vector matches the queue identifier unless the controller * has only one vector available. */ - nvmeq->cq_vector = dev->num_vecs == 1 ? 0 : qid; - result = adapter_alloc_cq(dev, qid, nvmeq); + cq_vector = dev->num_vecs == 1 ? 0 : qid; + result = adapter_alloc_cq(dev, qid, nvmeq, cq_vector); if (result < 0) - goto release_vector; + goto out; result = adapter_alloc_sq(dev, qid, nvmeq); if (result < 0) goto release_cq; + /* + * set cq_vector after alloc cq/sq, otherwise, if alloc cq/sq command + * timeout, nvme_suspend_queue will invoke free_irq for it and cause warning + * 'Trying to free already-free IRQ xxx' + */ + nvmeq->cq_vector = cq_vector; nvme_init_queue(nvmeq, qid); result = queue_request_irq(nvmeq); if (result < 0) @@ -1487,13 +1494,13 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) return result; - release_sq: +release_sq: + nvmeq->cq_vector = -1; dev->online_queues--; adapter_delete_sq(dev, qid); - release_cq: +release_cq: adapter_delete_cq(dev, qid); - release_vector: - nvmeq->cq_vector = -1; +out: return result; } -- 2.7.4