Skip to content

Commit

Permalink
Merge branch 'pci/misc' into next
Browse files Browse the repository at this point in the history
* pci/misc:
  PCI: Fix return value from pci_user_{read,write}_config_*()
  PCI: Turn pcibios_penalize_isa_irq() into a weak function
  PCI: Test for std config alias when testing extended config space
  • Loading branch information
Bjorn Helgaas committed May 28, 2014
2 parents d1a2523 + d97ffe2 commit fdaf36b
Show file tree
Hide file tree
Showing 23 changed files with 56 additions and 90 deletions.
5 changes: 0 additions & 5 deletions arch/alpha/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ struct pci_controller {

extern void pcibios_set_master(struct pci_dev *dev);

extern inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

/* IOMMU controls. */

/* The PCI address space does not equal the physical memory address space.
Expand Down
5 changes: 0 additions & 5 deletions arch/arm/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ static inline int pci_proc_domain(struct pci_bus *bus)
}
#endif /* CONFIG_PCI_DOMAINS */

static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

/*
* The PCI address space does equal the physical memory address space.
* The networking and block device layers use this boolean for bounce
Expand Down
5 changes: 0 additions & 5 deletions arch/blackfin/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,4 @@
#define PCIBIOS_MIN_IO 0x00001000
#define PCIBIOS_MIN_MEM 0x10000000

static inline void pcibios_penalize_isa_irq(int irq)
{
/* We don't do dynamic PCI IRQ allocation */
}

#endif /* _ASM_BFIN_PCI_H */
1 change: 0 additions & 1 deletion arch/cris/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ void pcibios_config_init(void);
struct pci_bus * pcibios_scan_root(int bus);

void pcibios_set_master(struct pci_dev *dev);
void pcibios_penalize_isa_irq(int irq);
struct irq_routing_table *pcibios_get_irq_routing_table(void);
int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);

Expand Down
2 changes: 0 additions & 2 deletions arch/frv/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ struct pci_dev;

extern void pcibios_set_master(struct pci_dev *dev);

extern void pcibios_penalize_isa_irq(int irq);

#ifdef CONFIG_MMU
extern void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle);
extern void consistent_free(void *vaddr);
Expand Down
4 changes: 0 additions & 4 deletions arch/frv/mb93090-mb00/pci-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ void __init pcibios_fixup_irqs(void)
}
}

void __init pcibios_penalize_isa_irq(int irq)
{
}

