diff options
Diffstat (limited to 'drivers/scsi/gdth.c')
-rw-r--r-- | drivers/scsi/gdth.c | 320 |
1 files changed, 132 insertions, 188 deletions
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 0b2080d33575..c6d6e7c6559a 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -85,10 +85,10 @@ | |||
85 | 85 | ||
86 | /* The meaning of the Scsi_Pointer members in this driver is as follows: | 86 | /* The meaning of the Scsi_Pointer members in this driver is as follows: |
87 | * ptr: Chaining | 87 | * ptr: Chaining |
88 | * this_residual: gdth_bufflen | 88 | * this_residual: unused |
89 | * buffer: gdth_sglist | 89 | * buffer: unused |
90 | * dma_handle: unused | 90 | * dma_handle: unused |
91 | * buffers_residual: gdth_sg_count | 91 | * buffers_residual: unused |
92 | * Status: unused | 92 | * Status: unused |
93 | * Message: unused | 93 | * Message: unused |
94 | * have_data_in: unused | 94 | * have_data_in: unused |
@@ -372,47 +372,6 @@ static const struct file_operations gdth_fops = { | |||
372 | .release = gdth_close, | 372 | .release = gdth_close, |
373 | }; | 373 | }; |
374 | 374 | ||
375 | /* | ||
376 | * gdth scsi_command access wrappers. | ||
377 | * below 6 functions are used throughout the driver to access scsi_command's | ||
378 | * io parameters. The reason we do not use the regular accessors from | ||
379 | * scsi_cmnd.h is because of gdth_execute(). Since it is unrecommended for | ||
380 | * llds to directly set scsi_cmnd's IO members. This driver will use SCp | ||
381 | * members for IO parameters, and will copy scsi_cmnd's members to Scp | ||
382 | * members in queuecommand. For internal commands through gdth_execute() | ||
383 | * SCp's members will be set directly. | ||
384 | */ | ||
385 | static inline unsigned gdth_bufflen(struct scsi_cmnd *cmd) | ||
386 | { | ||
387 | return (unsigned)cmd->SCp.this_residual; | ||
388 | } | ||
389 | |||
390 | static inline void gdth_set_bufflen(struct scsi_cmnd *cmd, unsigned bufflen) | ||
391 | { | ||
392 | cmd->SCp.this_residual = bufflen; | ||
393 | } | ||
394 | |||
395 | static inline unsigned gdth_sg_count(struct scsi_cmnd *cmd) | ||
396 | { | ||
397 | return (unsigned)cmd->SCp.buffers_residual; | ||
398 | } | ||
399 | |||
400 | static inline void gdth_set_sg_count(struct scsi_cmnd *cmd, unsigned sg_count) | ||
401 | { | ||
402 | cmd->SCp.buffers_residual = sg_count; | ||
403 | } | ||
404 | |||
405 | static inline struct scatterlist *gdth_sglist(struct scsi_cmnd *cmd) | ||
406 | { | ||
407 | return cmd->SCp.buffer; | ||
408 | } | ||
409 | |||
410 | static inline void gdth_set_sglist(struct scsi_cmnd *cmd, | ||
411 | struct scatterlist *sglist) | ||
412 | { | ||
413 | cmd->SCp.buffer = sglist; | ||
414 | } | ||
415 | |||
416 | #include "gdth_proc.h" | 375 | #include "gdth_proc.h" |
417 | #include "gdth_proc.c" | 376 | #include "gdth_proc.c" |
418 | 377 | ||
@@ -591,125 +550,111 @@ static int __init gdth_search_isa(ulong32 bios_adr) | |||
591 | #endif /* CONFIG_ISA */ | 550 | #endif /* CONFIG_ISA */ |
592 | 551 | ||
593 | #ifdef CONFIG_PCI | 552 | #ifdef CONFIG_PCI |
594 | static void gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt, | 553 | static bool gdth_pci_registered; |
595 | ushort vendor, ushort dev); | ||
596 | 554 | ||
597 | static int __init gdth_search_pci(gdth_pci_str *pcistr) | 555 | static bool gdth_search_vortex(ushort device) |
598 | { | 556 | { |
599 | ushort device, cnt; | 557 | if (device <= PCI_DEVICE_ID_VORTEX_GDT6555) |
600 | 558 | return true; | |
601 | TRACE(("gdth_search_pci()\n")); | 559 | if (device >= PCI_DEVICE_ID_VORTEX_GDT6x17RP && |
602 | 560 | device <= PCI_DEVICE_ID_VORTEX_GDTMAXRP) | |
603 | cnt = 0; | 561 | return true; |
604 | for (device = 0; device <= PCI_DEVICE_ID_VORTEX_GDT6555; ++device) | 562 | if (device == PCI_DEVICE_ID_VORTEX_GDTNEWRX || |
605 | gdth_search_dev(pcistr, &cnt, PCI_VENDOR_ID_VORTEX, device); | 563 | device == PCI_DEVICE_ID_VORTEX_GDTNEWRX2) |
606 | for (device = PCI_DEVICE_ID_VORTEX_GDT6x17RP; | 564 | return true; |
607 | device <= PCI_DEVICE_ID_VORTEX_GDTMAXRP; ++device) | 565 | return false; |
608 | gdth_search_dev(pcistr, &cnt, PCI_VENDOR_ID_VORTEX, device); | ||
609 | gdth_search_dev(pcistr, &cnt, PCI_VENDOR_ID_VORTEX, | ||
610 | PCI_DEVICE_ID_VORTEX_GDTNEWRX); | ||
611 | gdth_search_dev(pcistr, &cnt, PCI_VENDOR_ID_VORTEX, | ||
612 | PCI_DEVICE_ID_VORTEX_GDTNEWRX2); | ||
613 | gdth_search_dev(pcistr, &cnt, PCI_VENDOR_ID_INTEL, | ||
614 | PCI_DEVICE_ID_INTEL_SRC); | ||
615 | gdth_search_dev(pcistr, &cnt, PCI_VENDOR_ID_INTEL, | ||
616 | PCI_DEVICE_ID_INTEL_SRC_XSCALE); | ||
617 | return cnt; | ||
618 | } | 566 | } |
619 | 567 | ||
568 | static int gdth_pci_probe_one(gdth_pci_str *pcistr, gdth_ha_str **ha_out); | ||
569 | static int gdth_pci_init_one(struct pci_dev *pdev, | ||
570 | const struct pci_device_id *ent); | ||
571 | static void gdth_pci_remove_one(struct pci_dev *pdev); | ||
572 | static void gdth_remove_one(gdth_ha_str *ha); | ||
573 | |||
620 | /* Vortex only makes RAID controllers. | 574 | /* Vortex only makes RAID controllers. |
621 | * We do not really want to specify all 550 ids here, so wildcard match. | 575 | * We do not really want to specify all 550 ids here, so wildcard match. |
622 | */ | 576 | */ |
623 | static struct pci_device_id gdthtable[] __maybe_unused = { | 577 | static const struct pci_device_id gdthtable[] = { |
624 | {PCI_VENDOR_ID_VORTEX,PCI_ANY_ID,PCI_ANY_ID, PCI_ANY_ID}, | 578 | { PCI_VDEVICE(VORTEX, PCI_ANY_ID) }, |
625 | {PCI_VENDOR_ID_INTEL,PCI_DEVICE_ID_INTEL_SRC,PCI_ANY_ID,PCI_ANY_ID}, | 579 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SRC) }, |
626 | {PCI_VENDOR_ID_INTEL,PCI_DEVICE_ID_INTEL_SRC_XSCALE,PCI_ANY_ID,PCI_ANY_ID}, | 580 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SRC_XSCALE) }, |
627 | {0} | 581 | { } /* terminate list */ |
582 | }; | ||
583 | MODULE_DEVICE_TABLE(pci, gdthtable); | ||
584 | |||
585 | static struct pci_driver gdth_pci_driver = { | ||
586 | .name = "gdth", | ||
587 | .id_table = gdthtable, | ||
588 | .probe = gdth_pci_init_one, | ||
589 | .remove = gdth_pci_remove_one, | ||
628 | }; | 590 | }; |
629 | MODULE_DEVICE_TABLE(pci,gdthtable); | ||
630 | 591 | ||
631 | static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt, | 592 | static void gdth_pci_remove_one(struct pci_dev *pdev) |
632 | ushort vendor, ushort device) | ||
633 | { | 593 | { |
634 | ulong base0, base1, base2; | 594 | gdth_ha_str *ha = pci_get_drvdata(pdev); |
635 | struct pci_dev *pdev; | 595 | |
596 | pci_set_drvdata(pdev, NULL); | ||
597 | |||
598 | list_del(&ha->list); | ||
599 | gdth_remove_one(ha); | ||
600 | |||
601 | pci_disable_device(pdev); | ||
602 | } | ||
603 | |||
604 | static int gdth_pci_init_one(struct pci_dev *pdev, | ||
605 | const struct pci_device_id *ent) | ||
606 | { | ||
607 | ushort vendor = pdev->vendor; | ||
608 | ushort device = pdev->device; | ||
609 | ulong base0, base1, base2; | ||
610 | int rc; | ||
611 | gdth_pci_str gdth_pcistr; | ||
612 | gdth_ha_str *ha = NULL; | ||
636 | 613 | ||
637 | TRACE(("gdth_search_dev() cnt %d vendor %x device %x\n", | 614 | TRACE(("gdth_search_dev() cnt %d vendor %x device %x\n", |
638 | *cnt, vendor, device)); | 615 | gdth_ctr_count, vendor, device)); |
639 | 616 | ||
640 | pdev = NULL; | 617 | memset(&gdth_pcistr, 0, sizeof(gdth_pcistr)); |
641 | while ((pdev = pci_get_device(vendor, device, pdev)) | 618 | |
642 | != NULL) { | 619 | if (vendor == PCI_VENDOR_ID_VORTEX && !gdth_search_vortex(device)) |
643 | if (pci_enable_device(pdev)) | 620 | return -ENODEV; |
644 | continue; | 621 | |
645 | if (*cnt >= MAXHA) { | 622 | rc = pci_enable_device(pdev); |
646 | pci_dev_put(pdev); | 623 | if (rc) |
647 | return; | 624 | return rc; |
648 | } | 625 | |
626 | if (gdth_ctr_count >= MAXHA) | ||
627 | return -EBUSY; | ||
649 | 628 | ||
650 | /* GDT PCI controller found, resources are already in pdev */ | 629 | /* GDT PCI controller found, resources are already in pdev */ |
651 | pcistr[*cnt].pdev = pdev; | 630 | gdth_pcistr.pdev = pdev; |
652 | pcistr[*cnt].irq = pdev->irq; | ||
653 | base0 = pci_resource_flags(pdev, 0); | 631 | base0 = pci_resource_flags(pdev, 0); |
654 | base1 = pci_resource_flags(pdev, 1); | 632 | base1 = pci_resource_flags(pdev, 1); |
655 | base2 = pci_resource_flags(pdev, 2); | 633 | base2 = pci_resource_flags(pdev, 2); |
656 | if (device <= PCI_DEVICE_ID_VORTEX_GDT6000B || /* GDT6000/B */ | 634 | if (device <= PCI_DEVICE_ID_VORTEX_GDT6000B || /* GDT6000/B */ |
657 | device >= PCI_DEVICE_ID_VORTEX_GDT6x17RP) { /* MPR */ | 635 | device >= PCI_DEVICE_ID_VORTEX_GDT6x17RP) { /* MPR */ |
658 | if (!(base0 & IORESOURCE_MEM)) | 636 | if (!(base0 & IORESOURCE_MEM)) |
659 | continue; | 637 | return -ENODEV; |
660 | pcistr[*cnt].dpmem = pci_resource_start(pdev, 0); | 638 | gdth_pcistr.dpmem = pci_resource_start(pdev, 0); |
661 | } else { /* GDT6110, GDT6120, .. */ | 639 | } else { /* GDT6110, GDT6120, .. */ |
662 | if (!(base0 & IORESOURCE_MEM) || | 640 | if (!(base0 & IORESOURCE_MEM) || |
663 | !(base2 & IORESOURCE_MEM) || | 641 | !(base2 & IORESOURCE_MEM) || |
664 | !(base1 & IORESOURCE_IO)) | 642 | !(base1 & IORESOURCE_IO)) |
665 | continue; | 643 | return -ENODEV; |
666 | pcistr[*cnt].dpmem = pci_resource_start(pdev, 2); | 644 | gdth_pcistr.dpmem = pci_resource_start(pdev, 2); |
667 | pcistr[*cnt].io_mm = pci_resource_start(pdev, 0); | 645 | gdth_pcistr.io = pci_resource_start(pdev, 1); |
668 | pcistr[*cnt].io = pci_resource_start(pdev, 1); | ||
669 | } | 646 | } |
670 | TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n", | 647 | TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n", |
671 | pcistr[*cnt].pdev->bus->number, | 648 | gdth_pcistr.pdev->bus->number, |
672 | PCI_SLOT(pcistr[*cnt].pdev->devfn), | 649 | PCI_SLOT(gdth_pcistr.pdev->devfn), |
673 | pcistr[*cnt].irq, pcistr[*cnt].dpmem)); | 650 | gdth_pcistr.irq, |
674 | (*cnt)++; | 651 | gdth_pcistr.dpmem)); |
675 | } | ||
676 | } | ||
677 | 652 | ||
678 | static void __init gdth_sort_pci(gdth_pci_str *pcistr, int cnt) | 653 | rc = gdth_pci_probe_one(&gdth_pcistr, &ha); |
679 | { | 654 | if (rc) |
680 | gdth_pci_str temp; | 655 | return rc; |
681 | int i, changed; | ||
682 | |||
683 | TRACE(("gdth_sort_pci() cnt %d\n",cnt)); | ||
684 | if (cnt == 0) | ||
685 | return; | ||
686 | 656 | ||
687 | do { | 657 | return 0; |
688 | changed = FALSE; | ||
689 | for (i = 0; i < cnt-1; ++i) { | ||
690 | if (!reverse_scan) { | ||
691 | if ((pcistr[i].pdev->bus->number > pcistr[i+1].pdev->bus->number) || | ||
692 | (pcistr[i].pdev->bus->number == pcistr[i+1].pdev->bus->number && | ||
693 | PCI_SLOT(pcistr[i].pdev->devfn) > | ||
694 | PCI_SLOT(pcistr[i+1].pdev->devfn))) { | ||
695 | temp = pcistr[i]; | ||
696 | pcistr[i] = pcistr[i+1]; | ||
697 | pcistr[i+1] = temp; | ||
698 | changed = TRUE; | ||
699 | } | ||
700 | } else { | ||
701 | if ((pcistr[i].pdev->bus->number < pcistr[i+1].pdev->bus->number) || | ||
702 | (pcistr[i].pdev->bus->number == pcistr[i+1].pdev->bus->number && | ||
703 | PCI_SLOT(pcistr[i].pdev->devfn) < | ||
704 | PCI_SLOT(pcistr[i+1].pdev->devfn))) { | ||
705 | temp = pcistr[i]; | ||
706 | pcistr[i] = pcistr[i+1]; | ||
707 | pcistr[i+1] = temp; | ||
708 | changed = TRUE; | ||
709 | } | ||
710 | } | ||
711 | } | ||
712 | } while (changed); | ||
713 | } | 658 | } |
714 | #endif /* CONFIG_PCI */ | 659 | #endif /* CONFIG_PCI */ |
715 | 660 | ||
@@ -909,7 +854,8 @@ static int __init gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha) | |||
909 | #endif /* CONFIG_ISA */ | 854 | #endif /* CONFIG_ISA */ |
910 | 855 | ||
911 | #ifdef CONFIG_PCI | 856 | #ifdef CONFIG_PCI |
912 | static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha) | 857 | static int gdth_init_pci(struct pci_dev *pdev, gdth_pci_str *pcistr, |
858 | gdth_ha_str *ha) | ||
913 | { | 859 | { |
914 | register gdt6_dpram_str __iomem *dp6_ptr; | 860 | register gdt6_dpram_str __iomem *dp6_ptr; |
915 | register gdt6c_dpram_str __iomem *dp6c_ptr; | 861 | register gdt6c_dpram_str __iomem *dp6c_ptr; |
@@ -921,14 +867,14 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha) | |||
921 | 867 | ||
922 | TRACE(("gdth_init_pci()\n")); | 868 | TRACE(("gdth_init_pci()\n")); |
923 | 869 | ||
924 | if (pcistr->pdev->vendor == PCI_VENDOR_ID_INTEL) | 870 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) |
925 | ha->oem_id = OEM_ID_INTEL; | 871 | ha->oem_id = OEM_ID_INTEL; |
926 | else | 872 | else |
927 | ha->oem_id = OEM_ID_ICP; | 873 | ha->oem_id = OEM_ID_ICP; |
928 | ha->brd_phys = (pcistr->pdev->bus->number << 8) | (pcistr->pdev->devfn & 0xf8); | 874 | ha->brd_phys = (pdev->bus->number << 8) | (pdev->devfn & 0xf8); |
929 | ha->stype = (ulong32)pcistr->pdev->device; | 875 | ha->stype = (ulong32)pdev->device; |
930 | ha->irq = pcistr->irq; | 876 | ha->irq = pdev->irq; |
931 | ha->pdev = pcistr->pdev; | 877 | ha->pdev = pdev; |
932 | 878 | ||
933 | if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */ | 879 | if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */ |
934 | TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); | 880 | TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); |
@@ -956,8 +902,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha) | |||
956 | continue; | 902 | continue; |
957 | } | 903 | } |
958 | iounmap(ha->brd); | 904 | iounmap(ha->brd); |
959 | pci_write_config_dword(pcistr->pdev, | 905 | pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, i); |
960 | PCI_BASE_ADDRESS_0, i); | ||
961 | ha->brd = ioremap(i, sizeof(gdt6_dpram_str)); | 906 | ha->brd = ioremap(i, sizeof(gdt6_dpram_str)); |
962 | if (ha->brd == NULL) { | 907 | if (ha->brd == NULL) { |
963 | printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); | 908 | printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); |
@@ -1066,8 +1011,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha) | |||
1066 | continue; | 1011 | continue; |
1067 | } | 1012 | } |
1068 | iounmap(ha->brd); | 1013 | iounmap(ha->brd); |
1069 | pci_write_config_dword(pcistr->pdev, | 1014 | pci_write_config_dword(pdev, PCI_BASE_ADDRESS_2, i); |
1070 | PCI_BASE_ADDRESS_2, i); | ||
1071 | ha->brd = ioremap(i, sizeof(gdt6c_dpram_str)); | 1015 | ha->brd = ioremap(i, sizeof(gdt6c_dpram_str)); |
1072 | if (ha->brd == NULL) { | 1016 | if (ha->brd == NULL) { |
1073 | printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); | 1017 | printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); |
@@ -1159,16 +1103,16 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha) | |||
1159 | } | 1103 | } |
1160 | 1104 | ||
1161 | /* manipulate config. space to enable DPMEM, start RP controller */ | 1105 | /* manipulate config. space to enable DPMEM, start RP controller */ |
1162 | pci_read_config_word(pcistr->pdev, PCI_COMMAND, &command); | 1106 | pci_read_config_word(pdev, PCI_COMMAND, &command); |
1163 | command |= 6; | 1107 | command |= 6; |
1164 | pci_write_config_word(pcistr->pdev, PCI_COMMAND, command); | 1108 | pci_write_config_word(pdev, PCI_COMMAND, command); |
1165 | if (pci_resource_start(pcistr->pdev, 8) == 1UL) | 1109 | if (pci_resource_start(pdev, 8) == 1UL) |
1166 | pci_resource_start(pcistr->pdev, 8) = 0UL; | 1110 | pci_resource_start(pdev, 8) = 0UL; |
1167 | i = 0xFEFF0001UL; | 1111 | i = 0xFEFF0001UL; |
1168 | pci_write_config_dword(pcistr->pdev, PCI_ROM_ADDRESS, i); | 1112 | pci_write_config_dword(pdev, PCI_ROM_ADDRESS, i); |
1169 | gdth_delay(1); | 1113 | gdth_delay(1); |
1170 | pci_write_config_dword(pcistr->pdev, PCI_ROM_ADDRESS, | 1114 | pci_write_config_dword(pdev, PCI_ROM_ADDRESS, |
1171 | pci_resource_start(pcistr->pdev, 8)); | 1115 | pci_resource_start(pdev, 8)); |
1172 | 1116 | ||
1173 | dp6m_ptr = ha->brd; | 1117 | dp6m_ptr = ha->brd; |
1174 | 1118 | ||
@@ -1195,8 +1139,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha) | |||
1195 | continue; | 1139 | continue; |
1196 | } | 1140 | } |
1197 | iounmap(ha->brd); | 1141 | iounmap(ha->brd); |
1198 | pci_write_config_dword(pcistr->pdev, | 1142 | pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, i); |
1199 | PCI_BASE_ADDRESS_0, i); | ||
1200 | ha->brd = ioremap(i, sizeof(gdt6m_dpram_str)); | 1143 | ha->brd = ioremap(i, sizeof(gdt6m_dpram_str)); |
1201 | if (ha->brd == NULL) { | 1144 | if (ha->brd == NULL) { |
1202 | printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); | 1145 | printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); |
@@ -2353,12 +2296,12 @@ static void gdth_next(gdth_ha_str *ha) | |||
2353 | static void gdth_copy_internal_data(gdth_ha_str *ha, Scsi_Cmnd *scp, | 2296 | static void gdth_copy_internal_data(gdth_ha_str *ha, Scsi_Cmnd *scp, |
2354 | char *buffer, ushort count) | 2297 | char *buffer, ushort count) |
2355 | { | 2298 | { |
2356 | ushort cpcount,i, max_sg = gdth_sg_count(scp); | 2299 | ushort cpcount,i, max_sg = scsi_sg_count(scp); |
2357 | ushort cpsum,cpnow; | 2300 | ushort cpsum,cpnow; |
2358 | struct scatterlist *sl; | 2301 | struct scatterlist *sl; |
2359 | char *address; | 2302 | char *address; |
2360 | 2303 | ||
2361 | cpcount = min_t(ushort, count, gdth_bufflen(scp)); | 2304 | cpcount = min_t(ushort, count, scsi_bufflen(scp)); |
2362 | 2305 | ||
2363 | if (cpcount) { | 2306 | if (cpcount) { |
2364 | cpsum=0; | 2307 | cpsum=0; |
@@ -2366,7 +2309,7 @@ static void gdth_copy_internal_data(gdth_ha_str *ha, Scsi_Cmnd *scp, | |||
2366 | unsigned long flags; | 2309 | unsigned long flags; |
2367 | cpnow = (ushort)sl->length; | 2310 | cpnow = (ushort)sl->length; |
2368 | TRACE(("copy_internal() now %d sum %d count %d %d\n", | 2311 | TRACE(("copy_internal() now %d sum %d count %d %d\n", |
2369 | cpnow, cpsum, cpcount, gdth_bufflen(scp))); | 2312 | cpnow, cpsum, cpcount, scsi_bufflen(scp))); |
2370 | if (cpsum+cpnow > cpcount) | 2313 | if (cpsum+cpnow > cpcount) |
2371 | cpnow = cpcount - cpsum; | 2314 | cpnow = cpcount - cpsum; |
2372 | cpsum += cpnow; | 2315 | cpsum += cpnow; |
@@ -2589,10 +2532,10 @@ static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive) | |||
2589 | cmdp->u.cache.BlockCnt = blockcnt; | 2532 | cmdp->u.cache.BlockCnt = blockcnt; |
2590 | } | 2533 | } |
2591 | 2534 | ||
2592 | if (gdth_bufflen(scp)) { | 2535 | if (scsi_bufflen(scp)) { |
2593 | cmndinfo->dma_dir = (read_write == 1 ? | 2536 | cmndinfo->dma_dir = (read_write == 1 ? |
2594 | PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | 2537 | PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); |
2595 | sgcnt = pci_map_sg(ha->pdev, gdth_sglist(scp), gdth_sg_count(scp), | 2538 | sgcnt = pci_map_sg(ha->pdev, scsi_sglist(scp), scsi_sg_count(scp), |
2596 | cmndinfo->dma_dir); | 2539 | cmndinfo->dma_dir); |
2597 | if (mode64) { | 2540 | if (mode64) { |
2598 | struct scatterlist *sl; | 2541 | struct scatterlist *sl; |
@@ -2739,7 +2682,7 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar b) | |||
2739 | cmdp->u.raw64.lun = l; | 2682 | cmdp->u.raw64.lun = l; |
2740 | cmdp->u.raw64.bus = b; | 2683 | cmdp->u.raw64.bus = b; |
2741 | cmdp->u.raw64.priority = 0; | 2684 | cmdp->u.raw64.priority = 0; |
2742 | cmdp->u.raw64.sdlen = gdth_bufflen(scp); | 2685 | cmdp->u.raw64.sdlen = scsi_bufflen(scp); |
2743 | cmdp->u.raw64.sense_len = 16; | 2686 | cmdp->u.raw64.sense_len = 16; |
2744 | cmdp->u.raw64.sense_data = sense_paddr; | 2687 | cmdp->u.raw64.sense_data = sense_paddr; |
2745 | cmdp->u.raw64.direction = | 2688 | cmdp->u.raw64.direction = |
@@ -2756,7 +2699,7 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar b) | |||
2756 | cmdp->u.raw.bus = b; | 2699 | cmdp->u.raw.bus = b; |
2757 | cmdp->u.raw.priority = 0; | 2700 | cmdp->u.raw.priority = 0; |
2758 | cmdp->u.raw.link_p = 0; | 2701 | cmdp->u.raw.link_p = 0; |
2759 | cmdp->u.raw.sdlen = gdth_bufflen(scp); | 2702 | cmdp->u.raw.sdlen = scsi_bufflen(scp); |
2760 | cmdp->u.raw.sense_len = 16; | 2703 | cmdp->u.raw.sense_len = 16; |
2761 | cmdp->u.raw.sense_data = sense_paddr; | 2704 | cmdp->u.raw.sense_data = sense_paddr; |
2762 | cmdp->u.raw.direction = | 2705 | cmdp->u.raw.direction = |
@@ -2765,9 +2708,9 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar b) | |||
2765 | cmdp->u.raw.sg_ranz = 0; | 2708 | cmdp->u.raw.sg_ranz = 0; |
2766 | } | 2709 | } |
2767 | 2710 | ||
2768 | if (gdth_bufflen(scp)) { | 2711 | if (scsi_bufflen(scp)) { |
2769 | cmndinfo->dma_dir = PCI_DMA_BIDIRECTIONAL; | 2712 | cmndinfo->dma_dir = PCI_DMA_BIDIRECTIONAL; |
2770 | sgcnt = pci_map_sg(ha->pdev, gdth_sglist(scp), gdth_sg_count(scp), | 2713 | sgcnt = pci_map_sg(ha->pdev, scsi_sglist(scp), scsi_sg_count(scp), |
2771 | cmndinfo->dma_dir); | 2714 | cmndinfo->dma_dir); |
2772 | if (mode64) { | 2715 | if (mode64) { |
2773 | struct scatterlist *sl; | 2716 | struct scatterlist *sl; |
@@ -3388,8 +3331,8 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index, | |||
3388 | /* retry */ | 3331 | /* retry */ |
3389 | return 2; | 3332 | return 2; |
3390 | } | 3333 | } |
3391 | if (gdth_bufflen(scp)) | 3334 | if (scsi_bufflen(scp)) |
3392 | pci_unmap_sg(ha->pdev, gdth_sglist(scp), gdth_sg_count(scp), | 3335 | pci_unmap_sg(ha->pdev, scsi_sglist(scp), scsi_sg_count(scp), |
3393 | cmndinfo->dma_dir); | 3336 | cmndinfo->dma_dir); |
3394 | 3337 | ||
3395 | if (cmndinfo->sense_paddr) | 3338 | if (cmndinfo->sense_paddr) |
@@ -4031,10 +3974,6 @@ static int gdth_queuecommand(struct scsi_cmnd *scp, | |||
4031 | gdth_update_timeout(scp, scp->timeout_per_command * 6); | 3974 | gdth_update_timeout(scp, scp->timeout_per_command * 6); |
4032 | cmndinfo->priority = DEFAULT_PRI; | 3975 | cmndinfo->priority = DEFAULT_PRI; |
4033 | 3976 | ||
4034 | gdth_set_bufflen(scp, scsi_bufflen(scp)); | ||
4035 | gdth_set_sg_count(scp, scsi_sg_count(scp)); | ||
4036 | gdth_set_sglist(scp, scsi_sglist(scp)); | ||
4037 | |||
4038 | return __gdth_queuecommand(ha, scp, cmndinfo); | 3977 | return __gdth_queuecommand(ha, scp, cmndinfo); |
4039 | } | 3978 | } |
4040 | 3979 | ||
@@ -4955,12 +4894,16 @@ static int __init gdth_eisa_probe_one(ushort eisa_slot) | |||
4955 | #endif /* CONFIG_EISA */ | 4894 | #endif /* CONFIG_EISA */ |
4956 | 4895 | ||
4957 | #ifdef CONFIG_PCI | 4896 | #ifdef CONFIG_PCI |
4958 | static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) | 4897 | static int gdth_pci_probe_one(gdth_pci_str *pcistr, |
4898 | gdth_ha_str **ha_out) | ||
4959 | { | 4899 | { |
4960 | struct Scsi_Host *shp; | 4900 | struct Scsi_Host *shp; |
4961 | gdth_ha_str *ha; | 4901 | gdth_ha_str *ha; |
4962 | dma_addr_t scratch_dma_handle = 0; | 4902 | dma_addr_t scratch_dma_handle = 0; |
4963 | int error, i; | 4903 | int error, i; |
4904 | struct pci_dev *pdev = pcistr->pdev; | ||
4905 | |||
4906 | *ha_out = NULL; | ||
4964 | 4907 | ||
4965 | shp = scsi_host_alloc(&gdth_template, sizeof(gdth_ha_str)); | 4908 | shp = scsi_host_alloc(&gdth_template, sizeof(gdth_ha_str)); |
4966 | if (!shp) | 4909 | if (!shp) |
@@ -4968,13 +4911,13 @@ static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) | |||
4968 | ha = shost_priv(shp); | 4911 | ha = shost_priv(shp); |
4969 | 4912 | ||
4970 | error = -ENODEV; | 4913 | error = -ENODEV; |
4971 | if (!gdth_init_pci(&pcistr[ctr],ha)) | 4914 | if (!gdth_init_pci(pdev, pcistr, ha)) |
4972 | goto out_host_put; | 4915 | goto out_host_put; |
4973 | 4916 | ||
4974 | /* controller found and initialized */ | 4917 | /* controller found and initialized */ |
4975 | printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n", | 4918 | printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n", |
4976 | pcistr[ctr].pdev->bus->number, | 4919 | pdev->bus->number, |
4977 | PCI_SLOT(pcistr[ctr].pdev->devfn), | 4920 | PCI_SLOT(pdev->devfn), |
4978 | ha->irq); | 4921 | ha->irq); |
4979 | 4922 | ||
4980 | error = request_irq(ha->irq, gdth_interrupt, | 4923 | error = request_irq(ha->irq, gdth_interrupt, |
@@ -5019,7 +4962,7 @@ static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) | |||
5019 | 4962 | ||
5020 | ha->scratch_busy = FALSE; | 4963 | ha->scratch_busy = FALSE; |
5021 | ha->req_first = NULL; | 4964 | ha->req_first = NULL; |
5022 | ha->tid_cnt = pcistr[ctr].pdev->device >= 0x200 ? MAXID : MAX_HDRIVES; | 4965 | ha->tid_cnt = pdev->device >= 0x200 ? MAXID : MAX_HDRIVES; |
5023 | if (max_ids > 0 && max_ids < ha->tid_cnt) | 4966 | if (max_ids > 0 && max_ids < ha->tid_cnt) |
5024 | ha->tid_cnt = max_ids; | 4967 | ha->tid_cnt = max_ids; |
5025 | for (i = 0; i < GDTH_MAXCMDS; ++i) | 4968 | for (i = 0; i < GDTH_MAXCMDS; ++i) |
@@ -5039,16 +4982,16 @@ static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) | |||
5039 | /* 64-bit DMA only supported from FW >= x.43 */ | 4982 | /* 64-bit DMA only supported from FW >= x.43 */ |
5040 | if (!(ha->cache_feat & ha->raw_feat & ha->screen_feat & GDT_64BIT) || | 4983 | if (!(ha->cache_feat & ha->raw_feat & ha->screen_feat & GDT_64BIT) || |
5041 | !ha->dma64_support) { | 4984 | !ha->dma64_support) { |
5042 | if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) { | 4985 | if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { |
5043 | printk(KERN_WARNING "GDT-PCI %d: " | 4986 | printk(KERN_WARNING "GDT-PCI %d: " |
5044 | "Unable to set 32-bit DMA\n", ha->hanum); | 4987 | "Unable to set 32-bit DMA\n", ha->hanum); |
5045 | goto out_free_coal_stat; | 4988 | goto out_free_coal_stat; |
5046 | } | 4989 | } |
5047 | } else { | 4990 | } else { |
5048 | shp->max_cmd_len = 16; | 4991 | shp->max_cmd_len = 16; |
5049 | if (!pci_set_dma_mask(pcistr[ctr].pdev, DMA_64BIT_MASK)) { | 4992 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { |
5050 | printk("GDT-PCI %d: 64-bit DMA enabled\n", ha->hanum); | 4993 | printk("GDT-PCI %d: 64-bit DMA enabled\n", ha->hanum); |
5051 | } else if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) { | 4994 | } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { |
5052 | printk(KERN_WARNING "GDT-PCI %d: " | 4995 | printk(KERN_WARNING "GDT-PCI %d: " |
5053 | "Unable to set 64/32-bit DMA\n", ha->hanum); | 4996 | "Unable to set 64/32-bit DMA\n", ha->hanum); |
5054 | goto out_free_coal_stat; | 4997 | goto out_free_coal_stat; |
@@ -5062,13 +5005,17 @@ static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) | |||
5062 | spin_lock_init(&ha->smp_lock); | 5005 | spin_lock_init(&ha->smp_lock); |
5063 | gdth_enable_int(ha); | 5006 | gdth_enable_int(ha); |
5064 | 5007 | ||
5065 | error = scsi_add_host(shp, &pcistr[ctr].pdev->dev); | 5008 | error = scsi_add_host(shp, &pdev->dev); |
5066 | if (error) | 5009 | if (error) |
5067 | goto out_free_coal_stat; | 5010 | goto out_free_coal_stat; |
5068 | list_add_tail(&ha->list, &gdth_instances); | 5011 | list_add_tail(&ha->list, &gdth_instances); |
5069 | 5012 | ||
5013 | pci_set_drvdata(ha->pdev, ha); | ||
5014 | |||
5070 | scsi_scan_host(shp); | 5015 | scsi_scan_host(shp); |
5071 | 5016 | ||
5017 | *ha_out = ha; | ||
5018 | |||
5072 | return 0; | 5019 | return 0; |
5073 | 5020 | ||
5074 | out_free_coal_stat: | 5021 | out_free_coal_stat: |
@@ -5185,16 +5132,8 @@ static int __init gdth_init(void) | |||
5185 | 5132 | ||
5186 | #ifdef CONFIG_PCI | 5133 | #ifdef CONFIG_PCI |
5187 | /* scanning for PCI controllers */ | 5134 | /* scanning for PCI controllers */ |
5188 | { | 5135 | if (pci_register_driver(&gdth_pci_driver) == 0) |
5189 | gdth_pci_str pcistr[MAXHA]; | 5136 | gdth_pci_registered = true; |
5190 | int cnt,ctr; | ||
5191 | |||
5192 | cnt = gdth_search_pci(pcistr); | ||
5193 | printk("GDT-HA: Found %d PCI Storage RAID Controllers\n", cnt); | ||
5194 | gdth_sort_pci(pcistr,cnt); | ||
5195 | for (ctr = 0; ctr < cnt; ++ctr) | ||
5196 | gdth_pci_probe_one(pcistr, ctr); | ||
5197 | } | ||
5198 | #endif /* CONFIG_PCI */ | 5137 | #endif /* CONFIG_PCI */ |
5199 | 5138 | ||
5200 | TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count)); | 5139 | TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count)); |
@@ -5227,6 +5166,11 @@ static void __exit gdth_exit(void) | |||
5227 | del_timer_sync(&gdth_timer); | 5166 | del_timer_sync(&gdth_timer); |
5228 | #endif | 5167 | #endif |
5229 | 5168 | ||
5169 | #ifdef CONFIG_PCI | ||
5170 | if (gdth_pci_registered) | ||
5171 | pci_unregister_driver(&gdth_pci_driver); | ||
5172 | #endif | ||
5173 | |||
5230 | list_for_each_entry(ha, &gdth_instances, list) | 5174 | list_for_each_entry(ha, &gdth_instances, list) |
5231 | gdth_remove_one(ha); | 5175 | gdth_remove_one(ha); |
5232 | } | 5176 | } |