Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64C9DC4332F for ; Mon, 11 Apr 2022 13:16:58 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1ndtuW-0004pi-5b; Mon, 11 Apr 2022 09:16:52 -0400 Received: from mscreen.etri.re.kr ([129.254.9.16]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (Exim 4.94.2) (envelope-from ) id 1ndtuT-0004oe-Bt for kernelnewbies@kernelnewbies.org; Mon, 11 Apr 2022 09:16:49 -0400 Received: from unknown (HELO send001-relay.gov-dooray.com) (211.180.235.152) by 129.254.9.16 with ESMTP; 11 Apr 2022 22:16:45 +0900 X-Original-SENDERIP: 211.180.235.152 X-Original-MAILFROM: ckim@etri.re.kr X-Original-RCPTTO: kernelnewbies@kernelnewbies.org Received: from [10.162.225.112] (HELO smtp002-imp.gov-dooray.com) ([10.162.225.112]) by send001-relay.gov-dooray.com with SMTP id 8b492f9c62542a3d; Mon, 11 Apr 2022 22:16:45 +0900 DKIM-Signature: a=rsa-sha256; b=f4KZn1RSphHklN0zROWqzTs8yevSPECEbQ2XAN2jt8/eI72bXbZD/0ZalGzm3qSs+UWaoQeGB1 tKoIPMOYl3BCfxjn8ZVYc38WKK8IiyNm9FtEzJJgZeBTLfAzc0gQJxf2O47BCCPKYxiCPeau4+p5 umzdxtsskxATPNUWs20C/iIwk/JQjUsv0XsWKwXu4AsMr4exohxdI5hpUyAl5esB99a81STS3bA3 9xuy/VXqZz7WaQrzbOhMT4buVsXPvPy9OEcA3/VMwPMhooVwm2RfS6UluTPdTGbGBSPEK5ErM7FB BX9iQO7lw3fxnwxKujlXTfOQB1qJrTD740xgAXKA==; c=relaxed/relaxed; s=selector; d=dooray.com; v=1; bh=AUPAgyTyksGp1TO4ufXJewlFHuH2KmHVRtZ7hplF2tY=; h=From:To:Subject:Message-ID; Received: from [129.254.132.39] (HELO CHANKIMPC) ([129.254.132.39]) by smtp002-imp.gov-dooray.com with SMTP id 6c476cb262542a3d; Mon, 11 Apr 2022 22:16:45 +0900 From: "Chan Kim" To: "'Ozgur Kara'" , "'qemu-discuss'" , References: <049201d84b04$951cbab0$bf563010$@etri.re.kr> <06c401d84da0$bc1a5ca0$344f15e0$@etri.re.kr> <710521649681774@mail.yandex.com> In-Reply-To: <710521649681774@mail.yandex.com> Subject: RE: Can't understand /proc/interrupts output for GICv3 case Date: Mon, 11 Apr 2022 22:16:43 +0900 Message-ID: <06d101d84da6$639f8c20$2adea460$@etri.re.kr> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Content-Language: ko Thread-Index: AQKunJY+kgmmewJd0lkF9aO9YfiVjAIaT1gqAbiZBcCrH3us0A== X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============3608241624443479586==" Errors-To: kernelnewbies-bounces@kernelnewbies.org This is a multipart message in MIME format. --===============3608241624443479586== Content-Type: multipart/alternative; boundary="----=_NextPart_000_06D2_01D84DF1.D38893B0" Content-Language: ko This is a multipart message in MIME format. ------=_NextPart_000_06D2_01D84DF1.D38893B0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Ozgur, The SPI I meant was =E2=80=98shared peripheral interrupt=E2=80=99 of = armv8 architecture. (the interrupt is shared among cores. The interrupt controller = distributes it) I=E2=80=99ll look into your link when I=E2=80=99ll be working with SPI = (serial peripheral interface) later :). Thank you. Chan=20 =20 From: Ozgur Kara =20 Sent: Monday, April 11, 2022 10:10 PM To: Chan Kim ; 'qemu-discuss' = ; kernelnewbies@kernelnewbies.org Subject: Re: Can't understand /proc/interrupts output for GICv3 case =20 Hello, =20 firstly when you say SPI so can you give some more information about = your hardware? I think you are doing an embedded development in that case you should do = some research on howto understand SPI interface under the kernel. =20 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. =20 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. =20 Please attention some kernel call: =20 - request_irq - irqsave() - irqrestore() =20 and maybe check out the "Interrupt Handling" book and please read follow = website: =20 https://www.kernel.org/doc/html/v4.11/driver-api/spi.html =20 * Book (Understand the Linux Kernel) - Section: Interrupt Handling =20 Salut! =20 11.04.2022, 16:36, "Chan Kim" = >: Hi, nobody's replying to my question.. so sad.. I found the kernel makes an array (actually a radix tree) of = 'irq_desc's. And my hwirq (SPI 15) is assigned to one of these irq_descs while = processing device tree. In my case it was assigned irq 6 (this irq is what is called virtual = irq). So I registered the handler by request_irq(6,...) and the interrupt = works fine. So now my question is : how can find my irq number (correct irq_desc = number) in kernel driver module? I'll appreciate it if you could tell me how to do it. Thank you! Chan Kim =20 -----Original Message----- From: Chan Kim > Sent: Friday, April 8, 2022 1:53 PM To: 'qemu-discuss' >; kernelnewbies@kernelnewbies.org = =20 Subject: Can't understand /proc/interrupts output for GICv3 case =20 Hello all =20 I think I'm asking too many question recently but sometimes I get very = big help from here so please forgive me. (and I think someone else can get help from this email thread) I'm = doing experiment for interrupt of a device called axpu on an arm64 virtual machine. In QEMU virtual machine, the interrupts are assigned as below. (These numbers are SPI(shared peripheral interrupt) numbers, and there = are 16 SGI and 16 PPI before SPI, so we have to add 32 to get the INTID value(hwirq number)) =20 static const int a15irqmap[] =3D { [AB21Q_UART] =3D 1, [AB21Q_RTC] =3D 2, [AB21Q_PCIE] =3D 3, /* ... to 6 */ [AB21Q_GPIO] =3D 7, [AB21Q_SECURE_UART] =3D 8, [AB21Q_ACPI_GED] =3D 9, [AB21Q_MMIO] =3D 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [AB21Q_GIC_V2M] =3D 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [AB21Q_SMMU] =3D 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ [AB21Q_PLATFORM_BUS] =3D 112, /* ...to 112 + PLATFORM_BUS_NUM_IRQS = -1 */ [AB21Q_AXPU] =3D 15, }; =20 In the driver, when I do request_irq(32+15, axpu_irq_handler, = IRQF_SHARED, "axpu_irq", &axpu_cdev) for my device axpu, the /proc/interrupts' looks like this. See the 10th item(axpu_irq). =20 CPU0 1: 0 GICv3 25 Level vgic 3: 0 GICv3 30 Level kvm guest ptimer 4: 0 GICv3 27 Level kvm guest vtimer 5: 20432 GICv3 26 Level arch_timer 40: 0 GICv3 106 Edge arm-smmu-v3-evtq 43: 0 GICv3 109 Edge arm-smmu-v3-gerror 44: 0 GICv3 34 Level rtc-pl031 45: 164 GICv3 33 Level uart-pl011 46: 0 GICv3 23 Level arm-pmu 47: 7789 GICv3 36 Level virtio0, axpu_irq 48: 0 9030000.pl061 3 Edge GPIO Key Poweroff IPI0: 0 Rescheduling interrupts IPI1: 0 Function call interrupts IPI2: 0 CPU stop interrupts IPI3: 0 CPU stop (for crash dump) interrupts IPI4: 0 Timer broadcast interrupts IPI5: 0 IRQ work interrupts IPI6: 0 CPU wake-up interrupts Err: 0 =20 There are two numbers. One in the first column and the other in the 4th column. After observing uart-pl011 driver's action(who's irq in 8th row), I = found the number in the first column is the one I should pass to the = request_irq funcion, and the second number in the 4th column is the input to the GICv3. (uart was assigned SPI 1, so 32+1 =3D 33). In my axpu driver case, I requested request_irq(47, ...) so hwirq is 47 but I don't know why it was assigned to GICv3 input 36. Shouldn't it be 47 too? (32+15=3D47). =20 Without fixing QEMU code(still using SPI 15), I tried doing request_irq(15, axpu_irq_handler, ..) for test and this time it looks like this.(see = the 5th row) =20 CPU0 1: 0 GICv3 25 Level vgic 3: 0 GICv3 30 Level kvm guest ptimer 4: 0 GICv3 27 Level kvm guest vtimer 5: 8174 GICv3 26 Level arch_timer 15: 0 GICv3 56 Edge axpu_irq 40: 0 GICv3 106 Edge arm-smmu-v3-evtq 43: 0 GICv3 109 Edge arm-smmu-v3-gerror 44: 0 GICv3 34 Level rtc-pl031 45: 175 GICv3 33 Level uart-pl011 46: 0 GICv3 23 Level arm-pmu 47: 7790 GICv3 36 Level virtio0 48: 0 9030000.pl061 3 Edge GPIO Key Poweroff IPI0: 0 Rescheduling interrupts IPI1: 0 Function call interrupts IPI2: 0 CPU stop interrupts IPI3: 0 CPU stop (for crash dump) interrupts IPI4: 0 Timer broadcast interrupts IPI5: 0 IRQ work interrupts IPI6: 0 CPU wake-up interrupts Err: 0 =20 Now axpu_irq has moved to INTID 15 (as expected), but it changed to = "GICv3 56 Edge". How is this GICv3 number is assigned? (and I guess edge trigger is the default for INTID < 16. Because it's SGI..?) =20 I thought I connected my device (axpu) to SPI 15 in qemu code but this GICv3 input number changes according to with what number I called reqeust_irq. Could anyone tell me what is going on here? =20 Thank you. Chan Kim ------=_NextPart_000_06D2_01D84DF1.D38893B0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi Ozgur,

The SPI I meant was =E2=80=98shared peripheral = interrupt=E2=80=99 of armv8 architecture.

(the interrupt is shared among cores. The interrupt = controller distributes it)

I=E2=80=99ll look into your link when I=E2=80=99ll = be working with SPI (serial peripheral interface) later = :).

