Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/mvs/mvs.c
Show First 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | bus_dmamem_free(ch->dma.workrp_tag, | ||||
ch->dma.workrp, ch->dma.workrp_map); | ch->dma.workrp, ch->dma.workrp_map); | ||||
goto error; | goto error; | ||||
} | } | ||||
ch->dma.workrp_bus = dcba.maddr; | ch->dma.workrp_bus = dcba.maddr; | ||||
/* Data area. */ | /* Data area. */ | ||||
if (bus_dma_tag_create(bus_get_dma_tag(dev), 2, MVS_EPRD_MAX, | if (bus_dma_tag_create(bus_get_dma_tag(dev), 2, MVS_EPRD_MAX, | ||||
BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, | BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, | ||||
NULL, NULL, | NULL, NULL, | ||||
MVS_SG_ENTRIES * PAGE_SIZE * MVS_MAX_SLOTS, | MVS_SG_ENTRIES * PAGE_SIZE, MVS_SG_ENTRIES, MVS_EPRD_MAX, | ||||
MVS_SG_ENTRIES, MVS_EPRD_MAX, | |||||
0, busdma_lock_mutex, &ch->mtx, &ch->dma.data_tag)) { | 0, busdma_lock_mutex, &ch->mtx, &ch->dma.data_tag)) { | ||||
goto error; | goto error; | ||||
} | } | ||||
return; | return; | ||||
error: | error: | ||||
device_printf(dev, "WARNING - DMA initialization failed\n"); | device_printf(dev, "WARNING - DMA initialization failed\n"); | ||||
mvs_dmafini(dev); | mvs_dmafini(dev); | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | mvs_slotsalloc(device_t dev) | ||||
/* Alloc and setup command/dma slots */ | /* Alloc and setup command/dma slots */ | ||||
bzero(ch->slot, sizeof(ch->slot)); | bzero(ch->slot, sizeof(ch->slot)); | ||||
for (i = 0; i < MVS_MAX_SLOTS; i++) { | for (i = 0; i < MVS_MAX_SLOTS; i++) { | ||||
struct mvs_slot *slot = &ch->slot[i]; | struct mvs_slot *slot = &ch->slot[i]; | ||||
slot->dev = dev; | slot->dev = dev; | ||||
slot->slot = i; | slot->slot = i; | ||||
slot->state = MVS_SLOT_EMPTY; | slot->state = MVS_SLOT_EMPTY; | ||||
slot->eprd_offset = MVS_EPRD_OFFSET + MVS_EPRD_SIZE * i; | |||||
slot->ccb = NULL; | slot->ccb = NULL; | ||||
callout_init_mtx(&slot->timeout, &ch->mtx, 0); | callout_init_mtx(&slot->timeout, &ch->mtx, 0); | ||||
if (bus_dmamap_create(ch->dma.data_tag, 0, &slot->dma.data_map)) | if (bus_dmamap_create(ch->dma.data_tag, 0, &slot->dma.data_map)) | ||||
device_printf(ch->dev, "FAILURE - create data_map\n"); | device_printf(ch->dev, "FAILURE - create data_map\n"); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 832 Lines • ▼ Show 20 Lines | mvs_dmasetprd(void *arg, bus_dma_segment_t *segs, int nsegs, int error) | ||||
KASSERT(nsegs <= MVS_SG_ENTRIES, ("too many DMA segment entries\n")); | KASSERT(nsegs <= MVS_SG_ENTRIES, ("too many DMA segment entries\n")); | ||||
/* If there is only one segment - no need to use S/G table on Gen-IIe. */ | /* If there is only one segment - no need to use S/G table on Gen-IIe. */ | ||||
if (nsegs == 1 && ch->basic_dma == 0 && (ch->quirks & MVS_Q_GENIIE)) { | if (nsegs == 1 && ch->basic_dma == 0 && (ch->quirks & MVS_Q_GENIIE)) { | ||||
slot->dma.addr = segs[0].ds_addr; | slot->dma.addr = segs[0].ds_addr; | ||||
slot->dma.len = segs[0].ds_len; | slot->dma.len = segs[0].ds_len; | ||||
} else { | } else { | ||||
slot->dma.addr = 0; | slot->dma.addr = 0; | ||||
/* Get a piece of the workspace for this EPRD */ | /* Get a piece of the workspace for this EPRD */ | ||||
eprd = (struct mvs_eprd *) | eprd = (struct mvs_eprd *)(ch->dma.workrq + slot->eprd_offset); | ||||
(ch->dma.workrq + MVS_EPRD_OFFSET + (MVS_EPRD_SIZE * slot->slot)); | |||||
/* Fill S/G table */ | /* Fill S/G table */ | ||||
for (i = 0; i < nsegs; i++) { | for (i = 0; i < nsegs; i++) { | ||||
eprd[i].prdbal = htole32(segs[i].ds_addr); | eprd[i].prdbal = htole32(segs[i].ds_addr); | ||||
eprd[i].bytecount = htole32(segs[i].ds_len & MVS_EPRD_MASK); | eprd[i].bytecount = htole32(segs[i].ds_len & MVS_EPRD_MASK); | ||||
eprd[i].prdbah = htole32((segs[i].ds_addr >> 16) >> 16); | eprd[i].prdbah = htole32((segs[i].ds_addr >> 16) >> 16); | ||||
} | } | ||||
eprd[i - 1].bytecount |= htole32(MVS_EPRD_EOF); | eprd[i - 1].bytecount |= htole32(MVS_EPRD_EOF); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | if (ccb->ccb_h.func_code == XPT_ATA_IO) { | ||||
/* Write ATAPI command. */ | /* Write ATAPI command. */ | ||||
ATA_OUTSW_STRM(ch->r_mem, ATA_DATA, | ATA_OUTSW_STRM(ch->r_mem, ATA_DATA, | ||||
(uint16_t *)((ccb->ccb_h.flags & CAM_CDB_POINTER) ? | (uint16_t *)((ccb->ccb_h.flags & CAM_CDB_POINTER) ? | ||||
ccb->csio.cdb_io.cdb_ptr : ccb->csio.cdb_io.cdb_bytes), | ccb->csio.cdb_io.cdb_ptr : ccb->csio.cdb_io.cdb_bytes), | ||||
ch->curr[port].atapi / 2); | ch->curr[port].atapi / 2); | ||||
DELAY(10); | DELAY(10); | ||||
if (ch->basic_dma) { | if (ch->basic_dma) { | ||||
/* Start basic DMA. */ | /* Start basic DMA. */ | ||||
eprd = ch->dma.workrq_bus + MVS_EPRD_OFFSET + | eprd = ch->dma.workrq_bus + slot->eprd_offset; | ||||
(MVS_EPRD_SIZE * slot->slot); | |||||
ATA_OUTL(ch->r_mem, DMA_DTLBA, eprd); | ATA_OUTL(ch->r_mem, DMA_DTLBA, eprd); | ||||
ATA_OUTL(ch->r_mem, DMA_DTHBA, (eprd >> 16) >> 16); | ATA_OUTL(ch->r_mem, DMA_DTHBA, (eprd >> 16) >> 16); | ||||
ATA_OUTL(ch->r_mem, DMA_C, DMA_C_START | | ATA_OUTL(ch->r_mem, DMA_C, DMA_C_START | | ||||
(((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) ? | (((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) ? | ||||
DMA_C_READ : 0)); | DMA_C_READ : 0)); | ||||
} | } | ||||
} | } | ||||
/* Start command execution timeout */ | /* Start command execution timeout */ | ||||
Show All 10 Lines | mvs_execute_transaction(struct mvs_slot *slot) | ||||
bus_addr_t eprd; | bus_addr_t eprd; | ||||
struct mvs_crqb *crqb; | struct mvs_crqb *crqb; | ||||
struct mvs_crqb_gen2e *crqb2e; | struct mvs_crqb_gen2e *crqb2e; | ||||
union ccb *ccb = slot->ccb; | union ccb *ccb = slot->ccb; | ||||
int port = ccb->ccb_h.target_id & 0x0f; | int port = ccb->ccb_h.target_id & 0x0f; | ||||
int i; | int i; | ||||
/* Get address of the prepared EPRD */ | /* Get address of the prepared EPRD */ | ||||
eprd = ch->dma.workrq_bus + MVS_EPRD_OFFSET + (MVS_EPRD_SIZE * slot->slot); | eprd = ch->dma.workrq_bus + slot->eprd_offset; | ||||
/* Prepare CRQB. Gen IIe uses different CRQB format. */ | /* Prepare CRQB. Gen IIe uses different CRQB format. */ | ||||
if (ch->quirks & MVS_Q_GENIIE) { | if (ch->quirks & MVS_Q_GENIIE) { | ||||
crqb2e = (struct mvs_crqb_gen2e *) | crqb2e = (struct mvs_crqb_gen2e *) | ||||
(ch->dma.workrq + MVS_CRQB_OFFSET + (MVS_CRQB_SIZE * ch->out_idx)); | (ch->dma.workrq + MVS_CRQB_OFFSET + (MVS_CRQB_SIZE * ch->out_idx)); | ||||
crqb2e->ctrlflg = htole32( | crqb2e->ctrlflg = htole32( | ||||
((ccb->ccb_h.flags & CAM_DIR_IN) ? MVS_CRQB2E_READ : 0) | | ((ccb->ccb_h.flags & CAM_DIR_IN) ? MVS_CRQB2E_READ : 0) | | ||||
(slot->tag << MVS_CRQB2E_DTAG_SHIFT) | | (slot->tag << MVS_CRQB2E_DTAG_SHIFT) | | ||||
(port << MVS_CRQB2E_PMP_SHIFT) | | (port << MVS_CRQB2E_PMP_SHIFT) | | ||||
▲ Show 20 Lines • Show All 973 Lines • ▼ Show 20 Lines | case XPT_PATH_INQ: /* Path routing inquiry */ | ||||
strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); | strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); | ||||
strlcpy(cpi->hba_vid, "Marvell", HBA_IDLEN); | strlcpy(cpi->hba_vid, "Marvell", HBA_IDLEN); | ||||
strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); | strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); | ||||
cpi->unit_number = cam_sim_unit(sim); | cpi->unit_number = cam_sim_unit(sim); | ||||
cpi->transport = XPORT_SATA; | cpi->transport = XPORT_SATA; | ||||
cpi->transport_version = XPORT_VERSION_UNSPECIFIED; | cpi->transport_version = XPORT_VERSION_UNSPECIFIED; | ||||
cpi->protocol = PROTO_ATA; | cpi->protocol = PROTO_ATA; | ||||
cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; | cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; | ||||
cpi->maxio = MAXPHYS; | cpi->maxio = maxphys; | ||||
if ((ch->quirks & MVS_Q_SOC) == 0) { | if ((ch->quirks & MVS_Q_SOC) == 0) { | ||||
cpi->hba_vendor = pci_get_vendor(parent); | cpi->hba_vendor = pci_get_vendor(parent); | ||||
cpi->hba_device = pci_get_device(parent); | cpi->hba_device = pci_get_device(parent); | ||||
cpi->hba_subvendor = pci_get_subvendor(parent); | cpi->hba_subvendor = pci_get_subvendor(parent); | ||||
cpi->hba_subdevice = pci_get_subdevice(parent); | cpi->hba_subdevice = pci_get_subdevice(parent); | ||||
} | } | ||||
cpi->ccb_h.status = CAM_REQ_CMP; | cpi->ccb_h.status = CAM_REQ_CMP; | ||||
break; | break; | ||||
Show All 23 Lines |