pciehp_hpc.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * PCI Express PCI Hot Plug Driver
  4. *
  5. * Copyright (C) 1995,2001 Compaq Computer Corporation
  6. * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
  7. * Copyright (C) 2001 IBM Corp.
  8. * Copyright (C) 2003-2004 Intel Corporation
  9. *
  10. * All rights reserved.
  11. *
  12. * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com>
  13. */
  14. #define dev_fmt(fmt) "pciehp: " fmt
  15. #include <linux/bitfield.h>
  16. #include <linux/dmi.h>
  17. #include <linux/kernel.h>
  18. #include <linux/types.h>
  19. #include <linux/jiffies.h>
  20. #include <linux/kthread.h>
  21. #include <linux/pci.h>
  22. #include <linux/pm_runtime.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/slab.h>
  25. #include "../pci.h"
  26. #include "pciehp.h"
  27. static const struct dmi_system_id inband_presence_disabled_dmi_table[] = {
  28. /*
  29. * Match all Dell systems, as some Dell systems have inband
  30. * presence disabled on NVMe slots (but don't support the bit to
  31. * report it). Setting inband presence disabled should have no
  32. * negative effect, except on broken hotplug slots that never
  33. * assert presence detect--and those will still work, they will
  34. * just have a bit of extra delay before being probed.
  35. */
  36. {
  37. .ident = "Dell System",
  38. .matches = {
  39. DMI_MATCH(DMI_OEM_STRING, "Dell System"),
  40. },
  41. },
  42. {}
  43. };
  44. static inline struct pci_dev *ctrl_dev(struct controller *ctrl)
  45. {
  46. return ctrl->pcie->port;
  47. }
  48. static irqreturn_t pciehp_isr(int irq, void *dev_id);
  49. static irqreturn_t pciehp_ist(int irq, void *dev_id);
  50. static int pciehp_poll(void *data);
  51. static inline int pciehp_request_irq(struct controller *ctrl)
  52. {
  53. int retval, irq = ctrl->pcie->irq;
  54. if (pciehp_poll_mode) {
  55. ctrl->poll_thread = kthread_run(&pciehp_poll, ctrl,
  56. "pciehp_poll-%s",
  57. slot_name(ctrl));
  58. return PTR_ERR_OR_ZERO(ctrl->poll_thread);
  59. }
  60. /* Installs the interrupt handler */
  61. retval = request_threaded_irq(irq, pciehp_isr, pciehp_ist,
  62. IRQF_SHARED, "pciehp", ctrl);
  63. if (retval)
  64. ctrl_err(ctrl, "Cannot get irq %d for the hotplug controller\n",
  65. irq);
  66. return retval;
  67. }
  68. static inline void pciehp_free_irq(struct controller *ctrl)
  69. {
  70. if (pciehp_poll_mode)
  71. kthread_stop(ctrl->poll_thread);
  72. else
  73. free_irq(ctrl->pcie->irq, ctrl);
  74. }
  75. static int pcie_poll_cmd(struct controller *ctrl, int timeout)
  76. {
  77. struct pci_dev *pdev = ctrl_dev(ctrl);
  78. u16 slot_status;
  79. do {
  80. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  81. if (PCI_POSSIBLE_ERROR(slot_status)) {
  82. ctrl_info(ctrl, "%s: no response from device\n",
  83. __func__);
  84. return 0;
  85. }
  86. if (slot_status & PCI_EXP_SLTSTA_CC) {
  87. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
  88. PCI_EXP_SLTSTA_CC);
  89. ctrl->cmd_busy = 0;
  90. smp_mb();
  91. return 1;
  92. }
  93. msleep(10);
  94. timeout -= 10;
  95. } while (timeout >= 0);
  96. return 0; /* timeout */
  97. }
  98. static void pcie_wait_cmd(struct controller *ctrl)
  99. {
  100. unsigned int msecs = pciehp_poll_mode ? 2500 : 1000;
  101. unsigned long duration = msecs_to_jiffies(msecs);
  102. unsigned long cmd_timeout = ctrl->cmd_started + duration;
  103. unsigned long now, timeout;
  104. int rc;
  105. /*
  106. * If the controller does not generate notifications for command
  107. * completions, we never need to wait between writes.
  108. */
  109. if (NO_CMD_CMPL(ctrl))
  110. return;
  111. if (!ctrl->cmd_busy)
  112. return;
  113. /*
  114. * Even if the command has already timed out, we want to call
  115. * pcie_poll_cmd() so it can clear PCI_EXP_SLTSTA_CC.
  116. */
  117. now = jiffies;
  118. if (time_before_eq(cmd_timeout, now))
  119. timeout = 1;
  120. else
  121. timeout = cmd_timeout - now;
  122. if (ctrl->slot_ctrl & PCI_EXP_SLTCTL_HPIE &&
  123. ctrl->slot_ctrl & PCI_EXP_SLTCTL_CCIE)
  124. rc = wait_event_timeout(ctrl->queue, !ctrl->cmd_busy, timeout);
  125. else
  126. rc = pcie_poll_cmd(ctrl, jiffies_to_msecs(timeout));
  127. if (!rc)
  128. ctrl_info(ctrl, "Timeout on hotplug command %#06x (issued %u msec ago)\n",
  129. ctrl->slot_ctrl,
  130. jiffies_to_msecs(jiffies - ctrl->cmd_started));
  131. }
  132. #define CC_ERRATUM_MASK (PCI_EXP_SLTCTL_PCC | \
  133. PCI_EXP_SLTCTL_PIC | \
  134. PCI_EXP_SLTCTL_AIC | \
  135. PCI_EXP_SLTCTL_EIC)
  136. static void pcie_do_write_cmd(struct controller *ctrl, u16 cmd,
  137. u16 mask, bool wait)
  138. {
  139. struct pci_dev *pdev = ctrl_dev(ctrl);
  140. u16 slot_ctrl_orig, slot_ctrl;
  141. mutex_lock(&ctrl->ctrl_lock);
  142. /*
  143. * Always wait for any previous command that might still be in progress
  144. */
  145. pcie_wait_cmd(ctrl);
  146. pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl);
  147. if (PCI_POSSIBLE_ERROR(slot_ctrl)) {
  148. ctrl_info(ctrl, "%s: no response from device\n", __func__);
  149. goto out;
  150. }
  151. slot_ctrl_orig = slot_ctrl;
  152. slot_ctrl &= ~mask;
  153. slot_ctrl |= (cmd & mask);
  154. ctrl->cmd_busy = 1;
  155. smp_mb();
  156. ctrl->slot_ctrl = slot_ctrl;
  157. pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, slot_ctrl);
  158. ctrl->cmd_started = jiffies;
  159. /*
  160. * Controllers with the Intel CF118 and similar errata advertise
  161. * Command Completed support, but they only set Command Completed
  162. * if we change the "Control" bits for power, power indicator,
  163. * attention indicator, or interlock. If we only change the
  164. * "Enable" bits, they never set the Command Completed bit.
  165. */
  166. if (pdev->broken_cmd_compl &&
  167. (slot_ctrl_orig & CC_ERRATUM_MASK) == (slot_ctrl & CC_ERRATUM_MASK))
  168. ctrl->cmd_busy = 0;
  169. /*
  170. * Optionally wait for the hardware to be ready for a new command,
  171. * indicating completion of the above issued command.
  172. */
  173. if (wait)
  174. pcie_wait_cmd(ctrl);
  175. out:
  176. mutex_unlock(&ctrl->ctrl_lock);
  177. }
  178. /**
  179. * pcie_write_cmd - Issue controller command
  180. * @ctrl: controller to which the command is issued
  181. * @cmd: command value written to slot control register
  182. * @mask: bitmask of slot control register to be modified
  183. */
  184. static void pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
  185. {
  186. pcie_do_write_cmd(ctrl, cmd, mask, true);
  187. }
  188. /* Same as above without waiting for the hardware to latch */
  189. static void pcie_write_cmd_nowait(struct controller *ctrl, u16 cmd, u16 mask)
  190. {
  191. pcie_do_write_cmd(ctrl, cmd, mask, false);
  192. }
  193. /**
  194. * pciehp_check_link_active() - Is the link active
  195. * @ctrl: PCIe hotplug controller
  196. *
  197. * Check whether the downstream link is currently active. Note it is
  198. * possible that the card is removed immediately after this so the
  199. * caller may need to take it into account.
  200. *
  201. * If the hotplug controller itself is not available anymore returns
  202. * %-ENODEV.
  203. */
  204. int pciehp_check_link_active(struct controller *ctrl)
  205. {
  206. struct pci_dev *pdev = ctrl_dev(ctrl);
  207. u16 lnk_status;
  208. int ret;
  209. ret = pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
  210. if (ret == PCIBIOS_DEVICE_NOT_FOUND || PCI_POSSIBLE_ERROR(lnk_status))
  211. return -ENODEV;
  212. ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA);
  213. ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
  214. return ret;
  215. }
  216. static bool pci_bus_check_dev(struct pci_bus *bus, int devfn)
  217. {
  218. u32 l;
  219. int count = 0;
  220. int delay = 1000, step = 20;
  221. bool found = false;
  222. do {
  223. found = pci_bus_read_dev_vendor_id(bus, devfn, &l, 0);
  224. count++;
  225. if (found)
  226. break;
  227. msleep(step);
  228. delay -= step;
  229. } while (delay > 0);
  230. if (count > 1)
  231. pr_debug("pci %04x:%02x:%02x.%d id reading try %d times with interval %d ms to get %08x\n",
  232. pci_domain_nr(bus), bus->number, PCI_SLOT(devfn),
  233. PCI_FUNC(devfn), count, step, l);
  234. return found;
  235. }
  236. static void pcie_wait_for_presence(struct pci_dev *pdev)
  237. {
  238. int timeout = 1250;
  239. u16 slot_status;
  240. do {
  241. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  242. if (slot_status & PCI_EXP_SLTSTA_PDS)
  243. return;
  244. msleep(10);
  245. timeout -= 10;
  246. } while (timeout > 0);
  247. }
  248. int pciehp_check_link_status(struct controller *ctrl)
  249. {
  250. struct pci_dev *pdev = ctrl_dev(ctrl);
  251. bool found;
  252. u16 lnk_status, linksta2;
  253. if (!pcie_wait_for_link(pdev, true)) {
  254. ctrl_info(ctrl, "Slot(%s): No link\n", slot_name(ctrl));
  255. return -1;
  256. }
  257. if (ctrl->inband_presence_disabled)
  258. pcie_wait_for_presence(pdev);
  259. found = pci_bus_check_dev(ctrl->pcie->port->subordinate,
  260. PCI_DEVFN(0, 0));
  261. /* ignore link or presence changes up to this point */
  262. if (found)
  263. atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC),
  264. &ctrl->pending_events);
  265. pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
  266. ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
  267. if ((lnk_status & PCI_EXP_LNKSTA_LT) ||
  268. !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
  269. ctrl_info(ctrl, "Slot(%s): Cannot train link: status %#06x\n",
  270. slot_name(ctrl), lnk_status);
  271. return -1;
  272. }
  273. pcie_capability_read_word(pdev, PCI_EXP_LNKSTA2, &linksta2);
  274. __pcie_update_link_speed(ctrl->pcie->port->subordinate, PCIE_HOTPLUG,
  275. lnk_status, linksta2);
  276. if (!found) {
  277. ctrl_info(ctrl, "Slot(%s): No device found\n",
  278. slot_name(ctrl));
  279. return -1;
  280. }
  281. return 0;
  282. }
  283. static int __pciehp_link_set(struct controller *ctrl, bool enable)
  284. {
  285. struct pci_dev *pdev = ctrl_dev(ctrl);
  286. pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL,
  287. PCI_EXP_LNKCTL_LD,
  288. enable ? 0 : PCI_EXP_LNKCTL_LD);
  289. return 0;
  290. }
  291. static int pciehp_link_enable(struct controller *ctrl)
  292. {
  293. return __pciehp_link_set(ctrl, true);
  294. }
  295. int pciehp_get_raw_indicator_status(struct hotplug_slot *hotplug_slot,
  296. u8 *status)
  297. {
  298. struct controller *ctrl = to_ctrl(hotplug_slot);
  299. struct pci_dev *pdev = ctrl_dev(ctrl);
  300. u16 slot_ctrl;
  301. pci_config_pm_runtime_get(pdev);
  302. pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl);
  303. pci_config_pm_runtime_put(pdev);
  304. *status = (slot_ctrl & (PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC)) >> 6;
  305. return 0;
  306. }
  307. int pciehp_get_attention_status(struct hotplug_slot *hotplug_slot, u8 *status)
  308. {
  309. struct controller *ctrl = to_ctrl(hotplug_slot);
  310. struct pci_dev *pdev = ctrl_dev(ctrl);
  311. u16 slot_ctrl;
  312. pci_config_pm_runtime_get(pdev);
  313. pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl);
  314. pci_config_pm_runtime_put(pdev);
  315. ctrl_dbg(ctrl, "%s: SLOTCTRL %x, value read %x\n", __func__,
  316. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_ctrl);
  317. switch (slot_ctrl & PCI_EXP_SLTCTL_AIC) {
  318. case PCI_EXP_SLTCTL_ATTN_IND_ON:
  319. *status = 1; /* On */
  320. break;
  321. case PCI_EXP_SLTCTL_ATTN_IND_BLINK:
  322. *status = 2; /* Blink */
  323. break;
  324. case PCI_EXP_SLTCTL_ATTN_IND_OFF:
  325. *status = 0; /* Off */
  326. break;
  327. default:
  328. *status = 0xFF;
  329. break;
  330. }
  331. return 0;
  332. }
  333. void pciehp_get_power_status(struct controller *ctrl, u8 *status)
  334. {
  335. struct pci_dev *pdev = ctrl_dev(ctrl);
  336. u16 slot_ctrl;
  337. pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl);
  338. ctrl_dbg(ctrl, "%s: SLOTCTRL %x value read %x\n", __func__,
  339. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_ctrl);
  340. switch (slot_ctrl & PCI_EXP_SLTCTL_PCC) {
  341. case PCI_EXP_SLTCTL_PWR_ON:
  342. *status = 1; /* On */
  343. break;
  344. case PCI_EXP_SLTCTL_PWR_OFF:
  345. *status = 0; /* Off */
  346. break;
  347. default:
  348. *status = 0xFF;
  349. break;
  350. }
  351. }
  352. void pciehp_get_latch_status(struct controller *ctrl, u8 *status)
  353. {
  354. struct pci_dev *pdev = ctrl_dev(ctrl);
  355. u16 slot_status;
  356. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  357. *status = !!(slot_status & PCI_EXP_SLTSTA_MRLSS);
  358. }
  359. /**
  360. * pciehp_card_present() - Is the card present
  361. * @ctrl: PCIe hotplug controller
  362. *
  363. * Function checks whether the card is currently present in the slot and
  364. * in that case returns true. Note it is possible that the card is
  365. * removed immediately after the check so the caller may need to take
  366. * this into account.
  367. *
  368. * If the hotplug controller itself is not available anymore returns
  369. * %-ENODEV.
  370. */
  371. int pciehp_card_present(struct controller *ctrl)
  372. {
  373. struct pci_dev *pdev = ctrl_dev(ctrl);
  374. u16 slot_status;
  375. int ret;
  376. ret = pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  377. if (ret == PCIBIOS_DEVICE_NOT_FOUND || PCI_POSSIBLE_ERROR(slot_status))
  378. return -ENODEV;
  379. return !!(slot_status & PCI_EXP_SLTSTA_PDS);
  380. }
  381. /**
  382. * pciehp_card_present_or_link_active() - whether given slot is occupied
  383. * @ctrl: PCIe hotplug controller
  384. *
  385. * Unlike pciehp_card_present(), which determines presence solely from the
  386. * Presence Detect State bit, this helper also returns true if the Link Active
  387. * bit is set. This is a concession to broken hotplug ports which hardwire
  388. * Presence Detect State to zero, such as Wilocity's [1ae9:0200].
  389. *
  390. * Returns: %1 if the slot is occupied and %0 if it is not. If the hotplug
  391. * port is not present anymore returns %-ENODEV.
  392. */
  393. int pciehp_card_present_or_link_active(struct controller *ctrl)
  394. {
  395. int ret;
  396. ret = pciehp_card_present(ctrl);
  397. if (ret)
  398. return ret;
  399. return pciehp_check_link_active(ctrl);
  400. }
  401. int pciehp_query_power_fault(struct controller *ctrl)
  402. {
  403. struct pci_dev *pdev = ctrl_dev(ctrl);
  404. u16 slot_status;
  405. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  406. return !!(slot_status & PCI_EXP_SLTSTA_PFD);
  407. }
  408. int pciehp_set_raw_indicator_status(struct hotplug_slot *hotplug_slot,
  409. u8 status)
  410. {
  411. struct controller *ctrl = to_ctrl(hotplug_slot);
  412. struct pci_dev *pdev = ctrl_dev(ctrl);
  413. pci_config_pm_runtime_get(pdev);
  414. /* Attention and Power Indicator Control bits are supported */
  415. pcie_write_cmd_nowait(ctrl, FIELD_PREP(PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC, status),
  416. PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC);
  417. pci_config_pm_runtime_put(pdev);
  418. return 0;
  419. }
  420. /**
  421. * pciehp_set_indicators() - set attention indicator, power indicator, or both
  422. * @ctrl: PCIe hotplug controller
  423. * @pwr: one of:
  424. * PCI_EXP_SLTCTL_PWR_IND_ON
  425. * PCI_EXP_SLTCTL_PWR_IND_BLINK
  426. * PCI_EXP_SLTCTL_PWR_IND_OFF
  427. * @attn: one of:
  428. * PCI_EXP_SLTCTL_ATTN_IND_ON
  429. * PCI_EXP_SLTCTL_ATTN_IND_BLINK
  430. * PCI_EXP_SLTCTL_ATTN_IND_OFF
  431. *
  432. * Either @pwr or @attn can also be INDICATOR_NOOP to leave that indicator
  433. * unchanged.
  434. */
  435. void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn)
  436. {
  437. u16 cmd = 0, mask = 0;
  438. if (PWR_LED(ctrl) && pwr != INDICATOR_NOOP) {
  439. cmd |= (pwr & PCI_EXP_SLTCTL_PIC);
  440. mask |= PCI_EXP_SLTCTL_PIC;
  441. }
  442. if (ATTN_LED(ctrl) && attn != INDICATOR_NOOP) {
  443. cmd |= (attn & PCI_EXP_SLTCTL_AIC);
  444. mask |= PCI_EXP_SLTCTL_AIC;
  445. }
  446. if (cmd) {
  447. pcie_write_cmd_nowait(ctrl, cmd, mask);
  448. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  449. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd);
  450. }
  451. }
  452. int pciehp_power_on_slot(struct controller *ctrl)
  453. {
  454. struct pci_dev *pdev = ctrl_dev(ctrl);
  455. u16 slot_status;
  456. int retval;
  457. /* Clear power-fault bit from previous power failures */
  458. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  459. if (slot_status & PCI_EXP_SLTSTA_PFD)
  460. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
  461. PCI_EXP_SLTSTA_PFD);
  462. ctrl->power_fault_detected = 0;
  463. pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_ON, PCI_EXP_SLTCTL_PCC);
  464. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  465. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
  466. PCI_EXP_SLTCTL_PWR_ON);
  467. retval = pciehp_link_enable(ctrl);
  468. if (retval)
  469. ctrl_err(ctrl, "%s: Can not enable the link!\n", __func__);
  470. return retval;
  471. }
  472. void pciehp_power_off_slot(struct controller *ctrl)
  473. {
  474. pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_OFF, PCI_EXP_SLTCTL_PCC);
  475. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  476. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
  477. PCI_EXP_SLTCTL_PWR_OFF);
  478. }
  479. bool pciehp_device_replaced(struct controller *ctrl)
  480. {
  481. struct pci_dev *pdev __free(pci_dev_put) = NULL;
  482. u32 reg;
  483. if (pci_dev_is_disconnected(ctrl->pcie->port))
  484. return false;
  485. pdev = pci_get_slot(ctrl->pcie->port->subordinate, PCI_DEVFN(0, 0));
  486. if (!pdev)
  487. return true;
  488. if (pci_read_config_dword(pdev, PCI_VENDOR_ID, &reg) ||
  489. reg != (pdev->vendor | (pdev->device << 16)) ||
  490. pci_read_config_dword(pdev, PCI_CLASS_REVISION, &reg) ||
  491. reg != (pdev->revision | (pdev->class << 8)))
  492. return true;
  493. if (pdev->hdr_type == PCI_HEADER_TYPE_NORMAL &&
  494. (pci_read_config_dword(pdev, PCI_SUBSYSTEM_VENDOR_ID, &reg) ||
  495. reg != (pdev->subsystem_vendor | (pdev->subsystem_device << 16))))
  496. return true;
  497. if (pci_get_dsn(pdev) != ctrl->dsn)
  498. return true;
  499. return false;
  500. }
  501. static void pciehp_ignore_link_change(struct controller *ctrl,
  502. struct pci_dev *pdev, int irq,
  503. u16 ignored_events)
  504. {
  505. /*
  506. * Ignore link changes which occurred while waiting for DPC recovery.
  507. * Could be several if DPC triggered multiple times consecutively.
  508. * Also ignore link changes caused by Secondary Bus Reset, etc.
  509. */
  510. synchronize_hardirq(irq);
  511. atomic_and(~ignored_events, &ctrl->pending_events);
  512. if (pciehp_poll_mode)
  513. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
  514. ignored_events);
  515. ctrl_info(ctrl, "Slot(%s): Link Down/Up ignored\n", slot_name(ctrl));
  516. /*
  517. * If the link is unexpectedly down after successful recovery,
  518. * the corresponding link change may have been ignored above.
  519. * Synthesize it to ensure that it is acted on.
  520. */
  521. down_read_nested(&ctrl->reset_lock, ctrl->depth);
  522. if (!pciehp_check_link_active(ctrl) || pciehp_device_replaced(ctrl))
  523. pciehp_request(ctrl, ignored_events);
  524. up_read(&ctrl->reset_lock);
  525. }
  526. static irqreturn_t pciehp_isr(int irq, void *dev_id)
  527. {
  528. struct controller *ctrl = (struct controller *)dev_id;
  529. struct pci_dev *pdev = ctrl_dev(ctrl);
  530. struct device *parent = pdev->dev.parent;
  531. u16 status, events = 0;
  532. /*
  533. * Interrupts only occur in D3hot or shallower and only if enabled
  534. * in the Slot Control register (PCIe r4.0, sec 6.7.3.4).
  535. */
  536. if (pdev->current_state == PCI_D3cold ||
  537. (!(ctrl->slot_ctrl & PCI_EXP_SLTCTL_HPIE) && !pciehp_poll_mode))
  538. return IRQ_NONE;
  539. /*
  540. * Keep the port accessible by holding a runtime PM ref on its parent.
  541. * Defer resume of the parent to the IRQ thread if it's suspended.
  542. * Mask the interrupt until then.
  543. */
  544. if (parent) {
  545. pm_runtime_get_noresume(parent);
  546. if (!pm_runtime_active(parent)) {
  547. pm_runtime_put(parent);
  548. disable_irq_nosync(irq);
  549. atomic_or(RERUN_ISR, &ctrl->pending_events);
  550. return IRQ_WAKE_THREAD;
  551. }
  552. }
  553. read_status:
  554. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &status);
  555. if (PCI_POSSIBLE_ERROR(status)) {
  556. ctrl_info(ctrl, "%s: no response from device\n", __func__);
  557. if (parent)
  558. pm_runtime_put(parent);
  559. return IRQ_NONE;
  560. }
  561. /*
  562. * Slot Status contains plain status bits as well as event
  563. * notification bits; right now we only want the event bits.
  564. */
  565. status &= PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
  566. PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_CC |
  567. PCI_EXP_SLTSTA_DLLSC;
  568. /*
  569. * If we've already reported a power fault, don't report it again
  570. * until we've done something to handle it.
  571. */
  572. if (ctrl->power_fault_detected)
  573. status &= ~PCI_EXP_SLTSTA_PFD;
  574. else if (status & PCI_EXP_SLTSTA_PFD)
  575. ctrl->power_fault_detected = true;
  576. events |= status;
  577. if (!events) {
  578. if (parent)
  579. pm_runtime_put(parent);
  580. return IRQ_NONE;
  581. }
  582. if (status) {
  583. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, status);
  584. /*
  585. * In MSI mode, all event bits must be zero before the port
  586. * will send a new interrupt (PCIe Base Spec r5.0 sec 6.7.3.4).
  587. * So re-read the Slot Status register in case a bit was set
  588. * between read and write.
  589. */
  590. if (pci_dev_msi_enabled(pdev) && !pciehp_poll_mode)
  591. goto read_status;
  592. }
  593. ctrl_dbg(ctrl, "pending interrupts %#06x from Slot Status\n", events);
  594. if (parent)
  595. pm_runtime_put(parent);
  596. /*
  597. * Command Completed notifications are not deferred to the
  598. * IRQ thread because it may be waiting for their arrival.
  599. */
  600. if (events & PCI_EXP_SLTSTA_CC) {
  601. ctrl->cmd_busy = 0;
  602. smp_mb();
  603. wake_up(&ctrl->queue);
  604. if (events == PCI_EXP_SLTSTA_CC)
  605. return IRQ_HANDLED;
  606. events &= ~PCI_EXP_SLTSTA_CC;
  607. }
  608. if (pdev->ignore_hotplug) {
  609. ctrl_dbg(ctrl, "ignoring hotplug event %#06x\n", events);
  610. return IRQ_HANDLED;
  611. }
  612. /* Save pending events for consumption by IRQ thread. */
  613. atomic_or(events, &ctrl->pending_events);
  614. return IRQ_WAKE_THREAD;
  615. }
  616. static irqreturn_t pciehp_ist(int irq, void *dev_id)
  617. {
  618. struct controller *ctrl = (struct controller *)dev_id;
  619. struct pci_dev *pdev = ctrl_dev(ctrl);
  620. irqreturn_t ret;
  621. u32 events;
  622. ctrl->ist_running = true;
  623. pci_config_pm_runtime_get(pdev);
  624. /* rerun pciehp_isr() if the port was inaccessible on interrupt */
  625. if (atomic_fetch_and(~RERUN_ISR, &ctrl->pending_events) & RERUN_ISR) {
  626. ret = pciehp_isr(irq, dev_id);
  627. enable_irq(irq);
  628. if (ret != IRQ_WAKE_THREAD)
  629. goto out;
  630. }
  631. synchronize_hardirq(irq);
  632. events = atomic_xchg(&ctrl->pending_events, 0);
  633. if (!events) {
  634. ret = IRQ_NONE;
  635. goto out;
  636. }
  637. /* Check Attention Button Pressed */
  638. if (events & PCI_EXP_SLTSTA_ABP)
  639. pciehp_handle_button_press(ctrl);
  640. /* Check Power Fault Detected */
  641. if (events & PCI_EXP_SLTSTA_PFD) {
  642. ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(ctrl));
  643. pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF,
  644. PCI_EXP_SLTCTL_ATTN_IND_ON);
  645. }
  646. /*
  647. * Ignore Link Down/Up events caused by Downstream Port Containment
  648. * if recovery succeeded, or caused by Secondary Bus Reset,
  649. * suspend to D3cold, firmware update, FPGA reconfiguration, etc.
  650. */
  651. if ((events & (PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC)) &&
  652. (pci_dpc_recovered(pdev) || pci_hp_spurious_link_change(pdev)) &&
  653. ctrl->state == ON_STATE) {
  654. u16 ignored_events = PCI_EXP_SLTSTA_DLLSC;
  655. if (!ctrl->inband_presence_disabled)
  656. ignored_events |= PCI_EXP_SLTSTA_PDC;
  657. events &= ~ignored_events;
  658. pciehp_ignore_link_change(ctrl, pdev, irq, ignored_events);
  659. }
  660. /*
  661. * Disable requests have higher priority than Presence Detect Changed
  662. * or Data Link Layer State Changed events.
  663. */
  664. down_read_nested(&ctrl->reset_lock, ctrl->depth);
  665. if (events & DISABLE_SLOT)
  666. pciehp_handle_disable_request(ctrl);
  667. else if (events & (PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC))
  668. pciehp_handle_presence_or_link_change(ctrl, events);
  669. up_read(&ctrl->reset_lock);
  670. ret = IRQ_HANDLED;
  671. out:
  672. pci_config_pm_runtime_put(pdev);
  673. ctrl->ist_running = false;
  674. wake_up(&ctrl->requester);
  675. return ret;
  676. }
  677. static int pciehp_poll(void *data)
  678. {
  679. struct controller *ctrl = data;
  680. schedule_timeout_idle(10 * HZ); /* start with 10 sec delay */
  681. while (!kthread_should_stop()) {
  682. /* poll for interrupt events or user requests */
  683. while (pciehp_isr(IRQ_NOTCONNECTED, ctrl) == IRQ_WAKE_THREAD ||
  684. atomic_read(&ctrl->pending_events))
  685. pciehp_ist(IRQ_NOTCONNECTED, ctrl);
  686. if (pciehp_poll_time <= 0 || pciehp_poll_time > 60)
  687. pciehp_poll_time = 2; /* clamp to sane value */
  688. schedule_timeout_idle(pciehp_poll_time * HZ);
  689. }
  690. return 0;
  691. }
  692. static void pcie_enable_notification(struct controller *ctrl)
  693. {
  694. u16 cmd, mask;
  695. /*
  696. * TBD: Power fault detected software notification support.
  697. *
  698. * Power fault detected software notification is not enabled
  699. * now, because it caused power fault detected interrupt storm
  700. * on some machines. On those machines, power fault detected
  701. * bit in the slot status register was set again immediately
  702. * when it is cleared in the interrupt service routine, and
  703. * next power fault detected interrupt was notified again.
  704. */
  705. /*
  706. * Always enable link events: thus link-up and link-down shall
  707. * always be treated as hotplug and unplug respectively. Enable
  708. * presence detect only if Attention Button is not present.
  709. */
  710. cmd = PCI_EXP_SLTCTL_DLLSCE;
  711. if (ATTN_BUTTN(ctrl))
  712. cmd |= PCI_EXP_SLTCTL_ABPE;
  713. else
  714. cmd |= PCI_EXP_SLTCTL_PDCE;
  715. if (!pciehp_poll_mode)
  716. cmd |= PCI_EXP_SLTCTL_HPIE;
  717. if (!pciehp_poll_mode && !NO_CMD_CMPL(ctrl))
  718. cmd |= PCI_EXP_SLTCTL_CCIE;
  719. mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE |
  720. PCI_EXP_SLTCTL_PFDE |
  721. PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE |
  722. PCI_EXP_SLTCTL_DLLSCE);
  723. pcie_write_cmd_nowait(ctrl, cmd, mask);
  724. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  725. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd);
  726. }
  727. static void pcie_disable_notification(struct controller *ctrl)
  728. {
  729. u16 mask;
  730. mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE |
  731. PCI_EXP_SLTCTL_MRLSCE | PCI_EXP_SLTCTL_PFDE |
  732. PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE |
  733. PCI_EXP_SLTCTL_DLLSCE);
  734. pcie_write_cmd(ctrl, 0, mask);
  735. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  736. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, 0);
  737. }
  738. void pcie_clear_hotplug_events(struct controller *ctrl)
  739. {
  740. pcie_capability_write_word(ctrl_dev(ctrl), PCI_EXP_SLTSTA,
  741. PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC);
  742. }
  743. void pcie_enable_interrupt(struct controller *ctrl)
  744. {
  745. u16 mask;
  746. mask = PCI_EXP_SLTCTL_DLLSCE;
  747. if (!pciehp_poll_mode)
  748. mask |= PCI_EXP_SLTCTL_HPIE;
  749. pcie_write_cmd(ctrl, mask, mask);
  750. }
  751. void pcie_disable_interrupt(struct controller *ctrl)
  752. {
  753. u16 mask;
  754. /*
  755. * Mask hot-plug interrupt to prevent it triggering immediately
  756. * when the link goes inactive (we still get PME when any of the
  757. * enabled events is detected). Same goes with Link Layer State
  758. * changed event which generates PME immediately when the link goes
  759. * inactive so mask it as well.
  760. */
  761. mask = PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_DLLSCE;
  762. pcie_write_cmd(ctrl, 0, mask);
  763. }
  764. /**
  765. * pciehp_slot_reset() - ignore link event caused by error-induced hot reset
  766. * @dev: PCI Express port service device
  767. *
  768. * Called from pcie_portdrv_slot_reset() after AER or DPC initiated a reset
  769. * further up in the hierarchy to recover from an error. The reset was
  770. * propagated down to this hotplug port. Ignore the resulting link flap.
  771. * If the link failed to retrain successfully, synthesize the ignored event.
  772. * Surprise removal during reset is detected through Presence Detect Changed.
  773. */
  774. int pciehp_slot_reset(struct pcie_device *dev)
  775. {
  776. struct controller *ctrl = get_service_data(dev);
  777. if (ctrl->state != ON_STATE)
  778. return 0;
  779. pcie_capability_write_word(dev->port, PCI_EXP_SLTSTA,
  780. PCI_EXP_SLTSTA_DLLSC);
  781. if (!pciehp_check_link_active(ctrl))
  782. pciehp_request(ctrl, PCI_EXP_SLTSTA_DLLSC);
  783. return 0;
  784. }
  785. /*
  786. * pciehp has a 1:1 bus:slot relationship so we ultimately want a secondary
  787. * bus reset of the bridge, but at the same time we want to ensure that it is
  788. * not seen as a hot-unplug, followed by the hot-plug of the device. Thus,
  789. * disable link state notification and presence detection change notification
  790. * momentarily, if we see that they could interfere. Also, clear any spurious
  791. * events after.
  792. */
  793. int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, bool probe)
  794. {
  795. struct controller *ctrl = to_ctrl(hotplug_slot);
  796. struct pci_dev *pdev = ctrl_dev(ctrl);
  797. int rc;
  798. if (probe)
  799. return 0;
  800. down_write_nested(&ctrl->reset_lock, ctrl->depth);
  801. pci_hp_ignore_link_change(pdev);
  802. rc = pci_bridge_secondary_bus_reset(ctrl->pcie->port);
  803. pci_hp_unignore_link_change(pdev);
  804. up_write(&ctrl->reset_lock);
  805. return rc;
  806. }
  807. int pcie_init_notification(struct controller *ctrl)
  808. {
  809. if (pciehp_request_irq(ctrl))
  810. return -1;
  811. pcie_enable_notification(ctrl);
  812. ctrl->notification_enabled = 1;
  813. return 0;
  814. }
  815. void pcie_shutdown_notification(struct controller *ctrl)
  816. {
  817. if (ctrl->notification_enabled) {
  818. pcie_disable_notification(ctrl);
  819. pciehp_free_irq(ctrl);
  820. ctrl->notification_enabled = 0;
  821. }
  822. }
  823. static inline void dbg_ctrl(struct controller *ctrl)
  824. {
  825. struct pci_dev *pdev = ctrl->pcie->port;
  826. u16 reg16;
  827. ctrl_dbg(ctrl, "Slot Capabilities : 0x%08x\n", ctrl->slot_cap);
  828. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &reg16);
  829. ctrl_dbg(ctrl, "Slot Status : 0x%04x\n", reg16);
  830. pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &reg16);
  831. ctrl_dbg(ctrl, "Slot Control : 0x%04x\n", reg16);
  832. }
  833. #define FLAG(x, y) (((x) & (y)) ? '+' : '-')
  834. static inline int pcie_hotplug_depth(struct pci_dev *dev)
  835. {
  836. struct pci_bus *bus = dev->bus;
  837. int depth = 0;
  838. while (bus->parent) {
  839. bus = bus->parent;
  840. if (bus->self && bus->self->is_pciehp)
  841. depth++;
  842. }
  843. return depth;
  844. }
  845. struct controller *pcie_init(struct pcie_device *dev)
  846. {
  847. struct controller *ctrl;
  848. u32 slot_cap, slot_cap2;
  849. u8 poweron;
  850. struct pci_dev *pdev = dev->port;
  851. struct pci_bus *subordinate = pdev->subordinate;
  852. ctrl = kzalloc_obj(*ctrl);
  853. if (!ctrl)
  854. return NULL;
  855. ctrl->pcie = dev;
  856. ctrl->depth = pcie_hotplug_depth(dev->port);
  857. pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap);
  858. if (pdev->hotplug_user_indicators)
  859. slot_cap &= ~(PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_PIP);
  860. /*
  861. * We assume no Thunderbolt controllers support Command Complete events,
  862. * but some controllers falsely claim they do.
  863. */
  864. if (pdev->is_thunderbolt)
  865. slot_cap |= PCI_EXP_SLTCAP_NCCS;
  866. ctrl->slot_cap = slot_cap;
  867. mutex_init(&ctrl->ctrl_lock);
  868. mutex_init(&ctrl->state_lock);
  869. init_rwsem(&ctrl->reset_lock);
  870. init_waitqueue_head(&ctrl->requester);
  871. init_waitqueue_head(&ctrl->queue);
  872. INIT_DELAYED_WORK(&ctrl->button_work, pciehp_queue_pushbutton_work);
  873. dbg_ctrl(ctrl);
  874. down_read(&pci_bus_sem);
  875. ctrl->state = list_empty(&subordinate->devices) ? OFF_STATE : ON_STATE;
  876. up_read(&pci_bus_sem);
  877. pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP2, &slot_cap2);
  878. if (slot_cap2 & PCI_EXP_SLTCAP2_IBPD) {
  879. pcie_write_cmd_nowait(ctrl, PCI_EXP_SLTCTL_IBPD_DISABLE,
  880. PCI_EXP_SLTCTL_IBPD_DISABLE);
  881. ctrl->inband_presence_disabled = 1;
  882. }
  883. if (dmi_first_match(inband_presence_disabled_dmi_table))
  884. ctrl->inband_presence_disabled = 1;
  885. /* Clear all remaining event bits in Slot Status register. */
  886. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
  887. PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
  888. PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_CC |
  889. PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC);
  890. ctrl_info(ctrl, "Slot #%d AttnBtn%c PwrCtrl%c MRL%c AttnInd%c PwrInd%c HotPlug%c Surprise%c Interlock%c NoCompl%c IbPresDis%c LLActRep%c%s\n",
  891. FIELD_GET(PCI_EXP_SLTCAP_PSN, slot_cap),
  892. FLAG(slot_cap, PCI_EXP_SLTCAP_ABP),
  893. FLAG(slot_cap, PCI_EXP_SLTCAP_PCP),
  894. FLAG(slot_cap, PCI_EXP_SLTCAP_MRLSP),
  895. FLAG(slot_cap, PCI_EXP_SLTCAP_AIP),
  896. FLAG(slot_cap, PCI_EXP_SLTCAP_PIP),
  897. FLAG(slot_cap, PCI_EXP_SLTCAP_HPC),
  898. FLAG(slot_cap, PCI_EXP_SLTCAP_HPS),
  899. FLAG(slot_cap, PCI_EXP_SLTCAP_EIP),
  900. FLAG(slot_cap, PCI_EXP_SLTCAP_NCCS),
  901. FLAG(slot_cap2, PCI_EXP_SLTCAP2_IBPD),
  902. FLAG(pdev->link_active_reporting, true),
  903. pdev->broken_cmd_compl ? " (with Cmd Compl erratum)" : "");
  904. /*
  905. * If empty slot's power status is on, turn power off. The IRQ isn't
  906. * requested yet, so avoid triggering a notification with this command.
  907. */
  908. if (POWER_CTRL(ctrl)) {
  909. pciehp_get_power_status(ctrl, &poweron);
  910. if (!pciehp_card_present_or_link_active(ctrl) && poweron) {
  911. pcie_disable_notification(ctrl);
  912. pciehp_power_off_slot(ctrl);
  913. }
  914. }
  915. pdev = pci_get_slot(subordinate, PCI_DEVFN(0, 0));
  916. if (pdev)
  917. ctrl->dsn = pci_get_dsn(pdev);
  918. pci_dev_put(pdev);
  919. return ctrl;
  920. }
  921. void pciehp_release_ctrl(struct controller *ctrl)
  922. {
  923. cancel_delayed_work_sync(&ctrl->button_work);
  924. kfree(ctrl);
  925. }
  926. static void quirk_cmd_compl(struct pci_dev *pdev)
  927. {
  928. u32 slot_cap;
  929. if (pci_is_pcie(pdev)) {
  930. pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap);
  931. if (slot_cap & PCI_EXP_SLTCAP_HPC &&
  932. !(slot_cap & PCI_EXP_SLTCAP_NCCS))
  933. pdev->broken_cmd_compl = 1;
  934. }
  935. }
  936. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
  937. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  938. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x010e,
  939. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  940. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0110,
  941. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  942. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0400,
  943. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  944. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0401,
  945. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  946. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_HXT, 0x0401,
  947. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);