From: Markus Armbruster <armbru@redhat.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com,
linux-fbdev-devel@lists.sourceforge.net,
dmitry.torokhov@gmail.com, virtualization@lists.osdl.org,
linux-input@vger.kernel.org, adaplas@pol.net,
akpm@linux-foundation.org, jayakumar.lkml@gmail.com
Subject: Re: [PATCH 2/2] xen pvfb: Para-virtual framebuffer, keyboard and pointer driver
Date: Fri, 22 Feb 2008 07:31:43 +0100 [thread overview]
Message-ID: <8763whbiy8.fsf@pike.pond.sub.org> (raw)
In-Reply-To: <47BDDF97.7070001@goop.org> (Jeremy Fitzhardinge's message of "Thu\, 21 Feb 2008 12\:31\:19 -0800")
Jeremy Fitzhardinge <jeremy@goop.org> writes:
> Markus Armbruster wrote:
>> This is a pair of Xen para-virtual frontend device drivers:
>> drivers/video/xen-fbfront.c provides a framebuffer, and
>> drivers/input/xen-kbdfront provides keyboard and mouse.
>>
>
> Unless they're actually inter-dependent, could you post this as two
> separate patches? I don't know anything about these parts of the
> kernel, so it would be nice to make it very obvious which changes are
> fb vs mouse/keyboard.
I could do that do that, but the intermediate step (one driver, not
the other) is somewhat problematic: the backend in dom0 needs both
drivers, and will refuse to complete device initialization unless
they're both present.
> (I guess input/* vs video/* should make it obvious, but it looks like
> input has a config dependency on fb, so I'll avoid making too many
> presumptions...)
Framebuffer: fbif.h xen-fbfront.c
Keyboard/mouse: kbdif.h xen-kbdfront.h
I added the config dependency because having one without the other
doesn't make sense, as explained above.
Still want it split into two separate patches?
> (Couple of comments below)
>
> J
>
>> The backends run in dom0 user space.
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>>
>> ---
[...]
>> diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c
>> new file mode 100644
>> index 0000000..84f65cf
>> --- /dev/null
>> +++ b/drivers/input/xen-kbdfront.c
>> @@ -0,0 +1,337 @@
[...]
>> +static int __devinit xenkbd_probe(struct xenbus_device *dev,
>> + const struct xenbus_device_id *id)
>> +{
[...]
>> + if (ret < 0)
>> + goto error;
>> +
>> + return 0;
>> +
>> + error_nomem:
>> + ret = -ENOMEM;
>> + xenbus_dev_fatal(dev, ret, "allocating device memory");
>> + error:
>> + xenkbd_remove(dev);
>>
>
> This is happy if dev->info is only partially initialized?
It's designed that way. dev->info is initialized so that
xenkbd_remove() does nothing. Then stuff is stored into dev->info
only when it's sufficiently initialized for xenkbd_remove() to clean
it up.
>> + return ret;
>> +}
>> +
>> +static int xenkbd_resume(struct xenbus_device *dev)
>> +{
>> + struct xenkbd_info *info = dev->dev.driver_data;
>> +
>> + xenkbd_disconnect_backend(info);
>> + memset(info->page, 0, PAGE_SIZE);
>> + return xenkbd_connect_backend(dev, info);
>> +}
>> +
>> +static int xenkbd_remove(struct xenbus_device *dev)
>> +{
>> + struct xenkbd_info *info = dev->dev.driver_data;
>> +
>> + xenkbd_disconnect_backend(info);
>> + input_unregister_device(info->kbd);
>> + input_unregister_device(info->ptr);
>>
>
> Does this free kdb and ptr?
Yes. xenkbd_probe() initializes info->kbd and info->ptr to null, and
changes that to the device only after input_register_device()
succeeds. If something goes wrong between input_allocate_device() and
input_register_device(), xenkbd_probe() frees the device with
input_free_device(). This is how input_register_device() wants to be
used according to its function comment:
/**
* input_register_device - register device with input core
* @dev: device to be registered
*
* This function registers device with input core. The device must be
* allocated with input_allocate_device() and all it's capabilities
* set up before registering.
* If function fails the device must be freed with input_free_device().
* Once device has been successfully registered it can be unregistered
* with input_unregister_device(); input_free_device() should not be
* called in this case.
*/
There's another bug here: must not call input_unregister_device() when
the device is still null. Man, I remember checking cleanup multiple
times when this stuff went into Xen (i.e. quite some time ago), and I
still missed this one. Going to check cleanup *again*.
>> + free_page((unsigned long)info->page);
>> + kfree(info);
>> + return 0;
>> +}
[...]
Thanks!
next prev parent reply other threads:[~2008-02-22 6:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-21 9:42 [PATCH 0/2] xen pvfb: Para-virtual framebuffer, keyboard and pointer Markus Armbruster
2008-02-21 9:43 ` [PATCH 1/2] fbdev: Make deferred I/O work as advertized Markus Armbruster
2008-02-21 16:30 ` Jaya Kumar
2008-02-21 17:31 ` Markus Armbruster
2008-02-21 9:43 ` [PATCH 2/2] xen pvfb: Para-virtual framebuffer, keyboard and pointer driver Markus Armbruster
2008-02-21 16:37 ` Jaya Kumar
2008-02-21 20:31 ` Jeremy Fitzhardinge
2008-02-22 6:31 ` Markus Armbruster [this message]
2008-02-22 22:31 ` Jeremy Fitzhardinge
2008-02-21 11:51 ` [PATCH 0/2] xen pvfb: Para-virtual framebuffer, keyboard and pointer Markus Armbruster
2008-02-21 19:45 ` Jeremy Fitzhardinge
2008-02-21 20:47 ` Markus Armbruster
2008-02-21 22:33 ` Jeremy Fitzhardinge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8763whbiy8.fsf@pike.pond.sub.org \
--to=armbru@redhat.com \
--cc=adaplas@pol.net \
--cc=akpm@linux-foundation.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jayakumar.lkml@gmail.com \
--cc=jeremy@goop.org \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.osdl.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).