1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

hpt27xx: Remove FreeBSD 9.x support including Giant.

MFC after:	2 weeks
This commit is contained in:
Alexander Motin 2021-12-09 20:24:29 -05:00
parent 5ae7518b7b
commit 63e0f96ace
3 changed files with 18 additions and 152 deletions

View File

@ -250,14 +250,8 @@ void os_request_timer(void * osext, HPT_U32 interval)
PVBUS_EXT vbus_ext = osext;
HPT_ASSERT(vbus_ext->ext_type==EXT_TYPE_VBUS);
#if (__FreeBSD_version >= 1000510)
callout_reset_sbt(&vbus_ext->timer, SBT_1US * interval, 0,
os_timer_for_ldm, vbus_ext, 0);
#else
untimeout(os_timer_for_ldm, vbus_ext, vbus_ext->timer);
vbus_ext->timer = timeout(os_timer_for_ldm, vbus_ext, interval * hz / 1000000);
#endif
}
HPT_TIME os_query_time(void)

View File

@ -376,10 +376,8 @@ static void hpt_shutdown_vbus(PVBUS_EXT vbus_ext, int howto)
vbus_ext->hba_list = hba->next;
free(hba->ldm_adapter.him_handle, M_DEVBUF);
}
#if (__FreeBSD_version >= 1000510)
callout_drain(&vbus_ext->timer);
mtx_destroy(&vbus_ext->lock);
#endif
free(vbus_ext, M_DEVBUF);
KdPrint(("hpt_shutdown_vbus done"));
}
@ -443,11 +441,7 @@ static void os_cmddone(PCOMMAND pCmd)
union ccb *ccb = ext->ccb;
KdPrint(("<8>os_cmddone(%p, %d)", pCmd, pCmd->Result));
#if (__FreeBSD_version >= 1000510)
callout_stop(&ext->timeout);
#else
untimeout(hpt_timeout, pCmd, ccb->ccb_h.timeout_ch);
#endif
switch(pCmd->Result) {
case RETURN_SUCCESS:
ccb->ccb_h.status = CAM_REQ_CMP;
@ -490,39 +484,13 @@ static int os_buildsgl(PCOMMAND pCmd, PSG pSg, int logical)
{
POS_CMDEXT ext = (POS_CMDEXT)pCmd->priv;
union ccb *ccb = ext->ccb;
#if (__FreeBSD_version >= 1000510)
if(logical) {
os_set_sgptr(pSg, (HPT_U8 *)ccb->csio.data_ptr);
pSg->size = ccb->csio.dxfer_len;
pSg->eot = 1;
return TRUE;
}
#else
bus_dma_segment_t *sgList = (bus_dma_segment_t *)ccb->csio.data_ptr;
int idx;
if(logical) {
if (ccb->ccb_h.flags & CAM_DATA_PHYS)
panic("physical address unsupported");
if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS)
panic("physical address unsupported");
for (idx = 0; idx < ccb->csio.sglist_cnt; idx++) {
os_set_sgptr(&pSg[idx], (HPT_U8 *)(HPT_UPTR)sgList[idx].ds_addr);
pSg[idx].size = sgList[idx].ds_len;
pSg[idx].eot = (idx==ccb->csio.sglist_cnt-1)? 1 : 0;
}
}
else {
os_set_sgptr(pSg, (HPT_U8 *)ccb->csio.data_ptr);
pSg->size = ccb->csio.dxfer_len;
pSg->eot = 1;
}
return TRUE;
}
#endif
/* since we have provided physical sg, nobody will ask us to build physical sg */
HPT_ASSERT(0);
return FALSE;
@ -559,11 +527,7 @@ static void hpt_io_dmamap_callback(void *arg, bus_dma_segment_t *segs, int nsegs
BUS_DMASYNC_PREWRITE);
}
}
#if (__FreeBSD_version >= 1000510)
callout_reset(&ext->timeout, HPT_OSM_TIMEOUT, hpt_timeout, pCmd);
#else
ext->ccb->ccb_h.timeout_ch = timeout(hpt_timeout, pCmd, HPT_OSM_TIMEOUT);
#endif
ldm_queue_cmd(pCmd);
}
@ -574,6 +538,7 @@ static void hpt_scsi_io(PVBUS_EXT vbus_ext, union ccb *ccb)
PCOMMAND pCmd;
POS_CMDEXT ext;
HPT_U8 *cdb;
int error;
if (ccb->ccb_h.flags & CAM_CDB_POINTER)
cdb = ccb->csio.cdb_io.cdb_ptr;
@ -819,50 +784,19 @@ static void hpt_scsi_io(PVBUS_EXT vbus_ext, union ccb *ccb)
pCmd->buildsgl = os_buildsgl;
pCmd->psg = ext->psg;
#if (__FreeBSD_version < 1000510)
if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
int idx;
bus_dma_segment_t *sgList = (bus_dma_segment_t *)ccb->csio.data_ptr;
if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS)
pCmd->flags.physical_sg = 1;
for (idx = 0; idx < ccb->csio.sglist_cnt; idx++) {
pCmd->psg[idx].addr.bus = sgList[idx].ds_addr;
pCmd->psg[idx].size = sgList[idx].ds_len;
pCmd->psg[idx].eot = (idx==ccb->csio.sglist_cnt-1)? 1 : 0;
}
ccb->ccb_h.timeout_ch = timeout(hpt_timeout, pCmd, HPT_OSM_TIMEOUT);
ldm_queue_cmd(pCmd);
}
else
#endif
{
int error;
pCmd->flags.physical_sg = 1;
#if (__FreeBSD_version >= 1000510)
error = bus_dmamap_load_ccb(vbus_ext->io_dmat,
ext->dma_map, ccb,
hpt_io_dmamap_callback, pCmd,
BUS_DMA_WAITOK
);
#else
error = bus_dmamap_load(vbus_ext->io_dmat,
ext->dma_map,
ccb->csio.data_ptr, ccb->csio.dxfer_len,
hpt_io_dmamap_callback, pCmd,
BUS_DMA_WAITOK
);
#endif
KdPrint(("<8>bus_dmamap_load return %d", error));
if (error && error!=EINPROGRESS) {
os_printk("bus_dmamap_load error %d", error);
cmdext_put(ext);
ldm_free_cmds(pCmd);
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
xpt_done(ccb);
}
pCmd->flags.physical_sg = 1;
error = bus_dmamap_load_ccb(vbus_ext->io_dmat,
ext->dma_map, ccb,
hpt_io_dmamap_callback, pCmd,
BUS_DMA_WAITOK
);
KdPrint(("<8>bus_dmamap_load return %d", error));
if (error && error!=EINPROGRESS) {
os_printk("bus_dmamap_load error %d", error);
cmdext_put(ext);
ldm_free_cmds(pCmd);
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
xpt_done(ccb);
}
return;
}
@ -882,24 +816,9 @@ static void hpt_action(struct cam_sim *sim, union ccb *ccb)
KdPrint(("<8>hpt_action(fn=%d, id=%d)", ccb->ccb_h.func_code, ccb->ccb_h.target_id));
#if (__FreeBSD_version >= 1000510)
hpt_assert_vbus_locked(vbus_ext);
#endif
switch (ccb->ccb_h.func_code) {
#if (__FreeBSD_version < 1000510)
case XPT_SCSI_IO:
hpt_lock_vbus(vbus_ext);
hpt_scsi_io(vbus_ext, ccb);
hpt_unlock_vbus(vbus_ext);
return;
case XPT_RESET_BUS:
hpt_lock_vbus(vbus_ext);
ldm_reset_vbus((PVBUS)vbus_ext->vbus);
hpt_unlock_vbus(vbus_ext);
break;
#else
case XPT_SCSI_IO:
hpt_scsi_io(vbus_ext, ccb);
return;
@ -907,7 +826,7 @@ static void hpt_action(struct cam_sim *sim, union ccb *ccb)
case XPT_RESET_BUS:
ldm_reset_vbus((PVBUS)vbus_ext->vbus);
break;
#endif
case XPT_GET_TRAN_SETTINGS:
case XPT_SET_TRAN_SETTINGS:
ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
@ -966,14 +885,10 @@ static void hpt_pci_intr(void *arg)
static void hpt_poll(struct cam_sim *sim)
{
#if (__FreeBSD_version < 1000510)
hpt_pci_intr(cam_sim_softc(sim));
#else
PVBUS_EXT vbus_ext = (PVBUS_EXT)cam_sim_softc(sim);
hpt_assert_vbus_locked(vbus_ext);
ldm_intr((PVBUS)vbus_ext->vbus);
#endif
}
static void hpt_async(void * callback_arg, u_int32_t code, struct cam_path * path, void * arg)
@ -1160,11 +1075,7 @@ static void hpt_final_init(void *dummy)
ldm_for_each_vbus(vbus, vbus_ext) {
/* make timer available here */
mtx_init(&vbus_ext->lock, "hptsleeplock", NULL, MTX_DEF);
#if (__FreeBSD_version < 1000510)
callout_handle_init(&vbus_ext->timer);
#else
callout_init_mtx(&vbus_ext->timer, &vbus_ext->lock, 0);
#endif
if (hpt_init_vbus(vbus_ext)) {
os_printk("fail to initialize hardware");
break; /* FIXME */
@ -1207,23 +1118,15 @@ static void hpt_final_init(void *dummy)
os_printk("Can't create dma map(%d)", i);
return ;
}
#if (__FreeBSD_version >= 1000510)
callout_init_mtx(&ext->timeout, &vbus_ext->lock, 0);
#endif
}
if ((devq = cam_simq_alloc(os_max_queue_comm)) == NULL) {
os_printk("cam_simq_alloc failed");
return ;
}
#if (__FreeBSD_version >= 1000510)
vbus_ext->sim = cam_sim_alloc(hpt_action, hpt_poll, driver_name,
vbus_ext, unit_number, &vbus_ext->lock, os_max_queue_comm, /*tagged*/8, devq);
#else
vbus_ext->sim = cam_sim_alloc(hpt_action, hpt_poll, driver_name,
vbus_ext, unit_number, &Giant, os_max_queue_comm, /*tagged*/8, devq);
#endif
unit_number++;
if (!vbus_ext->sim) {
os_printk("cam_sim_alloc failed");
@ -1269,11 +1172,7 @@ static void hpt_final_init(void *dummy)
os_printk("can't allocate interrupt");
return ;
}
#if (__FreeBSD_version >= 1000510)
if (bus_setup_intr(hba->pcidev, hba->irq_res, INTR_TYPE_CAM | INTR_MPSAFE,
#else
if (bus_setup_intr(hba->pcidev, hba->irq_res, INTR_TYPE_CAM,
#endif
NULL, hpt_pci_intr, vbus_ext, &hba->irq_handle))
{
os_printk("can't set up interrupt");
@ -1439,16 +1338,8 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, stru
if (!ioctl_args.lpOutBuffer)
goto invalid;
}
#if __FreeBSD_version < 1000510
mtx_lock(&Giant);
#endif
hpt_do_ioctl(&ioctl_args);
#if __FreeBSD_version < 1000510
mtx_unlock(&Giant);
#endif
if (ioctl_args.result==HPT_IOCTL_RESULT_OK) {
if (piop->nOutBufferSize) {
@ -1488,20 +1379,14 @@ static int hpt_rescan_bus(void)
{
union ccb *ccb;
PVBUS vbus;
PVBUS_EXT vbus_ext;
#if (__FreeBSD_version < 1000510)
mtx_lock(&Giant);
#endif
PVBUS_EXT vbus_ext;
ldm_for_each_vbus(vbus, vbus_ext) {
if ((ccb = xpt_alloc_ccb()) == NULL)
{
return(ENOMEM);
}
#if (__FreeBSD_version < 1000510)
if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(vbus_ext->sim),
#else
if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(vbus_ext->sim),
#endif
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP)
{
xpt_free_ccb(ccb);
@ -1509,9 +1394,6 @@ static int hpt_rescan_bus(void)
}
xpt_rescan(ccb);
}
#if (__FreeBSD_version < 1000510)
mtx_unlock(&Giant);
#endif
return(0);
}

View File

@ -155,9 +155,7 @@ typedef struct _os_cmdext {
struct _os_cmdext *next;
union ccb *ccb;
bus_dmamap_t dma_map;
#if (__FreeBSD_version >= 1000510)
struct callout timeout;
#endif
SG psg[os_max_sg_descriptors];
}
OS_CMDEXT, *POS_CMDEXT;
@ -178,11 +176,7 @@ typedef struct _vbus_ext {
OSM_TASK *tasks;
struct task worker;
#if (__FreeBSD_version >= 1000510)
struct callout timer;
#else
struct callout_handle timer;
#endif
eventhandler_tag shutdown_eh;
/* the LDM vbus instance continues */
@ -201,11 +195,7 @@ VBUS_EXT, *PVBUS_EXT;
#define HPT_SCAN_BUS _IO('H', 1)
#if __FreeBSD_version < 1000510
#define TASK_ENQUEUE(task) taskqueue_enqueue(taskqueue_swi_giant,(task));
#else
#define TASK_ENQUEUE(task) taskqueue_enqueue(taskqueue_swi,(task));
#endif
static __inline int hpt_sleep(PVBUS_EXT vbus_ext, void *ident, int priority, const char *wmesg, int timo)
{