--- zzzz-none-000/linux-3.10.107/drivers/vme/bridges/vme_ca91cx42.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/vme/bridges/vme_ca91cx42.c 2021-02-04 17:41:59.000000000 +0000 @@ -42,7 +42,7 @@ static const char driver_name[] = "vme_ca91cx42"; -static DEFINE_PCI_DEVICE_TABLE(ca91cx42_ids) = { +static const struct pci_device_id ca91cx42_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_CA91C142) }, { }, }; @@ -204,8 +204,7 @@ /* Need pdev */ pdev = container_of(ca91cx42_bridge->parent, struct pci_dev, dev); - /* Initialise list for VME bus errors */ - INIT_LIST_HEAD(&ca91cx42_bridge->vme_errors); + INIT_LIST_HEAD(&ca91cx42_bridge->vme_error_handlers); mutex_init(&ca91cx42_bridge->irq_mtx); @@ -243,6 +242,8 @@ static void ca91cx42_irq_exit(struct ca91cx42_driver *bridge, struct pci_dev *pdev) { + struct vme_bridge *ca91cx42_bridge; + /* Disable interrupts from PCI to VME */ iowrite32(0, bridge->base + VINT_EN); @@ -251,7 +252,9 @@ /* Clear Any Pending PCI Interrupts */ iowrite32(0x00FFFFFF, bridge->base + LINT_STAT); - free_irq(pdev->irq, pdev); + ca91cx42_bridge = container_of((void *)bridge, struct vme_bridge, + driver_priv); + free_irq(pdev->irq, ca91cx42_bridge); } static int ca91cx42_iack_received(struct ca91cx42_driver *bridge, int level) @@ -550,7 +553,7 @@ image->bus_resource.flags = IORESOURCE_MEM; retval = pci_bus_alloc_resource(pdev->bus, - &image->bus_resource, size, size, PCIBIOS_MIN_MEM, + &image->bus_resource, size, 0x10000, PCIBIOS_MIN_MEM, 0, NULL, NULL); if (retval) { dev_err(ca91cx42_bridge->parent, "Failed to allocate mem " @@ -856,7 +859,7 @@ void *buf, size_t count, loff_t offset) { ssize_t retval; - void *addr = image->kern_base + offset; + void __iomem *addr = image->kern_base + offset; unsigned int done = 0; unsigned int count32; @@ -865,14 +868,13 @@ spin_lock(&image->lock); - /* The following code handles VME address alignment problem - * in order to assure the maximal data width cycle. - * We cannot use memcpy_xxx directly here because it - * may cut data transfer in 8-bits cycles, thus making - * D16 cycle impossible. - * From the other hand, the bridge itself assures that - * maximal configured data cycle is used and splits it - * automatically for non-aligned addresses. + /* The following code handles VME address alignment. We cannot use + * memcpy_xxx here because it may cut data transfers in to 8-bit + * cycles when D16 or D32 cycles are required on the VME bus. + * On the other hand, the bridge itself assures that the maximum data + * cycle configured for the transfer is used and splits it + * automatically for non-aligned addresses, so we don't want the + * overhead of needlessly forcing small transfers for the entire cycle. */ if ((uintptr_t)addr & 0x1) { *(u8 *)buf = ioread8(addr); @@ -892,9 +894,9 @@ } count32 = (count - done) & ~0x3; - if (count32 > 0) { - memcpy_fromio(buf + done, addr + done, (unsigned int)count); - done += count32; + while (done < count32) { + *(u32 *)(buf + done) = ioread32(addr + done); + done += 4; } if ((count - done) & 0x2) { @@ -916,7 +918,7 @@ void *buf, size_t count, loff_t offset) { ssize_t retval; - void *addr = image->kern_base + offset; + void __iomem *addr = image->kern_base + offset; unsigned int done = 0; unsigned int count32; @@ -926,7 +928,7 @@ spin_lock(&image->lock); /* Here we apply for the same strategy we do in master_read - * function in order to assure D16 cycle when required. + * function in order to assure the correct cycles. */ if ((uintptr_t)addr & 0x1) { iowrite8(*(u8 *)buf, addr); @@ -946,9 +948,9 @@ } count32 = (count - done) & ~0x3; - if (count32 > 0) { - memcpy_toio(addr + done, buf + done, count32); - done += count32; + while (done < count32) { + iowrite32(*(u32 *)(buf + done), addr + done); + done += 4; } if ((count - done) & 0x2) { @@ -1189,7 +1191,7 @@ { struct vme_dma_resource *ctrlr; struct ca91cx42_dma_entry *entry; - int retval = 0; + int retval; dma_addr_t bus_addr; u32 val; struct device *dev; @@ -1242,8 +1244,18 @@ iowrite32(val, bridge->base + DGCS); - wait_event_interruptible(bridge->dma_queue, - ca91cx42_dma_busy(ctrlr->parent)); + retval = wait_event_interruptible(bridge->dma_queue, + ca91cx42_dma_busy(ctrlr->parent)); + + if (retval) { + val = ioread32(bridge->base + DGCS); + iowrite32(val | CA91CX42_DGCS_STOP_REQ, bridge->base + DGCS); + /* Wait for the operation to abort */ + wait_event(bridge->dma_queue, + ca91cx42_dma_busy(ctrlr->parent)); + retval = -EINTR; + goto exit; + } /* * Read status register, this register is valid until we kick off a @@ -1256,8 +1268,10 @@ dev_err(dev, "ca91c042: DMA Error. DGCS=%08X\n", val); val = ioread32(bridge->base + DCTL); + retval = -EIO; } +exit: /* Remove list from running list */ mutex_lock(&ctrlr->mtx); list_del(&list->list); @@ -1552,16 +1566,14 @@ } /* Allocate mem for CR/CSR image */ - bridge->crcsr_kernel = pci_alloc_consistent(pdev, VME_CRCSR_BUF_SIZE, - &bridge->crcsr_bus); + bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE, + &bridge->crcsr_bus); if (bridge->crcsr_kernel == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR " "image\n"); return -ENOMEM; } - memset(bridge->crcsr_kernel, 0, VME_CRCSR_BUF_SIZE); - crcsr_addr = slot * (512 * 1024); iowrite32(bridge->crcsr_bus - crcsr_addr, bridge->base + VCSR_TO);