Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107420490
D40880.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D40880.diff
View Options
diff --git a/sys/cam/cam.c b/sys/cam/cam.c
--- a/sys/cam/cam.c
+++ b/sys/cam/cam.c
@@ -35,6 +35,7 @@
#ifdef _KERNEL
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/memdesc.h>
#include <sys/sysctl.h>
#else /* _KERNEL */
#include <stdlib.h>
@@ -571,3 +572,74 @@
ccg->cylinders = ccg->volume_size / secs_per_cylinder;
ccg->ccb_h.status = CAM_REQ_CMP;
}
+
+#ifdef _KERNEL
+struct memdesc
+memdesc_ccb(union ccb *ccb)
+{
+ struct ccb_hdr *ccb_h;
+ void *data_ptr;
+ uint32_t dxfer_len;
+ uint16_t sglist_cnt;
+
+ ccb_h = &ccb->ccb_h;
+ switch (ccb_h->func_code) {
+ case XPT_SCSI_IO: {
+ struct ccb_scsiio *csio;
+
+ csio = &ccb->csio;
+ data_ptr = csio->data_ptr;
+ dxfer_len = csio->dxfer_len;
+ sglist_cnt = csio->sglist_cnt;
+ break;
+ }
+ case XPT_CONT_TARGET_IO: {
+ struct ccb_scsiio *ctio;
+
+ ctio = &ccb->ctio;
+ data_ptr = ctio->data_ptr;
+ dxfer_len = ctio->dxfer_len;
+ sglist_cnt = ctio->sglist_cnt;
+ break;
+ }
+ case XPT_ATA_IO: {
+ struct ccb_ataio *ataio;
+
+ ataio = &ccb->ataio;
+ data_ptr = ataio->data_ptr;
+ dxfer_len = ataio->dxfer_len;
+ sglist_cnt = 0;
+ break;
+ }
+ case XPT_NVME_IO:
+ case XPT_NVME_ADMIN: {
+ struct ccb_nvmeio *nvmeio;
+
+ nvmeio = &ccb->nvmeio;
+ data_ptr = nvmeio->data_ptr;
+ dxfer_len = nvmeio->dxfer_len;
+ sglist_cnt = nvmeio->sglist_cnt;
+ break;
+ }
+ default:
+ panic("%s: Unsupported func code %d", __func__,
+ ccb_h->func_code);
+ }
+
+ switch ((ccb_h->flags & CAM_DATA_MASK)) {
+ case CAM_DATA_VADDR:
+ return (memdesc_vaddr(data_ptr, dxfer_len));
+ case CAM_DATA_PADDR:
+ return (memdesc_paddr((vm_paddr_t)(uintptr_t)data_ptr,
+ dxfer_len));
+ case CAM_DATA_SG:
+ return (memdesc_vlist(data_ptr, sglist_cnt));
+ case CAM_DATA_SG_PADDR:
+ return (memdesc_plist(data_ptr, sglist_cnt));
+ case CAM_DATA_BIO:
+ return (memdesc_bio(data_ptr));
+ default:
+ panic("%s: flags 0x%X unimplemented", __func__, ccb_h->flags);
+ }
+}
+#endif
diff --git a/sys/kern/subr_bus_dma.c b/sys/kern/subr_bus_dma.c
--- a/sys/kern/subr_bus_dma.c
+++ b/sys/kern/subr_bus_dma.c
@@ -304,94 +304,6 @@
return (error);
}
-/*
- * Load a cam control block.
- */
-static int
-_bus_dmamap_load_ccb(bus_dma_tag_t dmat, bus_dmamap_t map, union ccb *ccb,
- int *nsegs, int flags)
-{
- struct ccb_hdr *ccb_h;
- void *data_ptr;
- int error;
- uint32_t dxfer_len;
- uint16_t sglist_cnt;
-
- error = 0;
- ccb_h = &ccb->ccb_h;
- switch (ccb_h->func_code) {
- case XPT_SCSI_IO: {
- struct ccb_scsiio *csio;
-
- csio = &ccb->csio;
- data_ptr = csio->data_ptr;
- dxfer_len = csio->dxfer_len;
- sglist_cnt = csio->sglist_cnt;
- break;
- }
- case XPT_CONT_TARGET_IO: {
- struct ccb_scsiio *ctio;
-
- ctio = &ccb->ctio;
- data_ptr = ctio->data_ptr;
- dxfer_len = ctio->dxfer_len;
- sglist_cnt = ctio->sglist_cnt;
- break;
- }
- case XPT_ATA_IO: {
- struct ccb_ataio *ataio;
-
- ataio = &ccb->ataio;
- data_ptr = ataio->data_ptr;
- dxfer_len = ataio->dxfer_len;
- sglist_cnt = 0;
- break;
- }
- case XPT_NVME_IO:
- case XPT_NVME_ADMIN: {
- struct ccb_nvmeio *nvmeio;
-
- nvmeio = &ccb->nvmeio;
- data_ptr = nvmeio->data_ptr;
- dxfer_len = nvmeio->dxfer_len;
- sglist_cnt = nvmeio->sglist_cnt;
- break;
- }
- default:
- panic("_bus_dmamap_load_ccb: Unsupported func code %d",
- ccb_h->func_code);
- }
-
- switch ((ccb_h->flags & CAM_DATA_MASK)) {
- case CAM_DATA_VADDR:
- error = _bus_dmamap_load_buffer(dmat, map, data_ptr, dxfer_len,
- kernel_pmap, flags, NULL, nsegs);
- break;
- case CAM_DATA_PADDR:
- error = _bus_dmamap_load_phys(dmat, map,
- (vm_paddr_t)(uintptr_t)data_ptr, dxfer_len, flags, NULL,
- nsegs);
- break;
- case CAM_DATA_SG:
- error = _bus_dmamap_load_vlist(dmat, map,
- (bus_dma_segment_t *)data_ptr, sglist_cnt, kernel_pmap,
- nsegs, flags, 0, dxfer_len);
- break;
- case CAM_DATA_SG_PADDR:
- error = _bus_dmamap_load_plist(dmat, map,
- (bus_dma_segment_t *)data_ptr, sglist_cnt, nsegs, flags);
- break;
- case CAM_DATA_BIO:
- error = _bus_dmamap_load_bio(dmat, map, (struct bio *)data_ptr,
- nsegs, flags);
- break;
- default:
- panic("_bus_dmamap_load_ccb: flags 0x%X unimplemented",
- ccb_h->flags);
- }
- return (error);
-}
-
/*
* Load a uio.
*/
@@ -566,49 +478,18 @@
bus_dmamap_callback_t *callback, void *callback_arg,
int flags)
{
- bus_dma_segment_t *segs;
struct ccb_hdr *ccb_h;
struct memdesc mem;
- int error;
- int nsegs;
-
-#ifdef KMSAN
- mem = memdesc_ccb(ccb);
- _bus_dmamap_load_kmsan(dmat, map, &mem);
-#endif
ccb_h = &ccb->ccb_h;
if ((ccb_h->flags & CAM_DIR_MASK) == CAM_DIR_NONE) {
callback(callback_arg, NULL, 0, 0);
return (0);
}
- if ((flags & BUS_DMA_NOWAIT) == 0) {
- mem = memdesc_ccb(ccb);
- _bus_dmamap_waitok(dmat, map, &mem, callback, callback_arg);
- }
- nsegs = -1;
- error = _bus_dmamap_load_ccb(dmat, map, ccb, &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);
+ mem = memdesc_ccb(ccb);
+ return (bus_dmamap_load_mem(dmat, map, &mem, callback, callback_arg,
+ flags));
}
int
@@ -702,10 +583,6 @@
error = _bus_dmamap_load_mbuf_sg(dmat, map, mem->u.md_mbuf,
NULL, &nsegs, flags);
break;
- case MEMDESC_CCB:
- error = _bus_dmamap_load_ccb(dmat, map, mem->u.md_ccb, &nsegs,
- flags);
- break;
}
nsegs++;
diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c
--- a/sys/kern/subr_msan.c
+++ b/sys/kern/subr_msan.c
@@ -57,9 +57,6 @@
#include <sys/sysctl.h>
#include <sys/uio.h>
-#include <cam/cam.h>
-#include <cam/cam_ccb.h>
-
#include <vm/vm.h>
#include <vm/pmap.h>
@@ -555,42 +552,6 @@
kmsan_mark(bp->bio_data, bp->bio_length, c);
}
-static void
-kmsan_mark_ccb(const union ccb *ccb, uint8_t c)
-{
- if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_IN)
- return;
- if ((ccb->ccb_h.flags & CAM_DATA_MASK) != CAM_DATA_VADDR)
- return;
-
- switch (ccb->ccb_h.func_code) {
- case XPT_SCSI_IO: {
- const struct ccb_scsiio *scsiio;
-
- scsiio = &ccb->ctio;
- kmsan_mark(scsiio->data_ptr, scsiio->dxfer_len, c);
- break;
- }
- case XPT_ATA_IO: {
- const struct ccb_ataio *ataio;
-
- ataio = &ccb->ataio;
- kmsan_mark(ataio->data_ptr, ataio->dxfer_len, c);
- break;
- }
- case XPT_NVME_IO: {
- const struct ccb_nvmeio *nvmeio;
-
- nvmeio = &ccb->nvmeio;
- kmsan_mark(nvmeio->data_ptr, nvmeio->dxfer_len, c);
- break;
- }
- default:
- kmsan_panic("%s: unhandled CCB type %d", __func__,
- ccb->ccb_h.func_code);
- }
-}
-
void
kmsan_mark_mbuf(const struct mbuf *m, uint8_t c)
{
@@ -613,39 +574,6 @@
kmsan_shadow_check((uintptr_t)bp->bio_data, bp->bio_length, descr);
}
-void
-kmsan_check_ccb(const union ccb *ccb, const char *descr)
-{
- if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_OUT)
- return;
- switch (ccb->ccb_h.func_code) {
- case XPT_SCSI_IO: {
- const struct ccb_scsiio *scsiio;
-
- scsiio = &ccb->ctio;
- kmsan_check(scsiio->data_ptr, scsiio->dxfer_len, descr);
- break;
- }
- case XPT_ATA_IO: {
- const struct ccb_ataio *ataio;
-
- ataio = &ccb->ataio;
- kmsan_check(ataio->data_ptr, ataio->dxfer_len, descr);
- break;
- }
- case XPT_NVME_IO: {
- const struct ccb_nvmeio *nvmeio;
-
- nvmeio = &ccb->nvmeio;
- kmsan_check(nvmeio->data_ptr, nvmeio->dxfer_len, descr);
- break;
- }
- default:
- kmsan_panic("%s: unhandled CCB type %d", __func__,
- ccb->ccb_h.func_code);
- }
-}
-
void
kmsan_check_mbuf(const struct mbuf *m, const char *descr)
{
@@ -1586,9 +1514,6 @@
case MEMDESC_MBUF:
kmsan_check_mbuf(desc->u.md_mbuf, "dmasync");
break;
- case MEMDESC_CCB:
- kmsan_check_ccb(desc->u.md_ccb, "dmasync");
- break;
case 0:
break;
default:
@@ -1608,9 +1533,6 @@
case MEMDESC_MBUF:
kmsan_mark_mbuf(desc->u.md_mbuf, KMSAN_STATE_INITED);
break;
- case MEMDESC_CCB:
- kmsan_mark_ccb(desc->u.md_ccb, KMSAN_STATE_INITED);
- break;
case 0:
break;
default:
diff --git a/sys/sys/memdesc.h b/sys/sys/memdesc.h
--- a/sys/sys/memdesc.h
+++ b/sys/sys/memdesc.h
@@ -49,7 +49,6 @@
struct bio *md_bio;
struct uio *md_uio;
struct mbuf *md_mbuf;
- union ccb *md_ccb;
} u;
size_t md_opaque; /* type specific data. */
uint32_t md_type; /* Type of memory. */
@@ -62,7 +61,6 @@
#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_CCB 8 /* Cam control block. (scsi/ata io). */
static inline struct memdesc
memdesc_vaddr(void *vaddr, size_t len)
@@ -145,14 +143,6 @@
return (mem);
}
-static inline struct memdesc
-memdesc_ccb(union ccb *ccb)
-{
- struct memdesc mem;
+struct memdesc memdesc_ccb(union ccb *ccb);
- mem.u.md_ccb = ccb;
- mem.md_type = MEMDESC_CCB;
-
- return (mem);
-}
#endif /* _SYS_MEMDESC_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 14, 10:15 PM (8 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15801625
Default Alt Text
D40880.diff (9 KB)
Attached To
Mode
D40880: memdesc: Retire MEMDESC_CCB.
Attached
Detach File
Event Timeline
Log In to Comment