Change in simtrace2[master]: cardem: RST resets all state (including release of buffers)

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Dec 15 17:00:39 UTC 2019


laforge has submitted this change. ( https://gerrit.osmocom.org/c/simtrace2/+/16584 )

Change subject: cardem: RST resets all state (including release of buffers)
......................................................................

cardem: RST resets all state (including release of buffers)

When the Modem is asserting RST, the emulated card should set all
of its state back to default/initial values and release any buffers
it may still hold in its state.

Change-Id: I66eca6afe4ff7d900c5b75df1e3ec6d52f6ef214
Related: OS#4251
---
M firmware/libcommon/source/card_emu.c
1 file changed, 19 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, approved; Verified



diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c
index 7ce10a8..63bf0d3 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -236,8 +236,25 @@
 /* reset all the 'dynamic' state of the card handle to the initial/default values */
 static void card_handle_reset(struct card_handle *ch)
 {
+	struct msgb *msg;
+
+	tc_etu_disable(ch->tc_chan);
+
 	ch->pts.state = PTS_S_WAIT_REQ_PTSS;
 	ch->tpdu.state = TPDU_S_WAIT_CLA;
+
+	/* release any buffers we may still own */
+	if (ch->uart_tx_msg) {
+		usb_buf_free(ch->uart_tx_msg);
+		ch->uart_tx_msg = NULL;
+	}
+	if (ch->uart_rx_msg) {
+		usb_buf_free(ch->uart_rx_msg);
+		ch->uart_rx_msg = NULL;
+	}
+	while ((msg = msgb_dequeue(&ch->uart_tx_queue))) {
+		usb_buf_free(msg);
+	}
 }
 
 struct llist_head *card_emu_get_uart_tx_queue(struct card_handle *ch)
@@ -1062,7 +1079,7 @@
 	case CARD_IO_VCC:
 		if (active == 0 && ch->vcc_active == 1) {
 			TRACE_INFO("%u: VCC deactivated\r\n", ch->num);
-			tc_etu_disable(ch->tc_chan);
+			card_handle_reset(ch);
 			card_set_state(ch, ISO_S_WAIT_POWER);
 		} else if (active == 1 && ch->vcc_active == 0) {
 			TRACE_INFO("%u: VCC activated\r\n", ch->num);
@@ -1091,7 +1108,7 @@
 			}
 		} else if (active && !ch->in_reset) {
 			TRACE_INFO("%u: RST asserted\r\n", ch->num);
-			tc_etu_disable(ch->tc_chan);
+			card_handle_reset(ch);
 		}
 		ch->in_reset = active;
 		break;

-- 
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/16584
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I66eca6afe4ff7d900c5b75df1e3ec6d52f6ef214
Gerrit-Change-Number: 16584
Gerrit-PatchSet: 5
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191215/030ccd5f/attachment.htm>


More information about the gerrit-log mailing list