Skip to content

Commit c7ff0e9

Browse files
sebottVasily Gorbik
authored andcommitted
s390/pci: deal with devices that have no support for MIO instructions
Unfortunately we have to handle a class of devices that don't support the new MIO instructions. Adjust resource assignment and mapping accordingly. Signed-off-by: Sebastian Ott <sebott@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 05f31e3 commit c7ff0e9

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎arch/s390/include/asm/pci.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ int zpci_init_iommu(struct zpci_dev *zdev);
194194
void zpci_destroy_iommu(struct zpci_dev *zdev);
195195

196196
#ifdef CONFIG_PCI
197+
static inline bool zpci_use_mio(struct zpci_dev *zdev)
198+
{
199+
return static_branch_likely(&have_mio) && zdev->mio_capable;
200+
}
201+
197202
/* Error handling and recovery */
198203
void zpci_event_error(void *);
199204
void zpci_event_availability(void *);

‎arch/s390/pci/pci.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,12 @@ static void zpci_map_resources(struct pci_dev *pdev)
421421
if (!len)
422422
continue;
423423

424-
if (static_branch_likely(&have_mio))
424+
if (zpci_use_mio(zdev))
425425
pdev->resource[i].start =
426426
(resource_size_t __force) zdev->bars[i].mio_wb;
427427
else
428-
pdev->resource[i].start =
429-
(resource_size_t __force) pci_iomap(pdev, i, 0);
428+
pdev->resource[i].start = (resource_size_t __force)
429+
pci_iomap_range_fh(pdev, i, 0, 0);
430430
pdev->resource[i].end = pdev->resource[i].start + len - 1;
431431
}
432432

@@ -444,18 +444,19 @@ static void zpci_map_resources(struct pci_dev *pdev)
444444

445445
static void zpci_unmap_resources(struct pci_dev *pdev)
446446
{
447+
struct zpci_dev *zdev = to_zpci(pdev);
447448
resource_size_t len;
448449
int i;
449450

450-
if (static_branch_likely(&have_mio))
451+
if (zpci_use_mio(zdev))
451452
return;
452453

453454
for (i = 0; i < PCI_BAR_COUNT; i++) {
454455
len = pci_resource_len(pdev, i);
455456
if (!len)
456457
continue;
457-
pci_iounmap(pdev, (void __iomem __force *)
458-
pdev->resource[i].start);
458+
pci_iounmap_fh(pdev, (void __iomem __force *)
459+
pdev->resource[i].start);
459460
}
460461
}
461462

@@ -528,7 +529,7 @@ static int zpci_setup_bus_resources(struct zpci_dev *zdev,
528529
if (zdev->bars[i].val & 4)
529530
flags |= IORESOURCE_MEM_64;
530531

531-
if (static_branch_likely(&have_mio))
532+
if (zpci_use_mio(zdev))
532533
addr = (unsigned long) zdev->bars[i].mio_wb;
533534
else
534535
addr = ZPCI_ADDR(entry);

0 commit comments

Comments
 (0)