Thank you.

Chan

 

From:<= /b> Ozgur Kara = <ozgur@goosey.org>
Sent: Monday, April 11, 2022 10:10 = PM
To: Chan Kim <ckim@etri.re.kr>; 'qemu-discuss' = <qemu-discuss@nongnu.org>; = kernelnewbies@kernelnewbies.org
Subject: Re: Can't understand = /proc/interrupts output for GICv3 = case

 

Hello,

 

firstly when you say SPI so can you = give some more information about your = hardware?

I think you are doing an embedded = development in that case you should do some research on howto understand = SPI interface under the kernel.

 

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.

 

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.

 

Please attention some kernel = call:

 

- = request_irq

- irqsave()

- = irqrestore()

 

and maybe check out the = "Interrupt Handling" book and please read follow = website:

 

 

* Book (Understand the Linux = Kernel)

  - Section: Interrupt = Handling

 

Salut!

 

11.04.2022, 16:36, "Chan = Kim" <ckim@etri.re.kr>:

Hi,
nobody's replying to my question.. so sad..
I = found the kernel makes an array (actually a radix tree) of = 'irq_desc's.
And my hwirq (SPI 15) is assigned to one of these = irq_descs while processing
device tree.
In my case it was assigned = irq 6 (this irq is what is called virtual irq).
So I registered the = handler by request_irq(6,...) and the interrupt works
fine.
So now = my question is : how can find my irq number (correct irq_desc = number)
in kernel driver module?
I'll appreciate it if you could = tell me how to do it.
Thank you!

