All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Smith <sos22-xen@srcf.ucam.org>
To: Markus Armbruster <armbru@redhat.com>
Cc: xen-devel@lists.xensource.com, sos22@srcf.ucam.org
Subject: Re: [PATCH 1/2] PV framebuffer
Date: Wed, 15 Nov 2006 12:11:25 +0000	[thread overview]
Message-ID: <20061115121124.GA2001@cam.ac.uk> (raw)
In-Reply-To: <87wt5yjffh.fsf@pike.pond.sub.org>


[-- Attachment #1.1: Type: text/plain, Size: 7394 bytes --]

> >> +    ret = fb_alloc_cmap(&fb_info->cmap, 256, 0);
> >> +    if (ret < 0) {
> >> +            framebuffer_release(fb_info);
> >> +            xenbus_dev_fatal(dev, ret, "fb_alloc_cmap");
> >> +            goto error;
> >> +    }
> >> +
> >> +    /* FIXME should this be delayed until backend XenbusStateConnected? */
> > I would, but I'm not sure it matters too much.  You have a potentially
> > slightly confusing situation where someone starts using the
> > framebuffer before the backend connects, so the backend has to be able
> > to handle there being events on the ring when it starts, but I think
> > it probably works as it is.
> 
> Yes, it works.
> 
> I might move it eventually just for cleanliness.
Actually, thinking about it, it probably does want to stay where it
is, at least if you want to support backend disconnect/reconnect
cleanly.  If you kill the backend and restart it, _probe shouldn't get
run a second time, whereas the state machine transitions probably will
be.  You probably want to present the same device to Linux, so
re-registering might not be a good idea.

> >> +	info->kthread = kthread_run(xenfb_thread, info, "xenfb thread");
> >> +	if (IS_ERR(info->kthread)) {
> >> +		ret = PTR_ERR(info->kthread);
> >> +		xenbus_dev_fatal(dev, ret, "register_framebuffer");
> >> +		goto error;
> > goto error will end up calling xenfb_remove, which will notice that
> > info->kthread is non-NULL and try to kthread_stop it.  That strikes me
> > as a bad idea.
> > ...
> Oops.  Thanks for catching.
np.

> >> +static int __devexit xenfb_remove(struct xenbus_device *dev)
> > This gets called from some error paths even when the driver is
> > remaining loaded.  Is __devexit safe?  I'm thinking particularly of
> > the case where the kernel is compiled without module unloading and
> > discards exit text segments.
> Insufficient understanding of __devexit on my part.  Fixing.
Yeah, I had to go and look it up.

> >> +{
> >> +	struct xenfb_info *info = dev->dev.driver_data;
> >> +
> >> +	del_timer(&info->refresh);
> >> +	if (info->kthread)
> >> +		kthread_stop(info->kthread);
> >> +	if (info->irq >= 0)
> >> +		unbind_from_irqhandler(info->irq, info);
> >> +	if (info->fb_info) {
> >> +		unregister_framebuffer(info->fb_info);
> >> +		fb_dealloc_cmap(&info->fb_info->cmap);
> >> +		framebuffer_release(info->fb_info);
> >> +	}
> >> +	free_page((unsigned long)info->page);
> >> +	vfree(info->mfns);
> >> +	kfree(info->pages);
> >> +	vfree(info->fb);
> >> +	kfree(info);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static struct xenbus_driver xenfb = {
> >> +	.name = "vfb",
> >> +	.owner = THIS_MODULE,
> >> +	.ids = xenfb_ids,
> >> +	.probe = xenfb_probe,
> >> +	.remove = xenfb_remove,
> > I think this wants to be __devexit_p.
> Only if xenfb is __devexit, right?
Yes, so if xenfb_remove loses __devexit this is correct.

> >> +	/* TODO .resume = xenfb_resume, */
> >> +	.otherend_changed = xenfb_backend_changed,
> >> +};
> >> +
> >> +static int __init xenfb_init(void)
> >> +{
> >> +	int ret;
> >> +
> >> +	if (!is_running_on_xen())
> >> +		return -ENODEV;
> >> +
> >> +	/* Nothing to do if running in dom0. */
> >> +	if (is_initial_xendomain())
> >> +		return -ENODEV;
> >> +	/* if we're not set up to use graphics mode, then don't initialize */
> >> +	if (xenbus_scanf(XBT_NIL, "console", "use_graphics", "%d", &ret) < 0)
> >> +		return -ENODEV;
> >> +	if (ret == 0)
> >> +		return -ENODEV;
> > Not sure about this.  It seems to me like it might be useful to
> > sometimes have domains which have a PVFB but still use xencons for
> > kernel printks etc.  Perhaps I'm just confused.
> I guess you're right.
Thanks.

> >> +int __devinit xenkbd_probe(struct xenbus_device *dev,
> >> +			   const struct xenbus_device_id *id)
> >> +{
> > ...
> >> +	input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
> >> +	input_dev->keybit[LONG(BTN_MOUSE)]
> >> +		= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
> >> +	/* FIXME more buttons? */
> >> +	input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
> > Do you need to set some bits in absbit, as well, since you can
> > generate absolute coordinate messages?
> We missed that.  Curiously, everything seems to work all the same (as
> tested with evdev).  Apparently, no consumer actually tests the bits
> correctly.
Figures.

> Fixing anyway.
Thanks.

> >> diff -rupN -x '*.orig' linux-2.6.16.29-xen/include/xen/interface/io/xenfb.h linux-2.6.16.29-xen-vfb/include/xen/interface/io/xenfb.h
> >> --- linux-2.6.16.29-xen/include/xen/interface/io/xenfb.h	1970-01-01 01:00:00.000000000 +0100
> >> +++ linux-2.6.16.29-xen-vfb/include/xen/interface/io/xenfb.h	2006-11-10 09:43:37.000000000 +0100
> > I think this really wants to be in xen/include/public/io, but I'd
> > guess this is just an artifact of the diff.
> Where in the *Linux* tree you want it?  include/xen/interface or
> include/xen/public or somewhere else?
The IO header files all go in xen/include/public/io, with symlinks
from linux/include/xen/interface/io.  Your tree may be different due
to de-sparseification.  If that's all it is then I'll just ignore this
from now on.

> >> +struct xenfb_update
> >> +{
> >> +	__u8 type;		/* XENFB_TYPE_UPDATE */
> >> +	__s32 x;		/* source x */
> >> +	__s32 y;		/* source y */
> >> +	__s32 width;		/* rect width */
> >> +	__s32 height;		/* rect height */
> >> +};
> >> +
> >> +#define XENFB_OUT_EVENT_SIZE 40
> >> +
> >> +union xenfb_out_event
> >> +{
> >> +	__u8 type;
> >> +	struct xenfb_update update;
> >> +	char pad[XENFB_OUT_EVENT_SIZE];
> >> +};
> > I still think you'd be better off doing tagged unions the usual way,
> > but your funeral.
> While I personally prefer Anthony's way to do it, I'd convert to yours
> if I could ensure the type's size remains exactly XENFB_OUT_EVENT_SIZE
> portably and without undue ugliness.  Alternatively, if I could ensure
> the ring memory layout remains the same even when the type size
> changes.
How about something like this:

struct xenfb_out_event {
	__u8 type;
	__u8 pad1[7];
	union {
		struct xenfb_update update;
		__u8 pad[XENFB_OUT_SIZE-8];
	} u;
};

Does this satisfy your requirements?  Admittedly, I've had to move
some padding around to get good alignment, which I'd forgotten about
before and makes it look a bit uglier than I was hoping, but I'd still
say this is a little nicer.

> >> +/*
> >> + * Wart: xenkbd needs to know resolution.  Put it here until a better
> >> + * solution is found, but don't leak it to the backend.
> >> + */
> > Why does xenkbd need to know the resolution?  Do you mean xenfb?
> >
> > As far as I can see, these only get used in xenfb.c, so the #defines
> > could go there rather than in the IO description header.
> That's where they used to be.  But xenkbd needs to tell the input
> layer about the resolution to make absolute pointer work.
That's really quite unfortunate, and is going to cause problems when
you start supporting changes in resolution.

Does the resolution reported by xenkbd actually need to match the
resolution of the framebuffer?  Could you report a resolution of
65536x65536 and then have the backend scale it?  Presumably, a real
tablet won't scale its output to match the display resolution.

Steven.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2006-11-15 12:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-10  8:53 [PATCH 1/2] PV framebuffer Markus Armbruster
2006-11-12 14:20 ` Steven Smith
2006-11-12 19:05   ` Keir Fraser
2006-11-13 13:09     ` Markus Armbruster
2006-11-13 13:32       ` Keir Fraser
2006-11-14 14:01   ` Markus Armbruster
2006-11-15 12:11     ` Steven Smith [this message]
2006-11-15 16:57       ` Markus Armbruster
2006-11-17  9:46         ` Steven Smith
2006-11-17 15:33     ` Markus Armbruster
2006-11-17 13:22 ` Markus Armbruster
2006-11-17 13:24   ` Markus Armbruster
2006-11-24  8:05   ` Markus Armbruster

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=20061115121124.GA2001@cam.ac.uk \
    --to=sos22-xen@srcf.ucam.org \
    --cc=armbru@redhat.com \
    --cc=sos22@srcf.ucam.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.