From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752372AbbCYFgR (ORCPT ); Wed, 25 Mar 2015 01:36:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44936 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbbCYFgP (ORCPT ); Wed, 25 Mar 2015 01:36:15 -0400 Date: Wed, 25 Mar 2015 06:36:11 +0100 From: "Michael S. Tsirkin" To: Dmitry Torokhov Cc: Gerd Hoffmann , virtio-dev@lists.oasis-open.org, virtualization@lists.linux-foundation.org, David Herrmann , Rusty Russell , open list , "open list:ABI/API" Subject: Re: [PATCH v3] Add virtio-input driver. Message-ID: <20150325063245-mutt-send-email-mst@redhat.com> References: <1427182321-19451-1-git-send-email-kraxel@redhat.com> <20150324105829-mutt-send-email-mst@redhat.com> <20150324162337.GB34117@dtor-ws> <20150324180532-mutt-send-email-mst@redhat.com> <20150324172805.GA16445@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150324172805.GA16445@dtor-ws> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 24, 2015 at 10:28:05AM -0700, Dmitry Torokhov wrote: > > > > > + err = input_register_device(vi->idev); > > > > > + if (err) > > > > > + goto err_input_register; > > > > > + > > > > > + return 0; > > > > > + > > > > > +err_input_register: > > > > > > > > > + input_free_device(vi->idev); > > > > > > > > At this point you can already get interrupts > > > > since you called virtio_device_ready, and > > > > getting events from a freed device likely won't > > > > DTRT. > > > > > > Right. I guess you want to mark the virtio device ready only after > > > registering input device. > > > > No that's broken since you can get events after this > > point, and you won't be able to forward them. > > Who cares? virtio cares: guest will crash if you attempt to kick virtqueue before device ready call. > What makes these events needed compared to ones sent 1 ms > earlier before we had input device registered? > > But I guess if you can call virtio_device_ready/virtio_device_broken > several times then the best option is putting them into input_dev->open > and input_dev->close callbacks. > > Thanks. > -- > Dmitry