void pcibios_enable_irq(struct pci_dev *dev)
{
pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
Expand Down
6 changes: 0 additions & 6 deletions arch/ia64/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ struct pci_dev;
extern unsigned long ia64_max_iommu_merge_mask;
#define PCI_DMA_BUS_IS_PHYS (ia64_max_iommu_merge_mask == ~0UL)

static inline void
pcibios_penalize_isa_irq (int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

#include <asm-generic/pci-dma-compat.h>

#ifdef CONFIG_PCI
Expand Down
5 changes: 0 additions & 5 deletions arch/microblaze/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ struct pci_dev;
*/
#define pcibios_assign_all_busses() 0

static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

#ifdef CONFIG_PCI
extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
extern struct dma_map_ops *get_pci_dma_ops(void);
Expand Down
5 changes: 0 additions & 5 deletions arch/mips/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ extern unsigned long PCIBIOS_MIN_MEM;

extern void pcibios_set_master(struct pci_dev *dev);

static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

#define HAVE_PCI_MMAP

extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
Expand Down
1 change: 0 additions & 1 deletion arch/mn10300/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ extern void unit_pci_init(void);
#define PCIBIOS_MIN_MEM 0xB8000000

void pcibios_set_master(struct pci_dev *dev);
void pcibios_penalize_isa_irq(int irq);

/* Dynamic DMA mapping stuff.
* i386 has everything mapped statically.
Expand Down
4 changes: 0 additions & 4 deletions arch/mn10300/unit-asb2305/pci-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ void __init pcibios_fixup_irqs(void)
}
}

void __init pcibios_penalize_isa_irq(int irq)
{
}

void pcibios_enable_irq(struct pci_dev *dev)
{
pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
Expand Down
5 changes: 0 additions & 5 deletions arch/parisc/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
}
#endif

static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't need to penalize isa irq's */
}

static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
{
return channel ? 15 : 14;
Expand Down
5 changes: 0 additions & 5 deletions arch/powerpc/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ struct pci_dev;
#define pcibios_assign_all_busses() \
(pci_has_flag(PCI_REASSIGN_ALL_BUS))

static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

#define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
{
Expand Down
5 changes: 0 additions & 5 deletions arch/sh/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
enum pci_mmap_state mmap_state, int write_combine);
extern void pcibios_set_master(struct pci_dev *dev);

static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

/* Dynamic DMA mapping stuff.
* SuperH has everything mapped statically like x86.
*/
Expand Down
5 changes: 0 additions & 5 deletions arch/sparc/include/asm/pci_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@

#define PCI_IRQ_NONE 0xffffffff

static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

/* Dynamic DMA mapping stuff.
*/
#define PCI_DMA_BUS_IS_PHYS (0)
Expand Down
5 changes: 0 additions & 5 deletions arch/sparc/include/asm/pci_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@

#define PCI_IRQ_NONE 0xffffffff

static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

/* The PCI address space does not equal the physical memory
* address space. The networking and block device layers use
* this boolean for bounce buffer decisions.
Expand Down
5 changes: 0 additions & 5 deletions arch/unicore32/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
#include <asm-generic/pci.h>
#include <mach/hardware.h> /* for PCIBIOS_MIN_* */

static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}

#ifdef CONFIG_PCI
static inline void pci_dma_burst_advice(struct pci_dev *pdev,
enum pci_dma_burst_strategy *strat,
Expand Down
1 change: 0 additions & 1 deletion arch/x86/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ void pcibios_config_init(void);
void pcibios_scan_root(int bus);

void pcibios_set_master(struct pci_dev *dev);
void pcibios_penalize_isa_irq(int irq, int active);
struct irq_routing_table *pcibios_get_irq_routing_table(void);
int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);

Expand Down
5 changes: 0 additions & 5 deletions arch/xtensa/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@

extern struct pci_controller* pcibios_alloc_controller(void);

static inline void pcibios_penalize_isa_irq(int irq)
{
/* We don't do dynamic PCI IRQ allocation */
}

/* Assume some values. (We should revise them, if necessary) */

#define PCIBIOS_MIN_IO 0x2000
Expand Down
12 changes: 4 additions & 8 deletions drivers/pci/access.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static noinline void pci_wait_cfg(struct pci_dev *dev)
int pci_user_read_config_##size \
(struct pci_dev *dev, int pos, type *val) \
{ \
int ret = 0; \
int ret = PCIBIOS_SUCCESSFUL; \
u32 data = -1; \
if (PCI_##size##_BAD) \
return -EINVAL; \
Expand All @@ -159,9 +159,7 @@ int pci_user_read_config_##size \
pos, sizeof(type), &data); \
raw_spin_unlock_irq(&pci_lock); \
*val = (type)data; \
if (ret > 0) \
ret = -EINVAL; \
return ret; \
return pcibios_err_to_errno(ret); \
} \
EXPORT_SYMBOL_GPL(pci_user_read_config_##size);

Expand All @@ -170,7 +168,7 @@ EXPORT_SYMBOL_GPL(pci_user_read_config_##size);
int pci_user_write_config_##size \
(struct pci_dev *dev, int pos, type val) \
{ \
int ret = -EIO; \
int ret = PCIBIOS_SUCCESSFUL; \
if (PCI_##size##_BAD) \
return -EINVAL; \
raw_spin_lock_irq(&pci_lock); \
Expand All @@ -179,9 +177,7 @@ int pci_user_write_config_##size \
ret = dev->bus->ops->write(dev->bus, dev->devfn, \
pos, sizeof(type), val); \
raw_spin_unlock_irq(&pci_lock); \
if (ret > 0) \
ret = -EINVAL; \
return ret; \
return pcibios_err_to_errno(ret); \
} \
EXPORT_SYMBOL_GPL(pci_user_write_config_##size);

Expand Down
11 changes: 11 additions & 0 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,17 @@ void __weak pcibios_release_device(struct pci_dev *dev) {}
*/
void __weak pcibios_disable_device (struct pci_dev *dev) {}

/**
* pcibios_penalize_isa_irq - penalize an ISA IRQ
* @irq: ISA IRQ to penalize
* @active: IRQ active or not
*
* Permits the platform to provide architecture-specific functionality when
* penalizing ISA IRQs. This is the default implementation. Architecture
* implementations can override this.
*/
void __weak pcibios_penalize_isa_irq(int irq, int active) {}

static void do_pci_disable_device(struct pci_dev *dev)
{
u16 pci_command;
Expand Down
39 changes: 38 additions & 1 deletion drivers/pci/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,43 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev)
}


/**
* pci_ext_cfg_is_aliased - is ext config space just an alias of std config?
* @dev: PCI device
*
* PCI Express to PCI/PCI-X Bridge Specification, rev 1.0, 4.1.4 says that
* when forwarding a type1 configuration request the bridge must check that
* the extended register address field is zero. The bridge is not permitted
* to forward the transactions and must handle it as an Unsupported Request.
* Some bridges do not follow this rule and simply drop the extended register
* bits, resulting in the standard config space being aliased, every 256
* bytes across the entire configuration space. Test for this condition by
* comparing the first dword of each potential alias to the vendor/device ID.
* Known offenders:
* ASM1083/1085 PCIe-to-PCI Reversible Bridge (1b21:1080, rev 01 & 03)
* AMD/ATI SBx00 PCI to PCI Bridge (1002:4384, rev 40)
*/
static bool pci_ext_cfg_is_aliased(struct pci_dev *dev)
{
#ifdef CONFIG_PCI_QUIRKS
int pos;
u32 header, tmp;

pci_read_config_dword(dev, PCI_VENDOR_ID, &header);

for (pos = PCI_CFG_SPACE_SIZE;
pos < PCI_CFG_SPACE_EXP_SIZE; pos += PCI_CFG_SPACE_SIZE) {
if (pci_read_config_dword(dev, pos, &tmp) != PCIBIOS_SUCCESSFUL
|| header != tmp)
return false;
}

return true;
#else
return false;
#endif
}

/**
* pci_cfg_space_size - get the configuration space size of the PCI device.
* @dev: PCI device
Expand All @@ -1011,7 +1048,7 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev)

if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
goto fail;
if (status == 0xffffffff)
if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev))
goto fail;

return PCI_CFG_SPACE_EXP_SIZE;
Expand Down
5 changes: 3 additions & 2 deletions include/linux/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ static inline int pcibios_err_to_errno(int err)
case PCIBIOS_FUNC_NOT_SUPPORTED:
return -ENOENT;
case PCIBIOS_BAD_VENDOR_ID:
return -EINVAL;
return -ENOTTY;
case PCIBIOS_DEVICE_NOT_FOUND:
return -ENODEV;
case PCIBIOS_BAD_REGISTER_NUMBER:
Expand All @@ -543,7 +543,7 @@ static inline int pcibios_err_to_errno(int err)
return -ENOSPC;
}

return -ENOTTY;
return -ERANGE;
}

/* Low-level architecture-dependent routines */
Expand Down Expand Up @@ -1592,6 +1592,7 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev,
enum pcie_reset_state state);
int pcibios_add_device(struct pci_dev *dev);
void pcibios_release_device(struct pci_dev *dev);
void pcibios_penalize_isa_irq(int irq, int active);

#ifdef CONFIG_HIBERNATE_CALLBACKS
extern struct dev_pm_ops pcibios_pm_ops;
Expand Down

0 comments on commit fdaf36b

Please sign in to comment.