On 8/10/2010 2:39 AM, Lv, Zhiyuan wrote:
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -1113,6 +1113,14 @@ config TELCLOCK
/sys/devices/platform/telco_clock, with a number of files for
controlling the behavior of this hardware.
+config VIRTIOGL
+ tristate "Virtio userspace memory transport"
+ depends on VIRTIO_PCI
+ default n
+ help
+ A Driver to facilitate transferring data from userspace to a
+ hypervisor (eg. qemu)
+
this definitely needs to be in drivers/gpu not in drivers/char
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
has this driver been through the Intel internal process for releasing
Intel owned open source code?
(I'd wager not)
+//#include <asm/uaccess.h> /* for put_user */
// in Linux kernel code ? don't think so
+void cleanup_module(void);
+static int device_open(struct inode *, struct file *);
+static int device_release(struct inode *, struct file *);
+static int device_mmap(struct file *, struct vm_area_struct *);
+static int device_fsync (struct file *, struct dentry *, int datasync);
if the driver was in the right order, you'd not need these prototypes
+
+static char *virtiogl_devnode(struct device *dev, mode_t *mode)
+{
+ *mode = 0666;
+ return NULL;
+}
+
this is one weird function, and how it's used is even weirder
+
+#define MAX(a, b) ((a)<(b)?(b):(a))
the Linux kernel already has a max function which is, unlike this one,
not buggy
+ while (!virtqueue_get_buf(vq, &count))
+ cpu_relax();
busy waiting? that's not very nice.
The code that will cause that condition to change may not ever run now.
+static int device_open(struct inode *inode, struct file *file)+{
+ struct virtio_gl_data *gldata = kzalloc(sizeof(struct
virtio_gl_data), GFP_KERNEL);
+
+ gldata->pid = pid_nr(task_pid(current));
+
+ file->private_data = gldata;
you definitely want to check the return of kmalloc
+
+ try_module_get(THIS_MODULE);
+
and this is plain buggy and misguided.
+ return 0;
+}
+
+static void free_buffer(struct virtio_gl_data *gldata) {
+ int i;
+
+ if(gldata->buffer) {
+ for (i = 0; i < gldata->pages * PAGE_SIZE; i+= PAGE_SIZE)
+ ClearPageReserved(vmalloc_to_page((gldata->buffer + i)));
where does this PageReserved mess come from????
that's usually a sign that you either copied some buggy code from
elsewhere, have no idea what you're doing or buggered up the refcounting
+
+/*
+ * Called when a process closes the device file.
+ */
+static int device_release(struct inode *inode, struct file *file)
+{
+ struct virtio_gl_data *gldata = to_virtio_gl_data(file);
+
+ if(gldata && gldata->buffer) {
+ /* Make sure the host hears about the process ending / dying */
+ ((int*)gldata->buffer)[0] = gldata->pid;
+ ((int*)gldata->buffer)[1] = SIZE_OUT_HEADER + 2;
+ ((int*)gldata->buffer)[2] = SIZE_IN_HEADER;
+ *(short*)(gldata->buffer + SIZE_OUT_HEADER) = -1; // Death!
this many typecasts are a good indication something is very wrong...
+
+ module_put(THIS_MODULE);
again this is at best misguided.
+
+ for (i = 0; i < pages * PAGE_SIZE; i+= PAGE_SIZE) {
+ SetPageReserved(vmalloc_to_page((gldata->buffer + i)));
same comment about the PageReserved thing as before
all in all, not a very good driver yet... needs some work.
_______________________________________________
MeeGo-dev mailing list
[email protected]
http://lists.meego.com/listinfo/meego-dev