LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Block device drivers (https://www.linuxquestions.org/questions/linux-newbie-8/block-device-drivers-4175534160/)

ghaddab 02-16-2015 04:56 AM

Block device drivers
 
I am new to drivers development under linux kernel. After starting with the simple examples from the book Linux Device Drivers v3, I realised that the block driver API has been totally changed since the kernel 2.6.31 or maybe later versions, and I couldn't find any documentation about the new API and how to use it. There are just some few comments in the source code.

After struggling for one month I almost had something working but few parts are missing or I misunderstood something.

Here is the situation :

After fetching the request with blk_fetch_request(q), I use the macro __rq_for_each_bio for handling the full request
To transfer the segments one by one I use the macro bio_for_each_segment(bvec, bio, i) that loops over all the segments in a bio

My question is :

I need to do some DMA from/to my device (the dma engine is within the device), that's why I need some address that I could use it to DMA from/to
Which buffer should I use ? for the moment I use the buffer returned by char *buffer=bio_data(bio), Does "buffer" corresponds to the physical buffer that I can use for DMA
How to end the request in this case ? using __blk_end_request_cur(req, 0) ? or using __blk_end_request(req, 0, bytes) ?

If you don't have an answer to any of these questions, where can I find a useful documentation for the new API of the block device drivers.

ghaddab 02-18-2015 09:22 AM

I found it, I should have mapped the address returned from the bio structure with dma_map_single


All times are GMT -5. The time now is 03:32 AM.