From nobody Thu Jun 02 21:04:18 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 050EB1B60BBB; Thu, 2 Jun 2022 21:04:19 +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 4LDdmf6fkcz4dhS; Thu, 2 Jun 2022 21:04:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654203858; 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=Aslpz/Ik7yXVo3b2UQp5w/NpdFYcbFB5MG3OZ0U2bLM=; b=wp/FuzmFAfp6Utwvqsz8obO604Cg8sNxWY+bW6WDbQ6NfJN6ETodUy57zC1NXWvmCC8dcL 2hUu/p0rQP2TDnYUpx2hPsPcabLuANDE2HVqA5kkHDQVn7a9OQyUGEjMkT9ggQPxKXZxS1 nNK2yJzUJwWldreXYmsIRUazn9cmkcv6SEX4RDcJ7xx5QjtpiwOVoKQ1LKcVAsovmM9f7V k/OQBWzpsI6RNGCkoy7Wok6M6sui/+kd5lgZHIgkYuYDd+yAP4ZitrkU6daUu29InFLXK/ 76P44ognXpU7IH3dCgIlB0sjuCObiUYexUJ2r2Y3kDwDq49sapWVsT/oKxkyYQ== 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 C43801C199; Thu, 2 Jun 2022 21:04:18 +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 252L4I1W016159; Thu, 2 Jun 2022 21:04:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 252L4Iji016158; Thu, 2 Jun 2022 21:04:18 GMT (envelope-from git) Date: Thu, 2 Jun 2022 21:04:18 GMT Message-Id: <202206022104.252L4Iji016158@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: 04e86ae357b2 - main - busdma_iommu: simplify split logic 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/main X-Git-Reftype: branch X-Git-Commit: 04e86ae357b21fce238a90f31198b25975d0f479 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654203858; 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=Aslpz/Ik7yXVo3b2UQp5w/NpdFYcbFB5MG3OZ0U2bLM=; b=F6QtuaVyUfNjU2Nf2gNZ9q8++chB7WPTJQCesGA/MDNbCN6D0zfWqz3fP6zy5/aI9FLD3P lsqcjr9ay/2NpIY/om6lFXiAwhoLDHDvQBH4PLsA9VIWCF/iWFPx5x9fhaVe9qX4Ki+UTs Ug2q5uUQcUCQtXtYR4n8O5kZyScF/rD6BrdSuYu45nU/yTIabi+h4SVTWpGvrwUtjVBNZz AqcbsxedD1F4FxEL+GNixL+ApFsqGny4P8J3b2aTEqmYLB8u/CCRSfIZ1y9IsBZ1fMjZfd TgAOFFBsrqhNOR+l+7UTx9vyDKVIMcqpTX0XdBmezsYP5B7SD1soXE7ALM96IQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654203858; a=rsa-sha256; cv=none; b=OTq6HvgEpvEsFqsiTWv9BzW05pA3pdZe9F4QP4ZDQRMIuKYAYx5h83QJhX+gEqVAWhhAFb mKjRE6qFyKLTpiVQOH+YW2yKu8t6fTVRO27gxIuG0F08XORwDsjrGtTJAmXqjIDYv2cqxT wX8VNNuaGNJ5hlBZpP5IVUEEOFbM+yRoP3UpgTpUPm0g2an1EH1DNZTyUktvCF7IHTCdM9 /QKNFASQTVqmMJnNaAP+VUPOZdkwZc9CYypQAWb5vYpKWIkhJ7M+zHYxGj0RTuwbPdr3oz se6T7ECcs8WddXspqiSP7tIOio3rxapD6sbTlH5OzUfdNM/skaND+nns4i5BCw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=04e86ae357b21fce238a90f31198b25975d0f479 commit 04e86ae357b21fce238a90f31198b25975d0f479 Author: Doug Moore AuthorDate: 2022-06-02 20:59:57 +0000 Commit: Doug Moore CommitDate: 2022-06-02 20:59:57 +0000 busdma_iommu: simplify split logic iommu_bus_dmamap_load_something1 includes code for handling the possibility of splitting a buffer that is needlessly complex. Simplify it. Reviewed by: alc, kib MFC after: 3 weeks Tested by: pho (previous revisions) Differential Revision: https://reviews.freebsd.org/D35232 --- sys/dev/iommu/busdma_iommu.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 99d47f0b6ede..ad638e293324 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -564,15 +564,16 @@ iommu_bus_dmamap_load_something1(struct bus_dma_tag_iommu *tag, struct iommu_ctx *ctx; struct iommu_domain *domain; struct iommu_map_entry *entry; - iommu_gaddr_t size; bus_size_t buflen1; - int error, idx, gas_flags, seg; + int error, e_flags, idx, gas_flags, seg; KASSERT(offset < IOMMU_PAGE_SIZE, ("offset %d", offset)); if (segs == NULL) segs = tag->segments; ctx = tag->ctx; domain = ctx->domain; + e_flags = IOMMU_MAP_ENTRY_READ | + ((flags & BUS_DMA_NOWRITE) == 0 ? IOMMU_MAP_ENTRY_WRITE : 0); seg = *segp; error = 0; idx = 0; @@ -584,7 +585,6 @@ iommu_bus_dmamap_load_something1(struct bus_dma_tag_iommu *tag, } buflen1 = buflen > tag->common.maxsegsz ? tag->common.maxsegsz : buflen; - size = round_page(offset + buflen1); /* * (Too) optimistically allow split if there are more @@ -594,30 +594,14 @@ iommu_bus_dmamap_load_something1(struct bus_dma_tag_iommu *tag, if (seg + 1 < tag->common.nsegments) gas_flags |= IOMMU_MF_CANSPLIT; - error = iommu_map(domain, &tag->common, size, offset, - IOMMU_MAP_ENTRY_READ | - ((flags & BUS_DMA_NOWRITE) == 0 ? IOMMU_MAP_ENTRY_WRITE : 0), - gas_flags, ma + idx, &entry); + error = iommu_map(domain, &tag->common, + round_page(offset + buflen1), + offset, e_flags, gas_flags, ma + idx, &entry); if (error != 0) break; - if ((gas_flags & IOMMU_MF_CANSPLIT) != 0) { - KASSERT(size >= entry->end - entry->start, - ("split increased entry size %jx %jx %jx", - (uintmax_t)size, (uintmax_t)entry->start, - (uintmax_t)entry->end)); - size = entry->end - entry->start; - if (buflen1 > size) - buflen1 = size; - } else { - KASSERT(entry->end - entry->start == size, - ("no split allowed %jx %jx %jx", - (uintmax_t)size, (uintmax_t)entry->start, - (uintmax_t)entry->end)); - } - if (offset + buflen1 > size) - buflen1 = size - offset; - if (buflen1 > tag->common.maxsegsz) - buflen1 = tag->common.maxsegsz; + /* Update buflen1 in case buffer split. */ + if (buflen1 > entry->end - entry->start - offset) + buflen1 = entry->end - entry->start - offset; KASSERT(vm_addr_align_ok(entry->start + offset, tag->common.alignment),