Welcome!

Open Source Cloud Authors: Yeshim Deniz, Liz McMillan, Pat Romanski, Elizabeth White, Zakia Bouachraoui

Related Topics: Open Source Cloud

Open Source Cloud: Article

Measuring Interrupt Latency on the RPX-CLLF

Measuring Interrupt Latency on the RPX-CLLF

This is an excerpt from Chapter 11 of Embedded Linux by Craig Hollabaugh, published by Addison-Wesley. ISBN 0672322269. No part of this excerpt may be reproduced, in any form or by any means without the prior written permission of the publisher. (c) 2002 Addison-Wesley

The Project Trailblazer engineers want to use embedded Linux for race timing to reduce data entry errors, increase efficiency and enhance the racers' experience.

This chapter series explores using Linux as an event timer with 1-millisecond resolution. In Part 1 we discussed Linux timing sources and interrupt latency. Part 2 covered measuring interrupt latency on the MZ104, and Part 3 was about measuring interrupt latency on the MediaEngine. In this part we discuss measuring interrupt latency on the RPX-CLLF.

The RPX-CLLF's MPC860 has seven external interrupt pins. The Project Trailblazers want to drive IRQ2 with PA0, so they configure the interrupt controller for IRQ2 rising-edge operation. Asserting PA0 should generate Interrupt 2. Figure 5 shows the interrupt signal connection between the RPX-CLLF's PA0 and IRQ2 and the oscilloscope.

Listing 3 shows the source code for the interrupt_latency_rpxcllf.c device driver.

The interrupt_latency_rpxcllf.c device driver performs steps similar to those of the interrupt_latency_x86.c device driver. However, significant differences exist between the x86 and PowerPC interrupt controllers. The request_8xxirq function is a specialized PowerPC 8xx version of request_irq. request_8xxirq sets all the required MPC860 interrupt registers. When using an 8xx processor, you must explicitly call the request_8xxirq function. The following console output shows an instantaneous latency test result for the RPX-CLLF target board:

bash-2.04# insmod interrupt_latency_rpxcllf.o SIEL = 0x08000000
interrupt_latency_rpxcllf 1.0 initialized bash-2.04# cat/proc/interrupts

CPU0
3:08xx SIUEdgefec
4:08xx SIUEdgeinterrupt_latency
5:31118xx SIUEdgecpm
15:08xx SIUEdgetbint
BAD:0
bash-2.04# cat /proc/interrupt_latency
Start 112.477152
Finish 112.477187
Latency 35
Count 1

The /proc/interrupts file shows that the interrupt_latency routine is registered on Interrupt 4, not on Interrupt 2. This kernel version incorrectly reports interrupt values. The /proc/interrupt_latency file shows an instantaneous latency of 35ms. Figure 6 shows an oscilloscope capture of the interrupt signal.

The interrupt signal measurement shows a latency of 30.75ms, whereas the driver returns a calculated latency of 35ms. Code execution accounts for the 4.25ms discrepancy. As with the x86, this discrepancy is not a factor in the race timer.

The Project Trailblazer engineers calculated the RPX-CLLF's average interrupt latency to be approximately 35ms. The PowerPC version of the do_gettimeofday function has near microsecond accuracy.

Interrupt Latency Test Summary
The MZ104, the MediaEngine, and the RPX-CLLF exhibit fast average interrupt latencies, and their do_gettimeofday functions return near-microsecond accuracy. By using the interrupt latency device drivers and an oscilloscope, the engineers found the average interrupt latency for the MZ104, the MediaEngine, and the RPX-CLLF to be 50ms, 10ms, and 35ms, respectively. With average interrupt latencies at or below 50ms, each target board is capable of providing millisecond timing accuracy for the race timer. The engineers breathe a sign of relief because they feared that they would have to move to a real-time solution, such as RTLinux or Real Time Application Interface (RTAI), which would mean a significant increase in their development time. However, the stock Linux kernel running on the Project Trailblazer target boards provides their required functionality. The engineers are now ready to tackle the design of the race timer.

