# Patches to Sierra Linux QMI drivers version S2.39N2.60

**URL:** <https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-39n2-60/19221>\
**Category:** MC/EM Series\
**Created:** [February 3, 2020, 8:55am UTC](https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-39n2-60/19221 "2020-02-03T08:55:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![samveen](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@samveen](https://forum.sierrawireless.com/u/samveen)\
**Post date:** [February 3, 2020, 8:55am UTC](https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-39n2-60/19221/1 "2020-02-03T08:55:12Z")

</div>

I am glad to see that my previous patch to the Makefile for the [Linux QMI driver ver. S2.37N2.57](https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-37n2-57/16899) has been included into ver. S2.38N2.59. However a new build artifact has been introduced that is not cleaned up.  
I am attaching the patch for it here.

My work is an attempt to create a DKMS module for the Linux Qmi drivers so that I don’t have to recompile the module every time I update my kernel on Ubuntu (bionic). It can be found at [https://github.com/samveen/MC7710\_driver\_builder](https://github.com/samveen/MC7710_driver_builder)  
Regards,  
Samveen

[SierraLinuxQMIdriversS2.39N2.60.patch.gz](https://forum.sierrawireless.com/uploads/short-url/ffLTEDpvAUIFyvUpdkgKjQ6d6j2.gz) (306 Bytes)

---

<div class="post-metadata">

**Author:** ![samveen](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@samveen](https://forum.sierrawireless.com/u/samveen)\
**Post date:** [February 25, 2020, 1:00pm UTC](https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-39n2-60/19221/2 "2020-02-25T13:00:00Z")

</div>

While building the module out-of-kernel-tree for a kernel version that is installed, but not the running kernel, the DKMS build fails as the Makefiles for the GobiNet and the GobiSerial drivers use the current kernel version using `uname`. This leads to issues with DKMS post-install auto-triggered builds, as expected. A 2nd patch to fix this issue (that implements using the variables that are provided by DKMS) is attached below.

[SierraLinuxQMIdriversS2.39N2.60-2.patch.gz](https://forum.sierrawireless.com/uploads/short-url/IOb4zqxhRFHqVAYVTRLOY54lsa.gz) (513 Bytes)

---

<div class="post-metadata">

**Author:** ![anon56110884](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@anon56110884](https://forum.sierrawireless.com/u/anon56110884)\
**Post date:** [February 25, 2020, 6:12pm UTC](https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-39n2-60/19221/3 "2020-02-25T18:12:17Z")

</div>

Hi @samveen  
I’ve passed on your patched to our dev team for review. Thank you.  
Regards  
Alan

---

<div class="post-metadata">

**Author:** ![anon56110884](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@anon56110884](https://forum.sierrawireless.com/u/anon56110884)\
**Post date:** [April 14, 2020, 8:55pm UTC](https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-39n2-60/19221/4 "2020-04-14T20:55:36Z")

</div>

Hi @samveen

We’ll be pulling in the changes that you’ve shared to support DKMS with the next release. FYI, below is a conf file that we’ll also be providing:

> PACKAGE\_NAME=SierraLinuxQMIdrivers  
> PACKAGE\_VERSION=Sx.xxNx.xx  
> MAKE=“make -C GobiSerial && make -C GobiNet”  
> CLEAN=“make -C GobiSerial clean; make -C GobiNet clean”
> 
> BUILT\_MODULE\_NAME[0]=GobiSerial  
> BUILT\_MODULE\_LOCATION[0]=GobiSerial/  
> BUILT\_MODULE\_NAME[1]=GobiNet  
> BUILT\_MODULE\_LOCATION[1]=GobiNet/  
> AUTOINSTALL=“YES”

“x” will be actual release numbers.

Let us know if you have any comments. Thank you for your support.

Regards  
Alan

---

<div class="post-metadata">

**Author:** ![samveen](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@samveen](https://forum.sierrawireless.com/u/samveen)\
**Post date:** [June 25, 2020, 12:17pm UTC](https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-39n2-60/19221/5 "2020-06-25T12:17:55Z")

</div>

Hi Alan,

First apologies on the late reply. It’s been a world changing time 😉.

DKMS is built to be triggered automagically. This means that it can be triggered in 4 cases:

1. DKMS Package install time - for the currently running kernel; auto-magically
2. Kernel package install time - a new kernel; auto-magically
3. User request to DKMS for currently kernels
4. User request to DKMS for installed alternate kernels

The DKMS conf provided above and the existing makefiles (as of S2.39N260) WILL FAIL FOR CASE 2 and CASE 4 above. The reason is that the makefiles use the current running version of the kernel as the base for the kernel source directory, while DKMS expects that the module build framework should use the kernel version provided by DKMS as part of the `MAKE=` entry of the dkms conf file.

An example is

```
MAKE="bash build.sh --kver $kernelver"

```

In fact, the module source of the Sierra modules actually requires manual editing in the kernel includes tree to build correctly, name in the file `memcontrol.h`. Quoting directly from _GobiNet/GobiUSBNet.c_

```
#ifdef CONFIG_MEMCG
#define MEMCG_NOT_FIX
#ifdef MEMCG_NOT_FIX
#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 3,13,0 ) &&\
       LINUX_VERSION_CODE < KERNEL_VERSION( 4,4,0 ))
#warning "Remove memcontrol.h task_in_memcg_oom warning : replace 'return p->memcg_oom.memcg;' to 'return p->memcg_oom.memcg==NULL ? 0 : 1;' in function task_in_memcg_oom"
#warning "Commnet '#define MEMCG_NOT_FIX' above after fix applied."
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION( 4,4,0 ) )
#warning "Remove memcontrol.h task_in_memcg_oom warning : replace 'return p->memcg_in_oom;' to 'return p->memcg_in_oom==NULL ? 0 : 1;' in function task_in_memcg_oom"
#warning "Commnet '#define MEMCG_NOT_FIX' above after fix applied."
#endif
#endif
#endif

```

With this, it is not even possible to get the module under DKMS unless I add a whole framework around it to do this editing in an automated way (I did that at [https://github.com/samveen/MC7710\_driver\_builder](https://github.com/samveen/MC7710_driver_builder) ).

With disappointment and regards,  
Samveen

---

<div class="post-metadata">

**Author:** ![anon56110884](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@anon56110884](https://forum.sierrawireless.com/u/anon56110884)\
**Post date:** [June 25, 2020, 4:56pm UTC](https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-39n2-60/19221/6 "2020-06-25T16:56:49Z")

</div>

Hi @samveen  
I will certainly share your feedback with our R&D.  
Regards  
Alan

---

<div class="post-metadata">

**Author:** ![rob.dinoff.ext](https://avatars.discourse-cdn.com/v4/letter/r/9fc29f/32.png) [@rob.dinoff.ext](https://forum.sierrawireless.com/u/rob.dinoff.ext)\
**Post date:** [January 13, 2021, 3:55pm UTC](https://forum.sierrawireless.com/t/patches-to-sierra-linux-qmi-drivers-version-s2-39n2-60/19221/7 "2021-01-13T15:55:38Z")

</div>

this is still an issue with S2.42N2.64 … here is the patch I created KVER overriding uname --r where appropriate. tested on ubuntu

> diff --git a/GobiNet/Makefile b/GobiNet/Makefile  
> index 43ad240…0d2ea9c 100644  
> — a/GobiNet/Makefile  
> +++ b/GobiNet/Makefile  
> @@ -1,8 +1,9 @@  
> obj-m := GobiNet.o  
> GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o  
> -KDIR := /lib/modules/$(shell uname -r)/build  
> +KVER := $(shell uname -r)  
> +KDIR := /lib/modules/$(KVER)/build  
> PWD := $(shell pwd)  
> -OUTPUTDIR=/lib/modules/`uname -r`/kernel/drivers/net/usb/  
> +OUTPUTDIR=/lib/modules/$(KVER)/kernel/drivers/net/usb/  
> #KBUILD\_CFLAGS += -DQOS\_SIMULATE  
> #KBUILD\_CFLAGS += -DTX\_XMIT\_SIERRA -DTX\_URB\_MONITOR  
> ifdef TX\_URB\_MONITOR  
> diff --git a/GobiSerial/Makefile b/GobiSerial/Makefile  
> index 1349af8…9b7b403 100644  
> — a/GobiSerial/Makefile  
> +++ b/GobiSerial/Makefile  
> @@ -1,7 +1,8 @@  
> obj-m := GobiSerial.o  
> -KDIR := /lib/modules/$(shell uname -r)/build  
> +KVER := $(shell uname -r)  
> +KDIR := /lib/modules/$(KVER)/build  
> PWD := $(shell pwd)  
> -OUTPUTDIR=/lib/modules/`uname -r`/kernel/drivers/usb/serial/  
> +OUTPUTDIR=/lib/modules/$(KVER)/kernel/drivers/usb/serial/
> 
> PI\_KDIR := ~/k/linux-rpi-3.6.y  
> PI\_CCPREFIX=~/toolchain/rpi/tools-master/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-  
> diff --git a/dkms/dkms.conf b/dkms/dkms.conf  
> index 0d9ab82…d3d362a 100644  
> — a/dkms/dkms.conf  
> +++ b/dkms/dkms.conf  
> @@ -1,6 +1,6 @@  
> PACKAGE\_NAME=SierraLinuxQMIdrivers  
> PACKAGE\_VERSION=S2.42N2.64  
> -MAKE=“make -C GobiSerial && make -C GobiNet”  
> +MAKE=“make -C GobiSerial KVER=${kernelver} && make -C GobiNet KVER=${kernelver}”  
> CLEAN=“make -C GobiSerial clean; make -C GobiNet clean”
> 
> BUILT\_MODULE\_NAME[0]=GobiSerial
