Skip to contentSkip to conversation

NTB: ntb_transport: Free MWs in ntb_transport_link_cleanup()

PATCH In review Joey Zhang 3 participants 3 messages Jan 7, 2019 – Feb 11, 2019 NTB driver core

lore
Share & tools
lore

Joey Zhang

author
#0 lore raw

PATCH 1/1 NTB: ntb_transport: Free MWs in ntb_transport_link_cleanup()

If NTB peer host crashes or reboots, the NTB transport link will be down and the MWs of NTB transport will be invalid. But the ntb_transport_link_cleanup() does not free these invalid MWs. When the NTB peer host is recovered later, NTB transport link will be up and the ntb_set_mw() will not reset up MWs. Because the MWs of NTB transport are invalid, the NTB transport will not work.

We can fix it by freeing MWs when NTB transport link is down, then the ntb_set_mw() will reset up MWs when NTB transport link is up.

---
 drivers/ntb/ntb_transport.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/ntb/ntb_transport.c +3 -0
index 3bfdb45..6e8902d 100644
@@ -862,6 +862,9 @@ static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt)
 	if (!nt->link_is_up)
 		cancel_delayed_work_sync(&nt->link_work);
 
+	for (i = 0; i < nt->mw_count; i++)
+		ntb_free_mw(nt, i);
+
 	/* The scratchpad registers keep the values if the remote side
 	 * goes down, blast them now to give them a sane value the next
 	 * time they are accessed
Signature · 1 line
2.7.4
#1 lore raw
Quoted 11 lines · Joey Zhang

If NTB peer host crashes or reboots, the NTB transport link will be down and the MWs of NTB transport will be invalid. But the ntb_transport_link_cleanup() does not free these invalid MWs. When the NTB peer host is recovered later, NTB transport link will be up and the ntb_set_mw() will not reset up MWs. Because the MWs of NTB transport are invalid, the NTB transport will not work.

We can fix it by freeing MWs when NTB transport link is down, then the ntb_set_mw() will reset up MWs when NTB transport link is up.

Looks ok to me.

Reviewed By: Logan Gunthorpe <[email protected]>

Quoted 19 lines
---
 drivers/ntb/ntb_transport.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/ntb/ntb_transport.c +3 -0
index 3bfdb45..6e8902d 100644
@@ -862,6 +862,9 @@ static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt)
 	if (!nt->link_is_up)
 		cancel_delayed_work_sync(&nt->link_work);
 
+	for (i = 0; i < nt->mw_count; i++)
+		ntb_free_mw(nt, i);
+
 	/* The scratchpad registers keep the values if the remote side
 	 * goes down, blast them now to give them a sane value the next
 	 * time they are accessed
maintainer
#2 lore raw
Quoted 10 lines · Logan Gunthorpe
Quoted 7 lines · Joey Zhang

If NTB peer host crashes or reboots, the NTB transport link will be down and the MWs of NTB transport will be invalid. But the ntb_transport_link_cleanup() does not free these invalid MWs. When the NTB peer host is recovered later, NTB transport link will be up and the ntb_set_mw() will not reset up MWs. Because the MWs of NTB transport are invalid, the NTB transport will not work.

Quoted 6 lines
Quoted 4 lines

We can fix it by freeing MWs when NTB transport link is down, then the ntb_set_mw() will reset up MWs when NTB transport link is up.

Looks ok to me.

Added to the ntb branch, thanks!

Quoted 1 line

Reviewed By: Logan Gunthorpe <[email protected]>

Looks like your missed the '-' ;-)
I took the liberity of adding it

Thanks,
Jon

Quoted 20 lines
Quoted 20 lines
---
 drivers/ntb/ntb_transport.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/ntb/ntb_transport.c +3 -0
index 3bfdb45..6e8902d 100644
@@ -862,6 +862,9 @@ static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt)
 	if (!nt->link_is_up)
 		cancel_delayed_work_sync(&nt->link_work);
 
+	for (i = 0; i < nt->mw_count; i++)
+		ntb_free_mw(nt, i);
+
 	/* The scratchpad registers keep the values if the remote side
 	 * goes down, blast them now to give them a sane value the next
 	 * time they are accessed