All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio_console: Use virtio device index to generate port name
@ 2013-01-17 12:23 sjur.brandeland
  2013-01-21 23:23 ` Rusty Russell
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: sjur.brandeland @ 2013-01-17 12:23 UTC (permalink / raw)
  To: Amit Shah; +Cc: virtualization, Sjur Brændeland, Michael S. Tsirkin

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

Use virtio device index for creating unique device port names.
Current index allocation in virtio is based on a monotonically
increasing variable "index". A better handling of this is to
use device index which is allocated by ida.

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

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index c17b053..031be0b 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -61,9 +61,6 @@ struct ports_driver_data {
 	/* List of all the devices we're handling */
 	struct list_head portdevs;
 
-	/* Number of devices this driver is handling */
-	unsigned int index;
-
 	/*
 	 * This is used to keep track of the number of hvc consoles
 	 * spawned by this driver.  This number is given as the first
@@ -169,9 +166,6 @@ struct ports_device {
 	/* Array of per-port IO virtqueues */
 	struct virtqueue **in_vqs, **out_vqs;
 
-	/* Used for numbering devices for sysfs and debugfs */
-	unsigned int drv_index;
-
 	/* Major number for this device.  Ports will be created as minors. */
 	int chr_major;
 };
@@ -1415,7 +1409,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 	}
 	port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev,
 				  devt, port, "vport%up%u",
-				  port->portdev->drv_index, id);
+				  port->portdev->vdev->index, id);
 	if (IS_ERR(port->dev)) {
 		err = PTR_ERR(port->dev);
 		dev_err(&port->portdev->vdev->dev,
@@ -1470,7 +1464,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 		 * inspect a port's state at any time
 		 */
 		sprintf(debugfs_name, "vport%up%u",
-			port->portdev->drv_index, id);
+			port->portdev->vdev->index, id);
 		port->debugfs_file = debugfs_create_file(debugfs_name, 0444,
 							 pdrvdata.debugfs_dir,
 							 port,
@@ -1961,16 +1955,12 @@ static int virtcons_probe(struct virtio_device *vdev)
 	portdev->vdev = vdev;
 	vdev->priv = portdev;
 
-	spin_lock_irq(&pdrvdata_lock);
-	portdev->drv_index = pdrvdata.index++;
-	spin_unlock_irq(&pdrvdata_lock);
-
 	portdev->chr_major = register_chrdev(0, "virtio-portsdev",
 					     &portdev_fops);
 	if (portdev->chr_major < 0) {
 		dev_err(&vdev->dev,
 			"Error %d registering chrdev for device %u\n",
-			portdev->chr_major, portdev->drv_index);
+			portdev->chr_major, vdev->index);
 		err = portdev->chr_major;
 		goto free;
 	}
-- 
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] 7+ messages in thread

* Re: [PATCH] virtio_console: Use virtio device index to generate port name
  2013-01-17 12:23 [PATCH] virtio_console: Use virtio device index to generate port name sjur.brandeland
@ 2013-01-21 23:23 ` Rusty Russell
  2013-01-25  9:20 ` Amit Shah
  2013-02-11 15:55 ` Amit Shah
  2 siblings, 0 replies; 7+ messages in thread
From: Rusty Russell @ 2013-01-21 23:23 UTC (permalink / raw)
  To: Amit Shah; +Cc: virtualization, Sjur Brændeland, Michael S. Tsirkin

sjur.brandeland@stericsson.com writes:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>
> Use virtio device index for creating unique device port names.
> Current index allocation in virtio is based on a monotonically
> increasing variable "index". A better handling of this is to
> use device index which is allocated by ida.
>
> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>

This seems to make sense, but I'd need Amit's Ack to verify that the
current numbering isn't important for anyone.

Thanks,
Rusty.

