From nobody Wed Jan 5 21:51:06 2022 X-Original-To: dev-commits-src-main@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 8E98F1931719; Wed, 5 Jan 2022 21:51:07 +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 4JTjpy2P56z3HR3; Wed, 5 Jan 2022 21:51:06 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 30D73141E8; Wed, 5 Jan 2022 21:51: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 205Lp6sh054021; Wed, 5 Jan 2022 21:51:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 205Lp6av054020; Wed, 5 Jan 2022 21:51:06 GMT (envelope-from git) Date: Wed, 5 Jan 2022 21:51:06 GMT Message-Id: <202201052151.205Lp6av054020@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 7def1e10b3cc - main - bus_dma: Deduplicate locking helper functions. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7def1e10b3cc8ff8fd509aab07618d406f0d5bf2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641419466; 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=S2J7PtO3l5HFprQqn5wE+a6FeSjGANdA7nISsS9NhLs=; b=paY6OBLRRgCTxxSf/sebsJFoh8kuRAuvfKkqAqZ5oTPqdQDh7rlUq200xChOyaWwjk9dN1 UXwyAqkDVrIL+nqF2zusyTPREbIiZ01CmKt6aztoLwjJCsZUnVCAiETckI5SHJCnQX4UY+ 7Q9T5MDA0/1AsqcR1FwCqsWcvPlWUl1Whw7lRzuEGeBOgXontxKlZw8FlM+H9TYg12sMwp a57if8qfmeb2HdsZLVLMuGSuT1tKpwWLzlXTCvngMzIZil7x8/AzhJtMnqsUxE93qMIPdq XHxvBn3GHgpZsHZuk7Mc9MNeSuai/4Jk1Nrqfyz0Ncw6fPIZtjJRXrLtZ/1e4g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641419466; a=rsa-sha256; cv=none; b=q0iwsNe1NLy5AwSxeoX/Y0njeWvsSRYCjauHxsSPbRam34ZX51vwzIG329dDNxtRO3od0S o9qpB6nT732A2/Obahu9IpJD7Hjy5Ux5cw3l9GyLs+Vvm/HHf4dvhKzZCB8XaNW6fw4vLx ls/AQPnNof4v/NkHQAzd9947yrgZRx7Mqkg9xaU5K3pyfy3AWQd6VlRN8694wTqild2tRa SHNGwqZKDtx5BhYzPYJC6sF+pXk6CGVBqdMKJds8EhqwGcEjOcSYITskJXhO1rbbpLbzeb JGUCwr1cMXHoXjAsT6m5x7vi8kqqenzDbsgrxdhDRPg7bSfyneBPq0X87qnRSw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=7def1e10b3cc8ff8fd509aab07618d406f0d5bf2 commit 7def1e10b3cc8ff8fd509aab07618d406f0d5bf2 Author: John Baldwin AuthorDate: 2022-01-05 21:50:40 +0000 Commit: John Baldwin CommitDate: 2022-01-05 21:50:40 +0000 bus_dma: Deduplicate locking helper functions. - Move busdma_lock_mutex to subr_bus_dma.c. - Move _busdma_lock_dflt to subr_bus_dma.c. This function was named a couple of different things previously. It is not a public API but an internal helper used in place of a NULL pointer. The prototype is in as not all backends include . Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D33694 --- sys/arm/arm/busdma_machdep.c | 37 +--------------------------------- sys/arm64/arm64/busdma_machdep.c | 37 +--------------------------------- sys/arm64/include/bus_dma_impl.h | 1 - sys/kern/subr_bus_dma.c | 39 ++++++++++++++++++++++++++++++++++++ sys/powerpc/powerpc/busdma_machdep.c | 36 +-------------------------------- sys/riscv/include/bus_dma_impl.h | 1 - sys/riscv/riscv/busdma_machdep.c | 37 +--------------------------------- sys/sys/bus_dma.h | 5 +++++ sys/x86/include/busdma_impl.h | 1 - sys/x86/x86/busdma_machdep.c | 37 +--------------------------------- 10 files changed, 49 insertions(+), 182 deletions(-) diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c index 758517323ff1..a754cb13ddc5 100644 --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -375,41 +375,6 @@ must_bounce(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t paddr, return (0); } -/* - * Convenience function for manipulating driver locks from busdma (during - * busdma_swi, for example). - */ -void -busdma_lock_mutex(void *arg, bus_dma_lock_op_t op) -{ - struct mtx *dmtx; - - dmtx = (struct mtx *)arg; - switch (op) { - case BUS_DMA_LOCK: - mtx_lock(dmtx); - break; - case BUS_DMA_UNLOCK: - mtx_unlock(dmtx); - break; - default: - panic("Unknown operation 0x%x for busdma_lock_mutex!", op); - } -} - -/* - * dflt_lock should never get called. It gets put into the dma tag when - * lockfunc == NULL, which is only valid if the maps that are associated - * with the tag are meant to never be defered. - * XXX Should have a way to identify which driver is responsible here. - */ -static void -dflt_lock(void *arg, bus_dma_lock_op_t op) -{ - - panic("driver error: busdma dflt_lock called"); -} - /* * Allocate a device specific dma_tag. */ @@ -461,7 +426,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, newtag->lockfunc = lockfunc; newtag->lockfuncarg = lockfuncarg; } else { - newtag->lockfunc = dflt_lock; + newtag->lockfunc = _busdma_dflt_lock; newtag->lockfuncarg = NULL; } diff --git a/sys/arm64/arm64/busdma_machdep.c b/sys/arm64/arm64/busdma_machdep.c index 5d42d4e58c22..4ea604ce474c 100644 --- a/sys/arm64/arm64/busdma_machdep.c +++ b/sys/arm64/arm64/busdma_machdep.c @@ -51,41 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include -/* - * Convenience function for manipulating driver locks from busdma (during - * busdma_swi, for example). - */ -void -busdma_lock_mutex(void *arg, bus_dma_lock_op_t op) -{ - struct mtx *dmtx; - - dmtx = (struct mtx *)arg; - switch (op) { - case BUS_DMA_LOCK: - mtx_lock(dmtx); - break; - case BUS_DMA_UNLOCK: - mtx_unlock(dmtx); - break; - default: - panic("Unknown operation 0x%x for busdma_lock_mutex!", op); - } -} - -/* - * dflt_lock should never get called. It gets put into the dma tag when - * lockfunc == NULL, which is only valid if the maps that are associated - * with the tag are meant to never be defered. - * XXX Should have a way to identify which driver is responsible here. - */ -void -bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op) -{ - - panic("driver error: busdma dflt_lock called"); -} - /* * Return true if a match is made. * @@ -154,7 +119,7 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent, common->lockfunc = lockfunc; common->lockfuncarg = lockfuncarg; } else { - common->lockfunc = bus_dma_dflt_lock; + common->lockfunc = _busdma_dflt_lock; common->lockfuncarg = NULL; } diff --git a/sys/arm64/include/bus_dma_impl.h b/sys/arm64/include/bus_dma_impl.h index 1488bd3a55da..949850cc528e 100644 --- a/sys/arm64/include/bus_dma_impl.h +++ b/sys/arm64/include/bus_dma_impl.h @@ -84,7 +84,6 @@ struct bus_dma_impl { bus_dmasync_op_t op); }; -void bus_dma_dflt_lock(void *arg, bus_dma_lock_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, diff --git a/sys/kern/subr_bus_dma.c b/sys/kern/subr_bus_dma.c index 909750112a96..7ed012ba1a4f 100644 --- a/sys/kern/subr_bus_dma.c +++ b/sys/kern/subr_bus_dma.c @@ -42,8 +42,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include @@ -59,6 +61,43 @@ __FBSDID("$FreeBSD$"); #include +/* + * Convenience function for manipulating driver locks from busdma (during + * busdma_swi, for example). + */ +void +busdma_lock_mutex(void *arg, bus_dma_lock_op_t op) +{ + struct mtx *dmtx; + + dmtx = (struct mtx *)arg; + switch (op) { + case BUS_DMA_LOCK: + mtx_lock(dmtx); + break; + case BUS_DMA_UNLOCK: + mtx_unlock(dmtx); + break; + default: + panic("Unknown operation 0x%x for busdma_lock_mutex!", op); + } +} + +/* + * dflt_lock should never get called. It gets put into the dma tag when + * lockfunc == NULL, which is only valid if the maps that are associated + * with the tag are meant to never be deferred. + * + * XXX Should have a way to identify which driver is responsible here. + */ +void +_busdma_dflt_lock(void *arg, bus_dma_lock_op_t op) +{ + + panic("driver error: _bus_dma_dflt_lock called"); +} + + /* * Load up data starting at offset within a region specified by a * list of virtual address ranges until either length or the region diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index ea3ab3dc7315..666f40d4edd7 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -146,40 +146,6 @@ run_filter(bus_dma_tag_t dmat, bus_addr_t paddr) return (retval); } -/* - * Convenience function for manipulating driver locks from busdma (during - * busdma_swi, for example). - */ -void -busdma_lock_mutex(void *arg, bus_dma_lock_op_t op) -{ - struct mtx *dmtx; - - dmtx = (struct mtx *)arg; - switch (op) { - case BUS_DMA_LOCK: - mtx_lock(dmtx); - break; - case BUS_DMA_UNLOCK: - mtx_unlock(dmtx); - break; - default: - panic("Unknown operation 0x%x for busdma_lock_mutex!", op); - } -} - -/* - * dflt_lock should never get called. It gets put into the dma tag when - * lockfunc == NULL, which is only valid if the maps that are associated - * with the tag are meant to never be defered. - * XXX Should have a way to identify which driver is responsible here. - */ -static void -dflt_lock(void *arg, bus_dma_lock_op_t op) -{ - panic("driver error: busdma dflt_lock called"); -} - #define BUS_DMA_COULD_BOUNCE BUS_DMA_BUS3 #define BUS_DMA_MIN_ALLOC_COMP BUS_DMA_BUS4 /* @@ -232,7 +198,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, newtag->lockfunc = lockfunc; newtag->lockfuncarg = lockfuncarg; } else { - newtag->lockfunc = dflt_lock; + newtag->lockfunc = _busdma_dflt_lock; newtag->lockfuncarg = NULL; } diff --git a/sys/riscv/include/bus_dma_impl.h b/sys/riscv/include/bus_dma_impl.h index e482fb76a716..fd741210ca29 100644 --- a/sys/riscv/include/bus_dma_impl.h +++ b/sys/riscv/include/bus_dma_impl.h @@ -81,7 +81,6 @@ struct bus_dma_impl { bus_dmasync_op_t op); }; -void bus_dma_dflt_lock(void *arg, bus_dma_lock_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, diff --git a/sys/riscv/riscv/busdma_machdep.c b/sys/riscv/riscv/busdma_machdep.c index 5a80def489e9..11ff9aa6afa5 100644 --- a/sys/riscv/riscv/busdma_machdep.c +++ b/sys/riscv/riscv/busdma_machdep.c @@ -51,41 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include -/* - * Convenience function for manipulating driver locks from busdma (during - * busdma_swi, for example). - */ -void -busdma_lock_mutex(void *arg, bus_dma_lock_op_t op) -{ - struct mtx *dmtx; - - dmtx = (struct mtx *)arg; - switch (op) { - case BUS_DMA_LOCK: - mtx_lock(dmtx); - break; - case BUS_DMA_UNLOCK: - mtx_unlock(dmtx); - break; - default: - panic("Unknown operation 0x%x for busdma_lock_mutex!", op); - } -} - -/* - * dflt_lock should never get called. It gets put into the dma tag when - * lockfunc == NULL, which is only valid if the maps that are associated - * with the tag are meant to never be defered. - * XXX Should have a way to identify which driver is responsible here. - */ -void -bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op) -{ - - panic("driver error: busdma dflt_lock called"); -} - /* * Return true if a match is made. * @@ -156,7 +121,7 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent, common->lockfunc = lockfunc; common->lockfuncarg = lockfuncarg; } else { - common->lockfunc = bus_dma_dflt_lock; + common->lockfunc = _busdma_dflt_lock; common->lockfuncarg = NULL; } diff --git a/sys/sys/bus_dma.h b/sys/sys/bus_dma.h index 7eac96b5af1e..212d8e3af09d 100644 --- a/sys/sys/bus_dma.h +++ b/sys/sys/bus_dma.h @@ -149,6 +149,11 @@ typedef int bus_dma_filter_t(void *, bus_addr_t); */ void busdma_lock_mutex(void *arg, bus_dma_lock_op_t op); +/* + * Internal helper function used by tags that do not defer loads. + */ +void _busdma_dflt_lock(void *arg, bus_dma_lock_op_t op); + /* * Allocate a device specific dma_tag encapsulating the constraints of * the parent tag in addition to other restrictions specified: diff --git a/sys/x86/include/busdma_impl.h b/sys/x86/include/busdma_impl.h index 9ae75095821a..577fd99f9496 100644 --- a/sys/x86/include/busdma_impl.h +++ b/sys/x86/include/busdma_impl.h @@ -89,7 +89,6 @@ struct bus_dma_impl { #endif }; -void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op); 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, diff --git a/sys/x86/x86/busdma_machdep.c b/sys/x86/x86/busdma_machdep.c index ae62f83ea300..52bc765138c9 100644 --- a/sys/x86/x86/busdma_machdep.c +++ b/sys/x86/x86/busdma_machdep.c @@ -55,41 +55,6 @@ __FBSDID("$FreeBSD$"); #include #include -/* - * Convenience function for manipulating driver locks from busdma (during - * busdma_swi, for example). - */ -void -busdma_lock_mutex(void *arg, bus_dma_lock_op_t op) -{ - struct mtx *dmtx; - - dmtx = (struct mtx *)arg; - switch (op) { - case BUS_DMA_LOCK: - mtx_lock(dmtx); - break; - case BUS_DMA_UNLOCK: - mtx_unlock(dmtx); - break; - default: - panic("Unknown operation 0x%x for busdma_lock_mutex!", op); - } -} - -/* - * dflt_lock should never get called. It gets put into the dma tag when - * lockfunc == NULL, which is only valid if the maps that are associated - * with the tag are meant to never be defered. - * XXX Should have a way to identify which driver is responsible here. - */ -void -bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op) -{ - - panic("driver error: busdma dflt_lock called"); -} - /* * Return true if a match is made. * @@ -161,7 +126,7 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent, common->lockfunc = lockfunc; common->lockfuncarg = lockfuncarg; } else { - common->lockfunc = bus_dma_dflt_lock; + common->lockfunc = _busdma_dflt_lock; common->lockfuncarg = NULL; }