From nobody Mon Jun 27 05:37:22 2022 X-Original-To: dev-commits-src-branches@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 7F1818A353F; Mon, 27 Jun 2022 05:37:22 +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 4LWc1Z38gHz3p9f; Mon, 27 Jun 2022 05:37:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656308242; 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=PukLafZv2StFi8YKUSv7UD2rG90AqzFktl66QDRpuOo=; b=L9zaLWvgMdTJBx9/GUbtlJp/4grwdbrd5k0dj6mmax1xNW1MBXyYxcwM1hsUDJVss4JbNU DOHttAxBbtfaQRgMY8PCyvKNqd4h7jn8Dq7jNs7N0iklPlS8m7C4KzykAAAbcssUS8zWYp lWv6AuIL2E29suInn79JGGow270ZHXOb1le5eBXbsSuq14o26PO7CalGO0VY0439kmzgWY O1MCetWMkOQT8AqhIfwBvSDjxv58C8/bimVV0Z3mVCjVDsh0PK+gTIG0ZGP/GG5zjVR/+k ziQMWeeO4FIneHzcySKyPzodn5l6SvwODzh1096yMiXRUax/lUbQChufbxbQJA== 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 4863C22730; Mon, 27 Jun 2022 05:37:22 +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 25R5bMKq074579; Mon, 27 Jun 2022 05:37:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25R5bMWv074578; Mon, 27 Jun 2022 05:37:22 GMT (envelope-from git) Date: Mon, 27 Jun 2022 05:37:22 GMT Message-Id: <202206270537.25R5bMWv074578@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: 4d517feaea03 - stable/13 - busdma_iommu: simplify split logic List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: 4d517feaea0352aea8828a4a07c40ff85036010d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656308242; 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=PukLafZv2StFi8YKUSv7UD2rG90AqzFktl66QDRpuOo=; b=WvgdFK93y4snNMjAVxphB/ce6h7taIsBFO2lCASTa9OL+V0HBxZUuKhaCj/CAfkzaO+On5 Dp7SDtZkfa+paTkSb9Wxg2IBXGbVXmKthdaWWwneBm8KKXw6pJzILHtn8O3WpHAEYdfFBG zGf1UdAvFSJJ8UQ/guXP1jvWhzMB6cbyZCPqkzuR5TQiTltmXlQcRIoxjybenfUpEoHsrK 2samlEN7MAaberGKvWxdmilGUtUWp03Wu72NwU5J5OGMlppM37Ua94sRF/9udbaNFpqT8F mqkbBbV58KfE63UvxTZFZzwlqq54hqzPpcNkAZtgE7Rw1y0U2OT9oYVX3xI6sQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656308242; a=rsa-sha256; cv=none; b=R3MbEWRSQuw0qGfnrBNPY7WhUDmgXOu7TQeztycqP0DYet9W7K4RCiDhDsqb//tOjL7E4w DYUKQajwv9XyGvDuMcTGNPAMg7BsSzaODtkC4Otd9SpqA0dMwXiaXH5aT7ZTM9CXrcQF7u DcBLYGPJOVUQabQhrDxZbfeKyWIFu3N+VibAayvLCbSkarWWgcWpy4KECbPZwDVRcKhukJ 61wLxN1b7YzTmazYy3XjDhWx7We/mOuGlvVbqr9Lv78mOi+9anuIkZd0U6IQE/Rhm7dKT3 j8/j0srnJUwrykQV4gPzl2OuoCyZH4LfZ9hrd9HNzNUVFQR1yE/9eh0spfU+yA== 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=4d517feaea0352aea8828a4a07c40ff85036010d commit 4d517feaea0352aea8828a4a07c40ff85036010d Author: Doug Moore AuthorDate: 2022-06-02 20:59:57 +0000 Commit: Doug Moore CommitDate: 2022-06-27 05:34:59 +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 (cherry picked from commit 04e86ae357b21fce238a90f31198b25975d0f479) --- 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 02ac5845bdcc..89e5e1bcff39 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -563,15 +563,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; @@ -583,7 +584,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 @@ -593,30 +593,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(((entry->start + offset) & (tag->common.alignment - 1)) == 0,