Skip to content

Commit f839b74

Browse files
author
Kelvin Cao
committed
Merge branch 'xlink' into xlink_4.4_to_4.7
2 parents 75bf60a + a270ce1 commit f839b74

File tree

4 files changed

+60
-17
lines changed

4 files changed

+60
-17
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ copyto
1010
*.o
1111
__pycache__
1212
.project.sl
13+
cscope.out
14+
tags
15+
*.o.d

linux/switchtec.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,12 @@ struct ntb_info_regs {
174174
u16 requester_id;
175175
u16 reserved2;
176176
u32 reserved3[4];
177-
struct {
178-
u8 enabled;
179-
u8 partition_vec_low;
180-
u8 partition_vec_high;
181-
u8 reserved1;
182-
u32 reserved2[3];
183-
} crosslink[48];
177+
struct nt_partition_info {
178+
u32 xlink_enabled;
179+
u32 target_part_low;
180+
u32 target_part_high;
181+
u32 reserved;
182+
} ntp_info[48];
184183
} __packed;
185184

186185
struct part_cfg_regs {

ntb_hw_switchtec.c

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static int crosslink_is_enabled(struct switchtec_ntb *sndev)
449449
{
450450
struct ntb_info_regs __iomem *inf = sndev->mmio_ntb;
451451

452-
return ioread8(&inf->crosslink[sndev->self_partition].enabled);
452+
return ioread8(&inf->ntp_info[sndev->peer_partition].xlink_enabled);
453453
}
454454

455455
static void crosslink_init_dbmsgs(struct switchtec_ntb *sndev)
@@ -775,9 +775,12 @@ static const struct ntb_dev_ops switchtec_ntb_ops = {
775775
.peer_spad_addr = switchtec_ntb_peer_spad_addr,
776776
};
777777

778-
static void switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
778+
static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
779779
{
780+
u64 tpart_vec;
781+
int self;
780782
u64 part_map;
783+
int bit;
781784

782785
sndev->ntb.pdev = sndev->stdev->pdev;
783786
sndev->ntb.topo = NTB_TOPO_NONE;
@@ -786,13 +789,47 @@ static void switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
786789
sndev->self_partition = sndev->stdev->partition;
787790

788791
sndev->mmio_ntb = sndev->stdev->mmio_ntb;
792+
793+
self = sndev->self_partition;
794+
tpart_vec = ioread32(&sndev->mmio_ntb->ntp_info[self].target_part_high);
795+
tpart_vec <<= 32;
796+
tpart_vec |= ioread32(&sndev->mmio_ntb->ntp_info[self].target_part_low);
797+
789798
part_map = ioread64(&sndev->mmio_ntb->ep_map);
790799
part_map &= ~(1 << sndev->self_partition);
791-
sndev->peer_partition = ffs(part_map) - 1;
792800

793-
dev_dbg(&sndev->stdev->dev, "Partition ID %d of %d (%llx)",
794-
sndev->self_partition, sndev->stdev->partition_count,
795-
part_map);
801+
if (!ffs(tpart_vec)) {
802+
if (sndev->stdev->partition_count != 2) {
803+
dev_err(&sndev->stdev->dev,
804+
"ntb target partition not defined\n");
805+
return -ENODEV;
806+
}
807+
808+
bit = ffs(part_map);
809+
if (!bit) {
810+
dev_err(&sndev->stdev->dev,
811+
"peer partition is not NT partition\n");
812+
return -ENODEV;
813+
}
814+
815+
sndev->peer_partition = bit - 1;
816+
} else {
817+
if (ffs(tpart_vec) != fls(tpart_vec)) {
818+
dev_err(&sndev->stdev->dev,
819+
"ntb driver only supports 1 pair of 1-1 ntb mapping\n");
820+
return -ENODEV;
821+
}
822+
823+
sndev->peer_partition = ffs(tpart_vec) - 1;
824+
if (!(part_map && (1 << sndev->peer_partition))) {
825+
dev_err(&sndev->stdev->dev,
826+
"ntb target partition is not NT partition\n");
827+
return -ENODEV;
828+
}
829+
}
830+
831+
dev_dbg(&sndev->stdev->dev, "Partition ID %d of %d",
832+
sndev->self_partition, sndev->stdev->partition_count);
796833

797834
sndev->mmio_ctrl = (void * __iomem)sndev->mmio_ntb +
798835
SWITCHTEC_NTB_REG_CTRL_OFFSET;
@@ -803,6 +840,8 @@ static void switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
803840
sndev->mmio_peer_ctrl = &sndev->mmio_ctrl[sndev->peer_partition];
804841
sndev->mmio_self_dbmsg = &sndev->mmio_dbmsg[sndev->self_partition];
805842
sndev->mmio_peer_dbmsg = sndev->mmio_self_dbmsg;
843+
844+
return 0;
806845
}
807846

808847
static int config_rsvd_lut_win(struct switchtec_ntb *sndev,
@@ -1365,15 +1404,15 @@ static int switchtec_ntb_add(struct device *dev,
13651404
if (stdev->pdev->class != MICROSEMI_NTB_CLASSCODE)
13661405
return -ENODEV;
13671406

1368-
if (stdev->partition_count != 2)
1369-
dev_warn(dev, "ntb driver only supports 2 partitions");
1370-
13711407
sndev = kzalloc_node(sizeof(*sndev), GFP_KERNEL, dev_to_node(dev));
13721408
if (!sndev)
13731409
return -ENOMEM;
13741410

13751411
sndev->stdev = stdev;
1376-
switchtec_ntb_init_sndev(sndev);
1412+
rc = switchtec_ntb_init_sndev(sndev);
1413+
if (rc)
1414+
goto free_and_exit;
1415+
13771416
switchtec_ntb_init_mw(sndev);
13781417

13791418
rc = switchtec_ntb_init_req_id_table(sndev);

switchtec.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,8 @@ static const struct pci_device_id switchtec_pci_tbl[] = {
14171417
SWITCHTEC_PCI_DEVICE(0x8534), //PFX 64xG3
14181418
SWITCHTEC_PCI_DEVICE(0x8535), //PFX 80xG3
14191419
SWITCHTEC_PCI_DEVICE(0x8536), //PFX 96xG3
1420+
SWITCHTEC_PCI_DEVICE(0x8541), //PSX 24xG3
1421+
SWITCHTEC_PCI_DEVICE(0x8542), //PSX 32xG3
14201422
SWITCHTEC_PCI_DEVICE(0x8543), //PSX 48xG3
14211423
SWITCHTEC_PCI_DEVICE(0x8544), //PSX 64xG3
14221424
SWITCHTEC_PCI_DEVICE(0x8545), //PSX 80xG3

0 commit comments

Comments
 (0)