<div> </div><div>Hello Chan,</div><div> </div><div><div>of course i would but kernelnewbies is always a good way to mentoring first step kernel development and i think official LKML developers (linux-kernel) have time issues but on other hand, Greg-KH usually takes time and is responsive everytime :)</div><div> </div><div><div>Now i also pay attention to your code, are calling request_irq but type here must return int as an argument otherwise you will get an error because you never declared argument as a parameter. for example, if you took result in an if loop and produced an error when you couldnt get irq would see that. actually i think kernel also have a call for autodetect irq.</div></div></div><div> </div><div>Regards</div><div> </div><div>--</div><div>Ozgur</div><div><a href="mailto:ozgur@linux.com" rel="noopener noreferrer">ozgur@linux.com</a></div><div> </div><div>11.04.2022, 17:17, "Chan Kim" <ckim@etri.re.kr>:</div><blockquote><div lang="KO"><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US" style="font-size:10pt">Hi Ozgur,</span></p><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US" style="font-size:10pt">The SPI I meant was ‘shared peripheral interrupt’ of armv8 architecture.</span></p><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US" style="font-size:10pt">(the interrupt is shared among cores. The interrupt controller distributes it)</span></p><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US" style="font-size:10pt">I’ll look into your link when I’ll be working with SPI (serial peripheral interface) later :).</span></p><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US" style="font-size:10pt">Thank you.</span></p><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US" style="font-size:10pt">Chan </span></p><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US" style="font-size:10pt"> </span></p><div style="border-left-color:blue;border-style:none none none solid;border-width:medium medium medium 1.5pt;padding:0cm 0cm 0cm 4pt"><div><div style="border-style:solid none none none;border-top-color:#e1e1e1;border-width:1pt medium medium medium;padding:3pt 0cm 0cm 0cm"><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><strong><span lang="EN-US" style="font-family:'calibri' , sans-serif;font-size:11pt">From:</span></strong><span lang="EN-US" style="font-family:'calibri' , sans-serif;font-size:11pt"> Ozgur Kara <<a href="mailto:ozgur@goosey.org" rel="noopener noreferrer">ozgur@goosey.org</a>><br /><strong>Sent:</strong> Monday, April 11, 2022 10:10 PM<br /><strong>To:</strong> Chan Kim <<a href="mailto:ckim@etri.re.kr" rel="noopener noreferrer">ckim@etri.re.kr</a>>; 'qemu-discuss' <<a href="mailto:qemu-discuss@nongnu.org" rel="noopener noreferrer">qemu-discuss@nongnu.org</a>>; <a href="mailto:kernelnewbies@kernelnewbies.org" rel="noopener noreferrer">kernelnewbies@kernelnewbies.org</a><br /><strong>Subject:</strong> Re: Can't understand /proc/interrupts output for GICv3 case</span></p></div></div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p><div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">Hello,</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">firstly when you say SPI so can you give some more information about your hardware?</span></p></div><div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">I think you are doing an embedded development in that case you should do some research on howto understand SPI interface under the kernel.</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div><div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">I think for example, source code of a previously written hardware using SPI bus can give you an idea. You can look at examples for example spi-based Xilinx however I think all SPI hardware is declared under /linux/drivers/spi with "spi.c". Also we see a "spi.h" header file depending on kernel headers.</span></p></div></div></div></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div><div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">So, if you define a master mode (MOSI) then "interrupt.h" header file will be useful because must first determine free irq and these calls are defined in interrupt.h.</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">Please attention some kernel call:</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">- request_irq</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">- irqsave()</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">- irqrestore()</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div><div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">and maybe check out the "Interrupt Handling" book and please read follow website:</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div></div><div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"><a href="https://www.kernel.org/doc/html/v4.11/driver-api/spi.html" rel="noopener noreferrer" target="_blank">https://www.kernel.org/doc/html/v4.11/driver-api/spi.html</a></span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">* Book (Understand the Linux Kernel)</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">  - Section: Interrupt Handling</span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">Salut!</span></p></div></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> </span></p></div></div><div><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US">11.04.2022, 16:36, "Chan Kim" <<a href="mailto:ckim@etri.re.kr" rel="noopener noreferrer">ckim@etri.re.kr</a>>:</span></p></div><blockquote style="margin-bottom:5pt;margin-top:5pt"><p><span lang="EN-US">Hi,<br />nobody's replying to my question.. so sad..<br />I found the kernel makes an array (actually a radix tree) of 'irq_desc's.<br />And my hwirq (SPI 15) is assigned to one of these irq_descs while processing<br />device tree.<br />In my case it was assigned irq 6 (this irq is what is called virtual irq).<br />So I registered the handler by request_irq(6,...) and the interrupt works<br />fine.<br />So now my question is : how can find my irq number (correct irq_desc number)<br />in kernel driver module?<br />I'll appreciate it if you could tell me how to do it.<br />Thank you!<br /><br />Chan Kim<br /> </span></p><blockquote style="margin-bottom:5pt;margin-top:5pt"><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> -----Original Message-----<br /> From: Chan Kim <<a href="mailto:ckim@etri.re.kr" rel="noopener noreferrer">ckim@etri.re.kr</a>><br /> Sent: Friday, April 8, 2022 1:53 PM<br /> To: 'qemu-discuss' <<a href="mailto:qemu-discuss@nongnu.org" rel="noopener noreferrer">qemu-discuss@nongnu.org</a>>;<br /> <a href="mailto:kernelnewbies@kernelnewbies.org" rel="noopener noreferrer">kernelnewbies@kernelnewbies.org</a><br /> Subject: Can't understand /proc/interrupts output for GICv3 case<br /> <br /> Hello all<br /> <br /> I think I'm asking too many question recently but sometimes I get very big<br /> help from here so please forgive me.<br /> (and I think someone else can get help from this email thread) I'm doing<br /> experiment for interrupt of a device called axpu on an arm64 virtual<br /> machine.<br /> In QEMU virtual machine, the interrupts are assigned as below.<br /> (These numbers are SPI(shared peripheral interrupt) numbers, and there are<br /> 16 SGI and 16 PPI before SPI, so we have to add 32 to get the INTID<br /> value(hwirq number))<br /> <br /> static const int a15irqmap[] = {<!-- --><br />     [AB21Q_UART] = 1,<br />     [AB21Q_RTC] = 2,<br />     [AB21Q_PCIE] = 3, /* ... to 6 */<br />     [AB21Q_GPIO] = 7,<br />     [AB21Q_SECURE_UART] = 8,<br />     [AB21Q_ACPI_GED] = 9,<br />     [AB21Q_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */<br />     [AB21Q_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */<br />     [AB21Q_SMMU] = 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */<br />     [AB21Q_PLATFORM_BUS] = 112, /* ...to 112 + PLATFORM_BUS_NUM_IRQS -1 */<br />     [AB21Q_AXPU] = 15,<br /> };<br /> <br /> In the driver, when I do request_irq(32+15, axpu_irq_handler, IRQF_SHARED,<br /> "axpu_irq", &axpu_cdev) for my device axpu, the /proc/interrupts' looks<br /> like this. See the 10th item(axpu_irq).<br /> <br />                    CPU0<br />           1: 0 GICv3 25 Level vgic<br />           3: 0 GICv3 30 Level kvm guest ptimer<br />           4: 0 GICv3 27 Level kvm guest vtimer<br />           5: 20432 GICv3 26 Level arch_timer<br />          40: 0 GICv3 106 Edge arm-smmu-v3-evtq<br />          43: 0 GICv3 109 Edge arm-smmu-v3-gerror<br />          44: 0 GICv3 34 Level rtc-pl031<br />          45: 164 GICv3 33 Level uart-pl011<br />          46: 0 GICv3 23 Level arm-pmu<br />          47: 7789 GICv3 36 Level virtio0, axpu_irq<br />          48: 0 9030000.pl061 3 Edge GPIO Key Poweroff<br />         IPI0: 0 Rescheduling interrupts<br />         IPI1: 0 Function call interrupts<br />         IPI2: 0 CPU stop interrupts<br />         IPI3: 0 CPU stop (for crash dump) interrupts<br />         IPI4: 0 Timer broadcast interrupts<br />         IPI5: 0 IRQ work interrupts<br />         IPI6: 0 CPU wake-up interrupts<br />         Err: 0<br /> <br /> There are two numbers. One in the first column and the other in the 4th<br /> column.<br /> After observing uart-pl011 driver's action(who's irq in 8th row), I found<br /> the number in the first column is the one I should pass to the request_irq<br /> funcion, and the second number in the 4th column is the input to the</span></p></blockquote><p><span lang="EN-US">GICv3.</span></p><blockquote style="margin-bottom:5pt;margin-top:5pt"><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> (uart was assigned SPI 1, so 32+1 = 33).<br /> In my axpu driver case, I requested request_irq(47, ...) so hwirq is 47<br /> but I don't know why it was assigned to GICv3 input 36.<br /> Shouldn't it be 47 too? (32+15=47).<br /> <br /> Without fixing QEMU code(still using SPI 15), I tried doing</span></p></blockquote><p><span lang="EN-US">request_irq(15,</span></p><blockquote style="margin-bottom:5pt;margin-top:5pt"><p style="font-size:12pt;margin:0cm 0cm 0.0001pt 0cm"><span lang="EN-US"> axpu_irq_handler, ..) for test and this time it looks like this.(see the<br /> 5th<br /> row)<br /> <br />            CPU0<br />   1: 0 GICv3 25 Level vgic<br />   3: 0 GICv3 30 Level kvm guest ptimer<br />   4: 0 GICv3 27 Level kvm guest vtimer<br />   5: 8174 GICv3 26 Level arch_timer<br />  15: 0 GICv3 56 Edge axpu_irq<br />  40: 0 GICv3 106 Edge arm-smmu-v3-evtq<br />  43: 0 GICv3 109 Edge arm-smmu-v3-gerror<br />  44: 0 GICv3 34 Level rtc-pl031<br />  45: 175 GICv3 33 Level uart-pl011<br />  46: 0 GICv3 23 Level arm-pmu<br />  47: 7790 GICv3 36 Level virtio0<br />  48: 0 9030000.pl061 3 Edge GPIO Key Poweroff<br /> IPI0: 0 Rescheduling interrupts<br /> IPI1: 0 Function call interrupts<br /> IPI2: 0 CPU stop interrupts<br /> IPI3: 0 CPU stop (for crash dump) interrupts<br /> IPI4: 0 Timer broadcast interrupts<br /> IPI5: 0 IRQ work interrupts<br /> IPI6: 0 CPU wake-up interrupts<br /> Err: 0<br /> <br /> Now axpu_irq has moved to INTID 15 (as expected), but it changed to "GICv3<br /> 56 Edge".<br /> How is this GICv3 number is assigned? (and I guess edge trigger is the<br /> default for INTID < 16. Because it's SGI..?)<br /> <br /> I thought I connected my device (axpu) to SPI 15 in qemu code but this<br /> GICv3 input number changes according to with what number I called<br /> reqeust_irq.<br /> Could anyone tell me what is going on here?<br /> <br /> Thank you.<br /> Chan Kim</span></p></blockquote></blockquote></div></div></div>,<p>_______________________________________________<br />Kernelnewbies mailing list<br /><a href="mailto:Kernelnewbies@kernelnewbies.org" rel="noopener noreferrer">Kernelnewbies@kernelnewbies.org</a><br /><a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noopener noreferrer">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a></p></blockquote>