pciehp_hpc.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098
  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;
  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_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
  274. if (!found) {
  275. ctrl_info(ctrl, "Slot(%s): No device found\n",
  276. slot_name(ctrl));
  277. return -1;
  278. }
  279. return 0;
  280. }
  281. static int __pciehp_link_set(struct controller *ctrl, bool enable)
  282. {
  283. struct pci_dev *pdev = ctrl_dev(ctrl);
  284. pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL,
  285. PCI_EXP_LNKCTL_LD,
  286. enable ? 0 : PCI_EXP_LNKCTL_LD);
  287. return 0;
  288. }
  289. static int pciehp_link_enable(struct controller *ctrl)
  290. {
  291. return __pciehp_link_set(ctrl, true);
  292. }
  293. int pciehp_get_raw_indicator_status(struct hotplug_slot *hotplug_slot,
  294. u8 *status)
  295. {
  296. struct controller *ctrl = to_ctrl(hotplug_slot);
  297. struct pci_dev *pdev = ctrl_dev(ctrl);
  298. u16 slot_ctrl;
  299. pci_config_pm_runtime_get(pdev);
  300. pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl);
  301. pci_config_pm_runtime_put(pdev);
  302. *status = (slot_ctrl & (PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC)) >> 6;
  303. return 0;
  304. }
  305. int pciehp_get_attention_status(struct hotplug_slot *hotplug_slot, u8 *status)
  306. {
  307. struct controller *ctrl = to_ctrl(hotplug_slot);
  308. struct pci_dev *pdev = ctrl_dev(ctrl);
  309. u16 slot_ctrl;
  310. pci_config_pm_runtime_get(pdev);
  311. pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl);
  312. pci_config_pm_runtime_put(pdev);
  313. ctrl_dbg(ctrl, "%s: SLOTCTRL %x, value read %x\n", __func__,
  314. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_ctrl);
  315. switch (slot_ctrl & PCI_EXP_SLTCTL_AIC) {
  316. case PCI_EXP_SLTCTL_ATTN_IND_ON:
  317. *status = 1; /* On */
  318. break;
  319. case PCI_EXP_SLTCTL_ATTN_IND_BLINK:
  320. *status = 2; /* Blink */
  321. break;
  322. case PCI_EXP_SLTCTL_ATTN_IND_OFF:
  323. *status = 0; /* Off */
  324. break;
  325. default:
  326. *status = 0xFF;
  327. break;
  328. }
  329. return 0;
  330. }
  331. void pciehp_get_power_status(struct controller *ctrl, u8 *status)
  332. {
  333. struct pci_dev *pdev = ctrl_dev(ctrl);
  334. u16 slot_ctrl;
  335. pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl);
  336. ctrl_dbg(ctrl, "%s: SLOTCTRL %x value read %x\n", __func__,
  337. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_ctrl);
  338. switch (slot_ctrl & PCI_EXP_SLTCTL_PCC) {
  339. case PCI_EXP_SLTCTL_PWR_ON:
  340. *status = 1; /* On */
  341. break;
  342. case PCI_EXP_SLTCTL_PWR_OFF:
  343. *status = 0; /* Off */
  344. break;
  345. default:
  346. *status = 0xFF;
  347. break;
  348. }
  349. }
  350. void pciehp_get_latch_status(struct controller *ctrl, u8 *status)
  351. {
  352. struct pci_dev *pdev = ctrl_dev(ctrl);
  353. u16 slot_status;
  354. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  355. *status = !!(slot_status & PCI_EXP_SLTSTA_MRLSS);
  356. }
  357. /**
  358. * pciehp_card_present() - Is the card present
  359. * @ctrl: PCIe hotplug controller
  360. *
  361. * Function checks whether the card is currently present in the slot and
  362. * in that case returns true. Note it is possible that the card is
  363. * removed immediately after the check so the caller may need to take
  364. * this into account.
  365. *
  366. * It the hotplug controller itself is not available anymore returns
  367. * %-ENODEV.
  368. */
  369. int pciehp_card_present(struct controller *ctrl)
  370. {
  371. struct pci_dev *pdev = ctrl_dev(ctrl);
  372. u16 slot_status;
  373. int ret;
  374. ret = pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  375. if (ret == PCIBIOS_DEVICE_NOT_FOUND || PCI_POSSIBLE_ERROR(slot_status))
  376. return -ENODEV;
  377. return !!(slot_status & PCI_EXP_SLTSTA_PDS);
  378. }
  379. /**
  380. * pciehp_card_present_or_link_active() - whether given slot is occupied
  381. * @ctrl: PCIe hotplug controller
  382. *
  383. * Unlike pciehp_card_present(), which determines presence solely from the
  384. * Presence Detect State bit, this helper also returns true if the Link Active
  385. * bit is set. This is a concession to broken hotplug ports which hardwire
  386. * Presence Detect State to zero, such as Wilocity's [1ae9:0200].
  387. *
  388. * Returns: %1 if the slot is occupied and %0 if it is not. If the hotplug
  389. * port is not present anymore returns %-ENODEV.
  390. */
  391. int pciehp_card_present_or_link_active(struct controller *ctrl)
  392. {
  393. int ret;
  394. ret = pciehp_card_present(ctrl);
  395. if (ret)
  396. return ret;
  397. return pciehp_check_link_active(ctrl);
  398. }
  399. int pciehp_query_power_fault(struct controller *ctrl)
  400. {
  401. struct pci_dev *pdev = ctrl_dev(ctrl);
  402. u16 slot_status;
  403. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  404. return !!(slot_status & PCI_EXP_SLTSTA_PFD);
  405. }
  406. int pciehp_set_raw_indicator_status(struct hotplug_slot *hotplug_slot,
  407. u8 status)
  408. {
  409. struct controller *ctrl = to_ctrl(hotplug_slot);
  410. struct pci_dev *pdev = ctrl_dev(ctrl);
  411. pci_config_pm_runtime_get(pdev);
  412. /* Attention and Power Indicator Control bits are supported */
  413. pcie_write_cmd_nowait(ctrl, FIELD_PREP(PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC, status),
  414. PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC);
  415. pci_config_pm_runtime_put(pdev);
  416. return 0;
  417. }
  418. /**
  419. * pciehp_set_indicators() - set attention indicator, power indicator, or both
  420. * @ctrl: PCIe hotplug controller
  421. * @pwr: one of:
  422. * PCI_EXP_SLTCTL_PWR_IND_ON
  423. * PCI_EXP_SLTCTL_PWR_IND_BLINK
  424. * PCI_EXP_SLTCTL_PWR_IND_OFF
  425. * @attn: one of:
  426. * PCI_EXP_SLTCTL_ATTN_IND_ON
  427. * PCI_EXP_SLTCTL_ATTN_IND_BLINK
  428. * PCI_EXP_SLTCTL_ATTN_IND_OFF
  429. *
  430. * Either @pwr or @attn can also be INDICATOR_NOOP to leave that indicator
  431. * unchanged.
  432. */
  433. void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn)
  434. {
  435. u16 cmd = 0, mask = 0;
  436. if (PWR_LED(ctrl) && pwr != INDICATOR_NOOP) {
  437. cmd |= (pwr & PCI_EXP_SLTCTL_PIC);
  438. mask |= PCI_EXP_SLTCTL_PIC;
  439. }
  440. if (ATTN_LED(ctrl) && attn != INDICATOR_NOOP) {
  441. cmd |= (attn & PCI_EXP_SLTCTL_AIC);
  442. mask |= PCI_EXP_SLTCTL_AIC;
  443. }
  444. if (cmd) {
  445. pcie_write_cmd_nowait(ctrl, cmd, mask);
  446. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  447. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd);
  448. }
  449. }
  450. int pciehp_power_on_slot(struct controller *ctrl)
  451. {
  452. struct pci_dev *pdev = ctrl_dev(ctrl);
  453. u16 slot_status;
  454. int retval;
  455. /* Clear power-fault bit from previous power failures */
  456. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
  457. if (slot_status & PCI_EXP_SLTSTA_PFD)
  458. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
  459. PCI_EXP_SLTSTA_PFD);
  460. ctrl->power_fault_detected = 0;
  461. pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_ON, PCI_EXP_SLTCTL_PCC);
  462. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  463. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
  464. PCI_EXP_SLTCTL_PWR_ON);
  465. retval = pciehp_link_enable(ctrl);
  466. if (retval)
  467. ctrl_err(ctrl, "%s: Can not enable the link!\n", __func__);
  468. return retval;
  469. }
  470. void pciehp_power_off_slot(struct controller *ctrl)
  471. {
  472. pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_OFF, PCI_EXP_SLTCTL_PCC);
  473. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  474. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
  475. PCI_EXP_SLTCTL_PWR_OFF);
  476. }
  477. static void pciehp_ignore_dpc_link_change(struct controller *ctrl,
  478. struct pci_dev *pdev, int irq)
  479. {
  480. /*
  481. * Ignore link changes which occurred while waiting for DPC recovery.
  482. * Could be several if DPC triggered multiple times consecutively.
  483. */
  484. synchronize_hardirq(irq);
  485. atomic_and(~PCI_EXP_SLTSTA_DLLSC, &ctrl->pending_events);
  486. if (pciehp_poll_mode)
  487. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
  488. PCI_EXP_SLTSTA_DLLSC);
  489. ctrl_info(ctrl, "Slot(%s): Link Down/Up ignored (recovered by DPC)\n",
  490. slot_name(ctrl));
  491. /*
  492. * If the link is unexpectedly down after successful recovery,
  493. * the corresponding link change may have been ignored above.
  494. * Synthesize it to ensure that it is acted on.
  495. */
  496. down_read_nested(&ctrl->reset_lock, ctrl->depth);
  497. if (!pciehp_check_link_active(ctrl))
  498. pciehp_request(ctrl, PCI_EXP_SLTSTA_DLLSC);
  499. up_read(&ctrl->reset_lock);
  500. }
  501. static irqreturn_t pciehp_isr(int irq, void *dev_id)
  502. {
  503. struct controller *ctrl = (struct controller *)dev_id;
  504. struct pci_dev *pdev = ctrl_dev(ctrl);
  505. struct device *parent = pdev->dev.parent;
  506. u16 status, events = 0;
  507. /*
  508. * Interrupts only occur in D3hot or shallower and only if enabled
  509. * in the Slot Control register (PCIe r4.0, sec 6.7.3.4).
  510. */
  511. if (pdev->current_state == PCI_D3cold ||
  512. (!(ctrl->slot_ctrl & PCI_EXP_SLTCTL_HPIE) && !pciehp_poll_mode))
  513. return IRQ_NONE;
  514. /*
  515. * Keep the port accessible by holding a runtime PM ref on its parent.
  516. * Defer resume of the parent to the IRQ thread if it's suspended.
  517. * Mask the interrupt until then.
  518. */
  519. if (parent) {
  520. pm_runtime_get_noresume(parent);
  521. if (!pm_runtime_active(parent)) {
  522. pm_runtime_put(parent);
  523. disable_irq_nosync(irq);
  524. atomic_or(RERUN_ISR, &ctrl->pending_events);
  525. return IRQ_WAKE_THREAD;
  526. }
  527. }
  528. read_status:
  529. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &status);
  530. if (PCI_POSSIBLE_ERROR(status)) {
  531. ctrl_info(ctrl, "%s: no response from device\n", __func__);
  532. if (parent)
  533. pm_runtime_put(parent);
  534. return IRQ_NONE;
  535. }
  536. /*
  537. * Slot Status contains plain status bits as well as event
  538. * notification bits; right now we only want the event bits.
  539. */
  540. status &= PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
  541. PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_CC |
  542. PCI_EXP_SLTSTA_DLLSC;
  543. /*
  544. * If we've already reported a power fault, don't report it again
  545. * until we've done something to handle it.
  546. */
  547. if (ctrl->power_fault_detected)
  548. status &= ~PCI_EXP_SLTSTA_PFD;
  549. else if (status & PCI_EXP_SLTSTA_PFD)
  550. ctrl->power_fault_detected = true;
  551. events |= status;
  552. if (!events) {
  553. if (parent)
  554. pm_runtime_put(parent);
  555. return IRQ_NONE;
  556. }
  557. if (status) {
  558. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, status);
  559. /*
  560. * In MSI mode, all event bits must be zero before the port
  561. * will send a new interrupt (PCIe Base Spec r5.0 sec 6.7.3.4).
  562. * So re-read the Slot Status register in case a bit was set
  563. * between read and write.
  564. */
  565. if (pci_dev_msi_enabled(pdev) && !pciehp_poll_mode)
  566. goto read_status;
  567. }
  568. ctrl_dbg(ctrl, "pending interrupts %#06x from Slot Status\n", events);
  569. if (parent)
  570. pm_runtime_put(parent);
  571. /*
  572. * Command Completed notifications are not deferred to the
  573. * IRQ thread because it may be waiting for their arrival.
  574. */
  575. if (events & PCI_EXP_SLTSTA_CC) {
  576. ctrl->cmd_busy = 0;
  577. smp_mb();
  578. wake_up(&ctrl->queue);
  579. if (events == PCI_EXP_SLTSTA_CC)
  580. return IRQ_HANDLED;
  581. events &= ~PCI_EXP_SLTSTA_CC;
  582. }
  583. if (pdev->ignore_hotplug) {
  584. ctrl_dbg(ctrl, "ignoring hotplug event %#06x\n", events);
  585. return IRQ_HANDLED;
  586. }
  587. /* Save pending events for consumption by IRQ thread. */
  588. atomic_or(events, &ctrl->pending_events);
  589. return IRQ_WAKE_THREAD;
  590. }
  591. static irqreturn_t pciehp_ist(int irq, void *dev_id)
  592. {
  593. struct controller *ctrl = (struct controller *)dev_id;
  594. struct pci_dev *pdev = ctrl_dev(ctrl);
  595. irqreturn_t ret;
  596. u32 events;
  597. ctrl->ist_running = true;
  598. pci_config_pm_runtime_get(pdev);
  599. /* rerun pciehp_isr() if the port was inaccessible on interrupt */
  600. if (atomic_fetch_and(~RERUN_ISR, &ctrl->pending_events) & RERUN_ISR) {
  601. ret = pciehp_isr(irq, dev_id);
  602. enable_irq(irq);
  603. if (ret != IRQ_WAKE_THREAD)
  604. goto out;
  605. }
  606. synchronize_hardirq(irq);
  607. events = atomic_xchg(&ctrl->pending_events, 0);
  608. if (!events) {
  609. ret = IRQ_NONE;
  610. goto out;
  611. }
  612. /* Check Attention Button Pressed */
  613. if (events & PCI_EXP_SLTSTA_ABP)
  614. pciehp_handle_button_press(ctrl);
  615. /* Check Power Fault Detected */
  616. if (events & PCI_EXP_SLTSTA_PFD) {
  617. ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(ctrl));
  618. pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF,
  619. PCI_EXP_SLTCTL_ATTN_IND_ON);
  620. }
  621. /*
  622. * Ignore Link Down/Up events caused by Downstream Port Containment
  623. * if recovery from the error succeeded.
  624. */
  625. if ((events & PCI_EXP_SLTSTA_DLLSC) && pci_dpc_recovered(pdev) &&
  626. ctrl->state == ON_STATE) {
  627. events &= ~PCI_EXP_SLTSTA_DLLSC;
  628. pciehp_ignore_dpc_link_change(ctrl, pdev, irq);
  629. }
  630. /*
  631. * Disable requests have higher priority than Presence Detect Changed
  632. * or Data Link Layer State Changed events.
  633. */
  634. down_read_nested(&ctrl->reset_lock, ctrl->depth);
  635. if (events & DISABLE_SLOT)
  636. pciehp_handle_disable_request(ctrl);
  637. else if (events & (PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC))
  638. pciehp_handle_presence_or_link_change(ctrl, events);
  639. up_read(&ctrl->reset_lock);
  640. ret = IRQ_HANDLED;
  641. out:
  642. pci_config_pm_runtime_put(pdev);
  643. ctrl->ist_running = false;
  644. wake_up(&ctrl->requester);
  645. return ret;
  646. }
  647. static int pciehp_poll(void *data)
  648. {
  649. struct controller *ctrl = data;
  650. schedule_timeout_idle(10 * HZ); /* start with 10 sec delay */
  651. while (!kthread_should_stop()) {
  652. /* poll for interrupt events or user requests */
  653. while (pciehp_isr(IRQ_NOTCONNECTED, ctrl) == IRQ_WAKE_THREAD ||
  654. atomic_read(&ctrl->pending_events))
  655. pciehp_ist(IRQ_NOTCONNECTED, ctrl);
  656. if (pciehp_poll_time <= 0 || pciehp_poll_time > 60)
  657. pciehp_poll_time = 2; /* clamp to sane value */
  658. schedule_timeout_idle(pciehp_poll_time * HZ);
  659. }
  660. return 0;
  661. }
  662. static void pcie_enable_notification(struct controller *ctrl)
  663. {
  664. u16 cmd, mask;
  665. /*
  666. * TBD: Power fault detected software notification support.
  667. *
  668. * Power fault detected software notification is not enabled
  669. * now, because it caused power fault detected interrupt storm
  670. * on some machines. On those machines, power fault detected
  671. * bit in the slot status register was set again immediately
  672. * when it is cleared in the interrupt service routine, and
  673. * next power fault detected interrupt was notified again.
  674. */
  675. /*
  676. * Always enable link events: thus link-up and link-down shall
  677. * always be treated as hotplug and unplug respectively. Enable
  678. * presence detect only if Attention Button is not present.
  679. */
  680. cmd = PCI_EXP_SLTCTL_DLLSCE;
  681. if (ATTN_BUTTN(ctrl))
  682. cmd |= PCI_EXP_SLTCTL_ABPE;
  683. else
  684. cmd |= PCI_EXP_SLTCTL_PDCE;
  685. if (!pciehp_poll_mode)
  686. cmd |= PCI_EXP_SLTCTL_HPIE;
  687. if (!pciehp_poll_mode && !NO_CMD_CMPL(ctrl))
  688. cmd |= PCI_EXP_SLTCTL_CCIE;
  689. mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE |
  690. PCI_EXP_SLTCTL_PFDE |
  691. PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE |
  692. PCI_EXP_SLTCTL_DLLSCE);
  693. pcie_write_cmd_nowait(ctrl, cmd, mask);
  694. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  695. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd);
  696. }
  697. static void pcie_disable_notification(struct controller *ctrl)
  698. {
  699. u16 mask;
  700. mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE |
  701. PCI_EXP_SLTCTL_MRLSCE | PCI_EXP_SLTCTL_PFDE |
  702. PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE |
  703. PCI_EXP_SLTCTL_DLLSCE);
  704. pcie_write_cmd(ctrl, 0, mask);
  705. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  706. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, 0);
  707. }
  708. void pcie_clear_hotplug_events(struct controller *ctrl)
  709. {
  710. pcie_capability_write_word(ctrl_dev(ctrl), PCI_EXP_SLTSTA,
  711. PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC);
  712. }
  713. void pcie_enable_interrupt(struct controller *ctrl)
  714. {
  715. u16 mask;
  716. mask = PCI_EXP_SLTCTL_DLLSCE;
  717. if (!pciehp_poll_mode)
  718. mask |= PCI_EXP_SLTCTL_HPIE;
  719. pcie_write_cmd(ctrl, mask, mask);
  720. }
  721. void pcie_disable_interrupt(struct controller *ctrl)
  722. {
  723. u16 mask;
  724. /*
  725. * Mask hot-plug interrupt to prevent it triggering immediately
  726. * when the link goes inactive (we still get PME when any of the
  727. * enabled events is detected). Same goes with Link Layer State
  728. * changed event which generates PME immediately when the link goes
  729. * inactive so mask it as well.
  730. */
  731. mask = PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_DLLSCE;
  732. pcie_write_cmd(ctrl, 0, mask);
  733. }
  734. /**
  735. * pciehp_slot_reset() - ignore link event caused by error-induced hot reset
  736. * @dev: PCI Express port service device
  737. *
  738. * Called from pcie_portdrv_slot_reset() after AER or DPC initiated a reset
  739. * further up in the hierarchy to recover from an error. The reset was
  740. * propagated down to this hotplug port. Ignore the resulting link flap.
  741. * If the link failed to retrain successfully, synthesize the ignored event.
  742. * Surprise removal during reset is detected through Presence Detect Changed.
  743. */
  744. int pciehp_slot_reset(struct pcie_device *dev)
  745. {
  746. struct controller *ctrl = get_service_data(dev);
  747. if (ctrl->state != ON_STATE)
  748. return 0;
  749. pcie_capability_write_word(dev->port, PCI_EXP_SLTSTA,
  750. PCI_EXP_SLTSTA_DLLSC);
  751. if (!pciehp_check_link_active(ctrl))
  752. pciehp_request(ctrl, PCI_EXP_SLTSTA_DLLSC);
  753. return 0;
  754. }
  755. /*
  756. * pciehp has a 1:1 bus:slot relationship so we ultimately want a secondary
  757. * bus reset of the bridge, but at the same time we want to ensure that it is
  758. * not seen as a hot-unplug, followed by the hot-plug of the device. Thus,
  759. * disable link state notification and presence detection change notification
  760. * momentarily, if we see that they could interfere. Also, clear any spurious
  761. * events after.
  762. */
  763. int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, bool probe)
  764. {
  765. struct controller *ctrl = to_ctrl(hotplug_slot);
  766. struct pci_dev *pdev = ctrl_dev(ctrl);
  767. u16 stat_mask = 0, ctrl_mask = 0;
  768. int rc;
  769. if (probe)
  770. return 0;
  771. down_write_nested(&ctrl->reset_lock, ctrl->depth);
  772. if (!ATTN_BUTTN(ctrl)) {
  773. ctrl_mask |= PCI_EXP_SLTCTL_PDCE;
  774. stat_mask |= PCI_EXP_SLTSTA_PDC;
  775. }
  776. ctrl_mask |= PCI_EXP_SLTCTL_DLLSCE;
  777. stat_mask |= PCI_EXP_SLTSTA_DLLSC;
  778. pcie_write_cmd(ctrl, 0, ctrl_mask);
  779. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  780. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, 0);
  781. rc = pci_bridge_secondary_bus_reset(ctrl->pcie->port);
  782. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask);
  783. pcie_write_cmd_nowait(ctrl, ctrl_mask, ctrl_mask);
  784. ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  785. pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, ctrl_mask);
  786. up_write(&ctrl->reset_lock);
  787. return rc;
  788. }
  789. int pcie_init_notification(struct controller *ctrl)
  790. {
  791. if (pciehp_request_irq(ctrl))
  792. return -1;
  793. pcie_enable_notification(ctrl);
  794. ctrl->notification_enabled = 1;
  795. return 0;
  796. }
  797. void pcie_shutdown_notification(struct controller *ctrl)
  798. {
  799. if (ctrl->notification_enabled) {
  800. pcie_disable_notification(ctrl);
  801. pciehp_free_irq(ctrl);
  802. ctrl->notification_enabled = 0;
  803. }
  804. }
  805. static inline void dbg_ctrl(struct controller *ctrl)
  806. {
  807. struct pci_dev *pdev = ctrl->pcie->port;
  808. u16 reg16;
  809. ctrl_dbg(ctrl, "Slot Capabilities : 0x%08x\n", ctrl->slot_cap);
  810. pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &reg16);
  811. ctrl_dbg(ctrl, "Slot Status : 0x%04x\n", reg16);
  812. pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &reg16);
  813. ctrl_dbg(ctrl, "Slot Control : 0x%04x\n", reg16);
  814. }
  815. #define FLAG(x, y) (((x) & (y)) ? '+' : '-')
  816. static inline int pcie_hotplug_depth(struct pci_dev *dev)
  817. {
  818. struct pci_bus *bus = dev->bus;
  819. int depth = 0;
  820. while (bus->parent) {
  821. bus = bus->parent;
  822. if (bus->self && bus->self->is_hotplug_bridge)
  823. depth++;
  824. }
  825. return depth;
  826. }
  827. struct controller *pcie_init(struct pcie_device *dev)
  828. {
  829. struct controller *ctrl;
  830. u32 slot_cap, slot_cap2;
  831. u8 poweron;
  832. struct pci_dev *pdev = dev->port;
  833. struct pci_bus *subordinate = pdev->subordinate;
  834. ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
  835. if (!ctrl)
  836. return NULL;
  837. ctrl->pcie = dev;
  838. ctrl->depth = pcie_hotplug_depth(dev->port);
  839. pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap);
  840. if (pdev->hotplug_user_indicators)
  841. slot_cap &= ~(PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_PIP);
  842. /*
  843. * We assume no Thunderbolt controllers support Command Complete events,
  844. * but some controllers falsely claim they do.
  845. */
  846. if (pdev->is_thunderbolt)
  847. slot_cap |= PCI_EXP_SLTCAP_NCCS;
  848. ctrl->slot_cap = slot_cap;
  849. mutex_init(&ctrl->ctrl_lock);
  850. mutex_init(&ctrl->state_lock);
  851. init_rwsem(&ctrl->reset_lock);
  852. init_waitqueue_head(&ctrl->requester);
  853. init_waitqueue_head(&ctrl->queue);
  854. INIT_DELAYED_WORK(&ctrl->button_work, pciehp_queue_pushbutton_work);
  855. dbg_ctrl(ctrl);
  856. down_read(&pci_bus_sem);
  857. ctrl->state = list_empty(&subordinate->devices) ? OFF_STATE : ON_STATE;
  858. up_read(&pci_bus_sem);
  859. pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP2, &slot_cap2);
  860. if (slot_cap2 & PCI_EXP_SLTCAP2_IBPD) {
  861. pcie_write_cmd_nowait(ctrl, PCI_EXP_SLTCTL_IBPD_DISABLE,
  862. PCI_EXP_SLTCTL_IBPD_DISABLE);
  863. ctrl->inband_presence_disabled = 1;
  864. }
  865. if (dmi_first_match(inband_presence_disabled_dmi_table))
  866. ctrl->inband_presence_disabled = 1;
  867. /* Clear all remaining event bits in Slot Status register. */
  868. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
  869. PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
  870. PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_CC |
  871. PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC);
  872. 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",
  873. FIELD_GET(PCI_EXP_SLTCAP_PSN, slot_cap),
  874. FLAG(slot_cap, PCI_EXP_SLTCAP_ABP),
  875. FLAG(slot_cap, PCI_EXP_SLTCAP_PCP),
  876. FLAG(slot_cap, PCI_EXP_SLTCAP_MRLSP),
  877. FLAG(slot_cap, PCI_EXP_SLTCAP_AIP),
  878. FLAG(slot_cap, PCI_EXP_SLTCAP_PIP),
  879. FLAG(slot_cap, PCI_EXP_SLTCAP_HPC),
  880. FLAG(slot_cap, PCI_EXP_SLTCAP_HPS),
  881. FLAG(slot_cap, PCI_EXP_SLTCAP_EIP),
  882. FLAG(slot_cap, PCI_EXP_SLTCAP_NCCS),
  883. FLAG(slot_cap2, PCI_EXP_SLTCAP2_IBPD),
  884. FLAG(pdev->link_active_reporting, true),
  885. pdev->broken_cmd_compl ? " (with Cmd Compl erratum)" : "");
  886. /*
  887. * If empty slot's power status is on, turn power off. The IRQ isn't
  888. * requested yet, so avoid triggering a notification with this command.
  889. */
  890. if (POWER_CTRL(ctrl)) {
  891. pciehp_get_power_status(ctrl, &poweron);
  892. if (!pciehp_card_present_or_link_active(ctrl) && poweron) {
  893. pcie_disable_notification(ctrl);
  894. pciehp_power_off_slot(ctrl);
  895. }
  896. }
  897. pdev = pci_get_slot(subordinate, PCI_DEVFN(0, 0));
  898. if (pdev)
  899. ctrl->dsn = pci_get_dsn(pdev);
  900. pci_dev_put(pdev);
  901. return ctrl;
  902. }
  903. void pciehp_release_ctrl(struct controller *ctrl)
  904. {
  905. cancel_delayed_work_sync(&ctrl->button_work);
  906. kfree(ctrl);
  907. }
  908. static void quirk_cmd_compl(struct pci_dev *pdev)
  909. {
  910. u32 slot_cap;
  911. if (pci_is_pcie(pdev)) {
  912. pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap);
  913. if (slot_cap & PCI_EXP_SLTCAP_HPC &&
  914. !(slot_cap & PCI_EXP_SLTCAP_NCCS))
  915. pdev->broken_cmd_compl = 1;
  916. }
  917. }
  918. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
  919. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  920. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x010e,
  921. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  922. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0110,
  923. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  924. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0400,
  925. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  926. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0401,
  927. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);
  928. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_HXT, 0x0401,
  929. PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl);