Click to See Complete Forum and Search --> : kiobuf/kiovec and scatter-gather lists


cahoosier
11-27-2001, 08:11 PM
I am trying to create a scatter-gather list using kiovec/kiobuf on a 2.4.x kernel.
My device driver is causing my kernel to crash/halt. I am not sure if the problem
is in my mapping of user data into kernel space or with the setup of my device's
registers. The following code fragment is how I am mapping my user data into
kiobufs. Am I utilizing the kiobufs correctly?

Variables are as follows:
useraddr - Address of data in user space
bytesToWrite - Number of bytes to write
localaddr[] - (physical) local address to send to device
// Create kiovec with user data
result = alloc_kiovec(1, &iobuf);
if (result) {
printk("error from alloc_kiovec %d\n", result);
return result;
}
result = map_user_kiobuf(WRITE, iobuf, useraddr, bytesToWrite);
if (result) {
printk("error from map_user_kiobuf %d\n", result);
return result;
}
nBytes = 0;
for (i = 0; i < iobuf->nr_pages; i++) {
if (i == 0) {
localaddr[i] = virt_to_phys(kmap(iobuf->maplist[i]) + iobuf->offset);
}
else {
localaddr[i] = virt_to_phys(kmap(iobuf->maplist[i]));
}
}

Any help is appreciated.

Tony Holzer