reserved memory -- Linux/alpha 2.1.130

Stephen Williams (steve@icarus.com)
Sun, 29 Nov 1998 14:56:29 -0800


I have a device driver that grabs bunches of pages for use by both the
target PCI board (which has a processor and DMA) and host processes.
I manage this by allocating the pages and marking them reserved with
mem_map_reserve, to wit:

for (idx = 0 ; idx < xsp->frame[id]->page_count ; idx += 1) {

void*addr = (void*)get_free_page(GFP_KERNEL);
if (addr == 0)
goto no_mem;

/* Save the bus address in the frame information, and
mark the page reserved to keep the pager away. */
xsp->frame[id]->page[idx] = virt_to_bus(addr);
mem_map_reserve(MAP_NR(addr));
}

The driver uses mmap and nopage to allow the host process to map this memory,
as given below. This generally works fine on my 2.1.130 Linux/alpha kernel.
However, it seems to be less stable then then same thing running on a
2.0.X Linux/intel kernel. On the other hand, 2.1.130 (in fact, most of
the 2.1.X kernels) are unstable even without my driver.

I've been getting Oopses relating to kernel page faults at address 0x8,
but often I just get a complete and quiet lockup. And the Oopses seem
unrelated to my driver. I think my driver is not causing these or the
silent lockups.

PC164 w/ 256Meg RAM, 0 swap,
egcs 1.1b from egcs-1.1b-2.alpha.rpm

static unsigned long xxvmnopage(struct vm_area_struct*vma,
unsigned long address,
int write_access)
{
unsigned long offset, page_nr;
unsigned frame_nr;
#if LINUX_VERSION_CODE > 0x020100
struct inode*inode = vma->vm_file->f_dentry->d_inode;
#else
struct inode*inode = vma->vm_inode;
#endif
unsigned minor = MINOR(inode->i_rdev);
struct Instance*xsp = inst+minor;

frame_nr = (vma->vm_offset >> 28) & 0x0f;
offset = (address - vma->vm_start + vma->vm_offset) & 0x0fffffff;
page_nr = offset / PAGE_SIZE;

if (debug_flag&UCR_TRACE_FRAME)
printk(DEVICE_NAME "%d: nopage address=%p, offset=%p\n",
xsp->number, address, offset);

return (unsigned long)bus_to_virt(xsp->frame[frame_nr]->page[page_nr]);
}

-- 
Steve Williams                "The woods are lovely, dark and deep.
steve@icarus.com              But I have promises to keep,
steve@picturel.com            and lines to code before I sleep,
http://www.picturel.com       And lines to code before I sleep."

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/