From a9233ab3a271c24aede030a7a189b1e445089136 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Wed, 14 Aug 2019 11:37:46 -0400 Subject: [PATCH] v2.0.1 Resolve warning on changing MTU Reviewed our locking behavior, made tweaks where necessary --- README.md | 2 +- intrepid.c | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7a7695f..c14cb4f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Version 2.0.0 +Version 2.0.1 This is the kernel object portion of the Intrepid Control Systems SocketCAN support. For SocketCAN to work with Intrepid devices you will need to have this kernel object loaded on your system. Once the module is built and loaded run [icsscand](https://github.com/intrepidcs/icsscand) to turn on SocketCAN support. diff --git a/intrepid.c b/intrepid.c index 3a88112..b11465d 100644 --- a/intrepid.c +++ b/intrepid.c @@ -57,7 +57,7 @@ #define KO_DESC "Netdevice driver for Intrepid CAN/Ethernet devices" #define KO_MAJOR 2 #define KO_MINOR 0 -#define KO_PATCH 0 +#define KO_PATCH 1 #define KO_VERSION str(KO_MAJOR) "." str(KO_MINOR) "." str(KO_PATCH) #define KO_VERSION_INT (KO_MAJOR << 16) | (KO_MINOR << 8) | KO_PATCH @@ -142,12 +142,12 @@ static void intrepid_unpause_all_queues(void) continue; ics = netdev_priv(dev); + spin_lock_bh(&ics->lock); if (ics->is_stopped) { - spin_lock_bh(&ics->lock); netif_wake_queue(dev); ics->is_stopped = 0; - spin_unlock_bh(&ics->lock); } + spin_unlock_bh(&ics->lock); } } @@ -161,12 +161,12 @@ static void intrepid_pause_all_queues(void) continue; ics = netdev_priv(dev); + spin_lock_bh(&ics->lock); if (!ics->is_stopped) { - spin_lock_bh(&ics->lock); ics->is_stopped = 1; netif_stop_queue(dev); - spin_unlock_bh(&ics->lock); } + spin_unlock_bh(&ics->lock); } } @@ -347,6 +347,7 @@ static int intrepid_add_can_if(struct intrepid_netdevice **result, const char *r dev->flags |= IFF_ECHO; dev->min_mtu = CAN_MTU; dev->max_mtu = CANFD_MTU; + dev->mtu = CANFD_MTU; /* TODO: Check CAN-FD support from usermode daemon */ dev->netdev_ops = &intrepid_netdevice_ops; if (requestedName && ((aliasLen = strlen(requestedName)) > 0) && aliasLen < IFALIASZ) { dev->ifalias = kzalloc(sizeof(struct dev_ifalias) + aliasLen + 1, GFP_KERNEL); @@ -371,10 +372,6 @@ static int intrepid_add_can_if(struct intrepid_netdevice **result, const char *r goto exit; } - if (dev_set_mtu(dev, CANFD_MTU)) { - pr_alert("intrepid: Could not set MTU\n"); - } - net_devices[i] = dev; *result = ics; @@ -541,6 +538,7 @@ static int intrepid_read_messages(int device_index, unsigned int count) stats = &device->stats; ics = netdev_priv(device); + spin_lock_bh(&ics->lock); currentPosition = ics->from_user; if (count != 1) pr_info("intrepid: reading %d messages\n", count); @@ -569,6 +567,7 @@ static int intrepid_read_messages(int device_index, unsigned int count) pr_warn("intrepid: Dropping message on %s, dropped by kernel", device->name); } + spin_unlock_bh(&ics->lock); return 0; }