In Polled Mode the XSpi_Transfer function runs into a race condition while waiting for the data transmit to be finished before reading out the receive buffer. The function inhibits transmission in line 656 of attached file once the control register reports that the transmit buffer is empty. But an empty transmit buffer does not indicate that the transfer has been completed, thus the transfer may be interrupted during the final byte. On our system we saw that the final byte was truncated after transmission of 5 bits. Therefore, the last byte is not received and ByteCount never reaches 0. As a consequence the for loop waiting for all bytes to be received blocks the system.
An appropriate fix is to move lines 648-657 to line 708. This fix does not inhibit transmission until all bytes have been received. In order for all bytes to have been received the transmission of all bytes must have been completed.
Another appropriate fix would be to modify the IP so that the ControlRegister does not report TxFifo empty until transmission of all bytes was completed.