mvs.c (220615) | mvs.c (220822) |
---|---|
1/*- 2 * Copyright (c) 2010 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) 2010 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/dev/mvs/mvs.c 220615 2011-04-14 07:49:45Z mav $"); | 28__FBSDID("$FreeBSD: head/sys/dev/mvs/mvs.c 220822 2011-04-19 08:01:17Z mav $"); |
29 30#include <sys/param.h> 31#include <sys/module.h> 32#include <sys/systm.h> 33#include <sys/kernel.h> 34#include <sys/ata.h> 35#include <sys/bus.h> 36#include <sys/conf.h> --- 1739 unchanged lines hidden (view full) --- 1776mvs_issue_recovery(device_t dev) 1777{ 1778 struct mvs_channel *ch = device_get_softc(dev); 1779 union ccb *ccb; 1780 struct ccb_ataio *ataio; 1781 struct ccb_scsiio *csio; 1782 int i; 1783 | 29 30#include <sys/param.h> 31#include <sys/module.h> 32#include <sys/systm.h> 33#include <sys/kernel.h> 34#include <sys/ata.h> 35#include <sys/bus.h> 36#include <sys/conf.h> --- 1739 unchanged lines hidden (view full) --- 1776mvs_issue_recovery(device_t dev) 1777{ 1778 struct mvs_channel *ch = device_get_softc(dev); 1779 union ccb *ccb; 1780 struct ccb_ataio *ataio; 1781 struct ccb_scsiio *csio; 1782 int i; 1783 |
1784 ch->recoverycmd = 1; | |
1785 /* Find some holden command. */ 1786 for (i = 0; i < MVS_MAX_SLOTS; i++) { 1787 if (ch->hold[i]) 1788 break; 1789 } 1790 ccb = xpt_alloc_ccb_nowait(); 1791 if (ccb == NULL) { | 1784 /* Find some holden command. */ 1785 for (i = 0; i < MVS_MAX_SLOTS; i++) { 1786 if (ch->hold[i]) 1787 break; 1788 } 1789 ccb = xpt_alloc_ccb_nowait(); 1790 if (ccb == NULL) { |
1792 device_printf(dev, "Unable allocate READ LOG command"); 1793 return; /* XXX */ | 1791 device_printf(dev, "Unable allocate recovery command\n"); 1792completeall: 1793 /* We can't do anything -- complete holden commands. */ 1794 for (i = 0; i < MVS_MAX_SLOTS; i++) { 1795 if (ch->hold[i] == NULL) 1796 continue; 1797 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; 1798 ch->hold[i]->ccb_h.status |= CAM_RESRC_UNAVAIL; 1799 xpt_done(ch->hold[i]); 1800 ch->hold[i] = NULL; 1801 ch->numhslots--; 1802 } 1803 mvs_reset(dev); 1804 return; |
1794 } 1795 ccb->ccb_h = ch->hold[i]->ccb_h; /* Reuse old header. */ 1796 if (ccb->ccb_h.func_code == XPT_ATA_IO) { 1797 /* READ LOG */ 1798 ccb->ccb_h.recovery_type = RECOVERY_READ_LOG; 1799 ccb->ccb_h.func_code = XPT_ATA_IO; 1800 ccb->ccb_h.flags = CAM_DIR_IN; 1801 ccb->ccb_h.timeout = 1000; /* 1s should be enough. */ 1802 ataio = &ccb->ataio; 1803 ataio->data_ptr = malloc(512, M_MVS, M_NOWAIT); 1804 if (ataio->data_ptr == NULL) { 1805 xpt_free_ccb(ccb); | 1805 } 1806 ccb->ccb_h = ch->hold[i]->ccb_h; /* Reuse old header. */ 1807 if (ccb->ccb_h.func_code == XPT_ATA_IO) { 1808 /* READ LOG */ 1809 ccb->ccb_h.recovery_type = RECOVERY_READ_LOG; 1810 ccb->ccb_h.func_code = XPT_ATA_IO; 1811 ccb->ccb_h.flags = CAM_DIR_IN; 1812 ccb->ccb_h.timeout = 1000; /* 1s should be enough. */ 1813 ataio = &ccb->ataio; 1814 ataio->data_ptr = malloc(512, M_MVS, M_NOWAIT); 1815 if (ataio->data_ptr == NULL) { 1816 xpt_free_ccb(ccb); |
1806 device_printf(dev, "Unable allocate memory for READ LOG command"); 1807 return; /* XXX */ | 1817 device_printf(dev, 1818 "Unable allocate memory for READ LOG command\n"); 1819 goto completeall; |
1808 } 1809 ataio->dxfer_len = 512; 1810 bzero(&ataio->cmd, sizeof(ataio->cmd)); 1811 ataio->cmd.flags = CAM_ATAIO_48BIT; 1812 ataio->cmd.command = 0x2F; /* READ LOG EXT */ 1813 ataio->cmd.sector_count = 1; 1814 ataio->cmd.sector_count_exp = 0; 1815 ataio->cmd.lba_low = 0x10; --- 10 unchanged lines hidden (view full) --- 1826 csio = &ccb->csio; 1827 csio->data_ptr = (void *)&ch->hold[i]->csio.sense_data; 1828 csio->dxfer_len = ch->hold[i]->csio.sense_len; 1829 csio->cdb_len = 6; 1830 bzero(&csio->cdb_io, sizeof(csio->cdb_io)); 1831 csio->cdb_io.cdb_bytes[0] = 0x03; 1832 csio->cdb_io.cdb_bytes[4] = csio->dxfer_len; 1833 } | 1820 } 1821 ataio->dxfer_len = 512; 1822 bzero(&ataio->cmd, sizeof(ataio->cmd)); 1823 ataio->cmd.flags = CAM_ATAIO_48BIT; 1824 ataio->cmd.command = 0x2F; /* READ LOG EXT */ 1825 ataio->cmd.sector_count = 1; 1826 ataio->cmd.sector_count_exp = 0; 1827 ataio->cmd.lba_low = 0x10; --- 10 unchanged lines hidden (view full) --- 1838 csio = &ccb->csio; 1839 csio->data_ptr = (void *)&ch->hold[i]->csio.sense_data; 1840 csio->dxfer_len = ch->hold[i]->csio.sense_len; 1841 csio->cdb_len = 6; 1842 bzero(&csio->cdb_io, sizeof(csio->cdb_io)); 1843 csio->cdb_io.cdb_bytes[0] = 0x03; 1844 csio->cdb_io.cdb_bytes[4] = csio->dxfer_len; 1845 } |
1834 /* Freeze SIM while doing READ LOG EXT. */ | 1846 /* Freeze SIM while doing recovery. */ 1847 ch->recoverycmd = 1; |
1835 xpt_freeze_simq(ch->sim, 1); 1836 mvs_begin_transaction(dev, ccb); 1837} 1838 1839static void 1840mvs_process_read_log(device_t dev, union ccb *ccb) 1841{ 1842 struct mvs_channel *ch = device_get_softc(dev); --- 537 unchanged lines hidden --- | 1848 xpt_freeze_simq(ch->sim, 1); 1849 mvs_begin_transaction(dev, ccb); 1850} 1851 1852static void 1853mvs_process_read_log(device_t dev, union ccb *ccb) 1854{ 1855 struct mvs_channel *ch = device_get_softc(dev); --- 537 unchanged lines hidden --- |