scsi_da.c (237478) | scsi_da.c (237518) |
---|---|
1/*- 2 * Implementation of SCSI Direct Access Peripheral driver for CAM. 3 * 4 * Copyright (c) 1997 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Implementation of SCSI Direct Access Peripheral driver for CAM. 3 * 4 * Copyright (c) 1997 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_da.c 237478 2012-06-23 12:32:53Z mav $"); | 30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_da.c 237518 2012-06-24 04:29:03Z ken $"); |
31 32#include <sys/param.h> 33 34#ifdef _KERNEL 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/bio.h> 38#include <sys/sysctl.h> --- 1189 unchanged lines hidden (view full) --- 1228 1229 /* Register our shutdown event handler */ 1230 if ((EVENTHANDLER_REGISTER(shutdown_post_sync, dashutdown, 1231 NULL, SHUTDOWN_PRI_DEFAULT)) == NULL) 1232 printf("dainit: shutdown event registration failed!\n"); 1233 } 1234} 1235 | 31 32#include <sys/param.h> 33 34#ifdef _KERNEL 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/bio.h> 38#include <sys/sysctl.h> --- 1189 unchanged lines hidden (view full) --- 1228 1229 /* Register our shutdown event handler */ 1230 if ((EVENTHANDLER_REGISTER(shutdown_post_sync, dashutdown, 1231 NULL, SHUTDOWN_PRI_DEFAULT)) == NULL) 1232 printf("dainit: shutdown event registration failed!\n"); 1233 } 1234} 1235 |
1236/* 1237 * Callback from GEOM, called when it has finished cleaning up its 1238 * resources. 1239 */ |
|
1236static void | 1240static void |
1241dadiskgonecb(struct disk *dp) 1242{ 1243 struct cam_periph *periph; 1244 1245 periph = (struct cam_periph *)dp->d_drv1; 1246 1247 cam_periph_release(periph); 1248} 1249 1250static void |
|
1237daoninvalidate(struct cam_periph *periph) 1238{ 1239 struct da_softc *softc; 1240 1241 softc = (struct da_softc *)periph->softc; 1242 1243 /* 1244 * De-register any async callbacks. --- 5 unchanged lines hidden (view full) --- 1250 /* 1251 * Return all queued I/O with ENXIO. 1252 * XXX Handle any transactions queued to the card 1253 * with XPT_ABORT_CCB. 1254 */ 1255 bioq_flush(&softc->bio_queue, NULL, ENXIO); 1256 bioq_flush(&softc->delete_queue, NULL, ENXIO); 1257 | 1251daoninvalidate(struct cam_periph *periph) 1252{ 1253 struct da_softc *softc; 1254 1255 softc = (struct da_softc *)periph->softc; 1256 1257 /* 1258 * De-register any async callbacks. --- 5 unchanged lines hidden (view full) --- 1264 /* 1265 * Return all queued I/O with ENXIO. 1266 * XXX Handle any transactions queued to the card 1267 * with XPT_ABORT_CCB. 1268 */ 1269 bioq_flush(&softc->bio_queue, NULL, ENXIO); 1270 bioq_flush(&softc->delete_queue, NULL, ENXIO); 1271 |
1272 /* 1273 * Tell GEOM that we've gone away, we'll get a callback when it is 1274 * done cleaning up its resources. 1275 */ |
|
1258 disk_gone(softc->disk); | 1276 disk_gone(softc->disk); |
1277 |
|
1259 xpt_print(periph->path, "lost device - %d outstanding, %d refs\n", 1260 softc->outstanding_cmds, periph->refcount); 1261} 1262 1263static void 1264dacleanup(struct cam_periph *periph) 1265{ 1266 struct da_softc *softc; --- 361 unchanged lines hidden (view full) --- 1628 SID_TYPE(&cgd->inq_data) | 1629 XPORT_DEVSTAT_TYPE(cpi.transport), 1630 DEVSTAT_PRIORITY_DISK); 1631 softc->disk->d_open = daopen; 1632 softc->disk->d_close = daclose; 1633 softc->disk->d_strategy = dastrategy; 1634 softc->disk->d_dump = dadump; 1635 softc->disk->d_getattr = dagetattr; | 1278 xpt_print(periph->path, "lost device - %d outstanding, %d refs\n", 1279 softc->outstanding_cmds, periph->refcount); 1280} 1281 1282static void 1283dacleanup(struct cam_periph *periph) 1284{ 1285 struct da_softc *softc; --- 361 unchanged lines hidden (view full) --- 1647 SID_TYPE(&cgd->inq_data) | 1648 XPORT_DEVSTAT_TYPE(cpi.transport), 1649 DEVSTAT_PRIORITY_DISK); 1650 softc->disk->d_open = daopen; 1651 softc->disk->d_close = daclose; 1652 softc->disk->d_strategy = dastrategy; 1653 softc->disk->d_dump = dadump; 1654 softc->disk->d_getattr = dagetattr; |
1655 softc->disk->d_gone = dadiskgonecb; |
|
1636 softc->disk->d_name = "da"; 1637 softc->disk->d_drv1 = periph; 1638 if (cpi.maxio == 0) 1639 softc->disk->d_maxsize = DFLTPHYS; /* traditional default */ 1640 else if (cpi.maxio > MAXPHYS) 1641 softc->disk->d_maxsize = MAXPHYS; /* for safety */ 1642 else 1643 softc->disk->d_maxsize = cpi.maxio; --- 6 unchanged lines hidden (view full) --- 1650 strlcat(softc->disk->d_descr, " ", sizeof(softc->disk->d_descr)); 1651 cam_strvis(&softc->disk->d_descr[strlen(softc->disk->d_descr)], 1652 cgd->inq_data.product, sizeof(cgd->inq_data.product), 1653 sizeof(softc->disk->d_descr) - strlen(softc->disk->d_descr)); 1654 softc->disk->d_hba_vendor = cpi.hba_vendor; 1655 softc->disk->d_hba_device = cpi.hba_device; 1656 softc->disk->d_hba_subvendor = cpi.hba_subvendor; 1657 softc->disk->d_hba_subdevice = cpi.hba_subdevice; | 1656 softc->disk->d_name = "da"; 1657 softc->disk->d_drv1 = periph; 1658 if (cpi.maxio == 0) 1659 softc->disk->d_maxsize = DFLTPHYS; /* traditional default */ 1660 else if (cpi.maxio > MAXPHYS) 1661 softc->disk->d_maxsize = MAXPHYS; /* for safety */ 1662 else 1663 softc->disk->d_maxsize = cpi.maxio; --- 6 unchanged lines hidden (view full) --- 1670 strlcat(softc->disk->d_descr, " ", sizeof(softc->disk->d_descr)); 1671 cam_strvis(&softc->disk->d_descr[strlen(softc->disk->d_descr)], 1672 cgd->inq_data.product, sizeof(cgd->inq_data.product), 1673 sizeof(softc->disk->d_descr) - strlen(softc->disk->d_descr)); 1674 softc->disk->d_hba_vendor = cpi.hba_vendor; 1675 softc->disk->d_hba_device = cpi.hba_device; 1676 softc->disk->d_hba_subvendor = cpi.hba_subvendor; 1677 softc->disk->d_hba_subdevice = cpi.hba_subdevice; |
1678 1679 /* 1680 * Acquire a reference to the periph before we register with GEOM. 1681 * We'll release this reference once GEOM calls us back (via 1682 * dadiskgonecb()) telling us that our provider has been freed. 1683 */ 1684 if (cam_periph_acquire(periph) != CAM_REQ_CMP) { 1685 xpt_print(periph->path, "%s: lost periph during " 1686 "registration!\n", __func__); 1687 mtx_lock(periph->sim->mtx); 1688 return (CAM_REQ_CMP_ERR); 1689 } 1690 |
|
1658 disk_create(softc->disk, DISK_VERSION); 1659 mtx_lock(periph->sim->mtx); 1660 1661 /* 1662 * Add async callbacks for events of interest. 1663 * I don't bother checking if this fails as, 1664 * in most cases, the system will function just 1665 * fine without them and the only alternative --- 1057 unchanged lines hidden --- | 1691 disk_create(softc->disk, DISK_VERSION); 1692 mtx_lock(periph->sim->mtx); 1693 1694 /* 1695 * Add async callbacks for events of interest. 1696 * I don't bother checking if this fails as, 1697 * in most cases, the system will function just 1698 * fine without them and the only alternative --- 1057 unchanged lines hidden --- |