virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
@ 2013-03-11 15:15 sjur.brandeland
  2013-03-12  4:54 ` Rusty Russell
  2013-03-12  7:34 ` Amit Shah
  0 siblings, 2 replies; 10+ messages in thread
From: sjur.brandeland @ 2013-03-11 15:15 UTC (permalink / raw)
  To: Rusty Russell
  Cc: sjur, Linus Walleij, Erwan Yvin, virtualization, amit.shah,
	Sjur Brændeland

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b.

The reverted patch caused opening of ports to fail for rproc_serial.
In probe guest_connected was set to true, but port_fops_open()
fails with -EMFILE if guest_connected already is true.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
Hi Rusty,

Here is a fix intended for 3.9.
Sorry for the churn here :-(

Regards,
Sjur

 drivers/char/virtio_console.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index e905d5f..031be0b 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1436,7 +1436,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 		 * rproc_serial does not want the console port, only
 		 * the generic port implementation.
 		 */
-		port->host_connected = port->guest_connected = true;
+		port->host_connected = true;
 	else if (!use_multiport(port->portdev)) {
 		/*
 		 * If we're not using multiport support,
@@ -1757,8 +1757,11 @@ static void in_intr(struct virtqueue *vq)
 	 * tty is spawned) and the host sends out data to console
 	 * ports.  For generic serial ports, the host won't
 	 * (shouldn't) send data till the guest is connected.
+	 * However a remote device might send data before the port is
+	 * connected. So don't remove data from a rproc_serial device.
 	 */
-	if (!port->guest_connected)
+
+	if (!port->guest_connected && !is_rproc_serial(port->portdev->vdev))
 		discard_port_data(port);
 
 	spin_unlock_irqrestore(&port->inbuf_lock, flags);
-- 
1.7.5.4

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
  2013-03-11 15:15 [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial" sjur.brandeland
@ 2013-03-12  4:54 ` Rusty Russell
  2013-03-12  7:34 ` Amit Shah
  1 sibling, 0 replies; 10+ messages in thread
From: Rusty Russell @ 2013-03-12  4:54 UTC (permalink / raw)
  Cc: sjur, Linus Walleij, Erwan Yvin, virtualization, amit.shah,
	Sjur Brændeland

sjur.brandeland@stericsson.com writes:

> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>
> This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b.
>
> The reverted patch caused opening of ports to fail for rproc_serial.
> In probe guest_connected was set to true, but port_fops_open()
> fails with -EMFILE if guest_connected already is true.
>
> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
> ---
> Hi Rusty,
>
> Here is a fix intended for 3.9.
> Sorry for the churn here :-(

Applied,
Rusty.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
  2013-03-11 15:15 [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial" sjur.brandeland
  2013-03-12  4:54 ` Rusty Russell
@ 2013-03-12  7:34 ` Amit Shah
  2013-03-12 11:05   ` Sjur Brændeland
  1 sibling, 1 reply; 10+ messages in thread
From: Amit Shah @ 2013-03-12  7:34 UTC (permalink / raw)
  To: sjur.brandeland; +Cc: sjur, Linus Walleij, Erwan Yvin, virtualization

On (Mon) 11 Mar 2013 [16:15:00], sjur.brandeland@stericsson.com wrote:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
> 
> This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b.
> 
> The reverted patch caused opening of ports to fail for rproc_serial.
> In probe guest_connected was set to true, but port_fops_open()
> fails with -EMFILE if guest_connected already is true.

OK, I missed that.  Can you add a comment near the 2nd hunk mentioning
this?


		Amit

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
  2013-03-12  7:34 ` Amit Shah
@ 2013-03-12 11:05   ` Sjur Brændeland
  2013-03-13  0:17     ` Rusty Russell
  2013-03-13 10:03     ` Amit Shah
  0 siblings, 2 replies; 10+ messages in thread
From: Sjur Brændeland @ 2013-03-12 11:05 UTC (permalink / raw)
  To: Amit Shah; +Cc: Linus Walleij, Erwan Yvin, virtualization

On Tue, Mar 12, 2013 at 8:34 AM, Amit Shah <amit.shah@redhat.com> wrote:
> On (Mon) 11 Mar 2013 [16:15:00], sjur.brandeland@stericsson.com wrote:
>> From: Sjur Brćndeland <sjur.brandeland@stericsson.com>
>>
>> This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b.
>>
>> The reverted patch caused opening of ports to fail for rproc_serial.
>> In probe guest_connected was set to true, but port_fops_open()
>> fails with -EMFILE if guest_connected already is true.
>
> OK, I missed that.  Can you add a comment near the 2nd hunk mentioning
> this?

Ok, I ended up rewriting the whole comment here in my attempt
to "mention this". Perhaps it's a bit over the top to write a short essay to
explain two code lines, but anyway here it is. Let me know what you think:

	/*
	 * Normally the port should not accept data when the port is
	 * closed. For generic serial ports, the host won't (shouldn't)
	 * send data till the guest is connected. But this condition
	 * can be reached when a console port is not yet connected (no
	 * tty is spawned) and the other side sends out data over the
	 * vring, or when a remote devices start sending data before
	 * the ports are opened.
	 *
	 * A generic serial port will discard data if not connected,
	 * while console ports and rproc-serial ports accepts data at
	 * any time. rproc-serial is initiated with guest_connect = false
	 * because port_fops_open expects this. Console ports are
	 * hooked up with an HVC console and is initialized with
	 * guest_connected = true.
	 */

Regards,
Sjur
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
  2013-03-12 11:05   ` Sjur Brændeland
@ 2013-03-13  0:17     ` Rusty Russell
  2013-03-13 10:03     ` Amit Shah
  1 sibling, 0 replies; 10+ messages in thread
From: Rusty Russell @ 2013-03-13  0:17 UTC (permalink / raw)
  To: Sjur Brændeland, Amit Shah; +Cc: Linus Walleij, Erwan Yvin, virtualization

Sjur Brændeland <sjurbr@gmail.com> writes:
> On Tue, Mar 12, 2013 at 8:34 AM, Amit Shah <amit.shah@redhat.com> wrote:
>> On (Mon) 11 Mar 2013 [16:15:00], sjur.brandeland@stericsson.com wrote:
>>> From: Sjur Brćndeland <sjur.brandeland@stericsson.com>
>>>
>>> This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b.
>>>
>>> The reverted patch caused opening of ports to fail for rproc_serial.
>>> In probe guest_connected was set to true, but port_fops_open()
>>> fails with -EMFILE if guest_connected already is true.
>>
>> OK, I missed that.  Can you add a comment near the 2nd hunk mentioning
>> this?
>
> Ok, I ended up rewriting the whole comment here in my attempt
> to "mention this". Perhaps it's a bit over the top to write a short essay to
> explain two code lines, but anyway here it is. Let me know what you think:

OK, I'll hold onto this revert for a bit longer then.  Please resubmit
once you're happy.

Thanks,
Rusty.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
  2013-03-12 11:05   ` Sjur Brændeland
  2013-03-13  0:17     ` Rusty Russell
@ 2013-03-13 10:03     ` Amit Shah
  2013-03-13 11:10       ` [PATCHv2] " sjur.brandeland
  1 sibling, 1 reply; 10+ messages in thread
From: Amit Shah @ 2013-03-13 10:03 UTC (permalink / raw)
  To: Sjur Brændeland; +Cc: Linus Walleij, Erwan Yvin, virtualization

On (Tue) 12 Mar 2013 [12:05:03], Sjur Brændeland wrote:
> On Tue, Mar 12, 2013 at 8:34 AM, Amit Shah <amit.shah@redhat.com> wrote:
> > On (Mon) 11 Mar 2013 [16:15:00], sjur.brandeland@stericsson.com wrote:
> >> From: Sjur Brćndeland <sjur.brandeland@stericsson.com>
> >>
> >> This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b.
> >>
> >> The reverted patch caused opening of ports to fail for rproc_serial.
> >> In probe guest_connected was set to true, but port_fops_open()
> >> fails with -EMFILE if guest_connected already is true.
> >
> > OK, I missed that.  Can you add a comment near the 2nd hunk mentioning
> > this?
> 
> Ok, I ended up rewriting the whole comment here in my attempt
> to "mention this". Perhaps it's a bit over the top to write a short essay to
> explain two code lines, but anyway here it is. Let me know what you think:
> 
> 	/*
> 	 * Normally the port should not accept data when the port is
> 	 * closed. For generic serial ports, the host won't (shouldn't)
> 	 * send data till the guest is connected. But this condition
> 	 * can be reached when a console port is not yet connected (no
> 	 * tty is spawned) and the other side sends out data over the
> 	 * vring, or when a remote devices start sending data before
> 	 * the ports are opened.
> 	 *
> 	 * A generic serial port will discard data if not connected,
> 	 * while console ports and rproc-serial ports accepts data at
> 	 * any time. rproc-serial is initiated with guest_connect = false

'guest_connected'

> 	 * because port_fops_open expects this. Console ports are
> 	 * hooked up with an HVC console and is initialized with
> 	 * guest_connected = true.
> 	 */

Yes, it is a bit verbose, but looks fine to me.

Thanks,

		Amit
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCHv2] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
  2013-03-13 10:03     ` Amit Shah
@ 2013-03-13 11:10       ` sjur.brandeland
  2013-03-17 23:51         ` Rusty Russell
  2013-03-18  5:27         ` Amit Shah
  0 siblings, 2 replies; 10+ messages in thread
From: sjur.brandeland @ 2013-03-13 11:10 UTC (permalink / raw)
  To: Rusty Russell, amit.shah
  Cc: sjur, Linus Walleij, Sjur Brændeland, Erwan Yvin,
	virtualization

From: Sjur Brændeland <sjur.brandeland@stericsson.com>


This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b, and
adds a lengthy comment explaining the problem area.

The reverted patch caused opening of ports to fail for rproc_serial.
In probe guest_connected was set to true, but port_fops_open()
fails with -EMFILE if guest_connected already is true.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
 drivers/char/virtio_console.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index e905d5f..e6ba6b7 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1436,7 +1436,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 		 * rproc_serial does not want the console port, only
 		 * the generic port implementation.
 		 */
-		port->host_connected = port->guest_connected = true;
+		port->host_connected = true;
 	else if (!use_multiport(port->portdev)) {
 		/*
 		 * If we're not using multiport support,
@@ -1752,13 +1752,23 @@ static void in_intr(struct virtqueue *vq)
 	port->inbuf = get_inbuf(port);
 
 	/*
-	 * Don't queue up data when port is closed.  This condition
+	 * Normally the port should not accept data when the port is
+	 * closed. For generic serial ports, the host won't (shouldn't)
+	 * send data till the guest is connected. But this condition
 	 * can be reached when a console port is not yet connected (no
-	 * tty is spawned) and the host sends out data to console
-	 * ports.  For generic serial ports, the host won't
-	 * (shouldn't) send data till the guest is connected.
+	 * tty is spawned) and the other side sends out data over the
+	 * vring, or when a remote devices start sending data before
+	 * the ports are opened.
+	 *
+	 * A generic serial port will discard data if not connected,
+	 * while console ports and rproc-serial ports accepts data at
+	 * any time. rproc-serial is initiated with guest_connected to
+	 * false because port_fops_open expects this. Console ports are
+	 * hooked up with an HVC console and is initialized with
+	 * guest_connected to true.
 	 */
-	if (!port->guest_connected)
+
+	if (!port->guest_connected && !is_rproc_serial(port->portdev->vdev))
 		discard_port_data(port);
 
 	spin_unlock_irqrestore(&port->inbuf_lock, flags);
-- 
1.7.5.4

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCHv2] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
  2013-03-13 11:10       ` [PATCHv2] " sjur.brandeland
@ 2013-03-17 23:51         ` Rusty Russell
  2013-03-18  5:27         ` Amit Shah
  1 sibling, 0 replies; 10+ messages in thread
From: Rusty Russell @ 2013-03-17 23:51 UTC (permalink / raw)
  To: amit.shah
  Cc: sjur, Linus Walleij, Sjur Brændeland, Erwan Yvin,
	virtualization

sjur.brandeland@stericsson.com writes:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>
>
> This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b, and
> adds a lengthy comment explaining the problem area.
>
> The reverted patch caused opening of ports to fail for rproc_serial.
> In probe guest_connected was set to true, but port_fops_open()
> fails with -EMFILE if guest_connected already is true.
>
> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>

Needs Amit's Ack.

Thanks,
Rusty.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCHv2] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
  2013-03-13 11:10       ` [PATCHv2] " sjur.brandeland
  2013-03-17 23:51         ` Rusty Russell
@ 2013-03-18  5:27         ` Amit Shah
  2013-03-18  8:51           ` Rusty Russell
  1 sibling, 1 reply; 10+ messages in thread
From: Amit Shah @ 2013-03-18  5:27 UTC (permalink / raw)
  To: sjur.brandeland; +Cc: sjur, Linus Walleij, Erwan Yvin, virtualization

On (Wed) 13 Mar 2013 [12:10:48], sjur.brandeland@stericsson.com wrote:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
> 
> 
> This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b, and
> adds a lengthy comment explaining the problem area.
> 
> The reverted patch caused opening of ports to fail for rproc_serial.
> In probe guest_connected was set to true, but port_fops_open()
> fails with -EMFILE if guest_connected already is true.
> 
> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>

Acked-by: Amit Shah <amit.shah@redhat.com>

		Amit

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCHv2] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
  2013-03-18  5:27         ` Amit Shah
@ 2013-03-18  8:51           ` Rusty Russell
  0 siblings, 0 replies; 10+ messages in thread
From: Rusty Russell @ 2013-03-18  8:51 UTC (permalink / raw)
  To: Amit Shah, sjur.brandeland
  Cc: sjur, Linus Walleij, Erwan Yvin, virtualization

Amit Shah <amit.shah@redhat.com> writes:
> On (Wed) 13 Mar 2013 [12:10:48], sjur.brandeland@stericsson.com wrote:
>> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>> 
>> 
>> This reverts commit 8078db789a92b10ff6e2d713231b5367e014c53b, and
>> adds a lengthy comment explaining the problem area.
>> 
>> The reverted patch caused opening of ports to fail for rproc_serial.
>> In probe guest_connected was set to true, but port_fops_open()
>> fails with -EMFILE if guest_connected already is true.
>> 
>> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
>
> Acked-by: Amit Shah <amit.shah@redhat.com>
>
> 		Amit

Applied to my fixes branch.

Thanks,
Rusty.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-03-18  8:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-11 15:15 [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial" sjur.brandeland
2013-03-12  4:54 ` Rusty Russell
2013-03-12  7:34 ` Amit Shah
2013-03-12 11:05   ` Sjur Brændeland
2013-03-13  0:17     ` Rusty Russell
2013-03-13 10:03     ` Amit Shah
2013-03-13 11:10       ` [PATCHv2] " sjur.brandeland
2013-03-17 23:51         ` Rusty Russell
2013-03-18  5:27         ` Amit Shah
2013-03-18  8:51           ` Rusty Russell

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).