From nobody Sat Jul 16 03:26:55 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 4LlDDH6sZ4z4TD1S; Sat, 16 Jul 2022 03:26:55 +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 4LlDDH6Nssz3gWB; Sat, 16 Jul 2022 03:26:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657942015; 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=luJJ64XRKO5s3XD7EuNaWCVSwBcaOru8mbi5+DoRVIY=; b=aAcv3F/sawPjNCQsJMEj8DTx7i+n9TeKGZjATb0mPcBysH5rn5oUPYVFl2JGnr1I1Nknp4 9o9N0TmdTSJTuXK4OeeauXGwt5TTxQ0C9oXTpw2AiszqTUW3vR7CzhA7uIgR3sNZAeURf3 cbxKR+1O9YoC2X3qRQwhwuu7A5zoPPNswVQ5EMQZRb56Qv3msA9iV61ko+9RGHdbv/JZGo YhjHNqd6zPyUSBVFzKGmxWWLNxSOGCBXvNNTsUz5Uo1CAMajBi3Fy17QfqBH7ydsZSgHyn WKbonJMh6b8twMoCzv3KiuueLrLGIJhuf7ZqId6oVHlDsbvHqH8hrumEPSG9Tw== 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 4LlDDH5SYZz167L; Sat, 16 Jul 2022 03:26:55 +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 26G3QtD8019287; Sat, 16 Jul 2022 03:26:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26G3QtEE019286; Sat, 16 Jul 2022 03:26:55 GMT (envelope-from git) Date: Sat, 16 Jul 2022 03:26:55 GMT Message-Id: <202207160326.26G3QtEE019286@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Cox Subject: git: db0110a536bf - main - 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: alc X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: db0110a536bf70c1ff55f3b3f46a0b5a9af46058 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657942015; 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=luJJ64XRKO5s3XD7EuNaWCVSwBcaOru8mbi5+DoRVIY=; b=Uy6k6+oCpZVJrRsRa5ivknYW3+EfEMWo6fMsMTnBY0grI9RbEkEAg+oz06Fc7HpGhuNq19 l3GjuMds+dE35MYHvtUyHLQLD4SH4SrAqA0iWFfP+Hv36VuiLsmiv0ypH0hzlR34E0VPM6 4VJBqmcOF0wSR00cphL6iva8InoOLqOpaSeF4tX2IGNqovIVxh5sJX2Jru7+uXdbq0U5lb DHmqKnALqKqHrXY8oesyCr+1qgXnsdsHWmwtQU8ImYPyfgrz8WnQG5xvzHKpcTv26X/Cy5 O6QjFrJfxr0anUaK4VCo9Y+mtEsAP9WFHvljI8z7IuXZ87hg4geoNUlhCxvn/w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657942015; a=rsa-sha256; cv=none; b=MRu2H4koIKMB6jCC9LU7tXSs0RiqRjJL0BtH/2jlXT6D8qrGXNj7m3rjRqurgnCx/UJ5yN bv5WZr1S2669fATKPz8B89Fu74gB+wXUvt5W+oGZxYFSxBGdamfDdDFsGjjNLkHGG0T9w8 9ymsbcL4XYVW1razEY0+XTiGQo8+4LbMg0XakVwNovt4hzY82f9un00+AhNc9bfq6UXXHo NbQCQZcrlM52D91E2T1W0d4rktqRLDRx5WX5pdRIsiCfK+0tYLaKBJncRb69nAbBbE2RQ0 iwVlyvuQG5KGapg0cdYYfepOxvshXIgkhmTihAyz1EJJzUHYGEj89YiVEc8MsA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by alc: URL: https://cgit.FreeBSD.org/src/commit/?id=db0110a536bf70c1ff55f3b3f46a0b5a9af46058 commit db0110a536bf70c1ff55f3b3f46a0b5a9af46058 Author: Alan Cox AuthorDate: 2022-07-11 03:52:52 +0000 Commit: Alan Cox CommitDate: 2022-07-16 03:24:52 +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 --- 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 69cf9dd12e7e..10e7476b35eb 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -558,7 +558,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; @@ -626,10 +626,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; @@ -651,36 +648,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 815dc6146b00..79e2a15d80c7 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 10709fc0db61..020e97e2dff3 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -932,7 +932,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); } }