Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - i.mx6 network driver with InterruptLock() ???: (6 Items)
   
i.mx6 network driver with InterruptLock() ???  
Hi,

I was looking at the latest changes, to merge any bugfixes to our BSP-Tree.

Can somebody remove this buggy Interrupt spinlocks, please?

Regards 
Michwel 

//
// all three hardware interrupt sources are handled here
//
int
mx6q_process_interrupt(void *arg, struct nw_work_thread *wtp)
{
        mx6q_dev_t      *mx6q   = arg;
        uint32_t        *base           = mx6q->reg;
        uint32_t        ievent;

        InterruptLock(&mx6q->spinner);
        for (;;) {

                // read interrupt cause bits
                ievent = *(base + MX6Q_IEVENT);  

                if (mx6q->cfg.verbose > 6) {
                        log(LOG_ERR, "%s(): ievent 0x%X\n", __FUNCTION__, ievent);
                }

                if (!ievent) {
                        break;
                }

                *(base + MX6Q_IEVENT) = ievent; 

                if ((ievent & (IEVENT_RFINT | IEVENT_RXB)) != 0) {
                        mx6q_receive(mx6q, wtp);
                }
                if ((ievent & IEVENT_TS_AVAIL) != 0) {
                        mx6q_transmit_complete(mx6q);
                }
                if ((ievent & IEVENT_TS_TIMER) != 0) {
                        mx6q->rtc++;
                }
        }
        InterruptUnlock(&mx6q->spinner);

        return 1;
}
RE: i.mx6 network driver with InterruptLock() ???  
I would agree, this is too heavy with InterruptLock, and the lock is too long, with some kernel calls(for example the 
log() will have kernel calls) when holding the lock.


-----Original Message-----
From: Michael Tasche [mailto:community-noreply@qnx.com] 
Sent: Monday, March 10, 2014 7:24 AM
To: drivers-networking
Subject: i.mx6 network driver with InterruptLock() ???

Hi,

I was looking at the latest changes, to merge any bugfixes to our BSP-Tree.

Can somebody remove this buggy Interrupt spinlocks, please?

Regards
Michwel 

//
// all three hardware interrupt sources are handled here // int mx6q_process_interrupt(void *arg, struct nw_work_thread 
*wtp) {
        mx6q_dev_t      *mx6q   = arg;
        uint32_t        *base           = mx6q->reg;
        uint32_t        ievent;

        InterruptLock(&mx6q->spinner);
        for (;;) {

                // read interrupt cause bits
                ievent = *(base + MX6Q_IEVENT);  

                if (mx6q->cfg.verbose > 6) {
                        log(LOG_ERR, "%s(): ievent 0x%X\n", __FUNCTION__, ievent);
                }

                if (!ievent) {
                        break;
                }

                *(base + MX6Q_IEVENT) = ievent; 

                if ((ievent & (IEVENT_RFINT | IEVENT_RXB)) != 0) {
                        mx6q_receive(mx6q, wtp);
                }
                if ((ievent & IEVENT_TS_AVAIL) != 0) {
                        mx6q_transmit_complete(mx6q);
                }
                if ((ievent & IEVENT_TS_TIMER) != 0) {
                        mx6q->rtc++;
                }
        }
        InterruptUnlock(&mx6q->spinner);

        return 1;
}




_______________________________________________

Networking Drivers
http://community.qnx.com/sf/go/post109296
To cancel your subscription to this discussion, please e-mail drivers-networking-unsubscribe@community.qnx.com
Re: RE: i.mx6 network driver with InterruptLock() ???  
The lock in itself is not buggy, it is needed to guard the rtc increment against a ptp set command. It should be moved 
in to just that part. I'll fix it.
RE: RE: i.mx6 network driver with InterruptLock() ???  
If it's only the rtc, why not use atomic_*


-----Original Message-----
From: Nick Reilly [mailto:community-noreply@qnx.com] 
Sent: Monday, March 10, 2014 9:43 AM
To: drivers-networking
Subject: Re: RE: i.mx6 network driver with InterruptLock() ???

The lock in itself is not buggy, it is needed to guard the rtc increment against a ptp set command. It should be moved 
in to just that part. I'll fix it.



_______________________________________________

Networking Drivers
http://community.qnx.com/sf/go/post109303
To cancel your subscription to this discussion, please e-mail drivers-networking-unsubscribe@community.qnx.com
Re: RE: RE: i.mx6 network driver with InterruptLock() ???  
It needs to not only be an atomic operation here, the setting of the time also needs to be atomic:

void mx6q_ptp_set_cnt (mx6q_dev_t *mx6q, ptp_time_t cnt)
{
    volatile uint32_t *base = mx6q->reg;

    InterruptLock(&mx6q->spinner);
    mx6q->rtc = cnt.sec;
    *(base + MX6Q_TIMER_VALUER) = cnt.nsec;
    InterruptUnlock(&mx6q->spinner);
}

By removing the lock and changing the ISR to an increment, it could run between the set of the rtc and the set of the 
hardware.

But I've just realised the original block is the process interrupt function rather than the ISR itself. I can replace 
all this with a mutex which will typically not be contested so nice and fast.
Re: RE: i.mx6 network driver with InterruptLock() ???  
If you need it, use pthread_mutex_lock().

We do not have a synchronisation against IRQ-Level.
=> InterruptLock is not needed!

-Michael