Index: lib/libcam/cam_cdbparse.3 =================================================================== --- lib/libcam/cam_cdbparse.3 +++ lib/libcam/cam_cdbparse.3 @@ -212,8 +212,6 @@ /* CAM CCB flags */ typedef enum { CAM_CDB_POINTER = 0x00000001,/* The CDB field is a pointer */ - CAM_QUEUE_ENABLE = 0x00000002,/* SIM queue actions are enabled */ - CAM_CDB_LINKED = 0x00000004,/* CCB contains a linked CDB */ CAM_SCATTER_VALID = 0x00000010,/* Scatter/gather list is valid */ CAM_DIS_AUTOSENSE = 0x00000020,/* Disable autosense feature */ CAM_DIR_RESV = 0x00000000,/* Data direction (00:reserved) */ @@ -221,8 +219,6 @@ CAM_DIR_OUT = 0x00000080,/* Data direction (10:DATA OUT) */ CAM_DIR_NONE = 0x000000C0,/* Data direction (11:no data) */ CAM_DIR_MASK = 0x000000C0,/* Data direction Mask */ - CAM_SOFT_RST_OP = 0x00000100,/* Use Soft reset alternative */ - CAM_ENG_SYNC = 0x00000200,/* Flush resid bytes on complete */ CAM_DEV_QFRZDIS = 0x00000400,/* Disable DEV Q freezing */ CAM_DEV_QFREEZE = 0x00000800,/* Freeze DEV Q on execution */ CAM_HIGH_POWER = 0x00001000,/* Command takes a lot of power */ @@ -232,24 +228,11 @@ CAM_PASS_ERR_RECOVER = 0x00010000,/* Pass driver does err. recovery*/ CAM_DIS_DISCONNECT = 0x00020000,/* Disable disconnect */ CAM_SG_LIST_PHYS = 0x00040000,/* SG list has physical addrs. */ - CAM_MSG_BUF_PHYS = 0x00080000,/* Message buffer ptr is physical*/ - CAM_SNS_BUF_PHYS = 0x00100000,/* Autosense data ptr is physical*/ CAM_DATA_PHYS = 0x00200000,/* SG/Buffer data ptrs are phys. */ CAM_CDB_PHYS = 0x00400000,/* CDB pointer is physical */ - CAM_ENG_SGLIST = 0x00800000,/* SG list is for the HBA engine */ - -/* Phase cognizant mode flags */ - CAM_DIS_AUTOSRP = 0x01000000,/* Disable autosave/restore ptrs */ - CAM_DIS_AUTODISC = 0x02000000,/* Disable auto disconnect */ - CAM_TGT_CCB_AVAIL = 0x04000000,/* Target CCB available */ - CAM_TGT_PHASE_MODE = 0x08000000,/* The SIM runs in phase mode */ - CAM_MSGB_VALID = 0x20000000,/* Message buffer valid */ - CAM_STATUS_VALID = 0x40000000,/* Status buffer valid */ - CAM_DATAB_VALID = 0x80000000,/* Data buffer valid */ /* Host target Mode flags */ - CAM_TERM_IO = 0x20000000,/* Terminate I/O Message sup. */ - CAM_DISCONNECT = 0x40000000,/* Disconnects are mandatory */ + CAM_SEND_SENSE = 0x08000000,/* Send sense data with status */ CAM_SEND_STATUS = 0x80000000,/* Send status after data phase */ } ccb_flags; .Ed Index: sys/cam/cam_ccb.h =================================================================== --- sys/cam/cam_ccb.h +++ sys/cam/cam_ccb.h @@ -61,8 +61,8 @@ /* CAM CCB flags */ typedef enum { CAM_CDB_POINTER = 0x00000001,/* The CDB field is a pointer */ - CAM_QUEUE_ENABLE = 0x00000002,/* SIM queue actions are enabled */ - CAM_CDB_LINKED = 0x00000004,/* CCB contains a linked CDB */ + CAM_unused1 = 0x00000002, + CAM_unused2 = 0x00000004, CAM_NEGOTIATE = 0x00000008,/* * Perform transport negotiation * with this command. @@ -80,8 +80,8 @@ CAM_DATA_SG_PADDR = 0x00040010,/* Data type (011:sglist phys) */ CAM_DATA_BIO = 0x00200000,/* Data type (100:bio) */ CAM_DATA_MASK = 0x00240010,/* Data type mask */ - CAM_SOFT_RST_OP = 0x00000100,/* Use Soft reset alternative */ - CAM_ENG_SYNC = 0x00000200,/* Flush resid bytes on complete */ + CAM_unused3 = 0x00000100, + CAM_unused4 = 0x00000200, CAM_DEV_QFRZDIS = 0x00000400,/* Disable DEV Q freezing */ CAM_DEV_QFREEZE = 0x00000800,/* Freeze DEV Q on execution */ CAM_HIGH_POWER = 0x00001000,/* Command takes a lot of power */ @@ -90,24 +90,24 @@ CAM_TAG_ACTION_VALID = 0x00008000,/* Use the tag action in this ccb*/ CAM_PASS_ERR_RECOVER = 0x00010000,/* Pass driver does err. recovery*/ CAM_DIS_DISCONNECT = 0x00020000,/* Disable disconnect */ - CAM_MSG_BUF_PHYS = 0x00080000,/* Message buffer ptr is physical*/ - CAM_SNS_BUF_PHYS = 0x00100000,/* Autosense data ptr is physical*/ + CAM_unused5 = 0x00080000, + CAM_unused6 = 0x00100000, CAM_CDB_PHYS = 0x00400000,/* CDB poiner is physical */ - CAM_ENG_SGLIST = 0x00800000,/* SG list is for the HBA engine */ + CAM_unused7 = 0x00800000, /* Phase cognizant mode flags */ - CAM_DIS_AUTOSRP = 0x01000000,/* Disable autosave/restore ptrs */ - CAM_DIS_AUTODISC = 0x02000000,/* Disable auto disconnect */ - CAM_TGT_CCB_AVAIL = 0x04000000,/* Target CCB available */ - CAM_TGT_PHASE_MODE = 0x08000000,/* The SIM runs in phase mode */ - CAM_MSGB_VALID = 0x10000000,/* Message buffer valid */ - CAM_STATUS_VALID = 0x20000000,/* Status buffer valid */ - CAM_DATAB_VALID = 0x40000000,/* Data buffer valid */ + CAM_unused8 = 0x01000000, + CAM_unused9 = 0x02000000, + CAM_unused10 = 0x04000000, + CAM_unused11 = 0x08000000, + CAM_unused12 = 0x10000000, + CAM_unused13 = 0x20000000, + CAM_unused14 = 0x40000000, /* Host target Mode flags */ CAM_SEND_SENSE = 0x08000000,/* Send sense data with status */ - CAM_TERM_IO = 0x10000000,/* Terminate I/O Message sup. */ - CAM_DISCONNECT = 0x20000000,/* Disconnects are mandatory */ + CAM_unused15 = 0x10000000, + CAM_unused16 = 0x20000000, CAM_SEND_STATUS = 0x40000000,/* Send status after data phase */ CAM_UNLOCKED = 0x80000000 /* Call callback without lock. */ Index: sys/cam/cam_queue.h =================================================================== --- sys/cam/cam_queue.h +++ sys/cam/cam_queue.h @@ -101,11 +101,6 @@ void cam_ccbq_fini(struct cam_ccbq *ccbq); -/* - * Allocate and initialize a cam_queue structure. - */ -struct camq *camq_alloc(int size); - /* * Resize a cam queue */ @@ -116,13 +111,6 @@ */ int camq_init(struct camq *camq, int size); -/* - * Free a cam_queue structure. This should only be called if a controller - * driver failes somehow during its attach routine or is unloaded and has - * obtained a cam_queue structure. - */ -void camq_free(struct camq *queue); - /* * Finialize any internal storage or state of a cam_queue. */ Index: sys/cam/cam_queue.c =================================================================== --- sys/cam/cam_queue.c +++ sys/cam/cam_queue.c @@ -54,21 +54,6 @@ static void heap_down(cam_pinfo **queue_array, int index, int last_index); -struct camq * -camq_alloc(int size) -{ - struct camq *camq; - - camq = (struct camq *)malloc(sizeof(*camq), M_CAMQ, M_NOWAIT); - if (camq != NULL) { - if (camq_init(camq, size) != 0) { - free(camq, M_CAMQ); - camq = NULL; - } - } - return (camq); -} - int camq_init(struct camq *camq, int size) { @@ -96,15 +81,6 @@ * obtained a camq structure. The XPT should ensure that the queue * is empty before calling this routine. */ -void -camq_free(struct camq *queue) -{ - if (queue != NULL) { - camq_fini(queue); - free(queue, M_CAMQ); - } -} - void camq_fini(struct camq *queue) { Index: sys/cam/cam_xpt.h =================================================================== --- sys/cam/cam_xpt.h +++ sys/cam/cam_xpt.h @@ -140,8 +140,6 @@ lun_id_t lun_id); cam_status xpt_clone_path(struct cam_path **new_path, struct cam_path *path); -void xpt_copy_path(struct cam_path *new_path, - struct cam_path *path); void xpt_release_path(struct cam_path *path); Index: sys/cam/cam_xpt.c =================================================================== --- sys/cam/cam_xpt.c +++ sys/cam/cam_xpt.c @@ -803,7 +803,7 @@ xpt_scanner_thread(void *dummy) { union ccb *ccb; - struct cam_path path; + struct mtx *mtx; xpt_lock_buses(); for (;;) { @@ -815,15 +815,19 @@ xpt_unlock_buses(); /* - * Since lock can be dropped inside and path freed - * by completion callback even before return here, - * take our own path copy for reference. + * We need to lock the device's mutex which we use as + * the path mutex. We can't do it directly because the + * cam_path in the ccb may wind up going away because + * the path lock may be dropped and the path retired in + * the completion callback. We do this directly to keep + * the reference counts in cam_path sane. */ - xpt_copy_path(&path, ccb->ccb_h.path); - xpt_path_lock(&path); + mtx = xpt_path_mtx(ccb->ccb_h.path); + xpt_acquire_device(ccb->ccb_h.path->device); + mtx_lock(mtx); xpt_action(ccb); - xpt_path_unlock(&path); - xpt_release_path(&path); + mtx_unlock(mtx); + xpt_release_device(ccb->ccb_h.path->device); xpt_lock_buses(); } @@ -3686,15 +3690,6 @@ new_path = (struct cam_path *)malloc(sizeof(*path), M_CAMPATH, M_NOWAIT); if (new_path == NULL) return(CAM_RESRC_UNAVAIL); - xpt_copy_path(new_path, path); - *new_path_ptr = new_path; - return (CAM_REQ_CMP); -} - -void -xpt_copy_path(struct cam_path *new_path, struct cam_path *path) -{ - *new_path = *path; if (path->bus != NULL) xpt_acquire_bus(path->bus); @@ -3702,6 +3697,8 @@ xpt_acquire_target(path->target); if (path->device != NULL) xpt_acquire_device(path->device); + *new_path_ptr = new_path; + return (CAM_REQ_CMP); } void Index: sys/cam/ctl/ctl_frontend_cam_sim.c =================================================================== --- sys/cam/ctl/ctl_frontend_cam_sim.c +++ sys/cam/ctl/ctl_frontend_cam_sim.c @@ -88,8 +88,7 @@ * handle physical addresses yet. That would require mapping things in * order to do the copy. */ -#define CFCS_BAD_CCB_FLAGS (CAM_DATA_ISPHYS | CAM_MSG_BUF_PHYS | \ - CAM_SNS_BUF_PHYS | CAM_CDB_PHYS | CAM_SENSE_PTR | \ +#define CFCS_BAD_CCB_FLAGS (CAM_DATA_ISPHYS | CAM_CDB_PHYS | CAM_SENSE_PTR | \ CAM_SENSE_PHYS) static int cfcs_init(void);