aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/cxl/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/cxl/pci.c')
-rw-r--r--drivers/misc/cxl/pci.c88
1 files changed, 64 insertions, 24 deletions
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 3ba04f371380..bb7fd3f4edab 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -401,7 +401,8 @@ int cxl_calc_capp_routing(struct pci_dev *dev, u64 *chipid,
401 *capp_unit_id = get_capp_unit_id(np, *phb_index); 401 *capp_unit_id = get_capp_unit_id(np, *phb_index);
402 of_node_put(np); 402 of_node_put(np);
403 if (!*capp_unit_id) { 403 if (!*capp_unit_id) {
404 pr_err("cxl: invalid capp unit id\n"); 404 pr_err("cxl: invalid capp unit id (phb_index: %d)\n",
405 *phb_index);
405 return -ENODEV; 406 return -ENODEV;
406 } 407 }
407 408
@@ -475,37 +476,37 @@ static int init_implementation_adapter_regs_psl9(struct cxl *adapter,
475 psl_fircntl |= 0x1ULL; /* ce_thresh */ 476 psl_fircntl |= 0x1ULL; /* ce_thresh */
476 cxl_p1_write(adapter, CXL_PSL9_FIR_CNTL, psl_fircntl); 477 cxl_p1_write(adapter, CXL_PSL9_FIR_CNTL, psl_fircntl);
477 478
478 /* vccredits=0x1 pcklat=0x4 */ 479 /* Setup the PSL to transmit packets on the PCIe before the
479 cxl_p1_write(adapter, CXL_PSL9_DSNDCTL, 0x0000000000001810ULL); 480 * CAPP is enabled
480
481 /*
482 * For debugging with trace arrays.
483 * Configure RX trace 0 segmented mode.
484 * Configure CT trace 0 segmented mode.
485 * Configure LA0 trace 0 segmented mode.
486 * Configure LA1 trace 0 segmented mode.
487 */ 481 */
488 cxl_p1_write(adapter, CXL_PSL9_TRACECFG, 0x8040800080000000ULL); 482 cxl_p1_write(adapter, CXL_PSL9_DSNDCTL, 0x0001001000002A10ULL);
489 cxl_p1_write(adapter, CXL_PSL9_TRACECFG, 0x8040800080000003ULL);
490 cxl_p1_write(adapter, CXL_PSL9_TRACECFG, 0x8040800080000005ULL);
491 cxl_p1_write(adapter, CXL_PSL9_TRACECFG, 0x8040800080000006ULL);
492 483
493 /* 484 /*
494 * A response to an ASB_Notify request is returned by the 485 * A response to an ASB_Notify request is returned by the
495 * system as an MMIO write to the address defined in 486 * system as an MMIO write to the address defined in
496 * the PSL_TNR_ADDR register 487 * the PSL_TNR_ADDR register.
488 * keep the Reset Value: 0x00020000E0000000
497 */ 489 */
498 /* PSL_TNR_ADDR */
499 490
500 /* NORST */ 491 /* Enable XSL rty limit */
501 cxl_p1_write(adapter, CXL_PSL9_DEBUG, 0x8000000000000000ULL); 492 cxl_p1_write(adapter, CXL_XSL9_DEF, 0x51F8000000000005ULL);
493
494 /* Change XSL_INV dummy read threshold */
495 cxl_p1_write(adapter, CXL_XSL9_INV, 0x0000040007FFC200ULL);
496
497 if (phb_index == 3) {
498 /* disable machines 31-47 and 20-27 for DMA */
499 cxl_p1_write(adapter, CXL_PSL9_APCDEDTYPE, 0x40000FF3FFFF0000ULL);
500 }
502 501
503 /* allocate the apc machines */ 502 /* Snoop machines */
504 cxl_p1_write(adapter, CXL_PSL9_APCDEDTYPE, 0x40000003FFFF0000ULL); 503 cxl_p1_write(adapter, CXL_PSL9_APCDEDALLOC, 0x800F000200000000ULL);
505 504
506 /* Disable vc dd1 fix */ 505 if (cxl_is_power9_dd1()) {
507 if (cxl_is_power9_dd1()) 506 /* Disabling deadlock counter CAR */
508 cxl_p1_write(adapter, CXL_PSL9_GP_CT, 0x0400000000000001ULL); 507 cxl_p1_write(adapter, CXL_PSL9_GP_CT, 0x0020000000000001ULL);
508 } else
509 cxl_p1_write(adapter, CXL_PSL9_DEBUG, 0x4000000000000000ULL);
509 510
510 return 0; 511 return 0;
511} 512}
@@ -1746,6 +1747,44 @@ static void cxl_deconfigure_adapter(struct cxl *adapter)
1746 pci_disable_device(pdev); 1747 pci_disable_device(pdev);
1747} 1748}
1748 1749
1750static void cxl_stop_trace_psl9(struct cxl *adapter)
1751{
1752 int traceid;
1753 u64 trace_state, trace_mask;
1754 struct pci_dev *dev = to_pci_dev(adapter->dev.parent);
1755
1756 /* read each tracearray state and issue mmio to stop them is needed */
1757 for (traceid = 0; traceid <= CXL_PSL9_TRACEID_MAX; ++traceid) {
1758 trace_state = cxl_p1_read(adapter, CXL_PSL9_CTCCFG);
1759 trace_mask = (0x3ULL << (62 - traceid * 2));
1760 trace_state = (trace_state & trace_mask) >> (62 - traceid * 2);
1761 dev_dbg(&dev->dev, "cxl: Traceid-%d trace_state=0x%0llX\n",
1762 traceid, trace_state);
1763
1764 /* issue mmio if the trace array isn't in FIN state */
1765 if (trace_state != CXL_PSL9_TRACESTATE_FIN)
1766 cxl_p1_write(adapter, CXL_PSL9_TRACECFG,
1767 0x8400000000000000ULL | traceid);
1768 }
1769}
1770
1771static void cxl_stop_trace_psl8(struct cxl *adapter)
1772{
1773 int slice;
1774
1775 /* Stop the trace */
1776 cxl_p1_write(adapter, CXL_PSL_TRACE, 0x8000000000000017LL);
1777
1778 /* Stop the slice traces */
1779 spin_lock(&adapter->afu_list_lock);
1780 for (slice = 0; slice < adapter->slices; slice++) {
1781 if (adapter->afu[slice])
1782 cxl_p1n_write(adapter->afu[slice], CXL_PSL_SLICE_TRACE,
1783 0x8000000000000000LL);
1784 }
1785 spin_unlock(&adapter->afu_list_lock);
1786}
1787
1749static const struct cxl_service_layer_ops psl9_ops = { 1788static const struct cxl_service_layer_ops psl9_ops = {
1750 .adapter_regs_init = init_implementation_adapter_regs_psl9, 1789 .adapter_regs_init = init_implementation_adapter_regs_psl9,
1751 .invalidate_all = cxl_invalidate_all_psl9, 1790 .invalidate_all = cxl_invalidate_all_psl9,
@@ -1762,6 +1801,7 @@ static const struct cxl_service_layer_ops psl9_ops = {
1762 .debugfs_add_adapter_regs = cxl_debugfs_add_adapter_regs_psl9, 1801 .debugfs_add_adapter_regs = cxl_debugfs_add_adapter_regs_psl9,
1763 .debugfs_add_afu_regs = cxl_debugfs_add_afu_regs_psl9, 1802 .debugfs_add_afu_regs = cxl_debugfs_add_afu_regs_psl9,
1764 .psl_irq_dump_registers = cxl_native_irq_dump_regs_psl9, 1803 .psl_irq_dump_registers = cxl_native_irq_dump_regs_psl9,
1804 .err_irq_dump_registers = cxl_native_err_irq_dump_regs_psl9,
1765 .debugfs_stop_trace = cxl_stop_trace_psl9, 1805 .debugfs_stop_trace = cxl_stop_trace_psl9,
1766 .write_timebase_ctrl = write_timebase_ctrl_psl9, 1806 .write_timebase_ctrl = write_timebase_ctrl_psl9,
1767 .timebase_read = timebase_read_psl9, 1807 .timebase_read = timebase_read_psl9,
@@ -1785,7 +1825,7 @@ static const struct cxl_service_layer_ops psl8_ops = {
1785 .debugfs_add_adapter_regs = cxl_debugfs_add_adapter_regs_psl8, 1825 .debugfs_add_adapter_regs = cxl_debugfs_add_adapter_regs_psl8,
1786 .debugfs_add_afu_regs = cxl_debugfs_add_afu_regs_psl8, 1826 .debugfs_add_afu_regs = cxl_debugfs_add_afu_regs_psl8,
1787 .psl_irq_dump_registers = cxl_native_irq_dump_regs_psl8, 1827 .psl_irq_dump_registers = cxl_native_irq_dump_regs_psl8,
1788 .err_irq_dump_registers = cxl_native_err_irq_dump_regs, 1828 .err_irq_dump_registers = cxl_native_err_irq_dump_regs_psl8,
1789 .debugfs_stop_trace = cxl_stop_trace_psl8, 1829 .debugfs_stop_trace = cxl_stop_trace_psl8,
1790 .write_timebase_ctrl = write_timebase_ctrl_psl8, 1830 .write_timebase_ctrl = write_timebase_ctrl_psl8,
1791 .timebase_read = timebase_read_psl8, 1831 .timebase_read = timebase_read_psl8,