From nobody Fri Jul 14 18:41:06 2023 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 4R2gKb3HPmz4mpw3; Fri, 14 Jul 2023 18:41: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 4R2gKb1jJlz4KPs; Fri, 14 Jul 2023 18:41:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689360067; 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=u27uJkYjG1RpSKNYHFDutU+/x3hOmA3eDG+L2okWJAE=; b=ukvTdjrtoQZ0ZxEPW5twXm4WGYxrhnAkbKAnrhC7FarKiWM0G0ku7ZWvOuJbumYljyHh2M V9cvmMqOHFtzsV42vC+Blgv3DUHSO1WssuOwyZ/DRdW88j1nhxYPgo5Y67aR9V/XObm4ys aH/JdKJSy1JwwYHT0lPjghE26BLrojTSJ6xjyWBsvVI5l77JOVllBz1BYe/PAyNP9krMQ3 JkvvhhKH6Q3TJpG7srb5ruhDcjMWsCoTKDfsN4iBaG7Q6C6ev1gFzV/yv5dvdilNcwyZqR l/9tOQ1ZH6/sUtWBYs1/HP6yggJf8RJiT/jyiyvuQGH5QiqDxqW+9/fzYJS7IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689360067; 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=u27uJkYjG1RpSKNYHFDutU+/x3hOmA3eDG+L2okWJAE=; b=JL9khXWTx2H1rP99qdvVz3/nSd/g7OOkM9f5dlYPTqXc4hZ7ycG6QBqgTlfRNFxdI17c1Q NOGcqqGjEkpDabvQpzfavwb+vW/Denhw11O8r1nrEB8U20oMR0n1CCliH9DzZkG6QY1YmT Sb4fsUgTFODdzn0VFt65uCv1qO0dLqhBciGegd4fKBZPANgKKqrX2P8yLNVDfFk9JQxFu8 kp9KGb/zrD05oboogngS7YlBHheCIOWqDTg5DaRGZPVuN64SqQj2cU1CDxj7ZUahl7PFzB BNt8z6cdd4hkOsOlWmRaPnItr8wUbazFjIaPmqK5Tx66Lb24A13Io9Id4MO5jA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689360067; a=rsa-sha256; cv=none; b=QTyelnycKA3QwsLmTlpYP/WTtRvWXO0+mirToQV2pAKVYyVKUoBse1Lqq1Y93QppgNEVbj +6BYXQrgUg63qxCqVCUF3BKErY9hX7kfVGVFCyXAwLt/piQVFv68jKXz11CZjnSF55fIsG T3JohmrSnn/8PnEn2fyuWIJUA+o1vhbDr/h/90stI2Af+N/plX909L4RuOkk0gHFZ5KQKF K5jtVw7p1/PlaajQnMi6vHwdquQviRkTddAxK9+1fL9bNhC8Y/lcYcygtBxh98Z6YFM7lq U6vuU2acgas1jgvfEZXHR6yUJ1Snc74bbu11lAi9jx4IG3eNI5RbxHl3kHUSqw== 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 4R2gKb056WzTQc; Fri, 14 Jul 2023 18:41:07 +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 36EIf6wU019462; Fri, 14 Jul 2023 18:41:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36EIf6IL019461; Fri, 14 Jul 2023 18:41:06 GMT (envelope-from git) Date: Fri, 14 Jul 2023 18:41:06 GMT Message-Id: <202307141841.36EIf6IL019461@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: c9b19803946e - main - memdesc: Retire MEMDESC_BIO. 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: c9b19803946e0dc74a54a1dcbf71a2837c979388 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c9b19803946e0dc74a54a1dcbf71a2837c979388 commit c9b19803946e0dc74a54a1dcbf71a2837c979388 Author: John Baldwin AuthorDate: 2023-07-14 18:32:40 +0000 Commit: John Baldwin CommitDate: 2023-07-14 18:32:40 +0000 memdesc: Retire MEMDESC_BIO. Instead, change memdesc_bio to examine the bio and return a memdesc of a more generic type describing the data buffer. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D41029 --- sys/kern/subr_bus_dma.c | 64 ++----------------------------------------------- sys/kern/subr_msan.c | 6 ----- sys/kern/vfs_bio.c | 15 ++++++++++++ sys/sys/memdesc.h | 14 +---------- 4 files changed, 18 insertions(+), 81 deletions(-) diff --git a/sys/kern/subr_bus_dma.c b/sys/kern/subr_bus_dma.c index 0ff57c389fb1..da7a2ee4cdc9 100644 --- a/sys/kern/subr_bus_dma.c +++ b/sys/kern/subr_bus_dma.c @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -259,29 +258,6 @@ _bus_dmamap_load_mbuf_sg(bus_dma_tag_t dmat, bus_dmamap_t map, return (error); } -/* - * Load from block io. - */ -static int -_bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio, - int *nsegs, int flags) -{ - - if ((bio->bio_flags & BIO_VLIST) != 0) { - bus_dma_segment_t *segs = (bus_dma_segment_t *)bio->bio_data; - return (_bus_dmamap_load_vlist(dmat, map, segs, bio->bio_ma_n, - kernel_pmap, nsegs, flags, bio->bio_ma_offset, - bio->bio_bcount)); - } - - if ((bio->bio_flags & BIO_UNMAPPED) != 0) - return (_bus_dmamap_load_ma(dmat, map, bio->bio_ma, - bio->bio_bcount, bio->bio_ma_offset, flags, NULL, nsegs)); - - return (_bus_dmamap_load_buffer(dmat, map, bio->bio_data, - bio->bio_bcount, kernel_pmap, flags, NULL, nsegs)); -} - int bus_dmamap_load_ma_triv(bus_dma_tag_t dmat, bus_dmamap_t map, struct vm_page **ma, bus_size_t tlen, int ma_offs, int flags, @@ -497,43 +473,11 @@ bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio, bus_dmamap_callback_t *callback, void *callback_arg, int flags) { - bus_dma_segment_t *segs; struct memdesc mem; - int error; - int nsegs; -#ifdef KMSAN mem = memdesc_bio(bio); - _bus_dmamap_load_kmsan(dmat, map, &mem); -#endif - - if ((flags & BUS_DMA_NOWAIT) == 0) { - mem = memdesc_bio(bio); - _bus_dmamap_waitok(dmat, map, &mem, callback, callback_arg); - } - nsegs = -1; - error = _bus_dmamap_load_bio(dmat, map, bio, &nsegs, flags); - nsegs++; - - CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d", - __func__, dmat, flags, error, nsegs); - - if (error == EINPROGRESS) - return (error); - - segs = _bus_dmamap_complete(dmat, map, NULL, nsegs, error); - if (error) - (*callback)(callback_arg, segs, 0, error); - else - (*callback)(callback_arg, segs, nsegs, error); - /* - * Return ENOMEM to the caller so that it can pass it up the stack. - * This error only happens when NOWAIT is set, so deferral is disabled. - */ - if (error == ENOMEM) - return (error); - - return (0); + return (bus_dmamap_load_mem(dmat, map, &mem, callback, callback_arg, + flags)); } int @@ -571,10 +515,6 @@ bus_dmamap_load_mem(bus_dma_tag_t dmat, bus_dmamap_t map, error = _bus_dmamap_load_plist(dmat, map, mem->u.md_list, mem->md_nseg, &nsegs, flags); break; - case MEMDESC_BIO: - error = _bus_dmamap_load_bio(dmat, map, mem->u.md_bio, - &nsegs, flags); - break; case MEMDESC_UIO: error = _bus_dmamap_load_uio(dmat, map, mem->u.md_uio, &nsegs, flags); diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c index ec2492773243..ba625a5405c5 100644 --- a/sys/kern/subr_msan.c +++ b/sys/kern/subr_msan.c @@ -1508,9 +1508,6 @@ kmsan_bus_dmamap_sync(struct memdesc *desc, bus_dmasync_op_t op) kmsan_check(desc->u.md_vaddr, desc->md_len, "dmasync"); break; - case MEMDESC_BIO: - kmsan_check_bio(desc->u.md_bio, "dmasync"); - break; case MEMDESC_MBUF: kmsan_check_mbuf(desc->u.md_mbuf, "dmasync"); break; @@ -1527,9 +1524,6 @@ kmsan_bus_dmamap_sync(struct memdesc *desc, bus_dmasync_op_t op) kmsan_mark(desc->u.md_vaddr, desc->md_len, KMSAN_STATE_INITED); break; - case MEMDESC_BIO: - kmsan_mark_bio(desc->u.md_bio, KMSAN_STATE_INITED); - break; case MEMDESC_MBUF: kmsan_mark_mbuf(desc->u.md_mbuf, KMSAN_STATE_INITED); break; diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 98b267f89737..690dd97e708c 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -5233,6 +5234,20 @@ bdata2bio(struct buf *bp, struct bio *bip) } } +struct memdesc +memdesc_bio(struct bio *bio) +{ + if ((bio->bio_flags & BIO_VLIST) != 0) + return (memdesc_vlist((struct bus_dma_segment *)bio->bio_data, + bio->bio_ma_n)); + + if ((bio->bio_flags & BIO_UNMAPPED) != 0) + return (memdesc_vmpages(bio->bio_ma, bio->bio_bcount, + bio->bio_ma_offset)); + + return (memdesc_vaddr(bio->bio_data, bio->bio_bcount)); +} + static int buf_pager_relbuf; SYSCTL_INT(_vfs, OID_AUTO, buf_pager_relbuf, CTLFLAG_RWTUN, &buf_pager_relbuf, 0, diff --git a/sys/sys/memdesc.h b/sys/sys/memdesc.h index d31b04f32393..9054e2674409 100644 --- a/sys/sys/memdesc.h +++ b/sys/sys/memdesc.h @@ -47,7 +47,6 @@ struct memdesc { void *md_vaddr; vm_paddr_t md_paddr; struct bus_dma_segment *md_list; - struct bio *md_bio; struct uio *md_uio; struct mbuf *md_mbuf; struct vm_page **md_ma; @@ -66,7 +65,6 @@ struct memdesc { #define MEMDESC_PADDR 2 /* Contiguous physical address. */ #define MEMDESC_VLIST 3 /* scatter/gather list of kva addresses. */ #define MEMDESC_PLIST 4 /* scatter/gather list of physical addresses. */ -#define MEMDESC_BIO 5 /* Pointer to a bio (block io). */ #define MEMDESC_UIO 6 /* Pointer to a uio (any io). */ #define MEMDESC_MBUF 7 /* Pointer to a mbuf (network io). */ #define MEMDESC_VMPAGES 8 /* Pointer to array of VM pages. */ @@ -119,17 +117,6 @@ memdesc_plist(struct bus_dma_segment *plist, int sglist_cnt) return (mem); } -static inline struct memdesc -memdesc_bio(struct bio *bio) -{ - struct memdesc mem; - - mem.u.md_bio = bio; - mem.md_type = MEMDESC_BIO; - - return (mem); -} - static inline struct memdesc memdesc_uio(struct uio *uio) { @@ -165,6 +152,7 @@ memdesc_vmpages(struct vm_page **ma, size_t len, u_int ma_offset) return (mem); } +struct memdesc memdesc_bio(struct bio *bio); struct memdesc memdesc_ccb(union ccb *ccb); #endif /* _SYS_MEMDESC_H_ */