]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'virtio/virtio-next'
authorThierry Reding <treding@nvidia.com>
Thu, 24 Oct 2013 12:36:16 +0000 (14:36 +0200)
committerThierry Reding <treding@nvidia.com>
Thu, 24 Oct 2013 12:36:16 +0000 (14:36 +0200)
1  2 
drivers/net/virtio_net.c

diff --combined drivers/net/virtio_net.c
index 9fbdfcd1e1a0693e96edd908928953097b99742d,ee022714eadb985a19ce8fe160edf735046c9050..9b3481ed1cf38ce23cb048fbbcd6f51c812e567a
@@@ -852,8 -852,13 +852,13 @@@ static int virtnet_set_mac_address(stru
                        return -EINVAL;
                }
        } else if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
-               vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
-                                 addr->sa_data, dev->addr_len);
+               unsigned int i;
+               /* Naturally, this has an atomicity problem. */
+               for (i = 0; i < dev->addr_len; i++)
+                       virtio_cwrite8(vdev,
+                                      offsetof(struct virtio_net_config, mac) +
+                                      i, addr->sa_data[i]);
        }
  
        eth_commit_mac_addr_change(dev, p);
@@@ -938,9 -943,7 +943,9 @@@ static int virtnet_set_queues(struct vi
                return -EINVAL;
        } else {
                vi->curr_queue_pairs = queue_pairs;
 -              schedule_delayed_work(&vi->refill, 0);
 +              /* virtnet_open() will refill when device is going to up. */
 +              if (dev->flags & IFF_UP)
 +                      schedule_delayed_work(&vi->refill, 0);
        }
  
        return 0;
@@@ -1118,11 -1121,6 +1123,11 @@@ static int virtnet_cpu_callback(struct 
  {
        struct virtnet_info *vi = container_of(nfb, struct virtnet_info, nb);
  
 +      mutex_lock(&vi->config_lock);
 +
 +      if (!vi->config_enable)
 +              goto done;
 +
        switch(action & ~CPU_TASKS_FROZEN) {
        case CPU_ONLINE:
        case CPU_DOWN_FAILED:
        default:
                break;
        }
 +
 +done:
 +      mutex_unlock(&vi->config_lock);
        return NOTIFY_OK;
  }
  
@@@ -1276,9 -1271,8 +1281,8 @@@ static void virtnet_config_changed_work
        if (!vi->config_enable)
                goto done;
  
-       if (virtio_config_val(vi->vdev, VIRTIO_NET_F_STATUS,
-                             offsetof(struct virtio_net_config, status),
-                             &v) < 0)
+       if (virtio_cread_feature(vi->vdev, VIRTIO_NET_F_STATUS,
+                                struct virtio_net_config, status, &v) < 0)
                goto done;
  
        if (v & VIRTIO_NET_S_ANNOUNCE) {
@@@ -1500,9 -1494,9 +1504,9 @@@ static int virtnet_probe(struct virtio_
        u16 max_queue_pairs;
  
        /* Find if host supports multiqueue virtio_net device */
-       err = virtio_config_val(vdev, VIRTIO_NET_F_MQ,
-                               offsetof(struct virtio_net_config,
-                               max_virtqueue_pairs), &max_queue_pairs);
+       err = virtio_cread_feature(vdev, VIRTIO_NET_F_MQ,
+                                  struct virtio_net_config,
+                                  max_virtqueue_pairs, &max_queue_pairs);
  
        /* We need at least 2 queue's */
        if (err || max_queue_pairs < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN ||
        dev->vlan_features = dev->features;
  
        /* Configuration may specify what MAC to use.  Otherwise random. */
-       if (virtio_config_val_len(vdev, VIRTIO_NET_F_MAC,
-                                 offsetof(struct virtio_net_config, mac),
-                                 dev->dev_addr, dev->addr_len) < 0)
+       if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
+               virtio_cread_bytes(vdev,
+                                  offsetof(struct virtio_net_config, mac),
+                                  dev->dev_addr, dev->addr_len);
+       else
                eth_hw_addr_random(dev);
  
        /* Set up our device-specific information */
@@@ -1693,7 -1689,7 +1699,7 @@@ static void virtnet_remove(struct virti
        free_netdev(vi->dev);
  }
  
- #ifdef CONFIG_PM
+ #ifdef CONFIG_PM_SLEEP
  static int virtnet_freeze(struct virtio_device *vdev)
  {
        struct virtnet_info *vi = vdev->priv;
@@@ -1743,9 -1739,7 +1749,9 @@@ static int virtnet_restore(struct virti
        vi->config_enable = true;
        mutex_unlock(&vi->config_lock);
  
 +      rtnl_lock();
        virtnet_set_queues(vi, vi->curr_queue_pairs);
 +      rtnl_unlock();
  
        return 0;
  }
@@@ -1778,7 -1772,7 +1784,7 @@@ static struct virtio_driver virtio_net_
        .probe =        virtnet_probe,
        .remove =       virtnet_remove,
        .config_changed = virtnet_config_changed,
- #ifdef CONFIG_PM
+ #ifdef CONFIG_PM_SLEEP
        .freeze =       virtnet_freeze,
        .restore =      virtnet_restore,
  #endif