Patch for Hercules kernel mod broken by Linux 2.6.31

XML preset files and script files (.js) for MIDI and other controllers.

Moderators: garth, User Customization Moderators

Patch for Hercules kernel mod broken by Linux 2.6.31

Postby garth » Fri Oct 09, 2009 3:29 am

Linux 2.6.31 is included with Ubuntu 9.10 Karmic, some changes to ALSA break the driver so that dkms fails.

You can use these instructions with the patch below to patch and manually install the driver into the kernel:
Code: Select all
sudo dkms build -m hdj_mod -v 1.28  # this will fail but explode everything needed to build with
cd /var/lib/dkms/hdjmod/1.28/build
sudo sh -c "cat ~/Desktop/kernel_2.6.31_rc6_rt6.patch | patch"
sudo make
sudo make install


Credit to Arnaud Le Breton for cooking the patch up.

-G
[Board won't let me attach .patch files or .txt files right now, so here it is, select all, copy and paste into ~/Desktop/kernel_2.6.31_rc6_rt6.patch ]

Code: Select all
diff -rupNB hdjmod-1.28/bulk.c hdjmod-1.28_MODIF/bulk.c
--- hdjmod-1.28/bulk.c   2009-08-24 01:14:03.000000000 +0200
+++ hdjmod-1.28_MODIF/bulk.c   2009-08-24 22:56:07.000000000 +0200
@@ -3062,7 +3062,7 @@ int hdj_create_bulk_interface(struct snd
       goto hdj_create_bulk_interface_error;
    }
    /* allocate the buffer for bulk_out_urb */
-   init_MUTEX(&ubulk->bulk_out_buffer_mutex);
+   semaphore_init(&ubulk->bulk_out_buffer_mutex);
    
    ubulk->bulk_out_buffer =
       usb_buffer_alloc(ubulk->chip->dev, ubulk->bulk_out_size,
@@ -3601,7 +3601,7 @@ static int init_output_control_state(str
       return -EINVAL;
    }
 
-   init_MUTEX(&ubulk->output_control_mutex);
+   semaphore_init(&ubulk->output_control_mutex);
    init_completion(&ubulk->output_control_completion);
 
    /* Every product here except the Steel targets HID.  Since the steel does not target HID, we don't
@@ -3855,7 +3855,7 @@ int hdjbulk_init_dj_console(struct usb_h
    u16 value = 0;
    struct hdj_console_context *dc = ((struct hdj_console_context *)ubulk->device_context);
 
-   init_MUTEX(&dc->device_config_mutex);
+   semaphore_init(&dc->device_config_mutex);
    
    ret = hdjbulk_init_common_context(ubulk,&ubulk->hdj_common);
    if (ret!=0) {
@@ -4133,7 +4133,7 @@ int hdjbulk_init_dj_steel(struct usb_hdj
 
    spin_lock_init(&dc->bulk_buffer_lock);
    init_completion(&dc->bulk_request_completion);
-   init_MUTEX(&dc->bulk_request_mutex);
+   semaphore_init(&dc->bulk_request_mutex);
 
    if ((ret = init_continuous_reader(ubulk))!=0) {
       printk(KERN_WARNING"%s() init_continuous_reader() failed, rc:%d\n",
diff -rupNB hdjmod-1.28/device.c hdjmod-1.28_MODIF/device.c
--- hdjmod-1.28/device.c   2009-08-24 01:14:03.000000000 +0200
+++ hdjmod-1.28_MODIF/device.c   2009-08-24 22:52:13.000000000 +0200
@@ -66,7 +66,7 @@ MODULE_PARM_DESC(index, "Index value for
 module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for the Hercules DJ Series adapter.");
 
-static DECLARE_MUTEX(register_mutex);
+static DEFINE_SEMAPHORE(register_mutex);
 static struct snd_hdj_chip *usb_chip[SNDRV_CARDS];
 
 /* reference count for the socket */
@@ -1660,11 +1660,12 @@ static int snd_hdj_chip_create(struct us
       /* let the kernel option override custom id */
       strncpy(card_id,id[idx],sizeof(card_id)-1);
    }
-   card = snd_card_new(index[idx], card_id/*id[idx]*/, THIS_MODULE, 0);
-   if (card == NULL) {
-      snd_printk(KERN_WARNING "snd_hdj_chip_create(): cannot create card instance %d\n", idx);
-      return -ENOMEM;
-   }
+
+   err = snd_card_create(index[idx], card_id/*id[idx]*/, THIS_MODULE, 0, &card);
+        if (err < 0) {
+          snd_printk(KERN_WARNING "snd_hdj_chip_create(): cannot create card instance %d\n", idx);
+          return err;
+        }
    
    /* save the index, so people who have the card can reference the chip */
    card->private_data = (void*)(unsigned long)idx;
@@ -1682,7 +1683,7 @@ static int snd_hdj_chip_create(struct us
    chip->card = card;
    chip->product_code = product_code;
 
-   init_MUTEX(&chip->vendor_request_mutex);
+   semaphore_init(&chip->vendor_request_mutex);
 
    /* initialise the atomic variables */
    atomic_set(&chip->locked_io, 0);
@@ -1697,7 +1698,7 @@ static int snd_hdj_chip_create(struct us
    INIT_LIST_HEAD(&chip->bulk_list);
    chip->usb_id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
                le16_to_cpu(dev->descriptor.idProduct));
-   init_MUTEX(&chip->netlink_list_mutex);
+   semaphore_init(&chip->netlink_list_mutex);
    INIT_LIST_HEAD(&chip->netlink_registered_processes);
    
    /* fill in DJ capabilities for this device */
diff -rupNB hdjmod-1.28/midi.c hdjmod-1.28_MODIF/midi.c
--- hdjmod-1.28/midi.c   2009-08-24 01:14:03.000000000 +0200
+++ hdjmod-1.28_MODIF/midi.c   2009-08-24 22:57:10.000000000 +0200
@@ -677,7 +677,7 @@ static int controller_output_init(struct
    
    /* this buffer and URB below are for general control requests, like changing the
     *  mouse setting or setting LEDs */
-   init_MUTEX(&controller_state->output_control_ctl_mutex);
+   semaphore_init(&controller_state->output_control_ctl_mutex);
    init_completion(&controller_state->output_control_ctl_completion);
    controller_state->output_control_ctl_req = usb_buffer_alloc(ep->umidi->chip->dev,
                      sizeof(*(controller_state->output_control_ctl_req)),
garth
Mixxx Developer
 
Posts: 44
Joined: Sat Feb 14, 2009 10:29 pm

Re: Patch for Hercules kernel mod broken by Linux 2.6.31

Postby verde » Wed Oct 14, 2009 12:14 pm

hello! first i want to thank you guys for the patch! i got it working on my gentoo!

i'll detail what was happening in case someone finds itself in a similar situation.

somehow, the api change (init_MUTEX->semaphore_init) hasnt been applied to gentoo's kernels (both gentoo-sources and vanilla-sources) but the alsa's did (snd_card_new->snd_card_create) so i only used that subsection.

At this point the RMX all i got was lights on the RMX being activated from mixxx, and ofc, sound from it.

Then i compiled the driver with dkms ( i had it build before without the need of it) and voilá! I
was able to output its midi signals! i'll have to figure out what was different.

The RMX worked fine for, at max., 4-5 songs and them stopped sending signals.

Reloading the driver (modprobe -r hdj_mod && modprobe hdj_mod) fixed but to do that, i had to exit mixxx ( wasnt able to do it if it was in use). this was, ofc, impossible to deal.

the kernel said :

Code: Select all
ohci_hcd 0000:00:0b.0: urb ffff88013a2b5300  status -71


googling for a while got me the info that the RMX was getting "confused" and the kernel, imo, reseted the comunication with it. Seems these error codes indicate low-level USB communication problems.
From this mailing list i found a patch and with a minor change it was appliable to 2.6.32 (my current).

i've been using it just until now when mixxx segfaulted but oh well! all is well! thanks again!
verde
 
Posts: 5
Joined: Sat Oct 10, 2009 2:02 pm

Re: Patch for Hercules kernel mod broken by Linux 2.6.31

Postby verde » Wed Oct 14, 2009 12:21 pm

just in case...

if this possible to do within the driver, i guess it would be better.

Code: Select all
--- linux-2.6.32-rc3/drivers/usb/host/ohci-q.c  2009-10-12 05:35:06.000000000 +0100
+++ linux-2.6.32-rc3-pc1/drivers/usb/host/ohci-q.c      2009-10-14 08:58:33.000000000 +0100
@@ -854,6 +854,11 @@ static struct td *dl_reverse_done_list (
        struct td       *td_rev = NULL;
        struct td       *td = NULL;

+       urb_priv_t *urbpriv;
+       int count;
+       struct urb *urb;
+
+
        td_dma = hc32_to_cpup (ohci, &ohci->hcca->done_head);
        ohci->hcca->done_head = 0;
        wmb();
@@ -873,18 +878,38 @@ static struct td *dl_reverse_done_list (
                td->hwINFO |= cpu_to_hc32 (ohci, TD_DONE);
                cc = TD_CC_GET (hc32_to_cpup (ohci, &td->hwINFO));

-               /* Non-iso endpoints can halt on error; un-halt,
-                * and dequeue any other TDs from this urb.
-                * No other TD could have caused the halt.
-                */
-               if (cc != TD_CC_NOERROR
-                               && (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H)))
-                       ed_halted(ohci, td, cc);
-
-               td->next_dl_td = td_rev;
-               td_rev = td;
-               td_dma = hc32_to_cpup (ohci, &td->hwNextTD);
-       }
+
+               if (cc == TD_PIDCHECKFAIL || cc == TD_DEVNOTRESP) {
+                   urbpriv = td->urb->hcpriv;
+
+                   td->ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H);
+                   td->hwINFO &= ~cpu_to_hc32(ohci, TD_CC);
+                   td->hwINFO &= ~cpu_to_hc32(ohci, TD_EC);
+                   urb = td->urb;
+                   for (count = 0; count < urbpriv->length; count++) {
+                       td = urbpriv->td[count];
+                       if (td) {
+                           list_del(&td->td_list);
+                           td_dma =
+                               hc32_to_cpup(ohci, &td->hwNextTD);
+                       }
+                   }
+                   list_del(&urbpriv->pending);
+                   td_submit_urb(ohci, urb);
+               } else {
+                   /* Non-iso endpoints can halt on error; un-halt,
+                    * and dequeue any other TDs from this urb.
+                    * No other TD could have caused the halt.
+                    */
+                   if (cc != TD_CC_NOERROR &&
+                       (td->ed->hwHeadP & cpu_to_hc32(ohci, ED_H)))
+                       ed_halted(ohci, td, cc);
+
+                   td->next_dl_td = td_rev;
+                   td_rev = td;
+                   td_dma = hc32_to_cpup(ohci, &td->hwNextTD);
+               }
+       }
        return td_rev;
 }
verde
 
Posts: 5
Joined: Sat Oct 10, 2009 2:02 pm

Re: Patch for Hercules kernel mod broken by Linux 2.6.31

Postby AlexG » Fri Oct 23, 2009 10:34 pm

Hi guys, I've been googling for 8 hours straight to find info on making my Hercules working on Karmic Koala (kernel is 2.6.31-9-rt) and now I understand I need to apply this patch! Great... but I'm a bit of a noob so there a detail that confuses me...

I have not yet attempted to install the Hercules driver again... should I simply download and install the Hercules driver's .deb and then follow the instruction.. sudo dkms build -m hdj_mod -v 1.28 ... etc?

Or do I NOT install the .deb, but instead follow some other steps (getting driver source?) and then run the dkms build command?

Or, should I try to figure out what verde means by "if this possible to do within the driver, i guess it would be better."
I suppose I would get the driver's source, save what Verde put into a hdj.patch file and do:
sudo sh -c "cat ~/Desktop/hdj.patch | patch"

See... I'm soooo close to it but just a bit confused!

Thanks!

Alex
AlexG
 
Posts: 1
Joined: Fri Oct 23, 2009 10:16 pm

Re: Patch for Hercules kernel mod broken by Linux 2.6.31

Postby verde » Thu Oct 29, 2009 4:12 pm

oh alex! sorry only now i saw ur post!

did u made it? still need a hand? sorry! :$

anyways, let me just say that i had it working on my karmic ubuntu flawlessly ( well, as much as a 5yr old laptop can) with the .deb patched with the 1st post patch and 2.6.31 kernel.




PS: i meant: "it would be better if the driver would stop confusing the usb kernel module instead of having to mess with the usb kernel module, making it ignore those errors"
verde
 
Posts: 5
Joined: Sat Oct 10, 2009 2:02 pm

Re: Patch for Hercules kernel mod broken by Linux 2.6.31

Postby thomi » Fri Oct 30, 2009 10:11 pm

hi all

so, i have same problem.. have upgraded a test system to kubuntu karmic 9.10 with Kernel 2.6.31-14.
Have done all steps which garth has explained and after the command: sudo sh -c "cat ~/Desktop/kernel_2.6.31_rc6_rt6.patch | patch" i get this:

sudo sh -c "cat ~/Desktop/kernel_2.6.31_rc6_rt6.patch | patch"
(Patch is indented 4 spaces.)
patching file bulk.c
Hunk #1 FAILED at 3062.
Hunk #2 FAILED at 3601.
Hunk #3 FAILED at 3855.
Hunk #4 FAILED at 4133.
4 out of 4 hunks FAILED -- saving rejects to file bulk.c.rej
(Patch is indented 4 spaces.)
patching file device.c
patch: **** malformed patch at line 44: module_param_array(id, charp, NULL, 0444);

Attached is the bulk.c.rej file (zipped)

Thanks for Help

thomi
Attachments
bulk.c.rej.zip
(773 Bytes) Downloaded 571 times
thomi
 
Posts: 9
Joined: Fri Oct 30, 2009 10:06 pm

Re: Patch for Hercules kernel mod broken by Linux 2.6.31

Postby reetp » Sun Nov 01, 2009 11:10 pm

thomi wrote:hi all
so, i have same problem.. have upgraded a test system to kubuntu karmic 9.10 with Kernel 2.6.31-14.
Have done all steps which garth has explained and after the command: sudo sh -c "cat ~/Desktop/kernel_2.6.31_rc6_rt6.patch | patch" i get this:
sudo sh -c "cat ~/Desktop/kernel_2.6.31_rc6_rt6.patch | patch"
(Patch is indented 4 spaces.)
patching file bulk.c
Hunk #1 FAILED at 3062.
Hunk #2 FAILED at 3601.
Hunk #3 FAILED at 3855.
Hunk #4 FAILED at 4133.
4 out of 4 hunks FAILED -- saving rejects to file bulk.c.rej
(Patch is indented 4 spaces.)
patching file device.c
patch: **** malformed patch at line 44: module_param_array(id, charp, NULL, 0444);
thomi


Me too. Identical problem.

Any help please people ?

B. Rgds
John
reetp
 
Posts: 13
Joined: Tue Oct 13, 2009 8:13 pm

Re: Patch for Hercules kernel mod broken by Linux 2.6.31

Postby thomi » Tue Nov 03, 2009 7:28 am

Hi all..

No i have contacted Hercules Support.. maybe they plan to make new Linux Drivers too :)

Will inform you..

bye
thomi
thomi
 
Posts: 9
Joined: Fri Oct 30, 2009 10:06 pm

Hercules Dj Control MP3+ with Ubuntu 9.10 2.6.31-14-generic

Postby Gabo » Wed Nov 04, 2009 7:41 pm

Hello.
Patch in this thread didn't work for me. This is how i got kernel module compiled.

Code: Select all
sudo dpkg -i hdjmod-dkms_1.28_all.deb


Compilation fails. Next

Code: Select all
cd /var/lib/dkms/hdjmod/1.28/build/


edit device.c with your favourite editor. Go to row 1663. Change

Code: Select all
card = snd_card_new(index[idx], card_id/*id[idx]*/, THIS_MODULE, 0);


to

Code: Select all
snd_card_create(index[idx], card_id/*id[idx]*/, THIS_MODULE, 0, &card);


save file. Then

Code: Select all
sudo make


You see warnings again, but it compiles now

Code: Select all
sudo make install


Run mixxx.
Gabo
 
Posts: 1
Joined: Wed Nov 04, 2009 7:35 pm

Re: Patch for Hercules kernel mod broken by Linux 2.6.31

Postby thomi » Thu Nov 05, 2009 9:16 am

Hey Gabo

Excellent.. :) i'm happy....

I think the steps with the patch must also be done.. cause i have tried your solution without the patch steps and it won't work.. then make also the patch steps and now it works... some error/warnings on "sudo make" but it works... :mrgreen:

By the way, until today i had no response from Hercules Support... waiting... for a new driver that fixex the problem with Kernel 2.6.31...

King Regards from CH
thomi - dj n0way
thomi
 
Posts: 9
Joined: Fri Oct 30, 2009 10:06 pm

Next

Return to Controller presets/mappings

Who is online

Users browsing this forum: No registered users and 2 guests