> ---
>  drivers/char/virtio_console.c |   16 +++-------------
>  1 files changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
> index c17b053..031be0b 100644
> --- a/drivers/char/virtio_console.c
> +++ b/drivers/char/virtio_console.c
> @@ -61,9 +61,6 @@ struct ports_driver_data {
>  	/* List of all the devices we're handling */
>  	struct list_head portdevs;
>  
> -	/* Number of devices this driver is handling */
> -	unsigned int index;
> -
>  	/*
>  	 * This is used to keep track of the number of hvc consoles
>  	 * spawned by this driver.  This number is given as the first
> @@ -169,9 +166,6 @@ struct ports_device {
>  	/* Array of per-port IO virtqueues */
>  	struct virtqueue **in_vqs, **out_vqs;
>  
> -	/* Used for numbering devices for sysfs and debugfs */
> -	unsigned int drv_index;
> -
>  	/* Major number for this device.  Ports will be created as minors. */
>  	int chr_major;
>  };
> @@ -1415,7 +1409,7 @@ static int add_port(struct ports_device *portdev, u32 id)
>  	}
>  	port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev,
>  				  devt, port, "vport%up%u",
> -				  port->portdev->drv_index, id);
> +				  port->portdev->vdev->index, id);
>  	if (IS_ERR(port->dev)) {
>  		err = PTR_ERR(port->dev);
>  		dev_err(&port->portdev->vdev->dev,
> @@ -1470,7 +1464,7 @@ static int add_port(struct ports_device *portdev, u32 id)
>  		 * inspect a port's state at any time
>  		 */
>  		sprintf(debugfs_name, "vport%up%u",
> -			port->portdev->drv_index, id);
> +			port->portdev->vdev->index, id);
>  		port->debugfs_file = debugfs_create_file(debugfs_name, 0444,
>  							 pdrvdata.debugfs_dir,
>  							 port,
> @@ -1961,16 +1955,12 @@ static int virtcons_probe(struct virtio_device *vdev)
>  	portdev->vdev = vdev;
>  	vdev->priv = portdev;
>  
> -	spin_lock_irq(&pdrvdata_lock);
> -	portdev->drv_index = pdrvdata.index++;
> -	spin_unlock_irq(&pdrvdata_lock);
> -
>  	portdev->chr_major = register_chrdev(0, "virtio-portsdev",
>  					     &portdev_fops);
>  	if (portdev->chr_major < 0) {
>  		dev_err(&vdev->dev,
>  			"Error %d registering chrdev for device %u\n",
> -			portdev->chr_major, portdev->drv_index);
> +			portdev->chr_major, vdev->index);
>  		err = portdev->chr_major;
>  		goto free;
>  	}
> -- 
> 1.7.5.4
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH] virtio_console: Use virtio device index to generate port name
  2013-01-17 12:23 [PATCH] virtio_console: Use virtio device index to generate port name sjur.brandeland
  2013-01-21 23:23 ` Rusty Russell
@ 2013-01-25  9:20 ` Amit Shah
  2013-02-11 13:12   ` Sjur Brændeland
  2013-02-11 15:55 ` Amit Shah
  2 siblings, 1 reply; 7+ messages in thread
From: Amit Shah @ 2013-01-25  9:20 UTC (permalink / raw)
  To: sjur.brandeland; +Cc: virtualization, Michael S. Tsirkin

On (Thu) 17 Jan 2013 [13:23:17], sjur.brandeland@stericsson.com wrote:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
> 
> Use virtio device index for creating unique device port names.
> Current index allocation in virtio is based on a monotonically
> increasing variable "index". A better handling of this is to
> use device index which is allocated by ida.

This should be fine.  I'm wondering, though, if there's something else
you need from the naming scheme (esp. considering the next patch)?

		Amit

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

* Re: [PATCH] virtio_console: Use virtio device index to generate port name
  2013-01-25  9:20 ` Amit Shah
@ 2013-02-11 13:12   ` Sjur Brændeland
  2013-02-11 15:54     ` Amit Shah
  0 siblings, 1 reply; 7+ messages in thread
From: Sjur Brændeland @ 2013-02-11 13:12 UTC (permalink / raw)
  To: Amit Shah; +Cc: Michael S. Tsirkin, virtualization


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

On Fri, Jan 25, 2013 at 10:20 AM, Amit Shah <amit.shah@redhat.com> wrote:

> On (Thu) 17 Jan 2013 [13:23:17], sjur.brandeland@stericsson.com wrote:
> > From: Sjur Brændeland <sjur.brandeland@stericsson.com>
> >
> > Use virtio device index for creating unique device port names.
> > Current index allocation in virtio is based on a monotonically
> > increasing variable "index". A better handling of this is to
> > use device index which is allocated by ida.
>
> This should be fine.  I'm wondering, though, if there's something else
> you need from the naming scheme (esp. considering the next patch)?
>

This current patch solves the most critical issue - that the device name
changes for every modem reboot. This is a show-stopper for me. So it would
be
great if this patch could go upstream. The other problem that device name
is non-deterministic is currently only a theoretical problem as we have
only one
remoteproc device.

Regards,
Sjur

[-- Attachment #1.2: Type: text/html, Size: 1486 bytes --]

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

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

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

* Re: [PATCH] virtio_console: Use virtio device index to generate port name
  2013-02-11 13:12   ` Sjur Brændeland
