aes driver module

This forum is for users of Atmel's SAM Series and who are interested in using Linux OS.

Moderator: nferre

sama.m
Posts: 5
Joined: Mon Mar 24, 2014 8:36 am

aes driver module

Sun Nov 06, 2016 2:08 pm

hi,
i have ported an atmel aes driver from newer version 3.14 to work with kernel 2.6 in evaluation kit SAM9CN11.
the driver is loaded correctly and algorithms are registered in the kernel, but when i try to work with data more than 16 bytes which is the DMA threshold the system just hangs up, and the call back function is never called,i checked the configuration of DMA channels and addresses and nothing seems to be wrong. i found a similar issue in the following link but no exact solution was proposed or where might the problem be. discussions/viewtopic.php/p,39962.html#p39962

i hope if any one could provide any suggestion to solve this issue,,,
blue_z
Location: USA
Posts: 1496
Joined: Thu Apr 19, 2007 10:15 pm

Re: aes driver module

Wed Nov 09, 2016 2:31 am

sama.m wrote:i have ported an atmel aes driver from newer version 3.14 to work with kernel 2.6 in evaluation kit SAM9CN11.
Those are dubious choices.
Linux kernel 3.14 is presumably the mainline version? I don't recall Linux4SAM supporting 3.14.
Why not use 3.4.9-at91?
"2.6" is an imprecise kernel version number.
sama.m wrote:... the system just hangs up,,
That's really a summary or conclusion, rather than a description or observation.
If you can't even dump the device registers, then sprinkle printk()s in salient code.

Regards
sama.m
Posts: 5
Joined: Mon Mar 24, 2014 8:36 am

Re: aes driver module

Wed Jan 04, 2017 9:57 am

hello blue_z
"2.6" is an imprecise kernel version number.
the kernel we are working on is 2.6.39
https://github.com/linux4sam/linux-at91 ... .6.39-at91
and as you can see the tree doesn't contain atmel-aes.c

i tried again to port the latest atmel-aes.c from kernel 4.4
https://github.com/linux4sam/linux-at91 ... tmel-aes.c
but still the same result, i added alot of printk's to track where it hangs up exactly in function atmel_aes_dma_transfer_start , after submitting the job to read from DMA memory location to the AES_ODATAR register;

Code: Select all

