Skip to content

Commit e981219

Browse files
committed
Setup crosslink requester IDs when updating link status
When accessing the peer status for link status update, we need to setup the crosslink requester IDs first to ensure we have access to the peer status. Earlier crosslink requester IDs setup during device initialization or link enabling can fail because the peer switch may not in a good state or the link to the peer switch may not be well connected at the moment. Therefore, we add the requester IDs setup during link status update which could be triggered by a peer link up event at which the peer switch and the connection to the peer switch must be in a good state. For more background about the requester IDs setup, please refer to commit fd0edee.
1 parent 453e809 commit e981219

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ntb_hw_switchtec.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,21 @@ enum switchtec_msg {
588588

589589
static int switchtec_ntb_reinit_peer(struct switchtec_ntb *sndev);
590590

591+
static int crosslink_setup_req_ids(struct switchtec_ntb *sndev,
592+
struct ntb_ctrl_regs __iomem *mmio_ctrl);
593+
591594
static void switchtec_ntb_link_status_update(struct switchtec_ntb *sndev)
592595
{
593596
int link_sta;
594597
int old = sndev->link_is_up;
598+
u64 peer;
595599

596600
link_sta = sndev->self_shared->link_sta;
597601
if (link_sta) {
598-
u64 peer = ioread64(&sndev->peer_shared->magic);
602+
if (!sndev->link_is_up && crosslink_is_enabled(sndev))
603+
crosslink_setup_req_ids(sndev, sndev->mmio_xlink_peer_ctrl);
604+
605+
peer = ioread64(&sndev->peer_shared->magic);
599606

600607
if ((peer & 0xFFFFFFFF) == SWITCHTEC_NTB_MAGIC)
601608
link_sta = peer >> 32;
@@ -670,9 +677,6 @@ static u64 switchtec_ntb_link_is_up(struct ntb_dev *ntb,
670677
return sndev->link_is_up;
671678
}
672679

673-
static int crosslink_setup_req_ids(struct switchtec_ntb *sndev,
674-
struct ntb_ctrl_regs __iomem *mmio_ctrl);
675-
676680
static int switchtec_ntb_link_enable(struct ntb_dev *ntb,
677681
enum ntb_speed max_speed,
678682
enum ntb_width max_width)
@@ -684,9 +688,6 @@ static int switchtec_ntb_link_enable(struct ntb_dev *ntb,
684688
sndev->self_shared->link_sta = 1;
685689
switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
686690

687-
if (crosslink_is_enabled(sndev))
688-
crosslink_setup_req_ids(sndev, sndev->mmio_xlink_peer_ctrl);
689-
690691
switchtec_ntb_link_status_update(sndev);
691692

692693
return 0;

0 commit comments

Comments
 (0)