Skip to content

Commit

Permalink
s390/pci: fix [un]map_resources sequence
Browse files Browse the repository at this point in the history
Commit 8cfc99b ("s390: add pci_iomap_range") introduced counters
to keep track of the number of mappings created. This revealed that
we don't have our internal mappings in order when using hotunplug or
resume from hibernate. This patch addresses both issues.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
  • Loading branch information
Sebastian Ott authored and Martin Schwidefsky committed Feb 27, 2015
1 parent fb3d1c0 commit 1803ba2
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions arch/s390/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,8 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev)
airq_iv_free_bit(zpci_aisb_iv, zdev->aisb);
}

static void zpci_map_resources(struct zpci_dev *zdev)
static void zpci_map_resources(struct pci_dev *pdev)
{
struct pci_dev *pdev = zdev->pdev;
resource_size_t len;
int i;

Expand All @@ -499,9 +498,8 @@ static void zpci_map_resources(struct zpci_dev *zdev)
}
}

static void zpci_unmap_resources(struct zpci_dev *zdev)
static void zpci_unmap_resources(struct pci_dev *pdev)
{
struct pci_dev *pdev = zdev->pdev;
resource_size_t len;
int i;

Expand Down Expand Up @@ -651,7 +649,7 @@ int pcibios_add_device(struct pci_dev *pdev)

zdev->pdev = pdev;
pdev->dev.groups = zpci_attr_groups;
zpci_map_resources(zdev);
zpci_map_resources(pdev);

for (i = 0; i < PCI_BAR_COUNT; i++) {
res = &pdev->resource[i];
Expand All @@ -663,14 +661,18 @@ int pcibios_add_device(struct pci_dev *pdev)
return 0;
}

void pcibios_release_device(struct pci_dev *pdev)
{
zpci_unmap_resources(pdev);
}

int pcibios_enable_device(struct pci_dev *pdev, int mask)
{
struct zpci_dev *zdev = get_zdev(pdev);

zdev->pdev = pdev;
zpci_debug_init_device(zdev);
zpci_fmb_enable_device(zdev);
zpci_map_resources(zdev);

return pci_enable_resources(pdev, mask);
}
Expand All @@ -679,7 +681,6 @@ void pcibios_disable_device(struct pci_dev *pdev)
{
struct zpci_dev *zdev = get_zdev(pdev);

zpci_unmap_resources(zdev);
zpci_fmb_disable_device(zdev);
zpci_debug_exit_device(zdev);
zdev->pdev = NULL;
Expand All @@ -688,7 +689,8 @@ void pcibios_disable_device(struct pci_dev *pdev)
#ifdef CONFIG_HIBERNATE_CALLBACKS
static int zpci_restore(struct device *dev)
{
struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
struct pci_dev *pdev = to_pci_dev(dev);
struct zpci_dev *zdev = get_zdev(pdev);
int ret = 0;

if (zdev->state != ZPCI_FN_STATE_ONLINE)
Expand All @@ -698,7 +700,7 @@ static int zpci_restore(struct device *dev)
if (ret)
goto out;

zpci_map_resources(zdev);
zpci_map_resources(pdev);
zpci_register_ioat(zdev, 0, zdev->start_dma + PAGE_OFFSET,
zdev->start_dma + zdev->iommu_size - 1,
(u64) zdev->dma_table);
Expand All @@ -709,12 +711,14 @@ static int zpci_restore(struct device *dev)

static int zpci_freeze(struct device *dev)
{
struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
struct pci_dev *pdev = to_pci_dev(dev);
struct zpci_dev *zdev = get_zdev(pdev);

if (zdev->state != ZPCI_FN_STATE_ONLINE)
return 0;

zpci_unregister_ioat(zdev, 0);
zpci_unmap_resources(pdev);
return clp_disable_fh(zdev);
}

Expand Down

0 comments on commit 1803ba2

Please sign in to comment.