This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Enabling EDMA transfer completion interrupt in a Linux kernel module



Hello,

I am trying to trigger interrupts from a DMA transfer completion in EVM K2H but cannot configure it right.

I have written a character device kernel module for servicing all the interrupts and it works fine already for GPIO. Next I began to add the DMA support on it, but I receive:

genirq Flags mismatch irq 315. 00000080 (MyInterrupt) vs. 00000000 (2530000.i2c)


According to the K2H data sheet, 315 should be the IRQ for the EDMA0 channel 0 completion. I have also tried with 314 which should be global completion interrupt for EDMA0, but it does nothing, not even any error. Should I use some mapping from HW IRQ to Linux interrupt numbering? This is done for the GPIO, see my code below.

When I trigger the DMA transfer on channel 0, the data is copied right and the IPR register bit 0 sets to "1" as expected. Only the interrupt handler is not called.

With the GPIO I do it like this:

    static irqreturn_t r_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
    {

// my interrupt handler, this is called when I do a pulse into the pin, so it works perfectly

// however, with the EDMA this is never called

    }

To achieve the above I configure the GPIO interrupt for pin 0 like this:

    gpio_request(0, "MyInterrupt"); // GPIO pin 0

    // This returns 540 although it is 120 in the K2H data sheet:
    irq_any_gpio = gpio_to_irq(0); // interrupt number for GPIO pin 0

    request_irq(irq_any_gpio, (irq_handler_t ) r_irq_handler, IRQF_TRIGGER_FALLING, "MyInterrupt", "/dev/mydevice");

    irq_set_irq_type(irq_any_gpio, IRQ_TYPE_EDGE_FALLING);

So far so good!

Then I do it for the EDMA in a somewhat similar way:

    irq_edma = 315; // According to the data sheet this is EDMACC_0_TC_0 for ARM CorePac
        // When calling request_irq this produces the error "genirq Flags mismatch irq 315. 00000080 (MyInterrupt) vs. 00000000 (2530000.i2c)" Why "I2C" ??? Is 315 mapped to I2C instead of EDMA?
//    irq_edma = 314; // According to the data sheet this is EDMACC_0_GINT, for ARM CorePac, When calling request_irq this does not give any errors but does not work either
    request_irq(irq_edma, (irq_handler_t ) r_irq_handler_edma, IRQF_SHARED, "MyInterrupt", "/dev/mydevice");

//    irq_set_irq_type(irq_edma, IRQ_TYPE_NONE); // I do not know if this is needed for EDMA interrupts. It gives errors about the 2nd parameter if tried to do so.

Please give me some advice.

Best regards,

