From nobody Mon Aug 08 03:22:06 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M1M264kSJz4Yjbl; Mon, 8 Aug 2022 03:22:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M1M261lZHz44QH; Mon, 8 Aug 2022 03:22:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659928926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=260iVAZ1ikDJJqsvO8sIWz6qsAUCpFq3orqxkAuD+Kg=; b=PGBcblYMWaJJKNkmPwxuQINKFG22e3b6J0o0FS2p/I9f32WuUAl7wkK/JYrDVK4Xdt0NgL WPkPmCU11/JxCpSDJ86yL3j9womvSY+3zxeMmvzpWq//O6mnih8HCDEZOXj2ZQd+7M+zcq Od3vWE5zokIp/Fwn7tciLaZ5uX0q0IyFrikZ2MxAsF4ze2dj1ptYjfKdzA7An4Zja9wGxH mMxJ32TI0Nc8Qk4PzaNOHkEma9ElDGL+fgBJNPdofncsIQ6YxeI3X2qJM8DRwv2wsAT+7r N629hXLPAEKu9PaS8rNT3XnNgCJCdD6mVC/or/jgSHfFagk9/aUjHn9FM2QPdw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M1M260rvSzcmH; Mon, 8 Aug 2022 03:22:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2783M6DR017694; Mon, 8 Aug 2022 03:22:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2783M6pG017693; Mon, 8 Aug 2022 03:22:06 GMT (envelope-from git) Date: Mon, 8 Aug 2022 03:22:06 GMT Message-Id: <202208080322.2783M6pG017693@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Doug Moore Subject: git: f2453156ddfe - stable/13 - iommu: Shrink the iommu map entry structure List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f2453156ddfe625f1040d50f0db5d02152574eed Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659928926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=260iVAZ1ikDJJqsvO8sIWz6qsAUCpFq3orqxkAuD+Kg=; b=LYLs5wGmWSnnjwvVpse7bitIQgkzWnqXPh9635F6ZkPll15AKDf7XuyT0klPWe66Qggijk X8w1WJjyWbE88Sq9C4g2N4R7ht0ntUD3B4/txWF47imuKbAzfReq/XaVFZfpMMuIwxE8XK +oc3Q6af4YS352zaAd89RySz3NisGGcQ3fNOrGkEnT6MGWC+8Lxi7zo9fcGWPIUJGEEbGC h7XXGqle1NY6R880w1JwnoiQFnnTQ+odSzFGUwqfs4gtAbX9FJjECMSFIg3PpMXKZExoOm G49Ka6DFEriwvz0kH2M+TvVE5aL0kwa/2mjsa+N0OfekT2Z7lwupDJBnIL49eg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659928926; a=rsa-sha256; cv=none; b=DXAc0WIVdrYMTopL/2p81vLlocADfg4kXJFGb48KxURnQXup2/4qb1HDZ9c+RSS68015g9 HmiIZUBjDBIJO8e/kFUzaZ+rjaBnVrcKuYic49ps8wI71pwkJUTlJ+gkTIVUNbtWfLNfwg s+n3BbR2rEaCuIZskb43jouJms5lz0g6hmsHRByG91oayyuSzR9hPVzfNkJe9DI6htni38 jPeLwBOvbTR39oTWkDOaNgkxGGzk0LZuYbCsPP/xpZva1H7I+NiS0BVA9oRRVulyj2PMKj pR85qIzlXrDa60r+kgErV60x7tLsqe3h6nlExoPWA6Zje+l+RhB+PNDc+4KyAg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=f2453156ddfe625f1040d50f0db5d02152574eed commit f2453156ddfe625f1040d50f0db5d02152574eed Author: Alan Cox AuthorDate: 2022-07-11 03:52:52 +0000 Commit: Doug Moore CommitDate: 2022-08-08 03:17:58 +0000 iommu: Shrink the iommu map entry structure Eliminate the unroll_entry field from struct iommu_map_entry, shrinking the struct by 16 bytes on 64-bit architectures. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D35769 (cherry picked from commit db0110a536bf70c1ff55f3b3f46a0b5a9af46058) --- sys/dev/iommu/busdma_iommu.c | 33 ++++++++++----------------------- sys/dev/iommu/iommu.h | 2 -- sys/x86/iommu/intel_ctx.c | 4 ++-- sys/x86/iommu/intel_drv.c | 2 +- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 33549b4af011..4accafc64377 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -557,7 +557,7 @@ static int iommu_bus_dmamap_load_something1(struct bus_dma_tag_iommu *tag, struct bus_dmamap_iommu *map, vm_page_t *ma, int offset, bus_size_t buflen, int flags, bus_dma_segment_t *segs, int *segp, - struct iommu_map_entries_tailq *unroll_list) + struct iommu_map_entries_tailq *entries) { struct iommu_ctx *ctx; struct iommu_domain *domain; @@ -625,10 +625,7 @@ iommu_bus_dmamap_load_something1(struct bus_dma_tag_iommu *tag, KASSERT((entry->flags & IOMMU_MAP_ENTRY_MAP) != 0, ("entry %p missing IOMMU_MAP_ENTRY_MAP", entry)); - IOMMU_DMAMAP_LOCK(map); - TAILQ_INSERT_TAIL(&map->map_entries, entry, dmamap_link); - IOMMU_DMAMAP_UNLOCK(map); - TAILQ_INSERT_TAIL(unroll_list, entry, unroll_link); + TAILQ_INSERT_TAIL(entries, entry, dmamap_link); segs[seg].ds_addr = entry->start + offset; segs[seg].ds_len = buflen1; @@ -650,36 +647,26 @@ iommu_bus_dmamap_load_something(struct bus_dma_tag_iommu *tag, { struct iommu_ctx *ctx; struct iommu_domain *domain; - struct iommu_map_entry *entry; - struct iommu_map_entries_tailq entries, unroll_list; + struct iommu_map_entries_tailq entries; int error; ctx = tag->ctx; domain = ctx->domain; atomic_add_long(&ctx->loads, 1); - TAILQ_INIT(&unroll_list); + TAILQ_INIT(&entries); error = iommu_bus_dmamap_load_something1(tag, map, ma, offset, - buflen, flags, segs, segp, &unroll_list); - if (error != 0 && !TAILQ_EMPTY(&unroll_list)) { + buflen, flags, segs, segp, &entries); + if (error == 0) { + IOMMU_DMAMAP_LOCK(map); + TAILQ_CONCAT(&map->map_entries, &entries, dmamap_link); + IOMMU_DMAMAP_UNLOCK(map); + } else if (!TAILQ_EMPTY(&entries)) { /* * The busdma interface does not allow us to report * partial buffer load, so unfortunately we have to * revert all work done. */ - TAILQ_INIT(&entries); - IOMMU_DMAMAP_LOCK(map); - TAILQ_FOREACH(entry, &unroll_list, unroll_link) { - /* - * No entries other than what we have created - * during the failed run might have been - * inserted there in between, since we own ctx - * pglock. - */ - TAILQ_REMOVE(&map->map_entries, entry, dmamap_link); - TAILQ_INSERT_TAIL(&entries, entry, dmamap_link); - } - IOMMU_DMAMAP_UNLOCK(map); IOMMU_DOMAIN_LOCK(domain); TAILQ_CONCAT(&domain->unload_entries, &entries, dmamap_link); IOMMU_DOMAIN_UNLOCK(domain); diff --git a/sys/dev/iommu/iommu.h b/sys/dev/iommu/iommu.h index 3800213a1d64..62b5659b6e83 100644 --- a/sys/dev/iommu/iommu.h +++ b/sys/dev/iommu/iommu.h @@ -58,8 +58,6 @@ struct iommu_map_entry { u_int flags; TAILQ_ENTRY(iommu_map_entry) dmamap_link; /* Link for dmamap entries */ RB_ENTRY(iommu_map_entry) rb_entry; /* Links for domain entries */ - TAILQ_ENTRY(iommu_map_entry) unroll_link; /* Link for unroll after - dmamap_load failure */ struct iommu_domain *domain; struct iommu_qi_genseq gseq; }; diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c index b3573712de32..4e94936f27d4 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -245,7 +245,7 @@ domain_init_rmrr(struct dmar_domain *domain, device_t dev, int bus, TAILQ_INIT(&rmrr_entries); dmar_dev_parse_rmrr(domain, dev_domain, dev_busno, dev_path, dev_path_len, &rmrr_entries); - TAILQ_FOREACH_SAFE(entry, &rmrr_entries, unroll_link, entry1) { + TAILQ_FOREACH_SAFE(entry, &rmrr_entries, dmamap_link, entry1) { /* * VT-d specification requires that the start of an * RMRR entry is 4k-aligned. Buggy BIOSes put @@ -306,7 +306,7 @@ domain_init_rmrr(struct dmar_domain *domain, device_t dev, int bus, error1); error = error1; } - TAILQ_REMOVE(&rmrr_entries, entry, unroll_link); + TAILQ_REMOVE(&rmrr_entries, entry, dmamap_link); iommu_gas_free_entry(DOM2IODOM(domain), entry); } for (i = 0; i < size; i++) diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index 0b470d7bbf7a..c7647c1f7b1d 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -922,7 +922,7 @@ dmar_rmrr_iter(ACPI_DMAR_HEADER *dmarh, void *arg) /* The RMRR entry end address is inclusive. */ entry->end = resmem->EndAddress; TAILQ_INSERT_TAIL(ria->rmrr_entries, entry, - unroll_link); + dmamap_link); } }