From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753999AbcBAQ5K (ORCPT ); Mon, 1 Feb 2016 11:57:10 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:30858 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752613AbcBAQ5H (ORCPT ); Mon, 1 Feb 2016 11:57:07 -0500 Subject: Re: [PATCH] NVMe: do not touch sq door bell if nvmeq has been suspended To: Wenbo Wang , References: <1454341324-21273-1-git-send-email-mail_weber_wang@163.com> CC: , Wenbo Wang , From: Jens Axboe Message-ID: <56AF8DB5.70206@fb.com> Date: Mon, 1 Feb 2016 09:54:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1454341324-21273-1-git-send-email-mail_weber_wang@163.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.54.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-02-01_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/01/2016 08:42 AM, Wenbo Wang wrote: > If __nvme_submit_cmd races with nvme_dev_disable, nvmeq > could have been suspended and dev->bar could have been > unmapped. Do not touch sq door bell in this case. > > Signed-off-by: Wenbo Wang > Reviewed-by: Wenwei Tao > CC: linux-nvme@lists.infradead.org > --- > drivers/nvme/host/pci.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index 8b1a725..2288712 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -325,7 +325,8 @@ static void __nvme_submit_cmd(struct nvme_queue *nvmeq, > > if (++tail == nvmeq->q_depth) > tail = 0; > - writel(tail, nvmeq->q_db); > + if (likely(nvmeq->cq_vector >= 0)) > + writel(tail, nvmeq->q_db); > nvmeq->sq_tail = tail; What Keith said (this should not happen), and additionally, this won't work for a polled CQ without a vector. -- Jens Axboe From mboxrd@z Thu Jan 1 00:00:00 1970 From: axboe@fb.com (Jens Axboe) Date: Mon, 1 Feb 2016 09:54:13 -0700 Subject: [PATCH] NVMe: do not touch sq door bell if nvmeq has been suspended In-Reply-To: <1454341324-21273-1-git-send-email-mail_weber_wang@163.com> References: <1454341324-21273-1-git-send-email-mail_weber_wang@163.com> Message-ID: <56AF8DB5.70206@fb.com> On 02/01/2016 08:42 AM, Wenbo Wang wrote: > If __nvme_submit_cmd races with nvme_dev_disable, nvmeq > could have been suspended and dev->bar could have been > unmapped. Do not touch sq door bell in this case. > > Signed-off-by: Wenbo Wang > Reviewed-by: Wenwei Tao > CC: linux-nvme at lists.infradead.org > --- > drivers/nvme/host/pci.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index 8b1a725..2288712 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -325,7 +325,8 @@ static void __nvme_submit_cmd(struct nvme_queue *nvmeq, > > if (++tail == nvmeq->q_depth) > tail = 0; > - writel(tail, nvmeq->q_db); > + if (likely(nvmeq->cq_vector >= 0)) > + writel(tail, nvmeq->q_db); > nvmeq->sq_tail = tail; What Keith said (this should not happen), and additionally, this won't work for a polled CQ without a vector. -- Jens Axboe