Ari

  • Hi,

    Thanks for your post.

    Is your TR programmed for normal completion or early completion? Did you configured EDMA for chain triggered transfer? Usually the TR packets from EDMA CC would be queued in the TC and would be serviced based on priority mechanism. Please check the TCCMODE bit field of OPT and see Table 2-3 from the below doc:

    http://www.ti.com/lit/ug/sprugs5b/sprugs5b.pdf

    In case, if TR is programmed for early completion, it should be quite normal since the transfer is considered to be complete after the EDMACC submits a TR to the EDMATC but the TC may still be transferring the data and in this mode, the channel controller would generate the TCC internally which indicates the transfer is said to be complete but the actual transfer would be still in progress.

    Thanks & regards,

    Sivaraj K

    ------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    -------------------------------------------------------------------------------------------------------

  • Hello and thanks for a quick reply!

    I have programmed my transfer so that it requires 16 triggers before it completes. The interrupt is generated after the 16th trigger only. The transfer is not a chained one. Here are the PaRAM values which affect on these:

    PaRAM.OPT = 0x001000004

    ...

    PaRAM.CCNT = 16

    All the data is transferred just perectly from location A to location B, so the transfer itself works perfectly and the interrupt pending bit rises from 0 to 1 (IPR register bit 0).

    I have ported the code I use from my earlier project written for DM6443 DaVinci, so I know for 100% there is nothing wrong in the DMA register configuration. In DaVinci I got the interrupts exactly I am expecting them to come now with the Keystone II K2H.

    What I suspect the most is that there is some mapping between HW IRQ numbers and Linux IRQ numbers, since there is such a mapping with the GPIO interrupts which I already got working.

    WIth the GPIO the HW IRQ 120 (GPIO0) had to be converted to 540. I guess something similar must be done for the EDMA IRQ as well. I have read documents, sample codes, driver codes and discussion forums for days, but ended up with nothing. I still continue that.

    I will double check this by giving it some more (say 100 000) triggers to be sure there are enough of them. :-) But like I said, it works with only 16 triggers in DaVinci. Both DaVinci and Keystone II use the same EDMA3, right? At least I have not notices any difference in them.

    Best regards,

    Ari

  • Hi,

    I believe you are right. Both Davinci and keystone devices use the same EDMA3

    For references, shared below the EDMA user guide for davinci DM646x and keystone devices:

    http://www.ti.com/lit/ug/sprueq5b/sprueq5b.pdf
    http://www.ti.com/lit/ug/sprugs5b/sprugs5b.pdf

    Thanks & regards,
    Sivaraj K

    ------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    -------------------------------------------------------------------------------------------------------

  • Hi,

    could you please simply tell me if there is a mapping for the EDMA interrupt in the keystone Linux kernel or not?

    I can probably find it myself within some days, but I am sure somebody there can tell me that straight away.

    In my previous emails I tried to point out that for the GPIO interrupt there is a mapping from HW IRQ 120 ---> to Linux IRQ 540. So in my C code I have to use "540" instead of "120".

    Now I want to know if there is a similar mapping for the EDMA interrupt HW IRQ 315.

    With the above mapping my GPIO interrupts work OK, but the EDMA interrupt does not yet work.

    Best regards,

    Ari

  • Hi,

    some more questions came to my mind:

    1. Do I need some how to enable the EDMA interrupts and then recompile and upgrade the kernel or should they be enabled already by default in the EVM?

    2. Do I need to add something into the devicetree to make the EDMA working?

    I am using the EVM K2H board revision 4.0.

    Linux version 3.8.4 (gtbldadm@ubuntu-12) (gcc version 4.7.3 20130
    226 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.03-20130313 - Linaro GCC 2
    013.03) ) #1 SMP Fri Aug 16 17:51:01 EDT 2013

    Typing cat /proc/interrupts

    gives me the following:


               CPU0       CPU1       CPU2       CPU3
     29:          0          0          0          0       GIC  arch_timer
     30:      47231      47228      47224      47213       GIC  arch_timer
     80:          0          0          0          0       GIC  hwqueue-8704
     81:          0          0          0          0       GIC  hwqueue-8705
     82:         13          0          0          0       GIC  hwqueue-8706
     83:          0          0          0          0       GIC  hwqueue-8707
     84:          0          0          0          0       GIC  hwqueue-8708
     88:          0          0          0          0       GIC  hwqueue-8712
     89:          0          0          0          0       GIC  hwqueue-8713
    248:         23          0          0          0       GIC  hwqueue-acc-37
    309:       4010          0          0          0       GIC  serial
    315:          0          0          0          0       GIC  2530000.i2c0
    318:          0          0          0          0       GIC  2530400.i2c1
    321:          0          0          0          0       GIC  2530800.i2c2
    324:          6          0          0          0       GIC  21000400.spi
    520:          0          0          0          0  keystone-ipc-irq  2620040.dsp0

    521:          0          0          0          0  keystone-ipc-irq  2620044.dsp1

    522:          0          0          0          0  keystone-ipc-irq  2620048.dsp2

    523:          0          0          0          0  keystone-ipc-irq  262004c.dsp3

    524:          0          0          0          0  keystone-ipc-irq  2620050.dsp4

    525:          0          0          0          0  keystone-ipc-irq  2620054.dsp5

    526:          0          0          0          0  keystone-ipc-irq  2620058.dsp6

    527:          0          0          0          0  keystone-ipc-irq  262005c.dsp7

    608:          0          0          0          0      DWC3  xhci-hcd:usb1
    IPI0:          0          0          0          0  CPU wakeup interrupts
    IPI1:          0          0          0          0  Timer broadcast interrupts
    IPI2:       2763       2097        545       1594  Rescheduling interrupts
    IPI3:         31         29         33          6  Function call interrupts
    IPI4:          2          4          0         10  Single function call interrup
    ts
    IPI5:          0          0          0          0  CPU stop interrupts
    Err:          0

    3. What are these? Are they only for the DSP cores (CPU0 - CPU3)? If so, how can I see the ARM interrupts?

    Typing ls /proc/irq/

    gives me the following:
    100                   265                   425
    101                   266                   426
    102                   267                   427
    103                   268                   428
    104                   269                   429
    105                   27                    43
    106                   270                   430
    107                   271                   431
    108                   272                   432
    109                   273                   433
    110                   274                   434
    111                   275                   435
    112                   276                   436
    113                   277                   437
    114                   278                   438
    115                   279                   439
    116                   28                    44
    117                   280                   440
    118                   281                   441
    119                   282                   442
    120                   283                   443
    121                   284                   444
    122                   285                   445
    123                   286                   446
    124                   287                   447
    125                   288                   448
    126                   289                   449
    127                   29                    45
    128                   290                   450
    129                   291                   451
    130                   292                   452
    131                   293                   453
    132                   294                   454
    133                   295                   455
    134                   296                   456
    135                   297                   457
    136                   298                   458
    137                   299                   459
    138                   30                    46
    139                   300                   460
    140                   301                   461
    141                   302                   462
    142                   303                   463
    143                   304                   464
    144                   305                   465
    145                   306                   466
    146                   307                   467
    147                   308                   468
    148                   309                   469
    149                   31                    47
    150                   310                   470
    151                   311                   471
    152                   312                   472
    153                   313                   473
    154                   314                   474
    155                   315                   475
    156                   316                   476
    157                   317                   477
    158                   318                   478
    159                   319                   479
    16                    32                    48
    160                   320                   480
    161                   321                   481
    162                   322                   482
    163                   323                   483
    164                   324                   484
    165                   325                   485
    166                   326                   486
    167                   327                   487
    168                   328                   488
    169                   329                   489
    17                    33                    49
    170                   330                   490
    171                   331                   491
    172                   332                   492
    173                   333                   493
    174                   334                   494
    175                   335                   495
    176                   336                   496
    177                   337                   497
    178                   338                   498
    179                   339                   499
    18                    34                    50
    180                   340                   500
    181                   341                   501
    182                   342                   502
    183                   343                   503
    184                   344                   504
    185                   345                   505
    186                   346                   506
    187                   347                   507
    188                   348                   508
    189                   349                   509
    19                    35                    51
    190                   350                   510
    191                   351                   511
    192                   352                   512
    193                   353                   513
    194                   354                   514
    195                   355                   515
    196                   356                   516
    197                   357                   517
    198                   358                   518
    199                   359                   519
    20                    36                    52
    200                   360                   520
    201                   361                   521
    202                   362                   522
    203                   363                   523
    204                   364                   524
    205                   365                   525
    206                   366                   526
    207                   367                   527
    208                   368                   528
    209                   369                   529
    21                    37                    53
    210                   370                   530
    211                   371                   531
    212                   372                   532
    213                   373                   533
    214                   374                   534
    215                   375                   535
    216                   376                   536
    217                   377                   537
    218                   378                   538
    219                   379                   539
    22                    38                    54
    220                   380                   55
    221                   381                   56
    222                   382                   57
    223                   383                   58
    224                   384                   59
    225                   385                   60
    226                   386                   608
    227                   387                   61
    228                   388                   62
    229                   389                   63
    23                    39                    64
    230                   390                   65
    231                   391                   66
    232                   392                   67
    233                   393                   68
    234                   394                   69
    235                   395                   70
    236                   396                   71
    237                   397                   72
    238                   398                   73
    239                   399                   74
    24                    40                    75
    240                   400                   76
    241                   401                   77
    242                   402                   78
    242                   402                   78
    244                   404                   80
    245                   405                   81
    246                   406                   82
    247                   407                   83
    248                   408                   84
    249                   409                   85
    25                    41                    86
    250                   410                   87
    251                   411                   88
    252                   412                   89
    253                   413                   90
    254                   414                   91
    255                   415                   92
    256                   416                   93
    257                   417                   94
    258                   418                   95
    259                   419                   96
    26                    42                    97
    260                   420                   98
    261                   421                   99
    262                   422                   default_smp_affinity
    263                   423
    264                   424

    4. What are these IRQ numbers? I cannot see there the GPIO IRQ 540 which already works for me. Instead, IRQ 120 is included. So are these the supported HW IRQ numbers?

    Best regards,

    Ari

  • Hello!

    One more question:
    Do I need somehow to program CICs registers in order to map the HW interrupt to my SW?

    Best regards,
    Ari