In my next and last part we'll go over implementing the race timer.

Listing 3: The interrupt_latency_rpxcllf.c Device Driver

/*
* interrupt_latency_rpxcllf v1.0 11/25/01
* www.embeddedlinuxinterfacing.com
*
* The original location of this code is
* http://www.embeddedlinuxinterfacing.com/chapters/11/
*
* Copyright (C) 2001 by Craig Hollabaugh
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/*
* interrupt_latency_rpxcllf.c is based on procfs_example.c by Erik Mouw.
* For more information, please see, The Linux Kernel Procfs Guide, Erik Mouw
* http://kernelnewbies.org/documents/kdoc/procfs-guide/lkprocfsguide.html
*/

/*
powerpc-linux-gcc -O2 -D__KERNEL__ -DMODULE -I/usr/src/powerpc-linux/include \
-c interrupt_latency_rpxcllf.c \
-o /tftpboot/powerpc-rootfs/tmp/interrupt_latency_rpxcllf.o
*/

/* interrupt_latency_rpxcllf
* This module measures instantaneous interrupt latency of the RPX-CLLF
* using PA0 and IRQ2. Configure the SIU for IRQ2 edge interrupt
* generation. Configure PA0 as an output
then setting PA0 causes a
* rising edge that generates the interrupt.
*
* Section 11.5.1 of Motorola MPC860 PowerQUICC User's Manual
*
* After module insertion, reading /proc/interrupt_latency will assert PA0
* generating the interrupt. The interrupt handler will deassert this signal.
* View on scope. An interrupt counter is included to help debug noisy a
* interrupt line.
*/

#include
#include
#include
#include

#include

#include
#include
#include
#include
#include

#define MODULE_VERSION "1.0"
#define MODULE_NAME "interrupt_latency_rpxcllf"

volatile immap_t *immap;
static void *io_base;

#define PA0 0x8000
#define SIEL_ED2 0x08000000

int interruptcount = 0;
#define INTERRUPT SIU_IRQ2

struct timeval tv1, tv2; /* do_gettimeofday fills these */

static struct proc_dir_entry *interrupt_latency_file;

/*
* function interrupt_interrupt_latency
* This function is the interrupt handler for interrupt 2. It sets the tv2
* structure using do_gettimeofday. It then clears PA0.
*/
void interrupt_interrupt_latency(int irq, void *dev_id, struct pt_regs *regs)
{
do_gettimeofday(&tv2);
immap->im_ioport.iop_padat |= PA0; /* deassert the interrupt signal */
interruptcount++;
}

/*
* function proc_read_interrupt_latency
* The kernel executes this function when a read operation occurs on
* /proc/interrupt_latency. This function sets the tv1 structure. It asserts
* PA0 which should immediately cause interrupt 2 to occur. The handler
* records tv2 and deasserts PA0. This function returns the time
* differential between tv2 and tv1.
*/
static int proc_read_interrupt_latency(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;

do_gettimeofday(&tv1);
immap->im_ioport.iop_padat &= ~PA0; /* assert the interrupt signal */

len = sprintf(page, "Start %9i.%06i\nFinish %9i.%06i\nLatency %16i\n\
Count %18i\n",(int) tv1.tv_sec, (int) tv1.tv_usec,
(int) tv2.tv_sec, (int) tv2.tv_usec,
(int) (tv2.tv_usec - tv1.tv_usec),
interruptcount);

return len;
}

