From nobody Tue Apr 16 08:11:19 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@amazon.com; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=quarantine dis=quarantine) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1601500942; cv=none; d=zohomail.com; s=zohoarc; b=GTaQK/yACY0/VIv0xPmY+49vx8nYoDxRDSKrCiv03RJUForkGriG21Ho2i5p26BlaLotFXJBJTtf+JZbHm7D2CIwDbsm2SlkWSTQ/WEqzdIHv9y9Dmsj/VuCu5W3gR6iFEGmYh4l3mUkBbiRkyC/L+wSsjpIuVONgstuM8JFQSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601500942; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=jQ+2uqZB22VDov2h4QQi2B7uTvk9wj5hp9JWIUA6Ek0=; b=RgT00mi1iGvOvdzCPxOc7sy43fndR45d//8E0JlINZrS5bUmu+aTvuW+BzRCLIg/2DWeuUaIQfP0ir0+w1H8yzVFzHWIa7qcALbJ/huxrVNaFbbDc2uVcWcg1dHSKVKZ6tuy7n80x2Ec1Y39ttLbeUWVr9u0EXBUJXfq/1p2aYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@amazon.com; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1601500942962586.4809939738014; Wed, 30 Sep 2020 14:22:22 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id A4AC410C0096; Wed, 30 Sep 2020 21:22:18 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 61B4E10C008E for ; Wed, 30 Sep 2020 21:22:04 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 30 Sep 2020 21:22:01 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by email-inbound-relay-2a-90c42d1d.us-west-2.amazon.com (Postfix) with ESMTPS id 43576A11FB for ; Wed, 30 Sep 2020 21:11:06 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) EX13MTAUWC001.ant.amazon.com (10.43.162.135) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 30 Sep 2020 21:11:05 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 30 Sep 2020 21:11:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1601500924; x=1633036924; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WHyNICsRWkvz4Ku4KSw7GPuki67iKxMO7O/DZArkBfs=; b=v6bA/SNkXu57+IaYJzllvuO5mox/gmgEcElRpQ7z3jU/aU/Rg7eEh+s6 btZMEP1ab4LI6nX9kBjGpxnMvJ+J3cnvivpp5MbtISpJYE0JjLcWfTXDa m67u5UgEisEkzpyiSvS6g53gSV1QuUwkuD+9NONNYWGU6zPXhjyDvJ5QV 8=; X-IronPort-AV: E=Sophos;i="5.77,322,1596499200"; d="scan'208";a="57052188" From: Alexander Graf To: Date: Wed, 30 Sep 2020 23:10:53 +0200 Message-ID: <20200930211056.8478-2-graf@amazon.com> In-Reply-To: <20200930211056.8478-1-graf@amazon.com> References: <20200930211056.8478-1-graf@amazon.com> MIME-Version: 1.0 X-ClientProxiedBy: EX13D15UWA002.ant.amazon.com (10.43.160.218) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Message-ID-Hash: 7C35FRJVR65OFKEL77QH3FSPWSQM57AG X-Message-ID-Hash: 7C35FRJVR65OFKEL77QH3FSPWSQM57AG X-MailFrom: prvs=535b814ec=graf@amazon.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.3.2b1 Precedence: list Subject: [SeaBIOS] [PATCH v3 1/4] nvme: Record maximum allowed request size List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: ------ X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" NVMe has a limit on how many sectors it can handle at most within a single request. Remember that number, so that in a follow-up patch, we can verify that we don't exceed it. Signed-off-by: Alexander Graf --- v1 -> v2: - fix dprintf v2 -> v3: - Adjust the maximum request size to sector units. The hardware field describes it in pages. --- src/hw/nvme-int.h | 8 +++++++- src/hw/nvme.c | 13 +++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/hw/nvme-int.h b/src/hw/nvme-int.h index 9f95dd8..674008a 100644 --- a/src/hw/nvme-int.h +++ b/src/hw/nvme-int.h @@ -117,6 +117,7 @@ struct nvme_namespace { =20 u32 block_size; u32 metadata_size; + u32 max_req_size; =20 /* Page aligned buffer of size NVME_PAGE_SIZE. */ char *dma_buffer; @@ -131,7 +132,12 @@ struct nvme_identify_ctrl { char mn[40]; char fr[8]; =20 - char _boring[516 - 72]; + u8 rab; + u8 ieee[3]; + u8 cmic; + u8 mdts; + + char _boring[516 - 78]; =20 u32 nn; /* number of namespaces */ }; diff --git a/src/hw/nvme.c b/src/hw/nvme.c index 6a01204..5bc2586 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -238,7 +238,8 @@ nvme_admin_identify_ns(struct nvme_ctrl *ctrl, u32 ns_i= d) } =20 static void -nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_namespace *ns, u32 ns_id) +nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_namespace *ns, u32 ns_id, + u8 mdts) { ns->ctrl =3D ctrl; ns->ns_id =3D ns_id; @@ -281,6 +282,14 @@ nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_name= space *ns, u32 ns_id) ns->drive.blksize =3D ns->block_size; ns->drive.sectors =3D ns->lba_count; =20 + if (mdts) { + ns->max_req_size =3D ((1U << mdts) * NVME_PAGE_SIZE) / ns->block_s= ize; + dprintf(3, "NVME NS %u max request size: %d sectors\n", + ns_id, ns->max_req_size); + } else { + ns->max_req_size =3D -1U; + } + ns->dma_buffer =3D zalloc_page_aligned(&ZoneHigh, NVME_PAGE_SIZE); =20 char *desc =3D znprintf(MAXDESCSIZE, "NVMe NS %u: %llu MiB (%llu %u-by= te " @@ -567,7 +576,7 @@ nvme_controller_enable(struct nvme_ctrl *ctrl) /* Populate namespace IDs */ int ns_idx; for (ns_idx =3D 0; ns_idx < ctrl->ns_count; ns_idx++) { - nvme_probe_ns(ctrl, &ctrl->ns[ns_idx], ns_idx + 1); + nvme_probe_ns(ctrl, &ctrl->ns[ns_idx], ns_idx + 1, identify->mdts); } =20 dprintf(3, "NVMe initialization complete!\n"); --=20 2.16.4 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org