···210210 firmware assigned instance number of the PCI211211 device that can help in understanding the firmware212212 intended order of the PCI device.213213+214214+What: /sys/bus/pci/devices/.../d3cold_allowed215215+Date: July 2012216216+Contact: Huang Ying <ying.huang@intel.com>217217+Description:218218+ d3cold_allowed is bit to control whether the corresponding PCI219219+ device can be put into D3Cold state. If it is cleared, the220220+ device will never be put into D3Cold state. If it is set, the221221+ device may be put into D3Cold state if other requirements are222222+ satisfied too. Reading this attribute will show the current223223+ value of d3cold_allowed bit. Writing this attribute will set224224+ the value of d3cold_allowed bit.
+1-1
Documentation/feature-removal-schedule.txt
···579579----------------------------580580581581What: at91-mci driver ("CONFIG_MMC_AT91")582582-When: 3.7582582+When: 3.8583583Why: There are two mci drivers: at91-mci and atmel-mci. The PDC support584584 was added to atmel-mci as a first step to support more chips.585585 Then at91-mci was kept only for old IP versions (on at91rm9200 and
···203203}204204205205/*206206+ * This can be called during early boot to increase the size of the atomic207207+ * coherent DMA pool above the default value of 256KiB. It must be called208208+ * before postcore_initcall.209209+ */210210+extern void __init init_dma_coherent_pool_size(unsigned long size);211211+212212+/*206213 * This can be called during boot to increase the size of the consistent207214 * DMA region above it's default value of 2MB. It must be called before the208215 * memory allocator is initialised, i.e. before any core_initcall.
+1-1
arch/arm/mach-at91/at91rm9200_time.c
···197197 at91_st_read(AT91_ST_SR);198198199199 /* Make IRQs happen for the system timer */200200- setup_irq(AT91_ID_SYS, &at91rm9200_timer_irq);200200+ setup_irq(NR_IRQS_LEGACY + AT91_ID_SYS, &at91rm9200_timer_irq);201201202202 /* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used203203 * directly for the clocksource and all clockevents, after adjusting
+5-1
arch/arm/mach-at91/at91sam9260_devices.c
···726726 .flags = IORESOURCE_MEM,727727 }, {728728 .flags = IORESOURCE_MEM,729729+ }, {730730+ .flags = IORESOURCE_IRQ,729731 },730732};731733···746744 * The second resource is needed:747745 * GPBR will serve as the storage for RTC time offset748746 */749749- at91sam9260_rtt_device.num_resources = 2;747747+ at91sam9260_rtt_device.num_resources = 3;750748 rtt_resources[1].start = AT91SAM9260_BASE_GPBR +751749 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;752750 rtt_resources[1].end = rtt_resources[1].start + 3;751751+ rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;752752+ rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;753753}754754#else755755static void __init at91_add_device_rtt_rtc(void)
+5-1
arch/arm/mach-at91/at91sam9261_devices.c
···609609 .flags = IORESOURCE_MEM,610610 }, {611611 .flags = IORESOURCE_MEM,612612+ }, {613613+ .flags = IORESOURCE_IRQ,612614 }613615};614616···628626 * The second resource is needed:629627 * GPBR will serve as the storage for RTC time offset630628 */631631- at91sam9261_rtt_device.num_resources = 2;629629+ at91sam9261_rtt_device.num_resources = 3;632630 rtt_resources[1].start = AT91SAM9261_BASE_GPBR +633631 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;634632 rtt_resources[1].end = rtt_resources[1].start + 3;633633+ rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;634634+ rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;635635}636636#else637637static void __init at91_add_device_rtt_rtc(void)
+8-2
arch/arm/mach-at91/at91sam9263_devices.c
···990990 .flags = IORESOURCE_MEM,991991 }, {992992 .flags = IORESOURCE_MEM,993993+ }, {994994+ .flags = IORESOURCE_IRQ,993995 }994996};995997···10081006 .flags = IORESOURCE_MEM,10091007 }, {10101008 .flags = IORESOURCE_MEM,10091009+ }, {10101010+ .flags = IORESOURCE_IRQ,10111011 }10121012};10131013···10311027 * The second resource is needed only for the chosen RTT:10321028 * GPBR will serve as the storage for RTC time offset10331029 */10341034- at91sam9263_rtt0_device.num_resources = 2;10301030+ at91sam9263_rtt0_device.num_resources = 3;10351031 at91sam9263_rtt1_device.num_resources = 1;10361032 pdev = &at91sam9263_rtt0_device;10371033 r = rtt0_resources;10381034 break;10391035 case 1:10401036 at91sam9263_rtt0_device.num_resources = 1;10411041- at91sam9263_rtt1_device.num_resources = 2;10371037+ at91sam9263_rtt1_device.num_resources = 3;10421038 pdev = &at91sam9263_rtt1_device;10431039 r = rtt1_resources;10441040 break;···10511047 pdev->name = "rtc-at91sam9";10521048 r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;10531049 r[1].end = r[1].start + 3;10501050+ r[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;10511051+ r[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;10541052}10551053#else10561054static void __init at91_add_device_rtt_rtc(void)
+5-1
arch/arm/mach-at91/at91sam9g45_devices.c
···12931293 .flags = IORESOURCE_MEM,12941294 }, {12951295 .flags = IORESOURCE_MEM,12961296+ }, {12971297+ .flags = IORESOURCE_IRQ,12961298 }12971299};12981300···13121310 * The second resource is needed:13131311 * GPBR will serve as the storage for RTC time offset13141312 */13151315- at91sam9g45_rtt_device.num_resources = 2;13131313+ at91sam9g45_rtt_device.num_resources = 3;13161314 rtt_resources[1].start = AT91SAM9G45_BASE_GPBR +13171315 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;13181316 rtt_resources[1].end = rtt_resources[1].start + 3;13171317+ rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;13181318+ rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;13191319}13201320#else13211321static void __init at91_add_device_rtt_rtc(void)
+5-1
arch/arm/mach-at91/at91sam9rl_devices.c
···688688 .flags = IORESOURCE_MEM,689689 }, {690690 .flags = IORESOURCE_MEM,691691+ }, {692692+ .flags = IORESOURCE_IRQ,691693 }692694};693695···707705 * The second resource is needed:708706 * GPBR will serve as the storage for RTC time offset709707 */710710- at91sam9rl_rtt_device.num_resources = 2;708708+ at91sam9rl_rtt_device.num_resources = 3;711709 rtt_resources[1].start = AT91SAM9RL_BASE_GPBR +712710 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;713711 rtt_resources[1].end = rtt_resources[1].start + 3;712712+ rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;713713+ rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;714714}715715#else716716static void __init at91_add_device_rtt_rtc(void)
+12
arch/arm/mach-at91/clock.c
···63636464#define cpu_has_300M_plla() (cpu_is_at91sam9g10())65656666+#define cpu_has_240M_plla() (cpu_is_at91sam9261() \6767+ || cpu_is_at91sam9263() \6868+ || cpu_is_at91sam9rl())6969+7070+#define cpu_has_210M_plla() (cpu_is_at91sam9260())7171+6672#define cpu_has_pllb() (!(cpu_is_at91sam9rl() \6773 || cpu_is_at91sam9g45() \6874 || cpu_is_at91sam9x5() \···711705 pll_overclock = true;712706 } else if (cpu_has_800M_plla()) {713707 if (plla.rate_hz > 800000000)708708+ pll_overclock = true;709709+ } else if (cpu_has_240M_plla()) {710710+ if (plla.rate_hz > 240000000)711711+ pll_overclock = true;712712+ } else if (cpu_has_210M_plla()) {713713+ if (plla.rate_hz > 210000000)714714 pll_overclock = true;715715 } else {716716 if (plla.rate_hz > 209000000)
···517517void __init kirkwood_init_early(void)518518{519519 orion_time_set_base(TIMER_VIRT_BASE);520520+521521+ /*522522+ * Some Kirkwood devices allocate their coherent buffers from atomic523523+ * context. Increase size of atomic coherent pool to make sure such524524+ * the allocations won't fail.525525+ */526526+ init_dma_coherent_pool_size(SZ_1M);520527}521528522529int kirkwood_tclk;
···259259 return 0; /* always allow wakeup */260260}261261262262-#define RELOC_BASE 0x1000262262+#define RELOC_BASE 0x1200263263264264-/* INTCA IRQ pins at INTCS + 0x1000 to make space for GIC+INTC handling */264264+/* INTCA IRQ pins at INTCS + RELOC_BASE to make space for GIC+INTC handling */265265#define INTCS_VECT_RELOC(n, vect) INTCS_VECT((n), (vect) + RELOC_BASE)266266267267INTC_IRQ_PINS_32(intca_irq_pins, 0xe6900000,
···215215 /* Called after scan and before resource survey */216216 void (*pcibios_fixup_phb)(struct pci_controller *hose);217217218218+ /* Called during PCI resource reassignment */219219+ resource_size_t (*pcibios_window_alignment)(struct pci_bus *, unsigned long type);220220+218221 /* Called to shutdown machine specific hardware not already controlled219222 * by other drivers.220223 */
+20
arch/powerpc/kernel/pci-common.c
···9999 kfree(phb);100100}101101102102+/*103103+ * The function is used to return the minimal alignment104104+ * for memory or I/O windows of the associated P2P bridge.105105+ * By default, 4KiB alignment for I/O windows and 1MiB for106106+ * memory windows.107107+ */108108+resource_size_t pcibios_window_alignment(struct pci_bus *bus,109109+ unsigned long type)110110+{111111+ if (ppc_md.pcibios_window_alignment)112112+ return ppc_md.pcibios_window_alignment(bus, type);113113+114114+ /*115115+ * PCI core will figure out the default116116+ * alignment: 4KiB for I/O and 1MiB for117117+ * memory window.118118+ */119119+ return 1;120120+}121121+102122static resource_size_t pcibios_io_size(const struct pci_controller *hose)103123{104124#ifdef CONFIG_PPC64
+40-1
arch/powerpc/platforms/powernv/pci-ioda.c
···854854 if (pe == NULL)855855 continue;856856 /* Leaving the PCIe domain ... single PE# */857857- if (dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE)857857+ if (pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE)858858 pnv_ioda_setup_bus_PE(dev, pe);859859 else if (dev->subordinate)860860 pnv_ioda_setup_PEs(dev->subordinate);···11381138 }11391139}1140114011411141+/*11421142+ * Returns the alignment for I/O or memory windows for P2P11431143+ * bridges. That actually depends on how PEs are segmented.11441144+ * For now, we return I/O or M32 segment size for PE sensitive11451145+ * P2P bridges. Otherwise, the default values (4KiB for I/O,11461146+ * 1MiB for memory) will be returned.11471147+ *11481148+ * The current PCI bus might be put into one PE, which was11491149+ * create against the parent PCI bridge. For that case, we11501150+ * needn't enlarge the alignment so that we can save some11511151+ * resources.11521152+ */11531153+static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus,11541154+ unsigned long type)11551155+{11561156+ struct pci_dev *bridge;11571157+ struct pci_controller *hose = pci_bus_to_host(bus);11581158+ struct pnv_phb *phb = hose->private_data;11591159+ int num_pci_bridges = 0;11601160+11611161+ bridge = bus->self;11621162+ while (bridge) {11631163+ if (pci_pcie_type(bridge) == PCI_EXP_TYPE_PCI_BRIDGE) {11641164+ num_pci_bridges++;11651165+ if (num_pci_bridges >= 2)11661166+ return 1;11671167+ }11681168+11691169+ bridge = bridge->bus->self;11701170+ }11711171+11721172+ /* We need support prefetchable memory window later */11731173+ if (type & IORESOURCE_MEM)11741174+ return phb->ioda.m32_segsize;11751175+11761176+ return phb->ioda.io_segsize;11771177+}11781178+11411179/* Prevent enabling devices for which we couldn't properly11421180 * assign a PE11431181 */···13431305 */13441306 ppc_md.pcibios_fixup_phb = pnv_pci_ioda_fixup_phb;13451307 ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook;13081308+ ppc_md.pcibios_window_alignment = pnv_pci_window_alignment;13461309 pci_add_flags(PCI_PROBE_ONLY | PCI_REASSIGN_ALL_RSRC);1347131013481311 /* Reset IODA tables to a clean state */
+6-20
arch/tile/kernel/pci.c
···246246247247 /* Scan for the smallest maximum payload size. */248248 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {249249- int pcie_caps_offset;250249 u32 devcap;251250 int max_payload;252251253253- pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP);254254- if (pcie_caps_offset == 0)252252+ if (!pci_is_pcie(dev))255253 continue;256254257257- pci_read_config_dword(dev, pcie_caps_offset + PCI_EXP_DEVCAP,258258- &devcap);255255+ pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &devcap);259256 max_payload = devcap & PCI_EXP_DEVCAP_PAYLOAD;260257 if (max_payload < smallest_max_payload)261258 smallest_max_payload = max_payload;···260263261264 /* Now, set the max_payload_size for all devices to that value. */262265 new_values = (max_read_size << 12) | (smallest_max_payload << 5);263263- while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {264264- int pcie_caps_offset;265265- u16 devctl;266266-267267- pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP);268268- if (pcie_caps_offset == 0)269269- continue;270270-271271- pci_read_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL,272272- &devctl);273273- devctl &= ~(PCI_EXP_DEVCTL_PAYLOAD | PCI_EXP_DEVCTL_READRQ);274274- devctl |= new_values;275275- pci_write_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL,276276- devctl);277277- }266266+ while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)267267+ pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,268268+ PCI_EXP_DEVCTL_PAYLOAD | PCI_EXP_DEVCTL_READRQ,269269+ new_values);278270}279271280272
···8282 gpiochip_find(&gg_data, of_gpiochip_find_and_xlate);83838484 of_node_put(gg_data.gpiospec.np);8585- pr_debug("%s exited with status %d\n", __func__, ret);8585+ pr_debug("%s exited with status %d\n", __func__, gg_data.out_gpio);8686 return gg_data.out_gpio;8787}8888EXPORT_SYMBOL(of_get_named_gpio_flags);
+3-7
drivers/gpu/drm/radeon/evergreen.c
···7777void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev)7878{7979 u16 ctl, v;8080- int cap, err;8080+ int err;81818282- cap = pci_pcie_cap(rdev->pdev);8383- if (!cap)8484- return;8585-8686- err = pci_read_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, &ctl);8282+ err = pcie_capability_read_word(rdev->pdev, PCI_EXP_DEVCTL, &ctl);8783 if (err)8884 return;8985···9195 if ((v == 0) || (v == 6) || (v == 7)) {9296 ctl &= ~PCI_EXP_DEVCTL_READRQ;9397 ctl |= (2 << 12);9494- pci_write_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, ctl);9898+ pcie_capability_write_word(rdev->pdev, PCI_EXP_DEVCTL, ctl);9599 }96100}97101
···75277527 goto skip_bad_vf_detection;7528752875297529 bdev = pdev->bus->self;75307530- while (bdev && (bdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT))75307530+ while (bdev && (pci_pcie_type(bdev) != PCI_EXP_TYPE_ROOT_PORT))75317531 bdev = bdev->bus->self;7532753275337533 if (!bdev)
+4-4
drivers/net/ethernet/mellanox/mlx4/reset.c
···141141 /* Now restore the PCI headers */142142 if (pcie_cap) {143143 devctl = hca_header[(pcie_cap + PCI_EXP_DEVCTL) / 4];144144- if (pci_write_config_word(dev->pdev, pcie_cap + PCI_EXP_DEVCTL,145145- devctl)) {144144+ if (pcie_capability_write_word(dev->pdev, PCI_EXP_DEVCTL,145145+ devctl)) {146146 err = -ENODEV;147147 mlx4_err(dev, "Couldn't restore HCA PCI Express "148148 "Device Control register, aborting.\n");149149 goto out;150150 }151151 linkctl = hca_header[(pcie_cap + PCI_EXP_LNKCTL) / 4];152152- if (pci_write_config_word(dev->pdev, pcie_cap + PCI_EXP_LNKCTL,153153- linkctl)) {152152+ if (pcie_capability_write_word(dev->pdev, PCI_EXP_LNKCTL,153153+ linkctl)) {154154 err = -ENODEV;155155 mlx4_err(dev, "Couldn't restore HCA PCI Express "156156 "Link control register, aborting.\n");
+8-23
drivers/net/ethernet/myricom/myri10ge/myri10ge.c
···10781078#ifdef CONFIG_MYRI10GE_DCA10791079static int myri10ge_toggle_relaxed(struct pci_dev *pdev, int on)10801080{10811081- int ret, cap, err;10811081+ int ret;10821082 u16 ctl;1083108310841084- cap = pci_pcie_cap(pdev);10851085- if (!cap)10861086- return 0;10871087-10881088- err = pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &ctl);10891089- if (err)10901090- return 0;10841084+ pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &ctl);1091108510921086 ret = (ctl & PCI_EXP_DEVCTL_RELAX_EN) >> 4;10931087 if (ret != on) {10941088 ctl &= ~PCI_EXP_DEVCTL_RELAX_EN;10951089 ctl |= (on << 4);10961096- pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, ctl);10901090+ pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, ctl);10971091 }10981092 return ret;10991093}···31863192 struct device *dev = &mgp->pdev->dev;31873193 int cap;31883194 unsigned err_cap;31893189- u16 val;31903190- u8 ext_type;31913195 int ret;3192319631933197 if (!myri10ge_ecrc_enable || !bridge)31943198 return;3195319931963200 /* check that the bridge is a root port */31973197- cap = pci_pcie_cap(bridge);31983198- pci_read_config_word(bridge, cap + PCI_CAP_FLAGS, &val);31993199- ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4;32003200- if (ext_type != PCI_EXP_TYPE_ROOT_PORT) {32013201+ if (pci_pcie_type(bridge) != PCI_EXP_TYPE_ROOT_PORT) {32013202 if (myri10ge_ecrc_enable > 1) {32023203 struct pci_dev *prev_bridge, *old_bridge = bridge;32033204···32073218 " to force ECRC\n");32083219 return;32093220 }32103210- cap = pci_pcie_cap(bridge);32113211- pci_read_config_word(bridge,32123212- cap + PCI_CAP_FLAGS, &val);32133213- ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4;32143214- } while (ext_type != PCI_EXP_TYPE_ROOT_PORT);32213221+ } while (pci_pcie_type(bridge) !=32223222+ PCI_EXP_TYPE_ROOT_PORT);3215322332163224 dev_info(dev,32173225 "Forcing ECRC on non-root port %s"···33213335 int overridden = 0;3322333633233337 if (myri10ge_force_firmware == 0) {33243324- int link_width, exp_cap;33383338+ int link_width;33253339 u16 lnk;3326334033273327- exp_cap = pci_pcie_cap(mgp->pdev);33283328- pci_read_config_word(mgp->pdev, exp_cap + PCI_EXP_LNKSTA, &lnk);33413341+ pcie_capability_read_word(mgp->pdev, PCI_EXP_LNKSTA, &lnk);33293342 link_width = (lnk >> 4) & 0x3f;3330334333313344 /* Check to see if Link is less than 8 or if the
+2-2
drivers/net/ethernet/neterion/vxge/vxge-config.c
···757757 u16 lnk;758758759759 /* Get the negotiated link width and speed from PCI config space */760760- pci_read_config_word(dev, dev->pcie_cap + PCI_EXP_LNKSTA, &lnk);760760+ pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnk);761761762762 if ((lnk & PCI_EXP_LNKSTA_CLS) != 1)763763 return VXGE_HW_ERR_INVALID_PCI_INFO;···19821982 struct pci_dev *dev = hldev->pdev;19831983 u16 lnk;1984198419851985- pci_read_config_word(dev, dev->pcie_cap + PCI_EXP_LNKSTA, &lnk);19851985+ pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnk);19861986 return (lnk & VXGE_HW_PCI_EXP_LNKCAP_LNK_WIDTH) >> 4;19871987}19881988
···469469 raw_spin_unlock_irqrestore(&pci_lock, flags);470470}471471EXPORT_SYMBOL_GPL(pci_cfg_access_unlock);472472+473473+static inline int pcie_cap_version(const struct pci_dev *dev)474474+{475475+ return dev->pcie_flags_reg & PCI_EXP_FLAGS_VERS;476476+}477477+478478+static inline bool pcie_cap_has_devctl(const struct pci_dev *dev)479479+{480480+ return true;481481+}482482+483483+static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev)484484+{485485+ int type = pci_pcie_type(dev);486486+487487+ return pcie_cap_version(dev) > 1 ||488488+ type == PCI_EXP_TYPE_ROOT_PORT ||489489+ type == PCI_EXP_TYPE_ENDPOINT ||490490+ type == PCI_EXP_TYPE_LEG_END;491491+}492492+493493+static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev)494494+{495495+ int type = pci_pcie_type(dev);496496+497497+ return pcie_cap_version(dev) > 1 ||498498+ type == PCI_EXP_TYPE_ROOT_PORT ||499499+ (type == PCI_EXP_TYPE_DOWNSTREAM &&500500+ dev->pcie_flags_reg & PCI_EXP_FLAGS_SLOT);501501+}502502+503503+static inline bool pcie_cap_has_rtctl(const struct pci_dev *dev)504504+{505505+ int type = pci_pcie_type(dev);506506+507507+ return pcie_cap_version(dev) > 1 ||508508+ type == PCI_EXP_TYPE_ROOT_PORT ||509509+ type == PCI_EXP_TYPE_RC_EC;510510+}511511+512512+static bool pcie_capability_reg_implemented(struct pci_dev *dev, int pos)513513+{514514+ if (!pci_is_pcie(dev))515515+ return false;516516+517517+ switch (pos) {518518+ case PCI_EXP_FLAGS_TYPE:519519+ return true;520520+ case PCI_EXP_DEVCAP:521521+ case PCI_EXP_DEVCTL:522522+ case PCI_EXP_DEVSTA:523523+ return pcie_cap_has_devctl(dev);524524+ case PCI_EXP_LNKCAP:525525+ case PCI_EXP_LNKCTL:526526+ case PCI_EXP_LNKSTA:527527+ return pcie_cap_has_lnkctl(dev);528528+ case PCI_EXP_SLTCAP:529529+ case PCI_EXP_SLTCTL:530530+ case PCI_EXP_SLTSTA:531531+ return pcie_cap_has_sltctl(dev);532532+ case PCI_EXP_RTCTL:533533+ case PCI_EXP_RTCAP:534534+ case PCI_EXP_RTSTA:535535+ return pcie_cap_has_rtctl(dev);536536+ case PCI_EXP_DEVCAP2:537537+ case PCI_EXP_DEVCTL2:538538+ case PCI_EXP_LNKCAP2:539539+ case PCI_EXP_LNKCTL2:540540+ case PCI_EXP_LNKSTA2:541541+ return pcie_cap_version(dev) > 1;542542+ default:543543+ return false;544544+ }545545+}546546+547547+/*548548+ * Note that these accessor functions are only for the "PCI Express549549+ * Capability" (see PCIe spec r3.0, sec 7.8). They do not apply to the550550+ * other "PCI Express Extended Capabilities" (AER, VC, ACS, MFVC, etc.)551551+ */552552+int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val)553553+{554554+ int ret;555555+556556+ *val = 0;557557+ if (pos & 1)558558+ return -EINVAL;559559+560560+ if (pcie_capability_reg_implemented(dev, pos)) {561561+ ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val);562562+ /*563563+ * Reset *val to 0 if pci_read_config_word() fails, it may564564+ * have been written as 0xFFFF if hardware error happens565565+ * during pci_read_config_word().566566+ */567567+ if (ret)568568+ *val = 0;569569+ return ret;570570+ }571571+572572+ /*573573+ * For Functions that do not implement the Slot Capabilities,574574+ * Slot Status, and Slot Control registers, these spaces must575575+ * be hardwired to 0b, with the exception of the Presence Detect576576+ * State bit in the Slot Status register of Downstream Ports,577577+ * which must be hardwired to 1b. (PCIe Base Spec 3.0, sec 7.8)578578+ */579579+ if (pci_is_pcie(dev) && pos == PCI_EXP_SLTSTA &&580580+ pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) {581581+ *val = PCI_EXP_SLTSTA_PDS;582582+ }583583+584584+ return 0;585585+}586586+EXPORT_SYMBOL(pcie_capability_read_word);587587+588588+int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val)589589+{590590+ int ret;591591+592592+ *val = 0;593593+ if (pos & 3)594594+ return -EINVAL;595595+596596+ if (pcie_capability_reg_implemented(dev, pos)) {597597+ ret = pci_read_config_dword(dev, pci_pcie_cap(dev) + pos, val);598598+ /*599599+ * Reset *val to 0 if pci_read_config_dword() fails, it may600600+ * have been written as 0xFFFFFFFF if hardware error happens601601+ * during pci_read_config_dword().602602+ */603603+ if (ret)604604+ *val = 0;605605+ return ret;606606+ }607607+608608+ if (pci_is_pcie(dev) && pos == PCI_EXP_SLTCTL &&609609+ pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) {610610+ *val = PCI_EXP_SLTSTA_PDS;611611+ }612612+613613+ return 0;614614+}615615+EXPORT_SYMBOL(pcie_capability_read_dword);616616+617617+int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val)618618+{619619+ if (pos & 1)620620+ return -EINVAL;621621+622622+ if (!pcie_capability_reg_implemented(dev, pos))623623+ return 0;624624+625625+ return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val);626626+}627627+EXPORT_SYMBOL(pcie_capability_write_word);628628+629629+int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val)630630+{631631+ if (pos & 3)632632+ return -EINVAL;633633+634634+ if (!pcie_capability_reg_implemented(dev, pos))635635+ return 0;636636+637637+ return pci_write_config_dword(dev, pci_pcie_cap(dev) + pos, val);638638+}639639+EXPORT_SYMBOL(pcie_capability_write_dword);640640+641641+int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,642642+ u16 clear, u16 set)643643+{644644+ int ret;645645+ u16 val;646646+647647+ ret = pcie_capability_read_word(dev, pos, &val);648648+ if (!ret) {649649+ val &= ~clear;650650+ val |= set;651651+ ret = pcie_capability_write_word(dev, pos, val);652652+ }653653+654654+ return ret;655655+}656656+EXPORT_SYMBOL(pcie_capability_clear_and_set_word);657657+658658+int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,659659+ u32 clear, u32 set)660660+{661661+ int ret;662662+ u32 val;663663+664664+ ret = pcie_capability_read_dword(dev, pos, &val);665665+ if (!ret) {666666+ val &= ~clear;667667+ val |= set;668668+ ret = pcie_capability_write_dword(dev, pos, val);669669+ }670670+671671+ return ret;672672+}673673+EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
+1-5
drivers/pci/hotplug/pciehp_acpi.c
···8181/* Dummy driver for dumplicate name detection */8282static int __init dummy_probe(struct pcie_device *dev)8383{8484- int pos;8584 u32 slot_cap;8685 acpi_handle handle;8786 struct dummy_slot *slot, *tmp;8887 struct pci_dev *pdev = dev->port;89889090- pos = pci_pcie_cap(pdev);9191- if (!pos)9292- return -ENODEV;9393- pci_read_config_dword(pdev, pos + PCI_EXP_SLTCAP, &slot_cap);8989+ pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap);9490 slot = kzalloc(sizeof(*slot), GFP_KERNEL);9591 if (!slot)9692 return -ENOMEM;
···280280{281281 struct drv_dev_and_id *ddi = _ddi;282282 struct device *dev = &ddi->dev->dev;283283+ struct device *parent = dev->parent;283284 int rc;284285286286+ /* The parent bridge must be in active state when probing */287287+ if (parent)288288+ pm_runtime_get_sync(parent);285289 /* Unbound PCI devices are always set to disabled and suspended.286290 * During probe, the device is set to enabled and active and the287291 * usage count is incremented. If the driver supports runtime PM,···302298 pm_runtime_set_suspended(dev);303299 pm_runtime_put_noidle(dev);304300 }301301+ if (parent)302302+ pm_runtime_put(parent);305303 return rc;306304}307305
+42
drivers/pci/pci-sysfs.c
···458458}459459struct device_attribute vga_attr = __ATTR_RO(boot_vga);460460461461+static void462462+pci_config_pm_runtime_get(struct pci_dev *pdev)463463+{464464+ struct device *dev = &pdev->dev;465465+ struct device *parent = dev->parent;466466+467467+ if (parent)468468+ pm_runtime_get_sync(parent);469469+ pm_runtime_get_noresume(dev);470470+ /*471471+ * pdev->current_state is set to PCI_D3cold during suspending,472472+ * so wait until suspending completes473473+ */474474+ pm_runtime_barrier(dev);475475+ /*476476+ * Only need to resume devices in D3cold, because config477477+ * registers are still accessible for devices suspended but478478+ * not in D3cold.479479+ */480480+ if (pdev->current_state == PCI_D3cold)481481+ pm_runtime_resume(dev);482482+}483483+484484+static void485485+pci_config_pm_runtime_put(struct pci_dev *pdev)486486+{487487+ struct device *dev = &pdev->dev;488488+ struct device *parent = dev->parent;489489+490490+ pm_runtime_put(dev);491491+ if (parent)492492+ pm_runtime_put_sync(parent);493493+}494494+461495static ssize_t462496pci_read_config(struct file *filp, struct kobject *kobj,463497 struct bin_attribute *bin_attr,···517483 } else {518484 size = count;519485 }486486+487487+ pci_config_pm_runtime_get(dev);520488521489 if ((off & 1) && size) {522490 u8 val;···565529 --size;566530 }567531532532+ pci_config_pm_runtime_put(dev);533533+568534 return count;569535}570536···587549 count = size;588550 }589551552552+ pci_config_pm_runtime_get(dev);553553+590554 if ((off & 1) && size) {591555 pci_user_write_config_byte(dev, off, data[off - init_off]);592556 off++;···626586 off++;627587 --size;628588 }589589+590590+ pci_config_pm_runtime_put(dev);629591630592 return count;631593}
+64-253
drivers/pci/pci.c
···254254}255255256256/**257257- * pci_pcie_cap2 - query for devices' PCI_CAP_ID_EXP v2 capability structure258258- * @dev: PCI device to check259259- *260260- * Like pci_pcie_cap() but also checks that the PCIe capability version is261261- * >= 2. Note that v1 capability structures could be sparse in that not262262- * all register fields were required. v2 requires the entire structure to263263- * be present size wise, while still allowing for non-implemented registers264264- * to exist but they must be hardwired to 0.265265- *266266- * Due to the differences in the versions of capability structures, one267267- * must be careful not to try and access non-existant registers that may268268- * exist in early versions - v1 - of Express devices.269269- *270270- * Returns the offset of the PCIe capability structure as long as the271271- * capability version is >= 2; otherwise 0 is returned.272272- */273273-static int pci_pcie_cap2(struct pci_dev *dev)274274-{275275- u16 flags;276276- int pos;277277-278278- pos = pci_pcie_cap(dev);279279- if (pos) {280280- pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags);281281- if ((flags & PCI_EXP_FLAGS_VERS) < 2)282282- pos = 0;283283- }284284-285285- return pos;286286-}287287-288288-/**289257 * pci_find_ext_capability - Find an extended capability290258 * @dev: PCI device to query291259 * @cap: capability code···822854823855#define PCI_EXP_SAVE_REGS 7824856825825-#define pcie_cap_has_devctl(type, flags) 1826826-#define pcie_cap_has_lnkctl(type, flags) \827827- ((flags & PCI_EXP_FLAGS_VERS) > 1 || \828828- (type == PCI_EXP_TYPE_ROOT_PORT || \829829- type == PCI_EXP_TYPE_ENDPOINT || \830830- type == PCI_EXP_TYPE_LEG_END))831831-#define pcie_cap_has_sltctl(type, flags) \832832- ((flags & PCI_EXP_FLAGS_VERS) > 1 || \833833- ((type == PCI_EXP_TYPE_ROOT_PORT) || \834834- (type == PCI_EXP_TYPE_DOWNSTREAM && \835835- (flags & PCI_EXP_FLAGS_SLOT))))836836-#define pcie_cap_has_rtctl(type, flags) \837837- ((flags & PCI_EXP_FLAGS_VERS) > 1 || \838838- (type == PCI_EXP_TYPE_ROOT_PORT || \839839- type == PCI_EXP_TYPE_RC_EC))840857841858static struct pci_cap_saved_state *pci_find_saved_cap(842859 struct pci_dev *pci_dev, char cap)···838885839886static int pci_save_pcie_state(struct pci_dev *dev)840887{841841- int pos, i = 0;888888+ int i = 0;842889 struct pci_cap_saved_state *save_state;843890 u16 *cap;844844- u16 flags;845891846846- pos = pci_pcie_cap(dev);847847- if (!pos)892892+ if (!pci_is_pcie(dev))848893 return 0;849894850895 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP);···850899 dev_err(&dev->dev, "buffer not found in %s\n", __func__);851900 return -ENOMEM;852901 }902902+853903 cap = (u16 *)&save_state->cap.data[0];904904+ pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &cap[i++]);905905+ pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &cap[i++]);906906+ pcie_capability_read_word(dev, PCI_EXP_SLTCTL, &cap[i++]);907907+ pcie_capability_read_word(dev, PCI_EXP_RTCTL, &cap[i++]);908908+ pcie_capability_read_word(dev, PCI_EXP_DEVCTL2, &cap[i++]);909909+ pcie_capability_read_word(dev, PCI_EXP_LNKCTL2, &cap[i++]);910910+ pcie_capability_read_word(dev, PCI_EXP_SLTCTL2, &cap[i++]);854911855855- pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags);856856-857857- if (pcie_cap_has_devctl(dev->pcie_type, flags))858858- pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &cap[i++]);859859- if (pcie_cap_has_lnkctl(dev->pcie_type, flags))860860- pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]);861861- if (pcie_cap_has_sltctl(dev->pcie_type, flags))862862- pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]);863863- if (pcie_cap_has_rtctl(dev->pcie_type, flags))864864- pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]);865865-866866- pos = pci_pcie_cap2(dev);867867- if (!pos)868868- return 0;869869-870870- pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &cap[i++]);871871- pci_read_config_word(dev, pos + PCI_EXP_LNKCTL2, &cap[i++]);872872- pci_read_config_word(dev, pos + PCI_EXP_SLTCTL2, &cap[i++]);873912 return 0;874913}875914876915static void pci_restore_pcie_state(struct pci_dev *dev)877916{878878- int i = 0, pos;917917+ int i = 0;879918 struct pci_cap_saved_state *save_state;880919 u16 *cap;881881- u16 flags;882920883921 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP);884884- pos = pci_find_capability(dev, PCI_CAP_ID_EXP);885885- if (!save_state || pos <= 0)922922+ if (!save_state)886923 return;924924+887925 cap = (u16 *)&save_state->cap.data[0];888888-889889- pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags);890890-891891- if (pcie_cap_has_devctl(dev->pcie_type, flags))892892- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, cap[i++]);893893- if (pcie_cap_has_lnkctl(dev->pcie_type, flags))894894- pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]);895895- if (pcie_cap_has_sltctl(dev->pcie_type, flags))896896- pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]);897897- if (pcie_cap_has_rtctl(dev->pcie_type, flags))898898- pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]);899899-900900- pos = pci_pcie_cap2(dev);901901- if (!pos)902902- return;903903-904904- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, cap[i++]);905905- pci_write_config_word(dev, pos + PCI_EXP_LNKCTL2, cap[i++]);906906- pci_write_config_word(dev, pos + PCI_EXP_SLTCTL2, cap[i++]);926926+ pcie_capability_write_word(dev, PCI_EXP_DEVCTL, cap[i++]);927927+ pcie_capability_write_word(dev, PCI_EXP_LNKCTL, cap[i++]);928928+ pcie_capability_write_word(dev, PCI_EXP_SLTCTL, cap[i++]);929929+ pcie_capability_write_word(dev, PCI_EXP_RTCTL, cap[i++]);930930+ pcie_capability_write_word(dev, PCI_EXP_DEVCTL2, cap[i++]);931931+ pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, cap[i++]);932932+ pcie_capability_write_word(dev, PCI_EXP_SLTCTL2, cap[i++]);907933}908934909935···18691941 dev->pm_cap = pm;18701942 dev->d3_delay = PCI_PM_D3_WAIT;18711943 dev->d3cold_delay = PCI_PM_D3COLD_WAIT;19441944+ dev->d3cold_allowed = true;1872194518731946 dev->d1_support = false;18741947 dev->d2_support = false;···19952066 */19962067void pci_enable_ari(struct pci_dev *dev)19972068{19981998- int pos;19992069 u32 cap;20002000- u16 ctrl;20012070 struct pci_dev *bridge;2002207120032072 if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn)20042073 return;2005207420062006- pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI);20072007- if (!pos)20752075+ if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI))20082076 return;2009207720102078 bridge = dev->bus->self;20112079 if (!bridge)20122080 return;2013208120142014- /* ARI is a PCIe cap v2 feature */20152015- pos = pci_pcie_cap2(bridge);20162016- if (!pos)20172017- return;20182018-20192019- pci_read_config_dword(bridge, pos + PCI_EXP_DEVCAP2, &cap);20822082+ pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap);20202083 if (!(cap & PCI_EXP_DEVCAP2_ARI))20212084 return;2022208520232023- pci_read_config_word(bridge, pos + PCI_EXP_DEVCTL2, &ctrl);20242024- ctrl |= PCI_EXP_DEVCTL2_ARI;20252025- pci_write_config_word(bridge, pos + PCI_EXP_DEVCTL2, ctrl);20262026-20862086+ pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_ARI);20272087 bridge->ari_enabled = 1;20282088}20292089···20272109 */20282110void pci_enable_ido(struct pci_dev *dev, unsigned long type)20292111{20302030- int pos;20312031- u16 ctrl;21122112+ u16 ctrl = 0;2032211320332033- /* ID-based Ordering is a PCIe cap v2 feature */20342034- pos = pci_pcie_cap2(dev);20352035- if (!pos)20362036- return;20372037-20382038- pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl);20392114 if (type & PCI_EXP_IDO_REQUEST)20402115 ctrl |= PCI_EXP_IDO_REQ_EN;20412116 if (type & PCI_EXP_IDO_COMPLETION)20422117 ctrl |= PCI_EXP_IDO_CMP_EN;20432043- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl);21182118+ if (ctrl)21192119+ pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, ctrl);20442120}20452121EXPORT_SYMBOL(pci_enable_ido);20462122···20452133 */20462134void pci_disable_ido(struct pci_dev *dev, unsigned long type)20472135{20482048- int pos;20492049- u16 ctrl;21362136+ u16 ctrl = 0;2050213720512051- /* ID-based Ordering is a PCIe cap v2 feature */20522052- pos = pci_pcie_cap2(dev);20532053- if (!pos)20542054- return;20552055-20562056- pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl);20572138 if (type & PCI_EXP_IDO_REQUEST)20582058- ctrl &= ~PCI_EXP_IDO_REQ_EN;21392139+ ctrl |= PCI_EXP_IDO_REQ_EN;20592140 if (type & PCI_EXP_IDO_COMPLETION)20602060- ctrl &= ~PCI_EXP_IDO_CMP_EN;20612061- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl);21412141+ ctrl |= PCI_EXP_IDO_CMP_EN;21422142+ if (ctrl)21432143+ pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2, ctrl);20622144}20632145EXPORT_SYMBOL(pci_disable_ido);20642146···20772171 */20782172int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type type)20792173{20802080- int pos;20812174 u32 cap;20822175 u16 ctrl;20832176 int ret;2084217720852085- /* OBFF is a PCIe cap v2 feature */20862086- pos = pci_pcie_cap2(dev);20872087- if (!pos)20882088- return -ENOTSUPP;20892089-20902090- pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP2, &cap);21782178+ pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap);20912179 if (!(cap & PCI_EXP_OBFF_MASK))20922180 return -ENOTSUPP; /* no OBFF support at all */20932181···20922192 return ret;20932193 }2094219420952095- pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl);21952195+ pcie_capability_read_word(dev, PCI_EXP_DEVCTL2, &ctrl);20962196 if (cap & PCI_EXP_OBFF_WAKE)20972197 ctrl |= PCI_EXP_OBFF_WAKE_EN;20982198 else {···21102210 return -ENOTSUPP;21112211 }21122212 }21132113- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl);22132213+ pcie_capability_write_word(dev, PCI_EXP_DEVCTL2, ctrl);2114221421152215 return 0;21162216}···21242224 */21252225void pci_disable_obff(struct pci_dev *dev)21262226{21272127- int pos;21282128- u16 ctrl;21292129-21302130- /* OBFF is a PCIe cap v2 feature */21312131- pos = pci_pcie_cap2(dev);21322132- if (!pos)21332133- return;21342134-21352135- pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl);21362136- ctrl &= ~PCI_EXP_OBFF_WAKE_EN;21372137- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl);22272227+ pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2, PCI_EXP_OBFF_WAKE_EN);21382228}21392229EXPORT_SYMBOL(pci_disable_obff);21402230···21372247 */21382248static bool pci_ltr_supported(struct pci_dev *dev)21392249{21402140- int pos;21412250 u32 cap;2142225121432143- /* LTR is a PCIe cap v2 feature */21442144- pos = pci_pcie_cap2(dev);21452145- if (!pos)21462146- return false;21472147-21482148- pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP2, &cap);22522252+ pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap);2149225321502254 return cap & PCI_EXP_DEVCAP2_LTR;21512255}···21562272 */21572273int pci_enable_ltr(struct pci_dev *dev)21582274{21592159- int pos;21602160- u16 ctrl;21612275 int ret;21622162-21632163- if (!pci_ltr_supported(dev))21642164- return -ENOTSUPP;21652165-21662166- /* LTR is a PCIe cap v2 feature */21672167- pos = pci_pcie_cap2(dev);21682168- if (!pos)21692169- return -ENOTSUPP;2170227621712277 /* Only primary function can enable/disable LTR */21722278 if (PCI_FUNC(dev->devfn) != 0)21732279 return -EINVAL;22802280+22812281+ if (!pci_ltr_supported(dev))22822282+ return -ENOTSUPP;2174228321752284 /* Enable upstream ports first */21762285 if (dev->bus->self) {···21722295 return ret;21732296 }2174229721752175- pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl);21762176- ctrl |= PCI_EXP_LTR_EN;21772177- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl);21782178-21792179- return 0;22982298+ return pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, PCI_EXP_LTR_EN);21802299}21812300EXPORT_SYMBOL(pci_enable_ltr);21822301···21822309 */21832310void pci_disable_ltr(struct pci_dev *dev)21842311{21852185- int pos;21862186- u16 ctrl;21872187-21882188- if (!pci_ltr_supported(dev))21892189- return;21902190-21912191- /* LTR is a PCIe cap v2 feature */21922192- pos = pci_pcie_cap2(dev);21932193- if (!pos)21942194- return;21952195-21962312 /* Only primary function can enable/disable LTR */21972313 if (PCI_FUNC(dev->devfn) != 0)21982314 return;2199231522002200- pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl);22012201- ctrl &= ~PCI_EXP_LTR_EN;22022202- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl);23162316+ if (!pci_ltr_supported(dev))23172317+ return;23182318+23192319+ pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2, PCI_EXP_LTR_EN);22032320}22042321EXPORT_SYMBOL(pci_disable_ltr);22052322···22722409 if (!pci_acs_enable)22732410 return;2274241122752275- if (!pci_is_pcie(dev))22762276- return;22772277-22782412 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);22792413 if (!pos)22802414 return;···23192459 acs_flags &= (PCI_ACS_RR | PCI_ACS_CR |23202460 PCI_ACS_EC | PCI_ACS_DT);2321246123222322- if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM ||23232323- pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT ||24622462+ if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM ||24632463+ pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT ||23242464 pdev->multifunction) {23252465 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);23262466 if (!pos)···30363176static int pcie_flr(struct pci_dev *dev, int probe)30373177{30383178 int i;30393039- int pos;30403179 u32 cap;30413041- u16 status, control;31803180+ u16 status;3042318130433043- pos = pci_pcie_cap(dev);30443044- if (!pos)30453045- return -ENOTTY;30463046-30473047- pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP, &cap);31823182+ pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap);30483183 if (!(cap & PCI_EXP_DEVCAP_FLR))30493184 return -ENOTTY;30503185···30513196 if (i)30523197 msleep((1 << (i - 1)) * 100);3053319830543054- pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &status);31993199+ pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status);30553200 if (!(status & PCI_EXP_DEVSTA_TRPND))30563201 goto clear;30573202 }···30603205 "proceeding with reset anyway\n");3061320630623207clear:30633063- pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &control);30643064- control |= PCI_EXP_DEVCTL_BCR_FLR;30653065- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, control);32083208+ pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);3066320930673210 msleep(100);30683211···34283575 */34293576int pcie_get_readrq(struct pci_dev *dev)34303577{34313431- int ret, cap;34323578 u16 ctl;3433357934343434- cap = pci_pcie_cap(dev);34353435- if (!cap)34363436- return -EINVAL;35803580+ pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &ctl);3437358134383438- ret = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl);34393439- if (!ret)34403440- ret = 128 << ((ctl & PCI_EXP_DEVCTL_READRQ) >> 12);34413441-34423442- return ret;35823582+ return 128 << ((ctl & PCI_EXP_DEVCTL_READRQ) >> 12);34433583}34443584EXPORT_SYMBOL(pcie_get_readrq);34453585···34463600 */34473601int pcie_set_readrq(struct pci_dev *dev, int rq)34483602{34493449- int cap, err = -EINVAL;34503450- u16 ctl, v;36033603+ u16 v;3451360434523605 if (rq < 128 || rq > 4096 || !is_power_of_2(rq))34533453- goto out;36063606+ return -EINVAL;3454360734553455- cap = pci_pcie_cap(dev);34563456- if (!cap)34573457- goto out;34583458-34593459- err = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl);34603460- if (err)34613461- goto out;34623608 /*34633609 * If using the "performance" PCIe config, we clamp the34643610 * read rq size to the max packet size to prevent the···3468363034693631 v = (ffs(rq) - 8) << 12;3470363234713471- if ((ctl & PCI_EXP_DEVCTL_READRQ) != v) {34723472- ctl &= ~PCI_EXP_DEVCTL_READRQ;34733473- ctl |= v;34743474- err = pci_write_config_word(dev, cap + PCI_EXP_DEVCTL, ctl);34753475- }34763476-34773477-out:34783478- return err;36333633+ return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,36343634+ PCI_EXP_DEVCTL_READRQ, v);34793635}34803636EXPORT_SYMBOL(pcie_set_readrq);34813637···34823650 */34833651int pcie_get_mps(struct pci_dev *dev)34843652{34853485- int ret, cap;34863653 u16 ctl;3487365434883488- cap = pci_pcie_cap(dev);34893489- if (!cap)34903490- return -EINVAL;36553655+ pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &ctl);3491365634923492- ret = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl);34933493- if (!ret)34943494- ret = 128 << ((ctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);34953495-34963496- return ret;36573657+ return 128 << ((ctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);34973658}3498365934993660/**···34993674 */35003675int pcie_set_mps(struct pci_dev *dev, int mps)35013676{35023502- int cap, err = -EINVAL;35033503- u16 ctl, v;36773677+ u16 v;3504367835053679 if (mps < 128 || mps > 4096 || !is_power_of_2(mps))35063506- goto out;36803680+ return -EINVAL;3507368135083682 v = ffs(mps) - 8;35093683 if (v > dev->pcie_mpss) 35103510- goto out;36843684+ return -EINVAL;35113685 v <<= 5;3512368635133513- cap = pci_pcie_cap(dev);35143514- if (!cap)35153515- goto out;35163516-35173517- err = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl);35183518- if (err)35193519- goto out;35203520-35213521- if ((ctl & PCI_EXP_DEVCTL_PAYLOAD) != v) {35223522- ctl &= ~PCI_EXP_DEVCTL_PAYLOAD;35233523- ctl |= v;35243524- err = pci_write_config_word(dev, cap + PCI_EXP_DEVCTL, ctl);35253525- }35263526-out:35273527- return err;36873687+ return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,36883688+ PCI_EXP_DEVCTL_PAYLOAD, v);35283689}3529369035303691/**
+1-1
drivers/pci/pcie/aer/aer_inject.c
···288288 while (1) {289289 if (!pci_is_pcie(dev))290290 break;291291- if (dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT)291291+ if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)292292 return dev;293293 if (!dev->bus->self)294294 break;
···246246 */247247static int get_port_device_capability(struct pci_dev *dev)248248{249249- int services = 0, pos;250250- u16 reg16;249249+ int services = 0;251250 u32 reg32;252251 int cap_mask = 0;253252 int err;···264265 return 0;265266 }266267267267- pos = pci_pcie_cap(dev);268268- pci_read_config_word(dev, pos + PCI_EXP_FLAGS, ®16);269268 /* Hot-Plug Capable */270270- if ((cap_mask & PCIE_PORT_SERVICE_HP) && (reg16 & PCI_EXP_FLAGS_SLOT)) {271271- pci_read_config_dword(dev, pos + PCI_EXP_SLTCAP, ®32);269269+ if (cap_mask & PCIE_PORT_SERVICE_HP) {270270+ pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, ®32);272271 if (reg32 & PCI_EXP_SLTCAP_HPC) {273272 services |= PCIE_PORT_SERVICE_HP;274273 /*···274277 * enabled by the BIOS and the hot-plug service driver275278 * is not loaded.276279 */277277- pos += PCI_EXP_SLTCTL;278278- pci_read_config_word(dev, pos, ®16);279279- reg16 &= ~(PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE);280280- pci_write_config_word(dev, pos, reg16);280280+ pcie_capability_clear_word(dev, PCI_EXP_SLTCTL,281281+ PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE);281282 }282283 }283284 /* AER capable */···293298 services |= PCIE_PORT_SERVICE_VC;294299 /* Root ports are capable of generating PME too */295300 if ((cap_mask & PCIE_PORT_SERVICE_PME)296296- && dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) {301301+ && pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) {297302 services |= PCIE_PORT_SERVICE_PME;298303 /*299304 * Disable PME interrupt on this port in case it's been enabled···331336 device->release = release_pcie_device; /* callback to free pcie dev */332337 dev_set_name(device, "%s:pcie%02x",333338 pci_name(pdev),334334- get_descriptor_id(pdev->pcie_type, service));339339+ get_descriptor_id(pci_pcie_type(pdev), service));335340 device->parent = &pdev->dev;336341 device_enable_async_suspend(device);337342
+19-12
drivers/pci/pcie/portdrv_pci.c
···6464 */6565void pcie_clear_root_pme_status(struct pci_dev *dev)6666{6767- int rtsta_pos;6868- u32 rtsta;6969-7070- rtsta_pos = pci_pcie_cap(dev) + PCI_EXP_RTSTA;7171-7272- pci_read_config_dword(dev, rtsta_pos, &rtsta);7373- rtsta |= PCI_EXP_RTSTA_PME;7474- pci_write_config_dword(dev, rtsta_pos, rtsta);6767+ pcie_capability_set_dword(dev, PCI_EXP_RTSTA, PCI_EXP_RTSTA_PME);7568}76697770static int pcie_portdrv_restore_config(struct pci_dev *dev)···8895 * which breaks ACPI-based runtime wakeup on PCI Express, so clear those8996 * bits now just in case (shouldn't hurt).9097 */9191- if(pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT)9898+ if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT)9299 pcie_clear_root_pme_status(pdev);93100 return 0;94101}···133140{134141 return 0;135142}143143+144144+static int pcie_port_runtime_idle(struct device *dev)145145+{146146+ /* Delay for a short while to prevent too frequent suspend/resume */147147+ pm_schedule_suspend(dev, 10);148148+ return -EBUSY;149149+}136150#else137151#define pcie_port_runtime_suspend NULL138152#define pcie_port_runtime_resume NULL153153+#define pcie_port_runtime_idle NULL139154#endif140155141156static const struct dev_pm_ops pcie_portdrv_pm_ops = {···156155 .resume_noirq = pcie_port_resume_noirq,157156 .runtime_suspend = pcie_port_runtime_suspend,158157 .runtime_resume = pcie_port_runtime_resume,158158+ .runtime_idle = pcie_port_runtime_idle,159159};160160161161#define PCIE_PORTDRV_PM_OPS (&pcie_portdrv_pm_ops)···188186 int status;189187190188 if (!pci_is_pcie(dev) ||191191- ((dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&192192- (dev->pcie_type != PCI_EXP_TYPE_UPSTREAM) &&193193- (dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)))189189+ ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) &&190190+ (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) &&191191+ (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM)))194192 return -ENODEV;195193196194 if (!dev->irq && dev->pin) {···202200 return status;203201204202 pci_save_state(dev);203203+ /*204204+ * D3cold may not work properly on some PCIe port, so disable205205+ * it by default.206206+ */207207+ dev->d3cold_allowed = false;205208 if (!pci_match_id(port_runtime_pm_black_list, dev))206209 pm_runtime_put_noidle(&dev->dev);207210
+27-32
drivers/pci/probe.c
···144144 case PCI_BASE_ADDRESS_MEM_TYPE_32:145145 break;146146 case PCI_BASE_ADDRESS_MEM_TYPE_1M:147147- dev_info(&dev->dev, "1M mem BAR treated as 32-bit BAR\n");147147+ /* 1M mem BAR treated as 32-bit BAR */148148 break;149149 case PCI_BASE_ADDRESS_MEM_TYPE_64:150150 flags |= IORESOURCE_MEM_64;151151 break;152152 default:153153- dev_warn(&dev->dev,154154- "mem unknown type %x treated as 32-bit BAR\n",155155- mem_type);153153+ /* mem unknown type treated as 32-bit BAR */156154 break;157155 }158156 return flags;···171173 u32 l, sz, mask;172174 u16 orig_cmd;173175 struct pci_bus_region region;176176+ bool bar_too_big = false, bar_disabled = false;174177175178 mask = type ? PCI_ROM_ADDRESS_MASK : ~0;176179180180+ /* No printks while decoding is disabled! */177181 if (!dev->mmio_always_on) {178182 pci_read_config_word(dev, PCI_COMMAND, &orig_cmd);179183 pci_write_config_word(dev, PCI_COMMAND,···240240 goto fail;241241242242 if ((sizeof(resource_size_t) < 8) && (sz64 > 0x100000000ULL)) {243243- dev_err(&dev->dev, "reg %x: can't handle 64-bit BAR\n",244244- pos);243243+ bar_too_big = true;245244 goto fail;246245 }247246···251252 region.start = 0;252253 region.end = sz64;253254 pcibios_bus_to_resource(dev, res, ®ion);255255+ bar_disabled = true;254256 } else {255257 region.start = l64;256258 region.end = l64 + sz64;257259 pcibios_bus_to_resource(dev, res, ®ion);258258- dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n",259259- pos, res);260260 }261261 } else {262262 sz = pci_size(l, sz, mask);···266268 region.start = l;267269 region.end = l + sz;268270 pcibios_bus_to_resource(dev, res, ®ion);269269-270270- dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res);271271 }272272273273- out:273273+ goto out;274274+275275+276276+fail:277277+ res->flags = 0;278278+out:274279 if (!dev->mmio_always_on)275280 pci_write_config_word(dev, PCI_COMMAND, orig_cmd);276281282282+ if (bar_too_big)283283+ dev_err(&dev->dev, "reg %x: can't handle 64-bit BAR\n", pos);284284+ if (res->flags && !bar_disabled)285285+ dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res);286286+277287 return (res->flags & IORESOURCE_MEM_64) ? 1 : 0;278278- fail:279279- res->flags = 0;280280- goto out;281288}282289283290static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)···606603 u32 linkcap;607604 u16 linksta;608605609609- pci_read_config_dword(bridge, pos + PCI_EXP_LNKCAP, &linkcap);606606+ pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap);610607 bus->max_bus_speed = pcie_link_speed[linkcap & 0xf];611608612612- pci_read_config_word(bridge, pos + PCI_EXP_LNKSTA, &linksta);609609+ pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta);613610 pcie_update_link_speed(bus, linksta);614611 }615612}···932929 pdev->is_pcie = 1;933930 pdev->pcie_cap = pos;934931 pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, ®16);935935- pdev->pcie_type = (reg16 & PCI_EXP_FLAGS_TYPE) >> 4;932932+ pdev->pcie_flags_reg = reg16;936933 pci_read_config_word(pdev, pos + PCI_EXP_DEVCAP, ®16);937934 pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD;938935}939936940937void set_pcie_hotplug_bridge(struct pci_dev *pdev)941938{942942- int pos;943943- u16 reg16;944939 u32 reg32;945940946946- pos = pci_pcie_cap(pdev);947947- if (!pos)948948- return;949949- pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, ®16);950950- if (!(reg16 & PCI_EXP_FLAGS_SLOT))951951- return;952952- pci_read_config_dword(pdev, pos + PCI_EXP_SLTCAP, ®32);941941+ pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, ®32);953942 if (reg32 & PCI_EXP_SLTCAP_HPC)954943 pdev->is_hotplug_bridge = 1;955944}···11551160 if (class == PCI_CLASS_BRIDGE_HOST)11561161 return pci_cfg_space_size_ext(dev);1157116211581158- pos = pci_pcie_cap(dev);11591159- if (!pos) {11631163+ if (!pci_is_pcie(dev)) {11601164 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);11611165 if (!pos)11621166 goto fail;···1377138313781384 if (!parent || !pci_is_pcie(parent))13791385 return 0;13801380- if (parent->pcie_type == PCI_EXP_TYPE_ROOT_PORT)13861386+ if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT)13811387 return 1;13821382- if (parent->pcie_type == PCI_EXP_TYPE_DOWNSTREAM &&13881388+ if (pci_pcie_type(parent) == PCI_EXP_TYPE_DOWNSTREAM &&13831389 !pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS))13841390 return 1;13851391 return 0;···14561462 */14571463 if (dev->is_hotplug_bridge && (!list_is_singular(&dev->bus->devices) ||14581464 (dev->bus->self &&14591459- dev->bus->self->pcie_type != PCI_EXP_TYPE_ROOT_PORT)))14651465+ pci_pcie_type(dev->bus->self) != PCI_EXP_TYPE_ROOT_PORT)))14601466 *smpss = 0;1461146714621468 if (*smpss > dev->pcie_mpss)···14721478 if (pcie_bus_config == PCIE_BUS_PERFORMANCE) {14731479 mps = 128 << dev->pcie_mpss;1474148014751475- if (dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && dev->bus->self)14811481+ if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT &&14821482+ dev->bus->self)14761483 /* For "Performance", the assumption is made that14771484 * downstream communication will never be larger than14781485 * the MRRS. So, the MPS only needs to be configured
+25-6
drivers/pci/quirks.c
···3081308130823082static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe)30833083{30843084- int pos;30843084+ int i;30853085+ u16 status;3085308630863086- pos = pci_find_capability(dev, PCI_CAP_ID_EXP);30873087- if (!pos)30883088- return -ENOTTY;30873087+ /*30883088+ * http://www.intel.com/content/dam/doc/datasheet/82599-10-gbe-controller-datasheet.pdf30893089+ *30903090+ * The 82599 supports FLR on VFs, but FLR support is reported only30913091+ * in the PF DEVCAP (sec 9.3.10.4), not in the VF DEVCAP (sec 9.5).30923092+ * Therefore, we can't use pcie_flr(), which checks the VF DEVCAP.30933093+ */3089309430903095 if (probe)30913096 return 0;3092309730933093- pci_write_config_word(dev, pos + PCI_EXP_DEVCTL,30943094- PCI_EXP_DEVCTL_BCR_FLR);30983098+ /* Wait for Transaction Pending bit clean */30993099+ for (i = 0; i < 4; i++) {31003100+ if (i)31013101+ msleep((1 << (i - 1)) * 100);31023102+31033103+ pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status);31043104+ if (!(status & PCI_EXP_DEVSTA_TRPND))31053105+ goto clear;31063106+ }31073107+31083108+ dev_err(&dev->dev, "transaction is not cleared; "31093109+ "proceeding with reset anyway\n");31103110+31113111+clear:31123112+ pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);31133113+30953114 msleep(100);3096311530973116 return 0;
+1-1
drivers/pci/search.c
···4141 continue;4242 }4343 /* PCI device should connect to a PCIe bridge */4444- if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) {4444+ if (pci_pcie_type(pdev) != PCI_EXP_TYPE_PCI_BRIDGE) {4545 /* Busted hardware? */4646 WARN_ON_ONCE(1);4747 return NULL;
+60-21
drivers/pci/setup-bus.c
···697697 return size;698698}699699700700+resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus,701701+ unsigned long type)702702+{703703+ return 1;704704+}705705+706706+#define PCI_P2P_DEFAULT_MEM_ALIGN 0x100000 /* 1MiB */707707+#define PCI_P2P_DEFAULT_IO_ALIGN 0x1000 /* 4KiB */708708+#define PCI_P2P_DEFAULT_IO_ALIGN_1K 0x400 /* 1KiB */709709+710710+static resource_size_t window_alignment(struct pci_bus *bus,711711+ unsigned long type)712712+{713713+ resource_size_t align = 1, arch_align;714714+715715+ if (type & IORESOURCE_MEM)716716+ align = PCI_P2P_DEFAULT_MEM_ALIGN;717717+ else if (type & IORESOURCE_IO) {718718+ /*719719+ * Per spec, I/O windows are 4K-aligned, but some720720+ * bridges have an extension to support 1K alignment.721721+ */722722+ if (bus->self->io_window_1k)723723+ align = PCI_P2P_DEFAULT_IO_ALIGN_1K;724724+ else725725+ align = PCI_P2P_DEFAULT_IO_ALIGN;726726+ }727727+728728+ arch_align = pcibios_window_alignment(bus, type);729729+ return max(align, arch_align);730730+}731731+700732/**701733 * pbus_size_io() - size the io window of a given bus702734 *···749717 struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);750718 unsigned long size = 0, size0 = 0, size1 = 0;751719 resource_size_t children_add_size = 0;752752- resource_size_t min_align = 4096, align;720720+ resource_size_t min_align, io_align, align;753721754722 if (!b_res)755723 return;756724757757- /*758758- * Per spec, I/O windows are 4K-aligned, but some bridges have an759759- * extension to support 1K alignment.760760- */761761- if (bus->self->io_window_1k)762762- min_align = 1024;725725+ io_align = min_align = window_alignment(bus, IORESOURCE_IO);763726 list_for_each_entry(dev, &bus->devices, bus_list) {764727 int i;765728···781754 }782755 }783756784784- if (min_align > 4096)785785- min_align = 4096;757757+ if (min_align > io_align)758758+ min_align = io_align;786759787760 size0 = calculate_iosize(size, min_size, size1,788761 resource_size(b_res), min_align);···810783 "%pR to %pR add_size %lx\n", b_res,811784 &bus->busn_res, size1-size0);812785 }786786+}787787+788788+static inline resource_size_t calculate_mem_align(resource_size_t *aligns,789789+ int max_order)790790+{791791+ resource_size_t align = 0;792792+ resource_size_t min_align = 0;793793+ int order;794794+795795+ for (order = 0; order <= max_order; order++) {796796+ resource_size_t align1 = 1;797797+798798+ align1 <<= (order + 20);799799+800800+ if (!align)801801+ min_align = align1;802802+ else if (ALIGN(align + min_align, min_align) < align1)803803+ min_align = align1 >> 1;804804+ align += aligns[order];805805+ }806806+807807+ return min_align;813808}814809815810/**···913864 children_add_size += get_res_add_size(realloc_head, r);914865 }915866 }916916- align = 0;917917- min_align = 0;918918- for (order = 0; order <= max_order; order++) {919919- resource_size_t align1 = 1;920867921921- align1 <<= (order + 20);922922-923923- if (!align)924924- min_align = align1;925925- else if (ALIGN(align + min_align, min_align) < align1)926926- min_align = align1 >> 1;927927- align += aligns[order];928928- }868868+ min_align = calculate_mem_align(aligns, max_order);869869+ min_align = max(min_align, window_alignment(bus, b_res->flags & mask));929870 size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align);930871 if (children_add_size > add_size)931872 add_size = children_add_size;
+6-12
drivers/rapidio/devices/tsi721.c
···22192219 const struct pci_device_id *id)22202220{22212221 struct tsi721_device *priv;22222222- int cap;22232222 int err;22242224- u32 regval;2225222322262224 priv = kzalloc(sizeof(struct tsi721_device), GFP_KERNEL);22272225 if (priv == NULL) {···23282330 dev_info(&pdev->dev, "Unable to set consistent DMA mask\n");23292331 }2330233223312331- cap = pci_pcie_cap(pdev);23322332- BUG_ON(cap == 0);23332333+ BUG_ON(!pci_is_pcie(pdev));2333233423342335 /* Clear "no snoop" and "relaxed ordering" bits, use default MRRS. */23352335- pci_read_config_dword(pdev, cap + PCI_EXP_DEVCTL, ®val);23362336- regval &= ~(PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_RELAX_EN |23372337- PCI_EXP_DEVCTL_NOSNOOP_EN);23382338- regval |= 0x2 << MAX_READ_REQUEST_SZ_SHIFT;23392339- pci_write_config_dword(pdev, cap + PCI_EXP_DEVCTL, regval);23362336+ pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL,23372337+ PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_RELAX_EN |23382338+ PCI_EXP_DEVCTL_NOSNOOP_EN,23392339+ 0x2 << MAX_READ_REQUEST_SZ_SHIFT);2340234023412341 /* Adjust PCIe completion timeout. */23422342- pci_read_config_dword(pdev, cap + PCI_EXP_DEVCTL2, ®val);23432343- regval &= ~(0x0f);23442344- pci_write_config_dword(pdev, cap + PCI_EXP_DEVCTL2, regval | 0x2);23422342+ pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL2, 0xf, 0x2);2345234323462344 /*23472345 * FIXUP: correct offsets of MSI-X tables in the MSI-X Capability Block
+15-7
drivers/rtc/rtc-at91sam9.c
···5858 struct rtc_device *rtcdev;5959 u32 imr;6060 void __iomem *gpbr;6161+ int irq;6162};62636364#define rtt_readl(rtc, field) \···293292{294293 struct resource *r, *r_gpbr;295294 struct sam9_rtc *rtc;296296- int ret;295295+ int ret, irq;297296 u32 mr;298297299298 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);···303302 return -ENODEV;304303 }305304305305+ irq = platform_get_irq(pdev, 0);306306+ if (irq < 0) {307307+ dev_err(&pdev->dev, "failed to get interrupt resource\n");308308+ return irq;309309+ }310310+306311 rtc = kzalloc(sizeof *rtc, GFP_KERNEL);307312 if (!rtc)308313 return -ENOMEM;314314+315315+ rtc->irq = irq;309316310317 /* platform setup code should have handled this; sigh */311318 if (!device_can_wakeup(&pdev->dev))···354345 }355346356347 /* register irq handler after we know what name we'll use */357357- ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt,358358- IRQF_SHARED,348348+ ret = request_irq(rtc->irq, at91_rtc_interrupt, IRQF_SHARED,359349 dev_name(&rtc->rtcdev->dev), rtc);360350 if (ret) {361361- dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS);351351+ dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq);362352 rtc_device_unregister(rtc->rtcdev);363353 goto fail_register;364354 }···394386395387 /* disable all interrupts */396388 rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN));397397- free_irq(AT91_ID_SYS, rtc);389389+ free_irq(rtc->irq, rtc);398390399391 rtc_device_unregister(rtc->rtcdev);400392···431423 rtc->imr = mr & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);432424 if (rtc->imr) {433425 if (device_may_wakeup(&pdev->dev) && (mr & AT91_RTT_ALMIEN)) {434434- enable_irq_wake(AT91_ID_SYS);426426+ enable_irq_wake(rtc->irq);435427 /* don't let RTTINC cause wakeups */436428 if (mr & AT91_RTT_RTTINCIEN)437429 rtt_writel(rtc, MR, mr & ~AT91_RTT_RTTINCIEN);···449441450442 if (rtc->imr) {451443 if (device_may_wakeup(&pdev->dev))452452- disable_irq_wake(AT91_ID_SYS);444444+ disable_irq_wake(rtc->irq);453445 mr = rtt_readl(rtc, MR);454446 rtt_writel(rtc, MR, mr | rtc->imr);455447 }
···39953995static int et131x_pci_init(struct et131x_adapter *adapter,39963996 struct pci_dev *pdev)39973997{39983998- int cap = pci_pcie_cap(pdev);39993998 u16 max_payload;40004000- u16 ctl;40013999 int i, rc;4002400040034001 rc = et131x_init_eeprom(adapter);40044002 if (rc < 0)40054003 goto out;4006400440074007- if (!cap) {40054005+ if (!pci_is_pcie(pdev)) {40084006 dev_err(&pdev->dev, "Missing PCIe capabilities\n");40094007 goto err_out;40104008 }···40104012 /* Let's set up the PORT LOGIC Register. First we need to know what40114013 * the max_payload_size is40124014 */40134013- if (pci_read_config_word(pdev, cap + PCI_EXP_DEVCAP, &max_payload)) {40154015+ if (pcie_capability_read_word(pdev, PCI_EXP_DEVCAP, &max_payload)) {40144016 dev_err(&pdev->dev,40154017 "Could not read PCI config space for Max Payload Size\n");40164018 goto err_out;···40474049 }4048405040494051 /* Change the max read size to 2k */40504050- if (pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &ctl)) {40524052+ if (pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL,40534053+ PCI_EXP_DEVCTL_READRQ, 0x4 << 12)) {40514054 dev_err(&pdev->dev,40524052- "Could not read PCI config space for Max read size\n");40534053- goto err_out;40544054- }40554055-40564056- ctl = (ctl & ~PCI_EXP_DEVCTL_READRQ) | (0x04 << 12);40574057-40584058- if (pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, ctl)) {40594059- dev_err(&pdev->dev,40604060- "Could not write PCI config space for Max read size\n");40554055+ "Couldn't change PCI config space for Max read size\n");40614056 goto err_out;40624057 }40634058
···162162 image.depth = 1;163163164164 if (attribute) {165165- buf = kmalloc(cellsize, GFP_KERNEL);165165+ buf = kmalloc(cellsize, GFP_ATOMIC);166166 if (!buf)167167 return;168168 }
+1-1
drivers/video/console/fbcon.c
···449449450450 while ((options = strsep(&this_opt, ",")) != NULL) {451451 if (!strncmp(options, "font:", 5))452452- strcpy(fontname, options + 5);452452+ strlcpy(fontname, options + 5, sizeof(fontname));453453454454 if (!strncmp(options, "scrollback:", 11)) {455455 options += 11;
+2
drivers/video/mb862xx/mb862xxfbdrv.c
···328328 case MB862XX_L1_SET_CFG:329329 if (copy_from_user(l1_cfg, argp, sizeof(*l1_cfg)))330330 return -EFAULT;331331+ if (l1_cfg->dh == 0 || l1_cfg->dw == 0)332332+ return -EINVAL;331333 if ((l1_cfg->sw >= l1_cfg->dw) && (l1_cfg->sh >= l1_cfg->dh)) {332334 /* downscaling */333335 outreg(cap, GC_CAP_CSC,
+14
drivers/video/omap2/dss/sdi.c
···105105106106 sdi_config_lcd_manager(dssdev);107107108108+ /*109109+ * LCLK and PCLK divisors are located in shadow registers, and we110110+ * normally write them to DISPC registers when enabling the output.111111+ * However, SDI uses pck-free as source clock for its PLL, and pck-free112112+ * is affected by the divisors. And as we need the PLL before enabling113113+ * the output, we need to write the divisors early.114114+ *115115+ * It seems just writing to the DISPC register is enough, and we don't116116+ * need to care about the shadow register mechanism for pck-free. The117117+ * exact reason for this is unknown.118118+ */119119+ dispc_mgr_set_clock_div(dssdev->manager->id,120120+ &sdi.mgr_config.clock_info);121121+108122 dss_sdi_init(dssdev->phy.sdi.datapairs);109123 r = dss_sdi_enable();110124 if (r)
···353353 if (err)354354 goto config_release;355355356356- dev_dbg(&dev->dev, "reseting (FLR, D3, etc) the device\n");357357- __pci_reset_function_locked(dev);358358-359356 /* We need the device active to save the state. */360357 dev_dbg(&dev->dev, "save state of device\n");361358 pci_save_state(dev);362359 dev_data->pci_saved_state = pci_store_saved_state(dev);363360 if (!dev_data->pci_saved_state)364361 dev_err(&dev->dev, "Could not store PCI conf saved state!\n");365365-362362+ else {363363+ dev_dbg(&dev->dev, "reseting (FLR, D3, etc) the device\n");364364+ __pci_reset_function_locked(dev);365365+ }366366 /* Now disable the device (this also ensures some private device367367 * data is setup before we export)368368 */
···211211212212 if ! cmp -s System.map .tmp_System.map; then213213 echo >&2 Inconsistent kallsyms data214214- echo >&2 echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround214214+ echo >&2 Try "make KALLSYMS_EXTRA_PASS=1" as a workaround215215 cleanup216216 exit 1217217 fi
+8-2
sound/pci/hda/hda_codec.c
···12091209 kfree(codec);12101210}1211121112121212+static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,12131213+ hda_nid_t fg, unsigned int power_state);12141214+12121215static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,12131216 unsigned int power_state);12141217···13191316 snd_hda_codec_read(codec, nid, 0,13201317 AC_VERB_GET_SUBSYSTEM_ID, 0);13211318 }13191319+13201320+ codec->epss = snd_hda_codec_get_supported_ps(codec,13211321+ codec->afg ? codec->afg : codec->mfg,13221322+ AC_PWRST_EPSS);1322132313231324 /* power-up all before initialization */13241325 hda_set_power_state(codec,···35503543 /* this delay seems necessary to avoid click noise at power-down */35513544 if (power_state == AC_PWRST_D3) {35523545 /* transition time less than 10ms for power down */35533553- bool epss = snd_hda_codec_get_supported_ps(codec, fg, AC_PWRST_EPSS);35543554- msleep(epss ? 10 : 100);35463546+ msleep(codec->epss ? 10 : 100);35553547 }3556354835573549 /* repeat power states setting at most 10 times*/
+1
sound/pci/hda/hda_codec.h
···862862 unsigned int ignore_misc_bit:1; /* ignore MISC_NO_PRESENCE bit */863863 unsigned int no_jack_detect:1; /* Machine has no jack-detection */864864 unsigned int pcm_format_first:1; /* PCM format must be set first */865865+ unsigned int epss:1; /* supporting EPSS? */865866#ifdef CONFIG_SND_HDA_POWER_SAVE866867 unsigned int power_on :1; /* current (global) power-state */867868 int power_transition; /* power-state in transition */
···141141 *142142 * For implicit feedback, next_packet_size() is unused.143143 */144144-static int next_packet_size(struct snd_usb_endpoint *ep)144144+int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep)145145{146146 unsigned long flags;147147 int ret;···175175176176 if (ep->retire_data_urb)177177 ep->retire_data_urb(ep->data_subs, urb);178178-}179179-180180-static void prepare_outbound_urb_sizes(struct snd_usb_endpoint *ep,181181- struct snd_urb_ctx *ctx)182182-{183183- int i;184184-185185- for (i = 0; i < ctx->packets; ++i)186186- ctx->packet_size[i] = next_packet_size(ep);187178}188179189180/*···361370 goto exit_clear;362371 }363372364364- prepare_outbound_urb_sizes(ep, ctx);365373 prepare_outbound_urb(ep, ctx);366374 } else {367375 retire_inbound_urb(ep, ctx);···789799/**790800 * snd_usb_endpoint_start: start an snd_usb_endpoint791801 *792792- * @ep: the endpoint to start802802+ * @ep: the endpoint to start803803+ * @can_sleep: flag indicating whether the operation is executed in804804+ * non-atomic context793805 *794806 * A call to this function will increment the use count of the endpoint.795807 * In case it is not already running, the URBs for this endpoint will be···801809 *802810 * Returns an error if the URB submission failed, 0 in all other cases.803811 */804804-int snd_usb_endpoint_start(struct snd_usb_endpoint *ep)812812+int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep)805813{806814 int err;807815 unsigned int i;···812820 /* already running? */813821 if (++ep->use_count != 1)814822 return 0;823823+824824+ /* just to be sure */825825+ deactivate_urbs(ep, 0, can_sleep);826826+ if (can_sleep)827827+ wait_clear_urbs(ep);815828816829 ep->active_mask = 0;817830 ep->unlink_mask = 0;···847850 goto __error;848851849852 if (usb_pipeout(ep->pipe)) {850850- prepare_outbound_urb_sizes(ep, urb->context);851853 prepare_outbound_urb(ep, urb->context);852854 } else {853855 prepare_inbound_urb(ep, urb->context);