Deleted Added
full compact
ata_da.c (198328) ata_da.c (198382)
1/*-
2 * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/cam/ata/ata_da.c 198328 2009-10-21 14:20:55Z mav $");
28__FBSDID("$FreeBSD: head/sys/cam/ata/ata_da.c 198382 2009-10-23 08:27:55Z mav $");
29
30#include <sys/param.h>
31
32#ifdef _KERNEL
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/bio.h>
36#include <sys/sysctl.h>

--- 228 unchanged lines hidden (view full) ---

265 cam_periph_release(periph);
266 return (error);
267 }
268
269 softc = (struct ada_softc *)periph->softc;
270 /* We only sync the cache if the drive is capable of it. */
271 if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) {
272
29
30#include <sys/param.h>
31
32#ifdef _KERNEL
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/bio.h>
36#include <sys/sysctl.h>

--- 228 unchanged lines hidden (view full) ---

265 cam_periph_release(periph);
266 return (error);
267 }
268
269 softc = (struct ada_softc *)periph->softc;
270 /* We only sync the cache if the drive is capable of it. */
271 if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) {
272
273 ccb = cam_periph_getccb(periph, /*priority*/1);
273 ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
274 cam_fill_ataio(&ccb->ataio,
275 1,
276 adadone,
277 CAM_DIR_NONE,
278 0,
279 NULL,
280 0,
281 ada_default_timeout*1000);

--- 56 unchanged lines hidden (view full) ---

338 /*
339 * Place it in the queue of disk activities for this disk
340 */
341 bioq_disksort(&softc->bio_queue, bp);
342
343 /*
344 * Schedule ourselves for performing the work.
345 */
274 cam_fill_ataio(&ccb->ataio,
275 1,
276 adadone,
277 CAM_DIR_NONE,
278 0,
279 NULL,
280 0,
281 ada_default_timeout*1000);

--- 56 unchanged lines hidden (view full) ---

338 /*
339 * Place it in the queue of disk activities for this disk
340 */
341 bioq_disksort(&softc->bio_queue, bp);
342
343 /*
344 * Schedule ourselves for performing the work.
345 */
346 xpt_schedule(periph, /* XXX priority */1);
346 xpt_schedule(periph, CAM_PRIORITY_NORMAL);
347 cam_periph_unlock(periph);
348
349 return;
350}
351
352static int
353adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t length)
354{

--- 17 unchanged lines hidden (view full) ---

372
373 if ((softc->flags & ADA_FLAG_PACK_INVALID) != 0) {
374 cam_periph_unlock(periph);
375 return (ENXIO);
376 }
377
378 if (length > 0) {
379 periph->flags |= CAM_PERIPH_POLLED;
347 cam_periph_unlock(periph);
348
349 return;
350}
351
352static int
353adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t length)
354{

--- 17 unchanged lines hidden (view full) ---

372
373 if ((softc->flags & ADA_FLAG_PACK_INVALID) != 0) {
374 cam_periph_unlock(periph);
375 return (ENXIO);
376 }
377
378 if (length > 0) {
379 periph->flags |= CAM_PERIPH_POLLED;
380 xpt_setup_ccb(&ccb.ccb_h, periph->path, /*priority*/1);
380 xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
381 ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
382 cam_fill_ataio(&ccb.ataio,
383 0,
384 adadone,
385 CAM_DIR_OUT,
386 0,
387 (u_int8_t *) virtual,
388 length,

--- 14 unchanged lines hidden (view full) ---

403 cam_periph_unlock(periph);
404 return(EIO);
405 }
406 cam_periph_unlock(periph);
407 return(0);
408 }
409
410 if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) {
381 ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
382 cam_fill_ataio(&ccb.ataio,
383 0,
384 adadone,
385 CAM_DIR_OUT,
386 0,
387 (u_int8_t *) virtual,
388 length,

--- 14 unchanged lines hidden (view full) ---

403 cam_periph_unlock(periph);
404 return(EIO);
405 }
406 cam_periph_unlock(periph);
407 return(0);
408 }
409
410 if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) {
411 xpt_setup_ccb(&ccb.ccb_h, periph->path, /*priority*/1);
411 xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
412
413 ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
414 cam_fill_ataio(&ccb.ataio,
415 1,
416 adadone,
417 CAM_DIR_NONE,
418 0,
419 NULL,

--- 138 unchanged lines hidden (view full) ---

558 cam_periph_async(periph, code, path, arg);
559 if (softc->state != ADA_STATE_NORMAL)
560 break;
561 /*
562 * Restore device configuration.
563 */
564 softc->state = ADA_STATE_SET_MULTI;
565 cam_periph_acquire(periph);
412
413 ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
414 cam_fill_ataio(&ccb.ataio,
415 1,
416 adadone,
417 CAM_DIR_NONE,
418 0,
419 NULL,

--- 138 unchanged lines hidden (view full) ---

558 cam_periph_async(periph, code, path, arg);
559 if (softc->state != ADA_STATE_NORMAL)
560 break;
561 /*
562 * Restore device configuration.
563 */
564 softc->state = ADA_STATE_SET_MULTI;
565 cam_periph_acquire(periph);
566 xpt_schedule(periph, 0);
566 xpt_schedule(periph, CAM_PRIORITY_DEV);
567 break;
568 }
569 default:
570 cam_periph_async(periph, code, path, arg);
571 break;
572 }
573}
574

--- 85 unchanged lines hidden (view full) ---

