git: bab38b44dd11 - main - memdesc: Add a MEMDESC_VMPAGES descriptor type.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 14 Jul 2023 18:41:05 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=bab38b44dd119fc9e8773b68e888cdcbc9564c55 commit bab38b44dd119fc9e8773b68e888cdcbc9564c55 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2023-07-14 18:31:42 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2023-07-14 18:32:24 +0000 memdesc: Add a MEMDESC_VMPAGES descriptor type. This memory descriptor is backed by an array of VM pages. This type requires adding a new field to 'struct memdesc' to hold the offset within the first page. For LP64 systems, this new field is added in an existing padding hole so does not increase the size. For ILP32 systems, this grows 'struct memdesc' from 12 to 16 bytes. Reviewed by: imp, markj Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D41028 --- sys/kern/subr_bus_dma.c | 4 ++++ sys/sys/memdesc.h | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_bus_dma.c b/sys/kern/subr_bus_dma.c index 329887affc99..0ff57c389fb1 100644 --- a/sys/kern/subr_bus_dma.c +++ b/sys/kern/subr_bus_dma.c @@ -583,6 +583,10 @@ bus_dmamap_load_mem(bus_dma_tag_t dmat, bus_dmamap_t map, error = _bus_dmamap_load_mbuf_sg(dmat, map, mem->u.md_mbuf, NULL, &nsegs, flags); break; + case MEMDESC_VMPAGES: + error = _bus_dmamap_load_ma(dmat, map, mem->u.md_ma, + mem->md_len, mem->md_offset, flags, NULL, &nsegs); + break; } nsegs++; diff --git a/sys/sys/memdesc.h b/sys/sys/memdesc.h index 58aafb2a1f1b..d31b04f32393 100644 --- a/sys/sys/memdesc.h +++ b/sys/sys/memdesc.h @@ -35,6 +35,7 @@ struct bio; struct bus_dma_segment; struct uio; struct mbuf; +struct vm_page; union ccb; /* @@ -49,11 +50,15 @@ struct memdesc { struct bio *md_bio; struct uio *md_uio; struct mbuf *md_mbuf; + struct vm_page **md_ma; } u; union { /* type specific data. */ - size_t md_len; /* VADDR, PADDR */ + size_t md_len; /* VADDR, PADDR, VMPAGES */ int md_nseg; /* VLIST, PLIST */ }; + union { + uint32_t md_offset; /* VMPAGES */ + }; uint32_t md_type; /* Type of memory. */ }; @@ -64,6 +69,7 @@ struct memdesc { #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. */ static inline struct memdesc memdesc_vaddr(void *vaddr, size_t len) @@ -146,6 +152,19 @@ memdesc_mbuf(struct mbuf *mbuf) return (mem); } +static inline struct memdesc +memdesc_vmpages(struct vm_page **ma, size_t len, u_int ma_offset) +{ + struct memdesc mem; + + mem.u.md_ma = ma; + mem.md_len = len; + mem.md_type = MEMDESC_VMPAGES; + mem.md_offset = ma_offset; + + return (mem); +} + struct memdesc memdesc_ccb(union ccb *ccb); #endif /* _SYS_MEMDESC_H_ */