/**
 * mrsas_map_request:           Map and load data   
 * input:                       Adapter instance soft state
 *                              Pointer to command packet
 *
 * For data from OS, map and load the data buffer into bus space.  The
 * SG list is built in the callback.  If the  bus dmamap load is not
 * successful, cmd->error_code will contain the  error code and a 1 is 
 * returned.
 */
int mrsas_map_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
{
    u_int32_t retcode = 0;
    struct cam_sim *sim;
    int flag = BUS_DMA_NOWAIT;

    sim = xpt_path_sim(cmd->ccb_ptr->ccb_h.path);

    if (cmd->data != NULL) {
        lockmgr(&sc->io_lock, LK_EXCLUSIVE);
        /* Map data buffer into bus space */
        retcode = bus_dmamap_load(sc->data_tag, cmd->data_dmamap, cmd->data,
                              cmd->length, mrsas_data_load_cb, cmd, flag);
        lockmgr(&sc->io_lock, LK_RELEASE);
	if (retcode)
	    device_printf(sc->mrsas_dev, "bus_dmamap_load(): retcode = %d\n", retcode);
        if (retcode == EINPROGRESS) {
            device_printf(sc->mrsas_dev, "request load in progress\n");
            mrsas_freeze_simq(cmd, sim);
        } 
    }
    if (cmd->error_code)
        return(1);
    return(retcode);
}
Beispiel #2
0
/*
 * mrsas_map_request:	Map and load data
 * input:				Adapter instance soft state
 * 						Pointer to command packet
 *
 * For data from OS, map and load the data buffer into bus space.  The SG list
 * is built in the callback.  If the  bus dmamap load is not successful,
 * cmd->error_code will contain the  error code and a 1 is returned.
 */
int 
mrsas_map_request(struct mrsas_softc *sc,
    struct mrsas_mpt_cmd *cmd, union ccb *ccb)
{
	u_int32_t retcode = 0;
	struct cam_sim *sim;

	sim = xpt_path_sim(cmd->ccb_ptr->ccb_h.path);

	if (cmd->data != NULL) {
		/* Map data buffer into bus space */
		mtx_lock(&sc->io_lock);
#if (__FreeBSD_version >= 902001)
		retcode = bus_dmamap_load_ccb(sc->data_tag, cmd->data_dmamap, ccb,
		    mrsas_data_load_cb, cmd, 0);
#else
		retcode = bus_dmamap_load(sc->data_tag, cmd->data_dmamap, cmd->data,
		    cmd->length, mrsas_data_load_cb, cmd, BUS_DMA_NOWAIT);
#endif
		mtx_unlock(&sc->io_lock);
		if (retcode)
			device_printf(sc->mrsas_dev, "bus_dmamap_load(): retcode = %d\n", retcode);
		if (retcode == EINPROGRESS) {
			device_printf(sc->mrsas_dev, "request load in progress\n");
			mrsas_freeze_simq(cmd, sim);
		}
	}
	if (cmd->error_code)
		return (1);
	return (retcode);
}