From owner-p4-projects@FreeBSD.ORG Mon Jun 12 14:00:58 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E68E416A6C9; Mon, 12 Jun 2006 14:00:57 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C257716A6B9 for ; Mon, 12 Jun 2006 14:00:57 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9103943D5F for ; Mon, 12 Jun 2006 14:00:56 +0000 (GMT) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5CDwflA070151 for ; Mon, 12 Jun 2006 13:58:41 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5CDwfDW070148 for perforce@freebsd.org; Mon, 12 Jun 2006 13:58:41 GMT (envelope-from scottl@freebsd.org) Date: Mon, 12 Jun 2006 13:58:41 GMT Message-Id: <200606121358.k5CDwfDW070148@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to scottl@freebsd.org using -f From: Scott Long To: Perforce Change Reviews Cc: Subject: PERFORCE change 99050 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jun 2006 14:00:58 -0000 http://perforce.freebsd.org/chv.cgi?CH=99050 Change 99050 by scottl@scottl-x64 on 2006/06/12 13:58:16 Checkpoint sim lock handling in the da periph and camisr. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#10 edit .. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#7 edit .. //depot/projects/scottl-camlock/src/sys/cam/cam_sim.h#7 edit .. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#35 edit .. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#10 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#10 (text+ko) ==== @@ -114,6 +114,7 @@ ac_callback_t *ac_callback, ac_code code, void *arg) { struct periph_driver **p_drv; + struct cam_sim *sim; struct cam_periph *periph; struct cam_periph *cur_periph; path_id_t path_id; @@ -159,7 +160,8 @@ if (strcmp((*p_drv)->driver_name, name) == 0) break; } - + + sim = xpt_path_sim(path); path_id = xpt_path_path_id(path); target_id = xpt_path_target_id(path); lun_id = xpt_path_lun_id(path); @@ -173,6 +175,7 @@ periph->unit_number = camperiphunit(*p_drv, path_id, target_id, lun_id); periph->immediate_priority = CAM_PRIORITY_NONE; periph->refcount = 0; + periph->sim = sim; SLIST_INIT(&periph->ccb_list); status = xpt_create_path(&path, periph, path_id, target_id, lun_id); if (status != CAM_REQ_CMP) ==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#7 (text+ko) ==== @@ -104,6 +104,7 @@ char *periph_name; struct cam_path *path; /* Compiled path to device */ void *softc; + struct cam_sim *sim; u_int32_t unit_number; cam_periph_type type; u_int32_t flags; ==== //depot/projects/scottl-camlock/src/sys/cam/cam_sim.h#7 (text+ko) ==== @@ -116,6 +116,9 @@ }; +#define CAM_SIM_LOCK(sim) mtx_lock((sim)->mtx); +#define CAM_SIM_UNLOCK(sim) mtx_unlock((sim)->mtx); + static __inline u_int32_t cam_sim_path(struct cam_sim *sim) { ==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#35 (text+ko) ==== @@ -83,9 +83,6 @@ SLIST_HEAD(async_list, async_node); SLIST_HEAD(periph_list, cam_periph); -#define CAM_SIM_LOCK(sim) mtx_lock((sim)->mtx); -#define CAM_SIM_UNLOCK(sim) mtx_unlock((sim)->mtx); - /* * This is the maximum number of high powered commands (e.g. start unit) * that can be outstanding at a particular time. @@ -1460,7 +1457,7 @@ } /* Install our software interrupt handlers */ - swi_add(NULL, "cambio", camisr, &cam_bioq, SWI_CAMBIO, 0, &cambio_ih); + swi_add(NULL, "cambio", camisr, &cam_bioq, SWI_CAMBIO, INTR_MPSAFE, &cambio_ih); } static cam_status @@ -7201,6 +7198,7 @@ int runq; TAILQ_REMOVE(&queue, ccb_h, sim_links.tqe); + mtx_lock(ccb_h->path->bus->sim->mtx); ccb_h->pinfo.index = CAM_UNQUEUED_INDEX; splx(s); @@ -7290,6 +7288,7 @@ (*ccb_h->cbfcnp)(ccb_h->path->periph, (union ccb *)ccb_h); /* Raise IPL for while test */ + mtx_unlock(ccb_h->path->bus->sim->mtx); s = splcam(); } splx(s); ==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#10 (text+ko) ==== @@ -37,6 +37,8 @@ #include #include #include +#include +#include #endif /* _KERNEL */ #include @@ -61,6 +63,7 @@ #include #include #include +#include #include @@ -528,6 +531,8 @@ splx(s); return (ENXIO); } + mtx_lock(periph->sim->mtx); + unit = periph->unit_number; softc = (struct da_softc *)periph->softc; @@ -539,8 +544,10 @@ if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0) return (error); /* error code from tsleep */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + mtx_unlock(periph->sim->mtx); return(ENXIO); + } softc->flags |= DA_FLAG_OPEN; if ((softc->flags & DA_FLAG_PACK_INVALID) != 0) { @@ -571,6 +578,7 @@ cam_periph_release(periph); } cam_periph_unlock(periph); + mtx_unlock(periph->sim->mtx); return (error); } @@ -585,9 +593,11 @@ if (periph == NULL) return (ENXIO); + mtx_lock(periph->sim->mtx); softc = (struct da_softc *)periph->softc; if ((error = cam_periph_lock(periph, PRIBIO)) != 0) { + mtx_unlock(periph->sim->mtx); return (error); /* error code from tsleep */ } @@ -655,6 +665,7 @@ softc->flags &= ~DA_FLAG_OPEN; cam_periph_unlock(periph); cam_periph_release(periph); + mtx_unlock(periph->sim->mtx); return (0); } @@ -676,6 +687,9 @@ return; } softc = (struct da_softc *)periph->softc; + + mtx_lock(periph->sim->mtx); + #if 0 /* * check it's not too big a transfer for our adapter @@ -695,6 +709,7 @@ */ if ((softc->flags & DA_FLAG_PACK_INVALID)) { splx(s); + mtx_unlock(periph->sim->mtx); biofinish(bp, NULL, ENXIO); return; } @@ -710,6 +725,7 @@ * Schedule ourselves for performing the work. */ xpt_schedule(periph, /* XXX priority */1); + mtx_unlock(periph->sim->mtx); return; } @@ -1164,7 +1180,7 @@ softc->disk->d_drv1 = periph; softc->disk->d_maxsize = DFLTPHYS; /* XXX: probably not arbitrary */ softc->disk->d_unit = periph->unit_number; - softc->disk->d_flags = DISKFLAG_NEEDSGIANT; + softc->disk->d_flags = 0; disk_create(softc->disk, DISK_VERSION); /*