660
661 if (match != NULL)
662 softc->quirks = ((struct ada_quirk_entry *)match)->quirks;
663 else
664 softc->quirks = ADA_Q_NONE;
665
666 /* Check if the SIM does not want queued commands */
667 bzero(&cpi, sizeof(cpi));
567 break;
568 }
569 default:
570 cam_periph_async(periph, code, path, arg);
571 break;
572 }
573}
574

--- 85 unchanged lines hidden (view full) ---

660
661 if (match != NULL)
662 softc->quirks = ((struct ada_quirk_entry *)match)->quirks;
663 else
664 softc->quirks = ADA_Q_NONE;
665
666 /* Check if the SIM does not want queued commands */
667 bzero(&cpi, sizeof(cpi));
668 xpt_setup_ccb(&cpi.ccb_h, periph->path, /*priority*/1);
668 xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
669 cpi.ccb_h.func_code = XPT_PATH_INQ;
670 xpt_action((union ccb *)&cpi);
671 if (cpi.ccb_h.status != CAM_REQ_CMP ||
672 (cpi.hba_inquiry & PI_TAG_ABLE) == 0)
673 softc->flags &= ~ADA_FLAG_CAN_NCQ;
674
675 TASK_INIT(&softc->sysctl_task, 0, adasysctlinit, periph);
676

--- 215 unchanged lines hidden (view full) ---

892 start_ccb->ccb_h.ccb_bp = bp;
893 bp = bioq_first(&softc->bio_queue);
894
895 xpt_action(start_ccb);
896 }
897
898 if (bp != NULL) {
899 /* Have more work to do, so ensure we stay scheduled */
669 cpi.ccb_h.func_code = XPT_PATH_INQ;
670 xpt_action((union ccb *)&cpi);
671 if (cpi.ccb_h.status != CAM_REQ_CMP ||
672 (cpi.hba_inquiry & PI_TAG_ABLE) == 0)
673 softc->flags &= ~ADA_FLAG_CAN_NCQ;
674
675 TASK_INIT(&softc->sysctl_task, 0, adasysctlinit, periph);
676

--- 215 unchanged lines hidden (view full) ---

892 start_ccb->ccb_h.ccb_bp = bp;
893 bp = bioq_first(&softc->bio_queue);
894
895 xpt_action(start_ccb);
896 }
897
898 if (bp != NULL) {
899 /* Have more work to do, so ensure we stay scheduled */
900 xpt_schedule(periph, /* XXX priority */1);
900 xpt_schedule(periph, CAM_PRIORITY_NORMAL);
901 }
902 break;
903 }
904 case ADA_STATE_SET_MULTI:
905 {
906 cam_fill_ataio(ataio,
907 ada_retry_count,
908 adadone,

--- 113 unchanged lines hidden (view full) ---

1022 * before releasing the probe lock on the peripheral.
1023 * The peripheral will only go away once the last lock
1024 * is removed, and we need it around for the CCB release
1025 * operation.
1026 */
1027 xpt_release_ccb(done_ccb);
1028 if (bioq_first(&softc->bio_queue) != NULL) {
1029 /* Have more work to do, so ensure we stay scheduled */
901 }
902 break;
903 }
904 case ADA_STATE_SET_MULTI:
905 {
906 cam_fill_ataio(ataio,
907 ada_retry_count,
908 adadone,

--- 113 unchanged lines hidden (view full) ---

1022 * before releasing the probe lock on the peripheral.
1023 * The peripheral will only go away once the last lock
1024 * is removed, and we need it around for the CCB release
1025 * operation.
1026 */
1027 xpt_release_ccb(done_ccb);
1028 if (bioq_first(&softc->bio_queue) != NULL) {
1029 /* Have more work to do, so ensure we stay scheduled */
1030 xpt_schedule(periph, 1);
1030 xpt_schedule(periph, CAM_PRIORITY_NORMAL);
1031 }
1032 cam_periph_release_locked(periph);
1033 return;
1034 }
1035 case ADA_CCB_DUMP:
1036 /* No-op. We're polling */
1037 return;
1038 default:

--- 95 unchanged lines hidden (view full) ---

1134 * if the drive is capable of it..
1135 */
1136 if (((softc->flags & ADA_FLAG_OPEN) == 0) ||
1137 (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) == 0) {
1138 cam_periph_unlock(periph);
1139 continue;
1140 }
1141
1031 }
1032 cam_periph_release_locked(periph);
1033 return;
1034 }
1035 case ADA_CCB_DUMP:
1036 /* No-op. We're polling */
1037 return;
1038 default:

--- 95 unchanged lines hidden (view full) ---

1134 * if the drive is capable of it..
1135 */
1136 if (((softc->flags & ADA_FLAG_OPEN) == 0) ||
1137 (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) == 0) {
1138 cam_periph_unlock(periph);
1139 continue;
1140 }
1141
1142 xpt_setup_ccb(&ccb.ccb_h, periph->path, /*priority*/1);
1142 xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
1143
1144 ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
1145 cam_fill_ataio(&ccb.ataio,
1146 1,
1147 adadone,
1148 CAM_DIR_NONE,
1149 0,
1150 NULL,

--- 23 unchanged lines hidden ---
1143
1144 ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
1145 cam_fill_ataio(&ccb.ataio,
1146 1,
1147 adadone,
1148 CAM_DIR_NONE,
1149 0,
1150 NULL,

--- 23 unchanged lines hidden ---