cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
4,029 Views
Registered: ‎04-27-2010

Linux driver for XAPP1052 - incorrect source code

Hello,

 

I found some bugs in the source code of the Linux driver for XAPP1052 (xbmd.c).

 

The functions for reading and writing (XPCIe_Read and XPCIe_Write) are not communicating with the

device at all, they are just copying kernel buffers to and from user buffers.

 

You don't have to be a Linux driver developer to understand this, just take a look at the code of

XPCIe_Read:

 

ssize_t XPCIe_Read(struct file *filp, char *buf, size_t count, loff_t *f_pos)
{
  memcpy(buf, (char *)gWriteBuffer, count);
  printk(KERN_INFO"%s: XPCIe_Read: %d bytes have been read...\n", gDrvrName, count);
  return (0);
}

 

 

Interestingly, there are two others functions which are not used at all: XPCIe_ReadMem and XPCIe_WriteMem.

These seem to be the correct read and write functions (although the third argument loff_t *f_pos is missing in their argument list ).

 

There are also semaphore values defined but never used (the only one used is SEM_DMA), so I am not sure if there are any other errors or things missing in the code.

 

 

 

0 Kudos
1 Reply
Highlighted
Adventurer
Adventurer
3,996 Views
Registered: ‎01-29-2008

 


You don't have to be a Linux driver developer to understand this, just take a look at the code of

XPCIe_Read:


 

Hi,

 

Linux driver developer not , but understand the BMD design  yes :-)

 

If you look closely xPCIe_Read uses the gWriteBuffer : why ?

Because this write buffer is a write buffer from the FPGA board point of vue. When the DMA is launch (by the xbmd_main.cpp code) using IOCTL the device will automatically fill the gWriteBuffer (a DMA write is perform : FPGA->Main PC memory) then the xPCIe_Read get the result of the DMA transfer by reading the gWriteBuffer.

 

xPCIe_Write work in the other way (write to the gReadBuffer ; then DMA iniated by FPGA from PC RAM to FPGA )

 

XPCIe_ReadMem and XPCIe_WriteMem aren't use. It is just for testing classical MemRead/memWrite functions of the PCIe bus (without DMA : transfer initiated by the PC

0 Kudos