tiny6410 spi lost bytes

john
my master-spi(tiny6410 ) connect with slave-spi(stm32)

stm32 spi interrupt code like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
u8 g_val=0;

void SPI2_IRQHandler(void)
{
  if(SPI2->SR & SPI_I2S_FLAG_RXNE)

  {

    SPI2->DR;
  }


  if(SPI2->SR & SPI_I2S_FLAG_TXE)

  {

    SPI2->DR = g_val++;
        }
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


tiny6410 spi codes:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int test_ioctl_spi(int spi_fd, unsigned char buf[],int buflen)
{   
    char tx[100];
    struct spi_ioc_transfer tr ={
        .tx_buf     = (unsigned long)tx,
        .rx_buf     = (unsigned long)buf,
        .len        = buflen,
        .delay_usecs    = 0,
        .speed_hz   = 2000000,
        .bits_per_word  = 8,
        .cs_change = 1,
    };
    int ret = ioctl(spi_fd, SPI_IOC_MESSAGE(1), &tr);
    if(ret<0)
    {
        printf("spi read error ret=%d \n",ret);
        perror("");
        return -1;
    }
    return ret;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


I only want to read spi data from stm32. But may be lost bytes
occasionally:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@FriendlyARM code]# ./spi
main start
read err. oldval=0x00,newval=0x20,read_cnt=1
read err. oldval=0x50,newval=0x52,read_cnt=13244978
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
oldval=0x50,newval=0x52 meanings lost 0x51

if change tr.cs_change to .cs_change=0, also lost bytes

if call read() to read spi data, also lost bytes.


how to correct this problem. 

thanks.

john
full-duplexing spi mode