From patchwork Fri Jun 3 13:42:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 629838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3rLldn15fpz9t80; Fri, 3 Jun 2016 23:42:37 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b=WsGcW5s9; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1b8pMr-0001OH-8c; Fri, 03 Jun 2016 13:42:29 +0000 Received: from mail-it0-f46.google.com ([209.85.214.46]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1b8pMn-0001O1-DA for kernel-team@lists.ubuntu.com; Fri, 03 Jun 2016 13:42:25 +0000 Received: by mail-it0-f46.google.com with SMTP id z189so136760759itg.0 for ; Fri, 03 Jun 2016 06:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=vm6x9TxnoLTRDgQDd8T6HQybwkkLaxzYu538+VFKw9U=; b=WsGcW5s9sCzYF6ZKnlsb0NsNehzOvSNek1b2ZmJ/vLQprc8vlc5KX4NxIkRojDsLp8 O7zTGkE5/AFT0qxOZrKoTmc9vb73+h7olTf7bysHh8dEQexK/Od0OyvOOmVxToNVEN3R yb0fFQyuaPaMp8a5t9ZMIvNAG/qsYVxrArFHpf5L8yvzbxCZlq4leO94lsaJp/Ajzkht E9o4A6fP1WfqM129FtH71VT1fZxmkUD8E6gL1IkyebtswPrR4/S5n1guU3fHX1wpKWHl LH+4ghNtv4mEU1udjeMyfhS4oH9weDYuoaPhSTFc+F3Ka1EDN7vyMXHIgbu8TK8KaeWe RcRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=vm6x9TxnoLTRDgQDd8T6HQybwkkLaxzYu538+VFKw9U=; b=m8UX8OlsfQ4VVR9gq62frLdlF98YM/H7ot1d0VDLM86IMr58ngNiAaTUUOyOYPXF5S HmHMtQedty0sGLQ4nSXfFtesOQ6hrHQ65AZSgLTvE7q/EtV5Wj+jbKzpJwlcCF+1lf+P dEgZ+tOLqFdSS12aqNaZnpDnTmRciepeKC9FcynQahhqiEaq4DRK11O0T1Ia9rrkSEhT c+/pb+mlRiBw8IqgDfEsqHYIGa+ftuPcrD4Y04Likp2T1cQm3xq15aYo87I4HyBfyBQS 7tqihfy2LAomshcBcAMgT7BmZDWn+oUuqypWJitjYC633byRTrQegnVAqJ7vsFNGnRrI xHaA== X-Gm-Message-State: ALyK8tJYQDjEy0QtNAPWEDlCoVVWqasuzxemOreq70Ulok9CNVn/RcbU0Qw6/S0oU3FY3iio X-Received: by 10.36.149.215 with SMTP id m206mr5440607itd.20.1464961344286; Fri, 03 Jun 2016 06:42:24 -0700 (PDT) Received: from localhost.localdomain (host-174-45-44-32.hln-mt.client.bresnan.net. [174.45.44.32]) by smtp.gmail.com with ESMTPSA id q131sm2788652iod.40.2016.06.03.06.42.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Jun 2016 06:42:23 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/3 Xenial SRU] nvme: set queue limits for the admin queue Date: Fri, 3 Jun 2016 07:42:15 -0600 Message-Id: <1464961337-19608-1-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 1.9.1 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Christoph Hellwig BugLink: http://bugs.launchpad.net/bugs/1588449 Factor out a helper to set all the device specific queue limits and apply them to the admin queue in addition to the I/O queues. Without this the command size on the admin queue is arbitrarily low, and the missing other limitations are just minefields waiting for victims. Signed-off-by: Christoph Hellwig Reported-by: Jeff Lien Tested-by: Jeff Lien Reviewed-by: Keith Busch Signed-off-by: Jens Axboe (cherry picked from commit da35825d9a091a7a1d5824c8468168e2658333ff) Signed-off-by: Tim Gardner --- drivers/nvme/host/core.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index a87320c..fde3b4a 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -835,6 +835,21 @@ int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl) return ret; } +static void nvme_set_queue_limits(struct nvme_ctrl *ctrl, + struct request_queue *q) +{ + if (ctrl->max_hw_sectors) { + blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors); + blk_queue_max_segments(q, + (ctrl->max_hw_sectors / (ctrl->page_size >> 9)) + 1); + } + if (ctrl->stripe_size) + blk_queue_chunk_sectors(q, ctrl->stripe_size >> 9); + if (ctrl->vwc & NVME_CTRL_VWC_PRESENT) + blk_queue_flush(q, REQ_FLUSH | REQ_FUA); + blk_queue_virt_boundary(q, ctrl->page_size - 1); +} + /* * Initialize the cached copies of the Identify data and various controller * register in our nvme_ctrl structure. This should be called as soon as @@ -892,6 +907,8 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) } } + nvme_set_queue_limits(ctrl, ctrl->admin_q); + kfree(id); return 0; } @@ -1139,17 +1156,9 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) ns->disk = disk; ns->lba_shift = 9; /* set to a default value for 512 until disk is validated */ + blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift); - if (ctrl->max_hw_sectors) { - blk_queue_max_hw_sectors(ns->queue, ctrl->max_hw_sectors); - blk_queue_max_segments(ns->queue, - (ctrl->max_hw_sectors / (ctrl->page_size >> 9)) + 1); - } - if (ctrl->stripe_size) - blk_queue_chunk_sectors(ns->queue, ctrl->stripe_size >> 9); - if (ctrl->vwc & NVME_CTRL_VWC_PRESENT) - blk_queue_flush(ns->queue, REQ_FLUSH | REQ_FUA); - blk_queue_virt_boundary(ns->queue, ctrl->page_size - 1); + nvme_set_queue_limits(ctrl, ns->queue); disk->major = nvme_major; disk->first_minor = 0;