void zpci_event_error(void *data) { struct zpci_ccdf_err *ccdf = data; struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid); zpci_err("error CCDF:\n"); zpci_err_hex(ccdf, sizeof(*ccdf)); if (!zdev) return; pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n", pci_name(zdev->pdev), ccdf->pec, ccdf->fid); }
static void __zpci_event_error(struct zpci_ccdf_err *ccdf) { struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid); struct pci_dev *pdev = NULL; zpci_err("error CCDF:\n"); zpci_err_hex(ccdf, sizeof(*ccdf)); if (zdev) pdev = pci_get_slot(zdev->bus, ZPCI_DEVFN); pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n", pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid); if (!pdev) return; pci_dev_put(pdev); }
static void s390_dma_unmap_pages(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction, struct dma_attrs *attrs) { struct zpci_dev *zdev = get_zdev(to_pci_dev(dev)); unsigned long iommu_page_index; int npages; npages = iommu_num_pages(dma_addr, size, PAGE_SIZE); dma_addr = dma_addr & PAGE_MASK; if (dma_update_trans(zdev, 0, dma_addr, npages * PAGE_SIZE, ZPCI_TABLE_PROTECTED | ZPCI_PTE_INVALID)) { zpci_err("unmap error:\n"); zpci_err_hex(&dma_addr, sizeof(dma_addr)); } atomic64_add(npages, &zdev->fmb->unmapped_pages); iommu_page_index = (dma_addr - zdev->start_dma) >> PAGE_SHIFT; dma_free_iommu(zdev, iommu_page_index, npages); }
static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page, unsigned long offset, size_t size, enum dma_data_direction direction, struct dma_attrs *attrs) { struct zpci_dev *zdev = get_zdev(to_pci_dev(dev)); unsigned long nr_pages, iommu_page_index; unsigned long pa = page_to_phys(page) + offset; int flags = ZPCI_PTE_VALID; dma_addr_t dma_addr; /* This rounds up number of pages based on size and offset */ nr_pages = iommu_num_pages(pa, size, PAGE_SIZE); iommu_page_index = dma_alloc_iommu(zdev, nr_pages); if (iommu_page_index == -1) goto out_err; /* Use rounded up size */ size = nr_pages * PAGE_SIZE; dma_addr = zdev->start_dma + iommu_page_index * PAGE_SIZE; if (dma_addr + size > zdev->end_dma) goto out_free; if (direction == DMA_NONE || direction == DMA_TO_DEVICE) flags |= ZPCI_TABLE_PROTECTED; if (!dma_update_trans(zdev, pa, dma_addr, size, flags)) { atomic64_add(nr_pages, &zdev->fmb->mapped_pages); return dma_addr + (offset & ~PAGE_MASK); } out_free: dma_free_iommu(zdev, iommu_page_index, nr_pages); out_err: zpci_err("map error:\n"); zpci_err_hex(&pa, sizeof(pa)); return DMA_ERROR_CODE; }
static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf) { struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid); struct pci_dev *pdev = NULL; int ret; if (zdev) pdev = pci_get_slot(zdev->bus, ZPCI_DEVFN); pr_info("%s: Event 0x%x reconfigured PCI function 0x%x\n", pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid); zpci_err("avail CCDF:\n"); zpci_err_hex(ccdf, sizeof(*ccdf)); switch (ccdf->pec) { case 0x0301: /* Reserved|Standby -> Configured */ if (!zdev) { ret = clp_add_pci_device(ccdf->fid, ccdf->fh, 0); if (ret) break; zdev = get_zdev_by_fid(ccdf->fid); } if (!zdev || zdev->state != ZPCI_FN_STATE_STANDBY) break; zdev->state = ZPCI_FN_STATE_CONFIGURED; zdev->fh = ccdf->fh; ret = zpci_enable_device(zdev); if (ret) break; pci_lock_rescan_remove(); pci_rescan_bus(zdev->bus); pci_unlock_rescan_remove(); break; case 0x0302: /* Reserved -> Standby */ if (!zdev) clp_add_pci_device(ccdf->fid, ccdf->fh, 0); break; case 0x0303: /* Deconfiguration requested */ if (pdev) pci_stop_and_remove_bus_device_locked(pdev); ret = zpci_disable_device(zdev); if (ret) break; ret = sclp_pci_deconfigure(zdev->fid); zpci_dbg(3, "deconf fid:%x, rc:%d\n", zdev->fid, ret); if (!ret) zdev->state = ZPCI_FN_STATE_STANDBY; break; case 0x0304: /* Configured -> Standby */ if (pdev) { /* Give the driver a hint that the function is * already unusable. */ pdev->error_state = pci_channel_io_perm_failure; pci_stop_and_remove_bus_device_locked(pdev); } zdev->fh = ccdf->fh; zpci_disable_device(zdev); zdev->state = ZPCI_FN_STATE_STANDBY; break; case 0x0306: /* 0x308 or 0x302 for multiple devices */ clp_rescan_pci_devices(); break; case 0x0308: /* Standby -> Reserved */ if (!zdev) break; pci_stop_root_bus(zdev->bus); pci_remove_root_bus(zdev->bus); break; default: break; } if (pdev) pci_dev_put(pdev); }