From nobody Fri Apr 26 16:47:50 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=1601470066; cv=none; d=zohomail.com; s=zohoarc; b=ish+QkbyplplmThH6rhFXL1uOjIceHaoaL3YPdjkrs4Tum6MOh9hQg9keXv1rAYdsyRJu31tzPFVLhseuDM+4Ef6Mxopi+GTN9bBMCQDR7+hOI7Bn/lvGqkGclvjWixx6WBrbyZ+u87bK4DrtL/sQr/LYFfIgsBsd8YW9Sk9LA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601470066; 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=zNlqxcCeHT2jPLVSLeUo0WhAbawqOL4IR3Eiu2GVAzE=; b=kH3ZBURJCGK0ndiDCeioOvGw8S+k4ZWIsSFBZDN+v7fjuvTWFJ4eUzKKe+HJXIgZ7uIrgVmMnN7JMnFbcPjIrOUIxw4Xm/I/2BrU1KqnG0P9YD8Dhoe17ldAo6fMa6eep5TkFkporTllg6tXgSan8/ryDDwy60OoLj6JqPQ8ZmM= 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 1601470066640411.86415100040495; Wed, 30 Sep 2020 05:47:46 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 7B71A10C0082; Wed, 30 Sep 2020 12:47:42 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 59B5B10C0068 for ; Wed, 30 Sep 2020 12:47:17 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2020 12:47:16 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by email-inbound-relay-1d-98acfc19.us-east-1.amazon.com (Postfix) with ESMTPS id 61713A1F44 for ; Wed, 30 Sep 2020 12:47:14 +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 12:47:14 +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 12:47:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1601470038; x=1633006038; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kcZFe2EUxUqrp4MhTBDPdr8R3qrcnhCzWDWUkBiHRvk=; b=bFlql+YJtTRzKrz66dL+Jq4nVlOYT78fuczi5IArEeqtqg+qeZLqwM1g bqfIzmyffDbmrCiS5Hwvqgr9c87lV+Swi4vmtPXzim9OurVD9T0KUGUPj i3jBCaX3e1unJBRfe+KIExLyxA1NTr8EuSoW+X7Ix0sKMt9aAROlsGXnr M=; X-IronPort-AV: E=Sophos;i="5.77,322,1596499200"; d="scan'208";a="79237252" From: Alexander Graf To: Date: Wed, 30 Sep 2020 14:47:02 +0200 Message-ID: <20200930124704.1846-2-graf@amazon.com> In-Reply-To: <20200930124704.1846-1-graf@amazon.com> References: <20200930124704.1846-1-graf@amazon.com> MIME-Version: 1.0 X-ClientProxiedBy: EX13D34UWA002.ant.amazon.com (10.43.160.245) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Message-ID-Hash: ORFEFIVHJ6WPIVSEOQNTGKVHGAWJOK4C X-Message-ID-Hash: ORFEFIVHJ6WPIVSEOQNTGKVHGAWJOK4C 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 v2 1/3] 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 --- 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..7e56134 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; + 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