Skip to content

Commit

Permalink
PCI: Add pci_iounmap
Browse files Browse the repository at this point in the history
In case if any architecture selects CONFIG_GENERIC_PCI_IOMAP and not
CONFIG_GENERIC_IOMAP, then the pci_iounmap function is reduced to a NULL
function. Due to this the managed release variants or even the explicit
pci_iounmap calls doesn't really remove the mappings.

This issue is seen on an arm64 based system. arm64 by default selects
only CONFIG_GENERIC_PCI_IOMAP and not CONFIG_GENERIC_IOMAP from this
'commit cb61f67 ("ARM64: use GENERIC_PCI_IOMAP")'

Simple bind/unbind test of any pci driver using pcim_iomap/pci_iomap,
would lead to the following error message after long hour tests

"allocation failed: out of vmalloc space - use vmalloc=<size> to
increase size."

Signed-off-by: George Cherian <george.cherian@marvell.com>
  • Loading branch information
georgecherian81 authored and intel-lab-lkp committed Aug 19, 2020
1 parent 9123e3a commit 2bb1d10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/asm-generic/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -915,12 +915,16 @@ static inline void iowrite64_rep(volatile void __iomem *addr,
struct pci_dev;
extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);

#ifdef CONFIG_GENERIC_PCI_IOMAP
extern void pci_iounmap(struct pci_dev *dev, void __iomem *p);
#else
#ifndef pci_iounmap
#define pci_iounmap pci_iounmap
static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
{
}
#endif
#endif /* CONFIG_GENERIC_PCI_IOMAP */
#endif /* CONFIG_GENERIC_IOMAP */

/*
Expand Down
9 changes: 9 additions & 0 deletions lib/pci_iomap.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,13 @@ void __iomem *pci_iomap_wc(struct pci_dev *dev, int bar, unsigned long maxlen)
return pci_iomap_wc_range(dev, bar, 0, maxlen);
}
EXPORT_SYMBOL_GPL(pci_iomap_wc);

#ifndef CONFIG_GENERIC_IOMAP
#define pci_iounmap pci_iounmap
void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
{
iounmap(addr);
}
EXPORT_SYMBOL(pci_iounmap);
#endif
#endif /* CONFIG_PCI */

0 comments on commit 2bb1d10

Please sign in to comment.