Chan = Kim
 

 -----Original = Message-----
 From: Chan Kim <ckim@etri.re.kr>
 Sent: = Friday, April 8, 2022 1:53 PM
 To: 'qemu-discuss' <qemu-discuss@nongnu.org>;<= br> kernelnewbies@kernelnewbi= es.org
 Subject: Can't understand /proc/interrupts output = for GICv3 case
 
 Hello all
 
 I think = I'm asking too many question recently but sometimes I get very = big
 help from here so please forgive me.
 (and I think = someone else can get help from this email thread) I'm = doing
 experiment for interrupt of a device called axpu on an = arm64 virtual
 machine.
 In QEMU virtual machine, the = interrupts are assigned as below.
 (These numbers are SPI(shared = peripheral interrupt) numbers, and there are
 16 SGI and 16 PPI = before SPI, so we have to add 32 to get the INTID
 value(hwirq = number))
 
 static const int a15irqmap[] =3D = {
     [AB21Q_UART] =3D = 1,
     [AB21Q_RTC] =3D = 2,
     [AB21Q_PCIE] =3D 3, /* ... to 6 = */
     [AB21Q_GPIO] =3D = 7,
     [AB21Q_SECURE_UART] =3D = 8,
     [AB21Q_ACPI_GED] =3D = 9,
     [AB21Q_MMIO] =3D 16, /* ...to 16 + = NUM_VIRTIO_TRANSPORTS - 1 = */
     [AB21Q_GIC_V2M] =3D 48, /* ...to 48 = + NUM_GICV2M_SPIS - 1 */
     [AB21Q_SMMU] = =3D 74, /* ...to 74 + NUM_SMMU_IRQS - 1 = */
     [AB21Q_PLATFORM_BUS] =3D 112, /* = ...to 112 + PLATFORM_BUS_NUM_IRQS -1 = */
     [AB21Q_AXPU] =3D = 15,
 };
 
 In the driver, when I do = request_irq(32+15, axpu_irq_handler, = IRQF_SHARED,
 "axpu_irq", &axpu_cdev) for my = device axpu, the /proc/interrupts' looks
 like this. See the = 10th = item(axpu_irq).
 
       &n= bsp;           &nb= sp;CPU0
          &n= bsp;1: 0 GICv3 25 Level = vgic
           = ;3: 0 GICv3 30 Level kvm guest = ptimer
          &nb= sp;4: 0 GICv3 27 Level kvm guest = vtimer
          &nb= sp;5: 20432 GICv3 26 Level = arch_timer
          = ;40: 0 GICv3 106 Edge = arm-smmu-v3-evtq
         = ; 43: 0 GICv3 109 Edge = arm-smmu-v3-gerror
        &nb= sp; 44: 0 GICv3 34 Level = rtc-pl031
          = 45: 164 GICv3 33 Level = uart-pl011
          = ;46: 0 GICv3 23 Level = arm-pmu
          47= : 7789 GICv3 36 Level virtio0, = axpu_irq
          4= 8: 0 9030000.pl061 3 Edge GPIO Key = Poweroff
         IPI0: = 0 Rescheduling = interrupts
         IPI1:= 0 Function call = interrupts
         IPI2:= 0 CPU stop = interrupts
         IPI3:= 0 CPU stop (for crash dump) = interrupts
         IPI4:= 0 Timer broadcast = interrupts
         IPI5:= 0 IRQ work = interrupts
         IPI6:= 0 CPU wake-up = interrupts
         Err: = 0
 
 There are two numbers. One in the first column and = the other in the 4th
 column.
 After observing = uart-pl011 driver's action(who's irq in 8th row), I found
 the = number in the first column is the one I should pass to the = request_irq
 funcion, and the second number in the 4th column is = the input to the

