intr_remapping.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. #include <linux/interrupt.h>
  2. #include <linux/dmar.h>
  3. #include <linux/spinlock.h>
  4. #include <linux/jiffies.h>
  5. #include <linux/pci.h>
  6. #include <linux/irq.h>
  7. #include <asm/io_apic.h>
  8. #include <asm/smp.h>
  9. #include <asm/cpu.h>
  10. #include <linux/intel-iommu.h>
  11. #include "intr_remapping.h"
  12. #include <acpi/acpi.h>
  13. static struct ioapic_scope ir_ioapic[MAX_IO_APICS];
  14. static int ir_ioapic_num;
  15. int intr_remapping_enabled;
  16. struct irq_2_iommu {
  17. struct intel_iommu *iommu;
  18. u16 irte_index;
  19. u16 sub_handle;
  20. u8 irte_mask;
  21. };
  22. #ifdef CONFIG_GENERIC_HARDIRQS
  23. static struct irq_2_iommu *get_one_free_irq_2_iommu(int cpu)
  24. {
  25. struct irq_2_iommu *iommu;
  26. int node;
  27. node = cpu_to_node(cpu);
  28. iommu = kzalloc_node(sizeof(*iommu), GFP_ATOMIC, node);
  29. printk(KERN_DEBUG "alloc irq_2_iommu on cpu %d node %d\n", cpu, node);
  30. return iommu;
  31. }
  32. static struct irq_2_iommu *irq_2_iommu(unsigned int irq)
  33. {
  34. struct irq_desc *desc;
  35. desc = irq_to_desc(irq);
  36. if (WARN_ON_ONCE(!desc))
  37. return NULL;
  38. return desc->irq_2_iommu;
  39. }
  40. static struct irq_2_iommu *irq_2_iommu_alloc_cpu(unsigned int irq, int cpu)
  41. {
  42. struct irq_desc *desc;
  43. struct irq_2_iommu *irq_iommu;
  44. /*
  45. * alloc irq desc if not allocated already.
  46. */
  47. desc = irq_to_desc_alloc_cpu(irq, cpu);
  48. if (!desc) {
  49. printk(KERN_INFO "can not get irq_desc for %d\n", irq);
  50. return NULL;
  51. }
  52. irq_iommu = desc->irq_2_iommu;
  53. if (!irq_iommu)
  54. desc->irq_2_iommu = get_one_free_irq_2_iommu(cpu);
  55. return desc->irq_2_iommu;
  56. }
  57. static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq)
  58. {
  59. return irq_2_iommu_alloc_cpu(irq, boot_cpu_id);
  60. }
  61. #else /* !CONFIG_SPARSE_IRQ */
  62. static struct irq_2_iommu irq_2_iommuX[NR_IRQS];
  63. static struct irq_2_iommu *irq_2_iommu(unsigned int irq)
  64. {
  65. if (irq < nr_irqs)
  66. return &irq_2_iommuX[irq];
  67. return NULL;
  68. }
  69. static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq)
  70. {
  71. return irq_2_iommu(irq);
  72. }
  73. #endif
  74. static DEFINE_SPINLOCK(irq_2_ir_lock);
  75. static struct irq_2_iommu *valid_irq_2_iommu(unsigned int irq)
  76. {
  77. struct irq_2_iommu *irq_iommu;
  78. irq_iommu = irq_2_iommu(irq);
  79. if (!irq_iommu)
  80. return NULL;
  81. if (!irq_iommu->iommu)
  82. return NULL;
  83. return irq_iommu;
  84. }
  85. int irq_remapped(int irq)
  86. {
  87. return valid_irq_2_iommu(irq) != NULL;
  88. }
  89. int get_irte(int irq, struct irte *entry)
  90. {
  91. int index;
  92. struct irq_2_iommu *irq_iommu;
  93. unsigned long flags;
  94. if (!entry)
  95. return -1;
  96. spin_lock_irqsave(&irq_2_ir_lock, flags);
  97. irq_iommu = valid_irq_2_iommu(irq);
  98. if (!irq_iommu) {
  99. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  100. return -1;
  101. }
  102. index = irq_iommu->irte_index + irq_iommu->sub_handle;
  103. *entry = *(irq_iommu->iommu->ir_table->base + index);
  104. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  105. return 0;
  106. }
  107. int alloc_irte(struct intel_iommu *iommu, int irq, u16 count)
  108. {
  109. struct ir_table *table = iommu->ir_table;
  110. struct irq_2_iommu *irq_iommu;
  111. u16 index, start_index;
  112. unsigned int mask = 0;
  113. unsigned long flags;
  114. int i;
  115. if (!count)
  116. return -1;
  117. #ifndef CONFIG_SPARSE_IRQ
  118. /* protect irq_2_iommu_alloc later */
  119. if (irq >= nr_irqs)
  120. return -1;
  121. #endif
  122. /*
  123. * start the IRTE search from index 0.
  124. */
  125. index = start_index = 0;
  126. if (count > 1) {
  127. count = __roundup_pow_of_two(count);
  128. mask = ilog2(count);
  129. }
  130. if (mask > ecap_max_handle_mask(iommu->ecap)) {
  131. printk(KERN_ERR
  132. "Requested mask %x exceeds the max invalidation handle"
  133. " mask value %Lx\n", mask,
  134. ecap_max_handle_mask(iommu->ecap));
  135. return -1;
  136. }
  137. spin_lock_irqsave(&irq_2_ir_lock, flags);
  138. do {
  139. for (i = index; i < index + count; i++)
  140. if (table->base[i].present)
  141. break;
  142. /* empty index found */
  143. if (i == index + count)
  144. break;
  145. index = (index + count) % INTR_REMAP_TABLE_ENTRIES;
  146. if (index == start_index) {
  147. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  148. printk(KERN_ERR "can't allocate an IRTE\n");
  149. return -1;
  150. }
  151. } while (1);
  152. for (i = index; i < index + count; i++)
  153. table->base[i].present = 1;
  154. irq_iommu = irq_2_iommu_alloc(irq);
  155. if (!irq_iommu) {
  156. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  157. printk(KERN_ERR "can't allocate irq_2_iommu\n");
  158. return -1;
  159. }
  160. irq_iommu->iommu = iommu;
  161. irq_iommu->irte_index = index;
  162. irq_iommu->sub_handle = 0;
  163. irq_iommu->irte_mask = mask;
  164. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  165. return index;
  166. }
  167. static int qi_flush_iec(struct intel_iommu *iommu, int index, int mask)
  168. {
  169. struct qi_desc desc;
  170. desc.low = QI_IEC_IIDEX(index) | QI_IEC_TYPE | QI_IEC_IM(mask)
  171. | QI_IEC_SELECTIVE;
  172. desc.high = 0;
  173. return qi_submit_sync(&desc, iommu);
  174. }
  175. int map_irq_to_irte_handle(int irq, u16 *sub_handle)
  176. {
  177. int index;
  178. struct irq_2_iommu *irq_iommu;
  179. unsigned long flags;
  180. spin_lock_irqsave(&irq_2_ir_lock, flags);
  181. irq_iommu = valid_irq_2_iommu(irq);
  182. if (!irq_iommu) {
  183. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  184. return -1;
  185. }
  186. *sub_handle = irq_iommu->sub_handle;
  187. index = irq_iommu->irte_index;
  188. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  189. return index;
  190. }
  191. int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, u16 subhandle)
  192. {
  193. struct irq_2_iommu *irq_iommu;
  194. unsigned long flags;
  195. spin_lock_irqsave(&irq_2_ir_lock, flags);
  196. irq_iommu = irq_2_iommu_alloc(irq);
  197. if (!irq_iommu) {
  198. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  199. printk(KERN_ERR "can't allocate irq_2_iommu\n");
  200. return -1;
  201. }
  202. irq_iommu->iommu = iommu;
  203. irq_iommu->irte_index = index;
  204. irq_iommu->sub_handle = subhandle;
  205. irq_iommu->irte_mask = 0;
  206. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  207. return 0;
  208. }
  209. int clear_irte_irq(int irq, struct intel_iommu *iommu, u16 index)
  210. {
  211. struct irq_2_iommu *irq_iommu;
  212. unsigned long flags;
  213. spin_lock_irqsave(&irq_2_ir_lock, flags);
  214. irq_iommu = valid_irq_2_iommu(irq);
  215. if (!irq_iommu) {
  216. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  217. return -1;
  218. }
  219. irq_iommu->iommu = NULL;
  220. irq_iommu->irte_index = 0;
  221. irq_iommu->sub_handle = 0;
  222. irq_2_iommu(irq)->irte_mask = 0;
  223. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  224. return 0;
  225. }
  226. int modify_irte(int irq, struct irte *irte_modified)
  227. {
  228. int rc;
  229. int index;
  230. struct irte *irte;
  231. struct intel_iommu *iommu;
  232. struct irq_2_iommu *irq_iommu;
  233. unsigned long flags;
  234. spin_lock_irqsave(&irq_2_ir_lock, flags);
  235. irq_iommu = valid_irq_2_iommu(irq);
  236. if (!irq_iommu) {
  237. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  238. return -1;
  239. }
  240. iommu = irq_iommu->iommu;
  241. index = irq_iommu->irte_index + irq_iommu->sub_handle;
  242. irte = &iommu->ir_table->base[index];
  243. set_64bit((unsigned long *)irte, irte_modified->low);
  244. __iommu_flush_cache(iommu, irte, sizeof(*irte));
  245. rc = qi_flush_iec(iommu, index, 0);
  246. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  247. return rc;
  248. }
  249. int flush_irte(int irq)
  250. {
  251. int rc;
  252. int index;
  253. struct intel_iommu *iommu;
  254. struct irq_2_iommu *irq_iommu;
  255. unsigned long flags;
  256. spin_lock_irqsave(&irq_2_ir_lock, flags);
  257. irq_iommu = valid_irq_2_iommu(irq);
  258. if (!irq_iommu) {
  259. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  260. return -1;
  261. }
  262. iommu = irq_iommu->iommu;
  263. index = irq_iommu->irte_index + irq_iommu->sub_handle;
  264. rc = qi_flush_iec(iommu, index, irq_iommu->irte_mask);
  265. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  266. return rc;
  267. }
  268. struct intel_iommu *map_ioapic_to_ir(int apic)
  269. {
  270. int i;
  271. for (i = 0; i < MAX_IO_APICS; i++)
  272. if (ir_ioapic[i].id == apic)
  273. return ir_ioapic[i].iommu;
  274. return NULL;
  275. }
  276. struct intel_iommu *map_dev_to_ir(struct pci_dev *dev)
  277. {
  278. struct dmar_drhd_unit *drhd;
  279. drhd = dmar_find_matched_drhd_unit(dev);
  280. if (!drhd)
  281. return NULL;
  282. return drhd->iommu;
  283. }
  284. int free_irte(int irq)
  285. {
  286. int rc = 0;
  287. int index, i;
  288. struct irte *irte;
  289. struct intel_iommu *iommu;
  290. struct irq_2_iommu *irq_iommu;
  291. unsigned long flags;
  292. spin_lock_irqsave(&irq_2_ir_lock, flags);
  293. irq_iommu = valid_irq_2_iommu(irq);
  294. if (!irq_iommu) {
  295. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  296. return -1;
  297. }
  298. iommu = irq_iommu->iommu;
  299. index = irq_iommu->irte_index + irq_iommu->sub_handle;
  300. irte = &iommu->ir_table->base[index];
  301. if (!irq_iommu->sub_handle) {
  302. for (i = 0; i < (1 << irq_iommu->irte_mask); i++)
  303. set_64bit((unsigned long *)(irte + i), 0);
  304. rc = qi_flush_iec(iommu, index, irq_iommu->irte_mask);
  305. }
  306. irq_iommu->iommu = NULL;
  307. irq_iommu->irte_index = 0;
  308. irq_iommu->sub_handle = 0;
  309. irq_iommu->irte_mask = 0;
  310. spin_unlock_irqrestore(&irq_2_ir_lock, flags);
  311. return rc;
  312. }
  313. static void iommu_set_intr_remapping(struct intel_iommu *iommu, int mode)
  314. {
  315. u64 addr;
  316. u32 cmd, sts;
  317. unsigned long flags;
  318. addr = virt_to_phys((void *)iommu->ir_table->base);
  319. spin_lock_irqsave(&iommu->register_lock, flags);
  320. dmar_writeq(iommu->reg + DMAR_IRTA_REG,
  321. (addr) | IR_X2APIC_MODE(mode) | INTR_REMAP_TABLE_REG_SIZE);
  322. /* Set interrupt-remapping table pointer */
  323. cmd = iommu->gcmd | DMA_GCMD_SIRTP;
  324. iommu->gcmd |= DMA_GCMD_SIRTP;
  325. writel(cmd, iommu->reg + DMAR_GCMD_REG);
  326. IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
  327. readl, (sts & DMA_GSTS_IRTPS), sts);
  328. spin_unlock_irqrestore(&iommu->register_lock, flags);
  329. if (mode == 0) {
  330. spin_lock_irqsave(&iommu->register_lock, flags);
  331. /* enable comaptiblity format interrupt pass through */
  332. cmd = iommu->gcmd | DMA_GCMD_CFI;
  333. iommu->gcmd |= DMA_GCMD_CFI;
  334. writel(cmd, iommu->reg + DMAR_GCMD_REG);
  335. IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
  336. readl, (sts & DMA_GSTS_CFIS), sts);
  337. spin_unlock_irqrestore(&iommu->register_lock, flags);
  338. }
  339. /*
  340. * global invalidation of interrupt entry cache before enabling
  341. * interrupt-remapping.
  342. */
  343. qi_global_iec(iommu);
  344. spin_lock_irqsave(&iommu->register_lock, flags);
  345. /* Enable interrupt-remapping */
  346. cmd = iommu->gcmd | DMA_GCMD_IRE;
  347. iommu->gcmd |= DMA_GCMD_IRE;
  348. writel(cmd, iommu->reg + DMAR_GCMD_REG);
  349. IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
  350. readl, (sts & DMA_GSTS_IRES), sts);
  351. spin_unlock_irqrestore(&iommu->register_lock, flags);
  352. }
  353. static int setup_intr_remapping(struct intel_iommu *iommu, int mode)
  354. {
  355. struct ir_table *ir_table;
  356. struct page *pages;
  357. ir_table = iommu->ir_table = kzalloc(sizeof(struct ir_table),
  358. GFP_ATOMIC);
  359. if (!iommu->ir_table)
  360. return -ENOMEM;
  361. pages = alloc_pages(GFP_ATOMIC | __GFP_ZERO, INTR_REMAP_PAGE_ORDER);
  362. if (!pages) {
  363. printk(KERN_ERR "failed to allocate pages of order %d\n",
  364. INTR_REMAP_PAGE_ORDER);
  365. kfree(iommu->ir_table);
  366. return -ENOMEM;
  367. }
  368. ir_table->base = page_address(pages);
  369. iommu_set_intr_remapping(iommu, mode);
  370. return 0;
  371. }
  372. /*
  373. * Disable Interrupt Remapping.
  374. */
  375. static void iommu_disable_intr_remapping(struct intel_iommu *iommu)
  376. {
  377. unsigned long flags;
  378. u32 sts;
  379. if (!ecap_ir_support(iommu->ecap))
  380. return;
  381. /*
  382. * global invalidation of interrupt entry cache before disabling
  383. * interrupt-remapping.
  384. */
  385. qi_global_iec(iommu);
  386. spin_lock_irqsave(&iommu->register_lock, flags);
  387. sts = dmar_readq(iommu->reg + DMAR_GSTS_REG);
  388. if (!(sts & DMA_GSTS_IRES))
  389. goto end;
  390. iommu->gcmd &= ~DMA_GCMD_IRE;
  391. writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
  392. IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
  393. readl, !(sts & DMA_GSTS_IRES), sts);
  394. end:
  395. spin_unlock_irqrestore(&iommu->register_lock, flags);
  396. }
  397. int __init enable_intr_remapping(int eim)
  398. {
  399. struct dmar_drhd_unit *drhd;
  400. int setup = 0;
  401. for_each_drhd_unit(drhd) {
  402. struct intel_iommu *iommu = drhd->iommu;
  403. /*
  404. * If the queued invalidation is already initialized,
  405. * shouldn't disable it.
  406. */
  407. if (iommu->qi)
  408. continue;
  409. /*
  410. * Clear previous faults.
  411. */
  412. dmar_fault(-1, iommu);
  413. /*
  414. * Disable intr remapping and queued invalidation, if already
  415. * enabled prior to OS handover.
  416. */
  417. iommu_disable_intr_remapping(iommu);
  418. dmar_disable_qi(iommu);
  419. }
  420. /*
  421. * check for the Interrupt-remapping support
  422. */
  423. for_each_drhd_unit(drhd) {
  424. struct intel_iommu *iommu = drhd->iommu;
  425. if (!ecap_ir_support(iommu->ecap))
  426. continue;
  427. if (eim && !ecap_eim_support(iommu->ecap)) {
  428. printk(KERN_INFO "DRHD %Lx: EIM not supported by DRHD, "
  429. " ecap %Lx\n", drhd->reg_base_addr, iommu->ecap);
  430. return -1;
  431. }
  432. }
  433. /*
  434. * Enable queued invalidation for all the DRHD's.
  435. */
  436. for_each_drhd_unit(drhd) {
  437. int ret;
  438. struct intel_iommu *iommu = drhd->iommu;
  439. ret = dmar_enable_qi(iommu);
  440. if (ret) {
  441. printk(KERN_ERR "DRHD %Lx: failed to enable queued, "
  442. " invalidation, ecap %Lx, ret %d\n",
  443. drhd->reg_base_addr, iommu->ecap, ret);
  444. return -1;
  445. }
  446. }
  447. /*
  448. * Setup Interrupt-remapping for all the DRHD's now.
  449. */
  450. for_each_drhd_unit(drhd) {
  451. struct intel_iommu *iommu = drhd->iommu;
  452. if (!ecap_ir_support(iommu->ecap))
  453. continue;
  454. if (setup_intr_remapping(iommu, eim))
  455. goto error;
  456. setup = 1;
  457. }
  458. if (!setup)
  459. goto error;
  460. intr_remapping_enabled = 1;
  461. return 0;
  462. error:
  463. /*
  464. * handle error condition gracefully here!
  465. */
  466. return -1;
  467. }
  468. static int ir_parse_ioapic_scope(struct acpi_dmar_header *header,
  469. struct intel_iommu *iommu)
  470. {
  471. struct acpi_dmar_hardware_unit *drhd;
  472. struct acpi_dmar_device_scope *scope;
  473. void *start, *end;
  474. drhd = (struct acpi_dmar_hardware_unit *)header;
  475. start = (void *)(drhd + 1);
  476. end = ((void *)drhd) + header->length;
  477. while (start < end) {
  478. scope = start;
  479. if (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_IOAPIC) {
  480. if (ir_ioapic_num == MAX_IO_APICS) {
  481. printk(KERN_WARNING "Exceeded Max IO APICS\n");
  482. return -1;
  483. }
  484. printk(KERN_INFO "IOAPIC id %d under DRHD base"
  485. " 0x%Lx\n", scope->enumeration_id,
  486. drhd->address);
  487. ir_ioapic[ir_ioapic_num].iommu = iommu;
  488. ir_ioapic[ir_ioapic_num].id = scope->enumeration_id;
  489. ir_ioapic_num++;
  490. }
  491. start += scope->length;
  492. }
  493. return 0;
  494. }
  495. /*
  496. * Finds the assocaition between IOAPIC's and its Interrupt-remapping
  497. * hardware unit.
  498. */
  499. int __init parse_ioapics_under_ir(void)
  500. {
  501. struct dmar_drhd_unit *drhd;
  502. int ir_supported = 0;
  503. for_each_drhd_unit(drhd) {
  504. struct intel_iommu *iommu = drhd->iommu;
  505. if (ecap_ir_support(iommu->ecap)) {
  506. if (ir_parse_ioapic_scope(drhd->hdr, iommu))
  507. return -1;
  508. ir_supported = 1;
  509. }
  510. }
  511. if (ir_supported && ir_ioapic_num != nr_ioapics) {
  512. printk(KERN_WARNING
  513. "Not all IO-APIC's listed under remapping hardware\n");
  514. return -1;
  515. }
  516. return ir_supported;
  517. }
  518. void disable_intr_remapping(void)
  519. {
  520. struct dmar_drhd_unit *drhd;
  521. struct intel_iommu *iommu = NULL;
  522. /*
  523. * Disable Interrupt-remapping for all the DRHD's now.
  524. */
  525. for_each_iommu(iommu, drhd) {
  526. if (!ecap_ir_support(iommu->ecap))
  527. continue;
  528. iommu_disable_intr_remapping(iommu);
  529. }
  530. }
  531. int reenable_intr_remapping(int eim)
  532. {
  533. struct dmar_drhd_unit *drhd;
  534. int setup = 0;
  535. struct intel_iommu *iommu = NULL;
  536. for_each_iommu(iommu, drhd)
  537. if (iommu->qi)
  538. dmar_reenable_qi(iommu);
  539. /*
  540. * Setup Interrupt-remapping for all the DRHD's now.
  541. */
  542. for_each_iommu(iommu, drhd) {
  543. if (!ecap_ir_support(iommu->ecap))
  544. continue;
  545. /* Set up interrupt remapping for iommu.*/
  546. iommu_set_intr_remapping(iommu, eim);
  547. setup = 1;
  548. }
  549. if (!setup)
  550. goto error;
  551. return 0;
  552. error:
  553. /*
  554. * handle error condition gracefully here!
  555. */
  556. return -1;
  557. }