Page 1 of 1

blackmagic-io module doesn't compile on kernel 5.15

PostPosted: Tue Nov 09, 2021 3:09 pm
by goldyfruit
Just tried with kernel 5.15 and it does not compile as well.
Code: Select all
# cat /var/lib/dkms/blackmagic-io/12.2a12/build/make.log
DKMS make.log for blackmagic-io-12.2a12 for kernel 5.15.0-76051500-generic (x86_64)
Fri Nov  5 01:46:43 PM EDT 2021
touch .blackmagic.o.cmd

make -C /lib/modules/5.15.0-76051500-generic/build M=/var/lib/dkms/blackmagic-io/12.2a12/build
make[1]: Entering directory '/usr/src/linux-headers-5.15.0-76051500-generic'
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bmio_client.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bmio_dev.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bmio_device.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bmio_driver.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bmio_serial.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bmio_export.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bmio_pci_ids.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bm_locks.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bm_mm.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bm_pci.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bm_util.o
  SHIPPED /var/lib/dkms/blackmagic-io/12.2a12/build/blackmagic.o
  CC [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/bmio_audio.o
/var/lib/dkms/blackmagic-io/12.2a12/build/bm_mm.c: In function ‘bm_dma_get_physical_segment’:
/var/lib/dkms/blackmagic-io/12.2a12/build/bm_mm.c:331:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  331 |         addr64_t startAddr = dlist->addrs[page_n] + page_offset;
      |         ^~~~~~~~
/var/lib/dkms/blackmagic-io/12.2a12/build/bmio_serial.c: In function ‘bmio_serial_driver_init’:
/var/lib/dkms/blackmagic-io/12.2a12/build/bmio_serial.c:307:37: error: implicit declaration of function ‘alloc_tty_driver’ [-Werror=implicit-function-declaration]
  307 |         struct tty_driver* serial = alloc_tty_driver(MAX_SERIAL_LINES);
      |                                     ^~~~~~~~~~~~~~~~
/var/lib/dkms/blackmagic-io/12.2a12/build/bmio_serial.c:307:37: warning: initialization of ‘struct tty_driver *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
/var/lib/dkms/blackmagic-io/12.2a12/build/bmio_serial.c:327:17: error: implicit declaration of function ‘put_tty_driver’ [-Werror=implicit-function-declaration]
  327 |                 put_tty_driver(serial);
      |                 ^~~~~~~~~~~~~~
  LD [M]  /var/lib/dkms/blackmagic-io/12.2a12/build/snd_blackmagic-io.o
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/blackmagic-io/12.2a12/build/bmio_serial.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:1874: /var/lib/dkms/blackmagic-io/12.2a12/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.0-76051500-generic'
make: *** [Makefile:47: all] Error 2
Code: Select all
# cat /var/lib/dkms/blackmagic/12.2a12/build/make.log
DKMS make.log for blackmagic-12.2a12 for kernel 5.15.0-76051500-generic (x86_64)
Fri Nov  5 01:47:36 PM EDT 2021
touch .bmd-support.o.cmd
make -C /lib/modules/5.15.0-76051500-generic/build M=/var/lib/dkms/blackmagic/12.2a12/build
make[1]: Entering directory '/usr/src/linux-headers-5.15.0-76051500-generic'
  CC [M]  /var/lib/dkms/blackmagic/12.2a12/build/blackmagic_serial.o
  CC [M]  /var/lib/dkms/blackmagic/12.2a12/build/blackmagic_core.o
  CC [M]  /var/lib/dkms/blackmagic/12.2a12/build/blackmagic_lib.o
  CC [M]  /var/lib/dkms/blackmagic/12.2a12/build/blackmagic_dma.o
  CC [M]  /var/lib/dkms/blackmagic/12.2a12/build/blackmagic_gate.o
  SHIPPED /var/lib/dkms/blackmagic/12.2a12/build/bmd-support.o
/var/lib/dkms/blackmagic/12.2a12/build/blackmagic_serial.c: In function ‘blackmagic_serial_init’:
/var/lib/dkms/blackmagic/12.2a12/build/blackmagic_serial.c:616:18: error: implicit declaration of function ‘alloc_tty_driver’ [-Werror=implicit-function-declaration]
  616 |         driver = alloc_tty_driver(BLACKMAGIC_SERIAL_MINORS);
      |                  ^~~~~~~~~~~~~~~~
/var/lib/dkms/blackmagic/12.2a12/build/blackmagic_serial.c:616:16: warning: assignment to ‘struct tty_driver *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  616 |         driver = alloc_tty_driver(BLACKMAGIC_SERIAL_MINORS);
      |                ^
/var/lib/dkms/blackmagic/12.2a12/build/blackmagic_serial.c:642:9: error: implicit declaration of function ‘put_tty_driver’ [-Werror=implicit-function-declaration]
  642 |         put_tty_driver(driver);
      |         ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/blackmagic/12.2a12/build/blackmagic_serial.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:1874: /var/lib/dkms/blackmagic/12.2a12/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.0-76051500-generic'
make: *** [Makefile:44: all] Error 2

Re: blackmagic-io module doesn't compile on kernel 5.15

PostPosted: Mon Nov 15, 2021 6:23 pm
by NVieville
Hello goldyfruit,

First attempt to fix these issues. As usual, kernel 5.15.xx hasn't landed yet on my machine so patches are provided 'as is' and are not tested, unless for the first one that fixes warnings even on kernel 5.14.xx.

blackmagic-io-12.2a12-001-fix_5.14.xx_warnings.patch:
Code: Select all
diff -Naur ./blackmagic-io-12.2a12.orig/bm_mm.c ./blackmagic-io-12.2a12/bm_mm.c
--- ./blackmagic-io-12.2a12.orig/bm_mm.c   2021-10-18 04:26:46.000000000 +0200
+++ ./blackmagic-io-12.2a12/bm_mm.c   2021-11-15 18:34:48.376452824 +0100
@@ -314,6 +314,7 @@
 {
    size_t page_n;
    vm_offset_t page_offset;
+   addr64_t startAddr;
 
    if (dlist->contig)
    {
@@ -328,7 +329,7 @@
    if (page_n > dlist->length)
       return 0;
 
-   addr64_t startAddr = dlist->addrs[page_n] + page_offset;
+   startAddr = dlist->addrs[page_n] + page_offset;
 
    if (lenLimit)
    {


blackmagic-io-12.2a12-002-fix_5.15.xx_tty_driver_functions_names.patch:
Code: Select all
diff -Naur ./blackmagic-io-12.2a12.orig/bmio_serial.c ./blackmagic-io-12.2a12/bmio_serial.c
--- ./blackmagic-io-12.2a12.orig/bmio_serial.c   2021-10-18 04:26:46.000000000 +0200
+++ ./blackmagic-io-12.2a12/bmio_serial.c   2021-11-15 18:56:26.019348934 +0100
@@ -303,8 +303,13 @@
 int bmio_serial_driver_init(void)
 {
    int ret;
+   struct tty_driver* serial;
 
-   struct tty_driver* serial = alloc_tty_driver(MAX_SERIAL_LINES);
+#if KERNEL_VERSION_OR_LATER(5, 15, 0)
+   serial = tty_alloc_driver(MAX_SERIAL_LINES, 0);
+#else
+   serial = alloc_tty_driver(MAX_SERIAL_LINES);
+#endif
    if (!serial)
       return -ENOMEM;
 
@@ -324,7 +329,11 @@
    ret = tty_register_driver(serial);
    if (ret)
    {
+#if KERNEL_VERSION_OR_LATER(5, 15, 0)
+      tty_kref_put(serial);
+#else
       put_tty_driver(serial);
+#endif
       return ret;
    }
 


blackmagic-12.2a12-001-fix_5.15.xx_tty_driver_functions_names.patch:
Code: Select all
diff -Naur ./blackmagic-12.2a12.orig/blackmagic_serial.c ./blackmagic-12.2a12/blackmagic_serial.c
--- ./blackmagic-12.2a12.orig/blackmagic_serial.c   2021-10-18 04:26:45.000000000 +0200
+++ ./blackmagic-12.2a12/blackmagic_serial.c   2021-11-15 18:59:22.195334829 +0100
@@ -613,7 +613,11 @@
    int ret;
    struct tty_driver *driver;
 
+#if KERNEL_VERSION_OR_LATER(5, 15, 0)
+   driver = tty_alloc_driver(BLACKMAGIC_SERIAL_MINORS, 0);
+#else
    driver = alloc_tty_driver(BLACKMAGIC_SERIAL_MINORS);
+#endif
    if (!driver)
       return -ENOMEM;
 
@@ -639,7 +643,11 @@
 
 abort:
    printk(KERN_ERR "failed to register blackmagic serial driver");
+#if KERNEL_VERSION_OR_LATER(5, 15, 0)
+   tty_kref_put(driver);
+#else
    put_tty_driver(driver);
+#endif
    return ret;
 }
 


Hope this will help. Feel free to make any comment and feedback will be appreciated.

Cordially,


--
NVieville

Re: blackmagic-io module doesn't compile on kernel 5.15

PostPosted: Wed Nov 17, 2021 5:55 pm
by Subsentient
Fixed the patch. It's got some whitespace crap from a failed patch attempt too, just ignore that.

This compiles on 5.15.2 for me.

https://universe2.us/collector/bmdpatch_5.15.patch

This contains patches for both blackmagic and blackmagic-io drivers.
Go to /usr/src/ and apply it.

Hope it helps.

Re: blackmagic-io module doesn't compile on kernel 5.15

PostPosted: Thu Nov 18, 2021 5:09 pm
by goldyfruit
Subsentient wrote:Fixed the patch. It's got some whitespace crap from a failed patch attempt too, just ignore that.

This compiles on 5.15.2 for me.

https://universe2.us/collector/bmdpatch_5.15.patch

This contains patches for both blackmagic and blackmagic-io drivers.
Go to /usr/src/ and apply it.

Hope it helps.

Indeed, the previous patch was not working for me.
I tried yours and I was able to patch and compile the modules.
Code: Select all
$ cd /usr/src
$ sudo patch -p0 < ~/Downloads/bmdpatch_5.15.patch
patching file blackmagic-12.2a12/blackmagic_lib.c
patching file blackmagic-12.2a12/blackmagic_serial.c
patching file blackmagic-io-12.2a12/bm_mm.c
patching file blackmagic-io-12.2a12/bmio_client.c
patching file blackmagic-io-12.2a12/bmio_serial.c

Thanks guys!

Re: blackmagic-io module doesn't compile on kernel 5.15

PostPosted: Fri Nov 19, 2021 9:19 am
by NVieville
Hello,

Thank you goldyfruit for pointing out the non functional patches.

Indeed they are not usable due to the way they were provided: as code in the forum tool.
Looking at the text code, once copied from this forum (select and copy) and pasted in a text editor shows that all the original tabulations were converted to 3 spaces, making the patch useless.
To make text code copied from this forum useful as a patch, one has to convert all the 3 spaces to tabulations but not the leading space of each line as it is part of the patch file format.
Here is the 'oneline' sed command to achieve that:

Code: Select all
sed -i -e 's%^    % \t%g' -e 's%   %\t%g' [/possible_path_where_the_patch_file_is_located/]patch_name.patch

The first expression searches for each line beginning by 4 spaces and convert these spaces to 1 space followed by one tabulation, then the second expression converts each sequence of 3 spaces to 1 tabulation.

Once applied, the patches are useful again and can be applied, from the /usr/src directory, as this:

Code: Select all
patch -p0 -i [/possible_path_where_the_patch_file_is_located/]patch_name.patch

Hope this was understandable enough to make those patches usable.

Cordially,


--
NVieville

Re: blackmagic-io module doesn't compile on kernel 5.15

PostPosted: Thu Dec 16, 2021 3:04 pm
by goldyfruit
The version 12.2.2 fixed the issue.
Thanks again guys for your help.