aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/cxl/context.c2
-rw-r--r--drivers/misc/cxl/cxl.h12
-rw-r--r--drivers/misc/cxl/debugfs.c5
-rw-r--r--drivers/misc/cxl/pci.c75
4 files changed, 7 insertions, 87 deletions
diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c
index 0355d42d367f..5fe529b43ebe 100644
--- a/drivers/misc/cxl/context.c
+++ b/drivers/misc/cxl/context.c
@@ -95,7 +95,7 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master)
95 */ 95 */
96 mutex_lock(&afu->contexts_lock); 96 mutex_lock(&afu->contexts_lock);
97 idr_preload(GFP_KERNEL); 97 idr_preload(GFP_KERNEL);
98 i = idr_alloc(&ctx->afu->contexts_idr, ctx, ctx->afu->adapter->min_pe, 98 i = idr_alloc(&ctx->afu->contexts_idr, ctx, 0,
99 ctx->afu->num_procs, GFP_NOWAIT); 99 ctx->afu->num_procs, GFP_NOWAIT);
100 idr_preload_end(); 100 idr_preload_end();
101 mutex_unlock(&afu->contexts_lock); 101 mutex_unlock(&afu->contexts_lock);
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index aa453448201d..44bcfafbb579 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -93,11 +93,6 @@ static const cxl_p1_reg_t CXL_PSL_FIR_CNTL = {0x0148};
93static const cxl_p1_reg_t CXL_PSL_DSNDCTL = {0x0150}; 93static const cxl_p1_reg_t CXL_PSL_DSNDCTL = {0x0150};
94static const cxl_p1_reg_t CXL_PSL_SNWRALLOC = {0x0158}; 94static const cxl_p1_reg_t CXL_PSL_SNWRALLOC = {0x0158};
95static const cxl_p1_reg_t CXL_PSL_TRACE = {0x0170}; 95static const cxl_p1_reg_t CXL_PSL_TRACE = {0x0170};
96/* XSL registers (Mellanox CX4) */
97static const cxl_p1_reg_t CXL_XSL_Timebase = {0x0100};
98static const cxl_p1_reg_t CXL_XSL_TB_CTLSTAT = {0x0108};
99static const cxl_p1_reg_t CXL_XSL_FEC = {0x0158};
100static const cxl_p1_reg_t CXL_XSL_DSNCTL = {0x0168};
101/* PSL registers - CAIA 2 */ 96/* PSL registers - CAIA 2 */
102static const cxl_p1_reg_t CXL_PSL9_CONTROL = {0x0020}; 97static const cxl_p1_reg_t CXL_PSL9_CONTROL = {0x0020};
103static const cxl_p1_reg_t CXL_XSL9_INV = {0x0110}; 98static const cxl_p1_reg_t CXL_XSL9_INV = {0x0110};
@@ -695,7 +690,6 @@ struct cxl {
695 struct bin_attribute cxl_attr; 690 struct bin_attribute cxl_attr;
696 int adapter_num; 691 int adapter_num;
697 int user_irqs; 692 int user_irqs;
698 int min_pe;
699 u64 ps_size; 693 u64 ps_size;
700 u16 psl_rev; 694 u16 psl_rev;
701 u16 base_image; 695 u16 base_image;
@@ -934,7 +928,6 @@ int cxl_debugfs_afu_add(struct cxl_afu *afu);
934void cxl_debugfs_afu_remove(struct cxl_afu *afu); 928void cxl_debugfs_afu_remove(struct cxl_afu *afu);
935void cxl_debugfs_add_adapter_regs_psl9(struct cxl *adapter, struct dentry *dir); 929void cxl_debugfs_add_adapter_regs_psl9(struct cxl *adapter, struct dentry *dir);
936void cxl_debugfs_add_adapter_regs_psl8(struct cxl *adapter, struct dentry *dir); 930void cxl_debugfs_add_adapter_regs_psl8(struct cxl *adapter, struct dentry *dir);
937void cxl_debugfs_add_adapter_regs_xsl(struct cxl *adapter, struct dentry *dir);
938void cxl_debugfs_add_afu_regs_psl9(struct cxl_afu *afu, struct dentry *dir); 931void cxl_debugfs_add_afu_regs_psl9(struct cxl_afu *afu, struct dentry *dir);
939void cxl_debugfs_add_afu_regs_psl8(struct cxl_afu *afu, struct dentry *dir); 932void cxl_debugfs_add_afu_regs_psl8(struct cxl_afu *afu, struct dentry *dir);
940 933
@@ -977,11 +970,6 @@ static inline void cxl_debugfs_add_adapter_regs_psl8(struct cxl *adapter,
977{ 970{
978} 971}
979 972
980static inline void cxl_debugfs_add_adapter_regs_xsl(struct cxl *adapter,
981 struct dentry *dir)
982{
983}
984
985static inline void cxl_debugfs_add_afu_regs_psl9(struct cxl_afu *afu, struct dentry *dir) 973static inline void cxl_debugfs_add_afu_regs_psl9(struct cxl_afu *afu, struct dentry *dir)
986{ 974{
987} 975}
diff --git a/drivers/misc/cxl/debugfs.c b/drivers/misc/cxl/debugfs.c
index 1643850d2302..a1921d81593a 100644
--- a/drivers/misc/cxl/debugfs.c
+++ b/drivers/misc/cxl/debugfs.c
@@ -58,11 +58,6 @@ void cxl_debugfs_add_adapter_regs_psl8(struct cxl *adapter, struct dentry *dir)
58 debugfs_create_io_x64("trace", S_IRUSR | S_IWUSR, dir, _cxl_p1_addr(adapter, CXL_PSL_TRACE)); 58 debugfs_create_io_x64("trace", S_IRUSR | S_IWUSR, dir, _cxl_p1_addr(adapter, CXL_PSL_TRACE));
59} 59}
60 60
61void cxl_debugfs_add_adapter_regs_xsl(struct cxl *adapter, struct dentry *dir)
62{
63 debugfs_create_io_x64("fec", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_XSL_FEC));
64}
65
66int cxl_debugfs_adapter_add(struct cxl *adapter) 61int cxl_debugfs_adapter_add(struct cxl *adapter)
67{ 62{
68 struct dentry *dir; 63 struct dentry *dir;
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 0ca818396524..6dfb4ed345d3 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -593,27 +593,7 @@ static int init_implementation_adapter_regs_psl8(struct cxl *adapter, struct pci
593 return 0; 593 return 0;
594} 594}
595 595
596static int init_implementation_adapter_regs_xsl(struct cxl *adapter, struct pci_dev *dev) 596/* PSL */
597{
598 u64 xsl_dsnctl;
599 u64 chipid;
600 u32 phb_index;
601 u64 capp_unit_id;
602 int rc;
603
604 rc = cxl_calc_capp_routing(dev, &chipid, &phb_index, &capp_unit_id);
605 if (rc)
606 return rc;
607
608 /* Tell XSL where to route data to */
609 xsl_dsnctl = 0x0000600000000000ULL | (chipid << (63-5));
610 xsl_dsnctl |= (capp_unit_id << (63-13));
611 cxl_p1_write(adapter, CXL_XSL_DSNCTL, xsl_dsnctl);
612
613 return 0;
614}
615
616/* PSL & XSL */
617#define TBSYNC_CAL(n) (((u64)n & 0x7) << (63-3)) 597#define TBSYNC_CAL(n) (((u64)n & 0x7) << (63-3))
618#define TBSYNC_CNT(n) (((u64)n & 0x7) << (63-6)) 598#define TBSYNC_CNT(n) (((u64)n & 0x7) << (63-6))
619/* For the PSL this is a multiple for 0 < n <= 7: */ 599/* For the PSL this is a multiple for 0 < n <= 7: */
@@ -625,21 +605,6 @@ static void write_timebase_ctrl_psl8(struct cxl *adapter)
625 TBSYNC_CNT(2 * PSL_2048_250MHZ_CYCLES)); 605 TBSYNC_CNT(2 * PSL_2048_250MHZ_CYCLES));
626} 606}
627 607
628/* XSL */
629#define TBSYNC_ENA (1ULL << 63)
630/* For the XSL this is 2**n * 2000 clocks for 0 < n <= 6: */
631#define XSL_2000_CLOCKS 1
632#define XSL_4000_CLOCKS 2
633#define XSL_8000_CLOCKS 3
634
635static void write_timebase_ctrl_xsl(struct cxl *adapter)
636{
637 cxl_p1_write(adapter, CXL_XSL_TB_CTLSTAT,
638 TBSYNC_ENA |
639 TBSYNC_CAL(3) |
640 TBSYNC_CNT(XSL_4000_CLOCKS));
641}
642
643static u64 timebase_read_psl9(struct cxl *adapter) 608static u64 timebase_read_psl9(struct cxl *adapter)
644{ 609{
645 return cxl_p1_read(adapter, CXL_PSL9_Timebase); 610 return cxl_p1_read(adapter, CXL_PSL9_Timebase);
@@ -650,11 +615,6 @@ static u64 timebase_read_psl8(struct cxl *adapter)
650 return cxl_p1_read(adapter, CXL_PSL_Timebase); 615 return cxl_p1_read(adapter, CXL_PSL_Timebase);
651} 616}
652 617
653static u64 timebase_read_xsl(struct cxl *adapter)
654{
655 return cxl_p1_read(adapter, CXL_XSL_Timebase);
656}
657
658static void cxl_setup_psl_timebase(struct cxl *adapter, struct pci_dev *dev) 618static void cxl_setup_psl_timebase(struct cxl *adapter, struct pci_dev *dev)
659{ 619{
660 struct device_node *np; 620 struct device_node *np;
@@ -1671,37 +1631,14 @@ static const struct cxl_service_layer_ops psl8_ops = {
1671 .needs_reset_before_disable = true, 1631 .needs_reset_before_disable = true,
1672}; 1632};
1673 1633
1674static const struct cxl_service_layer_ops xsl_ops = {
1675 .adapter_regs_init = init_implementation_adapter_regs_xsl,
1676 .invalidate_all = cxl_invalidate_all_psl8,
1677 .sanitise_afu_regs = sanitise_afu_regs_psl8,
1678 .handle_interrupt = cxl_irq_psl8,
1679 .fail_irq = cxl_fail_irq_psl,
1680 .activate_dedicated_process = cxl_activate_dedicated_process_psl8,
1681 .attach_afu_directed = cxl_attach_afu_directed_psl8,
1682 .attach_dedicated_process = cxl_attach_dedicated_process_psl8,
1683 .update_dedicated_ivtes = cxl_update_dedicated_ivtes_psl8,
1684 .debugfs_add_adapter_regs = cxl_debugfs_add_adapter_regs_xsl,
1685 .write_timebase_ctrl = write_timebase_ctrl_xsl,
1686 .timebase_read = timebase_read_xsl,
1687 .capi_mode = OPAL_PHB_CAPI_MODE_DMA,
1688};
1689
1690static void set_sl_ops(struct cxl *adapter, struct pci_dev *dev) 1634static void set_sl_ops(struct cxl *adapter, struct pci_dev *dev)
1691{ 1635{
1692 if (dev->vendor == PCI_VENDOR_ID_MELLANOX && dev->device == 0x1013) { 1636 if (cxl_is_power8()) {
1693 /* Mellanox CX-4 */ 1637 dev_info(&dev->dev, "Device uses a PSL8\n");
1694 dev_info(&dev->dev, "Device uses an XSL\n"); 1638 adapter->native->sl_ops = &psl8_ops;
1695 adapter->native->sl_ops = &xsl_ops;
1696 adapter->min_pe = 1; /* Workaround for CX-4 hardware bug */
1697 } else { 1639 } else {
1698 if (cxl_is_power8()) { 1640 dev_info(&dev->dev, "Device uses a PSL9\n");
1699 dev_info(&dev->dev, "Device uses a PSL8\n"); 1641 adapter->native->sl_ops = &psl9_ops;
1700 adapter->native->sl_ops = &psl8_ops;
1701 } else {
1702 dev_info(&dev->dev, "Device uses a PSL9\n");
1703 adapter->native->sl_ops = &psl9_ops;
1704 }
1705 } 1642 }
1706} 1643}
1707 1644