From nobody Wed Dec 06 23:21:44 2023 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 4SlthS6dVcz539FS; Wed, 6 Dec 2023 23:21:44 +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 4SlthS42nTz4FVg; Wed, 6 Dec 2023 23:21:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701904904; 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=kvCclF/VYbckm+ugyzWBGYmX9f8/6GQaFGDc5a7RruI=; b=vX2c0/1tBZRzDLgtn+3XsN3flgNaPGdZq1WrrvcPUhI56FE8/y38ZWKXv714iwqPMUkzy5 U5QrUTiv5xprP/zBVPTTN/6EKOMS3Xu1mN+su0IJsgbuXV/uK5b5cHhsHGC1drBfmJbP3q qD5lvCsCgdOwjw5ZreCr51sSFWHT6xvyEfjCAb3U8gEu07UHHugJd5EwIQlHAMICNgT4JP El9aj92O9MoU1apGH2OxDIHb2B+aRvEqzkO3I67+z8gzm0oYQ1xBHIItg9Ck2beenqqdJy qhDxUHdhVI0KqroEEtKYfhjNaDDBlcxBE8nMbg8Bk5KqxsGhyre5xO4fTXjXLQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701904904; a=rsa-sha256; cv=none; b=oJcFB2aELbpX+Isn/MoM+BB+SXdOl1cNTfqIfincvIqtKAZDklOf1o6fTnLs6VFFkSTXa4 cD5b99dqbOwgFicDyoMDviHTpp5G87ibPtXVuTYi8TpQeLRseIqC7jMidbrgoiY0kYCxGD VMXwY8CA2HZgPe2jnEarG9gvJZjA6M/rpVtv8BSEb60ZWn9W3Qk/5yg0J81cGnUhBC9LYi QMws4nHukuMeqb6C3Rw5xLL6VRMY8kyjfXrVu0Dlu2BfjXXnBlsvVBRPygYzW+Ts2Zyv9q 31e9qRSmvdjb4c+d+LQlEZLUduXOqmLJESI3dbg3ulraZ1mW8EO6y1GFJ3p5sQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701904904; 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=kvCclF/VYbckm+ugyzWBGYmX9f8/6GQaFGDc5a7RruI=; b=RzHRwXmkDUsCblv+dp43LNnABhwHCCpHgjn6DiLz6SryuboMVlQLCJ1SWYMd3mLZuJR8g2 PHw9GkuB2TmwkSkx5AaTo2vC0hDfNOSPB9jWx0VzSyZkvkbIKCReiVjm9nXRSjkOtgtUi9 GCQgdJziJslA1OJeqQSL5Lesl5g7NaTgt+YhShoWwgqkkBw1fjznoJ5nXqDtlVK7xxfrmc gQpcBdUKBxqh9xoP0YFvleBx4LZ2T+MvWce73MgeP3YdLepf/XY9gJ6GhAzuUHP0zL4FZe V+uuzO8gIvK3nvY7FpOtXJpMljYbuqlRIzc9W2WUYw/ZMpuuwVzW1gb3BIQq+w== 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 4SlthS2qzDz1C1K; Wed, 6 Dec 2023 23:21:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3B6NLi1Z018048; Wed, 6 Dec 2023 23:21:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B6NLiVH018044; Wed, 6 Dec 2023 23:21:44 GMT (envelope-from git) Date: Wed, 6 Dec 2023 23:21:44 GMT Message-Id: <202312062321.3B6NLiVH018044@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 3933ff56f9b6 - main - busdma: tidy bus_dma_run_filter() functions 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3933ff56f9b6ee844105916b9002b46ba9536ea5 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=3933ff56f9b6ee844105916b9002b46ba9536ea5 commit 3933ff56f9b6ee844105916b9002b46ba9536ea5 Author: Mitchell Horne AuthorDate: 2023-12-06 23:09:27 +0000 Commit: Mitchell Horne CommitDate: 2023-12-06 23:11:39 +0000 busdma: tidy bus_dma_run_filter() functions After removing filter functionality, the naming doesn't clearly represent what the function does, so try to address this. Include some code clarity and style improvements. Create a common version in subr_busdma_bounce.c, used by most implementations. powerpc still needs its own version of the function, due to its dmat->iommu == NULL check. No functional change intended. Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42896 --- sys/arm/arm/busdma_machdep.c | 11 ++--------- sys/arm64/arm64/busdma_bounce.c | 7 ++----- sys/arm64/arm64/busdma_machdep.c | 18 ------------------ sys/arm64/include/bus_dma_impl.h | 1 - sys/kern/subr_busdma_bounce.c | 16 ++++++++++++++++ sys/powerpc/powerpc/busdma_machdep.c | 36 ++++++++++++++---------------------- sys/riscv/include/bus_dma_impl.h | 1 - sys/riscv/riscv/busdma_bounce.c | 10 +++++----- sys/riscv/riscv/busdma_machdep.c | 21 --------------------- sys/x86/include/busdma_impl.h | 1 - sys/x86/x86/busdma_bounce.c | 13 +++++++------ sys/x86/x86/busdma_machdep.c | 22 ---------------------- 12 files changed, 46 insertions(+), 111 deletions(-) diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c index dd31f7779b21..9f4c6e561bbc 100644 --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -169,6 +169,7 @@ MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata"); #define dmat_alignment(dmat) ((dmat)->alignment) #define dmat_flags(dmat) ((dmat)->flags) +#define dmat_highaddr(dmat) ((dmat)->highaddr) #define dmat_lowaddr(dmat) ((dmat)->lowaddr) #define dmat_lockfunc(dmat) ((dmat)->lockfunc) #define dmat_lockfuncarg(dmat) ((dmat)->lockfuncarg) @@ -340,18 +341,10 @@ must_bounce(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t paddr, if (cacheline_bounce(map, paddr, size)) return (1); - /* - * The tag already contains ancestors' alignment restrictions so this - * check doesn't need to be inside the loop. - */ - if (alignment_bounce(dmat, paddr)) - return (1); - /* * Check the tag's exclusion zone. */ - if (exclusion_bounce(dmat) && - paddr >= dmat->lowaddr && paddr <= dmat->highaddr) + if (exclusion_bounce(dmat) && addr_needs_bounce(dmat, paddr)) return (1); return (0); diff --git a/sys/arm64/arm64/busdma_bounce.c b/sys/arm64/arm64/busdma_bounce.c index 3b5521a31b92..a117e1041658 100644 --- a/sys/arm64/arm64/busdma_bounce.c +++ b/sys/arm64/arm64/busdma_bounce.c @@ -107,7 +107,6 @@ struct bus_dmamap { struct sync_list slist[]; }; -int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr); static bool _bus_dmamap_pagesneeded(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, bus_size_t buflen, int *pagesneeded); static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, @@ -120,6 +119,7 @@ static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata"); #define dmat_alignment(dmat) ((dmat)->common.alignment) #define dmat_domain(dmat) ((dmat)->common.domain) #define dmat_flags(dmat) ((dmat)->common.flags) +#define dmat_highaddr(dmat) ((dmat)->common.highaddr) #define dmat_lowaddr(dmat) ((dmat)->common.lowaddr) #define dmat_lockfunc(dmat) ((dmat)->common.lockfunc) #define dmat_lockfuncarg(dmat) ((dmat)->common.lockfuncarg) @@ -225,11 +225,8 @@ must_bounce(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t paddr, if (cacheline_bounce(dmat, map, paddr, size)) return (true); - if (alignment_bounce(dmat, paddr)) - return (true); - if ((dmat->bounce_flags & BF_COULD_BOUNCE) != 0 && - bus_dma_run_filter(&dmat->common, paddr)) + addr_needs_bounce(dmat, paddr)) return (true); return (false); diff --git a/sys/arm64/arm64/busdma_machdep.c b/sys/arm64/arm64/busdma_machdep.c index c88b28aa3e22..08dfb67abeab 100644 --- a/sys/arm64/arm64/busdma_machdep.c +++ b/sys/arm64/arm64/busdma_machdep.c @@ -49,24 +49,6 @@ #include #include -/* - * Return true if a match is made. - * - * To find a match walk the chain of bus_dma_tag_t's looking for 'paddr'. - * - * If paddr is within the bounds of the dma tag then call the filter callback - * to check for a match, if there is no filter callback then assume a match. - */ -int -bus_dma_run_filter(struct bus_dma_tag_common *tc, bus_addr_t paddr) -{ - - if (paddr > tc->lowaddr && paddr <= tc->highaddr) - return (1); - - return (0); -} - int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, diff --git a/sys/arm64/include/bus_dma_impl.h b/sys/arm64/include/bus_dma_impl.h index 55af1b477979..9e5741758ef5 100644 --- a/sys/arm64/include/bus_dma_impl.h +++ b/sys/arm64/include/bus_dma_impl.h @@ -77,7 +77,6 @@ struct bus_dma_impl { bus_dmasync_op_t op); }; -int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr); int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, bus_size_t maxsize, int nsegments, diff --git a/sys/kern/subr_busdma_bounce.c b/sys/kern/subr_busdma_bounce.c index 76f50b2abf38..77b1b358758f 100644 --- a/sys/kern/subr_busdma_bounce.c +++ b/sys/kern/subr_busdma_bounce.c @@ -155,6 +155,22 @@ busdma_sysctl_tree_top(struct bounce_zone *bz) return (bz->sysctl_tree_top); } +/* + * Returns true if the address falls within the tag's exclusion window, or + * fails to meet its alignment requirements. + */ +static bool +addr_needs_bounce(bus_dma_tag_t dmat, bus_addr_t paddr) +{ + + if (paddr > dmat_lowaddr(dmat) && paddr <= dmat_highaddr(dmat)) + return (true); + if (!vm_addr_align_ok(paddr, dmat_alignment(dmat))) + return (true); + + return (false); +} + static int alloc_bounce_zone(bus_dma_tag_t dmat) { diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index a4c30ee9470c..aa1a29e1f1ce 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -99,10 +99,9 @@ struct bus_dmamap { static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata"); -static __inline int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr); - #define dmat_alignment(dmat) ((dmat)->alignment) #define dmat_flags(dmat) ((dmat)->flags) +#define dmat_highaddr(dmat) ((dmat)->highaddr) #define dmat_lowaddr(dmat) ((dmat)->lowaddr) #define dmat_lockfunc(dmat) ((dmat)->lockfunc) #define dmat_lockfuncarg(dmat) ((dmat)->lockfuncarg) @@ -110,27 +109,20 @@ static __inline int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr); #include "../../kern/subr_busdma_bounce.c" /* - * Return true if a match is made. - * - * To find a match walk the chain of bus_dma_tag_t's looking for 'paddr'. - * - * If paddr is within the bounds of the dma tag then call the filter callback - * to check for a match, if there is no filter callback then assume a match. + * Returns true if the address falls within the tag's exclusion window, or + * fails to meet its alignment requirements. */ -static __inline int -run_filter(bus_dma_tag_t dmat, bus_addr_t paddr) +static __inline bool +must_bounce(bus_dma_tag_t dmat, bus_addr_t paddr) { - int retval; - - retval = 0; - if (dmat->iommu == NULL && - paddr > dmat->lowaddr && paddr <= dmat->highaddr) - retval = 1; + if (dmat->iommu == NULL && paddr > dmat->lowaddr && + paddr <= dmat->highaddr) + return (true); if (!vm_addr_align_ok(paddr, dmat->alignment)) - retval = 1; + return (true); - return (retval); + return (false); } #define BUS_DMA_COULD_BOUNCE BUS_DMA_BUS3 @@ -492,7 +484,7 @@ _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, curaddr = buf; while (buflen != 0) { sgsize = MIN(buflen, dmat->maxsegsz); - if (run_filter(dmat, curaddr) != 0) { + if (must_bounce(dmat, curaddr)) { sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); map->pagesneeded++; @@ -532,7 +524,7 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap, paddr = pmap_kextract(vaddr); else paddr = pmap_extract(pmap, vaddr); - if (run_filter(dmat, paddr) != 0) { + if (must_bounce(dmat, paddr)) { sg_len = roundup2(sg_len, dmat->alignment); map->pagesneeded++; } @@ -614,7 +606,7 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat, while (buflen > 0) { curaddr = buf; sgsize = MIN(buflen, dmat->maxsegsz); - if (map->pagesneeded != 0 && run_filter(dmat, curaddr)) { + if (map->pagesneeded != 0 && must_bounce(dmat, curaddr)) { sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); curaddr = add_bounce_page(dmat, map, 0, curaddr, sgsize); @@ -694,7 +686,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat, */ max_sgsize = MIN(buflen, dmat->maxsegsz); sgsize = PAGE_SIZE - (curaddr & PAGE_MASK); - if (map->pagesneeded != 0 && run_filter(dmat, curaddr)) { + if (map->pagesneeded != 0 && must_bounce(dmat, curaddr)) { sgsize = roundup2(sgsize, dmat->alignment); sgsize = MIN(sgsize, max_sgsize); curaddr = add_bounce_page(dmat, map, kvaddr, curaddr, diff --git a/sys/riscv/include/bus_dma_impl.h b/sys/riscv/include/bus_dma_impl.h index 550ba648615c..09fd29b74f8e 100644 --- a/sys/riscv/include/bus_dma_impl.h +++ b/sys/riscv/include/bus_dma_impl.h @@ -74,7 +74,6 @@ struct bus_dma_impl { bus_dmasync_op_t op); }; -int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr); int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, diff --git a/sys/riscv/riscv/busdma_bounce.c b/sys/riscv/riscv/busdma_bounce.c index e9801a8a732e..c9fdb0e38e40 100644 --- a/sys/riscv/riscv/busdma_bounce.c +++ b/sys/riscv/riscv/busdma_bounce.c @@ -103,7 +103,6 @@ struct bus_dmamap { struct sync_list slist[]; }; -int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr); static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap, void *buf, bus_size_t buflen, int flags); static void _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, @@ -113,6 +112,7 @@ static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata"); #define dmat_alignment(dmat) ((dmat)->common.alignment) #define dmat_flags(dmat) ((dmat)->common.flags) +#define dmat_highaddr(dmat) ((dmat)->common.highaddr) #define dmat_lowaddr(dmat) ((dmat)->common.lowaddr) #define dmat_lockfunc(dmat) ((dmat)->common.lockfunc) #define dmat_lockfuncarg(dmat) ((dmat)->common.lockfuncarg) @@ -494,7 +494,7 @@ _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, curaddr = buf; while (buflen != 0) { sgsize = MIN(buflen, dmat->common.maxsegsz); - if (bus_dma_run_filter(&dmat->common, curaddr)) { + if (addr_needs_bounce(dmat, curaddr)) { sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); map->pagesneeded++; @@ -535,7 +535,7 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap, paddr = pmap_kextract(vaddr); else paddr = pmap_extract(pmap, vaddr); - if (bus_dma_run_filter(&dmat->common, paddr) != 0) { + if (addr_needs_bounce(dmat, paddr)) { sg_len = roundup2(sg_len, dmat->common.alignment); map->pagesneeded++; @@ -621,7 +621,7 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, sgsize = MIN(buflen, dmat->common.maxsegsz); if (((dmat->bounce_flags & BF_COULD_BOUNCE) != 0) && map->pagesneeded != 0 && - bus_dma_run_filter(&dmat->common, curaddr)) { + addr_needs_bounce(dmat, curaddr)) { sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); curaddr = add_bounce_page(dmat, map, 0, curaddr, sgsize); @@ -708,7 +708,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, sgsize = PAGE_SIZE - (curaddr & PAGE_MASK); if (((dmat->bounce_flags & BF_COULD_BOUNCE) != 0) && map->pagesneeded != 0 && - bus_dma_run_filter(&dmat->common, curaddr)) { + addr_needs_bounce(dmat, curaddr)) { sgsize = roundup2(sgsize, dmat->common.alignment); sgsize = MIN(sgsize, max_sgsize); curaddr = add_bounce_page(dmat, map, kvaddr, curaddr, diff --git a/sys/riscv/riscv/busdma_machdep.c b/sys/riscv/riscv/busdma_machdep.c index 630938a394e1..4a736f874d16 100644 --- a/sys/riscv/riscv/busdma_machdep.c +++ b/sys/riscv/riscv/busdma_machdep.c @@ -48,27 +48,6 @@ #include #include -/* - * Return true if a match is made. - * - * To find a match walk the chain of bus_dma_tag_t's looking for 'paddr'. - * - * If paddr is within the bounds of the dma tag then call the filter callback - * to check for a match, if there is no filter callback then assume a match. - */ -int -bus_dma_run_filter(struct bus_dma_tag_common *tc, bus_addr_t paddr) -{ - int retval; - - retval = 0; - if ((paddr > tc->lowaddr && paddr <= tc->highaddr) || - !vm_addr_align_ok(paddr, tc->alignment)) - retval = 1; - - return (retval); -} - int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, diff --git a/sys/x86/include/busdma_impl.h b/sys/x86/include/busdma_impl.h index 2e4c83b04d72..86c8bb9ca972 100644 --- a/sys/x86/include/busdma_impl.h +++ b/sys/x86/include/busdma_impl.h @@ -82,7 +82,6 @@ struct bus_dma_impl { #endif }; -int bus_dma_run_filter(struct bus_dma_tag_common *dmat, vm_paddr_t paddr); int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c index 992f455ceb96..10e9e0b36602 100644 --- a/sys/x86/x86/busdma_bounce.c +++ b/sys/x86/x86/busdma_bounce.c @@ -110,6 +110,7 @@ static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata"); #define dmat_alignment(dmat) ((dmat)->common.alignment) #define dmat_domain(dmat) ((dmat)->common.domain) #define dmat_flags(dmat) ((dmat)->common.flags) +#define dmat_highaddr(dmat) ((dmat)->common.highaddr) #define dmat_lowaddr(dmat) ((dmat)->common.lowaddr) #define dmat_lockfunc(dmat) ((dmat)->common.lockfunc) #define dmat_lockfuncarg(dmat) ((dmat)->common.lockfuncarg) @@ -490,7 +491,7 @@ _bus_dmamap_pagesneeded(bus_dma_tag_t dmat, vm_paddr_t buf, bus_size_t buflen, curaddr = buf; while (buflen != 0) { sgsize = MIN(buflen, dmat->common.maxsegsz); - if (bus_dma_run_filter(&dmat->common, curaddr)) { + if (addr_needs_bounce(dmat, curaddr)) { sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); if (pagesneeded == NULL) @@ -546,7 +547,7 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap, paddr = pmap_kextract(vaddr); else paddr = pmap_extract(pmap, vaddr); - if (bus_dma_run_filter(&dmat->common, paddr) != 0) { + if (addr_needs_bounce(dmat, paddr)) { sg_len = roundup2(sg_len, dmat->common.alignment); map->pagesneeded++; @@ -583,7 +584,7 @@ _bus_dmamap_count_ma(bus_dma_tag_t dmat, bus_dmamap_t map, struct vm_page **ma, sg_len = PAGE_SIZE - ma_offs; max_sgsize = MIN(buflen, dmat->common.maxsegsz); sg_len = MIN(sg_len, max_sgsize); - if (bus_dma_run_filter(&dmat->common, paddr) != 0) { + if (addr_needs_bounce(dmat, paddr)) { sg_len = roundup2(sg_len, dmat->common.alignment); sg_len = MIN(sg_len, max_sgsize); @@ -684,7 +685,7 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, sgsize = MIN(buflen, dmat->common.maxsegsz); if ((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0 && map->pagesneeded != 0 && - bus_dma_run_filter(&dmat->common, curaddr)) { + addr_needs_bounce(dmat, curaddr)) { sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); curaddr = add_bounce_page(dmat, map, 0, curaddr, 0, sgsize); @@ -752,7 +753,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, sgsize = PAGE_SIZE - (curaddr & PAGE_MASK); if ((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0 && map->pagesneeded != 0 && - bus_dma_run_filter(&dmat->common, curaddr)) { + addr_needs_bounce(dmat, curaddr)) { sgsize = roundup2(sgsize, dmat->common.alignment); sgsize = MIN(sgsize, max_sgsize); curaddr = add_bounce_page(dmat, map, kvaddr, curaddr, 0, @@ -819,7 +820,7 @@ bounce_bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map, sgsize = PAGE_SIZE - ma_offs; if ((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0 && map->pagesneeded != 0 && - bus_dma_run_filter(&dmat->common, paddr)) { + addr_needs_bounce(dmat, paddr)) { sgsize = roundup2(sgsize, dmat->common.alignment); sgsize = MIN(sgsize, max_sgsize); KASSERT(vm_addr_align_ok(sgsize, diff --git a/sys/x86/x86/busdma_machdep.c b/sys/x86/x86/busdma_machdep.c index 6fe49367f7d8..efba01ea5988 100644 --- a/sys/x86/x86/busdma_machdep.c +++ b/sys/x86/x86/busdma_machdep.c @@ -53,28 +53,6 @@ #include #include -/* - * Return true if a match is made. - * - * To find a match walk the chain of bus_dma_tag_t's looking for 'paddr'. - * - * If paddr is within the bounds of the dma tag then call the filter callback - * to check for a match, if there is no filter callback then assume a match. - */ -int -bus_dma_run_filter(struct bus_dma_tag_common *tc, vm_paddr_t paddr) -{ - int retval; - - retval = 0; - if (paddr >= BUS_SPACE_MAXADDR || - (paddr > tc->lowaddr && paddr <= tc->highaddr) || - !vm_addr_align_ok(paddr, tc->alignment)) - retval = 1; - - return (retval); -} - int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,