@ 2013-02-11 15:54     ` Amit Shah
  0 siblings, 0 replies; 7+ messages in thread
From: Amit Shah @ 2013-02-11 15:54 UTC (permalink / raw)
  To: Sjur Brændeland; +Cc: Michael S. Tsirkin, virtualization

On (Mon) 11 Feb 2013 [14:12:52], Sjur Brændeland wrote:
> On Fri, Jan 25, 2013 at 10:20 AM, Amit Shah <amit.shah@redhat.com> wrote:
> 
> > On (Thu) 17 Jan 2013 [13:23:17], sjur.brandeland@stericsson.com wrote:
> > > From: Sjur Brændeland <sjur.brandeland@stericsson.com>
> > >
> > > Use virtio device index for creating unique device port names.
> > > Current index allocation in virtio is based on a monotonically
> > > increasing variable "index". A better handling of this is to
> > > use device index which is allocated by ida.
> >
> > This should be fine.  I'm wondering, though, if there's something else
> > you need from the naming scheme (esp. considering the next patch)?
> 
> This current patch solves the most critical issue - that the device name
> changes for every modem reboot. This is a show-stopper for me. So it would
> be
> great if this patch could go upstream. The other problem that device name
> is non-deterministic is currently only a theoretical problem as we have
> only one
> remoteproc device.

OK - I've no problem with the patch.

		Amit

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

* Re: [PATCH] virtio_console: Use virtio device index to generate port name
  2013-01-17 12:23 [PATCH] virtio_console: Use virtio device index to generate port name sjur.brandeland
  2013-01-21 23:23 ` Rusty Russell
  2013-01-25  9:20 ` Amit Shah
@ 2013-02-11 15:55 ` Amit Shah
  2013-02-12  5:56   ` Rusty Russell
  2 siblings, 1 reply; 7+ messages in thread
From: Amit Shah @ 2013-02-11 15:55 UTC (permalink / raw)
  To: sjur.brandeland; +Cc: virtualization, Michael S. Tsirkin

On (Thu) 17 Jan 2013 [13:23:17], sjur.brandeland@stericsson.com wrote:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
> 
> Use virtio device index for creating unique device port names.
> Current index allocation in virtio is based on a monotonically
> increasing variable "index". A better handling of this is to
> use device index which is allocated by ida.
> 
> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>

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

Rusty, please pick this one up.

Thanks,

		Amit

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

* Re: [PATCH] virtio_console: Use virtio device index to generate port name
  2013-02-11 15:55 ` Amit Shah
@ 2013-02-12  5:56   ` Rusty Russell
  0 siblings, 0 replies; 7+ messages in thread
From: Rusty Russell @ 2013-02-12  5:56 UTC (permalink / raw)
  To: Amit Shah, sjur.brandeland; +Cc: virtualization, Michael S. Tsirkin

Amit Shah <amit.shah@redhat.com> writes:

> On (Thu) 17 Jan 2013 [13:23:17], sjur.brandeland@stericsson.com wrote:
>> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>> 
>> Use virtio device index for creating unique device port names.
>> Current index allocation in virtio is based on a monotonically
>> increasing variable "index". A better handling of this is to
>> use device index which is allocated by ida.
>> 
>> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
>
> Acked-by: Amit Shah <amit.shah@redhat.com>
>
> Rusty, please pick this one up.

In my virtio-next queue now...

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

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

end of thread, other threads:[~2013-02-12  5:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-17 12:23 [PATCH] virtio_console: Use virtio device index to generate port name sjur.brandeland
2013-01-21 23:23 ` Rusty Russell
2013-01-25  9:20 ` Amit Shah
2013-02-11 13:12   ` Sjur Brændeland
2013-02-11 15:54     ` Amit Shah
2013-02-11 15:55 ` Amit Shah
2013-02-12  5:56   ` Rusty Russell

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.