title: "unexpected IRQ trap at vector XX" on Beaglebone Black (Linux BBBW 4.14.71-ti-r80)
body: <p>I have a problem with interrupt processing on the beaglebone black. I have written my own combination of a kernel module and a user-space driver to have access to gpios (see also <a href="https://github.com/Terstegge/gpio-bbb" rel="nofollow noreferrer">https://github.com/Terstegge/gpio-bbb</a>). With older kernels, everything was working fine. Using the most recent debian image (kernel 4.14.71-ti-r80), I get errors in the kernel log:</p>
  
  <pre><code>[  461.028013] gpio_bbb: Device /dev/gpio_bbb registered
  [  507.507335] gpio_bbb: Requesting GPIO #30
  [  507.507370] Mode: f
  [  507.507383] gpio_bbb: Requesting GPIO #49
  [  507.507395] Mode: 37
  [  507.507405] gpio_bbb: Requesting GPIO #15
  [  507.507414] Mode: 37
  [  507.507656] gpio_bbb: Using IRQ #77 for GPIO #49
  [  507.507821] gpio_bbb: Using IRQ #78 for GPIO #15
  [  571.511409] irq 77, desc: db1ad800, depth: 0, count: 0, unhandled: 0
  [  571.511429] -&gt;handle_irq():  c01ab7b0, 
  [  571.511458] handle_bad_irq+0x0/0x2c0
  [  571.511463] -&gt;irq_data.chip(): dc122910, 
  [  571.511476] 0xdc122910
  [  571.511481] -&gt;action(): dc454600
  [  571.511487] -&gt;action-&gt;handler(): bf4c904c, 
  [  571.511514] gpio_irq_handler+0x0/0x34 [gpio_bbb]
  [  571.511524]    IRQ_NOPROBE set
  [  571.511532] unexpected IRQ trap at vector 4d
  </code></pre>
  
  <p>What I do is the following: In the module code I call <code>gpio_to_irq()</code> to get the irq number and then call <code>request_irq()</code>. Both calls seem to work, because they don't report an error code (see logfile above):</p>
  
  <pre><code>  /* request the irq and install handler */
    if (!irq_enabled[gpio_num]) {
      irq = gpio_to_irq(gpio_num);
      /* request irq and install handler */
      ret = request_irq (irq, gpio_irq_handler, IRQF_SHARED, "gpio_bbb", &amp;gpio_data);
      if (ret != 0) {
        printk(KERN_ERR MOD_STR"Failed to request IRQ %i (error %i)\n", irq, ret);
        return ret;
      }
      printk(KERN_INFO MOD_STR"Using IRQ #%i for GPIO #%i\n", irq, gpio_num);
      irq_enabled[gpio_num] = irq;
    }
  </code></pre>
  
  <p>When starting a test program I can see that my module (gpio_bbb) is registered for the interrupts in /proc/interrupts:</p>
  
  <pre><code>           CPU0       
  ...
   62:          0  tps65217   2 Edge      tps65217_pwr_but
   63:       5822  44e07000.gpio  29 Edge      wl18xx
   77:          0  4804c000.gpio  17 Edge      gpio_bbb
   78:          0  44e07000.gpio  15 Edge      gpio_bbb
  IPI0:          0  CPU wakeup interrupts
  IPI1:          0  Timer broadcast interrupts
  </code></pre>
  
  <p>When triggering some interrupts (gpio input value change) and (even) with an empty interrupt handler, which does nothing:</p>
  
  <pre><code>irqreturn_t gpio_irq_handler(int irq, void *dev_id) {
    return IRQ_HANDLED;
  }
  </code></pre>
  
  <p>I get the above error messages in the kernel log, and my interrupts are not processed :( I have noticed that the interrupt numbers have changed (formerly the irq number of a gpio was #gpio+128). I am also aware of the new libgpiod, which is obviously running (I see the /dev/gpiochip[0..3] devices). Are my problems related to these changes?
  Still I am a little bit confused because all the methods I call seem to work, and still my interrupts are handled as 'unexpected'. What am I doing wrong??</p>