From 15f423c33f8dccbe39092a98b130c191bfd3f3da Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Mon, 27 Feb 2012 13:27:05 -0600 Subject: [PATCH 2/4] dahdi: Add dahdi_pci_disable_link_state for kernel < 2.6.25. Will allow the ASPM (Active State Power Management) state to be disabled on PCIe devices before kernel version 2.6.25. Signed-off-by: Shaun Ruffell --- drivers/dahdi/dahdi-base.c | 19 ++++++++++++++++++- include/dahdi/kernel.h | 17 +++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 020150e..e364a9a 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -10060,6 +10060,23 @@ failed_driver_init: return res; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) +#ifdef CONFIG_PCI +/* Backported pci_disable_link_state */ +void dahdi_pci_disable_link_state(struct pci_dev *pdev, int state) +{ + u16 reg16; + int pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); + if (!pos) + return; + pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, ®16); + reg16 &= ~(state); + pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); +} +EXPORT_SYMBOL(dahdi_pci_disable_link_state); +#endif /* CONFIG_PCI */ +#endif /* 2.6.25 */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) static inline void flush_find_master_work(void) { @@ -10134,7 +10151,7 @@ char *dahdi_kasprintf(gfp_t gfp, const char *fmt, ...) return p; } EXPORT_SYMBOL(dahdi_kasprintf); -#endif +#endif /* 2.6.12 */ module_init(dahdi_init); module_exit(dahdi_cleanup); diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index 882d31e..28b1a1d 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -72,6 +72,12 @@ #define DAHDI_IRQ_HANDLER(a) static irqreturn_t a(int irq, void *dev_id, struct pt_regs *regs) #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) +#ifdef CONFIG_PCI +#include +#endif +#endif + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) #define HAVE_NET_DEVICE_OPS #endif @@ -1409,6 +1415,17 @@ static inline int strcasecmp(const char *s1, const char *s2) return c1 - c2; } #endif /* clamp_val */ + +#ifdef CONFIG_PCI +#ifndef PCIE_LINK_STATE_L0S +#define PCIE_LINK_STATE_L0S 1 +#define PCIE_LINK_STATE_L1 2 +#define PCIE_LINK_STATE_CLKPM 4 +#endif +#define pci_disable_link_state dahdi_pci_disable_link_state +void dahdi_pci_disable_link_state(struct pci_dev *pdev, int state); +#endif /* CONFIG_PCI */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) static inline void list_replace(struct list_head *old, struct list_head *new) { -- 1.7.9.2