scsi_sa.c (287289) | scsi_sa.c (293350) |
---|---|
1/*- 2 * Implementation of SCSI Sequential Access Peripheral driver for CAM. 3 * 4 * Copyright (c) 1999, 2000 Matthew Jacob 5 * Copyright (c) 2013, 2014, 2015 Spectra Logic Corporation 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Implementation of SCSI Sequential Access Peripheral driver for CAM. 3 * 4 * Copyright (c) 1999, 2000 Matthew Jacob 5 * Copyright (c) 2013, 2014, 2015 Spectra Logic Corporation 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_sa.c 287289 2015-08-29 11:21:20Z mav $"); | 31__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_sa.c 293350 2016-01-07 20:22:55Z kib $"); |
32 33#include <sys/param.h> 34#include <sys/queue.h> 35#ifdef _KERNEL 36#include <sys/systm.h> 37#include <sys/kernel.h> 38#endif 39#include <sys/types.h> --- 686 unchanged lines hidden (view full) --- 726{ 727 struct cam_periph *periph; 728 struct sa_softc *softc; 729 int mode, error, writing, tmp, i; 730 int closedbits = SA_FLAG_OPEN; 731 732 mode = SAMODE(dev); 733 periph = (struct cam_periph *)dev->si_drv1; | 32 33#include <sys/param.h> 34#include <sys/queue.h> 35#ifdef _KERNEL 36#include <sys/systm.h> 37#include <sys/kernel.h> 38#endif 39#include <sys/types.h> --- 686 unchanged lines hidden (view full) --- 726{ 727 struct cam_periph *periph; 728 struct sa_softc *softc; 729 int mode, error, writing, tmp, i; 730 int closedbits = SA_FLAG_OPEN; 731 732 mode = SAMODE(dev); 733 periph = (struct cam_periph *)dev->si_drv1; |
734 if (periph == NULL) 735 return (ENXIO); 736 | |
737 cam_periph_lock(periph); 738 739 softc = (struct sa_softc *)periph->softc; 740 741 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO, 742 ("saclose(%s): softc=0x%x\n", devtoname(dev), softc->flags)); 743 744 --- 156 unchanged lines hidden (view full) --- 901 struct sa_softc *softc; 902 903 bp->bio_resid = bp->bio_bcount; 904 if (SA_IS_CTRL(bp->bio_dev)) { 905 biofinish(bp, NULL, EINVAL); 906 return; 907 } 908 periph = (struct cam_periph *)bp->bio_dev->si_drv1; | 734 cam_periph_lock(periph); 735 736 softc = (struct sa_softc *)periph->softc; 737 738 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO, 739 ("saclose(%s): softc=0x%x\n", devtoname(dev), softc->flags)); 740 741 --- 156 unchanged lines hidden (view full) --- 898 struct sa_softc *softc; 899 900 bp->bio_resid = bp->bio_bcount; 901 if (SA_IS_CTRL(bp->bio_dev)) { 902 biofinish(bp, NULL, EINVAL); 903 return; 904 } 905 periph = (struct cam_periph *)bp->bio_dev->si_drv1; |
909 if (periph == NULL) { 910 biofinish(bp, NULL, ENXIO); 911 return; 912 } | |
913 cam_periph_lock(periph); 914 915 softc = (struct sa_softc *)periph->softc; 916 917 if (softc->flags & SA_FLAG_INVALID) { 918 cam_periph_unlock(periph); 919 biofinish(bp, NULL, ENXIO); 920 return; --- 591 unchanged lines hidden (view full) --- 1512 int mode; 1513 int error = 0; 1514 1515 mode = SAMODE(dev); 1516 error = 0; /* shut up gcc */ 1517 spaceop = 0; /* shut up gcc */ 1518 1519 periph = (struct cam_periph *)dev->si_drv1; | 906 cam_periph_lock(periph); 907 908 softc = (struct sa_softc *)periph->softc; 909 910 if (softc->flags & SA_FLAG_INVALID) { 911 cam_periph_unlock(periph); 912 biofinish(bp, NULL, ENXIO); 913 return; --- 591 unchanged lines hidden (view full) --- 1505 int mode; 1506 int error = 0; 1507 1508 mode = SAMODE(dev); 1509 error = 0; /* shut up gcc */ 1510 spaceop = 0; /* shut up gcc */ 1511 1512 periph = (struct cam_periph *)dev->si_drv1; |
1520 if (periph == NULL) 1521 return (ENXIO); 1522 | |
1523 cam_periph_lock(periph); 1524 softc = (struct sa_softc *)periph->softc; 1525 1526 /* 1527 * Check for control mode accesses. We allow MTIOCGET and 1528 * MTIOCERRSTAT (but need to be the only one open in order 1529 * to clear latched status), and MTSETBSIZE, MTSETDNSTY 1530 * and MTCOMP (but need to be the only one accessing this --- 749 unchanged lines hidden (view full) --- 2280 cam_periph_async(periph, code, path, arg); 2281 break; 2282 } 2283} 2284 2285static void 2286sasetupdev(struct sa_softc *softc, struct cdev *dev) 2287{ | 1513 cam_periph_lock(periph); 1514 softc = (struct sa_softc *)periph->softc; 1515 1516 /* 1517 * Check for control mode accesses. We allow MTIOCGET and 1518 * MTIOCERRSTAT (but need to be the only one open in order 1519 * to clear latched status), and MTSETBSIZE, MTSETDNSTY 1520 * and MTCOMP (but need to be the only one accessing this --- 749 unchanged lines hidden (view full) --- 2270 cam_periph_async(periph, code, path, arg); 2271 break; 2272 } 2273} 2274 2275static void 2276sasetupdev(struct sa_softc *softc, struct cdev *dev) 2277{ |
2288 dev->si_drv1 = softc->periph; | 2278 |
2289 dev->si_iosize_max = softc->maxio; 2290 dev->si_flags |= softc->si_flags; 2291 /* 2292 * Keep a count of how many non-alias devices we have created, 2293 * so we can make sure we clean them all up on shutdown. Aliases 2294 * are cleaned up when we destroy the device they're an alias for. 2295 */ 2296 if ((dev->si_flags & SI_ALIAS) == 0) --- 45 unchanged lines hidden (view full) --- 2342} 2343 2344static cam_status 2345saregister(struct cam_periph *periph, void *arg) 2346{ 2347 struct sa_softc *softc; 2348 struct ccb_getdev *cgd; 2349 struct ccb_pathinq cpi; | 2279 dev->si_iosize_max = softc->maxio; 2280 dev->si_flags |= softc->si_flags; 2281 /* 2282 * Keep a count of how many non-alias devices we have created, 2283 * so we can make sure we clean them all up on shutdown. Aliases 2284 * are cleaned up when we destroy the device they're an alias for. 2285 */ 2286 if ((dev->si_flags & SI_ALIAS) == 0) --- 45 unchanged lines hidden (view full) --- 2332} 2333 2334static cam_status 2335saregister(struct cam_periph *periph, void *arg) 2336{ 2337 struct sa_softc *softc; 2338 struct ccb_getdev *cgd; 2339 struct ccb_pathinq cpi; |
2340 struct make_dev_args args; |
|
2350 caddr_t match; 2351 char tmpstr[80]; | 2341 caddr_t match; 2342 char tmpstr[80]; |
2343 int error; |
|
2352 2353 cgd = (struct ccb_getdev *)arg; 2354 if (cgd == NULL) { 2355 printf("saregister: no getdev CCB, can't register device\n"); 2356 return (CAM_REQ_CMP_ERR); 2357 } 2358 2359 softc = (struct sa_softc *) --- 141 unchanged lines hidden (view full) --- 2501 */ 2502 if (cam_periph_acquire(periph) != CAM_REQ_CMP) { 2503 xpt_print(periph->path, "%s: lost periph during " 2504 "registration!\n", __func__); 2505 cam_periph_lock(periph); 2506 return (CAM_REQ_CMP_ERR); 2507 } 2508 | 2344 2345 cgd = (struct ccb_getdev *)arg; 2346 if (cgd == NULL) { 2347 printf("saregister: no getdev CCB, can't register device\n"); 2348 return (CAM_REQ_CMP_ERR); 2349 } 2350 2351 softc = (struct sa_softc *) --- 141 unchanged lines hidden (view full) --- 2493 */ 2494 if (cam_periph_acquire(periph) != CAM_REQ_CMP) { 2495 xpt_print(periph->path, "%s: lost periph during " 2496 "registration!\n", __func__); 2497 cam_periph_lock(periph); 2498 return (CAM_REQ_CMP_ERR); 2499 } 2500 |
2509 softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV, 2510 SA_ATYPE_R), UID_ROOT, GID_OPERATOR, 2511 0660, "%s%d.ctl", periph->periph_name, periph->unit_number); | 2501 make_dev_args_init(&args); 2502 args.mda_devsw = &sa_cdevsw; 2503 args.mda_si_drv1 = softc->periph; 2504 args.mda_uid = UID_ROOT; 2505 args.mda_gid = GID_OPERATOR; 2506 args.mda_mode = 0660; 2507 2508 args.mda_unit = SAMINOR(SA_CTLDEV, SA_ATYPE_R); 2509 error = make_dev_s(&args, &softc->devs.ctl_dev, "%s%d.ctl", 2510 periph->periph_name, periph->unit_number); 2511 if (error != 0) { 2512 cam_periph_lock(periph); 2513 return (CAM_REQ_CMP_ERR); 2514 } |
2512 sasetupdev(softc, softc->devs.ctl_dev); 2513 | 2515 sasetupdev(softc, softc->devs.ctl_dev); 2516 |
2514 softc->devs.r_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV, 2515 SA_ATYPE_R), UID_ROOT, GID_OPERATOR, 2516 0660, "%s%d", periph->periph_name, periph->unit_number); | 2517 args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_R); 2518 error = make_dev_s(&args, &softc->devs.r_dev, "%s%d", 2519 periph->periph_name, periph->unit_number); 2520 if (error != 0) { 2521 cam_periph_lock(periph); 2522 return (CAM_REQ_CMP_ERR); 2523 } |
2517 sasetupdev(softc, softc->devs.r_dev); 2518 | 2524 sasetupdev(softc, softc->devs.r_dev); 2525 |
2519 softc->devs.nr_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV, 2520 SA_ATYPE_NR), UID_ROOT, GID_OPERATOR, 2521 0660, "n%s%d", periph->periph_name, periph->unit_number); | 2526 args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_NR); 2527 error = make_dev_s(&args, &softc->devs.nr_dev, "n%s%d", 2528 periph->periph_name, periph->unit_number); 2529 if (error != 0) { 2530 cam_periph_lock(periph); 2531 return (CAM_REQ_CMP_ERR); 2532 } |
2522 sasetupdev(softc, softc->devs.nr_dev); 2523 | 2533 sasetupdev(softc, softc->devs.nr_dev); 2534 |
2524 softc->devs.er_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV, 2525 SA_ATYPE_ER), UID_ROOT, GID_OPERATOR, 2526 0660, "e%s%d", periph->periph_name, periph->unit_number); 2527 sasetupdev(softc, softc->devs.er_dev); | 2535 args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_ER); 2536 error = make_dev_s(&args, &softc->devs.er_dev, "e%s%d", 2537 periph->periph_name, periph->unit_number); 2538 if (error != 0) { 2539 cam_periph_lock(periph); 2540 return (CAM_REQ_CMP_ERR); 2541 } 2542 sasetupdev(softc, softc->devs.er_dev); |
2528 2529 cam_periph_lock(periph); 2530 2531 softc->density_type_bits[0] = 0; 2532 softc->density_type_bits[1] = SRDS_MEDIA; 2533 softc->density_type_bits[2] = SRDS_MEDIUM_TYPE; 2534 softc->density_type_bits[3] = SRDS_MEDIUM_TYPE | SRDS_MEDIA; 2535 /* --- 3335 unchanged lines hidden --- | 2543 2544 cam_periph_lock(periph); 2545 2546 softc->density_type_bits[0] = 0; 2547 softc->density_type_bits[1] = SRDS_MEDIA; 2548 softc->density_type_bits[2] = SRDS_MEDIUM_TYPE; 2549 softc->density_type_bits[3] = SRDS_MEDIUM_TYPE | SRDS_MEDIA; 2550 /* --- 3335 unchanged lines hidden --- |