Notify remote endpoint with RX_COMPLETE prior to handling MCTP packet

This change ensures that prior to handling the contents of the
MCTP packet we get, we notify the the remote endpoint that we
have read the contents of the transmission they sent us.

Prior to this change, if the RX buffer contained a packet with the EOM
bit set, the packet is upgraded to a message and is passed to whatever
function the message_rx callback is bound to. In Hostboot's case this
causes a message to be sent to a message queue the PLDM requester
is blocked on. In some cases, we saw the PLDM requester thread get woken
up by this message, process the response, and fire off another PLDM
message, all prior to the task managing the MCTP rx waking back up to
send the RX_COMPLETE message to the KCS data register. We saw if the
TX_STARTED command for the next packet was written prior to Hostboot
writing the RX_COMPLETE from reading the last packet that, the message
that Hostboot sent would not make it to PLDM on the BMC.

Signed-off-by: Christian Geddes <crgeddes@us.ibm.com>
Change-Id: I9f3ecc0d504e22ef69999835c68a9abb033c48dd
diff --git a/astlpc.c b/astlpc.c
index 91fba85..388dc11 100644
--- a/astlpc.c
+++ b/astlpc.c
@@ -937,8 +937,10 @@
 	/* Eliminate the medium-specific header that we just read */
 	packet = astlpc->proto->packet_size(body) - 4;
 	pkt = mctp_pktbuf_alloc(&astlpc->binding, packet);
-	if (!pkt)
-		goto out_complete;
+	if (!pkt) {
+		astlpc_prwarn(astlpc, "unable to allocate pktbuf len 0x%x", packet);
+		return;
+	}
 
 	/*
 	 * Read payload and medium-specific trailer from immediately after the
@@ -947,6 +949,11 @@
 	mctp_astlpc_lpc_read(astlpc, mctp_pktbuf_hdr(pkt),
 			     astlpc->layout.rx.offset + 4, packet);
 
+	/* Inform the other side of the MCTP interface that we have read
+	 * the packet off the bus before handling the contents of the packet.
+	 */
+	mctp_astlpc_kcs_send(astlpc, 0x2);
+
 	/*
 	 * v3 will validate the CRC32 in the medium-specific trailer and adjust
 	 * the packet size accordingly. On older protocols validation is a no-op
@@ -959,9 +966,6 @@
 		mctp_pktbuf_free(pkt);
 		astlpc_prdebug(astlpc, "Dropped corrupt packet");
 	}
-
-out_complete:
-	mctp_astlpc_kcs_send(astlpc, 0x2);
 }
 
 static void mctp_astlpc_tx_complete(struct mctp_binding_astlpc *astlpc)