Re: [PATCH v5] can: virtio: Initial virtio CAN driver.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I thought there would be some more comments coming and I could address everything in one chunk. Not the case, besides your comments silence.

On 08.01.24 20:34, Christophe JAILLET wrote:

Hi,
a few nits below, should there be a v6.


I'm sure there will be but not so soon. Probably after acceptance of the virtio CAN specification or after change requests to the specification are received and the driver has to be adapted to an updated draft.



+static int virtio_can_alloc_tx_idx(struct virtio_can_priv *priv)
+{
+    int tx_idx;
+
+    tx_idx = ida_alloc_range(&priv->tx_putidx_ida, 0,
+                 priv->can.echo_skb_max - 1, GFP_KERNEL);
+    if (tx_idx >= 0)
+        atomic_add(1, &priv->tx_inflight);

atomic_inc() ?


Yes, will be done, already in my local code base.



+
+    return tx_idx;
+}
+
+static void virtio_can_free_tx_idx(struct virtio_can_priv *priv,
+                   unsigned int idx)
+{
+    ida_free(&priv->tx_putidx_ida, idx);
+    atomic_sub(1, &priv->tx_inflight);

atomic_dec() ?


See above.



+}

...

+static int virtio_can_probe(struct virtio_device *vdev)
+{
+    struct virtio_can_priv *priv;
+    struct net_device *dev;
+    int err;
+
+    dev = alloc_candev(sizeof(struct virtio_can_priv),
+               VIRTIO_CAN_ECHO_SKB_MAX);
+    if (!dev)
+        return -ENOMEM;
+
+    priv = netdev_priv(dev);
+
+    ida_init(&priv->tx_putidx_ida);
+
+    netif_napi_add(dev, &priv->napi, virtio_can_rx_poll);
+    netif_napi_add(dev, &priv->napi_tx, virtio_can_tx_poll);
+
+    SET_NETDEV_DEV(dev, &vdev->dev);
+
+    priv->dev = dev;
+    priv->vdev = vdev;
+    vdev->priv = priv;
+
+    priv->can.do_set_mode = virtio_can_set_mode;
+    /* Set Virtio CAN supported operations */
+    priv->can.ctrlmode_supported = CAN_CTRLMODE_BERR_REPORTING;
+    if (virtio_has_feature(vdev, VIRTIO_CAN_F_CAN_FD)) {
+        err = can_set_static_ctrlmode(dev, CAN_CTRLMODE_FD);
+        if (err != 0)
+            goto on_failure;
+    }
+
+    /* Initialize virtqueues */
+    err = virtio_can_find_vqs(priv);
+    if (err != 0)
+        goto on_failure;
+
+    INIT_LIST_HEAD(&priv->tx_list);
+
+    spin_lock_init(&priv->tx_lock);
+    mutex_init(&priv->ctrl_lock);
+
+    init_completion(&priv->ctrl_done);
+
+    virtio_can_populate_vqs(vdev);
+
+    register_virtio_can_dev(dev);

Check for error?


    err = register_virtio_can_dev(dev);
    if (err) {
        virtio_can_del_vq(vdev);
        dev_err(&vdev->dev, "Couldn't register candev (err=%d)\n", err);
        goto on_failure;
    }



CJ

+
+    napi_enable(&priv->napi);
+    napi_enable(&priv->napi_tx);
+
+    /* Request device going live */
+    virtio_device_ready(vdev); /* Optionally done by virtio_dev_probe() */


The virtio_device_ready() will also be removed. The caller will make the device live anyway after return. There are no operations between the virtio_device_ready() and the return 0 which make it necessary to have the device live early before the return.


+
+    return 0;
+
+on_failure:
+    virtio_can_free_candev(dev);
+    return err;
+}

...






[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux