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
This commit is contained in:
parent
bab38b44dd
commit
c9b1980394
@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/param.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bio.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/callout.h>
|
||||
#include <sys/ktr.h>
|
||||
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/limits.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/memdesc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -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,
|
||||
|
@ -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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user