static int atmel_aes_dma_transfer_start(struct atmel_aes_dev *dd,
                                        enum dma_slave_buswidth addr_width,
                                        enum dma_transfer_direction dir,
                                        u32 maxburst)
{
        struct dma_async_tx_descriptor *desc;
        struct dma_slave_config config;
        dma_async_tx_callback callback;
        struct atmel_aes_dma *dma;
        int err;

        memset(&config, 0, sizeof(config));
        config.direction = dir;
        config.src_addr_width = addr_width;
        config.dst_addr_width = addr_width;
        config.src_maxburst = maxburst;
        config.dst_maxburst = maxburst;

        switch (dir) {
        case DMA_MEM_TO_DEV:
                dma = &dd->src;
                callback = NULL;
                config.dst_addr = dd->phys_base + AES_IDATAR(0);
                break;

        case DMA_DEV_TO_MEM:
                dma = &dd->dst;
                callback = atmel_aes_dma_callback;
                config.src_addr = dd->phys_base + AES_ODATAR(0);
                break;

        default:
                return -EINVAL;
        }

        err = dmaengine_slave_config(dma->chan, &config);
        if (err)
                return err;
desc = dmaengine_prep_slave_sg(dma->chan, dma->sg, dma->sg_len, dir,
                                       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
        if (!desc)
                return -ENOMEM;

        desc->callback = callback;
        desc->callback_param = dd;
        dmaengine_submit(desc);
        dma_async_issue_pending(dma->chan);

        return 0;
}

here is the log of printk

Code: Select all

req->src ====== 0xc3ba7400 ////////////\\\\\\\ req->dst ========0xc3ba7400prep_slave_sg (1): FROM DEVICE f0x3
Dec 31 17:25:36 Wasil user.err kernel: saddr ==== reg ==== atslave->rx_reg ===== 0xf000c040
Dec 31 17:25:36 Wasil user.err kernel: DSCR = 0x23beb770
Dec 31 17:25:36 Wasil user.err kernel:  saddr = 0xf000c040    daddr = 0x23f20c80  ctrla = 0x22000008  ctrlb = 0x62400001 dscr = 0x23beb770 
Dec 31 17:25:36 Wasil user.err kernel:  saddr = 0xf000c040    daddr = 0x23f20c80  ctrla = 0x22000008  ctrlb = 0x62400001 dscr = 0x23beb770 
Dec 31 17:25:36 Wasil user.warn kernel: atc_tx_submit 
Dec 31 17:25:36 Wasil user.warn kernel: atc_dostart=======atc_dostart========= atc_dostart
Dec 31 17:25:36 Wasil user.err kernel: dma dma0chan7:   channel 7 : imr = 0xff00ff, chsr = 0xff0000
Dec 31 17:25:36 Wasil user.err kernel:   channel 7 : imr = 0xff00ff, chsr = 0xff0000
Dec 31 17:25:36 Wasil user.err kernel: dma dma0chan7:   channel: s0x0 d0x0 ctrl0x0:0x0 cfg0x200022ab l0x0
Dec 31 17:25:36 Wasil user.err kernel:   channel: s0x0 d0x0 ctrl0x0:0x0 cfg0x200022ab l0x0
Dec 31 17:25:36 Wasil user.warn kernel: clearing pending interrupts
Dec 31 17:25:36 Wasil user.warn kernel: after CPU_RELAX                      +-----------------------------+
Dec 31 17:25:36 Wasil user.err kernel: dma dma0chan7:   channel 7 : imr = 0xf|                             |
Dec 31 17:25:36 Wasil user.err kernel: dma dma0chan7:   channel: s0xf000c040 |  Cannot open /dev/ttyUSB0!  |510001 cfg0x200022ab l0x0
Dec 31 17:25:36 Wasil user.warn kernel: end of atc_dostart                   |                             |
Dec 31 17:25:36 Wasil user.warn kernel: atc_issue_pending                    +-----------------------------+
Dec 31 17:25:36 Wasil user.err kernel:   channel: s0xf000c040 d0x23f20c80 ctrl0x22000000:0x22510001 l0x0
Dec 31 17:25:36 Wasil user.warn kernel: atc_issue_pending DONE!!!
Dec 31 17:25:36 Wasil user.warn kernel: prep_slave_sg (1): TO DEVICE f0x3
Dec 31 17:25:36 Wasil user.err kernel: daddr ==== reg ==== atslave->tx_reg ===== 0xf000c050
Dec 31 17:25:36 Wasil user.err kernel: DSCR = 0x23b77660
Dec 31 17:25:36 Wasil user.err kernel:  saddr = 0x23f20c80    daddr = 0xf000c050  ctrla = 0x22000008  ctrlb = 0x62200010 dscr = 0x23b77661 
Dec 31 17:25:36 Wasil user.err kernel:  saddr = 0x23f20c80    daddr = 0xf000c050  ctrla = 0x22000008  ctrlb = 0x62200010 dscr = 0x23b77661 
Dec 31 17:25:36 Wasil user.warn kernel: atc_tx_submit 
Dec 31 17:25:36 Wasil user.warn kernel: atc_dostart=======atc_dostart========= atc_dostart
Dec 31 17:25:36 Wasil user.err kernel: dma dma0chan6:   channel 6 : imr = 0xff00ff, chsr = 0xff0080
Dec 31 17:25:36 Wasil user.err kernel:   channel 6 : imr = 0xff00ff, chsr = 0xff0080
Dec 31 17:25:36 Wasil user.err kernel: dma dma0chan6:   channel: s0x0 d0x0 ctrl0x0:0x0 cfg0x200022ab l0x0
Dec 31 17:25:36 Wasil user.err kernel:   channel: s0x0 d0x0 ctrl0x0:0x0 cfg0x200022ab l0x0
Dec 31 17:25:36 Wasil user.warn kernel: clearing pending interrupts
Dec 31 17:25:36 Wasil user.warn kernel: after CPU_RELAX
Dec 31 17:25:36 Wasil user.err kernel: dma dma0chan6:   channel 6 : imr = 0xff00ff, chsr = 0xff00c0
Dec 31 17:25:36 Wasil user.err kernel:   channel 6 : imr = 0xff00ff, chsr = 0xbf00c0
Dec 31 17:25:36 Wasil user.err kernel: dma dma0chan6:   channel: s0x23f20c80 d0xf000c050 ctrl0x22000004:0x22310010 cfg0x200022ab l0x0
Dec 31 17:25:36 Wasil user.err kernel:   channel: s0x23f20c80 d0xf000c050 ctrl0x22000004:0x22310010 cfg0x200022ab l0x0
Dec 31 17:25:36 Wasil user.warn kernel: end of atc_dostart
Dec 31 17:25:36 Wasil user.warn kernel: atc_issue_pending 
Dec 31 17:25:36 Wasil user.err kernel:   channel: s0x23f20c80 d0xf000c050 ctrl0x22000004:0x22310010 l0x0
Dec 31 17:25:36 Wasil user.warn kernel: atc_issue_pending DONE!!!
blue_z
Location: USA
Posts: 1496
Joined: Thu Apr 19, 2007 10:15 pm

Re: aes driver module

Fri Jan 06, 2017 9:15 pm

sama.m wrote:i tried again to port the latest atmel-aes.c from kernel 4.4
You're going in the wrong direction.
Trying to backport an even more recent version is less likely to be successful.
The driver-kernel interfaces are subject to change between releases, so going further away from the 2.6.39 version exposes you to more DKI changes.

You claim to be using the "evaluation kit SAM9CN11".
So why not build and test with a released Linux4SAM kernel?

Regards

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 1 guest