linux-device-driver

mmap very slow when using O_SYNC

ε祈祈猫儿з 提交于 2019-12-08 11:39:11
问题 Brief description of our project: We are using CycloneV in our project, FPGA will write data to DDR using AXI bus and our application needs to send the data out using Ethernet. We benchmark our Ethernet throughput using iperf and it can achieve a speed of about 700Mbps. When we test our application throughput, the result we are getting is just 400Mbps. We write a simple server code without using /dev/mem , then populate the memory with random data using dd command and the application reads

reserve system memory, ioremap()?

人走茶凉 提交于 2019-12-08 10:56:30
问题 Is it bad to call ioremap() on system DRAM. I would like to reserve a space in system DRAM that will not be used by any other process. Would this be the way to do it? I know that DRAM is not actually IO memory so I wasn't sure if this was considered bad practice. 回答1: Is it bad to call ioremap() on system DRAM. System memory that is managed by the kernel should not also be remapped using ioremap() . These multiple mappings can cause data corruption on some architectures/processors. Refer to

Where is the “Zero divide” done in kernel for Arm Cortex A-9

半城伤御伤魂 提交于 2019-12-08 08:56:16
问题 I am looking into kernel source code (2.6.35 ) for Zero divide . I inserted Zero divide in user space program and all threads stopped. So I want to know Where is the "Zero divide" done in kernel for Arm Cortex A-9? I am not able to find any trap for this .... Thanks 回答1: It depends on the architecture. Given the following user space code on an x86 system : main() { int x = 42 / 0; } the compiler inserts a idivl command into the object code. When this command is executed with a divisor of 0,

ioread32 followed by iowrite32 not giving same value

ぐ巨炮叔叔 提交于 2019-12-08 06:14:39
问题 I have started learning linux device drivers. I'm doing some sample programs as a part of my learning. To understand memory mapped IO I wrote the following code.(only init is shown here). There is no hardware mapped at the base address. static unsigned long base = 0xfed00000; unsigned long device_base=0; unsigned long virtual_base=0; static int __init sharedirqmodule_init(void) { u32 register1=0; u32 value=0x23456789; device_base=base; void *address=0; if(!request_mem_region(device_base,8,

How to validate/test/benchmark for the set of features on EXT4 filesystem

99封情书 提交于 2019-12-08 05:25:01
问题 I wanted to validate/test/benchmark set of features I have added to the ext4 kernel_tree/fs . I came across Spruce Linux file system driver verification. Especially for filesystem. The project is hosted @https://code.google.com/p/spruce/wiki/GettingStarted. and this is for x86. I work on arm target, and I have few questions before starting off. Has anybody worked on Spruce earlier. how to use Spruce project for ARM, Do we need to port for ARM? Is cross compilation straight forward or any

How usb OTG works(master/slave)

*爱你&永不变心* 提交于 2019-12-08 04:24:04
问题 A device has usb OTG Following is scenarios when a device connected to PC ,then device act as slave (how device knows it has to act as slave) when a device connected to printer ,then device act as master. (how device knows it has to act as master) what are the steps executed when device connected to OTG. how to implement this mechanism (in brief)? 回答1: The exact behavior of USB OTG devices is described in the specification you can find at usb.org. There is a PDF inside the zip called USB_OTG.

how to context switch in a kernel module thread?

不打扰是莪最后的温柔 提交于 2019-12-08 04:09:24
问题 I'm wondering if there is a way for a kernel module thread to switch its current mm. Kernel threads usually use the last mm that was active before it was scheduled. Is it possible to switch to a particular mm in a kernel thread? I'm looking for a linux equivalent to KeStackAttachProcess in windows. Context_switch() and switch_mm() are not exported so I'm wondering what I can use to switch context in my kernel module thread. 回答1: There is no such function available currently to switch context.

How do cdev and its associated file operation work?

橙三吉。 提交于 2019-12-08 03:07:26
Actually working on a PCI driver. I have two PCIe cards with same device ID and vendor ID. So to make a difference, I assign these two cards with two different MINOR numbers. //request for device numbers error = alloc_chrdev_region(&devt, 0, cards_found, DEVICE_NAME); if (error == 0) { major = MAJOR(devt); printk(KERN_INFO "(drv_init): MAJOR number is %d\n", major); printk(KERN_INFO "(drv_init): MINOR number range from 0 to %d\n", cards_found-1); cdevs = cdev_alloc(); cdevs->owner = THIS_MODULE; cdev_init(cdevs, fops); for(i=0;i<cards_found,i++) { devt = MKDEV(major, i); error = cdev_add(cdevs

MCP23017 I2C Device driver probe function is not called

ε祈祈猫儿з 提交于 2019-12-08 02:58:18
问题 I am using the following I2C/GPIO Device driver to access the MCP23017 GPIOs. With the insmod command I am able to load the driver and its listed in /proc/modules. I have two MCP23017 chips connected to my Raspberry Pi. Both are detected at addresses 0x20 and 0x21 . The initcall to the driver registers the driver. I checked this by printing out a message. But the driver probe function is not called. The devices are not opened/ cannot be located elsewhere. How is the probe function called?

When to use linux kernel add_timer vs queue_delayed_work

社会主义新天地 提交于 2019-12-08 02:49:46
问题 To schedule an action to happen later in a linux kernel driver I have 2 options: add_timer queue_delayed_work One difference I know about: for timers you need to specify expires which is the jiffies value when the timer will expire, for delayed work you need to specify the delay of jiffies. I've been reading other questions about timers and work_queue's, and it mentions timers run outside process context. Is this different from delayed work? Also I know there is an issue with timers, when