Lines Matching refs:sim
105 struct cam_sim *sim; in cam_sim_alloc() local
107 sim = malloc(sizeof(struct cam_sim), M_CAMSIM, M_ZERO | M_NOWAIT); in cam_sim_alloc()
108 if (sim == NULL) in cam_sim_alloc()
111 sim->sim_action = sim_action; in cam_sim_alloc()
112 sim->sim_poll = sim_poll; in cam_sim_alloc()
113 sim->sim_name = sim_name; in cam_sim_alloc()
114 sim->softc = softc; in cam_sim_alloc()
115 sim->path_id = CAM_PATH_ANY; in cam_sim_alloc()
116 sim->unit_number = unit; in cam_sim_alloc()
117 sim->bus_id = 0; /* set in xpt_bus_register */ in cam_sim_alloc()
118 sim->max_tagged_dev_openings = max_tagged_dev_transactions; in cam_sim_alloc()
119 sim->max_dev_openings = max_dev_transactions; in cam_sim_alloc()
120 sim->flags = 0; in cam_sim_alloc()
121 sim->refcount = 1; in cam_sim_alloc()
122 sim->devq = queue; in cam_sim_alloc()
123 sim->mtx = mtx; in cam_sim_alloc()
124 return (sim); in cam_sim_alloc()
141 cam_sim_free(struct cam_sim *sim, int free_devq) in cam_sim_free() argument
146 if (sim->mtx == NULL) { in cam_sim_free()
150 mtx = sim->mtx; in cam_sim_free()
153 KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); in cam_sim_free()
154 sim->refcount--; in cam_sim_free()
155 if (sim->refcount > 0) { in cam_sim_free()
156 error = msleep(sim, mtx, PRIBIO, "simfree", 0); in cam_sim_free()
159 KASSERT(sim->refcount == 0, ("sim->refcount == 0")); in cam_sim_free()
164 cam_simq_free(sim->devq); in cam_sim_free()
165 free(sim, M_CAMSIM); in cam_sim_free()
169 cam_sim_release(struct cam_sim *sim) in cam_sim_release() argument
173 if (sim->mtx == NULL) in cam_sim_release()
175 else if (!mtx_owned(sim->mtx)) in cam_sim_release()
176 mtx = sim->mtx; in cam_sim_release()
181 KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); in cam_sim_release()
182 sim->refcount--; in cam_sim_release()
183 if (sim->refcount == 0) in cam_sim_release()
184 wakeup(sim); in cam_sim_release()
190 cam_sim_hold(struct cam_sim *sim) in cam_sim_hold() argument
194 if (sim->mtx == NULL) in cam_sim_hold()
196 else if (!mtx_owned(sim->mtx)) in cam_sim_hold()
197 mtx = sim->mtx; in cam_sim_hold()
202 KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); in cam_sim_hold()
203 sim->refcount++; in cam_sim_hold()
209 cam_sim_set_path(struct cam_sim *sim, uint32_t path_id) in cam_sim_set_path() argument
211 sim->path_id = path_id; in cam_sim_set_path()