hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/scsi/ips.c
....@@ -208,7 +208,7 @@
208208
209209 #define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \
210210 DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \
211
- PCI_DMA_BIDIRECTIONAL : \
211
+ DMA_BIDIRECTIONAL : \
212212 scb->scsi_cmd->sc_data_direction)
213213
214214 #ifdef IPS_DEBUG
....@@ -365,7 +365,6 @@
365365 .this_id = -1,
366366 .sg_tablesize = IPS_MAX_SG,
367367 .cmd_per_lun = 3,
368
- .use_clustering = ENABLE_CLUSTERING,
369368 .no_write_same = 1,
370369 };
371370
....@@ -499,7 +498,7 @@
499498 int i;
500499 char *key;
501500 char *value;
502
- IPS_OPTION options[] = {
501
+ static const IPS_OPTION options[] = {
503502 {"noi2o", &ips_force_i2o, 0},
504503 {"nommap", &ips_force_memio, 0},
505504 {"ioctlsize", &ips_ioctlsize, IPS_IOCTL_SIZE},
....@@ -1529,11 +1528,12 @@
15291528 if (ha->ioctl_data && length <= ha->ioctl_len)
15301529 return 0;
15311530 /* there is no buffer or it's not big enough, allocate a new one */
1532
- bigger_buf = pci_alloc_consistent(ha->pcidev, length, &dma_busaddr);
1531
+ bigger_buf = dma_alloc_coherent(&ha->pcidev->dev, length, &dma_busaddr,
1532
+ GFP_KERNEL);
15331533 if (bigger_buf) {
15341534 /* free the old memory */
1535
- pci_free_consistent(ha->pcidev, ha->ioctl_len, ha->ioctl_data,
1536
- ha->ioctl_busaddr);
1535
+ dma_free_coherent(&ha->pcidev->dev, ha->ioctl_len,
1536
+ ha->ioctl_data, ha->ioctl_busaddr);
15371537 /* use the new memory */
15381538 ha->ioctl_data = (char *) bigger_buf;
15391539 ha->ioctl_len = length;
....@@ -1678,9 +1678,8 @@
16781678 } else if (!ha->flash_data) {
16791679 datasize = pt->CoppCP.cmd.flashfw.total_packets *
16801680 pt->CoppCP.cmd.flashfw.count;
1681
- ha->flash_data = pci_alloc_consistent(ha->pcidev,
1682
- datasize,
1683
- &ha->flash_busaddr);
1681
+ ha->flash_data = dma_alloc_coherent(&ha->pcidev->dev,
1682
+ datasize, &ha->flash_busaddr, GFP_KERNEL);
16841683 if (!ha->flash_data){
16851684 printk(KERN_WARNING "Unable to allocate a flash buffer\n");
16861685 return IPS_FAILURE;
....@@ -1801,13 +1800,13 @@
18011800 }
18021801 if (IPS_USE_ENH_SGLIST(ha)) {
18031802 scb->sg_list.enh_list[indx].address_lo =
1804
- cpu_to_le32(pci_dma_lo32(busaddr));
1803
+ cpu_to_le32(lower_32_bits(busaddr));
18051804 scb->sg_list.enh_list[indx].address_hi =
1806
- cpu_to_le32(pci_dma_hi32(busaddr));
1805
+ cpu_to_le32(upper_32_bits(busaddr));
18071806 scb->sg_list.enh_list[indx].length = cpu_to_le32(e_len);
18081807 } else {
18091808 scb->sg_list.std_list[indx].address =
1810
- cpu_to_le32(pci_dma_lo32(busaddr));
1809
+ cpu_to_le32(lower_32_bits(busaddr));
18111810 scb->sg_list.std_list[indx].length = cpu_to_le32(e_len);
18121811 }
18131812
....@@ -1858,7 +1857,7 @@
18581857
18591858 scb->data_len = ha->flash_datasize;
18601859 scb->data_busaddr =
1861
- pci_map_single(ha->pcidev, ha->flash_data, scb->data_len,
1860
+ dma_map_single(&ha->pcidev->dev, ha->flash_data, scb->data_len,
18621861 IPS_DMA_DIR(scb));
18631862 scb->flags |= IPS_SCB_MAP_SINGLE;
18641863 scb->cmd.flashfw.command_id = IPS_COMMAND_ID(ha, scb);
....@@ -1880,8 +1879,8 @@
18801879 if (ha->flash_data == ips_FlashData)
18811880 test_and_clear_bit(0, &ips_FlashDataInUse);
18821881 else if (ha->flash_data)
1883
- pci_free_consistent(ha->pcidev, ha->flash_len, ha->flash_data,
1884
- ha->flash_busaddr);
1882
+ dma_free_coherent(&ha->pcidev->dev, ha->flash_len,
1883
+ ha->flash_data, ha->flash_busaddr);
18851884 ha->flash_data = NULL;
18861885 }
18871886
....@@ -2240,7 +2239,7 @@
22402239 major = 0;
22412240 minor = 0;
22422241
2243
- strncpy(ha->bios_version, " ?", 8);
2242
+ memcpy(ha->bios_version, " ?", 8);
22442243
22452244 if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD) {
22462245 if (IPS_USE_MEMIO(ha)) {
....@@ -3516,11 +3515,11 @@
35163515 inquiry.Flags[1] =
35173516 IPS_SCSI_INQ_WBus16 |
35183517 IPS_SCSI_INQ_Sync;
3519
- strncpy(inquiry.VendorId, "IBM ",
3518
+ memcpy(inquiry.VendorId, "IBM ",
35203519 8);
3521
- strncpy(inquiry.ProductId,
3520
+ memcpy(inquiry.ProductId,
35223521 "SERVERAID ", 16);
3523
- strncpy(inquiry.ProductRevisionLevel,
3522
+ memcpy(inquiry.ProductRevisionLevel,
35243523 "1.00", 4);
35253524
35263525 ips_scmd_buf_write(scb->scsi_cmd,
....@@ -4037,9 +4036,9 @@
40374036 inquiry.Flags[0] = IPS_SCSI_INQ_Address16;
40384037 inquiry.Flags[1] =
40394038 IPS_SCSI_INQ_WBus16 | IPS_SCSI_INQ_Sync | IPS_SCSI_INQ_CmdQue;
4040
- strncpy(inquiry.VendorId, "IBM ", 8);
4041
- strncpy(inquiry.ProductId, "SERVERAID ", 16);
4042
- strncpy(inquiry.ProductRevisionLevel, "1.00", 4);
4039
+ memcpy(inquiry.VendorId, "IBM ", 8);
4040
+ memcpy(inquiry.ProductId, "SERVERAID ", 16);
4041
+ memcpy(inquiry.ProductRevisionLevel, "1.00", 4);
40434042
40444043 ips_scmd_buf_write(scb->scsi_cmd, &inquiry, sizeof (inquiry));
40454044
....@@ -4213,7 +4212,7 @@
42134212
42144213 if (ha) {
42154214 if (ha->enq) {
4216
- pci_free_consistent(ha->pcidev, sizeof(IPS_ENQ),
4215
+ dma_free_coherent(&ha->pcidev->dev, sizeof(IPS_ENQ),
42174216 ha->enq, ha->enq_busaddr);
42184217 ha->enq = NULL;
42194218 }
....@@ -4222,7 +4221,7 @@
42224221 ha->conf = NULL;
42234222
42244223 if (ha->adapt) {
4225
- pci_free_consistent(ha->pcidev,
4224
+ dma_free_coherent(&ha->pcidev->dev,
42264225 sizeof (IPS_ADAPTER) +
42274226 sizeof (IPS_IO_CMD), ha->adapt,
42284227 ha->adapt->hw_status_start);
....@@ -4230,7 +4229,7 @@
42304229 }
42314230
42324231 if (ha->logical_drive_info) {
4233
- pci_free_consistent(ha->pcidev,
4232
+ dma_free_coherent(&ha->pcidev->dev,
42344233 sizeof (IPS_LD_INFO),
42354234 ha->logical_drive_info,
42364235 ha->logical_drive_info_dma_addr);
....@@ -4244,7 +4243,7 @@
42444243 ha->subsys = NULL;
42454244
42464245 if (ha->ioctl_data) {
4247
- pci_free_consistent(ha->pcidev, ha->ioctl_len,
4246
+ dma_free_coherent(&ha->pcidev->dev, ha->ioctl_len,
42484247 ha->ioctl_data, ha->ioctl_busaddr);
42494248 ha->ioctl_data = NULL;
42504249 ha->ioctl_datasize = 0;
....@@ -4277,11 +4276,11 @@
42774276 ips_deallocatescbs(ips_ha_t * ha, int cmds)
42784277 {
42794278 if (ha->scbs) {
4280
- pci_free_consistent(ha->pcidev,
4279
+ dma_free_coherent(&ha->pcidev->dev,
42814280 IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * cmds,
42824281 ha->scbs->sg_list.list,
42834282 ha->scbs->sg_busaddr);
4284
- pci_free_consistent(ha->pcidev, sizeof (ips_scb_t) * cmds,
4283
+ dma_free_coherent(&ha->pcidev->dev, sizeof (ips_scb_t) * cmds,
42854284 ha->scbs, ha->scbs->scb_busaddr);
42864285 ha->scbs = NULL;
42874286 } /* end if */
....@@ -4308,17 +4307,16 @@
43084307 METHOD_TRACE("ips_allocatescbs", 1);
43094308
43104309 /* Allocate memory for the SCBs */
4311
- ha->scbs =
4312
- pci_alloc_consistent(ha->pcidev, ha->max_cmds * sizeof (ips_scb_t),
4313
- &command_dma);
4310
+ ha->scbs = dma_alloc_coherent(&ha->pcidev->dev,
4311
+ ha->max_cmds * sizeof (ips_scb_t),
4312
+ &command_dma, GFP_KERNEL);
43144313 if (ha->scbs == NULL)
43154314 return 0;
4316
- ips_sg.list =
4317
- pci_alloc_consistent(ha->pcidev,
4318
- IPS_SGLIST_SIZE(ha) * IPS_MAX_SG *
4319
- ha->max_cmds, &sg_dma);
4315
+ ips_sg.list = dma_alloc_coherent(&ha->pcidev->dev,
4316
+ IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * ha->max_cmds,
4317
+ &sg_dma, GFP_KERNEL);
43204318 if (ips_sg.list == NULL) {
4321
- pci_free_consistent(ha->pcidev,
4319
+ dma_free_coherent(&ha->pcidev->dev,
43224320 ha->max_cmds * sizeof (ips_scb_t), ha->scbs,
43234321 command_dma);
43244322 return 0;
....@@ -4447,8 +4445,8 @@
44474445 if (scb->flags & IPS_SCB_MAP_SG)
44484446 scsi_dma_unmap(scb->scsi_cmd);
44494447 else if (scb->flags & IPS_SCB_MAP_SINGLE)
4450
- pci_unmap_single(ha->pcidev, scb->data_busaddr, scb->data_len,
4451
- IPS_DMA_DIR(scb));
4448
+ dma_unmap_single(&ha->pcidev->dev, scb->data_busaddr,
4449
+ scb->data_len, IPS_DMA_DIR(scb));
44524450
44534451 /* check to make sure this is not our "special" scb */
44544452 if (IPS_COMMAND_ID(ha, scb) < (ha->max_cmds - 1)) {
....@@ -4560,7 +4558,8 @@
45604558 dma_addr_t command_dma;
45614559
45624560 /* Create a usuable SCB */
4563
- scb = pci_alloc_consistent(ha->pcidev, sizeof(ips_scb_t), &command_dma);
4561
+ scb = dma_alloc_coherent(&ha->pcidev->dev, sizeof(ips_scb_t),
4562
+ &command_dma, GFP_KERNEL);
45644563 if (scb) {
45654564 memset(scb, 0, sizeof(ips_scb_t));
45664565 ips_init_scb(ha, scb);
....@@ -4595,7 +4594,7 @@
45954594 /* Now RESET and INIT the adapter */
45964595 (*ha->func.reset) (ha);
45974596
4598
- pci_free_consistent(ha->pcidev, sizeof(ips_scb_t), scb, command_dma);
4597
+ dma_free_coherent(&ha->pcidev->dev, sizeof(ips_scb_t), scb, command_dma);
45994598 return;
46004599 }
46014600
....@@ -4698,7 +4697,6 @@
46984697 uint8_t Isr;
46994698 uint8_t Cbsp;
47004699 uint8_t PostByte[IPS_MAX_POST_BYTES];
4701
- uint8_t ConfigByte[IPS_MAX_CONFIG_BYTES];
47024700 int i, j;
47034701
47044702 METHOD_TRACE("ips_init_copperhead", 1);
....@@ -4743,7 +4741,7 @@
47434741 /* error occurred */
47444742 return (0);
47454743
4746
- ConfigByte[i] = inb(ha->io_addr + IPS_REG_ISPR);
4744
+ inb(ha->io_addr + IPS_REG_ISPR);
47474745 outb(Isr, ha->io_addr + IPS_REG_HISR);
47484746 }
47494747
....@@ -4792,7 +4790,6 @@
47924790 uint8_t Isr = 0;
47934791 uint8_t Cbsp;
47944792 uint8_t PostByte[IPS_MAX_POST_BYTES];
4795
- uint8_t ConfigByte[IPS_MAX_CONFIG_BYTES];
47964793 int i, j;
47974794
47984795 METHOD_TRACE("ips_init_copperhead_memio", 1);
....@@ -4837,7 +4834,7 @@
48374834 /* error occurred */
48384835 return (0);
48394836
4840
- ConfigByte[i] = readb(ha->mem_ptr + IPS_REG_ISPR);
4837
+ readb(ha->mem_ptr + IPS_REG_ISPR);
48414838 writeb(Isr, ha->mem_ptr + IPS_REG_HISR);
48424839 }
48434840
....@@ -5623,10 +5620,10 @@
56235620 /* change values (as needed) */
56245621 ha->nvram->operating_system = IPS_OS_LINUX;
56255622 ha->nvram->adapter_type = ha->ad_type;
5626
- strncpy((char *) ha->nvram->driver_high, IPS_VERSION_HIGH, 4);
5627
- strncpy((char *) ha->nvram->driver_low, IPS_VERSION_LOW, 4);
5628
- strncpy((char *) ha->nvram->bios_high, ha->bios_version, 4);
5629
- strncpy((char *) ha->nvram->bios_low, ha->bios_version + 4, 4);
5623
+ memcpy((char *) ha->nvram->driver_high, IPS_VERSION_HIGH, 4);
5624
+ memcpy((char *) ha->nvram->driver_low, IPS_VERSION_LOW, 4);
5625
+ memcpy((char *) ha->nvram->bios_high, ha->bios_version, 4);
5626
+ memcpy((char *) ha->nvram->bios_low, ha->bios_version + 4, 4);
56305627
56315628 ha->nvram->versioning = 0; /* Indicate the Driver Does Not Support Versioning */
56325629
....@@ -6678,7 +6675,6 @@
66786675 sh->sg_tablesize = sh->hostt->sg_tablesize;
66796676 sh->can_queue = sh->hostt->can_queue;
66806677 sh->cmd_per_lun = sh->hostt->cmd_per_lun;
6681
- sh->use_clustering = sh->hostt->use_clustering;
66826678 sh->max_sectors = 128;
66836679
66846680 sh->max_id = ha->ntargets;
....@@ -6837,8 +6833,6 @@
68376833 uint32_t mem_addr;
68386834 uint32_t io_len;
68396835 uint32_t mem_len;
6840
- uint8_t bus;
6841
- uint8_t func;
68426836 int j;
68436837 int index;
68446838 dma_addr_t dma_address;
....@@ -6857,10 +6851,6 @@
68576851
68586852 if (index >= IPS_MAX_ADAPTERS)
68596853 return -1;
6860
-
6861
- /* stuff that we get in dev */
6862
- bus = pci_dev->bus->number;
6863
- func = pci_dev->devfn;
68646854
68656855 /* Init MEM/IO addresses to 0 */
68666856 mem_addr = 0;
....@@ -6926,30 +6916,31 @@
69266916 * it! Also, don't use 64bit addressing if dma addresses
69276917 * are guaranteed to be < 4G.
69286918 */
6929
- if (IPS_ENABLE_DMA64 && IPS_HAS_ENH_SGLIST(ha) &&
6930
- !pci_set_dma_mask(ha->pcidev, DMA_BIT_MASK(64))) {
6919
+ if (sizeof(dma_addr_t) > 4 && IPS_HAS_ENH_SGLIST(ha) &&
6920
+ !dma_set_mask(&ha->pcidev->dev, DMA_BIT_MASK(64))) {
69316921 (ha)->flags |= IPS_HA_ENH_SG;
69326922 } else {
6933
- if (pci_set_dma_mask(ha->pcidev, DMA_BIT_MASK(32)) != 0) {
6923
+ if (dma_set_mask(&ha->pcidev->dev, DMA_BIT_MASK(32)) != 0) {
69346924 printk(KERN_WARNING "Unable to set DMA Mask\n");
69356925 return ips_abort_init(ha, index);
69366926 }
69376927 }
69386928 if(ips_cd_boot && !ips_FlashData){
6939
- ips_FlashData = pci_alloc_consistent(pci_dev, PAGE_SIZE << 7,
6940
- &ips_flashbusaddr);
6929
+ ips_FlashData = dma_alloc_coherent(&pci_dev->dev,
6930
+ PAGE_SIZE << 7, &ips_flashbusaddr, GFP_KERNEL);
69416931 }
69426932
6943
- ha->enq = pci_alloc_consistent(pci_dev, sizeof (IPS_ENQ),
6944
- &ha->enq_busaddr);
6933
+ ha->enq = dma_alloc_coherent(&pci_dev->dev, sizeof (IPS_ENQ),
6934
+ &ha->enq_busaddr, GFP_KERNEL);
69456935 if (!ha->enq) {
69466936 IPS_PRINTK(KERN_WARNING, pci_dev,
69476937 "Unable to allocate host inquiry structure\n");
69486938 return ips_abort_init(ha, index);
69496939 }
69506940
6951
- ha->adapt = pci_alloc_consistent(pci_dev, sizeof (IPS_ADAPTER) +
6952
- sizeof (IPS_IO_CMD), &dma_address);
6941
+ ha->adapt = dma_alloc_coherent(&pci_dev->dev,
6942
+ sizeof (IPS_ADAPTER) + sizeof (IPS_IO_CMD),
6943
+ &dma_address, GFP_KERNEL);
69536944 if (!ha->adapt) {
69546945 IPS_PRINTK(KERN_WARNING, pci_dev,
69556946 "Unable to allocate host adapt & dummy structures\n");
....@@ -6960,7 +6951,8 @@
69606951
69616952
69626953
6963
- ha->logical_drive_info = pci_alloc_consistent(pci_dev, sizeof (IPS_LD_INFO), &dma_address);
6954
+ ha->logical_drive_info = dma_alloc_coherent(&pci_dev->dev,
6955
+ sizeof (IPS_LD_INFO), &dma_address, GFP_KERNEL);
69646956 if (!ha->logical_drive_info) {
69656957 IPS_PRINTK(KERN_WARNING, pci_dev,
69666958 "Unable to allocate logical drive info structure\n");
....@@ -6998,8 +6990,8 @@
69986990 if (ips_ioctlsize < PAGE_SIZE)
69996991 ips_ioctlsize = PAGE_SIZE;
70006992
7001
- ha->ioctl_data = pci_alloc_consistent(pci_dev, ips_ioctlsize,
7002
- &ha->ioctl_busaddr);
6993
+ ha->ioctl_data = dma_alloc_coherent(&pci_dev->dev, ips_ioctlsize,
6994
+ &ha->ioctl_busaddr, GFP_KERNEL);
70036995 ha->ioctl_len = ips_ioctlsize;
70046996 if (!ha->ioctl_data) {
70056997 IPS_PRINTK(KERN_WARNING, pci_dev,