Re: [PATCH] virtio_pci: use 16-bit accessor for queue_enable.

2015-02-09 Thread Michael S. Tsirkin
On Tue, Feb 10, 2015 at 05:05:01PM +1030, Rusty Russell wrote:
> Since PCI is little endian, 8-bit access might work, but the spec section
> is very clear on this:
> 
>   4.1.3.1 Driver Requirements: PCI Device Layout
> 
>   The driver MUST access each field using the “natural” access method,
>   i.e. 32-bit accesses for 32-bit fields, 16-bit accesses for 16-bit
>   fields and 8-bit accesses for 8-bit fields.
> 
> Signed-off-by: Rusty Russell 

Acked-by: Michael S. Tsirkin 

> diff --git a/drivers/virtio/virtio_pci_modern.c 
> b/drivers/virtio/virtio_pci_modern.c
> index f16e462cb4ef..2aa38e59db2e 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
> @@ -294,7 +294,7 @@ static struct virtqueue *setup_vq(struct 
> virtio_pci_device *vp_dev,
>  
>   /* Check if queue is either not available or already active. */
>   num = ioread16(>queue_size);
> - if (!num || ioread8(>queue_enable))
> + if (!num || ioread16(>queue_enable))
>   return ERR_PTR(-ENOENT);
>  
>   if (num & (num - 1)) {
> @@ -394,7 +394,7 @@ static int vp_modern_find_vqs(struct virtio_device *vdev, 
> unsigned nvqs,
>*/
>   list_for_each_entry(vq, >vqs, list) {
>   iowrite16(vq->index, _dev->common->queue_select);
> - iowrite8(1, _dev->common->queue_enable);
> + iowrite16(1, _dev->common->queue_enable);
>   }
>  
>   return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] virtio_pci: use 16-bit accessor for queue_enable.

2015-02-09 Thread Rusty Russell
Since PCI is little endian, 8-bit access might work, but the spec section
is very clear on this:

  4.1.3.1 Driver Requirements: PCI Device Layout

  The driver MUST access each field using the “natural” access method,
  i.e. 32-bit accesses for 32-bit fields, 16-bit accesses for 16-bit
  fields and 8-bit accesses for 8-bit fields.

Signed-off-by: Rusty Russell 

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index f16e462cb4ef..2aa38e59db2e 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -294,7 +294,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
 
/* Check if queue is either not available or already active. */
num = ioread16(>queue_size);
-   if (!num || ioread8(>queue_enable))
+   if (!num || ioread16(>queue_enable))
return ERR_PTR(-ENOENT);
 
if (num & (num - 1)) {
@@ -394,7 +394,7 @@ static int vp_modern_find_vqs(struct virtio_device *vdev, 
unsigned nvqs,
 */
list_for_each_entry(vq, >vqs, list) {
iowrite16(vq->index, _dev->common->queue_select);
-   iowrite8(1, _dev->common->queue_enable);
+   iowrite16(1, _dev->common->queue_enable);
}
 
return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] virtio_pci: use 16-bit accessor for queue_enable.

2015-02-09 Thread Michael S. Tsirkin
On Tue, Feb 10, 2015 at 05:05:01PM +1030, Rusty Russell wrote:
 Since PCI is little endian, 8-bit access might work, but the spec section
 is very clear on this:
 
   4.1.3.1 Driver Requirements: PCI Device Layout
 
   The driver MUST access each field using the “natural” access method,
   i.e. 32-bit accesses for 32-bit fields, 16-bit accesses for 16-bit
   fields and 8-bit accesses for 8-bit fields.
 
 Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Acked-by: Michael S. Tsirkin m...@redhat.com

 diff --git a/drivers/virtio/virtio_pci_modern.c 
 b/drivers/virtio/virtio_pci_modern.c
 index f16e462cb4ef..2aa38e59db2e 100644
 --- a/drivers/virtio/virtio_pci_modern.c
 +++ b/drivers/virtio/virtio_pci_modern.c
 @@ -294,7 +294,7 @@ static struct virtqueue *setup_vq(struct 
 virtio_pci_device *vp_dev,
  
   /* Check if queue is either not available or already active. */
   num = ioread16(cfg-queue_size);
 - if (!num || ioread8(cfg-queue_enable))
 + if (!num || ioread16(cfg-queue_enable))
   return ERR_PTR(-ENOENT);
  
   if (num  (num - 1)) {
 @@ -394,7 +394,7 @@ static int vp_modern_find_vqs(struct virtio_device *vdev, 
 unsigned nvqs,
*/
   list_for_each_entry(vq, vdev-vqs, list) {
   iowrite16(vq-index, vp_dev-common-queue_select);
 - iowrite8(1, vp_dev-common-queue_enable);
 + iowrite16(1, vp_dev-common-queue_enable);
   }
  
   return 0;
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] virtio_pci: use 16-bit accessor for queue_enable.

2015-02-09 Thread Rusty Russell
Since PCI is little endian, 8-bit access might work, but the spec section
is very clear on this:

  4.1.3.1 Driver Requirements: PCI Device Layout

  The driver MUST access each field using the “natural” access method,
  i.e. 32-bit accesses for 32-bit fields, 16-bit accesses for 16-bit
  fields and 8-bit accesses for 8-bit fields.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index f16e462cb4ef..2aa38e59db2e 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -294,7 +294,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
 
/* Check if queue is either not available or already active. */
num = ioread16(cfg-queue_size);
-   if (!num || ioread8(cfg-queue_enable))
+   if (!num || ioread16(cfg-queue_enable))
return ERR_PTR(-ENOENT);
 
if (num  (num - 1)) {
@@ -394,7 +394,7 @@ static int vp_modern_find_vqs(struct virtio_device *vdev, 
unsigned nvqs,
 */
list_for_each_entry(vq, vdev-vqs, list) {
iowrite16(vq-index, vp_dev-common-queue_select);
-   iowrite8(1, vp_dev-common-queue_enable);
+   iowrite16(1, vp_dev-common-queue_enable);
}
 
return 0;
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/