<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 16.0.10366.20016">
<TITLE>RE: irq_desc not found for my interrupt number during request_irq (radix tree of irq_desc has only 64 entries..)</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">T</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">his is the boot message of the virtual machine</FONT><FONT SIZE=2 FACE="맑은 고딕"> related to IRQ.</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">[ 0.000000] GICv3: 2</FONT><FONT SIZE=2 FACE="맑은 고딕">24 SPIs implemented</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">[ 0.000000] GICv3: 0 Extended SPIs implemented</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">[ 0.000000] GICv3: Distributor has no Range Selector support</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">[ 0.000000] GICv3: 16 PPIs implemented</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">[ 0.000000] GICv3: no VLPI support, no direct LPI support</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">[ 0.000000] GICv</FONT><FONT SIZE=2 FACE="맑은 고딕">3: CPU0: found redistributor 0 region 0:0x00000000080a0000</FONT></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">S</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">omehow the NR_IRQS is 64</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2>.</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">So I tried using SPI 15 which was</FONT></SPAN><SPAN LANG="en-us"> <FONT SIZE=2 FACE="맑은 고딕">not assigned. (32 internal</FONT> <FONT SIZE=2 FACE="맑은 고딕">IRQs</FONT> <FONT SIZE=2 FACE="맑은 고딕">+ 15 <</FONT><FONT SIZE=2 FACE="맑은 고딕"> 64)</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕"> and now r</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">equest_irq returns 0.</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">S</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">o this irq_desc problem was solved</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">(?) for now.</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕"> (</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">I don</FONT><FONT SIZE=2 FACE="맑은 고딕">’</FONT><FONT SIZE=2 FACE="맑은 고딕">t know why this is so smal</FONT><FONT SIZE=2 FACE="맑은 고딕">l when CONFIG_</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">SPARSE_IR</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">QS</FONT><FONT SIZE=2 FACE="맑은 고딕">=y).</FONT></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕">A</FONT><FONT SIZE=2 FACE="맑은 고딕">nd</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="맑은 고딕"> s</FONT><FONT SIZE=2 FACE="맑은 고딕">t</FONT><FONT SIZE=2 FACE="맑은 고딕">ill the handler is not called even when I set qemu_set_irq</FONT></SPAN><SPAN LANG="en-us"><FONT SIZE=2>.</FONT></SPAN></P>
<UL DIR=LTR><UL DIR=LTR>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT FACE="Calibri">_____________________________________________<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT FACE="Calibri">From:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT FACE="Calibri"> Chan Kim <ckim@etri.re.kr><BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT FACE="Calibri">Sent:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT FACE="Calibri"> Wednesday, April 6, 2022 10:46 AM<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT FACE="Calibri">To:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT FACE="Calibri"> 'qemu-discuss' <qemu-discuss@nongnu.org>; kernelnewbies@kernelnewbies.org<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT FACE="Calibri">Subject:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT FACE="Calibri"> irq_desc not found for my interrupt number during request_irq (radix tree of irq_desc has only 64 entries..)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR ALIGN=JUSTIFY><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">Hello all, </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">I'm doing an linux driver and application test on a qemu arm64 virtual machine.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">My virtual machine is slightly modified version of</FONT> <FONT SIZE=2 FACE="Courier New">arm</FONT><FONT SIZE=2 FACE="Courier New"></FONT> <FONT SIZE=2 FACE="Courier New">'</FONT><FONT SIZE=2 FACE="Courier New">virt</FONT><FONT SIZE=2 FACE="Courier New">'</FONT><FONT SIZE=2 FACE="Courier New"> machine</FONT><FONT SIZE=2 FACE="Courier New"> and</FONT> <FONT SIZE=2 FACE="Courier New">it has</FONT> <FONT SIZE=2 FACE="Courier New">our device model included.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">When I do request_irq for INTID 208 (SPI 176) in linux on my arm64 virtual machine, it returns -EINVAL.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">I poked into that function and found the desc is returning NULL in function request_threaded_irq.</FONT></SPAN></P>
<UL DIR=LTR>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">int request_threaded_irq(u</FONT><FONT SIZE=2 FACE="Courier New">nsigned int irq, irq_handler_t handler,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> irq_handler_t thread_fn, unsigned long irqflags,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> const char *devname, void *dev_id)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">{</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> struct irqaction *action;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> struct irq_desc *desc;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> int retval;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">...</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">desc = irq_to_desc(irq);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> </FONT> <FONT SIZE=2 FACE="Courier New"> if (!desc) </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> return -EINVAL;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">...</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">}</FONT></SPAN></P>
</UL>
<P DIR=LTR><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">and irq_to_desc is supposed to return an irq_desc from the irq_radix_tree as shown below.</FONT></SPAN></P>
<UL DIR=LTR>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">struct irq_desc *irq_to_desc(unsigned int irq)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">{</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> return radix_tree_lookup(&irq_desc_tree, irq);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">}</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">void *radix_tree_lookup(const struct radix_tree_root *root, unsigned long index)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">{</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> return __radix_tree_lookup(root, index, NULL, NULL);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">}</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">void *__radix_tree_lookup(const struct radix_tree_root *root,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> unsigned long index, struct radix_tre</FONT><FONT SIZE=2 FACE="Courier New">e_node **nodep,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> void __rcu ***slotp)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">{</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> struct radix_tree_node *node, *parent;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> unsigned long maxindex;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> void __rcu **slot;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> restart:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> parent = NULL;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> slot = (void __rcu **)&root->xa_head;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> radix_tree_load_root(root, &node,</FONT><FONT SIZE=2 FACE="Courier New"> &maxindex);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> if (index > maxindex)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> return NULL;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">...</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">}</FONT></SPAN></P>
</UL>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">and I found my request index is 208 but the maxindex of the radix tree is 63. </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">So it looks like the radix tree of irq_desc has been set to have maximum 64 irq_descs. </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">Where and how can I se</FONT><FONT SIZE=2 FACE="Courier New">t this radix tree size?</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">I looked at qemu's hw/arm/ab21q-build-acpi.c for MADT or DSDT table parts but couldn't find what to add.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">I have my devices address range and irq added in the DSDT and MADT.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">static void</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">build_dsdt(GArray *table_data, BIOSLinker *linker, Ab21qMachineState *vms)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">{</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">...</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">acpi_dsdt_add_axpu(scope, &memmap[AB21Q_AXPU],</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> (irqmap[AB21Q_AXPU] + ARM_SPI_BASE));</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">...</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">}</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">static void acpi_dsdt_add_axpu(Aml *scope, const MemMapEntry</FONT> <FONT SIZE=2 FACE="Courier New">*axpu_memmap,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> uint32_t irq)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">{</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> Aml *dev = aml_device("AXPU");</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> aml_append(dev, aml_name_decl("_HID", aml_string("AXPU0011")));</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> aml_append(dev, aml_name_decl("_UID", aml_int(0)));</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> Aml *crs = aml_reso</FONT><FONT SIZE=2 FACE="Courier New">urce_template();</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> aml_append(crs, aml_memory32_fixed(axpu_memmap->base,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> axpu_memmap->size, AML_READ_WRITE));</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> aml_append(crs,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> </FONT> <FONT SIZE=2 FACE="Courier New"> AML_EXCLUSIVE, &irq, 1));</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> aml_append(dev, aml_name_decl("_CRS", crs));</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New"> aml_append(scope, dev);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">}</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">I'm not sure if I can just use _HID value as "AXPU0011". </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">If you see anything wrong and have a suggestion, please tell me.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">Thank you!</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">Chan Kim</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN></P>
</UL></UL>
</BODY>
</HTML>