linux-device-driver

change smp_affinity from linux device driver

爷,独闯天下 提交于 2019-12-11 09:31:34
问题 If I examine the cat /proc/interrupts command, all the IRQs are listed under cpu0 in SMP system. I can change the smp_affinity mask to tag the IRQ to particular CPU using following command. echo "4" > /proc/irq/230/smp_affinity Above command sets the affinity mask of the interrupt 230 to CPU 2. I would like achieve same from linux kernel module. How can I do this? I see create_proc_entry method which allows to create new proc entry. Is there any method which we can use to write existing proc

Is there any alternative for ioctl() in linux to interact with nvme drives

纵饮孤独 提交于 2019-12-11 09:30:07
问题 I am working on a testing tool for nvme-cli(written in c and can run on linux). For SSD validation purpose, we are actually looking for sending I/O commands to a particular Submission queue(IO Queue pair). We needed this because we wanted threading, but for threading to happen we need to send I/O requests to different queues else the I/O requests would be processed serially. So is there any way in ioctl() where we can specify the Submission queue IDs? OR Is there other thing similar to ioctl(

mmap() device memory into user space

怎甘沉沦 提交于 2019-12-11 09:02:45
问题 Saying if we do a mmap() system call and maps some PCIE device memory (like GPU) into the user space, then application can access those memory region in the device without any OS overhead. Data can by copied from file system buffer directly to device memory without any other copy. Above statement must be wrong... Can anyone tell me where is the flaw? Thanks! 回答1: For a normal device what you have said is correct. If the GPU memory behaves differently for reads/write, they might do this. We

Stack frame for signal handling in the Linux Kernel

孤街醉人 提交于 2019-12-11 08:44:52
问题 I see that the stack frame the process needs to handle signals is allocated in the function setup_rt_frame() . My question is: where it is de-allocated? Thank you! 回答1: setup_rt_frame() sets stack for Real-time signals (see man 7 signal). It does 2 main things: Saves CPU context of user process (before it was interrupted) from kernel stack to user stack. For ARM architecture it's done in setup_sigframe(). Saves return address (where signal handler returns) to user stack. Return address will

How does ftrace track interrupt service routines?

血红的双手。 提交于 2019-12-11 07:04:32
问题 ftrace is used for function tracing of kernel. Now how does it work for interrupts. Can it track kernel functions in interrupt mode. If so can you explain how it works. I am trying to write a function that tracks function calls and it works fine in Supervisor mode but does not work in interrupt mode (goes into loop). I need to make it work in IRQ mode. 回答1: As in Linux kernel ARM exception stack init details, the amount of IRQ stack used by Linux is minimal. ARM has several banked registers

Basic device operations in spi driver

◇◆丶佛笑我妖孽 提交于 2019-12-11 06:59:19
问题 I need to write an spi driver for omap4 from scratch. I am referring http://lxr.free-electrons.com/source/drivers/spi/spi-omap2-mcspi.c driver code. But, I am unable to understand how basic device operations are handled in this driver code. For example a char driver has the structure struct file_operations scull_fops = { .owner = THIS_MODULE, .llseek = scull_llseek, .read = scull_read, .write = scull_write, .ioctl = scull_ioctl, .open = scull_open, .release = scull_release, }; containing the

Undefined reference to -finstrument-functions

帅比萌擦擦* 提交于 2019-12-11 06:54:21
问题 I am trying to trace kernel functions and I am using -finstrument-functions to do that, but I get undefined reference errors as below: arch/arm/kernel/elf.c:9: undefined reference to `__cyg_profile_func_enter' arch/arm/kernel/elf.c:13: undefined reference to `__cyg_profile_func_exit' arch/arm/kernel/built-in.o: In function `elf_set_personality': arch/arm/kernel/elf.c:42: undefined reference to `__cyg_profile_func_enter' arch/arm/kernel/elf.c:75: undefined reference to `__cyg_profile_func_exit

let me know the following regarding USB Modem plugin & plug out notification handler APIs or system calls in Linux

醉酒当歌 提交于 2019-12-11 06:28:16
问题 Please let me know the following regarding USB Modem plugin & plug out notification handler APIs or system calls in Linux : In my application I have to write a function which will receive notifications in the following scenarios : When a USB Modem is plugged in, I would like to receive a notification that a USB Modem is plugged in, any Linux system call or Linux kernel API is there to send these notifications, also along with notification if I receive additional information about that device,

Driver to Simulate Keypress

两盒软妹~` 提交于 2019-12-11 06:04:13
问题 i need to make a driver to emulate keypresses into a particular process in linux, can anyone help me with that? It doesn't need to be a driver, but i believe there's no other way to do it, the OS is running with no screen manager and is using directfb to handle input 回答1: try xdotool-- it's for writing mouse/keyboard macros. $ xdotool type "hello world" $ xdotool keydown x etc 回答2: If you have the proper permissions, then you can use any of the read()/write() commands to interact with an

wake_up_interruptible() is not waking up the processes sleeping on condition

百般思念 提交于 2019-12-11 05:38:39
问题 I am writing a sleepy driver. Here any process that tries to write to the device file should sleep for 'n' number of seconds supplied by the user. Reader process should wake up all the waiting processes. Writer code : printk("Invoking interruptible_timeout for device flag[%d] = %d\n", idn, flag[idn]); long ret = wait_event_interruptible_timeout(wq[idn],flag[idn]==1,sec*HZ)/HZ; //flag[idn]=0; printk("timeout returned : %d idn = %d\n", ret, idn) printk("writer : flag[%d] = %d\n", idn, flag[idn]