Lines Matching +full:gen +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Copyright (C) 1995-06 ICP vortex GmbH, Achim Leubner *
9 * Copyright (C) 2002-04 Intel Corporation *
10 * Copyright (C) 2003-06 Adaptec Inc. *
33 * reserve_mode:2 reserve all not init. drives
35 * h- controller no., b- channel no.,
36 * t- target ID, l- LUN
39 * max_ids:x x - target ID count per channel (1..MAXID)
42 * hdr_channel:x x - number of virtual bus for host drives
53 * Here is another example: "gdth=reserve_list:0,1,2,0,0,1,3,0,rescan:Y".
64 * The other example: "modprobe gdth reserve_list=0,1,2,0,0,1,3,0 rescan=1".
98 #include <linux/dma-mapping.h>
169 #define TRACE2(a) {if (DebugState==1 || DebugState==2) {printk a;}}
184 #define GDTOFFSOF(a,b) (size_t)&(((a*)0)->b)
187 #define BUS_L2P(a,b) ((b)>(a)->virt_bus ? (b-1):(b))
199 #define DOU 2 /* OUT data direction */
241 /* 64 bit DMA mode, support for drives > 2 TB, if force_dma32 = 0 */
273 if (hanum == ha->hanum) in gdth_find_ha()
285 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_get_cmndinfo()
288 if (ha->cmndinfo[i].index == 0) { in gdth_get_cmndinfo()
289 priv = &ha->cmndinfo[i]; in gdth_get_cmndinfo()
291 priv->index = i+1; in gdth_get_cmndinfo()
296 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_get_cmndinfo()
304 priv->index = 0; in gdth_put_cmndinfo()
319 int internal_command = cmndinfo->internal_command; in gdth_scsi_done()
324 scp->host_scribble = NULL; in gdth_scsi_done()
327 complete((struct completion *)scp->request); in gdth_scsi_done()
329 scp->scsi_done(scp); in gdth_scsi_done()
335 gdth_ha_str *ha = shost_priv(sdev->host); in __gdth_execute()
343 return -ENOMEM; in __gdth_execute()
345 scp->sense_buffer = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); in __gdth_execute()
346 if (!scp->sense_buffer) { in __gdth_execute()
348 return -ENOMEM; in __gdth_execute()
351 scp->device = sdev; in __gdth_execute()
355 scp->request = (struct request *)&wait; in __gdth_execute()
356 scp->cmd_len = 12; in __gdth_execute()
357 scp->cmnd = cmnd; in __gdth_execute()
362 TRACE(("__gdth_execute() cmd 0x%x\n", scp->cmnd[0])); in __gdth_execute()
370 kfree(scp->sense_buffer); in __gdth_execute()
445 list_del(&ha->list); in gdth_pci_remove_one()
454 u16 vendor = pdev->vendor; in gdth_pci_init_one()
455 u16 device = pdev->device; in gdth_pci_init_one()
467 return -ENODEV; in gdth_pci_init_one()
474 return -EBUSY; in gdth_pci_init_one()
480 base2 = pci_resource_flags(pdev, 2); in gdth_pci_init_one()
484 return -ENODEV; in gdth_pci_init_one()
490 return -ENODEV; in gdth_pci_init_one()
491 gdth_pcistr.dpmem = pci_resource_start(pdev, 2); in gdth_pci_init_one()
495 gdth_pcistr.pdev->bus->number, in gdth_pci_init_one()
496 PCI_SLOT(gdth_pcistr.pdev->devfn), in gdth_pci_init_one()
520 if (pdev->vendor == PCI_VENDOR_ID_INTEL) in gdth_init_pci()
521 ha->oem_id = OEM_ID_INTEL; in gdth_init_pci()
523 ha->oem_id = OEM_ID_ICP; in gdth_init_pci()
524 ha->brd_phys = (pdev->bus->number << 8) | (pdev->devfn & 0xf8); in gdth_init_pci()
525 ha->stype = (u32)pdev->device; in gdth_init_pci()
526 ha->irq = pdev->irq; in gdth_init_pci()
527 ha->pdev = pdev; in gdth_init_pci()
529 if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */ in gdth_init_pci()
530 TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); in gdth_init_pci()
531 ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6_dpram_str)); in gdth_init_pci()
532 if (ha->brd == NULL) { in gdth_init_pci()
533 printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); in gdth_init_pci()
537 dp6_ptr = ha->brd; in gdth_init_pci()
538 writel(DPMEM_MAGIC, &dp6_ptr->u); in gdth_init_pci()
539 if (readl(&dp6_ptr->u) != DPMEM_MAGIC) { in gdth_init_pci()
540 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n", in gdth_init_pci()
541 pcistr->dpmem); in gdth_init_pci()
544 iounmap(ha->brd); in gdth_init_pci()
545 ha->brd = ioremap(i, sizeof(u16)); in gdth_init_pci()
546 if (ha->brd == NULL) { in gdth_init_pci()
547 printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); in gdth_init_pci()
550 if (readw(ha->brd) != 0xffff) { in gdth_init_pci()
554 iounmap(ha->brd); in gdth_init_pci()
556 ha->brd = ioremap(i, sizeof(gdt6_dpram_str)); in gdth_init_pci()
557 if (ha->brd == NULL) { in gdth_init_pci()
558 printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); in gdth_init_pci()
561 dp6_ptr = ha->brd; in gdth_init_pci()
562 writel(DPMEM_MAGIC, &dp6_ptr->u); in gdth_init_pci()
563 if (readl(&dp6_ptr->u) == DPMEM_MAGIC) { in gdth_init_pci()
564 printk("GDT-PCI: Use free address at 0x%x\n", i); in gdth_init_pci()
570 printk("GDT-PCI: No free address found!\n"); in gdth_init_pci()
571 iounmap(ha->brd); in gdth_init_pci()
575 memset_io(&dp6_ptr->u, 0, sizeof(dp6_ptr->u)); in gdth_init_pci()
576 if (readl(&dp6_ptr->u) != 0) { in gdth_init_pci()
577 printk("GDT-PCI: Initialization error (DPMEM write error)\n"); in gdth_init_pci()
578 iounmap(ha->brd); in gdth_init_pci()
583 writeb(0xff, &dp6_ptr->io.irqdel); in gdth_init_pci()
584 writeb(0x00, &dp6_ptr->io.irqen); in gdth_init_pci()
585 writeb(0x00, &dp6_ptr->u.ic.S_Status); in gdth_init_pci()
586 writeb(0x00, &dp6_ptr->u.ic.Cmd_Index); in gdth_init_pci()
588 writel(pcistr->dpmem, &dp6_ptr->u.ic.S_Info[0]); in gdth_init_pci()
589 writeb(0xff, &dp6_ptr->u.ic.S_Cmd_Indx); in gdth_init_pci()
590 writeb(0, &dp6_ptr->io.event); in gdth_init_pci()
593 while (readb(&dp6_ptr->u.ic.S_Status) != 0xff) { in gdth_init_pci()
594 if (--retries == 0) { in gdth_init_pci()
595 printk("GDT-PCI: Initialization error (DEINIT failed)\n"); in gdth_init_pci()
596 iounmap(ha->brd); in gdth_init_pci()
601 prot_ver = (u8)readl(&dp6_ptr->u.ic.S_Info[0]); in gdth_init_pci()
602 writeb(0, &dp6_ptr->u.ic.S_Status); in gdth_init_pci()
603 writeb(0xff, &dp6_ptr->io.irqdel); in gdth_init_pci()
605 printk("GDT-PCI: Illegal protocol version\n"); in gdth_init_pci()
606 iounmap(ha->brd); in gdth_init_pci()
610 ha->type = GDT_PCI; in gdth_init_pci()
611 ha->ic_all_size = sizeof(dp6_ptr->u); in gdth_init_pci()
614 writel(0x00, &dp6_ptr->u.ic.S_Info[0]); in gdth_init_pci()
615 writel(0x00, &dp6_ptr->u.ic.S_Info[1]); in gdth_init_pci()
616 writel(0x00, &dp6_ptr->u.ic.S_Info[2]); in gdth_init_pci()
617 writel(0x00, &dp6_ptr->u.ic.S_Info[3]); in gdth_init_pci()
618 writeb(0xfe, &dp6_ptr->u.ic.S_Cmd_Indx); in gdth_init_pci()
619 writeb(0, &dp6_ptr->io.event); in gdth_init_pci()
622 while (readb(&dp6_ptr->u.ic.S_Status) != 0xfe) { in gdth_init_pci()
623 if (--retries == 0) { in gdth_init_pci()
624 printk("GDT-PCI: Initialization error\n"); in gdth_init_pci()
625 iounmap(ha->brd); in gdth_init_pci()
630 writeb(0, &dp6_ptr->u.ic.S_Status); in gdth_init_pci()
631 writeb(0xff, &dp6_ptr->io.irqdel); in gdth_init_pci()
633 ha->dma64_support = 0; in gdth_init_pci()
635 } else if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6555) { /* GDT6110, ... */ in gdth_init_pci()
636 ha->plx = (gdt6c_plx_regs *)pcistr->io; in gdth_init_pci()
638 pcistr->dpmem,ha->irq)); in gdth_init_pci()
639 ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6c_dpram_str)); in gdth_init_pci()
640 if (ha->brd == NULL) { in gdth_init_pci()
641 printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); in gdth_init_pci()
642 iounmap(ha->brd); in gdth_init_pci()
646 dp6c_ptr = ha->brd; in gdth_init_pci()
647 writel(DPMEM_MAGIC, &dp6c_ptr->u); in gdth_init_pci()
648 if (readl(&dp6c_ptr->u) != DPMEM_MAGIC) { in gdth_init_pci()
649 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n", in gdth_init_pci()
650 pcistr->dpmem); in gdth_init_pci()
653 iounmap(ha->brd); in gdth_init_pci()
654 ha->brd = ioremap(i, sizeof(u16)); in gdth_init_pci()
655 if (ha->brd == NULL) { in gdth_init_pci()
656 printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); in gdth_init_pci()
659 if (readw(ha->brd) != 0xffff) { in gdth_init_pci()
663 iounmap(ha->brd); in gdth_init_pci()
665 ha->brd = ioremap(i, sizeof(gdt6c_dpram_str)); in gdth_init_pci()
666 if (ha->brd == NULL) { in gdth_init_pci()
667 printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); in gdth_init_pci()
670 dp6c_ptr = ha->brd; in gdth_init_pci()
671 writel(DPMEM_MAGIC, &dp6c_ptr->u); in gdth_init_pci()
672 if (readl(&dp6c_ptr->u) == DPMEM_MAGIC) { in gdth_init_pci()
673 printk("GDT-PCI: Use free address at 0x%x\n", i); in gdth_init_pci()
679 printk("GDT-PCI: No free address found!\n"); in gdth_init_pci()
680 iounmap(ha->brd); in gdth_init_pci()
684 memset_io(&dp6c_ptr->u, 0, sizeof(dp6c_ptr->u)); in gdth_init_pci()
685 if (readl(&dp6c_ptr->u) != 0) { in gdth_init_pci()
686 printk("GDT-PCI: Initialization error (DPMEM write error)\n"); in gdth_init_pci()
687 iounmap(ha->brd); in gdth_init_pci()
692 outb(0x00,PTR2USHORT(&ha->plx->control1)); in gdth_init_pci()
693 outb(0xff,PTR2USHORT(&ha->plx->edoor_reg)); in gdth_init_pci()
695 writeb(0x00, &dp6c_ptr->u.ic.S_Status); in gdth_init_pci()
696 writeb(0x00, &dp6c_ptr->u.ic.Cmd_Index); in gdth_init_pci()
698 writel(pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0]); in gdth_init_pci()
699 writeb(0xff, &dp6c_ptr->u.ic.S_Cmd_Indx); in gdth_init_pci()
701 outb(1,PTR2USHORT(&ha->plx->ldoor_reg)); in gdth_init_pci()
705 while (readb(&dp6c_ptr->u.ic.S_Status) != 0xff) { in gdth_init_pci()
706 if (--retries == 0) { in gdth_init_pci()
707 printk("GDT-PCI: Initialization error (DEINIT failed)\n"); in gdth_init_pci()
708 iounmap(ha->brd); in gdth_init_pci()
713 prot_ver = (u8)readl(&dp6c_ptr->u.ic.S_Info[0]); in gdth_init_pci()
714 writeb(0, &dp6c_ptr->u.ic.Status); in gdth_init_pci()
716 printk("GDT-PCI: Illegal protocol version\n"); in gdth_init_pci()
717 iounmap(ha->brd); in gdth_init_pci()
721 ha->type = GDT_PCINEW; in gdth_init_pci()
722 ha->ic_all_size = sizeof(dp6c_ptr->u); in gdth_init_pci()
725 writel(0x00, &dp6c_ptr->u.ic.S_Info[0]); in gdth_init_pci()
726 writel(0x00, &dp6c_ptr->u.ic.S_Info[1]); in gdth_init_pci()
727 writel(0x00, &dp6c_ptr->u.ic.S_Info[2]); in gdth_init_pci()
728 writel(0x00, &dp6c_ptr->u.ic.S_Info[3]); in gdth_init_pci()
729 writeb(0xfe, &dp6c_ptr->u.ic.S_Cmd_Indx); in gdth_init_pci()
731 outb(1,PTR2USHORT(&ha->plx->ldoor_reg)); in gdth_init_pci()
735 while (readb(&dp6c_ptr->u.ic.S_Status) != 0xfe) { in gdth_init_pci()
736 if (--retries == 0) { in gdth_init_pci()
737 printk("GDT-PCI: Initialization error\n"); in gdth_init_pci()
738 iounmap(ha->brd); in gdth_init_pci()
743 writeb(0, &dp6c_ptr->u.ic.S_Status); in gdth_init_pci()
745 ha->dma64_support = 0; in gdth_init_pci()
748 TRACE2(("init_pci_mpr() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); in gdth_init_pci()
749 ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6m_dpram_str)); in gdth_init_pci()
750 if (ha->brd == NULL) { in gdth_init_pci()
751 printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); in gdth_init_pci()
761 dp6m_ptr = ha->brd; in gdth_init_pci()
765 while( ((int)readb(&dp6m_ptr->i960r.sema0_reg) ) & 3 ) in gdth_init_pci()
769 writel(DPMEM_MAGIC, &dp6m_ptr->u); in gdth_init_pci()
770 if (readl(&dp6m_ptr->u) != DPMEM_MAGIC) { in gdth_init_pci()
771 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n", in gdth_init_pci()
772 pcistr->dpmem); in gdth_init_pci()
775 iounmap(ha->brd); in gdth_init_pci()
776 ha->brd = ioremap(i, sizeof(u16)); in gdth_init_pci()
777 if (ha->brd == NULL) { in gdth_init_pci()
778 printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); in gdth_init_pci()
781 if (readw(ha->brd) != 0xffff) { in gdth_init_pci()
785 iounmap(ha->brd); in gdth_init_pci()
787 ha->brd = ioremap(i, sizeof(gdt6m_dpram_str)); in gdth_init_pci()
788 if (ha->brd == NULL) { in gdth_init_pci()
789 printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); in gdth_init_pci()
792 dp6m_ptr = ha->brd; in gdth_init_pci()
793 writel(DPMEM_MAGIC, &dp6m_ptr->u); in gdth_init_pci()
794 if (readl(&dp6m_ptr->u) == DPMEM_MAGIC) { in gdth_init_pci()
795 printk("GDT-PCI: Use free address at 0x%x\n", i); in gdth_init_pci()
801 printk("GDT-PCI: No free address found!\n"); in gdth_init_pci()
802 iounmap(ha->brd); in gdth_init_pci()
806 memset_io(&dp6m_ptr->u, 0, sizeof(dp6m_ptr->u)); in gdth_init_pci()
809 writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) | 4, in gdth_init_pci()
810 &dp6m_ptr->i960r.edoor_en_reg); in gdth_init_pci()
811 writeb(0xff, &dp6m_ptr->i960r.edoor_reg); in gdth_init_pci()
812 writeb(0x00, &dp6m_ptr->u.ic.S_Status); in gdth_init_pci()
813 writeb(0x00, &dp6m_ptr->u.ic.Cmd_Index); in gdth_init_pci()
815 writel(pcistr->dpmem, &dp6m_ptr->u.ic.S_Info[0]); in gdth_init_pci()
816 writeb(0xff, &dp6m_ptr->u.ic.S_Cmd_Indx); in gdth_init_pci()
817 writeb(1, &dp6m_ptr->i960r.ldoor_reg); in gdth_init_pci()
820 while (readb(&dp6m_ptr->u.ic.S_Status) != 0xff) { in gdth_init_pci()
821 if (--retries == 0) { in gdth_init_pci()
822 printk("GDT-PCI: Initialization error (DEINIT failed)\n"); in gdth_init_pci()
823 iounmap(ha->brd); in gdth_init_pci()
828 prot_ver = (u8)readl(&dp6m_ptr->u.ic.S_Info[0]); in gdth_init_pci()
829 writeb(0, &dp6m_ptr->u.ic.S_Status); in gdth_init_pci()
831 printk("GDT-PCI: Illegal protocol version\n"); in gdth_init_pci()
832 iounmap(ha->brd); in gdth_init_pci()
836 ha->type = GDT_PCIMPR; in gdth_init_pci()
837 ha->ic_all_size = sizeof(dp6m_ptr->u); in gdth_init_pci()
840 writel(0x00, &dp6m_ptr->u.ic.S_Info[0]); in gdth_init_pci()
841 writel(0x00, &dp6m_ptr->u.ic.S_Info[1]); in gdth_init_pci()
842 writel(0x00, &dp6m_ptr->u.ic.S_Info[2]); in gdth_init_pci()
843 writel(0x00, &dp6m_ptr->u.ic.S_Info[3]); in gdth_init_pci()
844 writeb(0xfe, &dp6m_ptr->u.ic.S_Cmd_Indx); in gdth_init_pci()
845 writeb(1, &dp6m_ptr->i960r.ldoor_reg); in gdth_init_pci()
848 while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfe) { in gdth_init_pci()
849 if (--retries == 0) { in gdth_init_pci()
850 printk("GDT-PCI: Initialization error\n"); in gdth_init_pci()
851 iounmap(ha->brd); in gdth_init_pci()
856 writeb(0, &dp6m_ptr->u.ic.S_Status); in gdth_init_pci()
858 /* read FW version to detect 64-bit DMA support */ in gdth_init_pci()
859 writeb(0xfd, &dp6m_ptr->u.ic.S_Cmd_Indx); in gdth_init_pci()
860 writeb(1, &dp6m_ptr->i960r.ldoor_reg); in gdth_init_pci()
863 while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfd) { in gdth_init_pci()
864 if (--retries == 0) { in gdth_init_pci()
865 printk("GDT-PCI: Initialization error (DEINIT failed)\n"); in gdth_init_pci()
866 iounmap(ha->brd); in gdth_init_pci()
871 prot_ver = (u8)(readl(&dp6m_ptr->u.ic.S_Info[0]) >> 16); in gdth_init_pci()
872 writeb(0, &dp6m_ptr->u.ic.S_Status); in gdth_init_pci()
873 if (prot_ver < 0x2b) /* FW < x.43: no 64-bit DMA support */ in gdth_init_pci()
874 ha->dma64_support = 0; in gdth_init_pci()
876 ha->dma64_support = 1; in gdth_init_pci()
890 TRACE(("gdth_enable_int() hanum %d\n",ha->hanum)); in gdth_enable_int()
891 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_enable_int()
893 if (ha->type == GDT_PCI) { in gdth_enable_int()
894 dp6_ptr = ha->brd; in gdth_enable_int()
895 writeb(1, &dp6_ptr->io.irqdel); in gdth_enable_int()
896 writeb(0, &dp6_ptr->u.ic.Cmd_Index); in gdth_enable_int()
897 writeb(1, &dp6_ptr->io.irqen); in gdth_enable_int()
898 } else if (ha->type == GDT_PCINEW) { in gdth_enable_int()
899 outb(0xff, PTR2USHORT(&ha->plx->edoor_reg)); in gdth_enable_int()
900 outb(0x03, PTR2USHORT(&ha->plx->control1)); in gdth_enable_int()
901 } else if (ha->type == GDT_PCIMPR) { in gdth_enable_int()
902 dp6m_ptr = ha->brd; in gdth_enable_int()
903 writeb(0xff, &dp6m_ptr->i960r.edoor_reg); in gdth_enable_int()
904 writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) & ~4, in gdth_enable_int()
905 &dp6m_ptr->i960r.edoor_en_reg); in gdth_enable_int()
907 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_enable_int()
915 TRACE(("gdth_get_status() irq %d ctr_count %d\n", ha->irq, gdth_ctr_count)); in gdth_get_status()
917 if (ha->type == GDT_PCI) in gdth_get_status()
919 readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Cmd_Index); in gdth_get_status()
920 else if (ha->type == GDT_PCINEW) in gdth_get_status()
921 IStatus = inb(PTR2USHORT(&ha->plx->edoor_reg)); in gdth_get_status()
922 else if (ha->type == GDT_PCIMPR) in gdth_get_status()
924 readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.edoor_reg); in gdth_get_status()
933 TRACE(("gdth_test_busy() hanum %d\n", ha->hanum)); in gdth_test_busy()
935 if (ha->type == GDT_PCI) in gdth_test_busy()
936 gdtsema0 = (int)readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0); in gdth_test_busy()
937 else if (ha->type == GDT_PCINEW) in gdth_test_busy()
938 gdtsema0 = (int)inb(PTR2USHORT(&ha->plx->sema0_reg)); in gdth_test_busy()
939 else if (ha->type == GDT_PCIMPR) in gdth_test_busy()
941 (int)readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg); in gdth_test_busy()
951 TRACE(("gdth_get_cmd_index() hanum %d\n", ha->hanum)); in gdth_get_cmd_index()
954 if (ha->cmd_tab[i].cmnd == UNUSED_CMND) { in gdth_get_cmd_index()
955 ha->cmd_tab[i].cmnd = ha->pccb->RequestBuffer; in gdth_get_cmd_index()
956 ha->cmd_tab[i].service = ha->pccb->Service; in gdth_get_cmd_index()
957 ha->pccb->CommandIndex = (u32)i+2; in gdth_get_cmd_index()
958 return (i+2); in gdth_get_cmd_index()
967 TRACE(("gdth_set_sema0() hanum %d\n", ha->hanum)); in gdth_set_sema0()
969 if (ha->type == GDT_PCI) { in gdth_set_sema0()
970 writeb(1, &((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0); in gdth_set_sema0()
971 } else if (ha->type == GDT_PCINEW) { in gdth_set_sema0()
972 outb(1, PTR2USHORT(&ha->plx->sema0_reg)); in gdth_set_sema0()
973 } else if (ha->type == GDT_PCIMPR) { in gdth_set_sema0()
974 writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg); in gdth_set_sema0()
987 TRACE(("gdth_copy_command() hanum %d\n", ha->hanum)); in gdth_copy_command()
989 cp_count = ha->cmd_len; in gdth_copy_command()
990 dp_offset= ha->cmd_offs_dpmem; in gdth_copy_command()
991 cmd_no = ha->cmd_cnt; in gdth_copy_command()
992 cmd_ptr = ha->pccb; in gdth_copy_command()
994 ++ha->cmd_cnt; in gdth_copy_command()
998 cp_count += (4 - (cp_count & 3)); in gdth_copy_command()
1000 ha->cmd_offs_dpmem += cp_count; in gdth_copy_command()
1003 if (ha->type == GDT_PCI) { in gdth_copy_command()
1004 dp6_ptr = ha->brd; in gdth_copy_command()
1006 &dp6_ptr->u.ic.comm_queue[cmd_no].offset); in gdth_copy_command()
1007 writew((u16)cmd_ptr->Service, in gdth_copy_command()
1008 &dp6_ptr->u.ic.comm_queue[cmd_no].serv_id); in gdth_copy_command()
1009 memcpy_toio(&dp6_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count); in gdth_copy_command()
1010 } else if (ha->type == GDT_PCINEW) { in gdth_copy_command()
1011 dp6c_ptr = ha->brd; in gdth_copy_command()
1013 &dp6c_ptr->u.ic.comm_queue[cmd_no].offset); in gdth_copy_command()
1014 writew((u16)cmd_ptr->Service, in gdth_copy_command()
1015 &dp6c_ptr->u.ic.comm_queue[cmd_no].serv_id); in gdth_copy_command()
1016 memcpy_toio(&dp6c_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count); in gdth_copy_command()
1017 } else if (ha->type == GDT_PCIMPR) { in gdth_copy_command()
1018 dp6m_ptr = ha->brd; in gdth_copy_command()
1020 &dp6m_ptr->u.ic.comm_queue[cmd_no].offset); in gdth_copy_command()
1021 writew((u16)cmd_ptr->Service, in gdth_copy_command()
1022 &dp6m_ptr->u.ic.comm_queue[cmd_no].serv_id); in gdth_copy_command()
1023 memcpy_toio(&dp6m_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count); in gdth_copy_command()
1030 TRACE(("gdth_release_event() hanum %d\n", ha->hanum)); in gdth_release_event()
1036 if (ha->cmd_tab[j].cmnd != UNUSED_CMND) in gdth_release_event()
1046 if (ha->pccb->OpCode == GDT_INIT) in gdth_release_event()
1047 ha->pccb->Service |= 0x80; in gdth_release_event()
1049 if (ha->type == GDT_PCI) { in gdth_release_event()
1050 writeb(0, &((gdt6_dpram_str __iomem *)ha->brd)->io.event); in gdth_release_event()
1051 } else if (ha->type == GDT_PCINEW) { in gdth_release_event()
1052 outb(1, PTR2USHORT(&ha->plx->ldoor_reg)); in gdth_release_event()
1053 } else if (ha->type == GDT_PCIMPR) { in gdth_release_event()
1054 writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.ldoor_reg); in gdth_release_event()
1063 TRACE(("gdth_wait() hanum %d index %d time %d\n", ha->hanum, index, time)); in gdth_wait()
1075 } while (--time); in gdth_wait()
1092 cmd_ptr = ha->pccb; in gdth_internal_cmd()
1097 cmd_ptr->Service = service; in gdth_internal_cmd()
1098 cmd_ptr->RequestBuffer = INTERNAL_CMND; in gdth_internal_cmd()
1104 cmd_ptr->OpCode = opcode; in gdth_internal_cmd()
1105 cmd_ptr->BoardNode = LOCALBOARD; in gdth_internal_cmd()
1108 cmd_ptr->u.ioctl.subfunc = p1; in gdth_internal_cmd()
1109 cmd_ptr->u.ioctl.channel = (u32)p2; in gdth_internal_cmd()
1110 cmd_ptr->u.ioctl.param_size = (u16)p3; in gdth_internal_cmd()
1111 cmd_ptr->u.ioctl.p_param = ha->scratch_phys; in gdth_internal_cmd()
1113 if (ha->cache_feat & GDT_64BIT) { in gdth_internal_cmd()
1114 cmd_ptr->u.cache64.DeviceNo = (u16)p1; in gdth_internal_cmd()
1115 cmd_ptr->u.cache64.BlockNo = p2; in gdth_internal_cmd()
1117 cmd_ptr->u.cache.DeviceNo = (u16)p1; in gdth_internal_cmd()
1118 cmd_ptr->u.cache.BlockNo = (u32)p2; in gdth_internal_cmd()
1122 if (ha->raw_feat & GDT_64BIT) { in gdth_internal_cmd()
1123 cmd_ptr->u.raw64.direction = p1; in gdth_internal_cmd()
1124 cmd_ptr->u.raw64.bus = (u8)p2; in gdth_internal_cmd()
1125 cmd_ptr->u.raw64.target = (u8)p3; in gdth_internal_cmd()
1126 cmd_ptr->u.raw64.lun = (u8)(p3 >> 8); in gdth_internal_cmd()
1128 cmd_ptr->u.raw.direction = p1; in gdth_internal_cmd()
1129 cmd_ptr->u.raw.bus = (u8)p2; in gdth_internal_cmd()
1130 cmd_ptr->u.raw.target = (u8)p3; in gdth_internal_cmd()
1131 cmd_ptr->u.raw.lun = (u8)(p3 >> 8); in gdth_internal_cmd()
1135 *(u32 *)&cmd_ptr->u.screen.su.data[0] = p1; in gdth_internal_cmd()
1136 *(u32 *)&cmd_ptr->u.screen.su.data[4] = (u32)p2; in gdth_internal_cmd()
1137 *(u32 *)&cmd_ptr->u.screen.su.data[8] = (u32)p3; in gdth_internal_cmd()
1140 ha->cmd_len = sizeof(gdth_cmd_str); in gdth_internal_cmd()
1141 ha->cmd_offs_dpmem = 0; in gdth_internal_cmd()
1142 ha->cmd_cnt = 0; in gdth_internal_cmd()
1150 if (ha->status != S_BSY || --retries == 0) in gdth_internal_cmd()
1155 return (ha->status != S_OK ? 0:1); in gdth_internal_cmd()
1174 TRACE(("gdth_search_drives() hanum %d\n", ha->hanum)); in gdth_search_drives()
1178 ha->screen_feat = 0; in gdth_search_drives()
1182 ha->screen_feat = GDT_64BIT; in gdth_search_drives()
1184 if (force_dma32 || (!ok && ha->status == (u16)S_NOFUNC)) in gdth_search_drives()
1187 printk("GDT-HA %d: Initialization error screen service (code %d)\n", in gdth_search_drives()
1188 ha->hanum, ha->status); in gdth_search_drives()
1197 ha->cache_feat = 0; in gdth_search_drives()
1202 ha->cache_feat = GDT_64BIT; in gdth_search_drives()
1204 if (force_dma32 || (!ok && ha->status == (u16)S_NOFUNC)) in gdth_search_drives()
1207 printk("GDT-HA %d: Initialization error cache service (code %d)\n", in gdth_search_drives()
1208 ha->hanum, ha->status); in gdth_search_drives()
1212 cdev_cnt = (u16)ha->info; in gdth_search_drives()
1213 ha->fw_vers = ha->service; in gdth_search_drives()
1215 /* detect number of buses - try new IOCTL */ in gdth_search_drives()
1216 iocr = (gdth_raw_iochan_str *)ha->pscratch; in gdth_search_drives()
1217 iocr->hdr.version = 0xffffffff; in gdth_search_drives()
1218 iocr->hdr.list_entries = MAXBUS; in gdth_search_drives()
1219 iocr->hdr.first_chan = 0; in gdth_search_drives()
1220 iocr->hdr.last_chan = MAXBUS-1; in gdth_search_drives()
1221 iocr->hdr.list_offset = GDTOFFSOF(gdth_raw_iochan_str, list[0]); in gdth_search_drives()
1225 ha->bus_cnt = iocr->hdr.chan_count; in gdth_search_drives()
1226 for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { in gdth_search_drives()
1227 if (iocr->list[bus_no].proc_id < MAXID) in gdth_search_drives()
1228 ha->bus_id[bus_no] = iocr->list[bus_no].proc_id; in gdth_search_drives()
1230 ha->bus_id[bus_no] = 0xff; in gdth_search_drives()
1234 chn = (gdth_getch_str *)ha->pscratch; in gdth_search_drives()
1236 chn->channel_no = bus_no; in gdth_search_drives()
1242 printk("GDT-HA %d: Error detecting channel count (0x%x)\n", in gdth_search_drives()
1243 ha->hanum, ha->status); in gdth_search_drives()
1248 if (chn->siop_id < MAXID) in gdth_search_drives()
1249 ha->bus_id[bus_no] = chn->siop_id; in gdth_search_drives()
1251 ha->bus_id[bus_no] = 0xff; in gdth_search_drives()
1253 ha->bus_cnt = (u8)bus_no; in gdth_search_drives()
1255 TRACE2(("gdth_search_drives() %d channels\n",ha->bus_cnt)); in gdth_search_drives()
1260 printk("GDT-HA %d: Initialization error cache service (code %d)\n", in gdth_search_drives()
1261 ha->hanum, ha->status); in gdth_search_drives()
1264 ha->cpar = ((gdth_cinfo_str *)ha->pscratch)->cpar; in gdth_search_drives()
1266 ha->cpar.version,ha->cpar.state,ha->cpar.strategy, in gdth_search_drives()
1267 ha->cpar.write_back,ha->cpar.block_size)); in gdth_search_drives()
1270 ha->more_proc = FALSE; in gdth_search_drives()
1273 memcpy(&ha->binfo, (gdth_binfo_str *)ha->pscratch, in gdth_search_drives()
1278 ha->bfeat = *(gdth_bfeat_str *)ha->pscratch; in gdth_search_drives()
1279 ha->more_proc = TRUE; in gdth_search_drives()
1283 strcpy(ha->binfo.type_string, gdth_ctr_name(ha)); in gdth_search_drives()
1285 TRACE2(("Controller name: %s\n",ha->binfo.type_string)); in gdth_search_drives()
1288 if (ha->more_proc) { in gdth_search_drives()
1290 ioc = (gdth_iochan_str *)ha->pscratch; in gdth_search_drives()
1291 ioc->hdr.version = 0xffffffff; in gdth_search_drives()
1292 ioc->hdr.list_entries = MAXBUS; in gdth_search_drives()
1293 ioc->hdr.first_chan = 0; in gdth_search_drives()
1294 ioc->hdr.last_chan = MAXBUS-1; in gdth_search_drives()
1295 ioc->hdr.list_offset = GDTOFFSOF(gdth_iochan_str, list[0]); in gdth_search_drives()
1298 for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { in gdth_search_drives()
1299 ha->raw[bus_no].address = ioc->list[bus_no].address; in gdth_search_drives()
1300 ha->raw[bus_no].local_no = ioc->list[bus_no].local_no; in gdth_search_drives()
1303 for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { in gdth_search_drives()
1304 ha->raw[bus_no].address = IO_CHANNEL; in gdth_search_drives()
1305 ha->raw[bus_no].local_no = bus_no; in gdth_search_drives()
1308 for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { in gdth_search_drives()
1309 chn = (gdth_getch_str *)ha->pscratch; in gdth_search_drives()
1310 chn->channel_no = ha->raw[bus_no].local_no; in gdth_search_drives()
1313 ha->raw[bus_no].address | INVALID_CHANNEL, in gdth_search_drives()
1315 ha->raw[bus_no].pdev_cnt = chn->drive_cnt; in gdth_search_drives()
1317 bus_no,chn->drive_cnt)); in gdth_search_drives()
1319 if (ha->raw[bus_no].pdev_cnt > 0) { in gdth_search_drives()
1320 drl = (gdth_drlist_str *)ha->pscratch; in gdth_search_drives()
1321 drl->sc_no = ha->raw[bus_no].local_no; in gdth_search_drives()
1322 drl->sc_cnt = ha->raw[bus_no].pdev_cnt; in gdth_search_drives()
1325 ha->raw[bus_no].address | INVALID_CHANNEL, in gdth_search_drives()
1327 for (j = 0; j < ha->raw[bus_no].pdev_cnt; ++j) in gdth_search_drives()
1328 ha->raw[bus_no].id_list[j] = drl->sc_list[j]; in gdth_search_drives()
1330 ha->raw[bus_no].pdev_cnt = 0; in gdth_search_drives()
1338 drv_cnt = *(u32 *)ha->pscratch; in gdth_search_drives()
1342 drv_no = ((u32 *)ha->pscratch)[j]; in gdth_search_drives()
1344 ha->hdr[drv_no].is_logdrv = TRUE; in gdth_search_drives()
1349 alst = (gdth_arcdl_str *)ha->pscratch; in gdth_search_drives()
1350 alst->entries_avail = MAX_LDRIVES; in gdth_search_drives()
1351 alst->first_entry = 0; in gdth_search_drives()
1352 alst->list_offset = GDTOFFSOF(gdth_arcdl_str, list[0]); in gdth_search_drives()
1356 (alst->entries_avail-1) * sizeof(gdth_alist_str))) { in gdth_search_drives()
1357 for (j = 0; j < alst->entries_init; ++j) { in gdth_search_drives()
1358 ha->hdr[j].is_arraydrv = alst->list[j].is_arrayd; in gdth_search_drives()
1359 ha->hdr[j].is_master = alst->list[j].is_master; in gdth_search_drives()
1360 ha->hdr[j].is_parity = alst->list[j].is_parity; in gdth_search_drives()
1361 ha->hdr[j].is_hotfix = alst->list[j].is_hotfix; in gdth_search_drives()
1362 ha->hdr[j].master_no = alst->list[j].cd_handle; in gdth_search_drives()
1368 alst2 = &((gdth_alist_str *)ha->pscratch)[j]; in gdth_search_drives()
1369 ha->hdr[j].is_arraydrv = alst2->is_arrayd; in gdth_search_drives()
1370 ha->hdr[j].is_master = alst2->is_master; in gdth_search_drives()
1371 ha->hdr[j].is_parity = alst2->is_parity; in gdth_search_drives()
1372 ha->hdr[j].is_hotfix = alst2->is_hotfix; in gdth_search_drives()
1373 ha->hdr[j].master_no = alst2->cd_handle; in gdth_search_drives()
1380 ha->raw_feat = 0; in gdth_search_drives()
1384 ha->raw_feat = GDT_64BIT; in gdth_search_drives()
1386 if (force_dma32 || (!ok && ha->status == (u16)S_NOFUNC)) in gdth_search_drives()
1389 printk("GDT-HA %d: Initialization error raw service (code %d)\n", in gdth_search_drives()
1390 ha->hanum, ha->status); in gdth_search_drives()
1401 ha->info)); in gdth_search_drives()
1402 ha->raw_feat |= (u16)ha->info; in gdth_search_drives()
1412 ha->info)); in gdth_search_drives()
1413 ha->cache_feat |= (u16)ha->info; in gdth_search_drives()
1422 ha->status)); in gdth_search_drives()
1425 if (reserve_list[i] == ha->hanum && reserve_list[i+1] < ha->bus_cnt && in gdth_search_drives()
1426 reserve_list[i+2] < ha->tid_cnt && reserve_list[i+3] < MAXLUN) { in gdth_search_drives()
1429 reserve_list[i+2], reserve_list[i+3])); in gdth_search_drives()
1431 reserve_list[i+1], reserve_list[i+2] | in gdth_search_drives()
1433 printk("GDT-HA %d: Error raw service (RESERVE, code %d)\n", in gdth_search_drives()
1434 ha->hanum, ha->status); in gdth_search_drives()
1440 oemstr = (gdth_oem_str_ioctl *)ha->pscratch; in gdth_search_drives()
1441 oemstr->params.ctl_version = 0x01; in gdth_search_drives()
1442 oemstr->params.buffer_size = sizeof(oemstr->text); in gdth_search_drives()
1447 printk("GDT-HA %d: Vendor: %s Name: %s\n", in gdth_search_drives()
1448 ha->hanum, oemstr->text.oem_company_name, ha->binfo.type_string); in gdth_search_drives()
1450 strlcpy(ha->oem_name,oemstr->text.scsi_host_drive_inquiry_vendor_id, in gdth_search_drives()
1451 sizeof(ha->oem_name)); in gdth_search_drives()
1455 printk("GDT-HA %d: Name: %s\n", in gdth_search_drives()
1456 ha->hanum, ha->binfo.type_string); in gdth_search_drives()
1457 if (ha->oem_id == OEM_ID_INTEL) in gdth_search_drives()
1458 strlcpy(ha->oem_name,"Intel ", sizeof(ha->oem_name)); in gdth_search_drives()
1460 strlcpy(ha->oem_name,"ICP ", sizeof(ha->oem_name)); in gdth_search_drives()
1476 TRACE(("gdth_analyse_hdrive() hanum %d drive %d\n", ha->hanum, hdrive)); in gdth_analyse_hdrive()
1482 ha->hdr[hdrive].present = TRUE; in gdth_analyse_hdrive()
1483 ha->hdr[hdrive].size = ha->info; in gdth_analyse_hdrive()
1486 ha->hdr[hdrive].size &= ~SECS32; in gdth_analyse_hdrive()
1487 if (ha->info2 == 0) { in gdth_analyse_hdrive()
1488 gdth_eval_mapping(ha->hdr[hdrive].size,&drv_cyls,&drv_hds,&drv_secs); in gdth_analyse_hdrive()
1490 drv_hds = ha->info2 & 0xff; in gdth_analyse_hdrive()
1491 drv_secs = (ha->info2 >> 8) & 0xff; in gdth_analyse_hdrive()
1492 drv_cyls = (u32)ha->hdr[hdrive].size / drv_hds / drv_secs; in gdth_analyse_hdrive()
1494 ha->hdr[hdrive].heads = (u8)drv_hds; in gdth_analyse_hdrive()
1495 ha->hdr[hdrive].secs = (u8)drv_secs; in gdth_analyse_hdrive()
1497 ha->hdr[hdrive].size = drv_cyls * drv_hds * drv_secs; in gdth_analyse_hdrive()
1499 if (ha->cache_feat & GDT_64BIT) { in gdth_analyse_hdrive()
1501 && ha->info2 != 0) { in gdth_analyse_hdrive()
1502 ha->hdr[hdrive].size = ((u64)ha->info2 << 32) | ha->info; in gdth_analyse_hdrive()
1506 hdrive,ha->hdr[hdrive].size,drv_hds,drv_secs)); in gdth_analyse_hdrive()
1511 hdrive,ha->info)); in gdth_analyse_hdrive()
1512 ha->hdr[hdrive].devtype = (u16)ha->info; in gdth_analyse_hdrive()
1518 hdrive,ha->info)); in gdth_analyse_hdrive()
1520 ha->hdr[hdrive].cluster_type = (u8)ha->info; in gdth_analyse_hdrive()
1526 hdrive,ha->info)); in gdth_analyse_hdrive()
1527 ha->hdr[hdrive].rw_attribs = (u8)ha->info; in gdth_analyse_hdrive()
1544 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_putq()
1546 if (!cmndinfo->internal_command) in gdth_putq()
1547 cmndinfo->priority = priority; in gdth_putq()
1549 if (ha->req_first==NULL) { in gdth_putq()
1550 ha->req_first = scp; /* queue was empty */ in gdth_putq()
1551 scp->SCp.ptr = NULL; in gdth_putq()
1553 pscp = ha->req_first; in gdth_putq()
1554 nscp = (struct scsi_cmnd *)pscp->SCp.ptr; in gdth_putq()
1555 /* priority: 0-highest,..,0xff-lowest */ in gdth_putq()
1556 while (nscp && gdth_cmnd_priv(nscp)->priority <= priority) { in gdth_putq()
1558 nscp = (struct scsi_cmnd *)pscp->SCp.ptr; in gdth_putq()
1560 pscp->SCp.ptr = (char *)scp; in gdth_putq()
1561 scp->SCp.ptr = (char *)nscp; in gdth_putq()
1563 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_putq()
1567 for (nscp=ha->req_first; nscp; nscp=(struct scsi_cmnd*)nscp->SCp.ptr) in gdth_putq()
1585 TRACE(("gdth_next() hanum %d\n", ha->hanum)); in gdth_next()
1587 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_next()
1589 ha->cmd_cnt = ha->cmd_offs_dpmem = 0; in gdth_next()
1594 for (nscp = pscp = ha->req_first; nscp; nscp = (struct scsi_cmnd *)nscp->SCp.ptr) { in gdth_next()
1596 if (nscp != pscp && nscp != (struct scsi_cmnd *)pscp->SCp.ptr) in gdth_next()
1597 pscp = (struct scsi_cmnd *)pscp->SCp.ptr; in gdth_next()
1598 if (!nscp_cmndinfo->internal_command) { in gdth_next()
1599 b = nscp->device->channel; in gdth_next()
1600 t = nscp->device->id; in gdth_next()
1601 l = nscp->device->lun; in gdth_next()
1602 if (nscp_cmndinfo->priority >= DEFAULT_PRI) { in gdth_next()
1603 if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || in gdth_next()
1604 (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) in gdth_next()
1612 TRACE(("gdth_next() controller %d busy !\n", ha->hanum)); in gdth_next()
1614 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_next()
1623 if (!nscp_cmndinfo->internal_command) { in gdth_next()
1624 if (nscp_cmndinfo->phase == -1) { in gdth_next()
1625 nscp_cmndinfo->phase = CACHESERVICE; /* default: cache svc. */ in gdth_next()
1626 if (nscp->cmnd[0] == TEST_UNIT_READY) { in gdth_next()
1629 /* TEST_UNIT_READY -> set scan mode */ in gdth_next()
1630 if ((ha->scan_mode & 0x0f) == 0) { in gdth_next()
1632 ha->scan_mode |= 1; in gdth_next()
1633 TRACE2(("Scan mode: 0x%x\n", ha->scan_mode)); in gdth_next()
1635 } else if ((ha->scan_mode & 0x0f) == 1) { in gdth_next()
1638 nscp_cmndinfo->OpCode = GDT_SCAN_START; in gdth_next()
1639 nscp_cmndinfo->phase = ((ha->scan_mode & 0x10 ? 1:0) << 8) in gdth_next()
1641 ha->scan_mode = 0x12; in gdth_next()
1643 ha->scan_mode)); in gdth_next()
1645 ha->scan_mode &= 0x10; in gdth_next()
1646 TRACE2(("Scan mode: 0x%x\n", ha->scan_mode)); in gdth_next()
1648 } else if (ha->scan_mode == 0x12) { in gdth_next()
1649 if (b == ha->bus_cnt && t == ha->tid_cnt-1) { in gdth_next()
1650 nscp_cmndinfo->phase = SCSIRAWSERVICE; in gdth_next()
1651 nscp_cmndinfo->OpCode = GDT_SCAN_END; in gdth_next()
1652 ha->scan_mode &= 0x10; in gdth_next()
1654 ha->scan_mode)); in gdth_next()
1658 if (b == ha->virt_bus && nscp->cmnd[0] != INQUIRY && in gdth_next()
1659 nscp->cmnd[0] != READ_CAPACITY && nscp->cmnd[0] != MODE_SENSE && in gdth_next()
1660 (ha->hdr[t].cluster_type & CLUSTER_DRIVE)) { in gdth_next()
1662 nscp_cmndinfo->OpCode = GDT_CLUST_INFO; in gdth_next()
1667 if (nscp_cmndinfo->OpCode != -1) { in gdth_next()
1668 if ((nscp_cmndinfo->phase & 0xff) == CACHESERVICE) { in gdth_next()
1672 } else if ((nscp_cmndinfo->phase & 0xff) == SCSIRAWSERVICE) { in gdth_next()
1677 memset((char*)nscp->sense_buffer,0,16); in gdth_next()
1678 nscp->sense_buffer[0] = 0x70; in gdth_next()
1679 nscp->sense_buffer[2] = NOT_READY; in gdth_next()
1680 nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); in gdth_next()
1681 if (!nscp_cmndinfo->wait_for_completion) in gdth_next()
1682 nscp_cmndinfo->wait_for_completion++; in gdth_next()
1686 } else if (gdth_cmnd_priv(nscp)->internal_command) { in gdth_next()
1690 } else if (b != ha->virt_bus) { in gdth_next()
1691 if (ha->raw[BUS_L2P(ha,b)].io_cnt[t] >= GDTH_MAX_RAW || in gdth_next()
1695 ha->raw[BUS_L2P(ha,b)].io_cnt[t]++; in gdth_next()
1696 } else if (t >= MAX_HDRIVES || !ha->hdr[t].present || l != 0) { in gdth_next()
1697 TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n", in gdth_next()
1698 nscp->cmnd[0], b, t, l)); in gdth_next()
1699 nscp->result = DID_BAD_TARGET << 16; in gdth_next()
1700 if (!nscp_cmndinfo->wait_for_completion) in gdth_next()
1701 nscp_cmndinfo->wait_for_completion++; in gdth_next()
1705 switch (nscp->cmnd[0]) { in gdth_next()
1714 TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0], in gdth_next()
1715 nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3], in gdth_next()
1716 nscp->cmnd[4],nscp->cmnd[5])); in gdth_next()
1717 if (ha->hdr[t].media_changed && nscp->cmnd[0] != INQUIRY) { in gdth_next()
1720 nscp->cmnd[0], t)); in gdth_next()
1721 ha->hdr[t].media_changed = FALSE; in gdth_next()
1722 memset((char*)nscp->sense_buffer,0,16); in gdth_next()
1723 nscp->sense_buffer[0] = 0x70; in gdth_next()
1724 nscp->sense_buffer[2] = UNIT_ATTENTION; in gdth_next()
1725 nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); in gdth_next()
1726 if (!nscp_cmndinfo->wait_for_completion) in gdth_next()
1727 nscp_cmndinfo->wait_for_completion++; in gdth_next()
1735 TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0], in gdth_next()
1736 nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3], in gdth_next()
1737 nscp->cmnd[4],nscp->cmnd[5])); in gdth_next()
1738 if ( (nscp->cmnd[4]&1) && !(ha->hdr[t].devtype&1) ) { in gdth_next()
1739 TRACE(("Prevent r. nonremov. drive->do nothing\n")); in gdth_next()
1740 nscp->result = DID_OK << 16; in gdth_next()
1741 nscp->sense_buffer[0] = 0; in gdth_next()
1742 if (!nscp_cmndinfo->wait_for_completion) in gdth_next()
1743 nscp_cmndinfo->wait_for_completion++; in gdth_next()
1747 nscp->cmnd[3] = (ha->hdr[t].devtype&1) ? 1:0; in gdth_next()
1749 nscp->cmnd[4],nscp->cmnd[3])); in gdth_next()
1757 TRACE2(("cache cmd %s\n",nscp->cmnd[0] == RESERVE ? in gdth_next()
1769 if (ha->hdr[t].media_changed) { in gdth_next()
1772 nscp->cmnd[0], t)); in gdth_next()
1773 ha->hdr[t].media_changed = FALSE; in gdth_next()
1774 memset((char*)nscp->sense_buffer,0,16); in gdth_next()
1775 nscp->sense_buffer[0] = 0x70; in gdth_next()
1776 nscp->sense_buffer[2] = UNIT_ATTENTION; in gdth_next()
1777 nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); in gdth_next()
1778 if (!nscp_cmndinfo->wait_for_completion) in gdth_next()
1779 nscp_cmndinfo->wait_for_completion++; in gdth_next()
1787 TRACE2(("cache cmd %x/%x/%x/%x/%x/%x unknown\n",nscp->cmnd[0], in gdth_next()
1788 nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3], in gdth_next()
1789 nscp->cmnd[4],nscp->cmnd[5])); in gdth_next()
1790 printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n", in gdth_next()
1791 ha->hanum, nscp->cmnd[0]); in gdth_next()
1792 nscp->result = DID_ABORT << 16; in gdth_next()
1793 if (!nscp_cmndinfo->wait_for_completion) in gdth_next()
1794 nscp_cmndinfo->wait_for_completion++; in gdth_next()
1803 if (nscp == ha->req_first) in gdth_next()
1804 ha->req_first = pscp = (struct scsi_cmnd *)nscp->SCp.ptr; in gdth_next()
1806 pscp->SCp.ptr = nscp->SCp.ptr; in gdth_next()
1811 if (ha->cmd_cnt > 0) { in gdth_next()
1816 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_next()
1818 if (gdth_polling && ha->cmd_cnt > 0) { in gdth_next()
1820 printk("GDT-HA %d: Command %d timed out !\n", in gdth_next()
1821 ha->hanum, cmd_index); in gdth_next()
1826 * gdth_copy_internal_data() - copy to/from a buffer onto a scsi_cmnd's
1843 cpnow = (u16)sl->length; in gdth_copy_internal_data()
1847 cpnow = cpcount - cpsum; in gdth_copy_internal_data()
1850 printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n", in gdth_copy_internal_data()
1851 ha->hanum); in gdth_copy_internal_data()
1855 address = kmap_atomic(sg_page(sl)) + sl->offset; in gdth_copy_internal_data()
1865 printk("GDT-HA %d: SCSI command with no buffers but data transfer expected!\n", in gdth_copy_internal_data()
1866 ha->hanum); in gdth_copy_internal_data()
1880 t = scp->device->id; in gdth_internal_cache_cmd()
1882 scp->cmnd[0],t)); in gdth_internal_cache_cmd()
1884 scp->result = DID_OK << 16; in gdth_internal_cache_cmd()
1885 scp->sense_buffer[0] = 0; in gdth_internal_cache_cmd()
1887 switch (scp->cmnd[0]) { in gdth_internal_cache_cmd()
1896 t,ha->hdr[t].devtype)); in gdth_internal_cache_cmd()
1897 inq.type_qual = (ha->hdr[t].devtype&4) ? TYPE_ROM:TYPE_DISK; in gdth_internal_cache_cmd()
1901 if ((ha->hdr[t].devtype & 1) || in gdth_internal_cache_cmd()
1902 (ha->hdr[t].cluster_type & CLUSTER_DRIVE)) in gdth_internal_cache_cmd()
1904 inq.version = 2; in gdth_internal_cache_cmd()
1905 inq.resp_aenc = 2; in gdth_internal_cache_cmd()
1907 strcpy(inq.vendor,ha->oem_name); in gdth_internal_cache_cmd()
1927 mpd.hd.dev_par = (ha->hdr[t].devtype&2) ? 0x80:0; in gdth_internal_cache_cmd()
1931 mpd.bd.block_length[2] = (SECTOR_SIZE & 0x000000ff); in gdth_internal_cache_cmd()
1937 if (ha->hdr[t].size > (u64)0xffffffff) in gdth_internal_cache_cmd()
1940 rdc.last_block_no = cpu_to_be32(ha->hdr[t].size-1); in gdth_internal_cache_cmd()
1946 if ((scp->cmnd[1] & 0x1f) == SAI_READ_CAPACITY_16 && in gdth_internal_cache_cmd()
1947 (ha->cache_feat & GDT_64BIT)) { in gdth_internal_cache_cmd()
1951 rdc16.last_block_no = cpu_to_be64(ha->hdr[t].size-1); in gdth_internal_cache_cmd()
1956 scp->result = DID_ABORT << 16; in gdth_internal_cache_cmd()
1961 TRACE2(("Internal cache cmd 0x%x unknown\n",scp->cmnd[0])); in gdth_internal_cache_cmd()
1965 if (!cmndinfo->wait_for_completion) in gdth_internal_cache_cmd()
1966 cmndinfo->wait_for_completion++; in gdth_internal_cache_cmd()
1982 cmdp = ha->pccb; in gdth_fill_cache_cmd()
1984 scp->cmnd[0],scp->cmd_len,hdrive)); in gdth_fill_cache_cmd()
1986 mode64 = (ha->cache_feat & GDT_64BIT) ? TRUE : FALSE; in gdth_fill_cache_cmd()
1987 /* test for READ_16, WRITE_16 if !mode64 ? --- in gdth_fill_cache_cmd()
1991 cmdp->Service = CACHESERVICE; in gdth_fill_cache_cmd()
1992 cmdp->RequestBuffer = scp; in gdth_fill_cache_cmd()
1999 if (ha->cmd_cnt == 0) in gdth_fill_cache_cmd()
2004 if (cmndinfo->OpCode != -1) in gdth_fill_cache_cmd()
2005 cmdp->OpCode = cmndinfo->OpCode; /* special cache cmd. */ in gdth_fill_cache_cmd()
2006 else if (scp->cmnd[0] == RESERVE) in gdth_fill_cache_cmd()
2007 cmdp->OpCode = GDT_RESERVE_DRV; in gdth_fill_cache_cmd()
2008 else if (scp->cmnd[0] == RELEASE) in gdth_fill_cache_cmd()
2009 cmdp->OpCode = GDT_RELEASE_DRV; in gdth_fill_cache_cmd()
2010 else if (scp->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { in gdth_fill_cache_cmd()
2011 if (scp->cmnd[4] & 1) /* prevent ? */ in gdth_fill_cache_cmd()
2012 cmdp->OpCode = GDT_MOUNT; in gdth_fill_cache_cmd()
2013 else if (scp->cmnd[3] & 1) /* removable drive ? */ in gdth_fill_cache_cmd()
2014 cmdp->OpCode = GDT_UNMOUNT; in gdth_fill_cache_cmd()
2016 cmdp->OpCode = GDT_FLUSH; in gdth_fill_cache_cmd()
2017 } else if (scp->cmnd[0] == WRITE_6 || scp->cmnd[0] == WRITE_10 || in gdth_fill_cache_cmd()
2018 scp->cmnd[0] == WRITE_12 || scp->cmnd[0] == WRITE_16 in gdth_fill_cache_cmd()
2021 if (gdth_write_through || ((ha->hdr[hdrive].rw_attribs & 1) && in gdth_fill_cache_cmd()
2022 (ha->cache_feat & GDT_WR_THROUGH))) in gdth_fill_cache_cmd()
2023 cmdp->OpCode = GDT_WRITE_THR; in gdth_fill_cache_cmd()
2025 cmdp->OpCode = GDT_WRITE; in gdth_fill_cache_cmd()
2027 read_write = 2; in gdth_fill_cache_cmd()
2028 cmdp->OpCode = GDT_READ; in gdth_fill_cache_cmd()
2031 cmdp->BoardNode = LOCALBOARD; in gdth_fill_cache_cmd()
2033 cmdp->u.cache64.DeviceNo = hdrive; in gdth_fill_cache_cmd()
2034 cmdp->u.cache64.BlockNo = 1; in gdth_fill_cache_cmd()
2035 cmdp->u.cache64.sg_canz = 0; in gdth_fill_cache_cmd()
2037 cmdp->u.cache.DeviceNo = hdrive; in gdth_fill_cache_cmd()
2038 cmdp->u.cache.BlockNo = 1; in gdth_fill_cache_cmd()
2039 cmdp->u.cache.sg_canz = 0; in gdth_fill_cache_cmd()
2043 if (scp->cmd_len == 16) { in gdth_fill_cache_cmd()
2044 memcpy(&no, &scp->cmnd[2], sizeof(u64)); in gdth_fill_cache_cmd()
2046 memcpy(&cnt, &scp->cmnd[10], sizeof(u32)); in gdth_fill_cache_cmd()
2048 } else if (scp->cmd_len == 10) { in gdth_fill_cache_cmd()
2049 memcpy(&no, &scp->cmnd[2], sizeof(u32)); in gdth_fill_cache_cmd()
2051 memcpy(&cnt, &scp->cmnd[7], sizeof(u16)); in gdth_fill_cache_cmd()
2054 memcpy(&no, &scp->cmnd[0], sizeof(u32)); in gdth_fill_cache_cmd()
2056 blockcnt= scp->cmnd[4]==0 ? 0x100 : scp->cmnd[4]; in gdth_fill_cache_cmd()
2059 cmdp->u.cache64.BlockNo = blockno; in gdth_fill_cache_cmd()
2060 cmdp->u.cache64.BlockCnt = blockcnt; in gdth_fill_cache_cmd()
2062 cmdp->u.cache.BlockNo = (u32)blockno; in gdth_fill_cache_cmd()
2063 cmdp->u.cache.BlockCnt = blockcnt; in gdth_fill_cache_cmd()
2067 cmndinfo->dma_dir = (read_write == 1 ? in gdth_fill_cache_cmd()
2069 sgcnt = dma_map_sg(&ha->pdev->dev, scsi_sglist(scp), in gdth_fill_cache_cmd()
2070 scsi_sg_count(scp), cmndinfo->dma_dir); in gdth_fill_cache_cmd()
2074 cmdp->u.cache64.DestAddr= (u64)-1; in gdth_fill_cache_cmd()
2075 cmdp->u.cache64.sg_canz = sgcnt; in gdth_fill_cache_cmd()
2077 cmdp->u.cache64.sg_lst[i].sg_ptr = sg_dma_address(sl); in gdth_fill_cache_cmd()
2078 cmdp->u.cache64.sg_lst[i].sg_len = sg_dma_len(sl); in gdth_fill_cache_cmd()
2083 cmdp->u.cache.DestAddr= 0xffffffff; in gdth_fill_cache_cmd()
2084 cmdp->u.cache.sg_canz = sgcnt; in gdth_fill_cache_cmd()
2086 cmdp->u.cache.sg_lst[i].sg_ptr = sg_dma_address(sl); in gdth_fill_cache_cmd()
2087 cmdp->u.cache.sg_lst[i].sg_len = sg_dma_len(sl); in gdth_fill_cache_cmd()
2103 cmdp->u.cache64.DestAddr,cmdp->u.cache64.sg_canz, in gdth_fill_cache_cmd()
2104 cmdp->u.cache64.sg_lst[0].sg_ptr, in gdth_fill_cache_cmd()
2105 cmdp->u.cache64.sg_lst[0].sg_len)); in gdth_fill_cache_cmd()
2107 cmdp->OpCode,cmdp->u.cache64.BlockNo,cmdp->u.cache64.BlockCnt)); in gdth_fill_cache_cmd()
2108 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.cache64.sg_lst) + in gdth_fill_cache_cmd()
2109 (u16)cmdp->u.cache64.sg_canz * sizeof(gdth_sg64_str); in gdth_fill_cache_cmd()
2112 cmdp->u.cache.DestAddr,cmdp->u.cache.sg_canz, in gdth_fill_cache_cmd()
2113 cmdp->u.cache.sg_lst[0].sg_ptr, in gdth_fill_cache_cmd()
2114 cmdp->u.cache.sg_lst[0].sg_len)); in gdth_fill_cache_cmd()
2116 cmdp->OpCode,cmdp->u.cache.BlockNo,cmdp->u.cache.BlockCnt)); in gdth_fill_cache_cmd()
2117 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.cache.sg_lst) + in gdth_fill_cache_cmd()
2118 (u16)cmdp->u.cache.sg_canz * sizeof(gdth_sg_str); in gdth_fill_cache_cmd()
2120 if (ha->cmd_len & 3) in gdth_fill_cache_cmd()
2121 ha->cmd_len += (4 - (ha->cmd_len & 3)); in gdth_fill_cache_cmd()
2123 if (ha->cmd_cnt > 0) { in gdth_fill_cache_cmd()
2124 if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) > in gdth_fill_cache_cmd()
2125 ha->ic_all_size) { in gdth_fill_cache_cmd()
2127 ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND; in gdth_fill_cache_cmd()
2146 t = scp->device->id; in gdth_fill_raw_cmd()
2147 l = scp->device->lun; in gdth_fill_raw_cmd()
2148 cmdp = ha->pccb; in gdth_fill_raw_cmd()
2150 scp->cmnd[0],b,t,l)); in gdth_fill_raw_cmd()
2152 mode64 = (ha->raw_feat & GDT_64BIT) ? TRUE : FALSE; in gdth_fill_raw_cmd()
2154 cmdp->Service = SCSIRAWSERVICE; in gdth_fill_raw_cmd()
2155 cmdp->RequestBuffer = scp; in gdth_fill_raw_cmd()
2162 if (ha->cmd_cnt == 0) in gdth_fill_raw_cmd()
2167 if (cmndinfo->OpCode != -1) { in gdth_fill_raw_cmd()
2168 cmdp->OpCode = cmndinfo->OpCode; /* special raw cmd. */ in gdth_fill_raw_cmd()
2169 cmdp->BoardNode = LOCALBOARD; in gdth_fill_raw_cmd()
2171 cmdp->u.raw64.direction = (cmndinfo->phase >> 8); in gdth_fill_raw_cmd()
2173 cmdp->OpCode, cmdp->u.raw64.direction)); in gdth_fill_raw_cmd()
2175 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst); in gdth_fill_raw_cmd()
2177 cmdp->u.raw.direction = (cmndinfo->phase >> 8); in gdth_fill_raw_cmd()
2179 cmdp->OpCode, cmdp->u.raw.direction)); in gdth_fill_raw_cmd()
2181 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst); in gdth_fill_raw_cmd()
2185 sense_paddr = dma_map_single(&ha->pdev->dev, scp->sense_buffer, 16, in gdth_fill_raw_cmd()
2188 cmndinfo->sense_paddr = sense_paddr; in gdth_fill_raw_cmd()
2189 cmdp->OpCode = GDT_WRITE; /* always */ in gdth_fill_raw_cmd()
2190 cmdp->BoardNode = LOCALBOARD; in gdth_fill_raw_cmd()
2192 cmdp->u.raw64.reserved = 0; in gdth_fill_raw_cmd()
2193 cmdp->u.raw64.mdisc_time = 0; in gdth_fill_raw_cmd()
2194 cmdp->u.raw64.mcon_time = 0; in gdth_fill_raw_cmd()
2195 cmdp->u.raw64.clen = scp->cmd_len; in gdth_fill_raw_cmd()
2196 cmdp->u.raw64.target = t; in gdth_fill_raw_cmd()
2197 cmdp->u.raw64.lun = l; in gdth_fill_raw_cmd()
2198 cmdp->u.raw64.bus = b; in gdth_fill_raw_cmd()
2199 cmdp->u.raw64.priority = 0; in gdth_fill_raw_cmd()
2200 cmdp->u.raw64.sdlen = scsi_bufflen(scp); in gdth_fill_raw_cmd()
2201 cmdp->u.raw64.sense_len = 16; in gdth_fill_raw_cmd()
2202 cmdp->u.raw64.sense_data = sense_paddr; in gdth_fill_raw_cmd()
2203 cmdp->u.raw64.direction = in gdth_fill_raw_cmd()
2204 gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN; in gdth_fill_raw_cmd()
2205 memcpy(cmdp->u.raw64.cmd,scp->cmnd,16); in gdth_fill_raw_cmd()
2206 cmdp->u.raw64.sg_ranz = 0; in gdth_fill_raw_cmd()
2208 cmdp->u.raw.reserved = 0; in gdth_fill_raw_cmd()
2209 cmdp->u.raw.mdisc_time = 0; in gdth_fill_raw_cmd()
2210 cmdp->u.raw.mcon_time = 0; in gdth_fill_raw_cmd()
2211 cmdp->u.raw.clen = scp->cmd_len; in gdth_fill_raw_cmd()
2212 cmdp->u.raw.target = t; in gdth_fill_raw_cmd()
2213 cmdp->u.raw.lun = l; in gdth_fill_raw_cmd()
2214 cmdp->u.raw.bus = b; in gdth_fill_raw_cmd()
2215 cmdp->u.raw.priority = 0; in gdth_fill_raw_cmd()
2216 cmdp->u.raw.link_p = 0; in gdth_fill_raw_cmd()
2217 cmdp->u.raw.sdlen = scsi_bufflen(scp); in gdth_fill_raw_cmd()
2218 cmdp->u.raw.sense_len = 16; in gdth_fill_raw_cmd()
2219 cmdp->u.raw.sense_data = sense_paddr; in gdth_fill_raw_cmd()
2220 cmdp->u.raw.direction = in gdth_fill_raw_cmd()
2221 gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN; in gdth_fill_raw_cmd()
2222 memcpy(cmdp->u.raw.cmd,scp->cmnd,12); in gdth_fill_raw_cmd()
2223 cmdp->u.raw.sg_ranz = 0; in gdth_fill_raw_cmd()
2227 cmndinfo->dma_dir = DMA_BIDIRECTIONAL; in gdth_fill_raw_cmd()
2228 sgcnt = dma_map_sg(&ha->pdev->dev, scsi_sglist(scp), in gdth_fill_raw_cmd()
2229 scsi_sg_count(scp), cmndinfo->dma_dir); in gdth_fill_raw_cmd()
2233 cmdp->u.raw64.sdata = (u64)-1; in gdth_fill_raw_cmd()
2234 cmdp->u.raw64.sg_ranz = sgcnt; in gdth_fill_raw_cmd()
2236 cmdp->u.raw64.sg_lst[i].sg_ptr = sg_dma_address(sl); in gdth_fill_raw_cmd()
2237 cmdp->u.raw64.sg_lst[i].sg_len = sg_dma_len(sl); in gdth_fill_raw_cmd()
2242 cmdp->u.raw.sdata = 0xffffffff; in gdth_fill_raw_cmd()
2243 cmdp->u.raw.sg_ranz = sgcnt; in gdth_fill_raw_cmd()
2245 cmdp->u.raw.sg_lst[i].sg_ptr = sg_dma_address(sl); in gdth_fill_raw_cmd()
2246 cmdp->u.raw.sg_lst[i].sg_len = sg_dma_len(sl); in gdth_fill_raw_cmd()
2260 cmdp->u.raw64.sdata,cmdp->u.raw64.sg_ranz, in gdth_fill_raw_cmd()
2261 cmdp->u.raw64.sg_lst[0].sg_ptr, in gdth_fill_raw_cmd()
2262 cmdp->u.raw64.sg_lst[0].sg_len)); in gdth_fill_raw_cmd()
2264 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst) + in gdth_fill_raw_cmd()
2265 (u16)cmdp->u.raw64.sg_ranz * sizeof(gdth_sg64_str); in gdth_fill_raw_cmd()
2268 cmdp->u.raw.sdata,cmdp->u.raw.sg_ranz, in gdth_fill_raw_cmd()
2269 cmdp->u.raw.sg_lst[0].sg_ptr, in gdth_fill_raw_cmd()
2270 cmdp->u.raw.sg_lst[0].sg_len)); in gdth_fill_raw_cmd()
2272 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst) + in gdth_fill_raw_cmd()
2273 (u16)cmdp->u.raw.sg_ranz * sizeof(gdth_sg_str); in gdth_fill_raw_cmd()
2277 if (ha->cmd_len & 3) in gdth_fill_raw_cmd()
2278 ha->cmd_len += (4 - (ha->cmd_len & 3)); in gdth_fill_raw_cmd()
2280 if (ha->cmd_cnt > 0) { in gdth_fill_raw_cmd()
2281 if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) > in gdth_fill_raw_cmd()
2282 ha->ic_all_size) { in gdth_fill_raw_cmd()
2284 ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND; in gdth_fill_raw_cmd()
2300 cmdp= ha->pccb; in gdth_special_cmd()
2303 *cmdp = *cmndinfo->internal_cmd_str; in gdth_special_cmd()
2304 cmdp->RequestBuffer = scp; in gdth_special_cmd()
2313 if (ha->cmd_cnt == 0) in gdth_special_cmd()
2317 if (cmdp->OpCode == GDT_IOCTL) { in gdth_special_cmd()
2319 ha->cmd_len = in gdth_special_cmd()
2321 } else if (cmdp->Service == CACHESERVICE) { in gdth_special_cmd()
2322 TRACE2(("cache command %d\n",cmdp->OpCode)); in gdth_special_cmd()
2323 if (ha->cache_feat & GDT_64BIT) in gdth_special_cmd()
2324 ha->cmd_len = in gdth_special_cmd()
2327 ha->cmd_len = in gdth_special_cmd()
2329 } else if (cmdp->Service == SCSIRAWSERVICE) { in gdth_special_cmd()
2330 TRACE2(("raw command %d\n",cmdp->OpCode)); in gdth_special_cmd()
2331 if (ha->raw_feat & GDT_64BIT) in gdth_special_cmd()
2332 ha->cmd_len = in gdth_special_cmd()
2335 ha->cmd_len = in gdth_special_cmd()
2339 if (ha->cmd_len & 3) in gdth_special_cmd()
2340 ha->cmd_len += (4 - (ha->cmd_len & 3)); in gdth_special_cmd()
2342 if (ha->cmd_cnt > 0) { in gdth_special_cmd()
2343 if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) > in gdth_special_cmd()
2344 ha->ic_all_size) { in gdth_special_cmd()
2346 ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND; in gdth_special_cmd()
2365 if (source == 0) /* no source -> no event */ in gdth_store_event()
2370 ((evt->size != 0 && ebuffer[elastidx].event_data.size != 0 && in gdth_store_event()
2372 (char *)&evt->eu, evt->size)) || in gdth_store_event()
2373 (evt->size == 0 && ebuffer[elastidx].event_data.size == 0 && in gdth_store_event()
2375 (char *)&evt->event_string)))) { in gdth_store_event()
2377 e->last_stamp = (u32)ktime_get_real_seconds(); in gdth_store_event()
2378 ++e->same_count; in gdth_store_event()
2391 e->event_source = source; in gdth_store_event()
2392 e->event_idx = idx; in gdth_store_event()
2393 e->first_stamp = e->last_stamp = (u32)ktime_get_real_seconds(); in gdth_store_event()
2394 e->same_count = 1; in gdth_store_event()
2395 e->event_data = *evt; in gdth_store_event()
2396 e->application = 0; in gdth_store_event()
2408 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_read_event()
2409 if (handle == -1) in gdth_read_event()
2413 estr->event_source = 0; in gdth_read_event()
2416 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_read_event()
2420 if (e->event_source != 0) { in gdth_read_event()
2425 eindex = -1; in gdth_read_event()
2429 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_read_event()
2442 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_readapp_event()
2446 if (e->event_source == 0) in gdth_readapp_event()
2448 if ((e->application & application) == 0) { in gdth_readapp_event()
2449 e->application |= application; in gdth_readapp_event()
2461 estr->event_source = 0; in gdth_readapp_event()
2462 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_readapp_event()
2487 TRACE(("gdth_interrupt() IRQ %d\n", ha->irq)); in __gdth_interrupt()
2489 /* if polling and not from gdth_wait() -> return */ in __gdth_interrupt()
2497 spin_lock_irqsave(&ha->smp_lock, flags); in __gdth_interrupt()
2504 spin_unlock_irqrestore(&ha->smp_lock, flags); in __gdth_interrupt()
2512 if (ha->type == GDT_PCI) { in __gdth_interrupt()
2513 dp6_ptr = ha->brd; in __gdth_interrupt()
2516 ha->status = readw(&dp6_ptr->u.ic.Status); in __gdth_interrupt()
2517 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status)); in __gdth_interrupt()
2519 ha->status = S_OK; in __gdth_interrupt()
2520 ha->info = readl(&dp6_ptr->u.ic.Info[0]); in __gdth_interrupt()
2521 ha->service = readw(&dp6_ptr->u.ic.Service); in __gdth_interrupt()
2522 ha->info2 = readl(&dp6_ptr->u.ic.Info[1]); in __gdth_interrupt()
2524 writeb(0xff, &dp6_ptr->io.irqdel); /* acknowledge interrupt */ in __gdth_interrupt()
2525 writeb(0, &dp6_ptr->u.ic.Cmd_Index);/* reset command index */ in __gdth_interrupt()
2526 writeb(0, &dp6_ptr->io.Sema1); /* reset status semaphore */ in __gdth_interrupt()
2527 } else if (ha->type == GDT_PCINEW) { in __gdth_interrupt()
2530 ha->status = inw(PTR2USHORT(&ha->plx->status)); in __gdth_interrupt()
2531 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status)); in __gdth_interrupt()
2533 ha->status = S_OK; in __gdth_interrupt()
2534 ha->info = inl(PTR2USHORT(&ha->plx->info[0])); in __gdth_interrupt()
2535 ha->service = inw(PTR2USHORT(&ha->plx->service)); in __gdth_interrupt()
2536 ha->info2 = inl(PTR2USHORT(&ha->plx->info[1])); in __gdth_interrupt()
2538 outb(0xff, PTR2USHORT(&ha->plx->edoor_reg)); in __gdth_interrupt()
2539 outb(0x00, PTR2USHORT(&ha->plx->sema1_reg)); in __gdth_interrupt()
2540 } else if (ha->type == GDT_PCIMPR) { in __gdth_interrupt()
2541 dp6m_ptr = ha->brd; in __gdth_interrupt()
2544 ha->status = readw(&dp6m_ptr->i960r.status); in __gdth_interrupt()
2545 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status)); in __gdth_interrupt()
2547 ha->status = S_OK; in __gdth_interrupt()
2549 ha->info = readl(&dp6m_ptr->i960r.info[0]); in __gdth_interrupt()
2550 ha->service = readw(&dp6m_ptr->i960r.service); in __gdth_interrupt()
2551 ha->info2 = readl(&dp6m_ptr->i960r.info[1]); in __gdth_interrupt()
2555 if (ha->service != SCREENSERVICE && in __gdth_interrupt()
2556 (ha->fw_vers & 0xff) >= 0x1a) { in __gdth_interrupt()
2557 ha->dvr.severity = readb in __gdth_interrupt()
2558 (&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.severity); in __gdth_interrupt()
2560 ha->dvr.event_string[i] = readb in __gdth_interrupt()
2561 (&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.evt_str[i]); in __gdth_interrupt()
2562 if (ha->dvr.event_string[i] == 0) in __gdth_interrupt()
2567 writeb(0xff, &dp6m_ptr->i960r.edoor_reg); in __gdth_interrupt()
2568 writeb(0, &dp6m_ptr->i960r.sema1_reg); in __gdth_interrupt()
2572 spin_unlock_irqrestore(&ha->smp_lock, flags); in __gdth_interrupt()
2577 IStatus,ha->status,ha->info)); in __gdth_interrupt()
2587 spin_unlock_irqrestore(&ha->smp_lock, flags); in __gdth_interrupt()
2594 ha->dvr.size = sizeof(ha->dvr.eu.driver); in __gdth_interrupt()
2595 ha->dvr.eu.driver.ionode = ha->hanum; in __gdth_interrupt()
2596 gdth_store_event(ha, ES_DRIVER, 4, &ha->dvr); in __gdth_interrupt()
2598 spin_unlock_irqrestore(&ha->smp_lock, flags); in __gdth_interrupt()
2601 scp = ha->cmd_tab[IStatus-2].cmnd; in __gdth_interrupt()
2602 Service = ha->cmd_tab[IStatus-2].service; in __gdth_interrupt()
2603 ha->cmd_tab[IStatus-2].cmnd = UNUSED_CMND; in __gdth_interrupt()
2606 ha->dvr.size = sizeof(ha->dvr.eu.driver); in __gdth_interrupt()
2607 ha->dvr.eu.driver.ionode = ha->hanum; in __gdth_interrupt()
2608 ha->dvr.eu.driver.index = IStatus; in __gdth_interrupt()
2609 gdth_store_event(ha, ES_DRIVER, 1, &ha->dvr); in __gdth_interrupt()
2611 spin_unlock_irqrestore(&ha->smp_lock, flags); in __gdth_interrupt()
2617 spin_unlock_irqrestore(&ha->smp_lock, flags); in __gdth_interrupt()
2624 spin_unlock_irqrestore(&ha->smp_lock, flags); in __gdth_interrupt()
2625 if (rval == 2) { in __gdth_interrupt()
2626 gdth_putq(ha, scp, gdth_cmnd_priv(scp)->priority); in __gdth_interrupt()
2650 cmdp = ha->pccb; in gdth_sync_event()
2652 service,ha->status)); in gdth_sync_event()
2655 msg = ha->pmsg; in gdth_sync_event()
2657 msg->msg_len,msg->msg_answer,msg->msg_ext,msg->msg_alen)); in gdth_sync_event()
2658 if (msg->msg_len > MSGLEN+1) in gdth_sync_event()
2659 msg->msg_len = MSGLEN+1; in gdth_sync_event()
2660 if (msg->msg_len) in gdth_sync_event()
2661 if (!(msg->msg_answer && msg->msg_ext)) { in gdth_sync_event()
2662 msg->msg_text[msg->msg_len] = '\0'; in gdth_sync_event()
2663 printk("%s",msg->msg_text); in gdth_sync_event()
2666 if (msg->msg_ext && !msg->msg_answer) { in gdth_sync_event()
2669 cmdp->Service = SCREENSERVICE; in gdth_sync_event()
2670 cmdp->RequestBuffer = SCREEN_CMND; in gdth_sync_event()
2673 cmdp->OpCode = GDT_READ; in gdth_sync_event()
2674 cmdp->BoardNode = LOCALBOARD; in gdth_sync_event()
2675 cmdp->u.screen.reserved = 0; in gdth_sync_event()
2676 cmdp->u.screen.su.msg.msg_handle= msg->msg_handle; in gdth_sync_event()
2677 cmdp->u.screen.su.msg.msg_addr = ha->msg_phys; in gdth_sync_event()
2678 ha->cmd_offs_dpmem = 0; in gdth_sync_event()
2679 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) in gdth_sync_event()
2681 ha->cmd_cnt = 0; in gdth_sync_event()
2687 if (msg->msg_answer && msg->msg_alen) { in gdth_sync_event()
2689 if (msg->msg_alen == 1) { in gdth_sync_event()
2690 msg->msg_alen = 0; in gdth_sync_event()
2691 msg->msg_len = 1; in gdth_sync_event()
2692 msg->msg_text[0] = 0; in gdth_sync_event()
2694 msg->msg_alen -= 2; in gdth_sync_event()
2695 msg->msg_len = 2; in gdth_sync_event()
2696 msg->msg_text[0] = 1; in gdth_sync_event()
2697 msg->msg_text[1] = 0; in gdth_sync_event()
2699 msg->msg_ext = 0; in gdth_sync_event()
2700 msg->msg_answer = 0; in gdth_sync_event()
2703 cmdp->Service = SCREENSERVICE; in gdth_sync_event()
2704 cmdp->RequestBuffer = SCREEN_CMND; in gdth_sync_event()
2707 cmdp->OpCode = GDT_WRITE; in gdth_sync_event()
2708 cmdp->BoardNode = LOCALBOARD; in gdth_sync_event()
2709 cmdp->u.screen.reserved = 0; in gdth_sync_event()
2710 cmdp->u.screen.su.msg.msg_handle= msg->msg_handle; in gdth_sync_event()
2711 cmdp->u.screen.su.msg.msg_addr = ha->msg_phys; in gdth_sync_event()
2712 ha->cmd_offs_dpmem = 0; in gdth_sync_event()
2713 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) in gdth_sync_event()
2715 ha->cmd_cnt = 0; in gdth_sync_event()
2723 b = scp->device->channel; in gdth_sync_event()
2724 t = scp->device->id; in gdth_sync_event()
2725 if (cmndinfo->OpCode == -1 && b != ha->virt_bus) { in gdth_sync_event()
2726 ha->raw[BUS_L2P(ha,b)].io_cnt[t]--; in gdth_sync_event()
2729 if (ha->status == S_BSY) { in gdth_sync_event()
2730 TRACE2(("Controller busy -> retry !\n")); in gdth_sync_event()
2731 if (cmndinfo->OpCode == GDT_MOUNT) in gdth_sync_event()
2732 cmndinfo->OpCode = GDT_CLUST_INFO; in gdth_sync_event()
2734 return 2; in gdth_sync_event()
2737 dma_unmap_sg(&ha->pdev->dev, scsi_sglist(scp), scsi_sg_count(scp), in gdth_sync_event()
2738 cmndinfo->dma_dir); in gdth_sync_event()
2740 if (cmndinfo->sense_paddr) in gdth_sync_event()
2741 dma_unmap_page(&ha->pdev->dev, cmndinfo->sense_paddr, 16, in gdth_sync_event()
2744 if (ha->status == S_OK) { in gdth_sync_event()
2745 cmndinfo->status = S_OK; in gdth_sync_event()
2746 cmndinfo->info = ha->info; in gdth_sync_event()
2747 if (cmndinfo->OpCode != -1) { in gdth_sync_event()
2749 cmndinfo->OpCode)); in gdth_sync_event()
2751 if (cmndinfo->OpCode == GDT_CLUST_INFO) { in gdth_sync_event()
2752 ha->hdr[t].cluster_type = (u8)ha->info; in gdth_sync_event()
2753 if (!(ha->hdr[t].cluster_type & in gdth_sync_event()
2755 /* NOT MOUNTED -> MOUNT */ in gdth_sync_event()
2756 cmndinfo->OpCode = GDT_MOUNT; in gdth_sync_event()
2757 if (ha->hdr[t].cluster_type & in gdth_sync_event()
2760 cmndinfo->phase = -2; /* reservation conflict */ in gdth_sync_event()
2763 cmndinfo->OpCode = -1; in gdth_sync_event()
2766 if (cmndinfo->OpCode == GDT_MOUNT) { in gdth_sync_event()
2767 ha->hdr[t].cluster_type |= CLUSTER_MOUNTED; in gdth_sync_event()
2768 ha->hdr[t].media_changed = TRUE; in gdth_sync_event()
2769 } else if (cmndinfo->OpCode == GDT_UNMOUNT) { in gdth_sync_event()
2770 ha->hdr[t].cluster_type &= ~CLUSTER_MOUNTED; in gdth_sync_event()
2771 ha->hdr[t].media_changed = TRUE; in gdth_sync_event()
2773 cmndinfo->OpCode = -1; in gdth_sync_event()
2776 cmndinfo->priority = HIGH_PRI; in gdth_sync_event()
2777 return 2; in gdth_sync_event()
2780 if (scp->cmnd[0] == RESERVE) { in gdth_sync_event()
2781 ha->hdr[t].cluster_type |= CLUSTER_RESERVED; in gdth_sync_event()
2782 } else if (scp->cmnd[0] == RELEASE) { in gdth_sync_event()
2783 ha->hdr[t].cluster_type &= ~CLUSTER_RESERVED; in gdth_sync_event()
2785 scp->result = DID_OK << 16; in gdth_sync_event()
2786 scp->sense_buffer[0] = 0; in gdth_sync_event()
2789 cmndinfo->status = ha->status; in gdth_sync_event()
2790 cmndinfo->info = ha->info; in gdth_sync_event()
2792 if (cmndinfo->OpCode != -1) { in gdth_sync_event()
2794 cmndinfo->OpCode, ha->status)); in gdth_sync_event()
2795 if (cmndinfo->OpCode == GDT_SCAN_START || in gdth_sync_event()
2796 cmndinfo->OpCode == GDT_SCAN_END) { in gdth_sync_event()
2797 cmndinfo->OpCode = -1; in gdth_sync_event()
2799 cmndinfo->priority = HIGH_PRI; in gdth_sync_event()
2800 return 2; in gdth_sync_event()
2802 memset((char*)scp->sense_buffer,0,16); in gdth_sync_event()
2803 scp->sense_buffer[0] = 0x70; in gdth_sync_event()
2804 scp->sense_buffer[2] = NOT_READY; in gdth_sync_event()
2805 scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); in gdth_sync_event()
2807 if (ha->status == S_CACHE_UNKNOWN && in gdth_sync_event()
2808 (ha->hdr[t].cluster_type & in gdth_sync_event()
2810 /* bus reset -> force GDT_CLUST_INFO */ in gdth_sync_event()
2811 ha->hdr[t].cluster_type &= ~CLUSTER_RESERVED; in gdth_sync_event()
2813 memset((char*)scp->sense_buffer,0,16); in gdth_sync_event()
2814 if (ha->status == (u16)S_CACHE_RESERV) { in gdth_sync_event()
2815 scp->result = (DID_OK << 16) | (RESERVATION_CONFLICT << 1); in gdth_sync_event()
2817 scp->sense_buffer[0] = 0x70; in gdth_sync_event()
2818 scp->sense_buffer[2] = NOT_READY; in gdth_sync_event()
2819 scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); in gdth_sync_event()
2821 if (!cmndinfo->internal_command) { in gdth_sync_event()
2822 ha->dvr.size = sizeof(ha->dvr.eu.sync); in gdth_sync_event()
2823 ha->dvr.eu.sync.ionode = ha->hanum; in gdth_sync_event()
2824 ha->dvr.eu.sync.service = service; in gdth_sync_event()
2825 ha->dvr.eu.sync.status = ha->status; in gdth_sync_event()
2826 ha->dvr.eu.sync.info = ha->info; in gdth_sync_event()
2827 ha->dvr.eu.sync.hostdrive = t; in gdth_sync_event()
2828 if (ha->status >= 0x8000) in gdth_sync_event()
2829 gdth_store_event(ha, ES_SYNC, 0, &ha->dvr); in gdth_sync_event()
2831 gdth_store_event(ha, ES_SYNC, service, &ha->dvr); in gdth_sync_event()
2835 if (ha->status != S_RAW_SCSI || ha->info >= 0x100) { in gdth_sync_event()
2836 scp->result = DID_BAD_TARGET << 16; in gdth_sync_event()
2838 scp->result = (DID_OK << 16) | ha->info; in gdth_sync_event()
2842 if (!cmndinfo->wait_for_completion) in gdth_sync_event()
2843 cmndinfo->wait_for_completion++; in gdth_sync_event()
2856 /* 2*/ "\005\000\002\006\004"
3011 cmdp= ha->pccb; in gdth_async_event()
3013 ha->hanum, ha->service)); in gdth_async_event()
3015 if (ha->service == SCREENSERVICE) { in gdth_async_event()
3016 if (ha->status == MSG_REQUEST) { in gdth_async_event()
3019 cmdp->Service = SCREENSERVICE; in gdth_async_event()
3020 cmdp->RequestBuffer = SCREEN_CMND; in gdth_async_event()
3022 cmdp->OpCode = GDT_READ; in gdth_async_event()
3023 cmdp->BoardNode = LOCALBOARD; in gdth_async_event()
3024 cmdp->u.screen.reserved = 0; in gdth_async_event()
3025 cmdp->u.screen.su.msg.msg_handle= MSG_INV_HANDLE; in gdth_async_event()
3026 cmdp->u.screen.su.msg.msg_addr = ha->msg_phys; in gdth_async_event()
3027 ha->cmd_offs_dpmem = 0; in gdth_async_event()
3028 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) in gdth_async_event()
3030 ha->cmd_cnt = 0; in gdth_async_event()
3032 printk("[PCI %d/%d] ",(u16)(ha->brd_phys>>8), in gdth_async_event()
3033 (u16)((ha->brd_phys>>3)&0x1f)); in gdth_async_event()
3038 if (ha->type == GDT_PCIMPR && in gdth_async_event()
3039 (ha->fw_vers & 0xff) >= 0x1a) { in gdth_async_event()
3040 ha->dvr.size = 0; in gdth_async_event()
3041 ha->dvr.eu.async.ionode = ha->hanum; in gdth_async_event()
3042 ha->dvr.eu.async.status = ha->status; in gdth_async_event()
3045 ha->dvr.size = sizeof(ha->dvr.eu.async); in gdth_async_event()
3046 ha->dvr.eu.async.ionode = ha->hanum; in gdth_async_event()
3047 ha->dvr.eu.async.service = ha->service; in gdth_async_event()
3048 ha->dvr.eu.async.status = ha->status; in gdth_async_event()
3049 ha->dvr.eu.async.info = ha->info; in gdth_async_event()
3050 *(u32 *)ha->dvr.eu.async.scsi_coord = ha->info2; in gdth_async_event()
3052 gdth_store_event( ha, ES_ASYNC, ha->service, &ha->dvr ); in gdth_async_event()
3053 gdth_log_event( &ha->dvr, NULL ); in gdth_async_event()
3056 if (ha->service == CACHESERVICE && ha->status == 56) { in gdth_async_event()
3058 (u16)ha->info)); in gdth_async_event()
3059 /* gdth_analyse_hdrive(hanum, (u16)ha->info); */ in gdth_async_event()
3072 if (dvr->size == 0) { in gdth_log_event()
3074 printk("Adapter %d: %s\n",dvr->eu.async.ionode,dvr->event_string); in gdth_log_event()
3077 dvr->eu.async.ionode,dvr->event_string); in gdth_log_event()
3079 } else if (dvr->eu.async.service == CACHESERVICE && in gdth_log_event()
3080 INDEX_OK(dvr->eu.async.status, async_cache_tab)) { in gdth_log_event()
3082 dvr->eu.async.status)); in gdth_log_event()
3084 f = async_cache_tab[dvr->eu.async.status]; in gdth_log_event()
3087 for (j=0,i=1; i < f[0]; i+=2) { in gdth_log_event()
3090 stack.b[j++] = *(u32*)&dvr->eu.stream[(int)f[i]]; in gdth_log_event()
3092 case 2: in gdth_log_event()
3093 stack.b[j++] = *(u16*)&dvr->eu.stream[(int)f[i]]; in gdth_log_event()
3096 stack.b[j++] = *(u8*)&dvr->eu.stream[(int)f[i]]; in gdth_log_event()
3113 dvr->eu.async.ionode,dvr->eu.async.service,dvr->eu.async.status); in gdth_log_event()
3116 dvr->eu.async.ionode,dvr->eu.async.service,dvr->eu.async.status); in gdth_log_event()
3137 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_timeout()
3140 if (ha->cmd_tab[i].cmnd != UNUSED_CMND) in gdth_timeout()
3144 nscp=ha->req_first; nscp; nscp=(struct scsi_cmnd*)nscp->SCp.ptr) in gdth_timeout()
3153 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_timeout()
3176 if (ha->type == GDT_PCI) { in gdth_ctr_name()
3177 switch (ha->pdev->device) { in gdth_ctr_name()
3194 return ((const char *)ha->binfo.type_string); in gdth_info()
3199 gdth_ha_str *ha = shost_priv(scp->device->host); in gdth_timed_out()
3205 TRACE(("%s() cmd 0x%x\n", scp->cmnd[0], __func__)); in gdth_timed_out()
3206 b = scp->device->channel; in gdth_timed_out()
3207 t = scp->device->id; in gdth_timed_out()
3214 if (++cmndinfo->timeout_count < 6) in gdth_timed_out()
3218 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_timed_out()
3219 if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha, b)].lock) || in gdth_timed_out()
3220 (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) { in gdth_timed_out()
3224 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_timed_out()
3232 gdth_ha_str *ha = shost_priv(scp->device->host); in gdth_eh_bus_reset()
3240 b = scp->device->channel; in gdth_eh_bus_reset()
3243 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_eh_bus_reset()
3245 cmnd = ha->cmd_tab[i].cmnd; in gdth_eh_bus_reset()
3246 if (!SPECIAL_SCP(cmnd) && cmnd->device->channel == b) in gdth_eh_bus_reset()
3247 ha->cmd_tab[i].cmnd = UNUSED_CMND; in gdth_eh_bus_reset()
3249 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_eh_bus_reset()
3251 if (b == ha->virt_bus) { in gdth_eh_bus_reset()
3254 if (ha->hdr[i].present) { in gdth_eh_bus_reset()
3255 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_eh_bus_reset()
3261 ha->hdr[i].cluster_type &= ~CLUSTER_RESERVED; in gdth_eh_bus_reset()
3263 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_eh_bus_reset()
3268 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_eh_bus_reset()
3270 ha->raw[BUS_L2P(ha,b)].io_cnt[i] = 0; in gdth_eh_bus_reset()
3277 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_eh_bus_reset()
3285 gdth_ha_str *ha = shost_priv(sdev->host); in gdth_bios_param()
3291 b = sd->channel; in gdth_bios_param()
3292 t = sd->id; in gdth_bios_param()
3293 TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", ha->hanum, b, t)); in gdth_bios_param()
3295 if (b != ha->virt_bus || ha->hdr[t].heads == 0) { in gdth_bios_param()
3298 gdth_eval_mapping(capacity,&ip[2],&ip[0],&ip[1]); in gdth_bios_param()
3300 ip[0] = ha->hdr[t].heads; in gdth_bios_param()
3301 ip[1] = ha->hdr[t].secs; in gdth_bios_param()
3302 ip[2] = capacity / ip[0] / ip[1]; in gdth_bios_param()
3306 ip[0],ip[1],ip[2])); in gdth_bios_param()
3314 gdth_ha_str *ha = shost_priv(scp->device->host); in gdth_queuecommand_lck()
3317 TRACE(("gdth_queuecommand() cmd 0x%x\n", scp->cmnd[0])); in gdth_queuecommand_lck()
3322 scp->scsi_done = done; in gdth_queuecommand_lck()
3323 cmndinfo->timeout_count = 0; in gdth_queuecommand_lck()
3324 cmndinfo->priority = DEFAULT_PRI; in gdth_queuecommand_lck()
3334 scp->host_scribble = (unsigned char *)cmndinfo; in DEF_SCSI_QCMD()
3335 cmndinfo->wait_for_completion = 1; in DEF_SCSI_QCMD()
3336 cmndinfo->phase = -1; in DEF_SCSI_QCMD()
3337 cmndinfo->OpCode = -1; in DEF_SCSI_QCMD()
3343 gdth_putq(ha, scp, cmndinfo->priority); in DEF_SCSI_QCMD()
3355 if (!ha->sdev) in gdth_open()
3356 ha->sdev = scsi_get_host_dev(ha->shost); in gdth_open()
3377 return -EFAULT; in ioc_event()
3380 return -EFAULT; in ioc_event()
3391 spin_lock_irqsave(&ha->smp_lock, flags); in ioc_event()
3394 spin_unlock_irqrestore(&ha->smp_lock, flags); in ioc_event()
3403 return -EFAULT; in ioc_event()
3415 return -EFAULT; in ioc_lockdrv()
3418 return -EFAULT; in ioc_lockdrv()
3422 if (j >= MAX_HDRIVES || !ha->hdr[j].present) in ioc_lockdrv()
3425 spin_lock_irqsave(&ha->smp_lock, flags); in ioc_lockdrv()
3426 ha->hdr[j].lock = 1; in ioc_lockdrv()
3427 spin_unlock_irqrestore(&ha->smp_lock, flags); in ioc_lockdrv()
3428 gdth_wait_completion(ha, ha->bus_cnt, j); in ioc_lockdrv()
3430 spin_lock_irqsave(&ha->smp_lock, flags); in ioc_lockdrv()
3431 ha->hdr[j].lock = 0; in ioc_lockdrv()
3432 spin_unlock_irqrestore(&ha->smp_lock, flags); in ioc_lockdrv()
3448 return -EFAULT; in ioc_resetdrv()
3451 return -EFAULT; in ioc_resetdrv()
3453 if (!ha->hdr[res.number].present) in ioc_resetdrv()
3458 if (ha->cache_feat & GDT_64BIT) in ioc_resetdrv()
3463 rval = __gdth_execute(ha->sdev, &cmd, cmnd, 30, NULL); in ioc_resetdrv()
3469 return -EFAULT; in ioc_resetdrv()
3473 static void gdth_ioc_cacheservice(gdth_ha_str *ha, gdth_ioctl_general *gen, in gdth_ioc_cacheservice() argument
3476 if (ha->cache_feat & GDT_64BIT) { in gdth_ioc_cacheservice()
3477 /* copy elements from 32-bit IOCTL structure */ in gdth_ioc_cacheservice()
3478 gen->command.u.cache64.BlockCnt = gen->command.u.cache.BlockCnt; in gdth_ioc_cacheservice()
3479 gen->command.u.cache64.BlockNo = gen->command.u.cache.BlockNo; in gdth_ioc_cacheservice()
3480 gen->command.u.cache64.DeviceNo = gen->command.u.cache.DeviceNo; in gdth_ioc_cacheservice()
3482 if (ha->cache_feat & SCATTER_GATHER) { in gdth_ioc_cacheservice()
3483 gen->command.u.cache64.DestAddr = (u64)-1; in gdth_ioc_cacheservice()
3484 gen->command.u.cache64.sg_canz = 1; in gdth_ioc_cacheservice()
3485 gen->command.u.cache64.sg_lst[0].sg_ptr = paddr; in gdth_ioc_cacheservice()
3486 gen->command.u.cache64.sg_lst[0].sg_len = gen->data_len; in gdth_ioc_cacheservice()
3487 gen->command.u.cache64.sg_lst[1].sg_len = 0; in gdth_ioc_cacheservice()
3489 gen->command.u.cache64.DestAddr = paddr; in gdth_ioc_cacheservice()
3490 gen->command.u.cache64.sg_canz = 0; in gdth_ioc_cacheservice()
3493 if (ha->cache_feat & SCATTER_GATHER) { in gdth_ioc_cacheservice()
3494 gen->command.u.cache.DestAddr = 0xffffffff; in gdth_ioc_cacheservice()
3495 gen->command.u.cache.sg_canz = 1; in gdth_ioc_cacheservice()
3496 gen->command.u.cache.sg_lst[0].sg_ptr = (u32)paddr; in gdth_ioc_cacheservice()
3497 gen->command.u.cache.sg_lst[0].sg_len = gen->data_len; in gdth_ioc_cacheservice()
3498 gen->command.u.cache.sg_lst[1].sg_len = 0; in gdth_ioc_cacheservice()
3500 gen->command.u.cache.DestAddr = paddr; in gdth_ioc_cacheservice()
3501 gen->command.u.cache.sg_canz = 0; in gdth_ioc_cacheservice()
3506 static void gdth_ioc_scsiraw(gdth_ha_str *ha, gdth_ioctl_general *gen, in gdth_ioc_scsiraw() argument
3509 if (ha->raw_feat & GDT_64BIT) { in gdth_ioc_scsiraw()
3510 /* copy elements from 32-bit IOCTL structure */ in gdth_ioc_scsiraw()
3513 gen->command.u.raw64.sense_len = gen->command.u.raw.sense_len; in gdth_ioc_scsiraw()
3514 gen->command.u.raw64.bus = gen->command.u.raw.bus; in gdth_ioc_scsiraw()
3515 gen->command.u.raw64.lun = gen->command.u.raw.lun; in gdth_ioc_scsiraw()
3516 gen->command.u.raw64.target = gen->command.u.raw.target; in gdth_ioc_scsiraw()
3517 memcpy(cmd, gen->command.u.raw.cmd, 16); in gdth_ioc_scsiraw()
3518 memcpy(gen->command.u.raw64.cmd, cmd, 16); in gdth_ioc_scsiraw()
3519 gen->command.u.raw64.clen = gen->command.u.raw.clen; in gdth_ioc_scsiraw()
3520 gen->command.u.raw64.sdlen = gen->command.u.raw.sdlen; in gdth_ioc_scsiraw()
3521 gen->command.u.raw64.direction = gen->command.u.raw.direction; in gdth_ioc_scsiraw()
3524 if (ha->raw_feat & SCATTER_GATHER) { in gdth_ioc_scsiraw()
3525 gen->command.u.raw64.sdata = (u64)-1; in gdth_ioc_scsiraw()
3526 gen->command.u.raw64.sg_ranz = 1; in gdth_ioc_scsiraw()
3527 gen->command.u.raw64.sg_lst[0].sg_ptr = paddr; in gdth_ioc_scsiraw()
3528 gen->command.u.raw64.sg_lst[0].sg_len = gen->data_len; in gdth_ioc_scsiraw()
3529 gen->command.u.raw64.sg_lst[1].sg_len = 0; in gdth_ioc_scsiraw()
3531 gen->command.u.raw64.sdata = paddr; in gdth_ioc_scsiraw()
3532 gen->command.u.raw64.sg_ranz = 0; in gdth_ioc_scsiraw()
3535 gen->command.u.raw64.sense_data = paddr + gen->data_len; in gdth_ioc_scsiraw()
3537 if (ha->raw_feat & SCATTER_GATHER) { in gdth_ioc_scsiraw()
3538 gen->command.u.raw.sdata = 0xffffffff; in gdth_ioc_scsiraw()
3539 gen->command.u.raw.sg_ranz = 1; in gdth_ioc_scsiraw()
3540 gen->command.u.raw.sg_lst[0].sg_ptr = (u32)paddr; in gdth_ioc_scsiraw()
3541 gen->command.u.raw.sg_lst[0].sg_len = gen->data_len; in gdth_ioc_scsiraw()
3542 gen->command.u.raw.sg_lst[1].sg_len = 0; in gdth_ioc_scsiraw()
3544 gen->command.u.raw.sdata = paddr; in gdth_ioc_scsiraw()
3545 gen->command.u.raw.sg_ranz = 0; in gdth_ioc_scsiraw()
3548 gen->command.u.raw.sense_data = (u32)paddr + gen->data_len; in gdth_ioc_scsiraw()
3554 gdth_ioctl_general gen; in ioc_general() local
3560 if (copy_from_user(&gen, arg, sizeof(gdth_ioctl_general))) in ioc_general()
3561 return -EFAULT; in ioc_general()
3562 ha = gdth_find_ha(gen.ionode); in ioc_general()
3564 return -EFAULT; in ioc_general()
3566 if (gen.data_len > INT_MAX) in ioc_general()
3567 return -EINVAL; in ioc_general()
3568 if (gen.sense_len > INT_MAX) in ioc_general()
3569 return -EINVAL; in ioc_general()
3570 if (gen.data_len + gen.sense_len > INT_MAX) in ioc_general()
3571 return -EINVAL; in ioc_general()
3573 if (gen.data_len + gen.sense_len > 0) { in ioc_general()
3574 buf = dma_alloc_coherent(&ha->pdev->dev, in ioc_general()
3575 gen.data_len + gen.sense_len, &paddr, in ioc_general()
3578 return -EFAULT; in ioc_general()
3580 rval = -EFAULT; in ioc_general()
3582 gen.data_len + gen.sense_len)) in ioc_general()
3585 if (gen.command.OpCode == GDT_IOCTL) in ioc_general()
3586 gen.command.u.ioctl.p_param = paddr; in ioc_general()
3587 else if (gen.command.Service == CACHESERVICE) in ioc_general()
3588 gdth_ioc_cacheservice(ha, &gen, paddr); in ioc_general()
3589 else if (gen.command.Service == SCSIRAWSERVICE) in ioc_general()
3590 gdth_ioc_scsiraw(ha, &gen, paddr); in ioc_general()
3595 rval = __gdth_execute(ha->sdev, &gen.command, cmnd, gen.timeout, in ioc_general()
3596 &gen.info); in ioc_general()
3599 gen.status = rval; in ioc_general()
3601 rval = -EFAULT; in ioc_general()
3603 gen.data_len + gen.sense_len)) in ioc_general()
3605 if (copy_to_user(arg, &gen, in ioc_general()
3606 sizeof(gdth_ioctl_general) - sizeof(gdth_cmd_str))) in ioc_general()
3612 dma_free_coherent(&ha->pdev->dev, gen.data_len + gen.sense_len, in ioc_general()
3623 int rc = -ENOMEM; in ioc_hdrlist()
3632 (NULL == (ha = gdth_find_ha(rsc->ionode)))) { in ioc_hdrlist()
3633 rc = -EFAULT; in ioc_hdrlist()
3639 if (!ha->hdr[i].present) { in ioc_hdrlist()
3640 rsc->hdr_list[i].bus = 0xff; in ioc_hdrlist()
3643 rsc->hdr_list[i].bus = ha->virt_bus; in ioc_hdrlist()
3644 rsc->hdr_list[i].target = i; in ioc_hdrlist()
3645 rsc->hdr_list[i].lun = 0; in ioc_hdrlist()
3646 rsc->hdr_list[i].cluster_type = ha->hdr[i].cluster_type; in ioc_hdrlist()
3647 if (ha->hdr[i].cluster_type & CLUSTER_DRIVE) { in ioc_hdrlist()
3648 cmd->Service = CACHESERVICE; in ioc_hdrlist()
3649 cmd->OpCode = GDT_CLUST_INFO; in ioc_hdrlist()
3650 if (ha->cache_feat & GDT_64BIT) in ioc_hdrlist()
3651 cmd->u.cache64.DeviceNo = i; in ioc_hdrlist()
3653 cmd->u.cache.DeviceNo = i; in ioc_hdrlist()
3654 if (__gdth_execute(ha->sdev, cmd, cmnd, 30, &cluster_type) == S_OK) in ioc_hdrlist()
3655 rsc->hdr_list[i].cluster_type = cluster_type; in ioc_hdrlist()
3660 rc = -EFAULT; in ioc_hdrlist()
3677 int rc = -ENOMEM; in ioc_rescan()
3687 (NULL == (ha = gdth_find_ha(rsc->ionode)))) { in ioc_rescan()
3688 rc = -EFAULT; in ioc_rescan()
3693 if (rsc->flag == 0) { in ioc_rescan()
3694 /* old method: re-init. cache service */ in ioc_rescan()
3695 cmd->Service = CACHESERVICE; in ioc_rescan()
3696 if (ha->cache_feat & GDT_64BIT) { in ioc_rescan()
3697 cmd->OpCode = GDT_X_INIT_HOST; in ioc_rescan()
3698 cmd->u.cache64.DeviceNo = LINUX_OS; in ioc_rescan()
3700 cmd->OpCode = GDT_INIT; in ioc_rescan()
3701 cmd->u.cache.DeviceNo = LINUX_OS; in ioc_rescan()
3704 status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); in ioc_rescan()
3708 i = rsc->hdr_no; in ioc_rescan()
3713 cmd->Service = CACHESERVICE; in ioc_rescan()
3714 cmd->OpCode = GDT_INFO; in ioc_rescan()
3715 if (ha->cache_feat & GDT_64BIT) in ioc_rescan()
3716 cmd->u.cache64.DeviceNo = i; in ioc_rescan()
3718 cmd->u.cache.DeviceNo = i; in ioc_rescan()
3720 status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); in ioc_rescan()
3722 spin_lock_irqsave(&ha->smp_lock, flags); in ioc_rescan()
3723 rsc->hdr_list[i].bus = ha->virt_bus; in ioc_rescan()
3724 rsc->hdr_list[i].target = i; in ioc_rescan()
3725 rsc->hdr_list[i].lun = 0; in ioc_rescan()
3727 ha->hdr[i].present = FALSE; in ioc_rescan()
3729 ha->hdr[i].present = TRUE; in ioc_rescan()
3730 ha->hdr[i].size = info; in ioc_rescan()
3732 ha->hdr[i].size &= ~SECS32; in ioc_rescan()
3733 gdth_eval_mapping(ha->hdr[i].size,&cyls,&hds,&secs); in ioc_rescan()
3734 ha->hdr[i].heads = hds; in ioc_rescan()
3735 ha->hdr[i].secs = secs; in ioc_rescan()
3737 ha->hdr[i].size = cyls * hds * secs; in ioc_rescan()
3739 spin_unlock_irqrestore(&ha->smp_lock, flags); in ioc_rescan()
3743 /* extended info, if GDT_64BIT, for drives > 2 TB */ in ioc_rescan()
3744 /* but we need ha->info2, not yet stored in scp->SCp */ in ioc_rescan()
3747 cmd->Service = CACHESERVICE; in ioc_rescan()
3748 cmd->OpCode = GDT_DEVTYPE; in ioc_rescan()
3749 if (ha->cache_feat & GDT_64BIT) in ioc_rescan()
3750 cmd->u.cache64.DeviceNo = i; in ioc_rescan()
3752 cmd->u.cache.DeviceNo = i; in ioc_rescan()
3754 status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); in ioc_rescan()
3756 spin_lock_irqsave(&ha->smp_lock, flags); in ioc_rescan()
3757 ha->hdr[i].devtype = (status == S_OK ? (u16)info : 0); in ioc_rescan()
3758 spin_unlock_irqrestore(&ha->smp_lock, flags); in ioc_rescan()
3760 cmd->Service = CACHESERVICE; in ioc_rescan()
3761 cmd->OpCode = GDT_CLUST_INFO; in ioc_rescan()
3762 if (ha->cache_feat & GDT_64BIT) in ioc_rescan()
3763 cmd->u.cache64.DeviceNo = i; in ioc_rescan()
3765 cmd->u.cache.DeviceNo = i; in ioc_rescan()
3767 status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); in ioc_rescan()
3769 spin_lock_irqsave(&ha->smp_lock, flags); in ioc_rescan()
3770 ha->hdr[i].cluster_type = in ioc_rescan()
3772 spin_unlock_irqrestore(&ha->smp_lock, flags); in ioc_rescan()
3773 rsc->hdr_list[i].cluster_type = ha->hdr[i].cluster_type; in ioc_rescan()
3775 cmd->Service = CACHESERVICE; in ioc_rescan()
3776 cmd->OpCode = GDT_RW_ATTRIBS; in ioc_rescan()
3777 if (ha->cache_feat & GDT_64BIT) in ioc_rescan()
3778 cmd->u.cache64.DeviceNo = i; in ioc_rescan()
3780 cmd->u.cache.DeviceNo = i; in ioc_rescan()
3782 status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); in ioc_rescan()
3784 spin_lock_irqsave(&ha->smp_lock, flags); in ioc_rescan()
3785 ha->hdr[i].rw_attribs = (status == S_OK ? (u16)info : 0); in ioc_rescan()
3786 spin_unlock_irqrestore(&ha->smp_lock, flags); in ioc_rescan()
3790 rc = -EFAULT; in ioc_rescan()
3817 return -EFAULT; in gdth_ioctl()
3825 return -EFAULT; in gdth_ioctl()
3837 return -EFAULT; in gdth_ioctl()
3847 return -EFAULT; in gdth_ioctl()
3849 if (ha->type != GDT_PCIMPR) { in gdth_ioctl()
3850 ctrt.type = (u8)((ha->stype<<4) + 6); in gdth_ioctl()
3852 ctrt.type = (ha->oem_id == OEM_ID_INTEL ? 0xfd : 0xfe); in gdth_ioctl()
3853 if (ha->stype >= 0x300) in gdth_ioctl()
3854 ctrt.ext_type = 0x6000 | ha->pdev->subsystem_device; in gdth_ioctl()
3856 ctrt.ext_type = 0x6000 | ha->stype; in gdth_ioctl()
3858 ctrt.device_id = ha->pdev->device; in gdth_ioctl()
3859 ctrt.sub_device_id = ha->pdev->subsystem_device; in gdth_ioctl()
3860 ctrt.info = ha->brd_phys; in gdth_ioctl()
3861 ctrt.oem_id = ha->oem_id; in gdth_ioctl()
3863 return -EFAULT; in gdth_ioctl()
3883 return -EFAULT; in gdth_ioctl()
3886 if (i < ha->bus_cnt) { in gdth_ioctl()
3888 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_ioctl()
3889 ha->raw[i].lock = 1; in gdth_ioctl()
3890 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_ioctl()
3891 for (j = 0; j < ha->tid_cnt; ++j) in gdth_ioctl()
3894 spin_lock_irqsave(&ha->smp_lock, flags); in gdth_ioctl()
3895 ha->raw[i].lock = 0; in gdth_ioctl()
3896 spin_unlock_irqrestore(&ha->smp_lock, flags); in gdth_ioctl()
3897 for (j = 0; j < ha->tid_cnt; ++j) in gdth_ioctl()
3917 return -EFAULT; in gdth_ioctl()
3921 return -ENOMEM; in gdth_ioctl()
3922 scp->device = ha->sdev; in gdth_ioctl()
3923 scp->cmd_len = 12; in gdth_ioctl()
3924 scp->device->channel = res.number; in gdth_ioctl()
3930 return -EFAULT; in gdth_ioctl()
3963 TRACE2(("gdth_flush() hanum %d\n", ha->hanum)); in gdth_flush()
3966 if (ha->hdr[i].present) { in gdth_flush()
3970 if (ha->cache_feat & GDT_64BIT) { in gdth_flush()
3979 TRACE2(("gdth_flush(): flush ha %d drive %d\n", ha->hanum, i)); in gdth_flush()
3981 gdth_execute(ha->shost, &gdtcmd, cmnd, 30, NULL); in gdth_flush()
3989 sdev->skip_ms_page_3f = 1; in gdth_slave_configure()
3990 sdev->skip_ms_page_8 = 1; in gdth_slave_configure()
4006 .this_id = -1,
4019 struct pci_dev *pdev = pcistr->pdev; in gdth_pci_probe_one()
4025 return -ENOMEM; in gdth_pci_probe_one()
4028 error = -ENODEV; in gdth_pci_probe_one()
4033 printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n", in gdth_pci_probe_one()
4034 pdev->bus->number, in gdth_pci_probe_one()
4035 PCI_SLOT(pdev->devfn), in gdth_pci_probe_one()
4036 ha->irq); in gdth_pci_probe_one()
4038 error = request_irq(ha->irq, gdth_interrupt, in gdth_pci_probe_one()
4041 printk("GDT-PCI: Unable to allocate IRQ\n"); in gdth_pci_probe_one()
4045 shp->unchecked_isa_dma = 0; in gdth_pci_probe_one()
4046 shp->irq = ha->irq; in gdth_pci_probe_one()
4047 shp->dma_channel = 0xff; in gdth_pci_probe_one()
4049 ha->hanum = gdth_ctr_count++; in gdth_pci_probe_one()
4050 ha->shost = shp; in gdth_pci_probe_one()
4052 ha->pccb = &ha->cmdext; in gdth_pci_probe_one()
4053 ha->ccb_phys = 0L; in gdth_pci_probe_one()
4055 error = -ENOMEM; in gdth_pci_probe_one()
4057 ha->pscratch = dma_alloc_coherent(&ha->pdev->dev, GDTH_SCRATCH, in gdth_pci_probe_one()
4059 if (!ha->pscratch) in gdth_pci_probe_one()
4061 ha->scratch_phys = scratch_dma_handle; in gdth_pci_probe_one()
4063 ha->pmsg = dma_alloc_coherent(&ha->pdev->dev, sizeof(gdth_msg_str), in gdth_pci_probe_one()
4065 if (!ha->pmsg) in gdth_pci_probe_one()
4067 ha->msg_phys = scratch_dma_handle; in gdth_pci_probe_one()
4069 ha->scratch_busy = FALSE; in gdth_pci_probe_one()
4070 ha->req_first = NULL; in gdth_pci_probe_one()
4071 ha->tid_cnt = pdev->device >= 0x200 ? MAXID : MAX_HDRIVES; in gdth_pci_probe_one()
4072 if (max_ids > 0 && max_ids < ha->tid_cnt) in gdth_pci_probe_one()
4073 ha->tid_cnt = max_ids; in gdth_pci_probe_one()
4075 ha->cmd_tab[i].cmnd = UNUSED_CMND; in gdth_pci_probe_one()
4076 ha->scan_mode = rescan ? 0x10 : 0; in gdth_pci_probe_one()
4078 error = -ENODEV; in gdth_pci_probe_one()
4080 printk("GDT-PCI %d: Error during device scan\n", ha->hanum); in gdth_pci_probe_one()
4084 if (hdr_channel < 0 || hdr_channel > ha->bus_cnt) in gdth_pci_probe_one()
4085 hdr_channel = ha->bus_cnt; in gdth_pci_probe_one()
4086 ha->virt_bus = hdr_channel; in gdth_pci_probe_one()
4088 /* 64-bit DMA only supported from FW >= x.43 */ in gdth_pci_probe_one()
4089 if (!(ha->cache_feat & ha->raw_feat & ha->screen_feat & GDT_64BIT) || in gdth_pci_probe_one()
4090 !ha->dma64_support) { in gdth_pci_probe_one()
4091 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { in gdth_pci_probe_one()
4092 printk(KERN_WARNING "GDT-PCI %d: " in gdth_pci_probe_one()
4093 "Unable to set 32-bit DMA\n", ha->hanum); in gdth_pci_probe_one()
4097 shp->max_cmd_len = 16; in gdth_pci_probe_one()
4098 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { in gdth_pci_probe_one()
4099 printk("GDT-PCI %d: 64-bit DMA enabled\n", ha->hanum); in gdth_pci_probe_one()
4100 } else if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { in gdth_pci_probe_one()
4101 printk(KERN_WARNING "GDT-PCI %d: " in gdth_pci_probe_one()
4102 "Unable to set 64/32-bit DMA\n", ha->hanum); in gdth_pci_probe_one()
4107 shp->max_id = ha->tid_cnt; in gdth_pci_probe_one()
4108 shp->max_lun = MAXLUN; in gdth_pci_probe_one()
4109 shp->max_channel = ha->bus_cnt; in gdth_pci_probe_one()
4111 spin_lock_init(&ha->smp_lock); in gdth_pci_probe_one()
4114 error = scsi_add_host(shp, &pdev->dev); in gdth_pci_probe_one()
4117 list_add_tail(&ha->list, &gdth_instances); in gdth_pci_probe_one()
4119 pci_set_drvdata(ha->pdev, ha); in gdth_pci_probe_one()
4129 dma_free_coherent(&ha->pdev->dev, sizeof(gdth_msg_str), in gdth_pci_probe_one()
4130 ha->pmsg, ha->msg_phys); in gdth_pci_probe_one()
4132 dma_free_coherent(&ha->pdev->dev, GDTH_SCRATCH, in gdth_pci_probe_one()
4133 ha->pscratch, ha->scratch_phys); in gdth_pci_probe_one()
4135 free_irq(ha->irq, ha); in gdth_pci_probe_one()
4136 gdth_ctr_count--; in gdth_pci_probe_one()
4144 struct Scsi_Host *shp = ha->shost; in gdth_remove_one()
4152 if (ha->sdev) { in gdth_remove_one()
4153 scsi_free_host_dev(ha->sdev); in gdth_remove_one()
4154 ha->sdev = NULL; in gdth_remove_one()
4157 if (shp->irq) in gdth_remove_one()
4158 free_irq(shp->irq,ha); in gdth_remove_one()
4160 if (ha->pscratch) in gdth_remove_one()
4161 dma_free_coherent(&ha->pdev->dev, GDTH_SCRATCH, in gdth_remove_one()
4162 ha->pscratch, ha->scratch_phys); in gdth_remove_one()
4163 if (ha->pmsg) in gdth_remove_one()
4164 dma_free_coherent(&ha->pdev->dev, sizeof(gdth_msg_str), in gdth_remove_one()
4165 ha->pmsg, ha->msg_phys); in gdth_remove_one()
4166 if (ha->ccb_phys) in gdth_remove_one()
4167 dma_unmap_single(&ha->pdev->dev, ha->ccb_phys, in gdth_remove_one()
4194 printk("GDT-HA: Controller driver disabled from" in gdth_init()
4199 printk("GDT-HA: Storage RAID Controller Driver. Version: %s\n", in gdth_init()
4213 return -ENODEV; in gdth_init()
4286 --cur_str; in internal_setup()
4316 ints[0] = i - 1; in option_setup()