Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6:
[SCSI] aic94xx: fix section mismatch
[SCSI] u14-34f: Fix 32bit only problem
[SCSI] dpt_i2o: sysfs code
[SCSI] dpt_i2o: 64 bit support
[SCSI] dpt_i2o: move from virt_to_bus/bus_to_virt to dma_alloc_coherent
[SCSI] dpt_i2o: use standard __init / __exit code
[SCSI] megaraid_sas: fix suspend/resume sections
[SCSI] aacraid: Add Power Management support
[SCSI] aacraid: Fix jbod operations scan issues
[SCSI] aacraid: Fix warning about macro side-effects
[SCSI] add support for variable length extended commands
[SCSI] Let scsi_cmnd->cmnd use request->cmd buffer
[SCSI] bsg: add large command support
[SCSI] aacraid: Fix down_interruptible() to check the return value correctly
[SCSI] megaraid_sas; Update the Version and Changelog
[SCSI] ibmvscsi: Handle non SCSI error status
[SCSI] bug fix for free list handling
[SCSI] ipr: Rename ipr's state scsi host attribute to prevent collisions
[SCSI] megaraid_mbox: fix Dell CERC firmware problem

+884 -291
+22
Documentation/scsi/ChangeLog.megaraid_sas
··· 1 + 1 Release Date : Mon. March 10 11:02:31 PDT 2008 - 2 + (emaild-id:megaraidlinux@lsi.com) 3 + Sumant Patro 4 + Bo Yang 5 + 6 + 2 Current Version : 00.00.03.20-RC1 7 + 3 Older Version : 00.00.03.16 8 + 9 + 1. Rollback the sense info implementation 10 + Sense buffer ptr data type in the ioctl path is reverted back 11 + to u32 * as in previous versions of driver. 12 + 13 + 2. Fixed the driver frame count. 14 + When Driver sent wrong frame count to firmware. As this 15 + particular command is sent to drive, FW is seeing continuous 16 + chip resets and so the command will timeout. 17 + 18 + 3. Add the new controller(1078DE) support to the driver 19 + and Increase the max_wait to 60 from 10 in the controller 20 + operational status. With this max_wait increase, driver will 21 + make sure the FW will finish the pending cmd for KDUMP case. 22 + 1 23 1 Release Date : Thur. Nov. 07 16:30:43 PST 2007 - 2 24 (emaild-id:megaraidlinux@lsi.com) 3 25 Sumant Patro
+9 -3
block/bsg.c
··· 174 174 static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq, 175 175 struct sg_io_v4 *hdr, int has_write_perm) 176 176 { 177 - memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ 177 + if (hdr->request_len > BLK_MAX_CDB) { 178 + rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL); 179 + if (!rq->cmd) 180 + return -ENOMEM; 181 + } 178 182 179 183 if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request, 180 184 hdr->request_len)) ··· 214 210 int ret = 0; 215 211 216 212 if (hdr->guard != 'Q') 217 - return -EINVAL; 218 - if (hdr->request_len > BLK_MAX_CDB) 219 213 return -EINVAL; 220 214 if (hdr->dout_xfer_len > (q->max_sectors << 9) || 221 215 hdr->din_xfer_len > (q->max_sectors << 9)) ··· 304 302 } 305 303 return rq; 306 304 out: 305 + if (rq->cmd != rq->__cmd) 306 + kfree(rq->cmd); 307 307 blk_put_request(rq); 308 308 if (next_rq) { 309 309 blk_rq_unmap_user(next_rq->bio); ··· 459 455 ret = rq->errors; 460 456 461 457 blk_rq_unmap_user(bio); 458 + if (rq->cmd != rq->__cmd) 459 + kfree(rq->cmd); 462 460 blk_put_request(rq); 463 461 464 462 return ret;
+2 -3
block/scsi_ioctl.c
··· 33 33 #include <scsi/scsi_cmnd.h> 34 34 35 35 /* Command group 3 is reserved and should never be used. */ 36 - const unsigned char scsi_command_size[8] = 36 + const unsigned char scsi_command_size_tbl[8] = 37 37 { 38 38 6, 10, 10, 12, 39 39 16, 12, 10, 10 40 40 }; 41 - 42 - EXPORT_SYMBOL(scsi_command_size); 41 + EXPORT_SYMBOL(scsi_command_size_tbl); 43 42 44 43 #include <scsi/sg.h> 45 44
+1 -1
drivers/firewire/fw-sbp2.c
··· 1487 1487 if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0) 1488 1488 goto out; 1489 1489 1490 - memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd)); 1490 + memcpy(orb->request.command_block, cmd->cmnd, cmd->cmd_len); 1491 1491 1492 1492 orb->base.callback = complete_command_orb; 1493 1493 orb->base.request_bus =
+1 -1
drivers/s390/scsi/zfcp_dbf.c
··· 1055 1055 rec->scsi_result = scsi_cmnd->result; 1056 1056 rec->scsi_cmnd = (unsigned long)scsi_cmnd; 1057 1057 rec->scsi_serial = scsi_cmnd->serial_number; 1058 - memcpy(rec->scsi_opcode, &scsi_cmnd->cmnd, 1058 + memcpy(rec->scsi_opcode, scsi_cmnd->cmnd, 1059 1059 min((int)scsi_cmnd->cmd_len, 1060 1060 ZFCP_DBF_SCSI_OPCODE)); 1061 1061 rec->scsi_retries = scsi_cmnd->retries;
+1 -1
drivers/s390/scsi/zfcp_fsf.c
··· 4014 4014 ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n", 4015 4015 scpnt->result); 4016 4016 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, 4017 - (void *) &scpnt->cmnd, scpnt->cmd_len); 4017 + scpnt->cmnd, scpnt->cmd_len); 4018 4018 4019 4019 ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n", 4020 4020 fcp_rsp_iu->fcp_sns_len);
+3 -3
drivers/scsi/53c700.c
··· 599 599 (struct NCR_700_command_slot *)SCp->host_scribble; 600 600 601 601 dma_unmap_single(hostdata->dev, slot->pCmd, 602 - sizeof(SCp->cmnd), DMA_TO_DEVICE); 602 + MAX_COMMAND_SIZE, DMA_TO_DEVICE); 603 603 if (slot->flags == NCR_700_FLAG_AUTOSENSE) { 604 604 char *cmnd = NCR_700_get_sense_cmnd(SCp->device); 605 605 #ifdef NCR_700_DEBUG ··· 1004 1004 * here */ 1005 1005 NCR_700_unmap(hostdata, SCp, slot); 1006 1006 dma_unmap_single(hostdata->dev, slot->pCmd, 1007 - sizeof(SCp->cmnd), 1007 + MAX_COMMAND_SIZE, 1008 1008 DMA_TO_DEVICE); 1009 1009 1010 1010 cmnd[0] = REQUEST_SENSE; ··· 1901 1901 } 1902 1902 slot->resume_offset = 0; 1903 1903 slot->pCmd = dma_map_single(hostdata->dev, SCp->cmnd, 1904 - sizeof(SCp->cmnd), DMA_TO_DEVICE); 1904 + MAX_COMMAND_SIZE, DMA_TO_DEVICE); 1905 1905 NCR_700_start_command(SCp); 1906 1906 return 0; 1907 1907 }
+1 -2
drivers/scsi/Kconfig
··· 504 504 source "drivers/scsi/aic7xxx/Kconfig.aic79xx" 505 505 source "drivers/scsi/aic94xx/Kconfig" 506 506 507 - # All the I2O code and drivers do not seem to be 64bit safe. 508 507 config SCSI_DPT_I2O 509 508 tristate "Adaptec I2O RAID support " 510 - depends on !64BIT && SCSI && PCI && VIRT_TO_BUS 509 + depends on SCSI && PCI && VIRT_TO_BUS 511 510 help 512 511 This driver supports all of Adaptec's I2O based RAID controllers as 513 512 well as the DPT SmartRaid V cards. This is an Adaptec maintained
+1 -1
drivers/scsi/a100u2w.c
··· 895 895 } else { 896 896 scb->tag_msg = 0; /* No tag support */ 897 897 } 898 - memcpy(&scb->cdb[0], &cmd->cmnd, scb->cdb_len); 898 + memcpy(scb->cdb, cmd->cmnd, scb->cdb_len); 899 899 } 900 900 901 901 /**
+125 -8
drivers/scsi/aacraid/aachba.c
··· 498 498 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && 499 499 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { 500 500 fsa_dev_ptr->valid = 1; 501 + /* sense_key holds the current state of the spin-up */ 502 + if (dresp->mnt[0].state & cpu_to_le32(FSCS_NOT_READY)) 503 + fsa_dev_ptr->sense_data.sense_key = NOT_READY; 504 + else if (fsa_dev_ptr->sense_data.sense_key == NOT_READY) 505 + fsa_dev_ptr->sense_data.sense_key = NO_SENSE; 501 506 fsa_dev_ptr->type = le32_to_cpu(dresp->mnt[0].vol); 502 507 fsa_dev_ptr->size 503 508 = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + ··· 1514 1509 scsi_dma_unmap(scsicmd); 1515 1510 1516 1511 readreply = (struct aac_read_reply *)fib_data(fibptr); 1517 - if (le32_to_cpu(readreply->status) == ST_OK) 1518 - scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 1519 - else { 1512 + switch (le32_to_cpu(readreply->status)) { 1513 + case ST_OK: 1514 + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | 1515 + SAM_STAT_GOOD; 1516 + dev->fsa_dev[cid].sense_data.sense_key = NO_SENSE; 1517 + break; 1518 + case ST_NOT_READY: 1519 + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | 1520 + SAM_STAT_CHECK_CONDITION; 1521 + set_sense(&dev->fsa_dev[cid].sense_data, NOT_READY, 1522 + SENCODE_BECOMING_READY, ASENCODE_BECOMING_READY, 0, 0); 1523 + memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1524 + min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), 1525 + SCSI_SENSE_BUFFERSIZE)); 1526 + break; 1527 + default: 1520 1528 #ifdef AAC_DETAILED_STATUS_INFO 1521 1529 printk(KERN_WARNING "io_callback: io failed, status = %d\n", 1522 1530 le32_to_cpu(readreply->status)); 1523 1531 #endif 1524 - scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 1532 + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | 1533 + SAM_STAT_CHECK_CONDITION; 1525 1534 set_sense(&dev->fsa_dev[cid].sense_data, 1526 1535 HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, 1527 1536 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); 1528 1537 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1529 1538 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), 1530 1539 SCSI_SENSE_BUFFERSIZE)); 1540 + break; 1531 1541 } 1532 1542 aac_fib_complete(fibptr); 1533 1543 aac_fib_free(fibptr); ··· 1883 1863 return SCSI_MLQUEUE_HOST_BUSY; 1884 1864 } 1885 1865 1866 + static void aac_start_stop_callback(void *context, struct fib *fibptr) 1867 + { 1868 + struct scsi_cmnd *scsicmd = context; 1869 + 1870 + if (!aac_valid_context(scsicmd, fibptr)) 1871 + return; 1872 + 1873 + BUG_ON(fibptr == NULL); 1874 + 1875 + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 1876 + 1877 + aac_fib_complete(fibptr); 1878 + aac_fib_free(fibptr); 1879 + scsicmd->scsi_done(scsicmd); 1880 + } 1881 + 1882 + static int aac_start_stop(struct scsi_cmnd *scsicmd) 1883 + { 1884 + int status; 1885 + struct fib *cmd_fibcontext; 1886 + struct aac_power_management *pmcmd; 1887 + struct scsi_device *sdev = scsicmd->device; 1888 + struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata; 1889 + 1890 + if (!(aac->supplement_adapter_info.SupportedOptions2 & 1891 + AAC_OPTION_POWER_MANAGEMENT)) { 1892 + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | 1893 + SAM_STAT_GOOD; 1894 + scsicmd->scsi_done(scsicmd); 1895 + return 0; 1896 + } 1897 + 1898 + if (aac->in_reset) 1899 + return SCSI_MLQUEUE_HOST_BUSY; 1900 + 1901 + /* 1902 + * Allocate and initialize a Fib 1903 + */ 1904 + cmd_fibcontext = aac_fib_alloc(aac); 1905 + if (!cmd_fibcontext) 1906 + return SCSI_MLQUEUE_HOST_BUSY; 1907 + 1908 + aac_fib_init(cmd_fibcontext); 1909 + 1910 + pmcmd = fib_data(cmd_fibcontext); 1911 + pmcmd->command = cpu_to_le32(VM_ContainerConfig); 1912 + pmcmd->type = cpu_to_le32(CT_POWER_MANAGEMENT); 1913 + /* Eject bit ignored, not relevant */ 1914 + pmcmd->sub = (scsicmd->cmnd[4] & 1) ? 1915 + cpu_to_le32(CT_PM_START_UNIT) : cpu_to_le32(CT_PM_STOP_UNIT); 1916 + pmcmd->cid = cpu_to_le32(sdev_id(sdev)); 1917 + pmcmd->parm = (scsicmd->cmnd[1] & 1) ? 1918 + cpu_to_le32(CT_PM_UNIT_IMMEDIATE) : 0; 1919 + 1920 + /* 1921 + * Now send the Fib to the adapter 1922 + */ 1923 + status = aac_fib_send(ContainerCommand, 1924 + cmd_fibcontext, 1925 + sizeof(struct aac_power_management), 1926 + FsaNormal, 1927 + 0, 1, 1928 + (fib_callback)aac_start_stop_callback, 1929 + (void *)scsicmd); 1930 + 1931 + /* 1932 + * Check that the command queued to the controller 1933 + */ 1934 + if (status == -EINPROGRESS) { 1935 + scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; 1936 + return 0; 1937 + } 1938 + 1939 + aac_fib_complete(cmd_fibcontext); 1940 + aac_fib_free(cmd_fibcontext); 1941 + return SCSI_MLQUEUE_HOST_BUSY; 1942 + } 1943 + 1886 1944 /** 1887 1945 * aac_scsi_cmd() - Process SCSI command 1888 1946 * @scsicmd: SCSI command block ··· 1997 1899 * If the target container doesn't exist, it may have 1998 1900 * been newly created 1999 1901 */ 2000 - if ((fsa_dev_ptr[cid].valid & 1) == 0) { 1902 + if (((fsa_dev_ptr[cid].valid & 1) == 0) || 1903 + (fsa_dev_ptr[cid].sense_data.sense_key == 1904 + NOT_READY)) { 2001 1905 switch (scsicmd->cmnd[0]) { 2002 1906 case SERVICE_ACTION_IN: 2003 1907 if (!(dev->raw_io_interface) || ··· 2191 2091 scsi_sg_copy_from_buffer(scsicmd, cp, sizeof(cp)); 2192 2092 /* Do not cache partition table for arrays */ 2193 2093 scsicmd->device->removable = 1; 2194 - 2195 - scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 2094 + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | 2095 + SAM_STAT_GOOD; 2196 2096 scsicmd->scsi_done(scsicmd); 2197 2097 2198 2098 return 0; ··· 2287 2187 * These commands are all No-Ops 2288 2188 */ 2289 2189 case TEST_UNIT_READY: 2190 + if (fsa_dev_ptr[cid].sense_data.sense_key == NOT_READY) { 2191 + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | 2192 + SAM_STAT_CHECK_CONDITION; 2193 + set_sense(&dev->fsa_dev[cid].sense_data, 2194 + NOT_READY, SENCODE_BECOMING_READY, 2195 + ASENCODE_BECOMING_READY, 0, 0); 2196 + memcpy(scsicmd->sense_buffer, 2197 + &dev->fsa_dev[cid].sense_data, 2198 + min_t(size_t, 2199 + sizeof(dev->fsa_dev[cid].sense_data), 2200 + SCSI_SENSE_BUFFERSIZE)); 2201 + scsicmd->scsi_done(scsicmd); 2202 + return 0; 2203 + } 2204 + /* FALLTHRU */ 2290 2205 case RESERVE: 2291 2206 case RELEASE: 2292 2207 case REZERO_UNIT: 2293 2208 case REASSIGN_BLOCKS: 2294 2209 case SEEK_10: 2295 - case START_STOP: 2296 2210 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 2297 2211 scsicmd->scsi_done(scsicmd); 2298 2212 return 0; 2213 + 2214 + case START_STOP: 2215 + return aac_start_stop(scsicmd); 2299 2216 } 2300 2217 2301 2218 switch (scsicmd->cmnd[0])
+23 -5
drivers/scsi/aacraid/aacraid.h
··· 12 12 *----------------------------------------------------------------------------*/ 13 13 14 14 #ifndef AAC_DRIVER_BUILD 15 - # define AAC_DRIVER_BUILD 2455 15 + # define AAC_DRIVER_BUILD 2456 16 16 # define AAC_DRIVER_BRANCH "-ms" 17 17 #endif 18 18 #define MAXIMUM_NUM_CONTAINERS 32 ··· 34 34 #define CONTAINER_TO_ID(cont) (cont) 35 35 #define CONTAINER_TO_LUN(cont) (0) 36 36 37 - #define aac_phys_to_logical(x) (x+1) 38 - #define aac_logical_to_phys(x) (x?x-1:0) 37 + #define aac_phys_to_logical(x) ((x)+1) 38 + #define aac_logical_to_phys(x) ((x)?(x)-1:0) 39 39 40 40 /* #define AAC_DETAILED_STATUS_INFO */ 41 41 ··· 424 424 */ 425 425 __le32 InitFlags; /* flags for supported features */ 426 426 #define INITFLAGS_NEW_COMM_SUPPORTED 0x00000001 427 + #define INITFLAGS_DRIVER_USES_UTC_TIME 0x00000010 428 + #define INITFLAGS_DRIVER_SUPPORTS_PM 0x00000020 427 429 __le32 MaxIoCommands; /* max outstanding commands */ 428 430 __le32 MaxIoSize; /* largest I/O command */ 429 431 __le32 MaxFibSize; /* largest FIB to adapter */ ··· 869 867 }; 870 868 #define AAC_FEATURE_FALCON cpu_to_le32(0x00000010) 871 869 #define AAC_FEATURE_JBOD cpu_to_le32(0x08000000) 872 - #define AAC_OPTION_MU_RESET cpu_to_le32(0x00000001) 873 - #define AAC_OPTION_IGNORE_RESET cpu_to_le32(0x00000002) 870 + /* SupportedOptions2 */ 871 + #define AAC_OPTION_MU_RESET cpu_to_le32(0x00000001) 872 + #define AAC_OPTION_IGNORE_RESET cpu_to_le32(0x00000002) 873 + #define AAC_OPTION_POWER_MANAGEMENT cpu_to_le32(0x00000004) 874 874 #define AAC_SIS_VERSION_V3 3 875 875 #define AAC_SIS_SLOT_UNKNOWN 0xFF 876 876 ··· 1152 1148 #define ST_DQUOT 69 1153 1149 #define ST_STALE 70 1154 1150 #define ST_REMOTE 71 1151 + #define ST_NOT_READY 72 1155 1152 #define ST_BADHANDLE 10001 1156 1153 #define ST_NOT_SYNC 10002 1157 1154 #define ST_BAD_COOKIE 10003 ··· 1272 1267 __le32 parm4; 1273 1268 __le32 parm5; 1274 1269 u8 data[16]; 1270 + }; 1271 + 1272 + #define CT_POWER_MANAGEMENT 245 1273 + #define CT_PM_START_UNIT 2 1274 + #define CT_PM_STOP_UNIT 3 1275 + #define CT_PM_UNIT_IMMEDIATE 1 1276 + struct aac_power_management { 1277 + __le32 command; /* VM_ContainerConfig */ 1278 + __le32 type; /* CT_POWER_MANAGEMENT */ 1279 + __le32 sub; /* CT_PM_* */ 1280 + __le32 cid; 1281 + __le32 parm; /* CT_PM_sub_* */ 1275 1282 }; 1276 1283 1277 1284 #define CT_PAUSE_IO 65 ··· 1553 1536 #define FSCS_NOTCLEAN 0x0001 /* fsck is necessary before mounting */ 1554 1537 #define FSCS_READONLY 0x0002 /* possible result of broken mirror */ 1555 1538 #define FSCS_HIDDEN 0x0004 /* should be ignored - set during a clear */ 1539 + #define FSCS_NOT_READY 0x0008 /* Array spinning up to fulfil request */ 1556 1540 1557 1541 struct aac_query_mount { 1558 1542 __le32 command;
+2
drivers/scsi/aacraid/comminit.c
··· 97 97 init->InitFlags = cpu_to_le32(INITFLAGS_NEW_COMM_SUPPORTED); 98 98 dprintk((KERN_WARNING"aacraid: New Comm Interface enabled\n")); 99 99 } 100 + init->InitFlags |= cpu_to_le32(INITFLAGS_DRIVER_USES_UTC_TIME | 101 + INITFLAGS_DRIVER_SUPPORTS_PM); 100 102 init->MaxIoCommands = cpu_to_le32(dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); 101 103 init->MaxIoSize = cpu_to_le32(dev->scsi_host_ptr->max_sectors << 9); 102 104 init->MaxFibSize = cpu_to_le32(dev->max_fib_size);
+26 -8
drivers/scsi/aacraid/commsup.c
··· 515 515 } 516 516 udelay(5); 517 517 } 518 - } else if (down_interruptible(&fibptr->event_wait) == 0) { 518 + } else if (down_interruptible(&fibptr->event_wait)) { 519 519 fibptr->done = 2; 520 520 up(&fibptr->event_wait); 521 521 } ··· 906 906 case AifEnAddJBOD: 907 907 case AifEnDeleteJBOD: 908 908 container = le32_to_cpu(((__le32 *)aifcmd->data)[1]); 909 - if ((container >> 28)) 909 + if ((container >> 28)) { 910 + container = (u32)-1; 910 911 break; 912 + } 911 913 channel = (container >> 24) & 0xF; 912 - if (channel >= dev->maximum_num_channels) 914 + if (channel >= dev->maximum_num_channels) { 915 + container = (u32)-1; 913 916 break; 917 + } 914 918 id = container & 0xFFFF; 915 - if (id >= dev->maximum_num_physicals) 919 + if (id >= dev->maximum_num_physicals) { 920 + container = (u32)-1; 916 921 break; 922 + } 917 923 lun = (container >> 16) & 0xFF; 924 + container = (u32)-1; 918 925 channel = aac_phys_to_logical(channel); 919 926 device_config_needed = 920 927 (((__le32 *)aifcmd->data)[0] == ··· 940 933 case EM_DRIVE_REMOVAL: 941 934 container = le32_to_cpu( 942 935 ((__le32 *)aifcmd->data)[2]); 943 - if ((container >> 28)) 936 + if ((container >> 28)) { 937 + container = (u32)-1; 944 938 break; 939 + } 945 940 channel = (container >> 24) & 0xF; 946 - if (channel >= dev->maximum_num_channels) 941 + if (channel >= dev->maximum_num_channels) { 942 + container = (u32)-1; 947 943 break; 944 + } 948 945 id = container & 0xFFFF; 949 946 lun = (container >> 16) & 0xFF; 947 + container = (u32)-1; 950 948 if (id >= dev->maximum_num_physicals) { 951 949 /* legacy dev_t ? */ 952 950 if ((0x2000 <= id) || lun || channel || ··· 1037 1025 break; 1038 1026 } 1039 1027 1028 + container = 0; 1029 + retry_next: 1040 1030 if (device_config_needed == NOTHING) 1041 - for (container = 0; container < dev->maximum_num_containers; 1042 - ++container) { 1031 + for (; container < dev->maximum_num_containers; ++container) { 1043 1032 if ((dev->fsa_dev[container].config_waiting_on == 0) && 1044 1033 (dev->fsa_dev[container].config_needed != NOTHING) && 1045 1034 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT)) { ··· 1123 1110 } 1124 1111 if (device_config_needed == ADD) 1125 1112 scsi_add_device(dev->scsi_host_ptr, channel, id, lun); 1113 + if (channel == CONTAINER_CHANNEL) { 1114 + container++; 1115 + device_config_needed = NOTHING; 1116 + goto retry_next; 1117 + } 1126 1118 } 1127 1119 1128 1120 static int _aac_reset_adapter(struct aac_dev *aac, int forced)
+15 -7
drivers/scsi/aacraid/linit.c
··· 401 401 static int aac_slave_configure(struct scsi_device *sdev) 402 402 { 403 403 struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata; 404 + if (aac->jbod && (sdev->type == TYPE_DISK)) 405 + sdev->removable = 1; 404 406 if ((sdev->type == TYPE_DISK) && 405 407 (sdev_channel(sdev) != CONTAINER_CHANNEL) && 406 408 (!aac->jbod || sdev->inq_periph_qual) && ··· 811 809 "SAI_READ_CAPACITY_16\n"); 812 810 if (dev->jbod) 813 811 len += snprintf(buf + len, PAGE_SIZE - len, "SUPPORTED_JBOD\n"); 812 + if (dev->supplement_adapter_info.SupportedOptions2 & 813 + AAC_OPTION_POWER_MANAGEMENT) 814 + len += snprintf(buf + len, PAGE_SIZE - len, 815 + "SUPPORTED_POWER_MANAGEMENT\n"); 816 + if (dev->msi) 817 + len += snprintf(buf + len, PAGE_SIZE - len, "PCI_HAS_MSI\n"); 814 818 return len; 815 819 } 816 820 ··· 1114 1106 aac->pdev = pdev; 1115 1107 aac->name = aac_driver_template.name; 1116 1108 aac->id = shost->unique_id; 1117 - aac->cardtype = index; 1109 + aac->cardtype = index; 1118 1110 INIT_LIST_HEAD(&aac->entry); 1119 1111 1120 1112 aac->fibs = kmalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL); ··· 1154 1146 goto out_deinit; 1155 1147 1156 1148 /* 1157 - * Lets override negotiations and drop the maximum SG limit to 34 1158 - */ 1149 + * Lets override negotiations and drop the maximum SG limit to 34 1150 + */ 1159 1151 if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) && 1160 1152 (shost->sg_tablesize > 34)) { 1161 1153 shost->sg_tablesize = 34; 1162 1154 shost->max_sectors = (shost->sg_tablesize * 8) + 112; 1163 - } 1155 + } 1164 1156 1165 - if ((aac_drivers[index].quirks & AAC_QUIRK_17SG) && 1157 + if ((aac_drivers[index].quirks & AAC_QUIRK_17SG) && 1166 1158 (shost->sg_tablesize > 17)) { 1167 1159 shost->sg_tablesize = 17; 1168 1160 shost->max_sectors = (shost->sg_tablesize * 8) + 112; 1169 - } 1161 + } 1170 1162 1171 1163 error = pci_set_dma_max_seg_size(pdev, 1172 1164 (aac->adapter_info.options & AAC_OPT_NEW_COMM) ? ··· 1182 1174 else 1183 1175 aac->printf_enabled = 0; 1184 1176 1185 - /* 1177 + /* 1186 1178 * max channel will be the physical channels plus 1 virtual channel 1187 1179 * all containers are on the virtual channel 0 (CONTAINER_CHANNEL) 1188 1180 * physical channels are address by their actual physical number+1
+3 -3
drivers/scsi/aic94xx/aic94xx_init.c
··· 529 529 /* The first entry, 0, is used for dynamic ids, the rest for devices 530 530 * we know about. 531 531 */ 532 - static struct asd_pcidev_struct { 532 + static const struct asd_pcidev_struct { 533 533 const char * name; 534 534 int (*setup)(struct asd_ha_struct *asd_ha); 535 - } asd_pcidev_data[] = { 535 + } asd_pcidev_data[] __devinitconst = { 536 536 /* Id 0 is used for dynamic ids. */ 537 537 { .name = "Adaptec AIC-94xx SAS/SATA Host Adapter", 538 538 .setup = asd_aic9410_setup ··· 735 735 static int __devinit asd_pci_probe(struct pci_dev *dev, 736 736 const struct pci_device_id *id) 737 737 { 738 - struct asd_pcidev_struct *asd_dev; 738 + const struct asd_pcidev_struct *asd_dev; 739 739 unsigned asd_id = (unsigned) id->driver_data; 740 740 struct asd_ha_struct *asd_ha; 741 741 struct Scsi_Host *shost;
+3 -7
drivers/scsi/constants.c
··· 28 28 #define SERVICE_ACTION_OUT_12 0xa9 29 29 #define SERVICE_ACTION_IN_16 0x9e 30 30 #define SERVICE_ACTION_OUT_16 0x9f 31 - #define VARIABLE_LENGTH_CMD 0x7f 32 31 33 32 34 33 ··· 209 210 cdb0 = cdbp[0]; 210 211 switch(cdb0) { 211 212 case VARIABLE_LENGTH_CMD: 212 - len = cdbp[7] + 8; 213 + len = scsi_varlen_cdb_length(cdbp); 213 214 if (len < 10) { 214 215 printk("short variable length command, " 215 216 "len=%d ext_len=%d", len, cdb_len); ··· 299 300 cdb0 = cdbp[0]; 300 301 switch(cdb0) { 301 302 case VARIABLE_LENGTH_CMD: 302 - len = cdbp[7] + 8; 303 + len = scsi_varlen_cdb_length(cdbp); 303 304 if (len < 10) { 304 305 printk("short opcode=0x%x command, len=%d " 305 306 "ext_len=%d", cdb0, len, cdb_len); ··· 334 335 int k, len; 335 336 336 337 print_opcode_name(cdb, 0); 337 - if (VARIABLE_LENGTH_CMD == cdb[0]) 338 - len = cdb[7] + 8; 339 - else 340 - len = COMMAND_SIZE(cdb[0]); 338 + len = scsi_command_size(cdb); 341 339 /* print out all bytes in cdb */ 342 340 for (k = 0; k < len; ++k) 343 341 printk(" %02x", cdb[k]);
+8 -8
drivers/scsi/dpt/dpti_ioctl.h
··· 89 89 int njobs; /* # of jobs sent to HA */ 90 90 int qdepth; /* Controller queue depth. */ 91 91 int wakebase; /* mpx wakeup base index. */ 92 - uLONG SGsize; /* Scatter/Gather list size. */ 92 + uINT SGsize; /* Scatter/Gather list size. */ 93 93 unsigned heads; /* heads for drives on cntlr. */ 94 94 unsigned sectors; /* sectors for drives on cntlr. */ 95 95 uCHAR do_drive32; /* Flag for Above 16 MB Ability */ ··· 97 97 char idPAL[4]; /* 4 Bytes Of The ID Pal */ 98 98 uCHAR primary; /* 1 For Primary, 0 For Secondary */ 99 99 uCHAR eataVersion; /* EATA Version */ 100 - uLONG cpLength; /* EATA Command Packet Length */ 101 - uLONG spLength; /* EATA Status Packet Length */ 100 + uINT cpLength; /* EATA Command Packet Length */ 101 + uINT spLength; /* EATA Status Packet Length */ 102 102 uCHAR drqNum; /* DRQ Index (0,5,6,7) */ 103 103 uCHAR flag1; /* EATA Flags 1 (Byte 9) */ 104 104 uCHAR flag2; /* EATA Flags 2 (Byte 30) */ ··· 107 107 typedef struct { 108 108 uSHORT length; // Remaining length of this 109 109 uSHORT drvrHBAnum; // Relative HBA # used by the driver 110 - uLONG baseAddr; // Base I/O address 110 + uINT baseAddr; // Base I/O address 111 111 uSHORT blinkState; // Blink LED state (0=Not in blink LED) 112 112 uCHAR pciBusNum; // PCI Bus # (Optional) 113 113 uCHAR pciDeviceNum; // PCI Device # (Optional) 114 114 uSHORT hbaFlags; // Miscellaneous HBA flags 115 115 uSHORT Interrupt; // Interrupt set for this device. 116 116 # if (defined(_DPT_ARC)) 117 - uLONG baseLength; 117 + uINT baseLength; 118 118 ADAPTER_OBJECT *AdapterObject; 119 119 LARGE_INTEGER DmaLogicalAddress; 120 120 PVOID DmaVirtualAddress; 121 121 LARGE_INTEGER ReplyLogicalAddress; 122 122 PVOID ReplyVirtualAddress; 123 123 # else 124 - uLONG reserved1; // Reserved for future expansion 125 - uLONG reserved2; // Reserved for future expansion 126 - uLONG reserved3; // Reserved for future expansion 124 + uINT reserved1; // Reserved for future expansion 125 + uINT reserved2; // Reserved for future expansion 126 + uINT reserved3; // Reserved for future expansion 127 127 # endif 128 128 } drvrHBAinfo_S; 129 129
+2 -6
drivers/scsi/dpt/dptsig.h
··· 33 33 /* to make sure we are talking the same size under all OS's */ 34 34 typedef unsigned char sigBYTE; 35 35 typedef unsigned short sigWORD; 36 - #if (defined(_MULTI_DATAMODEL) && defined(sun) && !defined(_ILP32)) 37 - typedef uint32_t sigLONG; 38 - #else 39 - typedef unsigned long sigLONG; 40 - #endif 36 + typedef unsigned int sigINT; 41 37 42 38 /* 43 39 * use sigWORDLittleEndian for: ··· 296 300 sigBYTE dsFiletype; /* type of file */ 297 301 sigBYTE dsFiletypeFlags; /* flags to specify load type, etc. */ 298 302 sigBYTE dsOEM; /* OEM file was created for */ 299 - sigLONG dsOS; /* which Operating systems */ 303 + sigINT dsOS; /* which Operating systems */ 300 304 sigWORD dsCapabilities; /* RAID levels, etc. */ 301 305 sigWORD dsDeviceSupp; /* Types of SCSI devices supported */ 302 306 sigWORD dsAdapterSupp; /* DPT adapter families supported */
+2 -2
drivers/scsi/dpt/sys_info.h
··· 145 145 uCHAR smartROMRevision; 146 146 uSHORT flags; /* See bit definitions above */ 147 147 uSHORT conventionalMemSize; /* in KB */ 148 - uLONG extendedMemSize; /* in KB */ 149 - uLONG osType; /* Same as DPTSIG's definition */ 148 + uINT extendedMemSize; /* in KB */ 149 + uINT osType; /* Same as DPTSIG's definition */ 150 150 uCHAR osMajorVersion; 151 151 uCHAR osMinorVersion; /* The OS version */ 152 152 uCHAR osRevision;
+482 -158
drivers/scsi/dpt_i2o.c
··· 29 29 /*#define DEBUG 1 */ 30 30 /*#define UARTDELAY 1 */ 31 31 32 - /* On the real kernel ADDR32 should always be zero for 2.4. GFP_HIGH allocates 33 - high pages. Keep the macro around because of the broken unmerged ia64 tree */ 34 - 35 - #define ADDR32 (0) 36 - 37 32 #include <linux/module.h> 38 33 39 34 MODULE_AUTHOR("Deanna Bonds, with _lots_ of help from Mark Salyzyn"); ··· 103 108 104 109 static DEFINE_MUTEX(adpt_configuration_lock); 105 110 106 - static struct i2o_sys_tbl *sys_tbl = NULL; 107 - static int sys_tbl_ind = 0; 108 - static int sys_tbl_len = 0; 111 + static struct i2o_sys_tbl *sys_tbl; 112 + static dma_addr_t sys_tbl_pa; 113 + static int sys_tbl_ind; 114 + static int sys_tbl_len; 109 115 110 116 static adpt_hba* hba_chain = NULL; 111 117 static int hba_count = 0; 112 118 119 + static struct class *adpt_sysfs_class; 120 + 121 + #ifdef CONFIG_COMPAT 122 + static long compat_adpt_ioctl(struct file *, unsigned int, unsigned long); 123 + #endif 124 + 113 125 static const struct file_operations adpt_fops = { 114 126 .ioctl = adpt_ioctl, 115 127 .open = adpt_open, 116 - .release = adpt_close 117 - }; 118 - 119 - #ifdef REBOOT_NOTIFIER 120 - static struct notifier_block adpt_reboot_notifier = 121 - { 122 - adpt_reboot_event, 123 - NULL, 124 - 0 125 - }; 128 + .release = adpt_close, 129 + #ifdef CONFIG_COMPAT 130 + .compat_ioctl = compat_adpt_ioctl, 126 131 #endif 132 + }; 127 133 128 134 /* Structures and definitions for synchronous message posting. 129 135 * See adpt_i2o_post_wait() for description ··· 146 150 * Functions 147 151 *============================================================================ 148 152 */ 153 + 154 + static inline int dpt_dma64(adpt_hba *pHba) 155 + { 156 + return (sizeof(dma_addr_t) > 4 && (pHba)->dma64); 157 + } 158 + 159 + static inline u32 dma_high(dma_addr_t addr) 160 + { 161 + return upper_32_bits(addr); 162 + } 163 + 164 + static inline u32 dma_low(dma_addr_t addr) 165 + { 166 + return (u32)addr; 167 + } 149 168 150 169 static u8 adpt_read_blink_led(adpt_hba* host) 151 170 { ··· 188 177 { 189 178 struct pci_dev *pDev = NULL; 190 179 adpt_hba* pHba; 191 - 192 - adpt_init(); 193 180 194 181 PINFO("Detecting Adaptec I2O RAID controllers...\n"); 195 182 ··· 256 247 adpt_inquiry(pHba); 257 248 } 258 249 250 + adpt_sysfs_class = class_create(THIS_MODULE, "dpt_i2o"); 251 + if (IS_ERR(adpt_sysfs_class)) { 252 + printk(KERN_WARNING"dpti: unable to create dpt_i2o class\n"); 253 + adpt_sysfs_class = NULL; 254 + } 255 + 259 256 for (pHba = hba_chain; pHba; pHba = pHba->next) { 260 - if( adpt_scsi_register(pHba,sht) < 0){ 257 + if (adpt_scsi_host_alloc(pHba, sht) < 0){ 261 258 adpt_i2o_delete_hba(pHba); 262 259 continue; 263 260 } 264 261 pHba->initialized = TRUE; 265 262 pHba->state &= ~DPTI_STATE_RESET; 263 + if (adpt_sysfs_class) { 264 + struct device *dev = device_create(adpt_sysfs_class, 265 + NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), 266 + "dpti%d", pHba->unit); 267 + if (IS_ERR(dev)) { 268 + printk(KERN_WARNING"dpti%d: unable to " 269 + "create device in dpt_i2o class\n", 270 + pHba->unit); 271 + } 272 + } 266 273 } 267 274 268 275 // Register our control device node ··· 307 282 308 283 static void adpt_inquiry(adpt_hba* pHba) 309 284 { 310 - u32 msg[14]; 285 + u32 msg[17]; 311 286 u32 *mptr; 312 287 u32 *lenptr; 313 288 int direction; ··· 315 290 u32 len; 316 291 u32 reqlen; 317 292 u8* buf; 293 + dma_addr_t addr; 318 294 u8 scb[16]; 319 295 s32 rcode; 320 296 321 297 memset(msg, 0, sizeof(msg)); 322 - buf = kmalloc(80,GFP_KERNEL|ADDR32); 298 + buf = dma_alloc_coherent(&pHba->pDev->dev, 80, &addr, GFP_KERNEL); 323 299 if(!buf){ 324 300 printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name); 325 301 return; ··· 331 305 direction = 0x00000000; 332 306 scsidir =0x40000000; // DATA IN (iop<--dev) 333 307 334 - reqlen = 14; // SINGLE SGE 308 + if (dpt_dma64(pHba)) 309 + reqlen = 17; // SINGLE SGE, 64 bit 310 + else 311 + reqlen = 14; // SINGLE SGE, 32 bit 335 312 /* Stick the headers on */ 336 313 msg[0] = reqlen<<16 | SGL_OFFSET_12; 337 314 msg[1] = (0xff<<24|HOST_TID<<12|ADAPTER_TID); ··· 367 338 368 339 /* Now fill in the SGList and command */ 369 340 *lenptr = len; 370 - *mptr++ = 0xD0000000|direction|len; 371 - *mptr++ = virt_to_bus(buf); 341 + if (dpt_dma64(pHba)) { 342 + *mptr++ = (0x7C<<24)+(2<<16)+0x02; /* Enable 64 bit */ 343 + *mptr++ = 1 << PAGE_SHIFT; 344 + *mptr++ = 0xD0000000|direction|len; 345 + *mptr++ = dma_low(addr); 346 + *mptr++ = dma_high(addr); 347 + } else { 348 + *mptr++ = 0xD0000000|direction|len; 349 + *mptr++ = addr; 350 + } 372 351 373 352 // Send it on it's way 374 353 rcode = adpt_i2o_post_wait(pHba, msg, reqlen<<2, 120); ··· 384 347 sprintf(pHba->detail, "Adaptec I2O RAID"); 385 348 printk(KERN_INFO "%s: Inquiry Error (%d)\n",pHba->name,rcode); 386 349 if (rcode != -ETIME && rcode != -EINTR) 387 - kfree(buf); 350 + dma_free_coherent(&pHba->pDev->dev, 80, buf, addr); 388 351 } else { 389 352 memset(pHba->detail, 0, sizeof(pHba->detail)); 390 353 memcpy(&(pHba->detail), "Vendor: Adaptec ", 16); ··· 393 356 memcpy(&(pHba->detail[40]), " FW: ", 4); 394 357 memcpy(&(pHba->detail[44]), (u8*) &buf[32], 4); 395 358 pHba->detail[48] = '\0'; /* precautionary */ 396 - kfree(buf); 359 + dma_free_coherent(&pHba->pDev->dev, 80, buf, addr); 397 360 } 398 361 adpt_i2o_status_get(pHba); 399 362 return ; ··· 669 632 return len; 670 633 } 671 634 635 + /* 636 + * Turn a struct scsi_cmnd * into a unique 32 bit 'context'. 637 + */ 638 + static u32 adpt_cmd_to_context(struct scsi_cmnd *cmd) 639 + { 640 + return (u32)cmd->serial_number; 641 + } 642 + 643 + /* 644 + * Go from a u32 'context' to a struct scsi_cmnd * . 645 + * This could probably be made more efficient. 646 + */ 647 + static struct scsi_cmnd * 648 + adpt_cmd_from_context(adpt_hba * pHba, u32 context) 649 + { 650 + struct scsi_cmnd * cmd; 651 + struct scsi_device * d; 652 + 653 + if (context == 0) 654 + return NULL; 655 + 656 + spin_unlock(pHba->host->host_lock); 657 + shost_for_each_device(d, pHba->host) { 658 + unsigned long flags; 659 + spin_lock_irqsave(&d->list_lock, flags); 660 + list_for_each_entry(cmd, &d->cmd_list, list) { 661 + if (((u32)cmd->serial_number == context)) { 662 + spin_unlock_irqrestore(&d->list_lock, flags); 663 + scsi_device_put(d); 664 + spin_lock(pHba->host->host_lock); 665 + return cmd; 666 + } 667 + } 668 + spin_unlock_irqrestore(&d->list_lock, flags); 669 + } 670 + spin_lock(pHba->host->host_lock); 671 + 672 + return NULL; 673 + } 674 + 675 + /* 676 + * Turn a pointer to ioctl reply data into an u32 'context' 677 + */ 678 + static u32 adpt_ioctl_to_context(adpt_hba * pHba, void *reply) 679 + { 680 + #if BITS_PER_LONG == 32 681 + return (u32)(unsigned long)reply; 682 + #else 683 + ulong flags = 0; 684 + u32 nr, i; 685 + 686 + spin_lock_irqsave(pHba->host->host_lock, flags); 687 + nr = ARRAY_SIZE(pHba->ioctl_reply_context); 688 + for (i = 0; i < nr; i++) { 689 + if (pHba->ioctl_reply_context[i] == NULL) { 690 + pHba->ioctl_reply_context[i] = reply; 691 + break; 692 + } 693 + } 694 + spin_unlock_irqrestore(pHba->host->host_lock, flags); 695 + if (i >= nr) { 696 + kfree (reply); 697 + printk(KERN_WARNING"%s: Too many outstanding " 698 + "ioctl commands\n", pHba->name); 699 + return (u32)-1; 700 + } 701 + 702 + return i; 703 + #endif 704 + } 705 + 706 + /* 707 + * Go from an u32 'context' to a pointer to ioctl reply data. 708 + */ 709 + static void *adpt_ioctl_from_context(adpt_hba *pHba, u32 context) 710 + { 711 + #if BITS_PER_LONG == 32 712 + return (void *)(unsigned long)context; 713 + #else 714 + void *p = pHba->ioctl_reply_context[context]; 715 + pHba->ioctl_reply_context[context] = NULL; 716 + 717 + return p; 718 + #endif 719 + } 672 720 673 721 /*=========================================================================== 674 722 * Error Handling routines ··· 782 660 msg[1] = I2O_CMD_SCSI_ABORT<<24|HOST_TID<<12|dptdevice->tid; 783 661 msg[2] = 0; 784 662 msg[3]= 0; 785 - msg[4] = (u32)cmd; 663 + msg[4] = adpt_cmd_to_context(cmd); 786 664 if (pHba->host) 787 665 spin_lock_irq(pHba->host->host_lock); 788 666 rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER); ··· 983 861 printk(KERN_INFO "Adaptec I2O controllers down.\n"); 984 862 } 985 863 986 - /* 987 - * reboot/shutdown notification. 988 - * 989 - * - Quiesce each IOP in the system 990 - * 991 - */ 992 - 993 - #ifdef REBOOT_NOTIFIER 994 - static int adpt_reboot_event(struct notifier_block *n, ulong code, void *p) 995 - { 996 - 997 - if(code != SYS_RESTART && code != SYS_HALT && code != SYS_POWER_OFF) 998 - return NOTIFY_DONE; 999 - 1000 - adpt_i2o_sys_shutdown(); 1001 - 1002 - return NOTIFY_DONE; 1003 - } 1004 - #endif 1005 - 1006 - 1007 864 static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) 1008 865 { 1009 866 ··· 994 893 u32 hba_map1_area_size = 0; 995 894 void __iomem *base_addr_virt = NULL; 996 895 void __iomem *msg_addr_virt = NULL; 896 + int dma64 = 0; 997 897 998 898 int raptorFlag = FALSE; 999 899 ··· 1008 906 } 1009 907 1010 908 pci_set_master(pDev); 1011 - if (pci_set_dma_mask(pDev, DMA_32BIT_MASK)) 909 + 910 + /* 911 + * See if we should enable dma64 mode. 912 + */ 913 + if (sizeof(dma_addr_t) > 4 && 914 + pci_set_dma_mask(pDev, DMA_64BIT_MASK) == 0) { 915 + if (dma_get_required_mask(&pDev->dev) > DMA_32BIT_MASK) 916 + dma64 = 1; 917 + } 918 + if (!dma64 && pci_set_dma_mask(pDev, DMA_32BIT_MASK) != 0) 1012 919 return -EINVAL; 920 + 921 + /* adapter only supports message blocks below 4GB */ 922 + pci_set_consistent_dma_mask(pDev, DMA_32BIT_MASK); 1013 923 1014 924 base_addr0_phys = pci_resource_start(pDev,0); 1015 925 hba_map0_area_size = pci_resource_len(pDev,0); ··· 1042 928 hba_map1_area_size = pci_resource_len(pDev,1); 1043 929 raptorFlag = TRUE; 1044 930 } 931 + 932 + #if BITS_PER_LONG == 64 933 + /* 934 + * The original Adaptec 64 bit driver has this comment here: 935 + * "x86_64 machines need more optimal mappings" 936 + * 937 + * I assume some HBAs report ridiculously large mappings 938 + * and we need to limit them on platforms with IOMMUs. 939 + */ 940 + if (raptorFlag == TRUE) { 941 + if (hba_map0_area_size > 128) 942 + hba_map0_area_size = 128; 943 + if (hba_map1_area_size > 524288) 944 + hba_map1_area_size = 524288; 945 + } else { 946 + if (hba_map0_area_size > 524288) 947 + hba_map0_area_size = 524288; 948 + } 949 + #endif 1045 950 1046 951 base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size); 1047 952 if (!base_addr_virt) { ··· 1124 991 pHba->state = DPTI_STATE_RESET; 1125 992 pHba->pDev = pDev; 1126 993 pHba->devices = NULL; 994 + pHba->dma64 = dma64; 1127 995 1128 996 // Initializing the spinlocks 1129 997 spin_lock_init(&pHba->state_lock); 1130 998 spin_lock_init(&adpt_post_wait_lock); 1131 999 1132 1000 if(raptorFlag == 0){ 1133 - printk(KERN_INFO"Adaptec I2O RAID controller %d at %p size=%x irq=%d\n", 1134 - hba_count-1, base_addr_virt, hba_map0_area_size, pDev->irq); 1001 + printk(KERN_INFO "Adaptec I2O RAID controller" 1002 + " %d at %p size=%x irq=%d%s\n", 1003 + hba_count-1, base_addr_virt, 1004 + hba_map0_area_size, pDev->irq, 1005 + dma64 ? " (64-bit DMA)" : ""); 1135 1006 } else { 1136 - printk(KERN_INFO"Adaptec I2O RAID controller %d irq=%d\n",hba_count-1, pDev->irq); 1007 + printk(KERN_INFO"Adaptec I2O RAID controller %d irq=%d%s\n", 1008 + hba_count-1, pDev->irq, 1009 + dma64 ? " (64-bit DMA)" : ""); 1137 1010 printk(KERN_INFO" BAR0 %p - size= %x\n",base_addr_virt,hba_map0_area_size); 1138 1011 printk(KERN_INFO" BAR1 %p - size= %x\n",msg_addr_virt,hba_map1_area_size); 1139 1012 } ··· 1192 1053 if(pHba->msg_addr_virt != pHba->base_addr_virt){ 1193 1054 iounmap(pHba->msg_addr_virt); 1194 1055 } 1195 - kfree(pHba->hrt); 1196 - kfree(pHba->lct); 1197 - kfree(pHba->status_block); 1198 - kfree(pHba->reply_pool); 1056 + if(pHba->FwDebugBuffer_P) 1057 + iounmap(pHba->FwDebugBuffer_P); 1058 + if(pHba->hrt) { 1059 + dma_free_coherent(&pHba->pDev->dev, 1060 + pHba->hrt->num_entries * pHba->hrt->entry_len << 2, 1061 + pHba->hrt, pHba->hrt_pa); 1062 + } 1063 + if(pHba->lct) { 1064 + dma_free_coherent(&pHba->pDev->dev, pHba->lct_size, 1065 + pHba->lct, pHba->lct_pa); 1066 + } 1067 + if(pHba->status_block) { 1068 + dma_free_coherent(&pHba->pDev->dev, sizeof(i2o_status_block), 1069 + pHba->status_block, pHba->status_block_pa); 1070 + } 1071 + if(pHba->reply_pool) { 1072 + dma_free_coherent(&pHba->pDev->dev, 1073 + pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, 1074 + pHba->reply_pool, pHba->reply_pool_pa); 1075 + } 1199 1076 1200 1077 for(d = pHba->devices; d ; d = next){ 1201 1078 next = d->next; ··· 1230 1075 pci_dev_put(pHba->pDev); 1231 1076 kfree(pHba); 1232 1077 1078 + if (adpt_sysfs_class) 1079 + device_destroy(adpt_sysfs_class, 1080 + MKDEV(DPTI_I2O_MAJOR, pHba->unit)); 1081 + 1233 1082 if(hba_count <= 0){ 1234 1083 unregister_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER); 1084 + if (adpt_sysfs_class) { 1085 + class_destroy(adpt_sysfs_class); 1086 + adpt_sysfs_class = NULL; 1087 + } 1235 1088 } 1236 1089 } 1237 - 1238 - 1239 - static int adpt_init(void) 1240 - { 1241 - printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n"); 1242 - #ifdef REBOOT_NOTIFIER 1243 - register_reboot_notifier(&adpt_reboot_notifier); 1244 - #endif 1245 - 1246 - return 0; 1247 - } 1248 - 1249 1090 1250 1091 static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun) 1251 1092 { ··· 1434 1283 { 1435 1284 u32 msg[8]; 1436 1285 u8* status; 1286 + dma_addr_t addr; 1437 1287 u32 m = EMPTY_QUEUE ; 1438 1288 ulong timeout = jiffies + (TMOUT_IOPRESET*HZ); 1439 1289 ··· 1457 1305 schedule_timeout_uninterruptible(1); 1458 1306 } while (m == EMPTY_QUEUE); 1459 1307 1460 - status = kzalloc(4, GFP_KERNEL|ADDR32); 1308 + status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); 1461 1309 if(status == NULL) { 1462 1310 adpt_send_nop(pHba, m); 1463 1311 printk(KERN_ERR"IOP reset failed - no free memory.\n"); 1464 1312 return -ENOMEM; 1465 1313 } 1314 + memset(status,0,4); 1466 1315 1467 1316 msg[0]=EIGHT_WORD_MSG_SIZE|SGL_OFFSET_0; 1468 1317 msg[1]=I2O_CMD_ADAPTER_RESET<<24|HOST_TID<<12|ADAPTER_TID; ··· 1471 1318 msg[3]=0; 1472 1319 msg[4]=0; 1473 1320 msg[5]=0; 1474 - msg[6]=virt_to_bus(status); 1475 - msg[7]=0; 1321 + msg[6]=dma_low(addr); 1322 + msg[7]=dma_high(addr); 1476 1323 1477 1324 memcpy_toio(pHba->msg_addr_virt+m, msg, sizeof(msg)); 1478 1325 wmb(); ··· 1482 1329 while(*status == 0){ 1483 1330 if(time_after(jiffies,timeout)){ 1484 1331 printk(KERN_WARNING"%s: IOP Reset Timeout\n",pHba->name); 1485 - kfree(status); 1332 + /* We lose 4 bytes of "status" here, but we cannot 1333 + free these because controller may awake and corrupt 1334 + those bytes at any time */ 1335 + /* dma_free_coherent(&pHba->pDev->dev, 4, buf, addr); */ 1486 1336 return -ETIMEDOUT; 1487 1337 } 1488 1338 rmb(); ··· 1504 1348 } 1505 1349 if(time_after(jiffies,timeout)){ 1506 1350 printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name); 1351 + /* We lose 4 bytes of "status" here, but we 1352 + cannot free these because controller may 1353 + awake and corrupt those bytes at any time */ 1354 + /* dma_free_coherent(&pHba->pDev->dev, 4, buf, addr); */ 1507 1355 return -ETIMEDOUT; 1508 1356 } 1509 1357 schedule_timeout_uninterruptible(1); ··· 1524 1364 PDEBUG("%s: Reset completed.\n", pHba->name); 1525 1365 } 1526 1366 1527 - kfree(status); 1367 + dma_free_coherent(&pHba->pDev->dev, 4, status, addr); 1528 1368 #ifdef UARTDELAY 1529 1369 // This delay is to allow someone attached to the card through the debug UART to 1530 1370 // set up the dump levels that they want before the rest of the initialization sequence ··· 1796 1636 u32 i = 0; 1797 1637 u32 rcode = 0; 1798 1638 void *p = NULL; 1639 + dma_addr_t addr; 1799 1640 ulong flags = 0; 1800 1641 1801 1642 memset(&msg, 0, MAX_MESSAGE_SIZE*4); ··· 1829 1668 } 1830 1669 sg_offset = (msg[0]>>4)&0xf; 1831 1670 msg[2] = 0x40000000; // IOCTL context 1832 - msg[3] = (u32)reply; 1671 + msg[3] = adpt_ioctl_to_context(pHba, reply); 1672 + if (msg[3] == (u32)-1) 1673 + return -EBUSY; 1674 + 1833 1675 memset(sg_list,0, sizeof(sg_list[0])*pHba->sg_tablesize); 1834 1676 if(sg_offset) { 1835 - // TODO 64bit fix 1677 + // TODO add 64 bit API 1836 1678 struct sg_simple_element *sg = (struct sg_simple_element*) (msg+sg_offset); 1837 1679 sg_count = (size - sg_offset*4) / sizeof(struct sg_simple_element); 1838 1680 if (sg_count > pHba->sg_tablesize){ ··· 1854 1690 } 1855 1691 sg_size = sg[i].flag_count & 0xffffff; 1856 1692 /* Allocate memory for the transfer */ 1857 - p = kmalloc(sg_size, GFP_KERNEL|ADDR32); 1693 + p = dma_alloc_coherent(&pHba->pDev->dev, sg_size, &addr, GFP_KERNEL); 1858 1694 if(!p) { 1859 1695 printk(KERN_DEBUG"%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 1860 1696 pHba->name,sg_size,i,sg_count); ··· 1864 1700 sg_list[sg_index++] = p; // sglist indexed with input frame, not our internal frame. 1865 1701 /* Copy in the user's SG buffer if necessary */ 1866 1702 if(sg[i].flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR*/) { 1867 - // TODO 64bit fix 1868 - if (copy_from_user(p,(void __user *)sg[i].addr_bus, sg_size)) { 1703 + // sg_simple_element API is 32 bit 1704 + if (copy_from_user(p,(void __user *)(ulong)sg[i].addr_bus, sg_size)) { 1869 1705 printk(KERN_DEBUG"%s: Could not copy SG buf %d FROM user\n",pHba->name,i); 1870 1706 rcode = -EFAULT; 1871 1707 goto cleanup; 1872 1708 } 1873 1709 } 1874 - //TODO 64bit fix 1875 - sg[i].addr_bus = (u32)virt_to_bus(p); 1710 + /* sg_simple_element API is 32 bit, but addr < 4GB */ 1711 + sg[i].addr_bus = addr; 1876 1712 } 1877 1713 } 1878 1714 ··· 1900 1736 if(sg_offset) { 1901 1737 /* Copy back the Scatter Gather buffers back to user space */ 1902 1738 u32 j; 1903 - // TODO 64bit fix 1739 + // TODO add 64 bit API 1904 1740 struct sg_simple_element* sg; 1905 1741 int sg_size; 1906 1742 ··· 1920 1756 } 1921 1757 sg_count = (size - sg_offset*4) / sizeof(struct sg_simple_element); 1922 1758 1923 - // TODO 64bit fix 1759 + // TODO add 64 bit API 1924 1760 sg = (struct sg_simple_element*)(msg + sg_offset); 1925 1761 for (j = 0; j < sg_count; j++) { 1926 1762 /* Copy out the SG list to user's buffer if necessary */ 1927 1763 if(! (sg[j].flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR*/)) { 1928 1764 sg_size = sg[j].flag_count & 0xffffff; 1929 - // TODO 64bit fix 1930 - if (copy_to_user((void __user *)sg[j].addr_bus,sg_list[j], sg_size)) { 1765 + // sg_simple_element API is 32 bit 1766 + if (copy_to_user((void __user *)(ulong)sg[j].addr_bus,sg_list[j], sg_size)) { 1931 1767 printk(KERN_WARNING"%s: Could not copy %p TO user %x\n",pHba->name, sg_list[j], sg[j].addr_bus); 1932 1768 rcode = -EFAULT; 1933 1769 goto cleanup; ··· 1951 1787 1952 1788 1953 1789 cleanup: 1954 - if (rcode != -ETIME && rcode != -EINTR) 1790 + if (rcode != -ETIME && rcode != -EINTR) { 1791 + struct sg_simple_element *sg = 1792 + (struct sg_simple_element*) (msg +sg_offset); 1955 1793 kfree (reply); 1956 - while(sg_index) { 1957 - if(sg_list[--sg_index]) { 1958 - if (rcode != -ETIME && rcode != -EINTR) 1959 - kfree(sg_list[sg_index]); 1794 + while(sg_index) { 1795 + if(sg_list[--sg_index]) { 1796 + dma_free_coherent(&pHba->pDev->dev, 1797 + sg[sg_index].flag_count & 0xffffff, 1798 + sg_list[sg_index], 1799 + sg[sg_index].addr_bus); 1800 + } 1960 1801 } 1961 1802 } 1962 1803 return rcode; ··· 2147 1978 return error; 2148 1979 } 2149 1980 1981 + #ifdef CONFIG_COMPAT 1982 + static long compat_adpt_ioctl(struct file *file, 1983 + unsigned int cmd, unsigned long arg) 1984 + { 1985 + struct inode *inode; 1986 + long ret; 1987 + 1988 + inode = file->f_dentry->d_inode; 1989 + 1990 + lock_kernel(); 1991 + 1992 + switch(cmd) { 1993 + case DPT_SIGNATURE: 1994 + case I2OUSRCMD: 1995 + case DPT_CTRLINFO: 1996 + case DPT_SYSINFO: 1997 + case DPT_BLINKLED: 1998 + case I2ORESETCMD: 1999 + case I2ORESCANCMD: 2000 + case (DPT_TARGET_BUSY & 0xFFFF): 2001 + case DPT_TARGET_BUSY: 2002 + ret = adpt_ioctl(inode, file, cmd, arg); 2003 + break; 2004 + default: 2005 + ret = -ENOIOCTLCMD; 2006 + } 2007 + 2008 + unlock_kernel(); 2009 + 2010 + return ret; 2011 + } 2012 + #endif 2150 2013 2151 2014 static irqreturn_t adpt_isr(int irq, void *dev_id) 2152 2015 { ··· 2210 2009 goto out; 2211 2010 } 2212 2011 } 2213 - reply = bus_to_virt(m); 2012 + if (pHba->reply_pool_pa <= m && 2013 + m < pHba->reply_pool_pa + 2014 + (pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4)) { 2015 + reply = (u8 *)pHba->reply_pool + 2016 + (m - pHba->reply_pool_pa); 2017 + } else { 2018 + /* Ick, we should *never* be here */ 2019 + printk(KERN_ERR "dpti: reply frame not from pool\n"); 2020 + reply = (u8 *)bus_to_virt(m); 2021 + } 2214 2022 2215 2023 if (readl(reply) & MSG_FAIL) { 2216 2024 u32 old_m = readl(reply+28); ··· 2239 2029 } 2240 2030 context = readl(reply+8); 2241 2031 if(context & 0x40000000){ // IOCTL 2242 - void *p = (void *)readl(reply+12); 2032 + void *p = adpt_ioctl_from_context(pHba, readl(reply+12)); 2243 2033 if( p != NULL) { 2244 2034 memcpy_fromio(p, reply, REPLY_FRAME_SIZE * 4); 2245 2035 } ··· 2253 2043 status = I2O_POST_WAIT_OK; 2254 2044 } 2255 2045 if(!(context & 0x40000000)) { 2256 - cmd = (struct scsi_cmnd*) readl(reply+12); 2046 + cmd = adpt_cmd_from_context(pHba, 2047 + readl(reply+12)); 2257 2048 if(cmd != NULL) { 2258 2049 printk(KERN_WARNING"%s: Apparent SCSI cmd in Post Wait Context - cmd=%p context=%x\n", pHba->name, cmd, context); 2259 2050 } 2260 2051 } 2261 2052 adpt_i2o_post_wait_complete(context, status); 2262 2053 } else { // SCSI message 2263 - cmd = (struct scsi_cmnd*) readl(reply+12); 2054 + cmd = adpt_cmd_from_context (pHba, readl(reply+12)); 2264 2055 if(cmd != NULL){ 2056 + scsi_dma_unmap(cmd); 2265 2057 if(cmd->serial_number != 0) { // If not timedout 2266 2058 adpt_i2o_to_scsi(reply, cmd); 2267 2059 } ··· 2284 2072 int i; 2285 2073 u32 msg[MAX_MESSAGE_SIZE]; 2286 2074 u32* mptr; 2075 + u32* lptr; 2287 2076 u32 *lenptr; 2288 2077 int direction; 2289 2078 int scsidir; ··· 2292 2079 u32 len; 2293 2080 u32 reqlen; 2294 2081 s32 rcode; 2082 + dma_addr_t addr; 2295 2083 2296 2084 memset(msg, 0 , sizeof(msg)); 2297 2085 len = scsi_bufflen(cmd); ··· 2332 2118 // I2O_CMD_SCSI_EXEC 2333 2119 msg[1] = ((0xff<<24)|(HOST_TID<<12)|d->tid); 2334 2120 msg[2] = 0; 2335 - msg[3] = (u32)cmd; /* We want the SCSI control block back */ 2121 + msg[3] = adpt_cmd_to_context(cmd); /* Want SCSI control block back */ 2336 2122 // Our cards use the transaction context as the tag for queueing 2337 2123 // Adaptec/DPT Private stuff 2338 2124 msg[4] = I2O_CMD_SCSI_EXEC|(DPT_ORGANIZATION_ID<<16); ··· 2350 2136 memcpy(mptr, cmd->cmnd, cmd->cmd_len); 2351 2137 mptr+=4; 2352 2138 lenptr=mptr++; /* Remember me - fill in when we know */ 2353 - reqlen = 14; // SINGLE SGE 2139 + if (dpt_dma64(pHba)) { 2140 + reqlen = 16; // SINGLE SGE 2141 + *mptr++ = (0x7C<<24)+(2<<16)+0x02; /* Enable 64 bit */ 2142 + *mptr++ = 1 << PAGE_SHIFT; 2143 + } else { 2144 + reqlen = 14; // SINGLE SGE 2145 + } 2354 2146 /* Now fill in the SGList and command */ 2355 2147 2356 2148 nseg = scsi_dma_map(cmd); ··· 2366 2146 2367 2147 len = 0; 2368 2148 scsi_for_each_sg(cmd, sg, nseg, i) { 2149 + lptr = mptr; 2369 2150 *mptr++ = direction|0x10000000|sg_dma_len(sg); 2370 2151 len+=sg_dma_len(sg); 2371 - *mptr++ = sg_dma_address(sg); 2152 + addr = sg_dma_address(sg); 2153 + *mptr++ = dma_low(addr); 2154 + if (dpt_dma64(pHba)) 2155 + *mptr++ = dma_high(addr); 2372 2156 /* Make this an end of list */ 2373 2157 if (i == nseg - 1) 2374 - mptr[-2] = direction|0xD0000000|sg_dma_len(sg); 2158 + *lptr = direction|0xD0000000|sg_dma_len(sg); 2375 2159 } 2376 2160 reqlen = mptr - msg; 2377 2161 *lenptr = len; ··· 2401 2177 } 2402 2178 2403 2179 2404 - static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht) 2180 + static s32 adpt_scsi_host_alloc(adpt_hba* pHba, struct scsi_host_template *sht) 2405 2181 { 2406 - struct Scsi_Host *host = NULL; 2182 + struct Scsi_Host *host; 2407 2183 2408 - host = scsi_register(sht, sizeof(adpt_hba*)); 2184 + host = scsi_host_alloc(sht, sizeof(adpt_hba*)); 2409 2185 if (host == NULL) { 2410 - printk ("%s: scsi_register returned NULL\n",pHba->name); 2186 + printk("%s: scsi_host_alloc returned NULL\n", pHba->name); 2411 2187 return -1; 2412 2188 } 2413 2189 host->hostdata[0] = (unsigned long)pHba; ··· 2424 2200 host->max_lun = 256; 2425 2201 host->max_channel = pHba->top_scsi_channel + 1; 2426 2202 host->cmd_per_lun = 1; 2427 - host->unique_id = (uint) pHba; 2203 + host->unique_id = (u32)sys_tbl_pa + pHba->unit; 2428 2204 host->sg_tablesize = pHba->sg_tablesize; 2429 2205 host->can_queue = pHba->post_fifo_size; 2430 2206 ··· 2864 2640 static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) 2865 2641 { 2866 2642 u8 *status; 2643 + dma_addr_t addr; 2867 2644 u32 __iomem *msg = NULL; 2868 2645 int i; 2869 2646 ulong timeout = jiffies + TMOUT_INITOUTBOUND*HZ; 2870 - u32* ptr; 2871 - u32 outbound_frame; // This had to be a 32 bit address 2872 2647 u32 m; 2873 2648 2874 2649 do { ··· 2886 2663 2887 2664 msg=(u32 __iomem *)(pHba->msg_addr_virt+m); 2888 2665 2889 - status = kzalloc(4, GFP_KERNEL|ADDR32); 2666 + status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); 2890 2667 if (!status) { 2891 2668 adpt_send_nop(pHba, m); 2892 2669 printk(KERN_WARNING"%s: IOP reset failed - no free memory.\n", 2893 2670 pHba->name); 2894 2671 return -ENOMEM; 2895 2672 } 2673 + memset(status, 0, 4); 2896 2674 2897 2675 writel(EIGHT_WORD_MSG_SIZE| SGL_OFFSET_6, &msg[0]); 2898 2676 writel(I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID, &msg[1]); ··· 2902 2678 writel(4096, &msg[4]); /* Host page frame size */ 2903 2679 writel((REPLY_FRAME_SIZE)<<16|0x80, &msg[5]); /* Outbound msg frame size and Initcode */ 2904 2680 writel(0xD0000004, &msg[6]); /* Simple SG LE, EOB */ 2905 - writel(virt_to_bus(status), &msg[7]); 2681 + writel((u32)addr, &msg[7]); 2906 2682 2907 2683 writel(m, pHba->post_port); 2908 2684 wmb(); ··· 2917 2693 rmb(); 2918 2694 if(time_after(jiffies,timeout)){ 2919 2695 printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name); 2696 + /* We lose 4 bytes of "status" here, but we 2697 + cannot free these because controller may 2698 + awake and corrupt those bytes at any time */ 2699 + /* dma_free_coherent(&pHba->pDev->dev, 4, status, addr); */ 2920 2700 return -ETIMEDOUT; 2921 2701 } 2922 2702 schedule_timeout_uninterruptible(1); ··· 2929 2701 // If the command was successful, fill the fifo with our reply 2930 2702 // message packets 2931 2703 if(*status != 0x04 /*I2O_EXEC_OUTBOUND_INIT_COMPLETE*/) { 2932 - kfree(status); 2704 + dma_free_coherent(&pHba->pDev->dev, 4, status, addr); 2933 2705 return -2; 2934 2706 } 2935 - kfree(status); 2707 + dma_free_coherent(&pHba->pDev->dev, 4, status, addr); 2936 2708 2937 - kfree(pHba->reply_pool); 2709 + if(pHba->reply_pool != NULL) { 2710 + dma_free_coherent(&pHba->pDev->dev, 2711 + pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, 2712 + pHba->reply_pool, pHba->reply_pool_pa); 2713 + } 2938 2714 2939 - pHba->reply_pool = kzalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); 2715 + pHba->reply_pool = dma_alloc_coherent(&pHba->pDev->dev, 2716 + pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, 2717 + &pHba->reply_pool_pa, GFP_KERNEL); 2940 2718 if (!pHba->reply_pool) { 2941 2719 printk(KERN_ERR "%s: Could not allocate reply pool\n", pHba->name); 2942 2720 return -ENOMEM; 2943 2721 } 2722 + memset(pHba->reply_pool, 0 , pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4); 2944 2723 2945 - ptr = pHba->reply_pool; 2946 2724 for(i = 0; i < pHba->reply_fifo_size; i++) { 2947 - outbound_frame = (u32)virt_to_bus(ptr); 2948 - writel(outbound_frame, pHba->reply_port); 2725 + writel(pHba->reply_pool_pa + (i * REPLY_FRAME_SIZE * 4), 2726 + pHba->reply_port); 2949 2727 wmb(); 2950 - ptr += REPLY_FRAME_SIZE; 2951 2728 } 2952 2729 adpt_i2o_status_get(pHba); 2953 2730 return 0; ··· 2976 2743 u32 m; 2977 2744 u32 __iomem *msg; 2978 2745 u8 *status_block=NULL; 2979 - ulong status_block_bus; 2980 2746 2981 2747 if(pHba->status_block == NULL) { 2982 - pHba->status_block = (i2o_status_block*) 2983 - kmalloc(sizeof(i2o_status_block),GFP_KERNEL|ADDR32); 2748 + pHba->status_block = dma_alloc_coherent(&pHba->pDev->dev, 2749 + sizeof(i2o_status_block), 2750 + &pHba->status_block_pa, GFP_KERNEL); 2984 2751 if(pHba->status_block == NULL) { 2985 2752 printk(KERN_ERR 2986 2753 "dpti%d: Get Status Block failed; Out of memory. \n", ··· 2990 2757 } 2991 2758 memset(pHba->status_block, 0, sizeof(i2o_status_block)); 2992 2759 status_block = (u8*)(pHba->status_block); 2993 - status_block_bus = virt_to_bus(pHba->status_block); 2994 2760 timeout = jiffies+TMOUT_GETSTATUS*HZ; 2995 2761 do { 2996 2762 rmb(); ··· 3014 2782 writel(0, &msg[3]); 3015 2783 writel(0, &msg[4]); 3016 2784 writel(0, &msg[5]); 3017 - writel(((u32)status_block_bus)&0xffffffff, &msg[6]); 3018 - writel(0, &msg[7]); 2785 + writel( dma_low(pHba->status_block_pa), &msg[6]); 2786 + writel( dma_high(pHba->status_block_pa), &msg[7]); 3019 2787 writel(sizeof(i2o_status_block), &msg[8]); // 88 bytes 3020 2788 3021 2789 //post message ··· 3044 2812 } 3045 2813 3046 2814 // Calculate the Scatter Gather list size 3047 - pHba->sg_tablesize = (pHba->status_block->inbound_frame_size * 4 -40)/ sizeof(struct sg_simple_element); 2815 + if (dpt_dma64(pHba)) { 2816 + pHba->sg_tablesize 2817 + = ((pHba->status_block->inbound_frame_size * 4 2818 + - 14 * sizeof(u32)) 2819 + / (sizeof(struct sg_simple_element) + sizeof(u32))); 2820 + } else { 2821 + pHba->sg_tablesize 2822 + = ((pHba->status_block->inbound_frame_size * 4 2823 + - 12 * sizeof(u32)) 2824 + / sizeof(struct sg_simple_element)); 2825 + } 3048 2826 if (pHba->sg_tablesize > SG_LIST_ELEMENTS) { 3049 2827 pHba->sg_tablesize = SG_LIST_ELEMENTS; 3050 2828 } ··· 3105 2863 } 3106 2864 do { 3107 2865 if (pHba->lct == NULL) { 3108 - pHba->lct = kmalloc(pHba->lct_size, GFP_KERNEL|ADDR32); 2866 + pHba->lct = dma_alloc_coherent(&pHba->pDev->dev, 2867 + pHba->lct_size, &pHba->lct_pa, 2868 + GFP_KERNEL); 3109 2869 if(pHba->lct == NULL) { 3110 2870 printk(KERN_CRIT "%s: Lct Get failed. Out of memory.\n", 3111 2871 pHba->name); ··· 3123 2879 msg[4] = 0xFFFFFFFF; /* All devices */ 3124 2880 msg[5] = 0x00000000; /* Report now */ 3125 2881 msg[6] = 0xD0000000|pHba->lct_size; 3126 - msg[7] = virt_to_bus(pHba->lct); 2882 + msg[7] = (u32)pHba->lct_pa; 3127 2883 3128 2884 if ((ret=adpt_i2o_post_wait(pHba, msg, sizeof(msg), 360))) { 3129 2885 printk(KERN_ERR "%s: LCT Get failed (status=%#10x.\n", ··· 3134 2890 3135 2891 if ((pHba->lct->table_size << 2) > pHba->lct_size) { 3136 2892 pHba->lct_size = pHba->lct->table_size << 2; 3137 - kfree(pHba->lct); 2893 + dma_free_coherent(&pHba->pDev->dev, pHba->lct_size, 2894 + pHba->lct, pHba->lct_pa); 3138 2895 pHba->lct = NULL; 3139 2896 } 3140 2897 } while (pHba->lct == NULL); ··· 3146 2901 // I2O_DPT_EXEC_IOP_BUFFERS_GROUP_NO; 3147 2902 if(adpt_i2o_query_scalar(pHba, 0 , 0x8000, -1, buf, sizeof(buf))>=0) { 3148 2903 pHba->FwDebugBufferSize = buf[1]; 3149 - pHba->FwDebugBuffer_P = pHba->base_addr_virt + buf[0]; 3150 - pHba->FwDebugFlags_P = pHba->FwDebugBuffer_P + FW_DEBUG_FLAGS_OFFSET; 3151 - pHba->FwDebugBLEDvalue_P = pHba->FwDebugBuffer_P + FW_DEBUG_BLED_OFFSET; 3152 - pHba->FwDebugBLEDflag_P = pHba->FwDebugBLEDvalue_P + 1; 3153 - pHba->FwDebugStrLength_P = pHba->FwDebugBuffer_P + FW_DEBUG_STR_LENGTH_OFFSET; 3154 - pHba->FwDebugBuffer_P += buf[2]; 3155 - pHba->FwDebugFlags = 0; 2904 + pHba->FwDebugBuffer_P = ioremap(pHba->base_addr_phys + buf[0], 2905 + pHba->FwDebugBufferSize); 2906 + if (pHba->FwDebugBuffer_P) { 2907 + pHba->FwDebugFlags_P = pHba->FwDebugBuffer_P + 2908 + FW_DEBUG_FLAGS_OFFSET; 2909 + pHba->FwDebugBLEDvalue_P = pHba->FwDebugBuffer_P + 2910 + FW_DEBUG_BLED_OFFSET; 2911 + pHba->FwDebugBLEDflag_P = pHba->FwDebugBLEDvalue_P + 1; 2912 + pHba->FwDebugStrLength_P = pHba->FwDebugBuffer_P + 2913 + FW_DEBUG_STR_LENGTH_OFFSET; 2914 + pHba->FwDebugBuffer_P += buf[2]; 2915 + pHba->FwDebugFlags = 0; 2916 + } 3156 2917 } 3157 2918 3158 2919 return 0; ··· 3166 2915 3167 2916 static int adpt_i2o_build_sys_table(void) 3168 2917 { 3169 - adpt_hba* pHba = NULL; 2918 + adpt_hba* pHba = hba_chain; 3170 2919 int count = 0; 2920 + 2921 + if (sys_tbl) 2922 + dma_free_coherent(&pHba->pDev->dev, sys_tbl_len, 2923 + sys_tbl, sys_tbl_pa); 3171 2924 3172 2925 sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs 3173 2926 (hba_count) * sizeof(struct i2o_sys_tbl_entry); 3174 2927 3175 - kfree(sys_tbl); 3176 - 3177 - sys_tbl = kzalloc(sys_tbl_len, GFP_KERNEL|ADDR32); 2928 + sys_tbl = dma_alloc_coherent(&pHba->pDev->dev, 2929 + sys_tbl_len, &sys_tbl_pa, GFP_KERNEL); 3178 2930 if (!sys_tbl) { 3179 2931 printk(KERN_WARNING "SysTab Set failed. Out of memory.\n"); 3180 2932 return -ENOMEM; 3181 2933 } 2934 + memset(sys_tbl, 0, sys_tbl_len); 3182 2935 3183 2936 sys_tbl->num_entries = hba_count; 3184 2937 sys_tbl->version = I2OVERSION; 3185 2938 sys_tbl->change_ind = sys_tbl_ind++; 3186 2939 3187 2940 for(pHba = hba_chain; pHba; pHba = pHba->next) { 2941 + u64 addr; 3188 2942 // Get updated Status Block so we have the latest information 3189 2943 if (adpt_i2o_status_get(pHba)) { 3190 2944 sys_tbl->num_entries--; ··· 3205 2949 sys_tbl->iops[count].frame_size = pHba->status_block->inbound_frame_size; 3206 2950 sys_tbl->iops[count].last_changed = sys_tbl_ind - 1; // ?? 3207 2951 sys_tbl->iops[count].iop_capabilities = pHba->status_block->iop_capabilities; 3208 - sys_tbl->iops[count].inbound_low = (u32)virt_to_bus(pHba->post_port); 3209 - sys_tbl->iops[count].inbound_high = (u32)((u64)virt_to_bus(pHba->post_port)>>32); 2952 + addr = pHba->base_addr_phys + 0x40; 2953 + sys_tbl->iops[count].inbound_low = dma_low(addr); 2954 + sys_tbl->iops[count].inbound_high = dma_high(addr); 3210 2955 3211 2956 count++; 3212 2957 } ··· 3343 3086 3344 3087 do { 3345 3088 if (pHba->hrt == NULL) { 3346 - pHba->hrt=kmalloc(size, GFP_KERNEL|ADDR32); 3089 + pHba->hrt = dma_alloc_coherent(&pHba->pDev->dev, 3090 + size, &pHba->hrt_pa, GFP_KERNEL); 3347 3091 if (pHba->hrt == NULL) { 3348 3092 printk(KERN_CRIT "%s: Hrt Get failed; Out of memory.\n", pHba->name); 3349 3093 return -ENOMEM; ··· 3356 3098 msg[2]= 0; 3357 3099 msg[3]= 0; 3358 3100 msg[4]= (0xD0000000 | size); /* Simple transaction */ 3359 - msg[5]= virt_to_bus(pHba->hrt); /* Dump it here */ 3101 + msg[5]= (u32)pHba->hrt_pa; /* Dump it here */ 3360 3102 3361 3103 if ((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg),20))) { 3362 3104 printk(KERN_ERR "%s: Unable to get HRT (status=%#10x)\n", pHba->name, ret); ··· 3364 3106 } 3365 3107 3366 3108 if (pHba->hrt->num_entries * pHba->hrt->entry_len << 2 > size) { 3367 - size = pHba->hrt->num_entries * pHba->hrt->entry_len << 2; 3368 - kfree(pHba->hrt); 3109 + int newsize = pHba->hrt->num_entries * pHba->hrt->entry_len << 2; 3110 + dma_free_coherent(&pHba->pDev->dev, size, 3111 + pHba->hrt, pHba->hrt_pa); 3112 + size = newsize; 3369 3113 pHba->hrt = NULL; 3370 3114 } 3371 3115 } while(pHba->hrt == NULL); ··· 3381 3121 int group, int field, void *buf, int buflen) 3382 3122 { 3383 3123 u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field }; 3384 - u8 *resblk; 3124 + u8 *opblk_va; 3125 + dma_addr_t opblk_pa; 3126 + u8 *resblk_va; 3127 + dma_addr_t resblk_pa; 3385 3128 3386 3129 int size; 3387 3130 3388 3131 /* 8 bytes for header */ 3389 - resblk = kmalloc(sizeof(u8) * (8+buflen), GFP_KERNEL|ADDR32); 3390 - if (resblk == NULL) { 3132 + resblk_va = dma_alloc_coherent(&pHba->pDev->dev, 3133 + sizeof(u8) * (8 + buflen), &resblk_pa, GFP_KERNEL); 3134 + if (resblk_va == NULL) { 3391 3135 printk(KERN_CRIT "%s: query scalar failed; Out of memory.\n", pHba->name); 3392 3136 return -ENOMEM; 3393 3137 } 3394 3138 3139 + opblk_va = dma_alloc_coherent(&pHba->pDev->dev, 3140 + sizeof(opblk), &opblk_pa, GFP_KERNEL); 3141 + if (opblk_va == NULL) { 3142 + dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), 3143 + resblk_va, resblk_pa); 3144 + printk(KERN_CRIT "%s: query operatio failed; Out of memory.\n", 3145 + pHba->name); 3146 + return -ENOMEM; 3147 + } 3395 3148 if (field == -1) /* whole group */ 3396 3149 opblk[4] = -1; 3397 3150 3151 + memcpy(opblk_va, opblk, sizeof(opblk)); 3398 3152 size = adpt_i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET, pHba, tid, 3399 - opblk, sizeof(opblk), resblk, sizeof(u8)*(8+buflen)); 3153 + opblk_va, opblk_pa, sizeof(opblk), 3154 + resblk_va, resblk_pa, sizeof(u8)*(8+buflen)); 3155 + dma_free_coherent(&pHba->pDev->dev, sizeof(opblk), opblk_va, opblk_pa); 3400 3156 if (size == -ETIME) { 3157 + dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), 3158 + resblk_va, resblk_pa); 3401 3159 printk(KERN_WARNING "%s: issue params failed; Timed out.\n", pHba->name); 3402 3160 return -ETIME; 3403 3161 } else if (size == -EINTR) { 3162 + dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), 3163 + resblk_va, resblk_pa); 3404 3164 printk(KERN_WARNING "%s: issue params failed; Interrupted.\n", pHba->name); 3405 3165 return -EINTR; 3406 3166 } 3407 3167 3408 - memcpy(buf, resblk+8, buflen); /* cut off header */ 3168 + memcpy(buf, resblk_va+8, buflen); /* cut off header */ 3409 3169 3410 - kfree(resblk); 3170 + dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), 3171 + resblk_va, resblk_pa); 3411 3172 if (size < 0) 3412 3173 return size; 3413 3174 ··· 3445 3164 * ResultCount, ErrorInfoSize, BlockStatus and BlockSize. 3446 3165 */ 3447 3166 static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid, 3448 - void *opblk, int oplen, void *resblk, int reslen) 3167 + void *opblk_va, dma_addr_t opblk_pa, int oplen, 3168 + void *resblk_va, dma_addr_t resblk_pa, int reslen) 3449 3169 { 3450 3170 u32 msg[9]; 3451 - u32 *res = (u32 *)resblk; 3171 + u32 *res = (u32 *)resblk_va; 3452 3172 int wait_status; 3453 3173 3454 3174 msg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_5; ··· 3458 3176 msg[3] = 0; 3459 3177 msg[4] = 0; 3460 3178 msg[5] = 0x54000000 | oplen; /* OperationBlock */ 3461 - msg[6] = virt_to_bus(opblk); 3179 + msg[6] = (u32)opblk_pa; 3462 3180 msg[7] = 0xD0000000 | reslen; /* ResultBlock */ 3463 - msg[8] = virt_to_bus(resblk); 3181 + msg[8] = (u32)resblk_pa; 3464 3182 3465 3183 if ((wait_status = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 20))) { 3466 - printk("adpt_i2o_issue_params: post_wait failed (%p)\n", resblk); 3184 + printk("adpt_i2o_issue_params: post_wait failed (%p)\n", resblk_va); 3467 3185 return wait_status; /* -DetailedStatus */ 3468 3186 } 3469 3187 ··· 3566 3284 * Private i/o space declaration 3567 3285 */ 3568 3286 msg[6] = 0x54000000 | sys_tbl_len; 3569 - msg[7] = virt_to_phys(sys_tbl); 3287 + msg[7] = (u32)sys_tbl_pa; 3570 3288 msg[8] = 0x54000000 | 0; 3571 3289 msg[9] = 0; 3572 3290 msg[10] = 0xD4000000 | 0; ··· 3605 3323 #endif 3606 3324 3607 3325 static struct scsi_host_template driver_template = { 3326 + .module = THIS_MODULE, 3608 3327 .name = "dpt_i2o", 3609 3328 .proc_name = "dpt_i2o", 3610 3329 .proc_info = adpt_proc_info, 3611 - .detect = adpt_detect, 3612 - .release = adpt_release, 3613 3330 .info = adpt_info, 3614 3331 .queuecommand = adpt_queue, 3615 3332 .eh_abort_handler = adpt_abort, ··· 3622 3341 .cmd_per_lun = 1, 3623 3342 .use_clustering = ENABLE_CLUSTERING, 3624 3343 }; 3625 - #include "scsi_module.c" 3344 + 3345 + static int __init adpt_init(void) 3346 + { 3347 + int error; 3348 + adpt_hba *pHba, *next; 3349 + 3350 + printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n"); 3351 + 3352 + error = adpt_detect(&driver_template); 3353 + if (error < 0) 3354 + return error; 3355 + if (hba_chain == NULL) 3356 + return -ENODEV; 3357 + 3358 + for (pHba = hba_chain; pHba; pHba = pHba->next) { 3359 + error = scsi_add_host(pHba->host, &pHba->pDev->dev); 3360 + if (error) 3361 + goto fail; 3362 + scsi_scan_host(pHba->host); 3363 + } 3364 + return 0; 3365 + fail: 3366 + for (pHba = hba_chain; pHba; pHba = next) { 3367 + next = pHba->next; 3368 + scsi_remove_host(pHba->host); 3369 + } 3370 + return error; 3371 + } 3372 + 3373 + static void __exit adpt_exit(void) 3374 + { 3375 + adpt_hba *pHba, *next; 3376 + 3377 + for (pHba = hba_chain; pHba; pHba = pHba->next) 3378 + scsi_remove_host(pHba->host); 3379 + for (pHba = hba_chain; pHba; pHba = next) { 3380 + next = pHba->next; 3381 + adpt_release(pHba->host); 3382 + } 3383 + } 3384 + 3385 + module_init(adpt_init); 3386 + module_exit(adpt_exit); 3387 + 3626 3388 MODULE_LICENSE("GPL");
+9 -6
drivers/scsi/dpti.h
··· 84 84 #define PCI_DPT_DEVICE_ID (0xA501) // DPT PCI I2O Device ID 85 85 #define PCI_DPT_RAPTOR_DEVICE_ID (0xA511) 86 86 87 - //#define REBOOT_NOTIFIER 1 88 87 /* Debugging macro from Linux Device Drivers - Rubini */ 89 88 #undef PDEBUG 90 89 #ifdef DEBUG ··· 228 229 u32 post_fifo_size; 229 230 u32 reply_fifo_size; 230 231 u32* reply_pool; 232 + dma_addr_t reply_pool_pa; 231 233 u32 sg_tablesize; // Scatter/Gather List Size. 232 234 u8 top_scsi_channel; 233 235 u8 top_scsi_id; 234 236 u8 top_scsi_lun; 237 + u8 dma64; 235 238 236 239 i2o_status_block* status_block; 240 + dma_addr_t status_block_pa; 237 241 i2o_hrt* hrt; 242 + dma_addr_t hrt_pa; 238 243 i2o_lct* lct; 244 + dma_addr_t lct_pa; 239 245 uint lct_size; 240 246 struct i2o_device* devices; 241 247 struct adpt_channel channel[MAX_CHANNEL]; ··· 253 249 void __iomem *FwDebugBLEDflag_P;// Virtual Addr Of FW Debug BLED 254 250 void __iomem *FwDebugBLEDvalue_P;// Virtual Addr Of FW Debug BLED 255 251 u32 FwDebugFlags; 252 + u32 *ioctl_reply_context[4]; 256 253 } adpt_hba; 257 254 258 255 struct sg_simple_element { ··· 269 264 static int adpt_init(void); 270 265 static int adpt_i2o_build_sys_table(void); 271 266 static irqreturn_t adpt_isr(int irq, void *dev_id); 272 - #ifdef REBOOT_NOTIFIER 273 - static int adpt_reboot_event(struct notifier_block *n, ulong code, void *p); 274 - #endif 275 267 276 268 static void adpt_i2o_report_hba_unit(adpt_hba* pHba, struct i2o_device *d); 277 269 static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid, ··· 277 275 static const char *adpt_i2o_get_class_name(int class); 278 276 #endif 279 277 static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid, 280 - void *opblk, int oplen, void *resblk, int reslen); 278 + void *opblk, dma_addr_t opblk_pa, int oplen, 279 + void *resblk, dma_addr_t resblk_pa, int reslen); 281 280 static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout); 282 281 static int adpt_i2o_lct_get(adpt_hba* pHba); 283 282 static int adpt_i2o_parse_lct(adpt_hba* pHba); ··· 292 289 static s32 adpt_i2o_hrt_get(adpt_hba* pHba); 293 290 static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice); 294 291 static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd); 295 - static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht); 292 + static s32 adpt_scsi_host_alloc(adpt_hba* pHba,struct scsi_host_template * sht); 296 293 static s32 adpt_hba_reset(adpt_hba* pHba); 297 294 static s32 adpt_i2o_reset_hba(adpt_hba* pHba); 298 295 static s32 adpt_rescan(adpt_hba* pHba);
+1 -1
drivers/scsi/gdth.c
··· 465 465 scp->request = (struct request *)&wait; 466 466 scp->timeout_per_command = timeout*HZ; 467 467 scp->cmd_len = 12; 468 - memcpy(scp->cmnd, cmnd, 12); 468 + scp->cmnd = cmnd; 469 469 cmndinfo.priority = IOCTL_PRI; 470 470 cmndinfo.internal_cmd_str = gdtcmd; 471 471 cmndinfo.internal_command = 1;
+3 -3
drivers/scsi/hptiop.c
··· 763 763 scp, 764 764 host->host_no, scp->device->channel, 765 765 scp->device->id, scp->device->lun, 766 - *((u32 *)&scp->cmnd), 767 - *((u32 *)&scp->cmnd + 1), 768 - *((u32 *)&scp->cmnd + 2), 766 + ((u32 *)scp->cmnd)[0], 767 + ((u32 *)scp->cmnd)[1], 768 + ((u32 *)scp->cmnd)[2], 769 769 _req->index, _req->req_virt); 770 770 771 771 scp->result = 0;
+5 -2
drivers/scsi/ibmvscsi/ibmvscsi.c
··· 686 686 } 687 687 688 688 if (cmnd) { 689 - cmnd->result = rsp->status; 689 + cmnd->result |= rsp->status; 690 690 if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION) 691 691 memcpy(cmnd->sense_buffer, 692 692 rsp->data, ··· 730 730 u16 lun = lun_from_dev(cmnd->device); 731 731 u8 out_fmt, in_fmt; 732 732 733 + cmnd->result = (DID_OK << 16); 733 734 evt_struct = get_event_struct(&hostdata->pool); 734 735 if (!evt_struct) 735 736 return SCSI_MLQUEUE_HOST_BUSY; ··· 739 738 srp_cmd = &evt_struct->iu.srp.cmd; 740 739 memset(srp_cmd, 0x00, SRP_MAX_IU_LEN); 741 740 srp_cmd->opcode = SRP_CMD; 742 - memcpy(srp_cmd->cdb, cmnd->cmnd, sizeof(cmnd->cmnd)); 741 + memcpy(srp_cmd->cdb, cmnd->cmnd, sizeof(srp_cmd->cdb)); 743 742 srp_cmd->lun = ((u64) lun) << 48; 744 743 745 744 if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { ··· 1348 1347 1349 1348 del_timer(&evt_struct->timer); 1350 1349 1350 + if (crq->status != VIOSRP_OK && evt_struct->cmnd) 1351 + evt_struct->cmnd->result = DID_ERROR << 16; 1351 1352 if (evt_struct->done) 1352 1353 evt_struct->done(evt_struct); 1353 1354 else
+9
drivers/scsi/ibmvscsi/viosrp.h
··· 59 59 VIOSRP_INLINE_FORMAT = 0x07 60 60 }; 61 61 62 + enum viosrp_crq_status { 63 + VIOSRP_OK = 0x0, 64 + VIOSRP_NONRECOVERABLE_ERR = 0x1, 65 + VIOSRP_VIOLATES_MAX_XFER = 0x2, 66 + VIOSRP_PARTNER_PANIC = 0x3, 67 + VIOSRP_DEVICE_BUSY = 0x8, 68 + VIOSRP_ADAPTER_FAIL = 0x10 69 + }; 70 + 62 71 struct viosrp_crq { 63 72 u8 valid; /* used by RPA */ 64 73 u8 format; /* SCSI vs out-of-band */
+1 -1
drivers/scsi/initio.c
··· 2590 2590 cblk->hastat = 0; 2591 2591 cblk->tastat = 0; 2592 2592 /* Command the command */ 2593 - memcpy(&cblk->cdb[0], &cmnd->cmnd, cmnd->cmd_len); 2593 + memcpy(cblk->cdb, cmnd->cmnd, cmnd->cmd_len); 2594 2594 2595 2595 /* Set up tags */ 2596 2596 if (cmnd->device->tagged_supported) { /* Tag Support */
+1 -1
drivers/scsi/ipr.c
··· 2791 2791 2792 2792 static struct device_attribute ipr_ioa_state_attr = { 2793 2793 .attr = { 2794 - .name = "state", 2794 + .name = "online_state", 2795 2795 .mode = S_IRUGO | S_IWUSR, 2796 2796 }, 2797 2797 .show = ipr_show_adapter_state,
+17
drivers/scsi/megaraid/megaraid_mbox.c
··· 3168 3168 uint8_t raw_mbox[sizeof(mbox_t)]; 3169 3169 int rval; 3170 3170 3171 + /* 3172 + * Newer firmware on Dell CERC expect a different 3173 + * random deletion handling, so disable it. 3174 + */ 3175 + if (adapter->pdev->vendor == PCI_VENDOR_ID_AMI && 3176 + adapter->pdev->device == PCI_DEVICE_ID_AMI_MEGARAID3 && 3177 + adapter->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL && 3178 + adapter->pdev->subsystem_device == PCI_SUBSYS_ID_CERC_ATA100_4CH && 3179 + (adapter->fw_version[0] > '6' || 3180 + (adapter->fw_version[0] == '6' && 3181 + adapter->fw_version[2] > '6') || 3182 + (adapter->fw_version[0] == '6' 3183 + && adapter->fw_version[2] == '6' 3184 + && adapter->fw_version[3] > '1'))) { 3185 + con_log(CL_DLEVEL1, ("megaraid: disable random deletion\n")); 3186 + return 0; 3187 + } 3171 3188 3172 3189 mbox = (mbox_t *)raw_mbox; 3173 3190
+1
drivers/scsi/megaraid/megaraid_mbox.h
··· 88 88 #define PCI_SUBSYS_ID_PERC3_QC 0x0471 89 89 #define PCI_SUBSYS_ID_PERC3_DC 0x0493 90 90 #define PCI_SUBSYS_ID_PERC3_SC 0x0475 91 + #define PCI_SUBSYS_ID_CERC_ATA100_4CH 0x0511 91 92 92 93 93 94 #define MBOX_MAX_SCSI_CMDS 128 // number of cmds reserved for kernel
+9 -4
drivers/scsi/megaraid/megaraid_sas.c
··· 10 10 * 2 of the License, or (at your option) any later version. 11 11 * 12 12 * FILE : megaraid_sas.c 13 - * Version : v00.00.03.16-rc1 13 + * Version : v00.00.03.20-rc1 14 14 * 15 15 * Authors: 16 16 * (email-id : megaraidlinux@lsi.com) ··· 2650 2650 return; 2651 2651 } 2652 2652 2653 + #ifdef CONFIG_PM 2653 2654 /** 2654 2655 * megasas_suspend - driver suspend entry point 2655 2656 * @pdev: PCI device structure 2656 2657 * @state: PCI power state to suspend routine 2657 2658 */ 2658 - static int __devinit 2659 + static int 2659 2660 megasas_suspend(struct pci_dev *pdev, pm_message_t state) 2660 2661 { 2661 2662 struct Scsi_Host *host; ··· 2688 2687 * megasas_resume- driver resume entry point 2689 2688 * @pdev: PCI device structure 2690 2689 */ 2691 - static int __devinit 2690 + static int 2692 2691 megasas_resume(struct pci_dev *pdev) 2693 2692 { 2694 2693 int rval; ··· 2783 2782 2784 2783 return -ENODEV; 2785 2784 } 2785 + #else 2786 + #define megasas_suspend NULL 2787 + #define megasas_resume NULL 2788 + #endif 2786 2789 2787 2790 /** 2788 2791 * megasas_detach_one - PCI hot"un"plug entry point 2789 2792 * @pdev: PCI device structure 2790 2793 */ 2791 - static void megasas_detach_one(struct pci_dev *pdev) 2794 + static void __devexit megasas_detach_one(struct pci_dev *pdev) 2792 2795 { 2793 2796 int i; 2794 2797 struct Scsi_Host *host;
+3 -3
drivers/scsi/megaraid/megaraid_sas.h
··· 18 18 /* 19 19 * MegaRAID SAS Driver meta data 20 20 */ 21 - #define MEGASAS_VERSION "00.00.03.16-rc1" 22 - #define MEGASAS_RELDATE "Nov. 07, 2007" 23 - #define MEGASAS_EXT_VERSION "Thu. Nov. 07 10:09:32 PDT 2007" 21 + #define MEGASAS_VERSION "00.00.03.20-rc1" 22 + #define MEGASAS_RELDATE "March 10, 2008" 23 + #define MEGASAS_EXT_VERSION "Mon. March 10 11:02:31 PDT 2008" 24 24 25 25 /* 26 26 * Device IDs
+2 -2
drivers/scsi/qla1280.c
··· 2858 2858 2859 2859 /* Load SCSI command packet. */ 2860 2860 pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd)); 2861 - memcpy(pkt->scsi_cdb, &(CMD_CDBP(cmd)), CMD_CDBLEN(cmd)); 2861 + memcpy(pkt->scsi_cdb, CMD_CDBP(cmd), CMD_CDBLEN(cmd)); 2862 2862 /* dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */ 2863 2863 2864 2864 /* Set transfer direction. */ ··· 3127 3127 3128 3128 /* Load SCSI command packet. */ 3129 3129 pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd)); 3130 - memcpy(pkt->scsi_cdb, &(CMD_CDBP(cmd)), CMD_CDBLEN(cmd)); 3130 + memcpy(pkt->scsi_cdb, CMD_CDBP(cmd), CMD_CDBLEN(cmd)); 3131 3131 3132 3132 /*dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */ 3133 3133 /* Set transfer direction. */
+12 -11
drivers/scsi/scsi.c
··· 79 79 #define MIN_RESET_PERIOD (15*HZ) 80 80 81 81 /* 82 - * Macro to determine the size of SCSI command. This macro takes vendor 83 - * unique commands into account. SCSI commands in groups 6 and 7 are 84 - * vendor unique and we will depend upon the command length being 85 - * supplied correctly in cmd_len. 86 - */ 87 - #define CDB_SIZE(cmd) (((((cmd)->cmnd[0] >> 5) & 7) < 6) ? \ 88 - COMMAND_SIZE((cmd)->cmnd[0]) : (cmd)->cmd_len) 89 - 90 - /* 91 82 * Note - the initial logging level can be set here to log events at boot time. 92 83 * After the system is up, you may enable logging via the /proc interface. 93 84 */ ··· 460 469 cmd = scsi_pool_alloc_command(shost->cmd_pool, gfp_mask); 461 470 if (!cmd) { 462 471 scsi_put_host_cmd_pool(gfp_mask); 472 + shost->cmd_pool = NULL; 463 473 return -ENOMEM; 464 474 } 465 475 list_add(&cmd->list, &shost->free_list); ··· 473 481 */ 474 482 void scsi_destroy_command_freelist(struct Scsi_Host *shost) 475 483 { 484 + /* 485 + * If cmd_pool is NULL the free list was not initialized, so 486 + * do not attempt to release resources. 487 + */ 488 + if (!shost->cmd_pool) 489 + return; 490 + 476 491 while (!list_empty(&shost->free_list)) { 477 492 struct scsi_cmnd *cmd; 478 493 ··· 700 701 * Before we queue this command, check if the command 701 702 * length exceeds what the host adapter can handle. 702 703 */ 703 - if (CDB_SIZE(cmd) > cmd->device->host->max_cmd_len) { 704 + if (cmd->cmd_len > cmd->device->host->max_cmd_len) { 704 705 SCSI_LOG_MLQUEUE(3, 705 - printk("queuecommand : command too long.\n")); 706 + printk("queuecommand : command too long. " 707 + "cdb_size=%d host->max_cmd_len=%d\n", 708 + cmd->cmd_len, cmd->device->host->max_cmd_len)); 706 709 cmd->result = (DID_ABORT << 16); 707 710 708 711 scsi_done(cmd);
+8 -7
drivers/scsi/scsi_error.c
··· 626 626 * @scmd: SCSI command structure to hijack 627 627 * @ses: structure to save restore information 628 628 * @cmnd: CDB to send. Can be NULL if no new cmnd is needed 629 - * @cmnd_size: size in bytes of @cmnd 629 + * @cmnd_size: size in bytes of @cmnd (must be <= BLK_MAX_CDB) 630 630 * @sense_bytes: size of sense data to copy. or 0 (if != 0 @cmnd is ignored) 631 631 * 632 632 * This function is used to save a scsi command information before re-execution ··· 648 648 * command. 649 649 */ 650 650 ses->cmd_len = scmd->cmd_len; 651 - memcpy(ses->cmnd, scmd->cmnd, sizeof(scmd->cmnd)); 651 + ses->cmnd = scmd->cmnd; 652 652 ses->data_direction = scmd->sc_data_direction; 653 653 ses->sdb = scmd->sdb; 654 654 ses->next_rq = scmd->request->next_rq; 655 655 ses->result = scmd->result; 656 656 657 + scmd->cmnd = ses->eh_cmnd; 658 + memset(scmd->cmnd, 0, BLK_MAX_CDB); 657 659 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); 658 660 scmd->request->next_rq = NULL; 659 661 ··· 667 665 scmd->sdb.table.sgl = &ses->sense_sgl; 668 666 scmd->sc_data_direction = DMA_FROM_DEVICE; 669 667 scmd->sdb.table.nents = 1; 670 - memset(scmd->cmnd, 0, sizeof(scmd->cmnd)); 671 668 scmd->cmnd[0] = REQUEST_SENSE; 672 669 scmd->cmnd[4] = scmd->sdb.length; 673 670 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); 674 671 } else { 675 672 scmd->sc_data_direction = DMA_NONE; 676 673 if (cmnd) { 677 - memset(scmd->cmnd, 0, sizeof(scmd->cmnd)); 674 + BUG_ON(cmnd_size > BLK_MAX_CDB); 678 675 memcpy(scmd->cmnd, cmnd, cmnd_size); 679 676 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); 680 677 } ··· 706 705 * Restore original data 707 706 */ 708 707 scmd->cmd_len = ses->cmd_len; 709 - memcpy(scmd->cmnd, ses->cmnd, sizeof(scmd->cmnd)); 708 + scmd->cmnd = ses->cmnd; 710 709 scmd->sc_data_direction = ses->data_direction; 711 710 scmd->sdb = ses->sdb; 712 711 scmd->request->next_rq = ses->next_rq; ··· 1776 1775 scmd->request = &req; 1777 1776 memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout)); 1778 1777 1779 - memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd)); 1780 - 1778 + scmd->cmnd = req.cmd; 1779 + 1781 1780 scmd->scsi_done = scsi_reset_provider_done_command; 1782 1781 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); 1783 1782
+4 -3
drivers/scsi/scsi_lib.c
··· 445 445 scsi_set_resid(cmd, 0); 446 446 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 447 447 if (cmd->cmd_len == 0) 448 - cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]); 448 + cmd->cmd_len = scsi_command_size(cmd->cmnd); 449 449 } 450 450 451 451 void scsi_device_unbusy(struct scsi_device *sdev) ··· 1094 1094 cmd->tag = req->tag; 1095 1095 cmd->request = req; 1096 1096 1097 + cmd->cmnd = req->cmd; 1098 + 1097 1099 return cmd; 1098 1100 } 1099 1101 ··· 1133 1131 req->buffer = NULL; 1134 1132 } 1135 1133 1136 - BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); 1137 - memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1138 1134 cmd->cmd_len = req->cmd_len; 1139 1135 if (!req->data_len) 1140 1136 cmd->sc_data_direction = DMA_NONE; ··· 1169 1169 if (unlikely(!cmd)) 1170 1170 return BLKPREP_DEFER; 1171 1171 1172 + memset(cmd->cmnd, 0, BLK_MAX_CDB); 1172 1173 return scsi_init_io(cmd, GFP_ATOMIC); 1173 1174 } 1174 1175 EXPORT_SYMBOL(scsi_setup_fs_cmnd);
+2
drivers/scsi/scsi_tgt_lib.c
··· 107 107 cmd->jiffies_at_alloc = jiffies; 108 108 cmd->request = rq; 109 109 110 + cmd->cmnd = rq->cmd; 111 + 110 112 rq->special = cmd; 111 113 rq->cmd_type = REQ_TYPE_SPECIAL; 112 114 rq->cmd_flags |= REQ_TYPE_BLOCK_PC;
+4 -2
drivers/scsi/u14-34f.c
··· 744 744 static int board_inquiry(unsigned int j) { 745 745 struct mscp *cpp; 746 746 dma_addr_t id_dma_addr; 747 - unsigned int time, limit = 0; 747 + unsigned int limit = 0; 748 + unsigned long time; 748 749 749 750 id_dma_addr = pci_map_single(HD(j)->pdev, HD(j)->board_id, 750 751 sizeof(HD(j)->board_id), PCI_DMA_BIDIRECTIONAL); ··· 1393 1392 } 1394 1393 1395 1394 static int u14_34f_eh_host_reset(struct scsi_cmnd *SCarg) { 1396 - unsigned int i, j, time, k, c, limit = 0; 1395 + unsigned int i, j, k, c, limit = 0; 1396 + unsigned long time; 1397 1397 int arg_done = FALSE; 1398 1398 struct scsi_cmnd *SCpnt; 1399 1399
+1 -1
drivers/usb/storage/cypress_atacb.c
··· 46 46 } 47 47 48 48 memcpy(save_cmnd, srb->cmnd, sizeof(save_cmnd)); 49 - memset(srb->cmnd, 0, sizeof(srb->cmnd)); 49 + memset(srb->cmnd, 0, MAX_COMMAND_SIZE); 50 50 51 51 /* check if we support the command */ 52 52 if (save_cmnd[1] >> 5) /* MULTIPLE_COUNT */
+2
drivers/usb/storage/isd200.c
··· 292 292 293 293 /* maximum number of LUNs supported */ 294 294 unsigned char MaxLUNs; 295 + unsigned char cmnd[BLK_MAX_CDB]; 295 296 struct scsi_cmnd srb; 296 297 struct scatterlist sg; 297 298 }; ··· 451 450 452 451 memset(&ata, 0, sizeof(ata)); 453 452 memset(&srb_dev, 0, sizeof(srb_dev)); 453 + srb->cmnd = info->cmnd; 454 454 srb->device = &srb_dev; 455 455 ++srb->serial_number; 456 456
+33 -7
include/scsi/scsi.h
··· 30 30 #endif 31 31 32 32 /* 33 - * SCSI command lengths 34 - */ 35 - 36 - extern const unsigned char scsi_command_size[8]; 37 - #define COMMAND_SIZE(opcode) scsi_command_size[((opcode) >> 5) & 7] 38 - 39 - /* 40 33 * Special value for scanning to specify scanning or rescanning of all 41 34 * possible channels, (target) ids, or luns on a given shost. 42 35 */ ··· 102 109 #define MODE_SENSE_10 0x5a 103 110 #define PERSISTENT_RESERVE_IN 0x5e 104 111 #define PERSISTENT_RESERVE_OUT 0x5f 112 + #define VARIABLE_LENGTH_CMD 0x7f 105 113 #define REPORT_LUNS 0xa0 106 114 #define MAINTENANCE_IN 0xa3 107 115 #define MOVE_MEDIUM 0xa5 ··· 128 134 /* Values for T10/04-262r7 */ 129 135 #define ATA_16 0x85 /* 16-byte pass-thru */ 130 136 #define ATA_12 0xa1 /* 12-byte pass-thru */ 137 + 138 + /* 139 + * SCSI command lengths 140 + */ 141 + 142 + #define SCSI_MAX_VARLEN_CDB_SIZE 260 143 + 144 + /* defined in T10 SCSI Primary Commands-2 (SPC2) */ 145 + struct scsi_varlen_cdb_hdr { 146 + u8 opcode; /* opcode always == VARIABLE_LENGTH_CMD */ 147 + u8 control; 148 + u8 misc[5]; 149 + u8 additional_cdb_length; /* total cdb length - 8 */ 150 + __be16 service_action; 151 + /* service specific data follows */ 152 + }; 153 + 154 + static inline unsigned 155 + scsi_varlen_cdb_length(const void *hdr) 156 + { 157 + return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length + 8; 158 + } 159 + 160 + extern const unsigned char scsi_command_size_tbl[8]; 161 + #define COMMAND_SIZE(opcode) scsi_command_size_tbl[((opcode) >> 5) & 7] 162 + 163 + static inline unsigned 164 + scsi_command_size(const unsigned char *cmnd) 165 + { 166 + return (cmnd[0] == VARIABLE_LENGTH_CMD) ? 167 + scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]); 168 + } 131 169 132 170 /* 133 171 * SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
+20 -3
include/scsi/scsi_cmnd.h
··· 7 7 #include <linux/types.h> 8 8 #include <linux/timer.h> 9 9 #include <linux/scatterlist.h> 10 + #include <linux/blkdev.h> 10 11 11 12 struct Scsi_Host; 12 13 struct scsi_device; 14 + 15 + /* 16 + * MAX_COMMAND_SIZE is: 17 + * The longest fixed-length SCSI CDB as per the SCSI standard. 18 + * fixed-length means: commands that their size can be determined 19 + * by their opcode and the CDB does not carry a length specifier, (unlike 20 + * the VARIABLE_LENGTH_CMD(0x7f) command). This is actually not exactly 21 + * true and the SCSI standard also defines extended commands and 22 + * vendor specific commands that can be bigger than 16 bytes. The kernel 23 + * will support these using the same infrastructure used for VARLEN CDB's. 24 + * So in effect MAX_COMMAND_SIZE means the maximum size command scsi-ml 25 + * supports without specifying a cmd_len by ULD's 26 + */ 27 + #define MAX_COMMAND_SIZE 16 28 + #if (MAX_COMMAND_SIZE > BLK_MAX_CDB) 29 + # error MAX_COMMAND_SIZE can not be bigger than BLK_MAX_CDB 30 + #endif 13 31 14 32 struct scsi_data_buffer { 15 33 struct sg_table table; ··· 78 60 int allowed; 79 61 int timeout_per_command; 80 62 81 - unsigned char cmd_len; 63 + unsigned short cmd_len; 82 64 enum dma_data_direction sc_data_direction; 83 65 84 66 /* These elements define the operation we are about to perform */ 85 - #define MAX_COMMAND_SIZE 16 86 - unsigned char cmnd[MAX_COMMAND_SIZE]; 67 + unsigned char *cmnd; 87 68 88 69 struct timer_list eh_timeout; /* Used to time out the command. */ 89 70
+2 -2
include/scsi/scsi_eh.h
··· 75 75 int result; 76 76 enum dma_data_direction data_direction; 77 77 unsigned char cmd_len; 78 - unsigned char cmnd[MAX_COMMAND_SIZE]; 78 + unsigned char *cmnd; 79 79 struct scsi_data_buffer sdb; 80 80 struct request *next_rq; 81 - 82 81 /* new command support */ 82 + unsigned char eh_cmnd[BLK_MAX_CDB]; 83 83 struct scatterlist sense_sgl; 84 84 }; 85 85
+3 -5
include/scsi/scsi_host.h
··· 573 573 /* 574 574 * The maximum length of SCSI commands that this host can accept. 575 575 * Probably 12 for most host adapters, but could be 16 for others. 576 + * or 260 if the driver supports variable length cdbs. 576 577 * For drivers that don't set this field, a value of 12 is 577 - * assumed. I am leaving this as a number rather than a bit 578 - * because you never know what subsequent SCSI standards might do 579 - * (i.e. could there be a 20 byte or a 24-byte command a few years 580 - * down the road?). 578 + * assumed. 581 579 */ 582 - unsigned char max_cmd_len; 580 + unsigned short max_cmd_len; 583 581 584 582 int this_id; 585 583 int can_queue;