From patchwork Mon May 6 05:11:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 2523341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 0881FDF230 for ; Mon, 6 May 2013 07:55:17 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UZGGJ-0000qe-Br; Mon, 06 May 2013 07:55:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UZGGG-0008Uy-Rw; Mon, 06 May 2013 07:55:04 +0000 Received: from ozlabs.org ([203.10.76.45]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UZGGD-0008UG-BV for linux-arm-kernel@lists.infradead.org; Mon, 06 May 2013 07:55:02 +0000 Received: by ozlabs.org (Postfix, from userid 1011) id 1F5842C00D0; Mon, 6 May 2013 17:54:37 +1000 (EST) From: Rusty Russell To: Peter Maydell Subject: Re: [PATCH 0/2] Early printk support for virtio console devices. In-Reply-To: References: <1366974299-17877-1-git-send-email-pranavkumar@linaro.org> <87obcyc9sh.fsf@rustcorp.com.au> <336C59AA-D5D7-472E-A8DA-EEB413DD6C68@suse.de> <87sj27xxjr.fsf@rustcorp.com.au> User-Agent: Notmuch/0.15.2+81~gd2c8818 (http://notmuchmail.org) Emacs/23.4.1 (i686-pc-linux-gnu) Date: Mon, 06 May 2013 14:41:46 +0930 Message-ID: <87ip2wr8tp.fsf@rustcorp.com.au> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130506_035501_854068_E4939429 X-CRM114-Status: GOOD ( 19.59 ) X-Spam-Score: -3.1 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: "linaro-kernel@lists.linaro.org" , "patches@linaro.org" , "linux-kernel@vger.kernel.org List" , Alexander Graf , Amit Shah , "kvmarm@lists.cs.columbia.edu" , "linux-arm-kernel@lists.infradead.org" , Pranavkumar Sawargaonkar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Peter Maydell writes: > On 1 May 2013 03:07, Rusty Russell wrote: >> An emergency output is a reasonable idea, and this is a reasonable >> implementation. The question is practical: will it be used? Because we >> don't implement reasonable ideas which aren't going to be used. > > If you think it fits reasonably into the virtio spec (ie doesn't > implement things at the wrong level of the transport/backend > abstraction) then we can implement it in QEMU, and I think it > makes more sense to do this than to throw in a random extra > serial port. > > To be actually useful we need to also specify something in > the device tree to say "here is where you will find your > emergency output and what it is". Hmm, I'm not sure that's true. It looks like it needs: 1) An enhancment to the vdev->set_config callback to pass through (at least) an offset, probably offset and length. 2) An emerg_write() function ptr which can be called at any time, set by virtio_console.c's class_init: static void emerg_write(VirtIOSerialPort *port, char c) { VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); if (vcon->chr) qemu_chr_fe_write(vcon->chr, &c, 1); } 3) A routine to find an emerg-write-capable console in virtio_serial_bus.c (or just assume port 0?): static VirtIOSerialPort *find_emerg_write_port(VirtIOSerial *vser) { VirtIOSerialPort *port; QTAILQ_FOREACH(port, &vser->ports, next) { VirtIOSerialPortClass *vsc; vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port); if (vsc->emerg_write) { return port; } } return NULL; } 4) set_config in virtio_serial_bus.c to notice emergency writes: if (offset == offsetof(struct virtio_console_config, emerg_w) { VirtIOSerial *vser; vser = DO_UPCAST(VirtIOSerial, vdev, vdev); VirtIOSerialPort *port; port = find_emerg_write_port(vser); if (port) { vsc->emerg_write(port, config.emerg_w); } } Amit might have more clue... Amit? Thanks, Rusty. From: Pranavkumar Sawargaonkar Subject: virtio: console: Add early writeonly register to config space This patch adds a emerg_wr register (writeonly) in config space of virtio console device which can be used for debugging. Signed-off-by: Pranavkumar Sawargaonkar Signed-off-by: Anup Patel Signed-off-by: Rusty Russell --- include/uapi/linux/virtio_console.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/uapi/linux/virtio_console.h b/include/uapi/linux/virtio_console.h index ee13ab6..586678d 100644 --- a/include/uapi/linux/virtio_console.h +++ b/include/uapi/linux/virtio_console.h @@ -38,6 +38,7 @@ /* Feature bits */ #define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */ #define VIRTIO_CONSOLE_F_MULTIPORT 1 /* Does host provide multiple ports? */ +#define VIRTIO_CONSOLE_F_EMERG_WRITE 2 /* Does host support emergency write? */ #define VIRTIO_CONSOLE_BAD_ID (~(u32)0) @@ -48,6 +49,8 @@ struct virtio_console_config { __u16 rows; /* max. number of ports this device can hold */ __u32 max_nr_ports; + /* emergency write register */ + __u32 emerg_wr; } __attribute__((packed)); /*