From nobody Fri Apr 19 14:20:15 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@amazon.de; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1507761915059257.6610307417611; Wed, 11 Oct 2017 15:45:15 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1e2PkK-0008UA-9l; Thu, 12 Oct 2017 00:45:00 +0200 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]) by mail.coreboot.org with esmtps (TLSv1.2:RC4-SHA:128) (Exim 4.86_2) (envelope-from ) id 1e2Pk9-0008T3-HU for seabios@seabios.org; Thu, 12 Oct 2017 00:44:58 +0200 Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-9ec21598.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Oct 2017 22:44:08 +0000 Received: from uf8b156e456a5587c9af4.ant.amazon.com (iad7-ws-svc-lb50-vlan3.amazon.com [10.0.93.214]) by email-inbound-relay-1d-9ec21598.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id v9BMhhMh072933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Oct 2017 22:43:45 GMT Received: from uf8b156e456a5587c9af4.ant.amazon.com (localhost [127.0.0.1]) by uf8b156e456a5587c9af4.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id v9BMhgIe010857; Thu, 12 Oct 2017 00:43:43 +0200 Received: (from sironi@localhost) by uf8b156e456a5587c9af4.ant.amazon.com (8.15.2/8.15.2/Submit) id v9BMhg22010856; Thu, 12 Oct 2017 00:43:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1507761889; x=1539297889; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=2GQvh+VbqILfGZnLDVxiHCuSYC0RYmBGnVZSx2jZMWU=; b=VHdV5waiD9an6ZNlK1hxUqCIu3nlZOCpSHTHXptWEJbx49WiaE7Qcj6O YV1XwWlWBZj6/wP1b+eLXek6Aiocfj/e2C2s45Xv1RY3lvC8s7SuGbyn1 EwHgVkJaYQEm01ObiCGW31wV/Vhk4Fr3G4xnVichkBWwWOSohLJD4hMth 8=; X-IronPort-AV: E=Sophos;i="5.43,362,1503360000"; d="scan'208";a="567357099" From: Filippo Sironi To: seabios@seabios.org, kevin@koconnor.net Date: Thu, 12 Oct 2017 00:42:34 +0200 Message-Id: <1507761754-10584-1-git-send-email-sironi@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507668123-19960-1-git-send-email-sironi@amazon.de> References: <1507668123-19960-1-git-send-email-sironi@amazon.de> Precedence: Bulk X-Spam-Score: -10.6 (----------) Subject: [SeaBIOS] [PATCH v2] nvme: Use the Maximum Queue Entries Supported (MQES) to initialize I/O queues X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the Maximum Queue Entries Supported (MQES) to initialize I/O queues depth rather than picking a fixed number (256) which might not be supported by some NVMe controllers (the NVMe specification says that an NVMe controller may support any number between 2 to 4096). Still cap the I/O queues depth to 256 since, during my testing, SeaBIOS was running out of memory when using something higher than 256 (4096 on the NVMe controller that I've had a chance to try). Signed-off-by: Filippo Sironi --- src/hw/nvme.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hw/nvme.c b/src/hw/nvme.c index 946487f4fd43..19a4e7a48d3c 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -20,6 +20,8 @@ #include "nvme.h" #include "nvme-int.h" =20 +#define min(a, b) ({ typeof(a) _a =3D a; typeof(b) _b =3D b; _a < _b ? _a = : _b; }) + static void * zalloc_page_aligned(struct zone_s *zone, u32 size) { @@ -318,8 +320,10 @@ nvme_create_io_cq(struct nvme_ctrl *ctrl, struct nvme_= cq *cq, u16 q_idx) { int rc; struct nvme_sqe *cmd_create_cq; + u16 length; =20 - rc =3D nvme_init_cq(ctrl, cq, q_idx, NVME_PAGE_SIZE / sizeof(struct nv= me_cqe)); + length =3D min(1 + (ctrl->reg->cap & 0xffff), NVME_PAGE_SIZE / sizeof(= struct nvme_cqe)); + rc =3D nvme_init_cq(ctrl, cq, q_idx, length); if (rc) { goto err; } @@ -359,8 +363,10 @@ nvme_create_io_sq(struct nvme_ctrl *ctrl, struct nvme_= sq *sq, u16 q_idx, struct { int rc; struct nvme_sqe *cmd_create_sq; + u16 length; =20 - rc =3D nvme_init_sq(ctrl, sq, q_idx, NVME_PAGE_SIZE / sizeof(struct nv= me_cqe), cq); + length =3D min(1 + (ctrl->reg->cap & 0xffff), NVME_PAGE_SIZE / sizeof(= struct nvme_cqe)); + rc =3D nvme_init_sq(ctrl, sq, q_idx, length, cq); if (rc) { goto err; } --=20 2.7.4 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios