From nobody Fri Apr 26 08:46:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622015445; cv=none; d=zohomail.com; s=zohoarc; b=ix9+r3AETI+nd9RB4+p1fbFkqWEhZM+plzcWzUL5kTOGjfQQQq7PEIHopndY2UJ+hb4OuHUImw2K/UBQq8ZP1EE4Kyrmmajkd8JHB5Lhx7PIuMI8wYyrU3wuIaL8DURdXYrRFBZsO6Bsth836rvRKMFTC9Sa3E66h/aIP44KJh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622015445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=FDrgXf8pfO1uxEHt6meiN6+H2I0nyWMN1gelXYpjcHM=; b=GVGIpMwgJH/CC4Q5y2u/hYymM8p/lT6N/9Zrs0hoPtulJJjnMLOSRgRsBm7qS2zm7+7ukj+7va+FNG/HI//Ul/FpZOFuSQfF4aTA/kMdrw4ahcAKWxtebo6H3aVMGeslO7UrB1VmtI6vTSZpU5PvuqYht8H89/gZNRugHpsZ/5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1622015445265152.55924132543453; Wed, 26 May 2021 00:50:45 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id B13461061A06; Wed, 26 May 2021 07:50:41 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id B25BD10619E0 for ; Wed, 26 May 2021 07:50:09 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-dtMrowq2N32Ea35uefZS8g-1; Wed, 26 May 2021 03:50:06 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C6B31020C42 for ; Wed, 26 May 2021 07:50:05 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36ABD6F125; Wed, 26 May 2021 07:49:59 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id C257118000B9; Wed, 26 May 2021 09:49:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622015408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cw4dtcSEWZBx1eiDz5TpaDRna3+Xjp1BQoxzPvzLIeQ=; b=EozhXfdFiWGNJG49V0aPJHmBaIx0vRx4sg17FOT3mPG8zK4OVMdz7fRBQ20nZKixUJ0lXn mbzxsijXkFBwSPGpIaDc5WVsq5AJ71nW4V8iTgvBIiochXMWnOfPlybqSTBMYqB/UkdTuJ WFfFH9yW/gzFgMelIK2DWCYygeT3eXc= X-MC-Unique: dtMrowq2N32Ea35uefZS8g-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 26 May 2021 09:49:56 +0200 Message-Id: <20210526074957.100805-2-kraxel@redhat.com> In-Reply-To: <20210526074957.100805-1-kraxel@redhat.com> References: <20210526074957.100805-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: GYOE5P6SBOZWEE7Z62TWXNXUR7KXI72N X-Message-ID-Hash: GYOE5P6SBOZWEE7Z62TWXNXUR7KXI72N X-MailFrom: kraxel@redhat.com 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; digests; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.4 Precedence: list Subject: [SeaBIOS] [PATCH 1/2] nvme: improve namespace allocation List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: 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" Instead of allocating a big array upfront go probe the namespaces and only allocate an nvme_namespace struct for those namespaces which are actually active. Signed-off-by: Gerd Hoffmann --- src/hw/nvme-int.h | 1 - src/hw/nvme.c | 40 ++++++++++++++++------------------------ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/hw/nvme-int.h b/src/hw/nvme-int.h index 7947b29c9660..a4c1555cc058 100644 --- a/src/hw/nvme-int.h +++ b/src/hw/nvme-int.h @@ -103,7 +103,6 @@ struct nvme_ctrl { struct nvme_cq admin_cq; =20 u32 ns_count; - struct nvme_namespace *ns; =20 struct nvme_sq io_sq; struct nvme_cq io_cq; diff --git a/src/hw/nvme.c b/src/hw/nvme.c index f26b811e88bd..f64eba880a83 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -234,11 +234,9 @@ nvme_admin_identify_ns(struct nvme_ctrl *ctrl, u32 ns_= id) } =20 static void -nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_namespace *ns, u32 ns_id, - u8 mdts) +nvme_probe_ns(struct nvme_ctrl *ctrl, u32 ns_idx, u8 mdts) { - ns->ctrl =3D ctrl; - ns->ns_id =3D ns_id; + u32 ns_id =3D ns_idx + 1; =20 struct nvme_identify_ns *id =3D nvme_admin_identify_ns(ctrl, ns_id); if (!id) { @@ -254,12 +252,21 @@ nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_nam= espace *ns, u32 ns_id, goto free_buffer; } =20 - ns->lba_count =3D id->nsze; - if (!ns->lba_count) { + if (!id->nsze) { dprintf(2, "NVMe NS %u is inactive.\n", ns_id); goto free_buffer; } =20 + struct nvme_namespace *ns =3D malloc_fseg(sizeof(*ns)); + if (!ns) { + warn_noalloc(); + goto free_buffer; + } + memset(ns, 0, sizeof(*ns)); + ns->ctrl =3D ctrl; + ns->ns_id =3D ns_id; + ns->lba_count =3D id->nsze; + struct nvme_lba_format *fmt =3D &id->lbaf[current_lba_format]; =20 ns->block_size =3D 1U << fmt->lbads; @@ -269,10 +276,11 @@ nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_nam= espace *ns, u32 ns_id, /* If we see devices that trigger this path, we need to increase o= ur buffer size. */ warn_internalerror(); + free(ns); goto free_buffer; } =20 - ns->drive.cntl_id =3D ns - ctrl->ns; + ns->drive.cntl_id =3D ns_idx; ns->drive.removable =3D 0; ns->drive.type =3D DTYPE_NVME; ns->drive.blksize =3D ns->block_size; @@ -527,13 +535,6 @@ nvme_create_io_queues(struct nvme_ctrl *ctrl) return -1; } =20 -static void -nvme_destroy_io_queues(struct nvme_ctrl *ctrl) -{ - nvme_destroy_sq(&ctrl->io_sq); - nvme_destroy_cq(&ctrl->io_cq); -} - /* Waits for CSTS.RDY to match rdy. Returns 0 on success. */ static int nvme_wait_csts_rdy(struct nvme_ctrl *ctrl, unsigned rdy) @@ -627,24 +628,15 @@ nvme_controller_enable(struct nvme_ctrl *ctrl) goto err_destroy_admin_sq; } =20 - ctrl->ns =3D malloc_fseg(sizeof(*ctrl->ns) * ctrl->ns_count); - if (!ctrl->ns) { - warn_noalloc(); - goto err_destroy_ioq; - } - memset(ctrl->ns, 0, sizeof(*ctrl->ns) * ctrl->ns_count); - /* 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, identify->mdts); + nvme_probe_ns(ctrl, ns_idx, identify->mdts); } =20 dprintf(3, "NVMe initialization complete!\n"); return 0; =20 - err_destroy_ioq: - nvme_destroy_io_queues(ctrl); err_destroy_admin_sq: nvme_destroy_sq(&ctrl->admin_sq); err_destroy_admin_cq: --=20 2.31.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Fri Apr 26 08:46:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622015435; cv=none; d=zohomail.com; s=zohoarc; b=E3whnqIrJ3d+7Cb2e8BA0kZsm2vY2iMVOMVQxy9mBAdusdtWVpKaBpc/sKJklgEBY1pdArStc4WQKG0a3tkKWFtHu2OlhlVpyA+4/Xr8ctc1EamqwgHyD2AXeeqgxIgnBFMFzXcslMlCjIPxCYEraUwDtUhzP8EBlfksvuF+7xA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622015435; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=8RuoB+U67jd/2y7eZZZ9ko7E8JMdtLcxQWu++o2wee4=; b=TYMV+G8L/Q5b5s7MpSjCKyL4gD4BgbJWsiIIIcXXOUG3BHgUd2jb9/hVD+VrPoyNqzRQekrjL8vM9w7LS9ZtZdS9UjEylgCAOViHyMMrLPTD/VEztYi3lnbOWi7MLXtF9f4gRrgextkqJrmUsFepeyiaEgJpB2uI82eslGEpkgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 162201543503530.11450928776503; Wed, 26 May 2021 00:50:35 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 75D2A1061A02; Wed, 26 May 2021 07:50:31 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id D289310619E0 for ; Wed, 26 May 2021 07:50:08 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-UIDelpfwNF6Y5X_K7yieZg-1; Wed, 26 May 2021 03:50:05 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 01B931020C41 for ; Wed, 26 May 2021 07:50:05 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD7525D75A; Wed, 26 May 2021 07:50:04 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id C7756180038E; Wed, 26 May 2021 09:49:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622015407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YFoCEemLHdTMFSXn8gXNYsa7es099ruB1bDwf6OG60c=; b=RgpiaVFPfvbeUGk48tmwfo0mNKtuQLOBNTjIQW+4hG1LYPuUikhDZ0tVrfdN0bBdqhDul/ CaoWHKeSSCqhpTwD6r/+mL8fSMJXpCBef70FY63okYkUvK8AsTxpnJafPM10SuxN7XClpB Nr90UizX2mbckmh/NoagUQ81ghX3kSI= X-MC-Unique: UIDelpfwNF6Y5X_K7yieZg-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 26 May 2021 09:49:57 +0200 Message-Id: <20210526074957.100805-3-kraxel@redhat.com> In-Reply-To: <20210526074957.100805-1-kraxel@redhat.com> References: <20210526074957.100805-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: VPD3JAWFMORYYTDL6QCOY5XCERDBGPCT X-Message-ID-Hash: VPD3JAWFMORYYTDL6QCOY5XCERDBGPCT X-MailFrom: kraxel@redhat.com 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; digests; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.4 Precedence: list Subject: [SeaBIOS] [PATCH 2/2] nvme: drive desc should not include the newline List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: 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" Signed-off-by: Gerd Hoffmann --- src/hw/nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hw/nvme.c b/src/hw/nvme.c index f64eba880a83..746e4682d318 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -297,11 +297,11 @@ nvme_probe_ns(struct nvme_ctrl *ctrl, u32 ns_idx, u8 = mdts) 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 " - "blocks + %u-byte metadata)\n", + "blocks + %u-byte metadata)", ns_id, (ns->lba_count * ns->block_size) >> 20, ns->lba_count, ns->block_size, ns->metadata_size= ); =20 - dprintf(3, "%s", desc); + dprintf(3, "%s\n", desc); boot_add_hd(&ns->drive, desc, bootprio_find_pci_device(ctrl->pci)); =20 free_buffer: --=20 2.31.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org