GICv3.

 (uart was assigned SPI 1, so = 32+1 =3D 33).
 In my axpu driver case, I requested = request_irq(47, ...) so hwirq is 47
 but I don't know why it was = assigned to GICv3 input 36.
 Shouldn't it be 47 too? = (32+15=3D47).
 
 Without fixing QEMU code(still using = SPI 15), I tried doing

request_irq(15,

 axpu_irq_handler, ..) for = test and this time it looks like this.(see = the
 5th
 row)
 
     = ;       CPU0
   1: = 0 GICv3 25 Level vgic
   3: 0 GICv3 30 Level kvm guest = ptimer
   4: 0 GICv3 27 Level kvm guest = vtimer
   5: 8174 GICv3 26 Level = arch_timer
  15: 0 GICv3 56 Edge = axpu_irq
  40: 0 GICv3 106 Edge = arm-smmu-v3-evtq
  43: 0 GICv3 109 Edge = arm-smmu-v3-gerror
  44: 0 GICv3 34 Level = rtc-pl031
  45: 175 GICv3 33 Level = uart-pl011
  46: 0 GICv3 23 Level = arm-pmu
  47: 7790 GICv3 36 Level = virtio0
  48: 0 9030000.pl061 3 Edge GPIO Key = Poweroff
 IPI0: 0 Rescheduling interrupts
 IPI1: 0 = Function call interrupts
 IPI2: 0 CPU stop = interrupts
 IPI3: 0 CPU stop (for crash dump) = interrupts
 IPI4: 0 Timer broadcast interrupts
 IPI5: 0 = IRQ work interrupts
 IPI6: 0 CPU wake-up = interrupts
 Err: 0
 
 Now axpu_irq has moved to = INTID 15 (as expected), but it changed to "GICv3
 56 = Edge".
 How is this GICv3 number is assigned? (and I guess = edge trigger is the
 default for INTID < 16. Because it's = SGI..?)
 
 I thought I connected my device (axpu) to SPI = 15 in qemu code but this
 GICv3 input number changes according = to with what number I called
 reqeust_irq.
 Could anyone = tell me what is going on here?
 
 Thank = you.
 Chan = Kim

------=_NextPart_000_06D2_01D84DF1.D38893B0-- --===============3608241624443479586== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============3608241624443479586==--