/*
* function init_interrupt_latency
* This function creates the /proc directory entry interrupt_latency. It
* requests interrupt 2 from Linux then configures the interrupt controller.
*/
static int __init init_interrupt_latency(void)
{
unsigned long r;
int rv = 0;

interrupt_latency_file = create_proc_entry("interrupt_latency", 0444, NULL);
if(interrupt_latency_file == NULL) {
return -ENOMEM;
}

interrupt_latency_file->data = NULL;
interrupt_latency_file->read_proc = &proc_read_interrupt_latency;
interrupt_latency_file->write_proc = NULL;
interrupt_latency_file->owner = THIS_MODULE;

/* request interrupt from linux */
rv = request_8xxirq(INTERRUPT, interrupt_interrupt_latency, 0,
"interrupt_latency",NULL);
if ( rv ) {
printk("Can't get interrupt %d\n", INTERRUPT);
goto no_interrupt_latency;
}

/* get the IMMAP register address */
immap = (immap_t *)(mfspr(IMMR) & 0xFFFF0000);
immap->im_ioport.iop_papar &= ~PA0; /* set PA0 to general I/O */
immap->im_ioport.iop_padir |= PA0; /* set PA0 as output */

/* set IRQ2 to edge triggering */
immap->im_siu_conf.sc_siel |= SIEL_ED2;
printk("SIEL = 0x%08X\n",immap->im_siu_conf.sc_siel);

immap->im_ioport.iop_padat |= PA0; /* deassert the interrupt signal */

/* everything initialized */
printk(KERN_INFO "%s %s initialized\n",MODULE_NAME, MODULE_VERSION);
return 0;

no_interrupt_latency:
remove_proc_entry("interrupt_latency", NULL);
}

/*
* function cleanup_interrupt_latency
* This function frees interrupt 2 then removes the
* /proc directory entry interrupt_latency.
*/
static void __exit cleanup_interrupt_latency(void)
{
free_irq(INTERRUPT,NULL); /* free the interrupt */

remove_proc_entry("interrupt_latency", NULL);

printk(KERN_INFO "%s %s removed\n", MODULE_NAME, MODULE_VERSION);
}

module_init(init_interrupt_latency);
module_exit(cleanup_interrupt_latency);

MODULE_AUTHOR("Craig Hollabaugh");
MODULE_DESCRIPTION("interrupt_latency proc module");

EXPORT_NO_SYMBOLS;

More Stories By Maureen O'Gara

Maureen O'Gara the most read technology reporter for the past 20 years, is the Cloud Computing and Virtualization News Desk editor of SYS-CON Media. She is the publisher of famous "Billygrams" and the editor-in-chief of "Client/Server News" for more than a decade. One of the most respected technology reporters in the business, Maureen can be reached by email at maureen(at)sys-con.com or paperboy(at)g2news.com, and by phone at 516 759-7025. Twitter: @MaureenOGara

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
DXWorldEXPO LLC announced today that ICOHOLDER named "Media Sponsor" of Miami Blockchain Event by FinTechEXPO. ICOHOLDER gives detailed information and help the community to invest in the trusty projects. Miami Blockchain Event by FinTechEXPO has opened its Call for Papers. The two-day event will present 20 top Blockchain experts. All speaking inquiries which covers the following information can be submitted by email to [email protected] Miami Blockchain Event by FinTechEXPOalso offers sp...
Headquartered in Plainsboro, NJ, Synametrics Technologies has provided IT professionals and computer systems developers since 1997. Based on the success of their initial product offerings (WinSQL and DeltaCopy), the company continues to create and hone innovative products that help its customers get more from their computer applications, databases and infrastructure. To date, over one million users around the world have chosen Synametrics solutions to help power their accelerated business or per...
DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time t...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...
Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
Machine learning has taken residence at our cities' cores and now we can finally have "smart cities." Cities are a collection of buildings made to provide the structure and safety necessary for people to function, create and survive. Buildings are a pool of ever-changing performance data from large automated systems such as heating and cooling to the people that live and work within them. Through machine learning, buildings can optimize performance, reduce costs, and improve occupant comfort by ...
SYS-CON Events announced today that IoT Global Network has been named “Media Sponsor” of SYS-CON's @ThingsExpo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. The IoT Global Network is a platform where you can connect with industry experts and network across the IoT community to build the successful IoT business of the future.
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.